/* ============================================================
   Decoding·IS — financial instrument dashboard (mockup)
   Design: teal ink + cool paper, emerald accent, gold = money.
   Space Grotesk (display) / Inter (UI) / IBM Plex Mono (figures).
   ============================================================ */

:root {
  --ink:      #0C2027;   /* sidebar / brand / headings */
  --ink-2:    #143039;
  --ink-3:    #1d3f4a;
  --paper:    #EEF1F0;   /* app canvas (cool paper, not cream) */
  --card:     #FFFFFF;
  --line:     #DDE3E1;
  --line-2:   #E9EDEC;
  --accent:   #0E9F8E;   /* emerald "decode" signal */
  --accent-d: #0b8073;
  --gold:     #B67A17;   /* commission / money highlight */
  --gold-bg:  #F6EBD6;
  --pos:      #2E7D5B;   /* received / surplus */
  --pos-bg:   #E1F0E8;
  --danger:   #C0483C;   /* outstanding / deficit */
  --danger-bg:#F6E2df;
  --warn:     #C68A0C;   /* pending / part-paid */
  --warn-bg:  #F7EDD5;
  --text:     #10262E;
  --muted:    #5C6E71;
  --faint:    #8494 96;
  --faint:    #849496;

  --r: 12px;   /* card radius */
  --r-sm: 8px;
  --shadow: 0 1px 2px rgba(12,32,39,.04), 0 6px 20px rgba(12,32,39,.05);
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-ui: "Inter", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --sidebar-w: 250px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-ui);
  background: var(--paper);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.01em; margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ============================================================ LOGIN */
.login {
  min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr;
  background: var(--ink);
}
.login__brandpane {
  position: relative; padding: 56px 60px; color: #DCE7E6; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(1100px 600px at -10% -10%, rgba(14,159,142,.28), transparent 55%),
    radial-gradient(700px 500px at 110% 120%, rgba(182,122,23,.20), transparent 55%),
    var(--ink);
}
/* faint "decode" grid signature behind brand copy */
.login__brandpane::after {
  content: ""; position: absolute; inset: 0; opacity: .10; pointer-events: none;
  background-image:
    linear-gradient(rgba(220,231,230,.5) 1px, transparent 1px),
    linear-gradient(90deg, rgba(220,231,230,.5) 1px, transparent 1px);
  background-size: 34px 34px; mask-image: linear-gradient(120deg, #000 20%, transparent 78%);
}
.login__brandpane > * { position: relative; z-index: 1; }
.brandmark { display: flex; align-items: center; gap: 11px; }
.brandmark .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 4px rgba(14,159,142,.22); }
.brandmark .name { font-family: var(--font-display); font-weight: 600; font-size: 17px; letter-spacing: .02em; }
.login__hero h1 { font-size: clamp(30px, 4vw, 48px); line-height: 1.03; color: #F3F8F7; letter-spacing: -.02em; }
.login__hero h1 em { font-style: normal; color: var(--accent); }
.login__hero p { max-width: 42ch; color: #9FB2B2; font-size: 15px; margin-top: 18px; }
.login__stats { display: flex; gap: 34px; margin-top: 8px; }
.login__stats .s .n { font-family: var(--font-mono); font-size: 24px; color: #EAF2F1; }
.login__stats .s .l { font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: #7d9091; margin-top: 4px; }
.login__foot { font-size: 12px; color: #6f8384; }

.login__formpane { background: var(--paper); display: flex; align-items: center; justify-content: center; padding: 40px; }
.loginbox { width: 100%; max-width: 380px; }
.loginbox h2 { font-size: 22px; }
.loginbox .sub { color: var(--muted); margin: 6px 0 26px; font-size: 13px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted); margin-bottom: 7px; }
.field input {
  width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: var(--r-sm);
  font-family: var(--font-ui); font-size: 14px; background: #fff; color: var(--text); transition: border-color .15s, box-shadow .15s;
}
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14,159,142,.16); }
.btn {
  width: 100%; padding: 12px 16px; border: none; border-radius: var(--r-sm);
  background: var(--ink); color: #fff; font-weight: 600; font-size: 14px; letter-spacing: .01em;
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn--accent { background: var(--accent); }
.btn--accent:hover { background: var(--accent-d); }
.login__error { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 18px; font-weight: 500; }

.quicklogins { margin-top: 28px; border-top: 1px solid var(--line); padding-top: 18px; }
.quicklogins .qh { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--faint); margin-bottom: 12px; }
.quicklogins .ql { display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  padding: 9px 10px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: #fff; margin-bottom: 8px; transition: border-color .12s, background .12s; }
.quicklogins .ql:hover { border-color: var(--accent); background: #fafdfc; }
.quicklogins .ql .avatar { width: 30px; height: 30px; font-size: 11px; }
.quicklogins .ql .who { flex: 1; }
.quicklogins .ql .who b { font-weight: 600; font-size: 13px; }
.quicklogins .ql .who span { display: block; font-size: 11px; color: var(--muted); }
.pw-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.pw-hint code { font-family: var(--font-mono); background: #fff; border: 1px solid var(--line); padding: 1px 6px; border-radius: 5px; }

/* ============================================================ AVATAR / BADGE */
.avatar { border-radius: 50%; display: grid; place-items: center; font-family: var(--font-display);
  font-weight: 600; color: #fff; width: 34px; height: 34px; font-size: 12px; flex: none; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 100px; letter-spacing: .02em; white-space: nowrap; }
.badge--admin { background: var(--ink); color: #cfeee9; }
.badge--role  { background: #E6ECEB; color: var(--ink-2); }
.badge--pos   { background: var(--pos-bg); color: var(--pos); }
.badge--warn  { background: var(--warn-bg); color: var(--warn); }
.badge--danger{ background: var(--danger-bg); color: var(--danger); }
.badge--muted { background: #E6ECEB; color: var(--muted); }
.badge--gold  { background: var(--gold-bg); color: var(--gold); }

/* ============================================================ APP SHELL */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar { background: var(--ink); color: #C6D4D3; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; }
.sidebar__brand { display: flex; align-items: center; gap: 11px; padding: 20px 22px; }
.sidebar__brand .name { font-family: var(--font-display); font-weight: 600; color: #EAF2F1; font-size: 16px; letter-spacing: .02em; }
.nav { padding: 8px 12px; flex: 1; overflow-y: auto; }
.nav__label { font-size: 10px; text-transform: uppercase; letter-spacing: .16em; color: #5f7576; padding: 16px 12px 8px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-sm);
  color: #B4C5C4; font-size: 13.5px; font-weight: 500; margin-bottom: 2px; transition: background .12s, color .12s; }
.nav a .ico { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav a:hover { background: rgba(255,255,255,.05); color: #EAF2F1; }
.nav a.active { background: var(--accent); color: #fff; }
.nav a.active .ico { opacity: 1; }
.sidebar__user { border-top: 1px solid rgba(255,255,255,.08); padding: 14px 16px; display: flex; align-items: center; gap: 11px; }
.sidebar__user .meta { flex: 1; min-width: 0; }
.sidebar__user .meta b { color: #EAF2F1; font-size: 13px; font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__user .meta span { font-size: 11px; color: #7d9091; }
.logout { background: transparent; border: 1px solid rgba(255,255,255,.14); color: #C6D4D3; border-radius: 7px; padding: 6px 8px; font-size: 12px; }
.logout:hover { background: rgba(255,255,255,.07); color: #fff; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 16px 28px; border-bottom: 1px solid var(--line);
  background: rgba(238,241,240,.85); backdrop-filter: blur(6px); position: sticky; top: 0; z-index: 20; }
.topbar .menu-btn { display: none; }
.topbar h1 { font-size: 20px; }
.topbar .crumb { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; }
.topbar .spacer { flex: 1; }
.fy-pill { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted);
  background: #fff; border: 1px solid var(--line); border-radius: 100px; padding: 6px 13px; }
.fy-pill b { color: var(--text); font-family: var(--font-mono); }
.scope-note { font-size: 12px; color: var(--muted); }
.scope-note b { color: var(--accent-d); }

.content { padding: 24px 28px 60px; max-width: 1320px; width: 100%; }

/* ============================================================ METRIC CARDS */
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.metric { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 17px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.metric::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.metric.m-gold::before { background: var(--gold); }
.metric.m-pos::before { background: var(--pos); }
.metric.m-danger::before { background: var(--danger); }
.metric .l { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; }
.metric .v { font-family: var(--font-mono); font-size: 24px; font-weight: 500; margin-top: 8px; letter-spacing: -.02em; }
.metric .sub { font-size: 12px; color: var(--muted); margin-top: 5px; }
.metric .sub b { color: var(--text); font-family: var(--font-mono); }

/* ============================================================ CARDS / SECTIONS */
.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; margin-bottom: 22px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.panel__head { display: flex; align-items: center; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--line-2); }
.panel__head h3 { font-size: 15px; }
.panel__head .hint { color: var(--muted); font-size: 12px; }
.panel__head .spacer { flex: 1; }
.panel__body { padding: 16px 18px; }
.panel__body--flush { padding: 0; }

/* chart */
.chart { width: 100%; height: 240px; display: block; }
.chart .axis { fill: var(--muted); font-size: 10px; font-family: var(--font-mono); }
.legend { display: flex; gap: 18px; flex-wrap: wrap; padding: 4px 18px 16px; }
.legend .li { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.legend .sw { width: 11px; height: 11px; border-radius: 3px; }

/* consultant summary rows */
.csum { width: 100%; border-collapse: collapse; }
.csum td, .csum th { padding: 10px 8px; text-align: right; font-size: 13px; border-bottom: 1px solid var(--line-2); }
.csum th { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.csum td:first-child, .csum th:first-child { text-align: left; }
.csum .who { display: flex; align-items: center; gap: 9px; }
.csum .who .avatar { width: 26px; height: 26px; font-size: 10px; }
.csum tr:last-child td { border-bottom: none; }
.csum .mono { font-family: var(--font-mono); }
.bar-mini { height: 6px; border-radius: 4px; background: var(--line); overflow: hidden; min-width: 60px; }
.bar-mini > i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

/* ============================================================ TABLES */
.tablewrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 600; padding: 12px 14px; border-bottom: 1px solid var(--line); background: #F7F9F8; position: sticky; top: 0; }
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.data tbody tr { transition: background .1s; }
table.data tbody tr:hover { background: #F7FBFA; }
table.data td.num, table.data th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data .co { font-weight: 600; }
table.data .doc { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.linkish { color: var(--accent-d); font-weight: 600; cursor: pointer; }
.linkish:hover { text-decoration: underline; }
.row-click { cursor: pointer; }

/* ============================================================ PIPELINE SIGNAL TRACKER (signature) */
.pipe { display: inline-flex; align-items: center; gap: 3px; }
.pipe .seg { width: 22px; height: 6px; border-radius: 3px; background: var(--line); position: relative; }
.pipe .seg.on { background: var(--accent); }
.pipe.stage-quote .seg:nth-child(1).on { background: var(--muted); }
.pipe.stage-invoiced .seg.on { background: var(--warn); }
.pipe.stage-part .seg.on { background: var(--warn); }
.pipe.stage-paid .seg.on { background: var(--pos); }
.pipe-label { font-size: 11px; font-weight: 600; margin-left: 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.stage-legend { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.stage-legend .sl { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 100px; padding: 4px 11px; background: #fff; }
.stage-legend .sl .d { width: 9px; height: 9px; border-radius: 3px; }

/* toolbar / filters */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .search { flex: 1; min-width: 180px; max-width: 340px; }
.toolbar input, .toolbar select { padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r-sm);
  font-family: var(--font-ui); font-size: 13px; background: #fff; color: var(--text); }
.toolbar input:focus, .toolbar select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14,159,142,.14); }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; color: var(--muted); border-radius: 100px; padding: 7px 14px; font-size: 12.5px; font-weight: 500; }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ============================================================ LEDGER */
.ledger-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.ledger-head .back { font-size: 13px; color: var(--muted); }
.ledger-head .back:hover { color: var(--accent-d); }
.ledger-title { display: flex; align-items: center; gap: 14px; margin: 6px 0 4px; }
.ledger-title h1 { font-size: 24px; }
.ledger-meta { color: var(--muted); font-size: 13px; display: flex; gap: 16px; flex-wrap: wrap; }
.ledger-meta b { color: var(--text); }

.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 20px 0; }
.tl-item::before { content: ""; position: absolute; left: -26px; top: 3px; width: 14px; height: 14px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent); }
.tl-item.is-quote::before { border-color: var(--muted); }
.tl-item.is-invoiced::before, .tl-item.is-part::before { border-color: var(--warn); }
.tl-item.is-paid::before { border-color: var(--pos); }
.tl-item .tl-date { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.tl-item .tl-body { background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; margin-top: 6px; }
.tl-item .tl-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tl-item .tl-row .amt { font-family: var(--font-mono); font-weight: 600; margin-left: auto; }

/* empty state */
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 8px; }

/* section title */
.section-title { display: flex; align-items: baseline; gap: 12px; margin: 6px 0 14px; }
.section-title h2 { font-size: 17px; }
.section-title .n { color: var(--muted); font-size: 13px; }

/* mobile nav backdrop */
.backdrop { display: none; }

/* ============================================================ RESPONSIVE */
@media (max-width: 1080px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  :root { --sidebar-w: 0px; }
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 260px; z-index: 60; transform: translateX(-100%);
    transition: transform .22s ease; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .app.nav-open .sidebar { transform: translateX(0); }
  .app.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(6,18,22,.5); z-index: 50; }
  .topbar .menu-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 9px;
    border: 1px solid var(--line); background: #fff; }
  .content { padding: 18px 16px 60px; }
  .topbar { padding: 12px 16px; }
  .login { grid-template-columns: 1fr; }
  .login__brandpane { display: none; }
}
@media (max-width: 520px) {
  .metrics { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 17px; }
  .scope-note { display: none; }
}

/* accessibility */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
