

/* The kit. slots.md filled in: dark, warm charcoal greys, blue accent, system sans,
   6px radius, hairline rows, sentence-case muted column heads, tinted pills.
   scripts/build_css.sh turns this block into :root for public/css/app.css. */
:root {

  --color-bg: oklch(0.190 0.006 60);
  --color-surface: oklch(0.230 0.007 60);
  --color-raised: oklch(0.290 0.008 60);
  --color-field: oklch(0.160 0.005 60);
  --color-line: oklch(0.310 0.008 60);
  --color-line-hi: oklch(0.420 0.010 60);
  --color-text: oklch(0.950 0.008 80);
  --color-muted: oklch(0.700 0.012 70);
  --color-accent: oklch(0.740 0.120 230);
  --color-accent-lift: color-mix(in oklch, var(--color-accent) 88%, var(--color-text));
  --color-accent-ink: oklch(0.180 0.030 230);
  --color-up: oklch(0.760 0.150 150);
  --color-down: oklch(0.720 0.170 25);
  --color-warn: oklch(0.780 0.130 80);
  --color-tint-accent: oklch(0.300 0.060 230);
  --color-tint-up: oklch(0.300 0.060 150);
  --color-tint-down: oklch(0.300 0.070 25);
  --color-tint-warn: oklch(0.300 0.060 80);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;

  --text-hero: 40px;
  --text-title: 24px;
  --text-verdict: 18px;
  --text-section: 15px;
  --text-body: 14px;
  --text-meta: 13px;
  --text-pill: 12px;

  --radius-control: 6px;
  --radius-dialog: 8px;
  --shadow-pop: 0 12px 40px oklch(0 0 0 / 0.5);
  --ease-out: cubic-bezier(0.2, 0, 0, 1);
  --breakpoint-wide: 701px;

  --spacing: 8px;
  --control-h: 36px;
  --row-h: 44px;
  --field-row-h: 36px;
  --nav-h: 52px;
  --wrap: 1120px;
  --fields-w: 300px;
  --dur-fast: 120ms;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--color-bg); color: var(--color-text); font: 400 var(--text-body)/1.5 var(--font-sans); }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
button { font: inherit; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
h1, h2, h3, p, dl, dd, figure { margin: 0; }
table { border-collapse: collapse; }

/* Shell */
.tw-nav { height: var(--nav-h); border-bottom: 1px solid var(--color-line); }
.tw-nav__inner { display: flex; align-items: center; gap: 24px; height: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
.tw-nav__brand { margin-right: 8px; font-weight: 600; }
.tw-nav__link { color: var(--color-muted); }
.tw-nav__link:hover { color: var(--color-text); text-decoration: none; }
.tw-nav__link[aria-current="page"] { color: var(--color-text); }
.tw-nav__signout-form { margin-left: auto; }
.tw-nav__signout { padding: 0; border: 0; background: none; color: var(--color-muted); cursor: pointer; }
.tw-nav__signout:hover { color: var(--color-text); }
.tw-wrap { max-width: var(--wrap); margin: 0 auto; padding: 32px 24px 64px; }
.tw-wrap--narrow { max-width: 720px; }

.tw-guest { max-width: 380px; margin: 0 auto; padding: 48px 24px 64px; }
.tw-wordmark { margin-bottom: 40px; font-weight: 600; }

/* Page head and record layout */
.tw-back { display: inline-block; margin-bottom: 12px; color: var(--color-muted); }
.tw-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 24px; }
.tw-title { font-size: var(--text-title); font-weight: 600; line-height: 1.2; }
.tw-head__spacer { flex: 1; }
.tw-record { display: grid; grid-template-columns: minmax(0, 1fr) var(--fields-w); gap: 48px; align-items: start; }
.tw-fields { margin: 0; }
.tw-field-row { display: grid; grid-template-columns: 112px minmax(0, 1fr); align-items: center; gap: 12px; min-height: var(--field-row-h); }
.tw-field-row dt { color: var(--color-muted); }
.tw-field-row dd { font-variant-numeric: tabular-nums; }
.tw-field-row a { color: var(--color-accent); }

.tw-section { margin-bottom: 32px; }
.tw-section__head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 4px; padding-bottom: 8px; border-bottom: 1px solid var(--color-line); font-size: var(--text-section); font-weight: 600; }
.tw-section__count { color: var(--color-muted); font-size: var(--text-meta); font-weight: 400; }
.tw-section--narrow { max-width: 480px; }
.tw-section__link { margin-left: auto; color: var(--color-accent); font-size: var(--text-meta); font-weight: 400; }

/* Overview stats: a label above a number, the first one larger. */
.tw-stats { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px 48px; margin-bottom: 32px; }
.tw-stat dt { color: var(--color-muted); font-size: var(--text-meta); }
.tw-stat dd { font-size: var(--text-title); font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tw-stat--hero dd { font-size: var(--text-hero); }

.tw-prose { max-width: 60ch; margin-bottom: 8px; }
.tw-note { max-width: 60ch; color: var(--color-muted); }
.tw-note a, .tw-prose a { color: var(--color-accent); }
.tw-verdict { margin-bottom: 8px; font-size: var(--text-verdict); font-weight: 600; }
.tw-well { margin-bottom: 16px; padding: 12px 14px; border-left: 3px solid var(--color-down); border-radius: 0 var(--radius-control) var(--radius-control) 0; background: var(--color-field); font: 400 var(--text-meta)/1.5 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.tw-empty { padding-top: 12px; color: var(--color-muted); }
.tw-notice { margin: -8px 0 20px; }
.tw-empty a { color: var(--color-accent); }
.tw-mt-2 { margin-top: 16px; }
.tw-mt-3 { margin-top: 24px; }
.tw-mt-4 { margin-top: 32px; }

/* Tables */
.tw-table { width: 100%; font-variant-numeric: tabular-nums; }
.tw-table--conditions td:first-child { width: 45%; }
.tw-table th { height: 36px; padding: 0 8px; color: var(--color-muted); font-size: var(--text-meta); font-weight: 400; text-align: left; white-space: nowrap; }
.tw-table td { height: var(--row-h); padding: 0 8px; border-top: 1px solid var(--color-line); vertical-align: middle; }
.tw-table .tw-nowrap { white-space: nowrap; }
.tw-table > tbody:first-child > tr:first-child > td { border-top: 0; }
.tw-table th:first-child, .tw-table td:first-child { padding-left: 0; }
.tw-table th:last-child, .tw-table td:last-child { padding-right: 0; }
.tw-table .tw-num { text-align: right; }
.tw-table .tw-muted { color: var(--color-muted); }
.tw-table .tw-title-cell { font-weight: 600; }
.tw-table .tw-title-cell a { display: block; }
.tw-table .tw-title-cell a:hover { text-decoration: none; }
.tw-table tr[data-href] { cursor: pointer; }
.tw-table tr[data-href]:hover td { background: var(--color-surface); }
.tw-table .tw-meta { display: none; }
.tw-table .tw-row-actions { display: flex; gap: 16px; justify-content: flex-end; }
.tw-table .tw-row-actions a { color: var(--color-accent); }
.tw-table .tw-row-actions a.tw-danger { color: var(--color-down); }
.tw-up { color: var(--color-up); }
.tw-down { color: var(--color-down); }
.tw-muted { color: var(--color-muted); }

/* Pills */
.tw-pill { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; background: var(--color-raised); color: var(--color-muted); font-size: var(--text-pill); font-weight: 500; white-space: nowrap; }
.tw-pill--text { color: var(--color-text); }
.tw-pill--accent { background: var(--color-tint-accent); color: var(--color-accent); }
.tw-pill--up { background: var(--color-tint-up); color: var(--color-up); }
.tw-pill--down { background: var(--color-tint-down); color: var(--color-down); }
.tw-pill--warn { background: var(--color-tint-warn); color: var(--color-warn); }

/* Met and not-met marks on a market's conditions: neutral, because up and down mean profit and loss. */
.tw-mark { white-space: nowrap; color: var(--color-muted); }
.tw-mark::before { content: ""; display: inline-block; width: 10px; height: 0; margin: 0 8px 4px 0; border-top: 1.5px solid var(--color-muted); }
.tw-mark--met { color: var(--color-text); }
.tw-mark--met::before { width: 5px; height: 10px; margin: 0 8px 1px 2px; border: solid var(--color-up); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }

/* Controls */
.tw-btn { display: inline-flex; align-items: center; justify-content: center; height: var(--control-h); padding: 0 14px; border: 1px solid transparent; border-radius: var(--radius-control); background: var(--color-accent); color: var(--color-accent-ink); font-weight: 500; cursor: pointer; transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out); }
.tw-btn:hover { background: var(--color-accent-lift); text-decoration: none; }
.tw-btn:disabled { background: var(--color-raised); color: var(--color-muted); cursor: not-allowed; }
.tw-btn--secondary { border-color: var(--color-line-hi); background: transparent; color: var(--color-text); }
.tw-btn--secondary:hover { background: var(--color-surface); }
.tw-btn--danger { border-color: var(--color-down); background: transparent; color: var(--color-down); }
.tw-btn--danger:hover { background: var(--color-tint-down); }
.tw-btn--quiet { padding: 0; border: 0; background: none; color: var(--color-muted); }
.tw-btn--quiet:hover { background: none; color: var(--color-text); }
.tw-quiet-action { display: inline-flex; align-items: center; min-height: var(--control-h); padding: 0; border: 0; background: transparent; color: var(--color-accent); font-weight: 500; cursor: pointer; }
.tw-quiet-action:hover { text-decoration: underline; text-underline-offset: 3px; }
.tw-quiet-action:disabled { color: var(--color-muted); cursor: not-allowed; text-decoration: none; }
.tw-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.tw-actions--footer { justify-content: space-between; }

.tw-form-stack > * + * { margin-top: 18px; }
.tw-label { display: block; margin-bottom: 6px; color: var(--color-muted); font-size: var(--text-meta); }
.tw-field, .tw-select { height: var(--control-h); padding: 0 10px; border: 1px solid var(--color-line-hi); border-radius: var(--radius-control); background: var(--color-field); color: var(--color-text); font: inherit; color-scheme: dark; transition: border-color var(--dur-fast) var(--ease-out); }
.tw-field:hover, .tw-select:hover { border-color: var(--color-muted); }
.tw-field:focus-visible, .tw-select:focus-visible { border-color: var(--color-accent); }
.tw-field:disabled, .tw-select:disabled { border-color: var(--color-line); color: var(--color-muted); }
.tw-field.is-invalid, .tw-select.is-invalid, .tw-csv.is-invalid, .tw-import-csv.is-invalid { border-color: var(--color-down); }
.tw-field.is-invalid:focus-visible, .tw-select.is-invalid:focus-visible { outline-color: var(--color-down); }
.tw-field--full, .tw-select--full { width: 100%; }
.tw-field--short { width: 180px; }
.tw-field--mid { width: 300px; max-width: 100%; }
.tw-select { appearance: none; padding-right: 32px; }
.tw-select-wrap { position: relative; display: inline-block; max-width: 100%; }
.tw-select-wrap::after { content: ""; position: absolute; top: calc(50% - 5px); right: 13px; width: 7px; height: 7px; border-right: 1.5px solid var(--color-muted); border-bottom: 1.5px solid var(--color-muted); transform: rotate(45deg); pointer-events: none; }
.tw-help { display: block; margin-top: 6px; color: var(--color-muted); font-size: var(--text-meta); }
.tw-help--error { color: var(--color-down); }
.tw-help--error::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 6px; border: 1.5px solid currentColor; border-radius: 50%; vertical-align: -2px; }
.tw-help--error a { color: inherit; text-decoration: underline; }
.tw-errors { margin: 6px 0 0; padding-left: 18px; color: var(--color-down); font-size: var(--text-meta); }
.tw-segment { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--color-line-hi); border-radius: var(--radius-control); }
.tw-segment__choice { position: relative; display: inline-flex; align-items: center; height: 28px; padding: 0 12px; border-radius: 4px; color: var(--color-muted); font-weight: 500; cursor: pointer; }
.tw-segment__choice:has(input:checked) { background: var(--color-raised); color: var(--color-text); }
.tw-segment__choice:has(input:focus-visible) { outline: 2px solid var(--color-accent); outline-offset: 2px; }
.tw-segment__choice input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.tw-reset-fieldset { margin-inline: 0; padding: 0; border: 0; min-width: 0; }
.tw-reset-fieldset legend { padding: 0; }

/* Dialog */
.tw-dialog { width: 480px; max-width: calc(100% - 32px); margin: 80px auto; padding: 24px; border: 1px solid var(--color-line); border-radius: var(--radius-dialog); background: var(--color-bg); color: var(--color-text); box-shadow: var(--shadow-pop); }
.tw-dialog::backdrop { background: oklch(0 0 0 / 0.5); }
.tw-dialog h2 { margin-bottom: 4px; font-size: var(--text-verdict); font-weight: 600; }
.tw-dialog__sub { margin-bottom: 20px; color: var(--color-muted); }
.tw-dialog .tw-actions { align-items: center; }

/* Lists editor */
.tw-group-editor__top, .tw-group-builder__head, .tw-group-panel__head, .tw-group-mobile__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.tw-group-builder { padding: 24px 0; border-top: 1px solid var(--color-line); border-bottom: 1px solid var(--color-line); }
.tw-group-builder > .tw-label { margin-top: 24px; }
.tw-group-builder__actions { margin-top: 16px; }
.tw-group-workspace { display: grid; grid-template-columns: 184px minmax(0, 1fr); gap: 24px; }
.tw-group-index { border-top: 1px solid var(--color-line); }
.tw-group-index__button { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; width: 100%; min-height: var(--row-h); padding: 0 10px; border: 0; border-bottom: 1px solid var(--color-line); background: transparent; color: var(--color-muted); text-align: left; cursor: pointer; }
.tw-group-index__button:hover { background: var(--color-surface); color: var(--color-text); }
.tw-group-index__button[aria-current="true"] { background: var(--color-surface); color: var(--color-text); font-weight: 600; }
.tw-group-index__count { margin-left: 8px; color: var(--color-muted); font-size: var(--text-pill); font-weight: 400; }
.tw-group-mobile { display: none; }
.tw-group-panel { min-width: 0; }
.tw-group-panel__title { font-size: var(--text-section); font-weight: 600; }
.tw-group-panel__meta { margin-top: 4px; color: var(--color-muted); font-size: var(--text-meta); }
.tw-group-panel__remove { color: var(--color-down); }
.tw-group-markets { margin-top: 16px; }
.tw-group-market { display: grid; grid-template-columns: 92px minmax(0, 1fr) auto; align-items: center; min-height: var(--row-h); border-top: 1px solid var(--color-line); column-gap: 16px; }
.tw-group-market__symbol { font-weight: 600; }
.tw-group-market__company { min-width: 0; overflow: hidden; color: var(--color-muted); font-size: var(--text-meta); text-overflow: ellipsis; white-space: nowrap; }
.tw-group-market__status { display: inline-flex; align-items: center; height: 22px; margin-left: 8px; padding: 0 9px; border-radius: 999px; background: var(--color-raised); color: var(--color-muted); font-size: var(--text-pill); font-weight: 500; }
.tw-group-market__status--unknown { background: var(--color-tint-warn); color: var(--color-warn); }
.tw-group-panel__empty, .tw-group-empty { padding: 14px 0; border-top: 1px solid var(--color-line); color: var(--color-muted); }
.tw-market-adder { margin-top: 16px; }
.tw-market-adder__controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.tw-typeahead { position: relative; }
.tw-typeahead__results { position: absolute; z-index: 10; top: calc(100% + 5px); left: 0; width: 100%; overflow: hidden; border: 1px solid var(--color-line-hi); border-radius: var(--radius-control); background: var(--color-surface); box-shadow: var(--shadow-pop); }
.tw-typeahead__result { display: grid; grid-template-columns: 80px minmax(0, 1fr) auto; align-items: center; width: 100%; min-height: 44px; padding: 7px 12px; border: 0; border-bottom: 1px solid var(--color-line); background: transparent; color: var(--color-text); column-gap: 12px; text-align: left; cursor: pointer; }
.tw-typeahead__result:last-child { border-bottom: 0; }
.tw-typeahead__result:hover, .tw-typeahead__result:focus-visible { background: var(--color-raised); }
.tw-typeahead__symbol { font-weight: 600; }
.tw-typeahead__name { min-width: 0; overflow: hidden; color: var(--color-muted); font-size: var(--text-meta); text-overflow: ellipsis; white-space: nowrap; }
.tw-typeahead__exchange { color: var(--color-muted); font-size: var(--text-pill); }
.tw-typeahead__note { padding: 12px; color: var(--color-muted); font-size: var(--text-meta); }
.tw-bulk { padding-top: 16px; border-top: 1px solid var(--color-line); }
.tw-bulk__summary { display: inline-block; color: var(--color-accent); font-weight: 500; cursor: pointer; }
.tw-import-csv { width: 100%; min-height: 200px; resize: vertical; padding: 12px 14px; border: 1px solid var(--color-line-hi); border-radius: var(--radius-control); background: var(--color-field); color: var(--color-text); font: 400 var(--text-meta)/1.6 var(--font-mono); white-space: pre; }
.tw-file { width: 100%; min-height: var(--control-h); padding: 7px; border: 1px solid var(--color-line-hi); border-radius: var(--radius-control); background: var(--color-field); color: var(--color-muted); font-size: var(--text-meta); }
.tw-file::file-selector-button { min-height: calc(var(--control-h) - 16px); margin-right: 12px; padding: 0 12px; border: 1px solid var(--color-line-hi); border-radius: 4px; background: transparent; color: var(--color-text); font: 500 var(--text-meta)/1 var(--font-sans); cursor: pointer; }
.tw-csv { display: grid; grid-template-columns: 46px 1fr; height: 360px; overflow: hidden; border: 1px solid var(--color-line-hi); border-radius: var(--radius-control); background: var(--color-field); }
.tw-csv:focus-within { border-color: var(--color-accent); }
.tw-csv__gutter { overflow: hidden; padding: 12px 10px; border-right: 1px solid var(--color-line); color: var(--color-muted); font: 400 var(--text-meta)/1.6 var(--font-mono); text-align: right; }
.tw-csv__num--bad { color: var(--color-down); }
.tw-csv__text { width: 100%; height: 100%; resize: none; padding: 12px 14px; border: 0; outline: 0; background: transparent; color: var(--color-text); font: 400 var(--text-meta)/1.6 var(--font-mono); white-space: pre; overflow: auto; }

/* Mid: the fields column goes above the body so tables keep their columns. */
@media (max-width: 900px) {
  .tw-record { grid-template-columns: 1fr; gap: 24px; }
  .tw-fields { order: -1; }
  .tw-table .tw-hide-md { display: none; }
}

/* Narrow */
@media (max-width: 700px) {
  .tw-nav__inner { gap: 16px; padding: 0 16px; }
  .tw-wrap { padding: 20px 16px 48px; }
  .tw-title { font-size: 22px; }
  .tw-field-row { grid-template-columns: 104px minmax(0, 1fr); min-height: 32px; }
  .tw-table .tw-hide-sm { display: none; }
  .tw-table--fold td.tw-title-cell { height: auto; padding-top: 11px; padding-bottom: 11px; }
  .tw-table--fold .tw-meta { display: block; margin-top: 2px; color: var(--color-muted); font-size: var(--text-meta); font-weight: 400; }
  .tw-dialog { margin: 24px auto; padding: 20px 16px; }
  .tw-field--mid { width: 100%; }
  .tw-group-editor__top .tw-group-editor__add { display: none; }
  .tw-group-workspace { grid-template-columns: 1fr; gap: 0; }
  .tw-group-index { display: none; }
  .tw-group-mobile { display: block; }
  .tw-group-mobile__head { align-items: center; }
  .tw-group-mobile__head .tw-label { margin-bottom: 0; }
  .tw-group-panel { margin-top: 24px; }
  .tw-group-panel__head { align-items: center; }
  .tw-group-market { grid-template-columns: 72px minmax(0, 1fr) auto; column-gap: 8px; }
  .tw-typeahead__result { grid-template-columns: 68px minmax(0, 1fr); }
  .tw-typeahead__exchange { display: none; }
  .tw-csv { grid-template-columns: 38px 1fr; height: 320px; }
}
