/* Simplex Intelligence
   Tokens are the Simplex brand values from simplex.net.au. The two data ramps
   are validated ordinal ramps (one hue, monotone lightness, >=0.06 step gaps,
   surface-end contrast >=2:1) against the Simplex ink surface. */

@font-face { font-family: 'Inter'; font-weight: 400; font-style: normal; font-display: swap;
  src: url('fonts/inter-400.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 600; font-style: normal; font-display: swap;
  src: url('fonts/inter-600.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 700; font-style: normal; font-display: swap;
  src: url('fonts/inter-700.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-weight: 400; font-style: normal; font-display: swap;
  src: url('fonts/jbmono-400.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-weight: 600; font-style: normal; font-display: swap;
  src: url('fonts/jbmono-600.woff2') format('woff2'); }

:root {
  --red:      #E94B36;
  --red-deep: #C73E2C;
  --ink:      #14181D;
  --ink-2:    #1E232A;
  --ink-3:    #2A2F37;
  --rule:     rgba(255, 255, 255, 0.11);
  --rule-soft:rgba(255, 255, 255, 0.05);

  /* ink-biased neutrals, not flat grey */
  --text:  #EDEFF2;
  --mute:  #8A94A3;
  --dim:   #5C6675;

  /* validated ordinal ramp on --ink, dim -> bright */
  --d1: #8A3524; --d2: #B34A31; --d3: #D6553F; --d4: #ED6B57; --d5: #F5A091;

  --green: #2ECC8A;
  --amber: #F5A623;

  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--ink); color: var(--text);
  font-family: var(--sans); font-size: 13px; line-height: 1.5;
  -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; }
h1, h2, h3 { font-weight: 600; letter-spacing: -.011em; }

/* micro-label — the brand's tracked mono, as used on the site's stat blocks */
.lab {
  font-family: var(--mono); font-size: 10px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--dim); font-weight: 400;
}

/* ------------------------------------------------------------- top bar */

.topbar {
  background: var(--ink-2); border-bottom: 1px solid var(--rule);
  padding: 0 20px; height: 56px; display: flex; align-items: center; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15px;
  letter-spacing: -.01em; white-space: nowrap; }
.brand .mark { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--red);
  position: relative; flex: none; }
.brand .mark::after { content: ''; position: absolute; inset: 4px; border-radius: 50%; background: var(--red); }
.brand em { font-style: normal; color: var(--red); }

.tabs { display: flex; gap: 2px; }
.tab {
  background: none; border: 1px solid transparent; color: var(--mute);
  padding: 7px 13px; border-radius: 2px; cursor: pointer; font-size: 13.5px;
}
.tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.tab.active { background: rgba(233, 75, 54, 0.13); color: var(--red); font-weight: 600; }
.tab:focus-visible, .btn:focus-visible, th:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.topbar-spacer { flex: 1; }
.topbar-sub { font-size: 11px; color: var(--dim); font-family: var(--mono); white-space: nowrap; }

/* ---------------------------------------------------------------- shell */

.shell { display: grid; grid-template-columns: 208px 1fr; min-height: calc(100vh - 56px); }
.rail { border-right: 1px solid var(--rule); padding: 18px 0; background: rgba(0, 0, 0, 0.16); }
.rail h5 { padding: 0 20px; margin: 18px 0 7px; }
.rail h5:first-child { margin-top: 0; }
.rail a {
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
  padding: 7px 20px; font-size: 13px; color: var(--mute); text-decoration: none; cursor: pointer;
}
.rail a:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.rail a.on { color: var(--text); background: rgba(233, 75, 54, 0.12);
  box-shadow: inset 2px 0 0 var(--red); font-weight: 600; }
.rail a b { font-family: var(--mono); font-size: 11px; font-weight: 400; color: var(--dim); }

.main { padding: 20px 22px 40px; min-width: 0; }

/* ----------------------------------------------------------------- kpis */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 11px; }
.kpi { background: var(--ink-2); border: 1px solid var(--rule); border-radius: 2px; padding: 13px 15px; }
.kpi .val { font-size: 29px; font-weight: 700; letter-spacing: -.02em; margin-top: 5px; line-height: 1.05; }
.kpi .val small { font-size: 15px; color: var(--mute); font-weight: 400; }
.kpi .sub { font-size: 12px; color: var(--mute); margin-top: 3px; }
.kpi.flag { border-color: rgba(233, 75, 54, 0.45); }
.kpi.flag .val { color: var(--red); }
.kpi.click { cursor: pointer; }
.kpi.click:hover { border-color: var(--red); }

/* ---------------------------------------------------------------- cards */

.grid { display: grid; gap: 11px; margin-top: 11px; }
.g-32 { grid-template-columns: 3fr 2fr; }
.g-23 { grid-template-columns: 2fr 3fr; }
.g-11 { grid-template-columns: 1fr 1fr; }
@media (max-width: 1000px) { .g-32, .g-23, .g-11 { grid-template-columns: 1fr; } }

.card { background: var(--ink-2); border: 1px solid var(--rule); border-radius: 2px; padding: 15px 17px 17px; }
.card > header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 13px; }
.card h3 { font-size: 14px; }
.card header .hint { margin-left: auto; }
.card .foot { font-size: 12px; color: var(--mute); margin-top: 11px; }
.card .foot b { color: var(--red); font-weight: 600; }

/* ----------------------------------------------------------------- bars */

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 112px 1fr 60px; gap: 10px; align-items: center; }
.bar-row .cap { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { display: block; height: 15px; background: rgba(255, 255, 255, 0.055);
  border-radius: 2px; overflow: hidden; }
/* must be block — an inline span ignores width and height */
.bar-row .fill { display: block; height: 100%; background: var(--d3); border-radius: 0 2px 2px 0; }
.bar-row .n { font-family: var(--mono); font-size: 12px; text-align: right;
  font-variant-numeric: tabular-nums; }
.bar-row .n i { color: var(--dim); font-style: normal; }

/* --------------------------------------------------------------- stages */

.stages { display: flex; flex-direction: column; gap: 4px; }
.stage { display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 2px; cursor: pointer; }
.stage .nm { font-size: 13px; font-weight: 500; }
.stage .ct { font-family: var(--mono); font-size: 15px; font-weight: 600; }
.stage .pc { font-family: var(--mono); font-size: 10.5px; opacity: .72; margin-left: 7px; }

/* --------------------------------------------------------------- matrix */

table.matrix { border-collapse: separate; border-spacing: 2px; width: 100%; }
table.matrix th { padding: 4px 6px; text-align: center; font-family: var(--mono); font-size: 10px;
  letter-spacing: .1em; text-transform: uppercase; color: var(--dim); font-weight: 400; }
table.matrix th.rh { text-align: left; width: 58px; }
table.matrix td { text-align: center; padding: 11px 4px; border-radius: 2px; cursor: pointer;
  font-family: var(--mono); font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
table.matrix td.z { color: var(--dim); background: rgba(255, 255, 255, 0.03); font-weight: 400; cursor: default; }
table.matrix td:not(.z):hover { outline: 2px solid var(--text); outline-offset: -2px; }

/* --------------------------------------------------------------- tables */

.result-count { color: var(--mute); font-size: 12px; margin-bottom: 10px; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  background: var(--ink-2); font-family: var(--mono); font-size: 10px; letter-spacing: .1em;
  text-transform: uppercase; font-weight: 400; color: var(--dim); text-align: left;
  padding: 9px 11px; border-bottom: 1px solid var(--rule); white-space: nowrap;
  cursor: pointer; user-select: none; position: sticky; top: 0; z-index: 2;
}
table.data th:hover { color: var(--text); }
table.data th .arrow { margin-left: 4px; opacity: .35; }
table.data th.sorted .arrow { opacity: 1; color: var(--red); }
table.data td { padding: 9px 11px; border-bottom: 1px solid var(--rule-soft); vertical-align: top; line-height: 1.45; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover td { background: rgba(255, 255, 255, 0.03); }
table.data .num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
.cell-clip { display: inline-block; max-width: 340px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; vertical-align: bottom; }
.row-label { display: none; }
.muted { color: var(--mute); font-size: 12px; }

/* --------------------------------------------------------------- badges */

.badge { display: inline-block; padding: 2px 7px; border-radius: 2px; font-size: 11px;
  font-weight: 600; white-space: nowrap; font-family: var(--mono); }
.b-a     { background: var(--red); color: #fff; }
.b-b     { background: rgba(233, 75, 54, 0.2); color: #F1917F; }
.b-c     { background: rgba(255, 255, 255, 0.08); color: var(--mute); }
.b-green { background: rgba(46, 204, 138, 0.16); color: var(--green); }
.b-amber { background: rgba(245, 166, 35, 0.16); color: var(--amber); }
.b-red   { background: rgba(233, 75, 54, 0.16); color: var(--red); }
.b-gray  { background: rgba(255, 255, 255, 0.08); color: var(--mute); }
.b-warm  { background: rgba(214, 85, 63, 0.18); color: #E08E7C; }

/* -------------------------------------------------------------- filters */

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.fg { display: flex; flex-direction: column; gap: 4px; }
.filters input, .filters select {
  background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 2px; color: var(--text); padding: 7px 10px; outline: none;
}
.filters input { width: 210px; }
.filters input:focus, .filters select:focus { border-color: rgba(233, 75, 54, 0.6); }
.filters input::placeholder { color: var(--dim); }
.filters select option { background: var(--ink-3); }

.btn { background: rgba(233, 75, 54, 0.14); border: 1px solid rgba(233, 75, 54, 0.34);
  color: var(--red); border-radius: 2px; padding: 7px 13px; cursor: pointer; font-weight: 500; }
.btn:hover { background: rgba(233, 75, 54, 0.24); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-ghost { background: none; border-color: var(--rule); color: var(--mute); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
.btn-red { background: rgba(233, 75, 54, 0.1); border-color: rgba(233, 75, 54, 0.4); color: var(--red); }
.btn-on { background: var(--red); border-color: var(--red); color: #fff; }

/* ----------------------------------------------------------------- work */

.work-row { display: grid; grid-template-columns: 30px 1fr auto; gap: 14px; padding: 14px 16px;
  border-bottom: 1px solid var(--rule-soft); align-items: start; cursor: pointer; }
.work-row:hover { background: rgba(255, 255, 255, 0.03); }
.work-row .idx { font-family: var(--mono); font-size: 12px; color: var(--dim); padding-top: 3px; }
.work-row .ttl { font-weight: 600; font-size: 14.5px; }
.work-row .why { font-size: 12.5px; color: var(--mute); margin-top: 4px; max-width: 78ch; }
.work-row .tags { display: flex; gap: 7px; margin-top: 8px; flex-wrap: wrap; align-items: center; }
.work-row .act { text-align: right; white-space: nowrap; }
.work-row .act .score { font-family: var(--mono); font-size: 19px; font-weight: 600; }

.sect { display: flex; align-items: baseline; gap: 12px; padding: 18px 16px 11px; }
.sect h3 { font-size: 14.5px; }
.sect .rule { flex: 1; height: 1px; background: var(--rule); }

.evt-row { display: grid; grid-template-columns: 70px 1fr auto; gap: 14px; padding: 10px 16px;
  border-bottom: 1px solid var(--rule-soft); align-items: center; cursor: pointer; }
.evt-row:hover { background: rgba(255, 255, 255, 0.03); }
.evt-row .d { font-family: var(--mono); font-size: 11.5px; color: var(--mute); }

/* ------------------------------------------------------------------ map */

#map { height: 60vh; min-height: 380px; border-radius: 2px; border: 1px solid var(--rule); }
.mini-map svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 14px; font-size: 11.5px; margin-top: 9px; color: var(--mute); }
.legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.leaflet-popup-content-wrapper { background: var(--ink-3); color: var(--text); border-radius: 3px; }
.leaflet-popup-tip { background: var(--ink-3); }
.popup-title { font-weight: 700; margin-bottom: 5px; }
.popup-row { font-size: 12px; color: var(--mute); }
.popup-row span { color: var(--text); }

/* --------------------------------------------------------------- drawer */

.drawer-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); opacity: 0;
  pointer-events: none; transition: opacity .16s; z-index: 40; }
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; right: 0; height: 100%; width: min(560px, 100%);
  background: var(--ink-2); border-left: 1px solid var(--rule); transform: translateX(100%);
  transition: transform .2s ease; z-index: 50; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer-head { padding: 15px 20px; border-bottom: 1px solid var(--rule); display: flex; align-items: center; gap: 12px; }
.drawer-title { font-size: 15px; font-weight: 700; flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px; }
.drawer-foot { padding: 13px 20px; border-top: 1px solid var(--rule); display: flex; gap: 10px; align-items: center; }
.drawer-foot .spacer { flex: 1; }

.field { margin-bottom: 13px; }
.field label { display: block; margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 2px; color: var(--text); padding: 8px 10px; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: rgba(233, 75, 54, 0.6); }
.field textarea { min-height: 76px; resize: vertical; line-height: 1.5; }
.field select option { background: var(--ink-3); }
.field-readonly input { opacity: .5; }

/* ---------------------------------------------------------------- misc */

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--ink-3); border: 1px solid var(--rule); border-radius: 2px; padding: 10px 18px;
  z-index: 60; transition: transform .2s; box-shadow: 0 8px 28px rgba(0, 0, 0, .5); }
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { border-color: rgba(233, 75, 54, .6); color: var(--red); }

.login-screen { position: fixed; inset: 0; background: var(--ink); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-box { background: var(--ink-2); border: 1px solid var(--rule); border-radius: 3px;
  padding: 32px; width: 100%; max-width: 340px; }
.login-box .brand { margin-bottom: 18px; }
.login-box p { color: var(--mute); font-size: 12px; margin-bottom: 18px; }
.login-box input { width: 100%; background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.13); border-radius: 2px; color: var(--text);
  padding: 10px 12px; margin-bottom: 12px; outline: none; }
.login-box input:focus { border-color: rgba(233, 75, 54, 0.6); }
.login-box .btn { width: 100%; padding: 10px; }
.login-error { color: var(--red); font-size: 12px; margin-top: 10px; min-height: 16px; }

#tip { position: fixed; z-index: 99; pointer-events: none; opacity: 0; transition: opacity .1s;
  background: #000; color: #fff; border: 1px solid rgba(255, 255, 255, .22); border-radius: 2px;
  padding: 7px 10px; font-size: 12px; max-width: 260px; line-height: 1.45; }
#tip.on { opacity: 1; }
#tip b { font-family: var(--mono); }

.hidden { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* -------------------------------------------------- phone: cards, rail off */

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .rail { display: none; }
  .topbar { padding: 0 12px; gap: 10px; overflow-x: auto; }
  .topbar-sub { display: none; }
  .main { padding: 14px 12px 30px; }
  .filters input { width: 100%; }
  .fg { flex: 1 1 140px; }

  .table-wrap { overflow-x: visible; }
  table.data, table.data thead, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data thead { display: none; }
  table.data tbody tr { background: var(--ink-2); border: 1px solid var(--rule);
    border-radius: 2px; padding: 12px 14px; margin-bottom: 10px; }
  table.data tbody tr:hover td { background: none; }
  table.data td { border: none; padding: 3px 0; display: flex; gap: 10px; align-items: baseline; }
  .cell-clip { display: inline; max-width: none; white-space: normal; }
  .row-label { display: block; flex: 0 0 90px; font-family: var(--mono); font-size: 10px;
    letter-spacing: .05em; text-transform: uppercase; color: var(--dim); }
  table.data td:first-child { font-weight: 700; font-size: 14px; padding-bottom: 7px; }
  table.data td:first-child .row-label { display: none; }
  table.data td.td-empty { display: none; }
  .drawer { width: 100%; }
  .work-row { grid-template-columns: 1fr auto; }
  .work-row .idx { display: none; }
}
