:root {
  --bg: #f1f5f9;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #4f46e5;
  --primary-soft: #eef2ff;
  --in: #059669;
  --in-soft: #d1fae5;
  --out: #dc2626;
  --out-soft: #fee2e2;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --info: #0284c7;
  --info-soft: #e0f2fe;
  --violet: #7c3aed;
  --sidebar: #111827;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.05);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); font-size: 14px; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; }
button, input, select, textarea { font: inherit; }
svg { width: 18px; height: 18px; flex: none; }
.notice svg { width: 16px; height: 16px; vertical-align: -3px; }
.badge svg { width: 12px; height: 12px; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: #cbd5e1; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 700; font-size: 17px; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, #6366f1, #a855f7); display: grid; place-items: center; }
.org-chip { background: #1f2937; border-radius: 10px; padding: 10px 12px; margin: 0 4px 14px; font-size: 12px; }
.org-chip b { color: #fff; display: block; font-size: 13px; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: #64748b; margin: 14px 12px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; color: #cbd5e1; padding: 9px 12px; border-radius: 9px; margin: 2px 0; }
.nav a:hover { background: #1f2937; color: #fff; }
.nav a.active { background: linear-gradient(90deg, #4f46e5, #6366f1); color: #fff; }
.nav a .badge { margin-left: auto; }
.nav svg { width: 18px; height: 18px; flex: none; }
.sidebar .foot { margin-top: auto; padding: 12px; font-size: 12px; color: #64748b; }

.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar .title { font-size: 18px; font-weight: 700; }
.topbar .spacer { flex: 1; }
.menu-btn { display: none; }
.content { padding: 22px 24px 60px; max-width: 1500px; }

.user-pill { display: flex; align-items: center; gap: 8px; padding: 4px 10px 4px 4px; border-radius: 999px; background: var(--bg); cursor: pointer; position: relative; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; background: linear-gradient(135deg, #6366f1, #ec4899); flex: none; }
.user-pill small { display: block; color: var(--muted); font-size: 11px; }

/* ---------- components ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #4338ca; }
.btn.in { background: var(--in); border-color: var(--in); color: #fff; }
.btn.in:hover { background: #047857; }
.btn.out { background: var(--out); border-color: var(--out); color: #fff; }
.btn.out:hover { background: #b91c1c; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--bg); }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn.lg { padding: 12px 20px; font-size: 15px; border-radius: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.icon-btn { position: relative; border: none; background: var(--bg); width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn .dot { position: absolute; top: 4px; right: 4px; min-width: 17px; height: 17px; border-radius: 9px; background: var(--out); color: #fff; font-size: 10px; display: grid; place-items: center; padding: 0 4px; font-weight: 700; }

.badge { flex: none; display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge.in { background: var(--in-soft); color: var(--in); }
.badge.out { background: var(--out-soft); color: var(--out); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.violet { background: #ede9fe; color: var(--violet); }
.badge.primary { background: var(--primary-soft); color: var(--primary); }
.badge.red { background: var(--out); color: #fff; }

.card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-h h3 { font-size: 15px; }
.card-h .sub { color: var(--muted); font-size: 12px; }
.card-h .right { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-7-5 { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
.mb { margin-bottom: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.green { color: var(--in); }
.red { color: var(--out); }
.bold { font-weight: 700; }

/* KPI tiles */
.kpi { position: relative; overflow: hidden; border-radius: var(--radius); padding: 18px; color: #fff; box-shadow: var(--shadow); min-height: 118px; }
.kpi .label { font-size: 12px; opacity: 0.9; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.kpi .value { font-size: 26px; font-weight: 800; margin: 6px 0 4px; font-variant-numeric: tabular-nums; }
.kpi .meta { font-size: 12px; opacity: 0.9; }
.kpi .ico { position: absolute; right: -8px; bottom: -10px; width: 86px; height: 86px; opacity: 0.18; }
.kpi.indigo { background: linear-gradient(135deg, #4f46e5, #7c3aed); }
.kpi.green { background: linear-gradient(135deg, #059669, #10b981); }
.kpi.red { background: linear-gradient(135deg, #dc2626, #f97316); }
.kpi.blue { background: linear-gradient(135deg, #0284c7, #06b6d4); }
.kpi.amber { background: linear-gradient(135deg, #d97706, #f59e0b); }
.kpi.pink { background: linear-gradient(135deg, #db2777, #f472b6); }
.kpi.slate { background: linear-gradient(135deg, #334155, #64748b); }
.kpi.teal { background: linear-gradient(135deg, #0d9488, #14b8a6); }

.stat { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: flex; gap: 14px; align-items: center; min-width: 0; }
.stat .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.stat .ic svg { width: 22px; height: 22px; }
.stat .l { color: var(--muted); font-size: 12px; font-weight: 600; }
.stat .v { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }

.quick { display: flex; gap: 12px; flex-wrap: wrap; }
.quick .btn.lg svg { width: 20px; height: 20px; }

.alerts { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.alert { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px; font-weight: 600; cursor: pointer; flex: 1; min-width: 220px; }
.alert svg { width: 20px; height: 20px; flex: none; }
.alert.warn { background: var(--warn-soft); color: #92400e; }
.alert.info { background: var(--info-soft); color: #075985; }
.alert.violet { background: #ede9fe; color: #5b21b6; }

.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 210px; }
.chart-box.lg { height: 300px; }

/* bars list */
.bars .item { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; margin-bottom: 12px; cursor: pointer; }
.bars .track { grid-column: 1 / -1; height: 8px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.bars .fill { height: 100%; border-radius: 6px; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table.t { width: 100%; border-collapse: collapse; background: var(--panel); }
.t th { text-align: left; background: #f8fafc; color: var(--muted); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: none; }
.t tbody tr:hover { background: #fafbff; }
.t tr.clickable { cursor: pointer; }
.t tr.cancelled td { color: #94a3b8; text-decoration: line-through; }
.t tr.cancelled td.actions { text-decoration: none; }
.t tfoot td { background: #f8fafc; font-weight: 700; }
.t .actions { white-space: nowrap; text-align: right; }
.empty { text-align: center; color: var(--muted); padding: 34px 10px; }
.empty svg { width: 42px; height: 42px; opacity: 0.4; display: block; margin: 0 auto 8px; }

/* forms */
.form { display: grid; gap: 14px; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form .three { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
label.f { display: block; font-weight: 600; font-size: 13px; }
label.f > input, label.f > select, label.f > textarea { display: block; margin-top: 6px; }
label.f .req { color: var(--out); }
label.f .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
input, select, textarea { border: 1px solid #cbd5e1; border-radius: 9px; padding: 9px 11px; background: #fff; color: var(--ink); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #c7d2fe; border-color: var(--primary); }
textarea { resize: vertical; min-height: 64px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; cursor: pointer; }
.check input { width: auto; }
.seg { display: inline-flex; background: var(--bg); padding: 4px; border-radius: 11px; gap: 4px; flex-wrap: wrap; }
.seg button { border: none; background: transparent; padding: 8px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.seg button.on.in { color: var(--in); }
.seg button.on.out { color: var(--out); }
.seg button svg { width: 16px; height: 16px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters label.f { min-width: 140px; }
.filters input, .filters select { padding: 7px 10px; }
.notice { padding: 10px 12px; border-radius: 10px; font-size: 13px; }
.notice.warn { background: var(--warn-soft); color: #92400e; }
.notice.info { background: var(--info-soft); color: #075985; }
.notice.err { background: var(--out-soft); color: #991b1b; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade 0.15s; }
.modal { background: #fff; border-radius: 18px; width: 100%; max-width: 620px; max-height: 92vh; overflow-y: auto; box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3); }
.modal.wide { max-width: 900px; }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 2; }
.modal-h h3 { font-size: 17px; }
.modal-h .x { margin-left: auto; }
.modal-b { padding: 20px 22px; }
.modal-f { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; position: sticky; bottom: 0; background: #fff; }
@keyframes fade { from { opacity: 0; } }

/* toast */
#toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: grid; gap: 8px; }
.toast { background: #0f172a; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow); max-width: 380px; animation: fade 0.2s; }
.toast.err { background: #b91c1c; }
.toast.ok { background: #047857; }

/* dropdown */
.dropdown { position: absolute; top: 46px; right: 0; background: #fff; border-radius: 14px; box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2); width: 380px; max-height: 480px; overflow-y: auto; z-index: 50; border: 1px solid var(--line); }
.dropdown .item { padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; gap: 10px; }
.dropdown .item:hover { background: #f8fafc; }
.dropdown .item.unread { background: #f5f7ff; }
.dropdown .head { padding: 12px 14px; display: flex; align-items: center; border-bottom: 1px solid var(--line); font-weight: 700; position: sticky; top: 0; background: #fff; }
.menu { width: 220px; }
.menu .item { padding: 10px 14px; }

/* timeline */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ''; position: absolute; left: 9px; top: 4px; bottom: 4px; width: 2px; background: var(--line); }
.tl-item { position: relative; margin-bottom: 16px; }
.tl-item .dot { position: absolute; left: -23px; top: 3px; width: 14px; height: 14px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--primary); background: var(--primary); }
.tl-item .dot.in { box-shadow: 0 0 0 2px var(--in); background: var(--in); }
.tl-item .dot.out { box-shadow: 0 0 0 2px var(--out); background: var(--out); }
.tl-item .dot.warn { box-shadow: 0 0 0 2px var(--warn); background: var(--warn); }
.tl-item .when { font-size: 12px; color: var(--muted); }
.diff { display: grid; grid-template-columns: auto 1fr 1fr; gap: 4px 12px; font-size: 13px; margin-top: 6px; background: #f8fafc; padding: 10px; border-radius: 10px; }
.diff .k { color: var(--muted); font-weight: 600; }
.diff .old { color: var(--out); text-decoration: line-through; }
.diff .new { color: var(--in); font-weight: 600; }

/* party cards */
.party-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.party-head .big-av { width: 60px; height: 60px; border-radius: 16px; display: grid; place-items: center; color: #fff; font-size: 24px; font-weight: 800; }
.party-head .info { flex: 1; min-width: 220px; }
.party-head .info h2 { font-size: 22px; }
.party-head .meta { color: var(--muted); display: flex; gap: 14px; flex-wrap: wrap; margin-top: 4px; font-size: 13px; }
.party-head .meta span { display: inline-flex; align-items: center; gap: 4px; }
.party-head .meta svg { width: 14px; height: 14px; }

.branch-card { border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); overflow: hidden; cursor: pointer; transition: transform 0.15s; }
.branch-card:hover { transform: translateY(-2px); }
.branch-card .top { padding: 16px; color: #fff; background: linear-gradient(135deg, #312e81, #4f46e5); }
.branch-card .top h3 { font-size: 16px; }
.branch-card .bal { font-size: 24px; font-weight: 800; margin-top: 8px; }
.branch-card .bot { padding: 12px 16px; display: flex; gap: 14px; font-size: 13px; }

/* auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth .hero { background: linear-gradient(135deg, #1e1b4b, #4f46e5 60%, #a855f7); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.auth .hero h1 { font-size: 40px; line-height: 1.1; margin: 18px 0 14px; }
.auth .hero p { opacity: 0.85; font-size: 16px; max-width: 460px; }
.auth .feat { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 30px; max-width: 520px; }
.auth .feat div { background: rgba(255, 255, 255, 0.1); border-radius: 12px; padding: 12px; font-size: 13px; display: flex; gap: 8px; align-items: center; }
.auth .feat svg { width: 18px; height: 18px; flex: none; }
.auth .panel { display: grid; place-items: center; padding: 32px; }
.auth .box { width: 100%; max-width: 460px; }
.auth .box h2 { font-size: 26px; margin-bottom: 6px; }
.steps { display: flex; gap: 6px; margin: 16px 0; }
.steps span { flex: 1; height: 5px; border-radius: 4px; background: var(--line); }
.steps span.on { background: var(--primary); }
.choice { border: 2px solid var(--line); border-radius: 14px; padding: 14px; cursor: pointer; display: flex; gap: 12px; align-items: flex-start; }
.choice.on { border-color: var(--primary); background: var(--primary-soft); }
.choice svg { width: 28px; height: 28px; color: var(--primary); flex: none; }
.demo { margin-top: 18px; background: #f8fafc; border: 1px dashed #cbd5e1; border-radius: 12px; padding: 12px; font-size: 12px; }
.demo code { background: #e2e8f0; padding: 1px 5px; border-radius: 4px; }

.progress { height: 8px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, #10b981, #059669); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--primary); border-color: var(--primary); }

.spinner { width: 34px; height: 34px; border: 4px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 60px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-7-5, .g3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -260px; width: 250px; z-index: 60; transition: left 0.2s; }
  .sidebar.open { left: 0; }
  .menu-btn { display: grid; }
  .content { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .topbar .hide-sm { display: none; }
  .g2 { grid-template-columns: minmax(0, 1fr); }
  .auth { grid-template-columns: 1fr; }
  .auth .hero { display: none; }
  .form .two, .form .three { grid-template-columns: 1fr; }
  .dropdown { width: calc(100vw - 32px); right: -60px; }
}
@media (max-width: 520px) {
  .g4 { grid-template-columns: minmax(0, 1fr); }
  .kpi .value { font-size: 22px; }
}

/* searchable picker */
.combo { position: relative; }
.combo-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18); max-height: 280px; overflow-y: auto; z-index: 30; }
.combo-opt { display: flex; align-items: center; gap: 8px; padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--line); font-size: 13px; }
.combo-opt:last-child { border-bottom: none; }
.combo-opt.hi, .combo-opt:hover { background: var(--primary-soft); }
.combo-opt.add { color: var(--primary); font-weight: 600; }
.combo-opt.add svg { width: 16px; height: 16px; }

/* long tables scroll inside the card with a sticky header */
.table-wrap.scroll { max-height: 640px; overflow: auto; }
.table-wrap.scroll thead th { position: sticky; top: 0; z-index: 1; }
