:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #059669;
  --brand-weak: #ecfdf5;
  --warn: #b45309;
  --danger: #be123c;
  --sidebar: #0b1220;
  --sidebar-ink: #cbd5e1;
  --radius: 14px;
  font-synthesis: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }

/* brand */
.brand { display: flex; gap: 10px; align-items: center; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, #10b981, #047857); color: #fff; font-weight: 900;
}
.brand strong { display: block; font-size: 15px; letter-spacing: -0.02em; }
.brand small { color: var(--muted); font-size: 11px; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(900px 500px at 20% 0%, #d1fae5 0%, transparent 60%), var(--bg); }
.auth-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 28px; box-shadow: 0 24px 60px rgba(15, 23, 42, 0.08); }
.auth-card h1 { font-size: 22px; margin: 20px 0 4px; letter-spacing: -0.02em; }
.auth-card form { display: grid; gap: 12px; margin-top: 18px; }
label { display: grid; gap: 6px; font-size: 12px; font-weight: 700; color: #334155; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink); font: inherit; font-size: 13px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #a7f3d0; border-color: var(--brand); }
textarea { resize: vertical; }
.pw { position: relative; }
.pw input { padding-right: 74px; }
.pw-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: #047857; font: inherit; font-size: 11px; font-weight: 800; cursor: pointer; padding: 6px 8px; }

/* buttons */
.btn { border: 0; border-radius: 10px; padding: 9px 14px; font: inherit; font-size: 12px; font-weight: 800; cursor: pointer; background: #eef2f7; color: #0f172a; }
.btn:hover { filter: brightness(0.97); }
.btn.primary { background: var(--brand); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { background: #fff1f2; color: var(--danger); }
.btn.soft { background: var(--brand-weak); color: #047857; }
.btn.small-btn { width: 100%; padding: 7px 10px; font-size: 11px; }
.btn:disabled { opacity: .55; cursor: wait; }
.link { background: none; border: 0; color: #34d399; font: inherit; font-size: 12px; cursor: pointer; padding: 0; }

/* layout */
.layout { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar { background: var(--sidebar); color: var(--sidebar-ink); padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand strong { color: #fff; }
.sidebar .brand small { color: #64748b; }
.nav { display: grid; gap: 4px; }
.nav-item { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; padding: 10px 12px; border: 0; border-radius: 10px; background: transparent; color: #94a3b8; font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer; }
.nav-item span { width: 18px; text-align: center; color: #475569; }
.nav-item:hover { background: #111c30; color: #e2e8f0; }
.nav-item.active { background: #12233b; color: #fff; box-shadow: inset 3px 0 0 #10b981; }
.account-box { margin-top: auto; display: grid; gap: 8px; padding: 12px; border: 1px solid #1e293b; border-radius: 12px; background: #0f1a2b; }
.account-box select { background: #0b1220; border-color: #1e293b; color: #e2e8f0; font-size: 12px; }
.sidebar-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sidebar-foot .muted { color: #64748b; }

.main { min-width: 0; padding: 22px 26px 40px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.topbar h2 { margin: 0; font-size: 22px; letter-spacing: -0.02em; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: #e2e8f0; color: #334155; font-size: 11px; font-weight: 800; }
.badge.ok { background: #d1fae5; color: #047857; }
.badge.err { background: #ffe4e6; color: #be123c; }
.content { display: grid; gap: 16px; }

/* cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03); }
.card h4 { margin: 0 0 8px; font-size: 13px; }
.card .kpi { font-size: 24px; font-weight: 900; font-family: ui-monospace, "SFMono-Regular", monospace; letter-spacing: -0.03em; }
.card .label { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head h3 { margin: 0; font-size: 14px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }

/* table */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { text-align: left; padding: 9px 10px; background: #f8fafc; color: #475569; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
td { padding: 9px 10px; border-top: 1px solid #f1f5f9; vertical-align: top; }
td.mono, .mono { font-family: ui-monospace, SFMono-Regular, monospace; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.pill { display: inline-block; padding: 3px 8px; border-radius: 999px; background: #f1f5f9; font-size: 10px; font-weight: 800; color: #334155; }
.pill.green { background: #d1fae5; color: #047857; }
.pill.amber { background: #fef3c7; color: #92400e; }
.pill.red { background: #ffe4e6; color: #be123c; }

/* forms & misc */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.steps { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 6px; font-size: 12px; color: #334155; }
.connect-banner { display: flex; justify-content: space-between; align-items: center; gap: 16px; background: linear-gradient(135deg, #052e2b, #065f46); color: #ecfdf5; border-radius: 16px; padding: 18px 20px; }
.connect-banner h3 { margin: 2px 0 4px; font-size: 18px; }
.connect-banner .label { color: #6ee7b7; }
.connect-banner .help { color: #a7f3d0; }
.connect-banner .connect-btn { background: #fff; color: #065f46; white-space: nowrap; }
.notice { border: 1px solid #fde68a; background: #fffbeb; color: #92400e; border-radius: 12px; padding: 12px 14px; font-size: 12px; }
.error { color: var(--danger); font-size: 12px; }
.help { font-size: 11px; color: var(--muted); }
code { background: #f1f5f9; padding: 2px 5px; border-radius: 5px; font-size: 11px; }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .62); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { width: min(560px, 100%); max-height: 90vh; overflow: auto; background: #fff; border-radius: 18px; box-shadow: 0 30px 80px rgba(2, 6, 23, .35); }
.modal.wide { width: min(760px, 100%); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal header h3 { margin: 0; font-size: 14px; }
.modal .body { padding: 18px; display: grid; gap: 12px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); background: #f8fafc; }
.close { background: none; border: 0; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; }

/* toast */
.toast { position: fixed; bottom: 22px; right: 22px; background: #0f172a; color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 12px; font-weight: 700; box-shadow: 0 18px 40px rgba(2, 6, 23, .3); z-index: 80; max-width: 360px; }
.toast.err { background: #9f1239; }

/* responsive */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: column; }
  .nav { grid-template-columns: repeat(2, 1fr); }
  .account-box { margin-top: 0; }
  .main { padding: 16px; }
  .topbar { flex-direction: column; }
}