/* =====================================================================
   Senpay UI
   Type: IBM Plex Sans (UI) + IBM Plex Mono (references, keys, code)
   Scale: 12 / 13 / 14 / 15 / 17 / 20 / 28  ·  Weights: 400 / 500 / 600
   Figures are tabular everywhere so amounts align in columns.
   ===================================================================== */
:root, [data-theme="light"] {
  --bg: #f5f7fb; --surface: #ffffff; --surface-2: #f3f6fb; --border: #e4e9f1; --border-strong: #cdd6e3;
  --text: #0f1b33; --text-2: #34415a; --muted: #67748b; --accent: #f26a12; --accent-2: #dd5a07; --on-accent: #ffffff;
  --accent-soft: rgba(242,106,18,.10);
  --ok: #15924f; --ok-bg: #e6f6ed; --bad: #d23b3b; --bad-bg: #fdecec;
  --warn: #b7660b; --warn-bg: #fdf3e3; --chip: #f1f4f9; --shadow: 0 1px 2px rgba(15,27,51,.04), 0 2px 8px rgba(15,27,51,.04);
  --side-bg: #133a9e; --side-bg-2: #0f3290; --side-text: rgba(255,255,255,.92); --side-muted: rgba(255,255,255,.62);
  --side-hover: rgba(255,255,255,.08); --side-line: rgba(255,255,255,.10);
  --active-grad: linear-gradient(90deg, #f77a1c 0%, #ec5a0c 100%);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0d1220; --surface: #141a2b; --surface-2: #1a2236; --border: #253049; --border-strong: #34405c;
  --text: #e9edf5; --text-2: #c3cbdb; --muted: #8b96ab; --accent: #f57a24; --accent-2: #e5660f; --on-accent: #ffffff;
  --accent-soft: rgba(245,122,36,.13);
  --ok: #4ccf88; --ok-bg: rgba(76,207,136,.12); --bad: #f07272; --bad-bg: rgba(240,114,114,.12);
  --warn: #e8a93b; --warn-bg: rgba(232,169,59,.12); --chip: #1c2539; --shadow: none;
  --side-bg: #0f2c7a; --side-bg-2: #0b2466; --side-text: rgba(255,255,255,.92); --side-muted: rgba(255,255,255,.6);
  --side-hover: rgba(255,255,255,.07); --side-line: rgba(255,255,255,.09);
  --active-grad: linear-gradient(90deg, #f77a1c 0%, #ec5a0c 100%);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 400 14.5px/1.55 "IBM Plex Sans", -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
b, strong { font-weight: 600; }
h1, h2, h3, h4 { font-weight: 600; letter-spacing: -0.01em; }
.ic { width: 18px; height: 18px; flex: none; }
.mono { font-family: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace; font-size: 13px; letter-spacing: 0; }
.muted { color: var(--muted); }
.hide-amounts .amt { filter: blur(8px); user-select: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 272px; flex: none; background: linear-gradient(180deg, var(--side-bg) 0%, var(--side-bg-2) 100%); color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 22px; font-weight: 600; font-size: 21px; letter-spacing: -0.02em; height: 84px; color: #fff; }
.logo-mark { width: 38px; height: 38px; border-radius: 11px; background: var(--active-grad); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 18px; box-shadow: 0 6px 16px rgba(236,90,12,.35); }
.logo-mark.sm { width: 28px; height: 28px; font-size: 14px; border-radius: 8px; box-shadow: none; }
.nav { flex: 1; padding: 6px 14px 0; }
.nav-sec { padding: 2px 0; }
/* Group headers look exactly like regular menu items (same size, weight, colour, icon) */
.nav-head { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px; background: none; border: 0; color: var(--side-text); font: 400 15px "IBM Plex Sans", sans-serif; padding: 10px 12px; margin: 2px 0; border-radius: 12px; cursor: pointer; text-align: left; }
.nav-head:hover { background: var(--side-hover); color: #fff; }
.nav-head-label { display: flex; align-items: center; gap: 12px; }
.nav-head-label .ic { color: var(--side-text); opacity: .9; }
.nav-chev { display: inline-grid; }
.nav-chev .ic { width: 16px; height: 16px; color: var(--side-muted); transition: transform .15s; }
.nav-sec.open .nav-chev .ic { transform: rotate(90deg); }
.nav-sec.flat .nav-head { cursor: default; padding: 14px 12px 4px; color: var(--side-muted); font-size: 12.5px; font-weight: 500; }
.nav-sec.flat .nav-head:hover { background: none; color: var(--side-muted); }
.nav-children { display: none; padding: 2px 0 6px; }
.nav-sec.open .nav-children { display: block; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin: 2px 0; color: var(--side-text); font: 400 15px "IBM Plex Sans", sans-serif; border-radius: 12px; width: 100%; background: none; border: 0; cursor: pointer; text-align: left; }
.nav-link .ic { color: var(--side-text); opacity: .9; }
.nav-link:hover { background: var(--side-hover); color: #fff; }
.nav-link.active { background: var(--active-grad); color: #fff; font-weight: 500; box-shadow: 0 6px 16px rgba(236,90,12,.32); }
.nav-link.active .ic { color: #fff; opacity: 1; }
.nav-foot { padding: 12px 14px 18px; border-top: 1px solid var(--side-line); }
.nav-foot form { margin: 6px 0 0; }
.nav-link.logout { border: 0; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 84px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 0 28px; background: var(--surface); position: sticky; top: 0; z-index: 20; }
.who { font-weight: 500; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { margin-left: auto; display: flex; gap: 8px; }
.icon-btn { width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); display: grid; place-items: center; cursor: pointer; position: relative; }
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.bell .dot { position: absolute; top: -6px; right: -6px; background: #e5484d; color: #fff; font-size: 10.5px; font-weight: 600; padding: 1px 6px; border-radius: 99px; }
.content { padding: 32px 40px 120px; max-width: 1480px; width: 100%; }
.only-mobile { display: none; }
.backdrop { display: none; }

/* ---------- Components ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; margin: 0; line-height: 1.3; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 22px 24px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 14px; font-size: 15px; }
.stat .label { color: var(--muted); font-size: 13.5px; display: flex; justify-content: space-between; align-items: center; }
.stat .label .ic { width: 40px; height: 40px; padding: 10px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); }
.stat .value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; margin: 12px 0 6px; }
.stat .sub { color: var(--muted); font-size: 13px; }
.up { color: var(--ok); } .down { color: var(--bad); }
.tile { display: block; transition: border-color .15s; }
.tile:hover { border-color: var(--border-strong); }
.chip { display: inline-block; font-size: 12px; font-weight: 500; background: var(--chip); border: 1px solid var(--border); border-radius: 6px; padding: 2px 9px; color: var(--muted); }
.tile h4 { margin: 12px 0 4px; font-size: 15.5px; } .tile p { margin: 0; color: var(--muted); font-size: 14px; }
.tile .ic { color: var(--muted); }
.section-title { display: flex; justify-content: space-between; align-items: center; margin: 36px 0 14px; }
.section-title h2 { font-size: 16px; margin: 0; }

.btn { display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; padding: 9px 15px; font: 500 14px "IBM Plex Sans", sans-serif; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--border-strong); }
.btn .ic { width: 16px; height: 16px; }
.btn-primary { background: var(--active-grad); border-color: transparent; color: var(--on-accent); box-shadow: 0 4px 12px rgba(236,90,12,.25); }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-danger { color: var(--bad); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-light { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; min-width: 760px; }
.tbl th { text-align: left; font-size: 12.5px; font-weight: 500; color: var(--muted); padding: 13px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); }
.tbl td { padding: 13px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; font-size: 14px; }
.tbl td.amt, .tbl th.num { text-align: right; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }
.ref { display: inline-flex; align-items: center; gap: 6px; }
.ref a.mono:hover { color: var(--accent); }
.copy { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 2px; display: inline-grid; }
.copy .ic { width: 15px; height: 15px; }
.copy:hover { color: var(--accent); }
.tag { font-size: 11.5px; font-weight: 500; letter-spacing: .02em; padding: 3px 9px; border: 1px solid var(--border); border-radius: 6px; background: var(--chip); color: var(--text-2); }
.badge { display: inline-block; min-width: 96px; text-align: center; font-size: 12px; font-weight: 500; letter-spacing: .03em; padding: 3px 10px; border-radius: 6px; border: 1px solid var(--border); }
.badge-ok { color: var(--ok); background: var(--ok-bg); border-color: transparent; }
.badge-bad { color: var(--bad); background: var(--bad-bg); border-color: transparent; }
.badge-warn { color: var(--warn); background: var(--warn-bg); border-color: transparent; }
.badge-muted { color: var(--text-2); background: var(--chip); }
.empty { padding: 48px 24px; text-align: center; color: var(--muted); }

.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; align-items: center; }
.filters input, .filters select { width: auto; min-width: 150px; }
label { display: block; font-size: 13px; font-weight: 500; margin: 0 0 6px; color: var(--text-2); }
input, select, textarea { width: 100%; background: var(--surface); border: 1px solid var(--border); color: var(--text); border-radius: 10px; padding: 10px 12px; font: 400 14.5px "IBM Plex Sans", sans-serif; outline: none; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 96px; resize: vertical; }
.field { margin-bottom: 16px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 400; font-size: 14px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; border: 1px solid var(--border); font-size: 14px; }
.alert-success { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.alert-error { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.alert-info { background: var(--surface-2); }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 24px; overflow-x: auto; }
.tabs a { padding: 10px 14px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 500; white-space: nowrap; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }

.kv { display: grid; grid-template-columns: 170px 1fr; gap: 10px 18px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.secret-box { background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: 8px; padding: 12px 14px; display: flex; gap: 10px; align-items: center; word-break: break-all; }
pre.code { background: #08090a; color: #e4e6e5; border: 1px solid var(--border); border-radius: 8px; padding: 16px; overflow-x: auto; font: 12.5px/1.65 "IBM Plex Mono", monospace; }
.pager { display: flex; gap: 6px; align-items: center; padding: 14px 0; }
.pager a { padding: 5px 11px; border: 1px solid var(--border); border-radius: 7px; font-size: 13.5px; }
.pager a.on { background: var(--active-grad); color: var(--on-accent); border-color: transparent; }
.pager .muted { margin-left: 10px; font-size: 13.5px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: none; align-items: flex-start; justify-content: center; padding: 8vh 16px; z-index: 100; overflow-y: auto; }
.modal.open { display: flex; }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; width: 100%; max-width: 520px; padding: 24px; }
.modal-box h3 { margin: 0 0 18px; font-size: 17px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

.help-fab { position: fixed; right: 24px; bottom: 24px; background: var(--active-grad); color: var(--on-accent); border-radius: 99px; padding: 8px 20px 8px 9px; display: flex; gap: 11px; align-items: center; box-shadow: 0 8px 24px rgba(0,0,0,.28); z-index: 50; }
.help-fab .logo-mark { background: #fff; color: var(--accent); border-radius: 50%; box-shadow: none; }
.help-fab b { display: block; font-size: 14.5px; font-weight: 600; line-height: 1.2; } .help-fab small { display: block; font-size: 12.5px; opacity: .85; }
.chart-box { position: relative; height: 300px; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.list-plain li:last-child { border-bottom: 0; }
.thread .msg { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; }
.thread .msg.staff { border-color: var(--accent); background: var(--accent-soft); }
.doc { line-height: 1.65; }
.doc h2 { margin-top: 40px; font-size: 18px; } .doc h3 { margin-top: 26px; font-size: 15px; }
.doc p { max-width: 72ch; }
.doc table { border-collapse: collapse; width: 100%; margin: 10px 0; }
.doc td, .doc th { border: 1px solid var(--border); padding: 8px 10px; text-align: left; font-size: 13.5px; }
.doc th { font-weight: 500; color: var(--muted); }
.endpoint { display: inline-flex; gap: 8px; align-items: center; font: 13px "IBM Plex Mono", monospace; background: var(--surface-2); border: 1px solid var(--border); border-radius: 7px; padding: 5px 10px; }
.m-post { color: var(--warn); font-weight: 500; } .m-get { color: var(--ok); font-weight: 500; }

/* ---------- Public / checkout ---------- */
body.public { display: block; }
.public-wrap { width: 100%; max-width: 460px; padding: 48px 16px; margin: 0 auto; }
.checkout { padding: 28px; }
.checkout .merchant { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.checkout .merchant img { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; }
.checkout h2 { font-size: 19px; }
.checkout .price { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; margin: 8px 0 20px; }
.checkout .cover { width: 100%; border-radius: 10px; margin-bottom: 16px; max-height: 260px; object-fit: cover; }
.btn-block { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }
.powered { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 18px; }
.spinner { width: 48px; height: 48px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin 1s linear infinite; margin: 10px auto 18px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.big-ok { width: 56px; height: 56px; border-radius: 50%; background: var(--ok-bg); color: var(--ok); display: grid; place-items: center; font-size: 28px; margin: 0 auto 14px; }
.big-bad { background: var(--bad-bg); color: var(--bad); }
.auth-card { max-width: 420px; margin: 6vh auto; }
.auth-card .brand { border: 0; padding: 0 0 24px; height: auto; justify-content: center; color: var(--text); }
.auth-card h2 { font-size: 19px; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 900px) {
  .sidebar { position: fixed; left: -290px; z-index: 60; transition: left .2s; }
  .sidebar.open { left: 0; }
  .backdrop.on { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 55; }
  .only-mobile { display: grid; }
  .content { padding: 20px 16px 120px; }
  .topbar { padding: 0 16px; }
  .g3, .g2 { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; } .kv dd { margin-bottom: 8px; }
}
@media (max-width: 560px) {
  .g4 { grid-template-columns: 1fr; }
  .help-fab span:last-child { display: none; } .help-fab { padding: 9px; }
  .stat .value { font-size: 24px; }
}
