/* The dashboard's one stylesheet (board request 53, after the owner's reference): a light grey canvas, white cards with a
   large radius, a sidebar with a black active item, KPI tiles (the first dark), a lime accent, status pills; a dark theme
   with the same structure, from the system setting or the page's toggle. Dense for 1,440 to 2,560 px trading screens. */
:root {
  --bg: #eef0f3;
  --card: #ffffff;
  --text: #15181d;
  --muted: #7a828e;
  --line: #e7e9ee;
  --head: #f4f5f7;
  --ink: #111316;
  --ink-text: #f4f6f8;
  --lime: #c8f169;
  --lime-ink: #1f2a07;
  --up: #15803d;
  --down: #d92d20;
  --ok-bg: #e8f8ee; --ok-fg: #15803d;
  --warn-bg: #fff3dc; --warn-fg: #a15c07;
  --bad-bg: #fde8e7; --bad-fg: #c4320a;
  --info-bg: #e6efff; --info-fg: #1d4ed8;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.05);
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

:root[data-theme="dark"] {
  --bg: #0d0f12; --card: #16191e; --text: #e8ebf0; --muted: #8b939f; --line: #252a31; --head: #1c2026;
  --ink: #000000; --up: #4ade80; --down: #ff6b5f;
  --ok-bg: #12301f; --ok-fg: #5be08e; --warn-bg: #33270e; --warn-fg: #f5b544;
  --bad-bg: #3a1714; --bad-fg: #ff7a6e; --info-bg: #142545; --info-fg: #7aa7ff;
  --shadow: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0f12; --card: #16191e; --text: #e8ebf0; --muted: #8b939f; --line: #252a31; --head: #1c2026;
    --ink: #000000; --up: #4ade80; --down: #ff6b5f;
    --ok-bg: #12301f; --ok-fg: #5be08e; --warn-bg: #33270e; --warn-fg: #f5b544;
    --bad-bg: #3a1714; --bad-fg: #ff7a6e; --info-bg: #142545; --info-fg: #7aa7ff;
    --shadow: none;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;      /* `.app`'s grid must not show the page before sign-in */
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
}

.app {
  display: grid;
  grid-template-columns: 228px 1fr;
  min-height: 100vh;
  gap: 16px;
  padding: 16px;
}

.side {
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 16px;
  height: calc(100vh - 32px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  margin: 0 6px 18px;
}

.logo {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--ink);
  color: var(--lime);
  font-size: 12px;
}

.side-label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 4px 8px 6px;
}

.tabs {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tabs button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: none;
  background: none;
  border-radius: 12px;
  padding: 9px 12px;
  text-align: left;
  color: var(--text);
}

.tabs button:hover {
  background: var(--head);
}

.tabs button.active {
  background: var(--ink);
  color: var(--ink-text);
}

.count {
  background: var(--head);
  color: var(--text);
  border-radius: 999px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 600;
}

.tabs button.active .count {
  background: var(--lime);
  color: var(--lime-ink);
}

.side-foot {
  margin-top: auto;
  display: flex;
  gap: 8px;
}

.main {
  min-width: 0;
}

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 4px 14px;
}

.top h1 {
  font-size: 24px;
  margin: 0;
  letter-spacing: -0.01em;
}

.asof {
  margin-left: auto;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.tile {
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tile.dark {
  background: var(--ink);
  color: var(--ink-text);
}

.tile .label {
  color: var(--muted);
  font-size: 12px;
}

.tile .value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tile.dark .value {
  color: var(--lime);
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 1440px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.card {
  background: var(--card);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
  min-width: 0;
}

.card.wide,
.card:has(th:nth-child(7)) {
  grid-column: 1 / -1;
}

.card.dark {
  background: var(--ink);
  color: var(--ink-text);
  grid-column: 1 / -1;
}

.card.narrow {
  max-width: 380px;
  margin: 12vh auto;
}

.card h2 {
  font-size: 15px;
  margin: 0 0 8px;
}

.meta,
.reason,
.lead {
  margin: 0 0 8px;
}

.muted {
  color: var(--muted);
}

.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.pill.ok { background: var(--ok-bg); color: var(--ok-fg); }
.pill.warn { background: var(--warn-bg); color: var(--warn-fg); }
.pill.bad { background: var(--bad-bg); color: var(--bad-fg); }
.pill.info { background: var(--info-bg); color: var(--info-fg); }
.pill.attention { font-size: 12px; padding: 4px 12px; }
.pill.attention.ok { background: var(--lime); color: var(--lime-ink); }
.up { color: var(--up); }
.down { color: var(--down); }
.error { color: var(--down); }

.bullets {
  list-style: none;
  margin: 0;
  padding: 0;
}

.bullets li {
  padding: 6px 0 6px 18px;
  position: relative;
}

.bullets li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 12px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--lime);
}

.bullets li.bad::before { background: var(--down); }
.bullets li.warn::before { background: #f5b544; }
.bullets li.info::before { background: var(--info-fg); }

.scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 7px 8px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  background: var(--head);
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

th:first-child { border-radius: 10px 0 0 10px; }
th:last-child { border-radius: 0 10px 10px 0; }
td.num { text-align: right; }

form label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 4px 14px 4px 0;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 14px;
  margin: 10px 0;
  padding: 8px 12px;
}

input,
select,
button {
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 5px 9px;
}

button {
  cursor: pointer;
}

button[type="submit"],
.pill-button {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--ink-text);
  border-radius: 999px;
  padding: 6px 14px;
}

.log-lines {
  font: 12px/1.4 var(--mono);
  max-height: 70vh;
  overflow: auto;
}

.log {
  display: flex;
  gap: 10px;
  padding: 2px 0;
  border-bottom: 1px solid var(--line);
}

.log .svc { color: var(--muted); min-width: 52px; }
.log .txt { white-space: pre-wrap; word-break: break-word; }
.log.error .txt, .log.critical .txt { color: var(--down); }
.log.warning .txt { color: var(--warn-fg); }

.toast {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 10; max-width: min(560px, calc(100% - 32px));
  padding: 12px 16px; border-radius: 10px; font-weight: 600; cursor: pointer; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}
.toast.ok { background: var(--ok-bg); color: var(--ok-fg); }
.toast.error { background: var(--bad-bg); color: var(--bad-fg); }
.closed-day button.danger { background: var(--bad-fg); color: #fff; border: 0; font-weight: 600; }

/* History (board requests 82, 84): book, range and strategy toggles; totals; days left to right; a way back up */
.history-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 12px; }
.history-head h2 { margin: 0; }
.history-head label { display: flex; align-items: center; gap: 6px; margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { border-radius: 999px; padding: 5px 12px; background: var(--card); color: var(--muted); border: 1px solid var(--line); cursor: pointer; }
.chip.on { background: var(--ink); color: var(--lime); border-color: var(--ink); }
.sums { margin-bottom: 12px; }
.days { overflow-x: auto; margin-bottom: 16px; }
.days-grid { display: flex; gap: 10px; }
.day { flex: 0 0 160px; display: flex; flex-direction: column; gap: 4px; text-align: left; background: var(--head); color: var(--text);
  border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; cursor: pointer; }
.day:hover { border-color: var(--muted); }
.day .label { color: var(--muted); font-size: 12px; }
.day .value { font-size: 18px; font-weight: 700; }
.day-head { font-size: 13px; margin: 18px 0 6px; scroll-margin-top: 16px; }
.to-top { position: sticky; bottom: 16px; display: block; margin: 14px 0 0 auto; }
