/* botty-payment หน้าจัดการ · สีหลักสีเดียว (น้ำเงินหมึก) · ตัวเลขเงินแบบสมุดบัญชี: บาทใหญ่ สตางค์เล็ก ชิดขวา */
:root {
  --paper: #f2f4f6; --surface: #ffffff; --sunk: #f7f8fa; --line: #dde2e8; --line-strong: #c5cdd6;
  --ink: #17202b; --muted: #5d6876; --faint: #8a94a1;
  --blue: #1d5bbf; --blue-soft: #e6eefb; --blue-ink: #ffffff;
  --in: #0e7a4e; --out: #b3261e; --warn: #9a5b00; --warn-soft: #fdf1dc; --bad-soft: #fbe7e5; --ok-soft: #e2f4ea;
  --r: 8px; --font: 'IBM Plex Sans Thai', 'Noto Sans Thai', 'Sarabun', system-ui, sans-serif;
}
:root[data-theme="dark"] {
  --paper: #10151c; --surface: #18202a; --sunk: #141b24; --line: #2a3542; --line-strong: #3a4757;
  --ink: #e8edf2; --muted: #a2adba; --faint: #7a8696;
  --blue: #6ea2ff; --blue-soft: #1d2c45; --blue-ink: #0d1420;
  --in: #4cc98f; --out: #ff8a80; --warn: #f0b35a; --warn-soft: #33281a; --bad-soft: #3a2220; --ok-soft: #173326;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #10151c; --surface: #18202a; --sunk: #141b24; --line: #2a3542; --line-strong: #3a4757;
    --ink: #e8edf2; --muted: #a2adba; --faint: #7a8696;
    --blue: #6ea2ff; --blue-soft: #1d2c45; --blue-ink: #0d1420;
    --in: #4cc98f; --out: #ff8a80; --warn: #f0b35a; --warn-soft: #33281a; --bad-soft: #3a2220; --ok-soft: #173326;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); }
body { font: 15px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }

/* โครงหน้า: เมนูซ้าย + เนื้อหา */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.brand { padding: 0 10px 18px; }
.brand b { display: block; font-size: 17px; letter-spacing: -.01em; }
.brand span { color: var(--muted); font-size: 13px; }
.nav { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r); color: var(--ink); font-size: 14.5px; }
.nav:hover { background: var(--sunk); text-decoration: none; }
.nav.on { background: var(--blue-soft); color: var(--blue); font-weight: 600; }
.nav .n { margin-left: auto; background: var(--out); color: #fff; border-radius: 999px; font-size: 12px; padding: 0 7px; line-height: 20px; font-weight: 600; }
.side .grow { flex: 1; }
.side .who { padding: 10px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); margin-top: 8px; overflow-wrap: anywhere; }
main { padding: 28px 32px 64px; min-width: 0; max-width: 1240px; }
.head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.head h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; font-weight: 650; }
.head .sub { color: var(--muted); font-size: 14px; width: 100%; margin-top: -8px; }
.head .act { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
h2 { font-size: 16px; margin: 28px 0 10px; font-weight: 650; display: flex; align-items: center; gap: 10px; }
h2 .act { margin-left: auto; display: flex; gap: 8px; }
p.note { color: var(--muted); font-size: 14px; margin: 4px 0 12px; max-width: 72ch; }

/* ตัวเลขเงิน */
.amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.amt .s { font-size: .78em; color: var(--muted); }
.amt.in { color: var(--in); } .amt.out { color: var(--out); }

/* ตัวเลขสรุป: ตัวเลขล้วน เรียงตรงกัน */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; min-width: 0; }
.tile .k { color: var(--muted); font-size: 13.5px; }
.tile .v { font-size: 26px; font-weight: 600; line-height: 1.3; margin-top: 4px; letter-spacing: -.01em; }
.tile .d { color: var(--faint); font-size: 13px; margin-top: 2px; }
.tile.lead { border-color: var(--blue); }
.tile.lead .v { color: var(--blue); }
a.tile:hover { border-color: var(--line-strong); text-decoration: none; }
a.tile { color: inherit; display: block; }

/* ตาราง */
.box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 13px; background: var(--sunk); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
td.btns { text-align: right; white-space: nowrap; }
td.btns .btn + .btn { margin-left: 6px; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--sunk); }
td .mono, .mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 12.5px; }
td .sm, .sm { color: var(--muted); font-size: 13px; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

/* แถวข้อมูล (ชื่อ ค่า ปุ่ม อยู่แถวเดียวกัน) */
.rows { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.row { display: grid; grid-template-columns: 220px 1fr auto; gap: 12px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); min-height: 48px; }
.row:last-child { border-bottom: 0; }
.row > span:first-child { color: var(--muted); font-size: 14px; }
.row > :nth-child(2) { overflow-wrap: anywhere; min-width: 0; }
.row .btns { display: flex; gap: 6px; justify-content: flex-end; }

/* สถานะ */
.st { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 500; background: var(--sunk); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.st.paid, .st.succeeded, .st.sent, .st.active, .st.matched, .st.ok { background: var(--ok-soft); color: var(--in); border-color: transparent; }
.st.pending, .st.retrying, .st.processing { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.st.failed, .st.dead, .st.suspended, .st.bad, .st.unmatched { background: var(--bad-soft); color: var(--out); border-color: transparent; }

/* ปุ่มและช่องกรอก */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: var(--r); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--blue); color: var(--blue); text-decoration: none; }
.btn.pri { background: var(--blue); border-color: var(--blue); color: var(--blue-ink); font-weight: 600; }
.btn.pri:hover { filter: brightness(1.08); color: var(--blue-ink); }
.btn.danger { color: var(--out); }
.btn.danger:hover { border-color: var(--out); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; font-size: 14.5px; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r); height: 36px; padding: 0 10px; min-width: 0; }
textarea { height: auto; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px var(--blue-soft); }
input[type=checkbox] { height: 18px; width: 18px; accent-color: var(--blue); vertical-align: -4px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.filters input[type=search] { width: 260px; }
.more { display: flex; justify-content: center; padding: 12px; }

/* ฟอร์มในหน้าต่าง */
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 5px; font-size: 14px; color: var(--muted); }
.form label.chk { display: flex; align-items: center; gap: 10px; color: var(--ink); }
.form label.chk input { width: 18px; flex: none; }
.form input, .form select { width: 100%; }
.form .hint { font-size: 13px; color: var(--faint); }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* หน้าต่างกลางจอ */
.dim { position: fixed; inset: 0; background: rgba(12, 18, 26, .45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.dlg { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 18px 50px rgba(0, 0, 0, .25); }
.dlg.wide { max-width: 860px; }
.dlg header { padding: 18px 20px 6px; font-weight: 650; font-size: 17px; }
.dlg .body { padding: 8px 20px 16px; overflow-y: auto; }
.dlg footer { padding: 12px 20px 18px; display: flex; gap: 8px; justify-content: flex-end; border-top: 1px solid var(--line); }
.dlg .err { color: var(--out); font-size: 14px; margin-top: 10px; }
.secret { display: flex; gap: 8px; align-items: center; background: var(--sunk); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; }
.secret code { flex: 1; overflow-wrap: anywhere; font-size: 13.5px; }

/* แจ้งผลสั้นๆ มุมล่าง */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 10px 18px; border-radius: var(--r); font-size: 14px; z-index: 60; max-width: calc(100vw - 32px); }
.toast.bad { background: var(--out); color: #fff; }

.banner { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 12px 16px; display: flex; gap: 12px; align-items: center; margin-bottom: 16px; }
.banner.bad { border-color: var(--out); background: var(--bad-soft); }
.banner.ok { border-color: transparent; background: var(--ok-soft); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.steps { margin: 0; padding-left: 22px; color: var(--ink); }
.steps li { margin: 4px 0; }

/* เข้าสู่ระบบ */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px 24px; }
.login h1 { font-size: 20px; margin: 0 0 2px; }
.login p { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.login .btn.pri { width: 100%; justify-content: center; height: 40px; }
.login .alt { margin-top: 16px; text-align: center; font-size: 14px; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line); align-items: center; }
  .brand { padding: 0 10px 0 4px; white-space: nowrap; } .brand span { display: none; }
  .tiles { grid-template-columns: 1fr 1fr; } .tile .v { font-size: 21px; }
  .nav { white-space: nowrap; } .side .grow, .side .who { display: none; }
  main { padding: 20px 16px 48px; }
  .row { grid-template-columns: 1fr auto; } .row > span:first-child { grid-column: 1 / -1; }
  .split, .form .two { grid-template-columns: 1fr; }
  .filters input[type=search] { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
/* ประเภทผู้ให้บริการ: Payment Gateway (ค่ายภายนอก) · book (บัญชีที่ botty-payment นำเข้าเอง) */
.tag { display: inline-block; padding: 0 6px; border-radius: 4px; font-size: 11.5px; font-weight: 600; line-height: 18px; border: 1px solid var(--line-strong); color: var(--muted); white-space: nowrap; vertical-align: 1px; }
.tag.gateway { border-color: var(--blue); color: var(--blue); }
.tag.book { border-color: var(--in); color: var(--in); }
