/* Abundance community command centre.

   The palette is lifted from the Abundance mark: a deep forest ground, cream
   ink, and one green accent. Where something needs to separate two things it
   uses two steps of that one hue, or the accent against neutral grey. Nothing
   else carries colour except the two delta directions and the reserved status
   words, and those are text, never a filled pill.

   Order: tokens, base, shell, components, overlays, responsive. Nothing below
   the token block hardcodes a colour. */

:root {
  --bg: #0a120e;
  --panel: #0f1a14;
  --panel2: #132019;
  --raise: #182721;
  --line: #1c2c24;
  --line2: #28392f;

  --accent: #3fae74;
  --accent-2: #25704b;
  --accent-soft: rgba(63, 174, 116, 0.12);
  --accent-line: rgba(63, 174, 116, 0.36);

  --text: #f3efe4;
  --text2: #b3bfb7;
  --text3: #7f8f86;
  --text4: #5c6b63;

  --pos: #5fcf93;
  --neg: #e07a6a;
  --warn: #e0b35a;

  --sans: "DM Sans", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --r: 14px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font-family: inherit; }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: none; color: var(--text); }

/* small type: every eyebrow, label and column head in the interface */
.cap {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--text4);
  font-weight: 500;
}
.mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn { color: var(--warn); }
.dim { color: var(--text4); }
.muted { color: var(--text3); }

/* ---------- splash ---------- */

#splash {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 18px;
  transition: opacity 0.4s ease;
}
#splash.off { opacity: 0; pointer-events: none; }
#splash img { width: 64px; height: 64px; border-radius: 16px; }
#splash .cap { letter-spacing: 0.22em; }

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

.shell { display: flex; flex-direction: column; min-height: 100vh; }

.top {
  height: 64px;
  background: rgba(10, 18, 14, 0.88);
  border-bottom: 1px solid var(--line);
  padding: 0 34px;
  display: flex; align-items: center; gap: 20px;
  position: sticky; top: 0; z-index: 400;
  backdrop-filter: blur(16px);
}

.brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.brand .mark { width: 32px; height: 32px; border-radius: 9px; display: block; }
.brand-txt { display: flex; align-items: center; gap: 12px; min-width: 0; white-space: nowrap; }
.brand-txt b { font-size: 14px; font-weight: 500; letter-spacing: -0.005em; }
.brand-sep { width: 1px; height: 20px; background: var(--line2); }
.brand-txt span { font-size: 11.5px; color: var(--text3); }

.top-right { display: flex; align-items: center; gap: 16px; margin-left: auto; flex-shrink: 0; }

.src-pill {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text2); white-space: nowrap;
}
.pulse { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); flex-shrink: 0;
  animation: pulse 2.4s var(--ease) infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.synced { font-family: var(--mono); font-size: 10px; color: var(--text4); white-space: nowrap; letter-spacing: 0.04em; }
.sample-badge {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.13em; color: var(--text4);
  border: 1px solid var(--line2); padding: 3px 8px; border-radius: 5px; white-space: nowrap;
}

.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; }
.seg button {
  appearance: none; border: 0; background: transparent; color: var(--text3);
  font-size: 12.5px; font-weight: 400; padding: 6px 13px; border-radius: 7px; cursor: pointer;
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}
.seg button:hover { color: var(--text2); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--text); }

.kbd {
  font-family: var(--mono); font-size: 9px; color: var(--text4);
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px; line-height: 1.3;
}

.btn {
  appearance: none; background: var(--panel); border: 1px solid var(--line2); color: var(--text);
  font-size: 12.5px; padding: 0 14px; height: 36px; border-radius: 9px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease);
}
.btn:hover { background: var(--panel2); border-color: var(--line2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #07130d; font-weight: 500; }
.btn.primary:hover { background: var(--pos); border-color: var(--pos); }
.btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.btn[disabled]:active { transform: none; }
.btn:focus-visible, .seg button:focus-visible, .tab:focus-visible, select:focus-visible, input:focus-visible {
  outline: 1px solid var(--accent-line); outline-offset: 1px;
}

/* tabs: underline only, no pills */
.tabs {
  display: flex; gap: 26px; padding: 0 34px;
  background: var(--bg); border-bottom: 1px solid var(--line);
  position: sticky; top: 64px; z-index: 380;
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  appearance: none; background: none; border: 0; border-bottom: 1px solid transparent;
  color: var(--text3); font-size: 13.5px; font-weight: 400; padding: 15px 0;
  cursor: pointer; white-space: nowrap;
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease);
  display: flex; align-items: center; gap: 7px;
}
.tab:hover { color: var(--text2); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tab .kbd { font-size: 9px; }
.tab .pip {
  font-family: var(--mono); font-size: 9.5px; color: var(--text4);
  border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; line-height: 1.5;
}

/* filter bar: from, to, dimension filters, reset */
.bar {
  background: var(--bg); border-bottom: 1px solid var(--line);
  padding: 14px 34px; display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-end;
  position: sticky; top: 113px; z-index: 300;
}
.fg { display: flex; flex-direction: column; gap: 6px; flex: 0 1 auto; min-width: 128px; }
.fl { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.13em; text-transform: uppercase; color: var(--text4); font-weight: 500; }
.fg select, .fg input {
  background: var(--panel); border: 1px solid var(--line2); color: var(--text);
  font-size: 12.5px; padding: 0 11px; height: 36px; border-radius: 9px; min-width: 150px;
}
.fg input::placeholder { color: var(--text4); }
.bar .spacer { margin-left: auto; }
#scope { font-size: 11.5px; color: var(--text4); padding-bottom: 9px; white-space: nowrap; }
#scope b { color: var(--text2); font-weight: 500; }

.wrap { padding: 22px 34px 34px; flex: 1; }
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g32 { grid-template-columns: 3fr 2fr; gap: 16px; }

/* ---------- tiles: label, number, one line of context, signed delta ---------- */

.tile {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  padding: 19px 21px 21px;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}
.tile:hover { background: var(--panel2); border-color: var(--line2); }
.tile .lab { font-size: 12.5px; color: var(--text3); margin-bottom: 12px; }
.tile .val {
  font-size: 27px; font-weight: 500; line-height: 1.05;
  letter-spacing: -0.028em; color: var(--text); font-variant-numeric: tabular-nums;
}
.tile .val small { font-size: 14px; color: var(--text3); font-weight: 400; letter-spacing: 0; margin-left: 4px; }
.tile .sub { font-size: 11.5px; color: var(--text4); margin-top: 8px; line-height: 1.4; }

/* ---------- panels ---------- */

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r);
  display: flex; flex-direction: column; min-width: 0; overflow: hidden;
}
.panel > header {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 18px 22px 0;
}
.panel > header h3 { font-size: 13.5px; font-weight: 500; color: var(--text); letter-spacing: -0.005em; }
.panel > header .meta {
  margin-left: auto; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.13em;
  text-transform: uppercase; color: var(--text4); font-weight: 500;
}
.panel > header .btn { margin-left: 10px; height: 30px; font-size: 12px; }
.panel .body { padding: 16px 22px 20px; }
.panel .body.tight { padding: 12px 0 4px; }
.panel .body.tight > table, .panel .body.tight > ul.list { width: 100%; }

/* section head with the rule line running to the edge */
.dsec { display: flex; flex-direction: column; gap: 12px; }
.dsec h3 { font-size: 13px; font-weight: 500; color: var(--text); display: flex; align-items: center; gap: 12px; }
.dsec h3::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.hint { font-size: 12.5px; color: var(--text3); }
.empty { padding: 28px 16px; text-align: center; color: var(--text4); font-size: 12.5px; }

/* status words, never a filled pill */
.k-good { color: var(--pos); }
.k-warn { color: var(--warn); }
.k-bad { color: var(--neg); }
.k-mute { color: var(--text4); }
.chip { font-size: 11.5px; color: var(--text2); border: 1px solid var(--line2); border-radius: 6px; padding: 3px 8px; display: inline-flex; align-items: center; gap: 6px; }
.chip::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: none; }
.chip.k-good { color: var(--pos); }
.chip.k-warn { color: var(--warn); }
.chip.k-bad { color: var(--neg); }
.chip.k-mute { color: var(--text4); }

.tag {
  display: inline-block; font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em;
  padding: 2px 7px; border-radius: 5px; background: var(--raise);
  border: 1px solid var(--line2); color: var(--text3);
}

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

table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data th {
  position: sticky; top: 0; z-index: 2; text-align: left; padding: 10px 12px;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.13em; text-transform: uppercase;
  color: var(--text4); font-weight: 500; background: var(--panel);
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td {
  padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--text2);
  white-space: nowrap; font-variant-numeric: tabular-nums; vertical-align: middle;
}
table.data tbody tr:hover td { background: rgba(255, 255, 255, 0.025); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data td.n, table.data th.n { text-align: right; }
table.data td a { color: var(--text2); }
table.data td a:hover { color: var(--text); }

.person { display: flex; align-items: center; gap: 10px; }
.av {
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
  background: var(--raise); border: 1px solid var(--line2);
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.04em; color: var(--text2);
}
.av.coach { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.person .who { color: var(--text); font-weight: 500; }
.person .hint { font-size: 11px; color: var(--text4); }

/* bars inside cells: thin, one colour */
.mbar, .bar-track {
  display: inline-block; width: 100%; max-width: 96px; height: 3px;
  background: var(--line2); border-radius: 2px; vertical-align: middle;
  overflow: hidden;
}
.bar-fill { height: 100%; border-radius: 2px; background: var(--accent); display: block; }
.bar-fill.good { background: var(--pos); }
.bar-fill.warn { background: var(--warn); }
.bar-fill.bad { background: var(--neg); }

/* ---------- lists ---------- */

.list { list-style: none; }
.list li {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 22px; border-bottom: 1px solid var(--line); font-size: 12.5px; color: var(--text2);
}
.list li:last-child { border-bottom: 0; }
.list li .grow { flex: 1; min-width: 0; }
.list li .who { color: var(--text); font-weight: 500; }
.list li .why { color: var(--text4); font-size: 11.5px; }
.list li:first-child .why:only-child { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.13em; text-transform: uppercase; }
.thread { max-height: 460px; overflow: auto; }

/* ---------- overlays ---------- */

.scrim {
  position: fixed; inset: 0; z-index: 500; background: rgba(6, 12, 9, 0.72);
  backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center; padding: 11vh 20px 20px;
}
.scrim[hidden] { display: none; }

.palette {
  width: 100%; max-width: 620px; background: var(--panel); border: 1px solid var(--line2);
  border-radius: var(--r); overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.palette input {
  width: 100%; font-size: 15px; color: var(--text); background: transparent;
  border: 0; border-bottom: 1px solid var(--line); padding: 16px 18px;
}
.palette input::placeholder { color: var(--text4); }
.palette input:focus { outline: none; }
.palette .res { max-height: 46vh; overflow: auto; }
.palette .res button {
  width: 100%; text-align: left; appearance: none; background: transparent; border: 0;
  color: var(--text2); font-size: 13px; padding: 11px 18px; cursor: pointer;
  display: flex; align-items: center; gap: 10px;
}
.palette .res button[aria-current="true"], .palette .res button:hover { background: var(--accent-soft); color: var(--text); }
.palette .res .kind { margin-left: auto; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.13em; text-transform: uppercase; color: var(--text4); }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(580px, 94vw); z-index: 600;
  background: var(--bg); border-left: 1px solid var(--line2);
  box-shadow: -24px 0 60px rgba(0, 0, 0, 0.45);
  display: flex; flex-direction: column;
}
.drawer[hidden] { display: none; }
.drawer > header {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 22px; border-bottom: 1px solid var(--line);
}
.drawer > header > .grow { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; }
.drawer > header .av { width: 44px; height: 44px; border-radius: 12px; font-size: 13px; }
.drawer > header b { font-size: 14px; font-weight: 500; display: block; }
.drawer .body { padding: 20px 22px 28px; overflow: auto; display: flex; flex-direction: column; gap: 16px; }
.x {
  appearance: none; background: transparent; border: 0; color: var(--text4);
  font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: 7px;
}
.x:hover { color: var(--text); background: var(--raise); }

.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 700; display: grid; gap: 8px; }
.toast {
  background: var(--raise); border: 1px solid var(--line2); border-radius: 9px;
  padding: 10px 16px; font-size: 12.5px; color: var(--text2);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

.tipwrap { position: relative; }
.tip {
  position: absolute; bottom: calc(100% + 8px); left: 0; z-index: 50; width: 250px;
  background: var(--raise); border: 1px solid var(--line2); border-radius: 9px;
  padding: 10px 12px; font-size: 12px; color: var(--text3); line-height: 1.45;
}
.tip[hidden] { display: none; }

/* ---------- foot ---------- */

.foot {
  padding: 14px 34px; background: var(--bg); border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.13em;
  text-transform: uppercase; color: var(--text4);
}
.foot .spacer { margin-left: auto; }


/* ---------- overview: context line, tile grid, legend, brief ---------- */

.ctx { display: flex; align-items: baseline; gap: 12px; margin-bottom: 18px; font-size: 12.5px; color: var(--text3); }
.ctx .cap { margin-left: auto; white-space: nowrap; }
.ctx b { color: var(--text); font-weight: 500; }

.kgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.kgrid.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kgrid + .dsec, .kgrid + .grid { margin-top: 22px; }

.legend { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.legend .lg { display: inline-flex; align-items: center; gap: 7px; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.13em; text-transform: uppercase; color: var(--text4); }
.legend .lg i { width: 14px; height: 1px; display: inline-block; }

.brief p { font-size: 13px; color: var(--text2); line-height: 1.62; margin-bottom: 11px; }
.brief p:last-child { margin-bottom: 0; }
.brief b { color: var(--text); font-weight: 500; }

.list li .bar-track { width: 64px; flex: none; }
.list li a.who:hover { color: var(--accent); }

/* ---------- responsive ---------- */

@media (max-width: 1280px) {
  .src-pill { display: none; }
}
@media (max-width: 1280px) {
  .kgrid.k4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g32 { grid-template-columns: minmax(0, 1fr); }
  .synced { display: none; }
}
@media (max-width: 900px) {
  .g3, .g2 { grid-template-columns: minmax(0, 1fr); }
  .sample-badge { display: none; }
}
@media (max-width: 760px) {
  .top, .tabs, .bar, .wrap, .foot { padding-left: 16px; padding-right: 16px; }
  .tabs { position: static; }
  .bar { position: static; }
  .brand-txt span, .brand-sep { display: none; }
  .g4 { grid-template-columns: minmax(0, 1fr); }
  .kgrid.k4 { grid-template-columns: minmax(0, 1fr); }
}

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