/* SECBLAST base — palette, typography, layout primitives, common components.
 * Aesthetic: Bloomberg dark with breathing room; brutally pruned for analyst
 * usefulness; IBM Plex Mono + Plex Sans Condensed; tabular numerals.
 */

:root {
  /* LIGHT MODE — light gray surfaces, dark text. */
  /* Surfaces */
  --bg:        #f0f0f0;   /* page background — easy on eyes (not pure white) */
  --bg-2:      #e6e6e8;   /* command row, chip strips */
  --bg-3:      #d8d8da;   /* darker stripe, function-key wells */
  --panel:     #ffffff;   /* main content panel */
  --panel-2:   #f5f5f6;   /* secondary panel, drawer */
  --row:       #ffffff;
  --row-h:     #ebebee;   /* row hover */
  --border:    #d0d0d3;
  --border-2:  #b0b0b5;
  --line:      #e2e2e6;   /* table dividers */
  /* Text */
  --fg:        #14141a;   /* primary text — near black, slight cool */
  --fg-2:      #3a3a40;   /* secondary */
  --fg-dim:    #6c6c72;   /* dim */
  --fg-mute:   #989898;   /* mute */
  /* Active accent — dark on light. Variable names kept (amber/cyan) so rules
   * across the codebase keep working. Active state = darkest near-black. */
  --amber:     #1a1a1a;   /* primary active */
  --amber-2:   #000000;   /* strong */
  --cyan:      #4a4a52;   /* secondary (links, headings) */
  --cyan-2:    #1a1a1a;
  --teal:      #6a6a72;
  --magenta:   #707078;
  --blue:      #707078;
  --gold:      #4a4a52;
  /* Form-rail tints — saturated enough to read on white surfaces. */
  --form-10K:  #3d6c95;   /* cool slate-blue */
  --form-10Q:  #3d8585;   /* teal */
  --form-8K:   #b07a25;   /* amber/ochre */
  --form-4:    #835088;   /* mauve */
  --form-3:    #4d6a90;   /* cornflower */
  --form-S:    #3d8055;   /* sage green */
  /* Financial signal — chosen for contrast on white */
  --green:     #1f8e4a;
  --red:       #c93030;
  /* Type */
  --sans: "IBM Plex Sans Condensed", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.45;
  overflow: hidden;
  font-feature-settings: "tnum" 1, "ss01" 1;
}
::selection { background: rgba(20,20,30,0.18); color: var(--fg); }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 1px 5px;
  color: var(--fg-2);
}

/* ---- Layout ---- */
#app {
  display: grid;
  grid-template-rows: 36px 44px 1fr 22px;
  height: 100vh;
}

/* Header */
.hdr {
  display: flex;
  align-items: center;
  background: linear-gradient(180deg, #f8f8fa 0%, #f0f0f3 100%);
  border-bottom: 1px solid var(--border);
  padding: 0 14px;
  gap: 16px;
}
.hdr-brand { display: flex; align-items: baseline; gap: 6px; user-select: none; }
.brand-mark { color: var(--amber); font-size: 18px; line-height: 1; transform: translateY(2px); }
.brand-name { font-weight: 700; letter-spacing: 0.16em; font-size: 13px; color: var(--fg); }

.sec-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--fg-2);
  cursor: pointer;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--bg-2);
  white-space: nowrap;
  max-width: 380px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sec-pill:hover { border-color: var(--amber); }
.sec-pill.empty { color: var(--fg-mute); border-style: dashed; cursor: default; }
.sec-pill .ticker { color: var(--amber); font-weight: 700; }
.sec-pill .name   { color: var(--fg); font-weight: 600; }
.sec-pill .meta   { color: var(--fg-dim); font-size: 11px; }

.nav { display: flex; gap: 4px; margin-left: auto; }
.nav button {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 6px 12px;
  color: var(--fg-dim);
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: color 100ms;
}
.nav button:hover { color: var(--fg); }
.nav button.active { color: var(--amber); border-bottom-color: var(--amber); }
.nav button .num {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--fg-mute);
  font-weight: 600;
}
.nav button.active .num { color: var(--amber); }

.hdr-clock { display: flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 12px; color: var(--fg-2); }
.mkt {
  font-size: 9px;
  color: var(--green);
  text-shadow: 0 0 6px rgba(31,142,74,0.5);
}
.mkt.closed { color: var(--red); text-shadow: 0 0 6px rgba(201,48,48,0.5); }
.tz { color: var(--fg-mute); font-size: 10.5px; }

/* Command row — primary interaction surface. Should feel like the Spotlight /
 * cmd-K bar of a focused tool: roomy, single icon, clear placeholder. */
.cmd-row {
  display: flex;
  align-items: center;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 0 8px 0 14px;
  gap: 6px;
  transition: box-shadow 120ms, border-color 120ms;
}
.cmd-row:focus-within {
  background: var(--row);
  border-bottom-color: var(--fg-2);
  box-shadow: inset 0 -2px 0 0 var(--fg);
}
.cmd-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--fg-dim);
  flex-shrink: 0;
  cursor: text;
  width: 22px;
}
.cmd-row:focus-within .cmd-icon { color: var(--fg); }
.cmd-input-wrap { position: relative; flex: 1; display: flex; align-items: center; min-width: 0; }
/* Decoy username/password inputs that distract password managers from #cmd.
 * `display:none` would make some managers ignore them entirely; we put them
 * off-screen but still in the layout so they still "exist" to the manager. */
.sb-decoy {
  position: absolute;
  left: -10000px;
  top: -10000px;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
#cmd {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 0 12px;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--fg);
  letter-spacing: 0;
  caret-color: var(--fg);
  min-width: 0;
}
#cmd::placeholder {
  color: var(--fg-mute);
  letter-spacing: 0;
  font-family: var(--sans);
  font-size: 13px;
  font-style: normal;
}
.cmd-hint {
  pointer-events: none;
  padding-right: 4px;
  color: var(--fg-mute);
  font-family: var(--sans);
  font-size: 11.5px;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.cmd-keys {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  padding-right: 6px;
}
.cmd-keys kbd {
  font-size: 10px;
  padding: 2px 6px;
  opacity: 0.7;
  transition: opacity 120ms;
}
.cmd-row:focus-within .cmd-keys kbd { opacity: 0.35; }
.cmd-row:hover .cmd-keys kbd { opacity: 1; }

/* Workspace */
.workspace { display: grid; grid-template-columns: 1fr; min-height: 0; }
.workspace.with-rail { grid-template-columns: 1fr 300px; }
.pane { display: flex; flex-direction: column; background: var(--panel); min-width: 0; min-height: 0; }
.pane-r { border-left: 1px solid var(--border); }
.pane-r.hidden { display: none; }
.view { flex: 1; overflow: auto; padding: 0; }
.view.fixed { overflow: hidden; padding: 0; display: flex; flex-direction: column; min-height: 0; }
.view::-webkit-scrollbar, .rail-view::-webkit-scrollbar { width: 9px; height: 9px; }
.view::-webkit-scrollbar-thumb, .rail-view::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }
.rail-view { flex: 1; overflow: auto; }

/* Status */
.status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  background: linear-gradient(180deg, #f0f0f3 0%, #e8e8eb 100%);
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--fg-mute);
}
.s-mid { display: flex; gap: 14px; align-items: center; }
.s-left { color: var(--fg-2); }

/* ---- Common components ---- */

/* Cards (KPI/snapshot) */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1px;
  background: var(--border);
}
.card {
  background: var(--panel);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 4px;
  cursor: default;
}
.card.clickable { cursor: pointer; transition: background 80ms; }
.card.clickable:hover { background: var(--row-h); }
.card .lbl { color: var(--fg-mute); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; }
.card .val { color: var(--fg); font-family: var(--mono); font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.card .val.amber { color: var(--amber-2); }
.card .val.cyan  { color: var(--cyan-2); }
.card .val.green { color: var(--green); }
.card .val.red   { color: var(--red); }
.card .val.gold  { color: var(--gold); }
.card .sub { color: var(--fg-dim); font-size: 11px; font-family: var(--mono); }
.card .sub.green { color: var(--green); }
.card .sub.red   { color: var(--red); }

/* KV grid */
.kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  column-gap: 14px;
  row-gap: 2px;
  font-family: var(--mono);
  font-size: 12px;
}
.kv .k { color: var(--fg-mute); text-transform: uppercase; font-size: 10.5px; letter-spacing: 0.08em; padding-top: 3px; }
.kv .v { color: var(--fg); white-space: pre-wrap; word-break: break-word; }

/* Section wrapper */
.section { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.section h3 {
  margin: 0 0 10px;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--cyan);
  text-transform: uppercase;
  display: flex; align-items: center; gap: 8px;
}
.section h3::before {
  content: ''; display: block; width: 8px; height: 1px; background: var(--cyan);
}

/* Tables */
table.t {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 12px;
}
table.t thead th {
  position: sticky; top: 0;
  background: var(--bg-2);
  color: var(--cyan);
  font-weight: 600;
  text-align: left;
  padding: 5px 10px;
  border-bottom: 1px solid var(--border-2);
  white-space: nowrap;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  z-index: 1;
}
table.t thead th.num { text-align: right; }
table.t tbody td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--line);
  color: var(--fg-2);
  white-space: nowrap;
  vertical-align: top;
}
table.t tbody td.num { text-align: right; font-variant-numeric: tabular-nums; color: var(--fg); }
table.t tbody td.green { color: var(--green); }
table.t tbody td.red   { color: var(--red); }
table.t tbody td.dim   { color: var(--fg-dim); }
table.t tbody td.trunc { max-width: 32ch; overflow: hidden; text-overflow: ellipsis; }
table.t tbody tr.hov, table.t tbody tr.clickable { cursor: pointer; }
table.t tbody tr:hover td { background: var(--row-h); }

/* Form badges (color-coded by form type) */
.form-badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 2px;
  border: 1px solid var(--border-2);
  background: var(--bg-3);
  color: var(--fg-dim);
  white-space: nowrap;
  line-height: 1.3;
}
.form-badge.f10K { color: var(--form-10K); border-color: var(--form-10K); }
.form-badge.f10Q { color: var(--form-10Q); border-color: var(--form-10Q); }
.form-badge.f8K  { color: var(--form-8K);  border-color: var(--form-8K); }
.form-badge.f4   { color: var(--form-4);   border-color: var(--form-4); }
.form-badge.f3,
.form-badge.f5   { color: var(--form-3);   border-color: var(--form-3); }
.form-badge.fS   { color: var(--form-S);   border-color: var(--form-S); }

/* Chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-3);
  border: 1px solid var(--border-2);
  color: var(--fg-2);
  padding: 3px 10px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
  transition: all 80ms;
  white-space: nowrap;
}
.chip:hover { color: var(--fg); border-color: var(--cyan); }
.chip.active { background: rgba(20,20,30,0.08); border-color: var(--amber); color: var(--amber-2); }
.chip .x { color: var(--fg-mute); font-size: 11px; }
.chip .x:hover { color: var(--red); }

/* Empty state */
.empty {
  padding: 24px;
  text-align: center;
  color: var(--fg-mute);
  font-family: var(--mono);
  font-size: 12.5px;
  font-style: italic;
}
.empty .action { display: inline-block; margin-top: 10px; }

/* Spinner */
.spinner {
  display: inline-block;
  color: var(--amber);
  font-family: var(--mono);
}

/* Links + clickable */
a.link, .clickable {
  color: var(--cyan);
  text-decoration: none;
  cursor: pointer;
  border-bottom: 1px dotted transparent;
}
a.link:hover, .clickable:hover { color: var(--cyan-2); border-bottom-color: var(--cyan); }

/* Color utility classes */
.muted { color: var(--fg-mute); }
.dim   { color: var(--fg-dim); }
.amber { color: var(--amber-2); }
.cyan  { color: var(--cyan-2); }
.green { color: var(--green); }
.red   { color: var(--red); }
.gold  { color: var(--gold); }
.magenta { color: var(--magenta); }
.mono  { font-family: var(--mono); }
.right { text-align: right; }

/* ---- Cmd-bar autocomplete ---- */
.ac-drop {
  position: absolute;
  top: calc(100% + 1px);
  left: 0; right: 0;
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  border-top: 2px solid var(--amber);
  box-shadow: 0 16px 40px rgba(0,0,0,0.18), 0 0 0 1px rgba(20,20,30,0.05);
  max-height: 50vh;
  overflow-y: auto;
  z-index: 80;
  font-family: var(--mono);
  font-size: 12.5px;
}
.ac-drop.hidden { display: none; }
.ac-section {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 4px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--fg-mute);
  text-transform: uppercase;
  position: sticky; top: 0; z-index: 1;
}
.ac-section .count { margin-left: auto; color: var(--fg-mute); font-family: var(--mono); }
.ac-row {
  display: grid;
  grid-template-columns: 18px 96px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 6px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
  color: var(--fg-2);
  transition: background 50ms;
}
.ac-row:hover { background: var(--row-h); }
.ac-row.active {
  background: rgba(20,20,30,0.08);
  color: var(--fg);
}
.ac-row .ic { text-align: center; color: var(--fg-mute); font-size: 11px; }
.ac-row .ic.watch  { color: var(--amber); }
.ac-row .ic.recent { color: var(--cyan); }
.ac-row .ic.screen { color: var(--magenta); }
.ac-row .ic.search { color: var(--gold); }
.ac-row .pri {
  color: var(--amber-2);
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ac-row .pri.screen { color: var(--cyan-2); }
.ac-row .pri.search { color: var(--fg); }
.ac-row .desc {
  color: var(--fg-dim);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--sans);
  letter-spacing: 0.02em;
}
.ac-row .hint {
  color: var(--fg-mute);
  font-size: 10.5px;
  font-family: var(--sans);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}
.ac-row mark {
  background: rgba(20,20,30,0.12);
  color: var(--fg);
  padding: 0 1px;
  border-radius: 1px;
}
.ac-empty { padding: 14px 12px; color: var(--fg-mute); font-style: italic; font-size: 12px; }
.ac-foot {
  padding: 5px 12px;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  color: var(--fg-mute);
  font-family: var(--sans);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  display: flex; gap: 14px;
}

/* ---- Drawer ---- */
.drawer {
  position: fixed;
  top: 0; right: 0;
  width: 60vw;
  max-width: 1100px;
  height: 100vh;
  background: var(--panel);
  border-left: 1px solid var(--border-2);
  box-shadow: -16px 0 40px rgba(0,0,0,0.6);
  display: flex; flex-direction: column;
  z-index: 200;
  transition: transform 160ms ease-out;
}
.drawer.hidden { transform: translateX(105%); pointer-events: none; }
.drawer-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--fg-dim);
  text-transform: uppercase;
}
#drawer-title { color: var(--cyan); font-family: var(--mono); }
.drawer-actions { display: flex; gap: 6px; }
.drawer-actions button {
  background: var(--bg);
  border: 1px solid var(--border-2);
  color: var(--fg-2);
  padding: 4px 10px;
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.06em;
}
.drawer-actions button:hover { border-color: var(--amber); color: var(--amber); }
#drawer-frame { flex: 1; width: 100%; border: none; background: white; }

/* ---- Help overlay ---- */
.help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 300;
}
.help-overlay.hidden { display: none; }
.help-card {
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  border-top: 2px solid var(--amber);
  width: min(720px, 90vw);
  max-height: 80vh;
  overflow: auto;
}
.help-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
}
.help-title { font-family: var(--sans); font-size: 12px; letter-spacing: 0.12em; color: var(--amber); text-transform: uppercase; }
#help-close { background: transparent; border: none; color: var(--fg-mute); font-size: 14px; }
#help-close:hover { color: var(--red); }
.help-body { padding: 14px; font-family: var(--mono); font-size: 12px; color: var(--fg-2); }
.help-body h4 { font-family: var(--sans); color: var(--cyan); font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; margin: 14px 0 6px; }
.help-body table { width: 100%; border-collapse: collapse; }
.help-body td { padding: 3px 0; vertical-align: top; }
.help-body td.k { color: var(--fg); width: 200px; font-family: var(--mono); }
.help-body td.d { color: var(--fg-dim); }

/* Subtle CSS-only fade-in on every screen render */
.view > * { animation: fade-in 140ms ease-out; }
@keyframes fade-in {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 1; transform: translateY(0); }
}
