/* OSRS GE Signals dashboard theme (docs/design/13-dashboard.md).
 *
 * Committed, hand-authored stylesheet so the dashboard is fully styled with NO Node/network at
 * runtime. The semantic palette below is the contract used by both the dashboard and the CLI:
 *   green = act-worthy (ROI>=target, fresh, two-sided liquid)
 *   amber = marginal / bootstrapping / insufficient data
 *   red   = avoid (stale, negative-after-tax, thin-high-vol, manipulation)
 *   gray  = no data
 * Integrity Watch (phase 7) uses a DISTINCT violet/red theme so it never blends with flip colors.
 *
 * For production, `tailwind.input.css` regenerates an equivalent/superset stylesheet via the
 * Tailwind standalone CLI (no Node). This file is the offline-safe default.
 */

:root {
  --bg: #0f141b;
  --panel: #18202b;
  --panel-2: #1f2937;
  --border: #2b3543;
  --text: #e6edf3;
  --muted: #94a3b8;
  --accent: #3b82f6;
  --green: #22c55e;
  --green-bg: #14331f;
  --amber: #f59e0b;
  --amber-bg: #3a2c0c;
  --red: #ef4444;
  --red-bg: #3a1414;
  --gray: #6b7280;
  --gray-bg: #232a33;
  --violet: #8b5cf6;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 0.92em; color: var(--amber); }

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1.1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; letter-spacing: 0.02em; }
.nav { display: flex; align-items: center; gap: 1rem; flex: 1; }
.nav .spacer { flex: 1; }
.nav .who { color: var(--muted); }
.inline { display: inline; margin: 0; }

.content { max-width: 960px; margin: 1.5rem auto; padding: 0 1.1rem; }
/* Dense data-table pages (Signals, Chains) opt into a wider container so the 14-column grid fits a
   normal desktop without the rightmost columns (Status/Scanned) clipping off the edge. Forms/login/
   item keep the readable 960px. Narrower viewports still scroll gracefully via `.table-scroll`. */
.content-wide { max-width: 1440px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.25rem;
}
.card-narrow { max-width: 380px; margin: 3rem auto; }
h1 { font-size: 1.4rem; margin: 0 0 0.75rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 0.6rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.text-red { color: var(--red); }
.text-amber { color: var(--amber); }  /* 17b: near-floor "Daily Vol" thin cue (display-only) */

label { display: block; margin: 0.6rem 0; color: var(--muted); }
input, select {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem 0.6rem;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
}
.row, .actions { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.5rem; }
.row input, .row select, .actions input, .actions select { width: auto; margin-top: 0; }
.actions form { display: flex; align-items: center; gap: 0.35rem; }

.btn {
  display: inline-block;
  padding: 0.5rem 0.9rem;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--red); border-color: var(--red); background: transparent; }

.alert { padding: 0.6rem 0.8rem; border-radius: 7px; margin: 0.75rem 0; border: 1px solid transparent; }
.alert-red { color: var(--red); background: var(--red-bg); border-color: var(--red); }
.alert-green { color: var(--green); background: var(--green-bg); border-color: var(--green); }

.badge { display: inline-block; padding: 0.05rem 0.45rem; border-radius: 999px; font-size: 0.78rem; }
.badge-role { background: var(--gray-bg); color: var(--muted); border: 1px solid var(--border); }

/* Semantic state classes (shared with the readiness/signal views in 6b). */
.state-green { color: var(--green); background: var(--green-bg); }
.state-amber { color: var(--amber); background: var(--amber-bg); }
.state-red   { color: var(--red);   background: var(--red-bg); }
.state-gray  { color: var(--gray);  background: var(--gray-bg); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; margin: 0.75rem 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

table.grid { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
table.grid th, table.grid td { text-align: left; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.grid th { color: var(--muted); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; }

.footer { max-width: 960px; margin: 2rem auto; padding: 0 1.1rem 2rem; color: var(--muted); display: flex; gap: 1rem; align-items: center; }
/* a wide page (Signals/Chains) mirrors its content_class onto the footer so the footer aligns with
   the wider content card instead of sitting narrower than it. */
.footer.content-wide { max-width: 1440px; }
.legend { display: flex; gap: 0.4rem; }
.chip { padding: 0.05rem 0.5rem; border-radius: 999px; font-size: 0.75rem; }
.chip-green { color: var(--green); background: var(--green-bg); }
.chip-amber { color: var(--amber); background: var(--amber-bg); }
.chip-red   { color: var(--red);   background: var(--red-bg); }
.chip-gray  { color: var(--gray);  background: var(--gray-bg); }

/* --- Signals view (phase 6b) ------------------------------------------------------------------ */

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.section-head h1, .section-head h2 { margin: 0; }

/* status filter pills */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin: 0.85rem 0 0.4rem; }
.pill { padding: 0.2rem 0.7rem; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: 0.82rem; }
.pill:hover { text-decoration: none; border-color: var(--accent); }
.pill-active { background: var(--panel-2); color: var(--text); border-color: var(--accent); }

/* right-aligned, tabular numeric cells + sortable header links */
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Dense, single-line layout for the wide data grids. `class="grid signals"` is reused by four
   templates — the main Signals table, the Chains table, plus home's missed-panel and item's
   per-item list. Only the first two sit in a `.table-scroll` swap container, so we scope the dense
   rules to `.table-scroll table.signals`: the two wide grids get densified, while the narrow 960px
   home/item lists keep their relaxed (wrapping) layout untouched.

   The recipe (auto table-layout): every column except the first is pinned to `width:1%`, which
   resolves to min-content — so the numeric/badge columns shrink to exactly their content with NO
   dead gaps, and the first column (Item/Subject) absorbs all remaining width. The name link inside
   it truncates with an ellipsis (full name on hover via the cell `title`) instead of forcing the
   table wider, so rows stay single-line and the grid fits the card and only scrolls when genuinely
   too narrow. */
.table-scroll { overflow-x: auto; }
.table-scroll table.signals { width: 100%; }
.table-scroll table.signals th, .table-scroll table.signals td { white-space: nowrap; padding: 0.4rem 0.45rem; }
.table-scroll table.signals th:not(:first-child),
.table-scroll table.signals td:not(:first-child) { width: 1%; }
.table-scroll table.signals td:first-child { overflow: hidden; }
.table-scroll table.signals td:first-child a {
  display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; vertical-align: bottom;
}

/* Compact-gp cells (Signals + Chains): the dense table shows 1.18b / 18.5m / 355k; the exact
   comma-grouped value is on the span `title` (hover). Plain text — nothing here relies on CSS to
   hide an <input>, so a stale/old cached stylesheet can never turn these into stray checkboxes or
   print the compact and full numbers side by side. `cursor: help` hints the value-on-hover. */
.gpc { cursor: help; }

table.signals th a { color: var(--muted); }
table.signals th a:hover { color: var(--text); text-decoration: none; }
table.signals tbody tr { cursor: pointer; border-left: 3px solid transparent; }
table.signals tbody tr:hover { background: var(--panel-2); }

/* semantic row tints (subtle so text stays readable); hover overrides above */
table.signals tbody tr.row-green { background: rgba(34, 197, 94, 0.06); }
table.signals tbody tr.row-amber { background: rgba(245, 158, 11, 0.06); }
table.signals tbody tr.row-red   { background: rgba(239, 68, 68, 0.07); }
table.signals tbody tr.row-gray  { background: rgba(107, 114, 128, 0.06); }
table.signals tbody tr.row-green td:first-child { box-shadow: inset 3px 0 0 var(--green); }
table.signals tbody tr.row-amber td:first-child { box-shadow: inset 3px 0 0 var(--amber); }
table.signals tbody tr.row-red   td:first-child { box-shadow: inset 3px 0 0 var(--red); }
table.signals tbody tr.row-gray  td:first-child { box-shadow: inset 3px 0 0 var(--gray); }
table.signals tbody tr.row-unseen td:first-child { font-weight: 600; }

/* state dot + unseen marker */
.dot { display: inline-block; width: 0.6rem; height: 0.6rem; border-radius: 50%; margin-right: 0.35rem; vertical-align: baseline; }
.dot-green { background: var(--green); }
.dot-amber { background: var(--amber); }
.dot-red   { background: var(--red); }
.dot-gray  { background: var(--gray); }
.unseen-dot { display: inline-block; width: 0.45rem; height: 0.45rem; border-radius: 50%; background: var(--accent); margin-left: 0.4rem; }

/* status chips */
.badge-status { border: 1px solid var(--border); text-transform: capitalize; }
.status-new { color: var(--accent); }
.status-accepted { color: var(--green); background: var(--green-bg); }
.status-rejected { color: var(--red); background: var(--red-bg); }

/* evidence drawer */
.drawer-host { max-width: 960px; margin: 0 auto; padding: 0 1.1rem; }
.drawer {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1.3rem;
  margin-bottom: 1.25rem;
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.drawer-head h2 { margin: 0; font-size: 1.15rem; }
.drawer h3 { font-size: 0.95rem; margin: 1.1rem 0 0.4rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
table.mini th, table.mini td { padding: 0.3rem 0.55rem; font-size: 0.85rem; }
table.mini tbody tr.row-green td:first-child { box-shadow: inset 3px 0 0 var(--green); }
table.mini tbody tr.row-amber td:first-child { box-shadow: inset 3px 0 0 var(--amber); }

/* --- Config editor (phase 6c) ----------------------------------------------------------------- */

.cfg-group { border: 1px solid var(--border); border-radius: 9px; padding: 0.4rem 1rem 1rem; margin: 1rem 0; }
.cfg-group legend { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.03em; padding: 0 0.4rem; }
.cfg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.4rem 1rem; }
.cfg-field label { margin: 0.35rem 0; }
.cfg-field.cfg-overridden input, .cfg-field.cfg-overridden select { border-color: var(--amber); }
.cfg-check { display: flex; align-items: center; gap: 0.5rem; color: var(--text); }
.cfg-check input { width: auto; margin: 0; }
.cfg-flag { color: var(--amber); font-size: 0.7rem; margin-left: 0.35rem; vertical-align: middle; }
.cfg-actions { margin-top: 1rem; }
.cfg-reset { margin-top: 0.75rem; }
.cfg-preset-head { margin-top: 1.25rem; }
.errors { margin: 0.4rem 0 0; padding-left: 1.1rem; }

/* --- Charts + item detail (phase 6d) ---------------------------------------------------------- */

/* Server-side inline SVG charts (no client lib; renders with JS disabled). The viewBox scales to
 * the container width; a fixed height keeps the aspect readable. */
.chart {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.3rem;
  margin: 0.4rem 0 0.9rem;
}
.chart-svg { display: block; width: 100%; height: 180px; }
.chart-empty { margin: 0.6rem 0.3rem; }

/* price / hour-curve polylines: low (buy) = blue accent, high (sell) = green */
.spark-low  { stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.spark-high { stroke: var(--green);  stroke-width: 1.5; vector-effect: non-scaling-stroke; }
/* volume bars */
.bar { fill: var(--accent); opacity: 0.55; }
/* entry/exit markers on the hour-of-day curve */
.mark-buy  { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.8; vector-effect: non-scaling-stroke; }
.mark-sell { stroke: var(--green);  stroke-width: 1; stroke-dasharray: 3 3; opacity: 0.8; vector-effect: non-scaling-stroke; }

/* legend swatches for the chart series */
.swatch { display: inline-block; width: 0.7rem; height: 0.18rem; vertical-align: middle; margin-right: 0.25rem; }
.swatch-low  { background: var(--accent); }
.swatch-high { background: var(--green); }
.toolbar .spacer { flex: 1; }

/* --- Ask-Claude assistant (phase 6e) ---------------------------------------------------------- */

.assistant-ask textarea { width: 100%; resize: vertical; font: inherit; }
.assistant-answer-block { margin-top: 1rem; }
/* answer text preserves the model's line breaks; reuses panel-2 like the charts */
.assistant-answer {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  margin: 0.4rem 0 0;
}
/* the live SSE region only takes space once it has streamed text */
.assistant-live:empty { display: none; }
.assistant-selfcheck { margin-left: 0.5rem; }

/* --- Integrity Watch (phase 7c) --------------------------------------------------------------- */

/* Distinct VIOLET theme (doc 13/18) so the manipulation surface never blends with flip colors. */
:root { --violet-bg: #241a3a; }
.nav-integrity { color: var(--violet); }
.badge-violet { color: #fff; background: var(--violet); border: 1px solid var(--violet); }
.alert-violet { color: var(--text); background: var(--violet-bg); border-color: var(--violet); }
.state-violet { color: var(--violet); background: var(--violet-bg); }

/* the integrity card gets a violet top accent so it reads as a separate module */
.card.integrity { border-top: 3px solid var(--violet); }
.integrity-h { font-size: 1.02rem; margin: 1.3rem 0 0.3rem; }
.integrity-summary { grid-template-columns: max-content 1fr; }

/* flagged-print rows are tinted violet (suspect), not green/amber/red (which mean flip quality) */
table.grid tbody tr.row-violet td:first-child { box-shadow: inset 3px 0 0 var(--violet); }
table.integrity-events tbody tr.row-violet,
table.integrity-watchlist tbody tr.row-violet { background: rgba(139, 92, 246, 0.06); }

.integrity-eco { max-width: 30rem; }
.integrity-rationale { margin-top: 0.2rem; }
.integrity-review { display: flex; align-items: center; gap: 0.3rem; margin-top: 0.3rem; }
.integrity-note { font: inherit; padding: 0.15rem 0.35rem; max-width: 9rem; }

/* susceptibility sub-score "why" chips */
.integrity-why { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.why-chip { font-size: 0.72rem; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 0.02rem 0.5rem; }
.why-val { color: var(--violet); font-variant-numeric: tabular-nums; }
