:root {
  --ink: #16233A;
  --ink-soft: #3D4A61;
  --muted: #64748B;
  --bg: #EFF2F5;
  --surface: #FFFFFF;
  --border: #E1E5EA;
  --navy-deep: #0F2540;
  --navy: #173A63;
  --navy-mid: #1F4C82;
  --gold: #AD8A4D;
  --gold-light: #F1E6D2;
  --good: #2E7D5C;
  --good-bg: #E4F3EC;
  --warn: #B9791F;
  --warn-bg: #FBF0DE;
  --bad: #B23A3A;
  --bad-bg: #FBE7E7;
  --info: #2A5FA8;
  --info-bg: #E7EEF8;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'IBM Plex Sans', sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
.mono { font-family: 'IBM Plex Mono', monospace; }

/* ---------- APP SHELL ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px; flex: none;
  background: linear-gradient(180deg, var(--navy-deep) 0%, #0B1D33 100%);
  color: #CBD7E6;
  display: flex; flex-direction: column;
  padding: 0 0 20px 0;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 22px 20px 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand-mark {
  width: 40px; height: 40px; border-radius: 7px;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; padding: 3px; box-sizing: border-box;
}
.brand-mark img {
  width: 100%; height: 100%; object-fit: contain;
}
.brand-text .t1 { font-weight: 600; color: #fff; font-size: 15.5px; letter-spacing: 0.3px; line-height: 1.2; }
.brand-text .t2 { font-size: 10.5px; color: #8FA3BE; letter-spacing: 1.2px; text-transform: uppercase; margin-top: 2px; }

.nav-group { margin-top: 18px; padding: 0 12px; }
.nav-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.1px;
  color: #5E7392; padding: 6px 12px 6px 12px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: 8px; margin: 1px 0;
  color: #B7C4D8; cursor: pointer; font-size: 13.4px; font-weight: 500;
  position: relative; transition: background .15s ease, color .15s ease;
}
.nav-item svg { width: 17px; height: 17px; flex: none; opacity: 0.85; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: rgba(173,138,77,0.16); color: #fff; }
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 6px; bottom: 6px; width: 3px;
  background: var(--gold); border-radius: 2px;
}
.nav-item.active svg { opacity: 1; }
.nav-item.disabled { opacity: 0.42; cursor: default; }
.sidebar-foot {
  margin-top: auto; padding: 14px 20px 0 20px; font-size: 11px; color: #5E7392;
  border-top: 1px solid rgba(255,255,255,0.08); padding-top: 14px;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
}
.topbar-title { font-size: 18px; font-weight: 600; letter-spacing: 0.1px; }
.topbar-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.role-badge {
  display: flex; align-items: center; gap: 8px; background: var(--gold-light);
  border: 1px solid #E6D3AC; color: #7A5E28; padding: 6px 12px; border-radius: 20px;
  font-size: 12.3px; font-weight: 600;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--navy);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; font-family: 'IBM Plex Mono', monospace;
}
.logout-btn { background: none; border: none; cursor: pointer; color: var(--muted); }
.logout-btn:hover { color: var(--bad); }

/* Unit context strip — signature element */
.unit-strip {
  display: flex; align-items: stretch; gap: 0; flex-wrap: wrap;
  background: #FBFAF7; border-bottom: 1px solid var(--border);
  padding: 0 28px;
}
.unit-chip {
  display: flex; flex-direction: column; justify-content: center;
  padding: 9px 22px 9px 0; margin-right: 22px;
  border-top: 2.5px solid var(--gold);
  font-family: 'IBM Plex Mono', monospace;
}
.unit-chip .lbl { font-size: 9.5px; letter-spacing: 1.3px; color: var(--muted); text-transform: uppercase; }
.unit-chip .val { font-size: 13px; font-weight: 600; color: var(--navy-deep); margin-top: 1px; }

.content { padding: 24px 28px 60px 28px; }

h2.section-title { font-size: 15px; font-weight: 600; margin: 28px 0 12px 0; color: var(--navy-deep); }
h2.section-title:first-child { margin-top: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; }
@media (max-width: 1100px) { .stat-grid { grid-template-columns: repeat(3, 1fr); } }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 16px 14px 16px; position: relative; overflow: hidden;
}
.stat-card .icon {
  width: 30px; height: 30px; border-radius: 7px; display: flex; align-items: center; justify-content: center;
  margin-bottom: 10px;
}
.stat-card .label { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.stat-card .value { font-size: 19px; font-weight: 700; color: var(--ink); margin-top: 3px; font-family: 'IBM Plex Mono', monospace; letter-spacing: -0.3px; }
.stat-card .delta { font-size: 11px; margin-top: 6px; font-weight: 600; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }

.grid-2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; margin-top: 16px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-head h3 { font-size: 13.5px; font-weight: 600; margin: 0; color: var(--navy-deep); }
.card-head .hint { font-size: 11.3px; color: var(--muted); }
.chart-wrap { height: 230px; }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-size: 10.8px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--muted); font-weight: 600; padding: 9px 12px; border-bottom: 1.5px solid var(--border);
  background: #FAFBFC;
}
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--ink-soft); }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #F8FAFC; }
.num { font-family: 'IBM Plex Mono', monospace; font-size: 12.6px; text-align: right; }

.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px;
  font-size: 11.3px; font-weight: 600;
}
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.search {
  display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; width: 280px; color: var(--muted); font-size: 13px;
}
.search input { border: none; outline: none; background: none; font-family: inherit; font-size: 13px; width: 100%; color: var(--ink); }
.search svg { width: 15px; height: 15px; flex: none; }
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 15px; border-radius: 8px;
  font-size: 13px; font-weight: 600; border: 1px solid transparent; cursor: pointer; font-family: inherit;
}
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-mid); }
.btn-ghost { background: var(--surface); color: var(--ink-soft); border-color: var(--border); }
.btn-ghost:hover { border-color: #C7CEDA; }
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-filter {
  padding: 6px 12px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface);
  font-size: 12.3px; color: var(--muted); cursor: pointer; font-weight: 500;
}
.chip-filter.active { background: var(--navy-deep); color: #fff; border-color: var(--navy-deep); }

.stepper { display: flex; align-items: flex-start; margin: 6px 0 26px 0; }
.step { flex: 1; text-align: center; position: relative; }
.step .dot {
  width: 30px; height: 30px; border-radius: 50%; margin: 0 auto 8px auto;
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
  background: #E4E9EF; color: var(--muted); border: 2px solid #E4E9EF;
}
.step.done .dot { background: var(--good); border-color: var(--good); color: #fff; }
.step.current .dot { background: #fff; border-color: var(--navy); color: var(--navy); box-shadow: 0 0 0 4px var(--info-bg); }
.step.bad .dot { background: var(--bad); border-color: var(--bad); color: #fff; }
.step .lbl { font-size: 11.6px; font-weight: 600; color: var(--ink-soft); }
.step .sub { font-size: 10.6px; color: var(--muted); margin-top: 2px; }
.step:not(:last-child)::after {
  content: ""; position: absolute; top: 15px; left: calc(50% + 22px); right: calc(-50% + 22px);
  height: 2px; background: #E4E9EF;
}
.step.done:not(:last-child)::after { background: var(--good); }

.split { display: grid; grid-template-columns: 1fr 340px; gap: 16px; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 600; color: var(--ink); font-family: 'IBM Plex Mono', monospace; font-size: 12.6px; }

.receipt {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  max-width: 480px; padding: 0; overflow: hidden;
}
.receipt-head {
  background: var(--navy-deep); color: #fff; padding: 18px 22px;
  display: flex; align-items: center; justify-content: space-between;
}
.receipt-head .no { font-family: 'IBM Plex Mono', monospace; font-size: 12px; color: var(--gold-light); margin-top: 3px; }
.receipt-body { padding: 20px 22px; }
.receipt-body .kv .v { font-weight: 600; }
.receipt-total {
  margin-top: 14px; padding: 14px; background: #FAFBFC; border-radius: 8px;
  display: flex; justify-content: space-between; align-items: center;
}
.receipt-total .lbl { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.receipt-total .amt { font-size: 19px; font-weight: 700; color: var(--navy-deep); font-family: 'IBM Plex Mono', monospace; }
.receipt-foot { padding: 14px 22px; border-top: 1px dashed var(--border); font-size: 11px; color: var(--muted); text-align: center; }

.legend-row { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 12px; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-soft); }
.legend-dot { width: 9px; height: 9px; border-radius: 2px; }

.badge-count {
  background: var(--bad); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 10px;
  margin-left: auto;
}

/* ---------- AUTH / LOGIN ---------- */
.auth-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, var(--navy-deep) 0%, #0B1D33 100%);
  padding: 24px;
}
.auth-card {
  background: var(--surface); border-radius: 14px; padding: 36px 34px 30px 34px;
  width: 100%; max-width: 380px; box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.auth-title { font-size: 15px; font-weight: 600; margin: 0 0 4px 0; color: var(--navy-deep); }
.auth-sub { font-size: 12.5px; color: var(--muted); margin: 0 0 22px 0; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-family: inherit; font-size: 13.5px; color: var(--ink);
}
.field input:focus { outline: none; border-color: var(--navy-mid); }
.auth-error {
  background: var(--bad-bg); color: var(--bad); border-radius: 8px; padding: 10px 12px;
  font-size: 12.5px; margin-bottom: 16px;
}
.btn-block { width: 100%; justify-content: center; padding: 11px; }

[x-cloak] { display: none !important; }
