:root {
  --ink: #0e1726;
  --ink-soft: #1c2b3d;
  --muted: #6a7a8c;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --bg: #f1f4f8;
  --surface: #ffffff;
  --brand: #0b2540;
  --brand-2: #133554;
  --accent: #0e7490;
  --accent-soft: #e0f2f7;
  --ok: #0f766e;
  --ok-soft: #ecfdf8;
  --warn: #b45309;
  --warn-soft: #fff7ed;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(14, 23, 38, 0.04), 0 10px 28px rgba(11, 37, 64, 0.06);
  --shadow-sm: 0 1px 2px rgba(14, 23, 38, 0.05);
  --sidebar-w: 248px;
  --font: "Manrope", "Segoe UI", sans-serif;
  --display: "Manrope", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 0.9375rem;
  line-height: 1.5;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--brand); }
:focus-visible { outline: 2px solid rgba(14, 116, 144, 0.55); outline-offset: 2px; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  background:
    radial-gradient(900px 420px at 100% 0%, rgba(14, 116, 144, 0.07), transparent 55%),
    linear-gradient(180deg, #eef2f6 0%, var(--bg) 40%, #e8eef4 100%);
}

/* —— Sidebar —— */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  color: #e8eef5;
  background:
    radial-gradient(420px 280px at 0% 0%, rgba(14, 116, 144, 0.22), transparent 60%),
    linear-gradient(180deg, #0a1f35 0%, #0b2540 55%, #091c30 100%);
  border-right: 1px solid rgba(255,255,255,0.06);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px 22px;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: linear-gradient(145deg, #1286a3, #0b2540 72%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.2), 0 8px 18px rgba(0,0,0,0.18);
}
.brand-mark svg { display: block; }
.brand {
  font-weight: 750;
  font-size: 1.05rem;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: #fff;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  color: rgba(232, 238, 245, 0.78);
  font-weight: 650;
  font-size: 0.92rem;
  border: 1px solid transparent;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease;
}
.nav a svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.9;
  flex: 0 0 auto;
}
.nav a:hover {
  background: rgba(255,255,255,0.07);
  color: #fff;
}
.nav a.is-active {
  background: rgba(255,255,255,0.11);
  border-color: rgba(255,255,255,0.08);
  color: #fff;
  box-shadow: inset 3px 0 0 #2bb3cf;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: grid;
  gap: 8px;
}
.session-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
}
.session-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(43, 179, 207, 0.22);
  color: #dff6fb;
  font-weight: 750;
  font-size: 0.85rem;
}
.session-name {
  font-size: 0.88rem;
  font-weight: 650;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-exit {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(232, 238, 245, 0.85);
  font-weight: 650;
  font-size: 0.88rem;
  transition: background 160ms ease, color 160ms ease;
}
.nav-exit:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

/* —— Main —— */
.wrap {
  min-width: 0;
  padding: 28px 28px 48px;
  animation: rise 320ms ease both;
}
.page-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.page-head h1,
main h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 750;
  letter-spacing: -0.035em;
  color: var(--ink);
}
.page-head .muted { margin: 0; color: var(--muted); font-size: 0.9rem; }
.breadcrumb {
  margin: 0 0 14px;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--muted);
}
.breadcrumb a { color: var(--muted); }
.breadcrumb span { color: var(--ink-soft); }
.pager { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; align-items: center; }
.pager .btn { min-height: 36px; padding: 0 12px; font-size: 0.84rem; }

.btn, button.btn, a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: -0.01em;
  cursor: pointer;
  text-decoration: none;
  transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease, transform 120ms ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: none; }
.btn {
  background: linear-gradient(180deg, #164363, var(--brand));
  color: #fff;
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.12);
}
.btn:hover { color: #fff; }
.btn.secondary {
  background: var(--surface);
  color: var(--brand);
  border-color: var(--line);
  box-shadow: none;
}
.btn.secondary:hover { border-color: var(--line-strong); background: #f8fafc; }
.btn.danger {
  background: linear-gradient(180deg, #dc2626, var(--danger));
  color: #fff;
  box-shadow: none;
}
.btn.ghost {
  background: transparent;
  color: var(--brand);
  border-color: var(--line);
  box-shadow: none;
}
.btn.ghost:hover { background: #eef3f8; }
.btn.block { width: 100%; }

.panel, .card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
h2 {
  margin: 0 0 12px;
  font-size: 0.98rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  color: var(--ink-soft);
}
.panel-head h2 { margin: 0; }

.muted { color: var(--muted); }
.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 4px;
}
.stat {
  margin: 0;
  padding: 18px 18px 16px;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(180deg, #ffffff, #f8fafc);
}
.stat::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent 70%);
  opacity: 0.85;
}
.stat .muted {
  display: block;
  margin-bottom: 10px;
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat strong {
  display: block;
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--ink);
  line-height: 1.1;
}

label {
  display: block;
  margin: 14px 0 7px;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--ink-soft);
}
input[type="text"],
input[type="password"],
input[type="date"],
input[type="email"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 550;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
input:hover, select:hover, textarea:hover { border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #2a9bb5;
  box-shadow: 0 0 0 3px rgba(14, 116, 144, 0.14);
}
textarea { min-height: 104px; resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

.alert {
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  margin-bottom: 14px;
  border: 1px solid transparent;
  font-weight: 650;
  font-size: 0.9rem;
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #fecaca;
}
.alert.ok {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: #99f6e4;
}
.alert.warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: #fed7aa;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
tr:last-child td { border-bottom: 0; }
th {
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  background: #f8fafc;
}
tbody tr { transition: background 120ms ease; }
tbody tr:hover { background: #f5f9fb; }
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 6px;
  background: #e8eef5;
  color: var(--brand);
  font-size: 0.75rem;
  font-weight: 750;
  letter-spacing: 0.02em;
}
.badge.off {
  background: var(--danger-soft);
  color: var(--danger);
}
.key {
  font-family: var(--mono);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  word-break: break-all;
}
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-weight: 700;
}
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.detail-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px 18px;
  margin: 0;
}
.detail-grid dt {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}
.detail-grid dd { margin: 0; font-weight: 600; }

/* —— Auth —— */
.auth-body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 28px 16px;
  background:
    radial-gradient(900px 500px at 15% 10%, rgba(14, 116, 144, 0.28), transparent 55%),
    radial-gradient(800px 480px at 90% 90%, rgba(255,255,255,0.08), transparent 50%),
    linear-gradient(145deg, #071827 0%, #0b2540 48%, #123552 100%);
  position: relative;
  overflow: hidden;
}
.auth-body::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 40% 30%, #000 20%, transparent 75%);
  pointer-events: none;
}
.auth-body > form {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
}
.auth-card {
  padding: 32px 32px 28px;
  border-radius: 16px;
  background: rgba(255,255,255,0.98);
  border: 1px solid rgba(255,255,255,0.55);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
  animation: rise 380ms ease both;
}
.auth-card .actions { margin-top: 22px; }
.auth-card .brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}
.auth-card .brand {
  color: var(--ink);
  font-size: 1.15rem;
}
.auth-card h1,
.auth-card h2 {
  margin: 0 0 16px;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    padding: 12px;
  }
  .sidebar-brand { padding: 4px 8px 12px; }
  .nav {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .nav a { flex: 1 1 calc(50% - 4px); }
  .sidebar-foot {
    border-top: 0;
    padding-top: 8px;
    grid-template-columns: 1fr auto;
    align-items: center;
  }
  .nav-exit { min-width: 96px; }
  .wrap { padding: 18px 14px 36px; }
  .grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  .row { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }
  table.stack thead { display: none; }
  table.stack, .table-wrap { border: 0; }
  table.stack tr {
    display: block;
    border: 1px solid var(--line);
    border-radius: 10px;
    margin-bottom: 10px;
    padding: 4px 8px;
    background: #fff;
  }
  table.stack td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border: 0;
    padding: 10px 6px;
  }
  table.stack td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 750;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
  .detail-grid { grid-template-columns: 1fr; }
  .session-name { max-width: 120px; }
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 6px;
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
}
.kpi.ok::before { background: var(--ok); }
.kpi.warn::before { background: var(--warn); }
.kpi.bad::before { background: var(--danger); }
.kpi span {
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.kpi strong {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.layout-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.9fr);
  gap: 16px;
  align-items: start;
}
.stack-panels { display: grid; gap: 16px; }
.panel-ledger { border-top: 3px solid var(--accent); }
.panel-soft { background: linear-gradient(180deg, #f8fafc, #fff); }
.balance-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  margin-bottom: 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px solid rgba(14, 116, 144, 0.18);
}
.balance-box strong {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--brand);
}
.field-hint {
  margin: 6px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}
.reason-box { min-height: 64px; resize: vertical; }
.actions.twin { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions.wrap-actions { flex-wrap: wrap; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.muted.tight { margin: 0 0 12px; font-size: 0.86rem; }
.badge.soft {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(14, 116, 144, 0.2);
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.link-more { font-size: 0.84rem; font-weight: 700; }
.cell-sub { font-size: 0.78rem; color: var(--muted); font-weight: 600; margin-top: 2px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: 0.8rem; }
table.ledger .num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 0.84rem; }
table.ledger .pos { color: var(--ok); }
table.ledger .neg { color: var(--danger); }
.note-list {
  margin: 0;
  padding-left: 18px;
  color: var(--ink-soft);
  display: grid;
  gap: 10px;
  font-size: 0.9rem;
}

@media (max-width: 960px) {
  .layout-2 { grid-template-columns: 1fr; }
  .actions.twin { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
