:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-dark: #1e40af;
  --sidebar: #0f172a;
  --sidebar-ink: #cbd5e1;
  --sidebar-active: #1e293b;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .06);
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
  color: var(--ink); background: var(--bg); font-size: 14px;
}
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 500px at 50% -10%, #dbeafe, transparent), var(--bg); }
.login-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow); padding: 32px; }
.brand-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.logo { width: 34px; height: 34px; border-radius: 8px; background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  display: grid; place-items: center; color: #fff; font-weight: 800; }
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: .3px; }
.login-sub { color: var(--muted); margin: 4px 0 22px; }
label { display: block; font-weight: 600; margin: 14px 0 6px; font-size: 13px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; background: #fff; color: var(--ink); outline: none;
}
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.btn { background: var(--brand); color: #fff; border: none; padding: 10px 16px; border-radius: 8px;
  font-weight: 600; font-size: 14px; }
.btn:hover { background: var(--brand-dark); }
.btn.block { width: 100%; margin-top: 20px; padding: 12px; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: #f8fafc; }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.green { background: var(--green); } .btn.green:hover { filter: brightness(.94); }
.btn.red { background: var(--red); } .btn.red:hover { filter: brightness(.94); }
.btn.amber { background: var(--amber); } .btn.amber:hover { filter: brightness(.94); }
.hint { color: var(--muted); font-size: 12px; margin-top: 14px; text-align: center; }
.link { color: var(--brand); text-decoration: none; font-size: 13px; font-weight: 600; }
.link:hover { text-decoration: underline; }
.error { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-ink); padding: 18px 12px; }
.sidebar .brand-row { padding: 6px 8px 18px; color: #fff; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; color: var(--sidebar-ink);
  text-decoration: none; border-radius: 8px; font-weight: 500; margin-bottom: 2px; }
.nav a:hover { background: var(--sidebar-active); color: #fff; }
.nav a.active { background: var(--brand); color: #fff; }
.nav .ico { width: 18px; text-align: center; }
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 60px; background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px; position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 17px; margin: 0; }
.userbox { display: flex; align-items: center; gap: 14px; color: var(--muted); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #dbeafe; color: var(--brand-dark);
  display: grid; place-items: center; font-weight: 700; }
.content { padding: 24px; }

/* ---------- Cards / KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 22px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.kpi .k-label { color: var(--muted); font-size: 13px; }
.kpi .k-value { font-size: 26px; font-weight: 800; margin-top: 6px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 22px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-size: 15px; margin: 0; }
.panel-body { padding: 4px 0; }
.toolbar { display: flex; gap: 10px; align-items: center; }
.toolbar input { max-width: 260px; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 18px; font-size: 13.5px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; background: #fafbff; }
tbody tr:hover { background: #f8fafc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.tag.in { background: #dcfce7; color: #166534; }
.tag.out { background: #fee2e2; color: #991b1b; }
.tag.adjust { background: #fef3c7; color: #92400e; }
.tag.transfer_in, .tag.transfer_out { background: #e0e7ff; color: #3730a3; }
.tag.muted { background: #f1f5f9; color: #475569; }
.low { color: var(--red); font-weight: 700; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); }
.pager-info { color: var(--muted); font-size: 13px; margin-right: auto; }
.pager .btn[disabled] { opacity: .45; cursor: default; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: grid; place-items: center; z-index: 50; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 440px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal h3 { margin: 0; padding: 18px 20px; border-bottom: 1px solid var(--line); font-size: 16px; }
.modal .body { padding: 18px 20px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.toast { position: fixed; bottom: 22px; right: 22px; background: var(--ink); color: #fff; padding: 12px 18px;
  border-radius: 10px; box-shadow: var(--shadow); z-index: 80; opacity: 0; transform: translateY(8px); transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { background: var(--red); }

/* ---------- Module configurator ---------- */
.modgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.modcard { border: 1px solid var(--line); border-radius: 12px; padding: 18px; background: #fff; display: flex; flex-direction: column; gap: 8px; }
.modcard.on { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.08); }
.modcard.soon { opacity: .72; }
.modtop { display: flex; align-items: center; justify-content: space-between; }
.modic { width: 40px; height: 40px; border-radius: 10px; background: #eff6ff; color: var(--brand); display: grid; place-items: center; font-size: 20px; }
.modcard h3 { font-size: 15px; margin: 2px 0 0; }
.modcard p { color: var(--muted); font-size: 13px; flex: 1; }
.modcard .btn { align-self: flex-start; margin-top: 6px; }
code { background: #f1f5f9; padding: 1px 6px; border-radius: 5px; font-size: 12px; }

/* ---------- Banner ---------- */
.banner { padding: 0; }
.banner.trial, .banner.past { padding: 10px 24px; font-size: 14px; }
.banner.trial { background: #fef3c7; color: #92400e; border-bottom: 1px solid #fde68a; }
.banner.past { background: #fee2e2; color: #991b1b; border-bottom: 1px solid #fecaca; }
.banner-link { color: inherit; font-weight: 700; text-decoration: underline; margin-left: 8px; }

/* ---------- Onboarding checklist ---------- */
.checklist { display: flex; flex-wrap: wrap; gap: 10px; }
.checkitem { display: flex; align-items: center; gap: 8px; padding: 9px 14px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--ink); font-weight: 600; font-size: 13px; background: #fff; }
.checkitem:hover { background: #f8fafc; }
.checkitem .ck { width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; background: #f1f5f9; color: var(--muted); font-size: 12px; }
.checkitem.done { color: var(--muted); }
.checkitem.done .ck { background: #dcfce7; color: #16a34a; }

/* ---------- Plans (billing) ---------- */
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.plan { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 22px; text-align: center; }
.plan.featured { border: 2px solid var(--brand); box-shadow: 0 8px 30px rgba(37,99,235,.1); }
.plan h3 { font-size: 16px; }
.plan .price { font-size: 22px; font-weight: 800; margin: 8px 0; }

/* ---------- PIN lock overlay ---------- */
.lock-wrap { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 500px at 50% -10%, #dbeafe, #eef2ff); }
.lock-card { width: 100%; max-width: 360px; background: #fff; border: 1px solid var(--line);
  border-radius: 18px; box-shadow: 0 20px 60px rgba(15,23,42,.18); padding: 30px 28px; text-align: center; }
.lock-card .logo { margin: 0 auto 14px; width: 44px; height: 44px; font-size: 20px; }
.lock-card h2 { font-size: 19px; margin: 0 0 4px; }
.lock-card .lk-sub { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.pin-dots { display: flex; gap: 12px; justify-content: center; margin: 8px 0 18px; }
.pin-dot { width: 14px; height: 14px; border-radius: 50%; background: #e2e8f0; transition: .1s; }
.pin-dot.on { background: var(--brand); transform: scale(1.1); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pin-key { padding: 16px 0; font-size: 20px; font-weight: 600; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; cursor: pointer; user-select: none; }
.pin-key:hover { background: #f1f5f9; }
.pin-key:active { background: #e2e8f0; transform: scale(.97); }
.pin-key.wide { grid-column: span 1; font-size: 15px; }
.lock-card .error { min-height: 20px; margin-top: 10px; }
.lock-card .lk-foot { margin-top: 16px; display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
