/* Kingfisher dashboard. Look and feel from the Hummingbird dashboard: Day = Financial-Times
   paper, Night = calm charcoal; Newsreader for titles and the big figures, Source Sans 3 for
   everything else. Profit/loss colours are Hummingbird's validated teal/claret pair and are
   always shown with a + / - sign, never colour alone. */

:root {
  color-scheme: light;
  --page: #fff1e5;
  --card: #fff7f0;
  --raised: #fffbf7;
  --sunk: #f4e3d3;
  --hover: rgba(51, 48, 46, 0.045);
  --rule: #e8dacb;
  --rule-2: #d6c5b4;
  --grid: #eee1d3;
  --axis: #c9b8a7;
  --ink: #33302e;
  --ink-2: #66605c;
  --muted: #746d68;
  --accent: #0f5499;
  --accent-wash: rgba(15, 84, 153, 0.08);
  --accent-wash-2: rgba(15, 84, 153, 0.15);
  --on-accent: #ffffff;
  --good: #0d7680;
  --good-text: #0b6b74;
  --good-wash: rgba(13, 118, 128, 0.11);
  --bad: #990f3d;
  --bad-text: #990f3d;
  --bad-wash: rgba(153, 15, 61, 0.09);
  --on-bad: #ffffff;
  --warn: #8a5a00;
  --warn-wash: rgba(201, 133, 0, 0.14);
  --line: #0f5499;
  --shadow: 0 1px 2px rgba(51, 48, 46, 0.05);
  --shadow-pop: 0 14px 34px -12px rgba(51, 48, 46, 0.28), 0 2px 6px rgba(51, 48, 46, 0.08);
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #15171c;
    --card: #1c1f26;
    --raised: #23262e;
    --sunk: #262a33;
    --hover: rgba(238, 233, 226, 0.04);
    --rule: #2c3039;
    --rule-2: #3b404b;
    --grid: #282c34;
    --axis: #4a505c;
    --ink: #eee9e2;
    --ink-2: #a9a39b;
    --muted: #97918a;
    --accent: #6ea6ea;
    --accent-wash: rgba(110, 166, 234, 0.12);
    --accent-wash-2: rgba(110, 166, 234, 0.2);
    --on-accent: #0e1726;
    --good: #45aab3;
    --good-text: #4fb3bc;
    --good-wash: rgba(69, 170, 179, 0.15);
    --bad: #e0708f;
    --bad-text: #e0708f;
    --bad-wash: rgba(224, 112, 143, 0.14);
    --on-bad: #1a0d12;
    --warn: #e0a43a;
    --warn-wash: rgba(224, 164, 58, 0.14);
    --line: #6ea6ea;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-pop: 0 18px 40px -14px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(238, 233, 226, 0.04);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--page); }
body {
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-wash-2); }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }

.serif { font-family: var(--serif); font-optical-sizing: auto; }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--good-text); }
.neg { color: var(--bad-text); }
.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }

.wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px calc(40px + env(safe-area-inset-bottom));
}

/* -- header ------------------------------------------------------------------ */
.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 2px 18px;
}
.top h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.top .sub { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.top-right { display: flex; align-items: center; gap: 8px; padding-top: 4px; }
.icon-btn {
  width: 38px; height: 38px;
  display: inline-grid; place-items: center;
  border-radius: 10px;
  border: 1px solid var(--rule);
  background: var(--card);
  cursor: pointer;
  color: var(--ink-2);
  transition: background-color 140ms ease, border-color 140ms ease;
}
.icon-btn:hover { background: var(--raised); border-color: var(--rule-2); }
.icon-btn svg { width: 19px; height: 19px; }

.pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 11px 5px 9px;
  border-radius: 999px;
  font-size: 13px; font-weight: 600;
  background: var(--sunk);
  color: var(--ink-2);
  white-space: nowrap;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.good { background: var(--good-wash); color: var(--good-text); }
.pill.good .dot { animation: pulse 1.8s ease-in-out infinite; }
.pill.bad { background: var(--bad-wash); color: var(--bad-text); }
.pill.warn { background: var(--warn-wash); color: var(--warn); }
@keyframes pulse { 50% { opacity: 0.35; } }

.tag {
  display: inline-block;
  font-size: 11.5px; font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 1px 7px;
  border-radius: 6px;
  vertical-align: 2px;
}
.tag.paper { background: var(--warn-wash); color: var(--warn); }
.tag.live { background: var(--accent-wash-2); color: var(--accent); }

/* -- cards -------------------------------------------------------------------- */
.card {
  position: relative;
  border-radius: 14px;
  border: 1px solid var(--rule);
  background: var(--card);
  box-shadow: var(--shadow);
  padding: 18px 18px 16px;
  margin-bottom: 14px;
}
.first .card { animation: cardIn 220ms ease-out both; }
@keyframes cardIn { from { opacity: 0; transform: translate3d(0, 4px, 0); } }
.card.hero { box-shadow: inset 0 3px 0 var(--accent), var(--shadow); padding-top: 20px; }
.card h2 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 21px;
  margin: 0 0 2px;
  letter-spacing: -0.005em;
}
.card .lede { color: var(--ink-2); margin: 0 0 12px; font-size: 14px; }
.eyebrow {
  font-size: 12.5px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.big {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(44px, 11vw, 62px);
  line-height: 1.02;
  letter-spacing: -0.02em;
  margin: 6px 0 12px;
}
.big.flat { color: var(--ink); }
.split {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  border-top: 1px solid var(--rule);
  padding-top: 12px;
}
.split .lbl { display: block; font-size: 12.5px; color: var(--muted); }
.split .val { display: block; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.holding {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--sunk);
  font-size: 14px;
  color: var(--ink-2);
}
.holding b { color: var(--ink); font-weight: 600; }
.asof { margin-top: 10px; font-size: 12.5px; color: var(--muted); }

.banner {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 14px;
  font-size: 14px;
  border: 1px solid var(--rule);
  background: var(--raised);
}
.banner svg { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.banner.warn { background: var(--warn-wash); border-color: transparent; color: var(--ink); }
.banner.warn svg { color: var(--warn); }
.banner.bad { background: var(--bad-wash); border-color: transparent; }
.banner.bad svg { color: var(--bad); }
.banner .grow { flex: 1; }
.banner b { font-weight: 600; }

/* -- buttons ------------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 11px;
  border: 1px solid var(--rule-2);
  background: var(--raised);
  font-weight: 600;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease, opacity 140ms ease;
  white-space: nowrap;
}
.btn:hover { border-color: var(--axis); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: var(--on-bad); }
.btn.danger-ghost { background: transparent; border-color: var(--bad); color: var(--bad-text); }
.btn.danger-ghost:hover { background: var(--bad-wash); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn .spin {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }

/* -- stop card ------------------------------------------------------------------ */
.stop-grid { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.stop-grid .txt { flex: 1 1 280px; }
.stop-grid p { margin: 2px 0 0; color: var(--ink-2); font-size: 14px; }
.confirm {
  margin-top: 14px;
  padding: 14px;
  border-radius: 12px;
  background: var(--bad-wash);
}
.confirm p { margin: 0 0 12px; }
.result { margin-top: 12px; display: flex; gap: 10px; align-items: flex-start; font-size: 14.5px; }
.result svg { flex: none; width: 20px; height: 20px; margin-top: 1px; }
.result.done svg { color: var(--good); }
.result.failed { color: var(--bad-text); }
.result.working svg { color: var(--accent); }

/* -- charts ------------------------------------------------------------------- */
.chart { position: relative; margin: 6px 0 4px; touch-action: pan-y; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart text { font-family: var(--sans); font-size: 11.5px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .zero { stroke: var(--axis); stroke-width: 1; }
.chart .ln { fill: none; stroke: var(--line); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent-wash); }
.chart .cross { stroke: var(--axis); stroke-width: 1; }
.chart .halo { paint-order: stroke; stroke: var(--card); stroke-width: 4px; stroke-linejoin: round; }
.chart .bar-pos { fill: var(--good); }
.chart .bar-neg { fill: var(--bad); }
.chart .bar-paper { fill-opacity: 0.38; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .hl, .chart .hl.on { fill: var(--hover); }
.chart .mk-in { stroke: var(--card); stroke-width: 2; }
.chart .mk-out { fill: var(--card); stroke-width: 2; }
.tip {
  position: absolute;
  pointer-events: none;
  z-index: 5;
  min-width: 120px;
  padding: 7px 10px;
  border-radius: 9px;
  background: var(--raised);
  border: 1px solid var(--rule-2);
  box-shadow: var(--shadow-pop);
  font-size: 13px;
  line-height: 1.35;
  white-space: nowrap;
  transform: translate(-50%, calc(-100% - 10px));
}
.tip b { font-weight: 600; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  background: var(--sunk);
}
.seg button {
  border: 0; background: transparent;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 13.5px; font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--raised); color: var(--ink); box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }

/* -- trades and days lists ---------------------------------------------------- */
.list { list-style: none; margin: 4px 0 0; padding: 0; }
.list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 12px;
  padding: 10px 2px;
  border-top: 1px solid var(--rule);
}
.list li:first-child { border-top: 0; }
.list .t1 { font-weight: 600; }
.list .t2 { font-size: 13px; color: var(--muted); grid-column: 1; }
.list .amt { grid-row: 1 / span 2; grid-column: 2; align-self: center; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; font-size: 16px; }
.chip {
  display: inline-block;
  font-size: 12px; font-weight: 700;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--sunk);
  color: var(--ink-2);
  margin-right: 6px;
  vertical-align: 1px;
}
.empty { color: var(--muted); font-size: 14px; padding: 8px 2px; }

.tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 6px 0 14px;
}
.tile { padding: 10px 12px; border-radius: 11px; background: var(--raised); border: 1px solid var(--rule); }
.tile .lbl { font-size: 12.5px; color: var(--muted); }
.tile .val { font-family: var(--serif); font-size: 22px; font-weight: 500; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tile .note { font-size: 12px; color: var(--muted); }
@media (max-width: 560px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split .val { font-size: 16px; }
}
.more { margin-top: 6px; }

footer.foot { margin: 22px 2px 0; font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* -- forms (sign in, settings) ------------------------------------------------- */
.signin { max-width: 400px; margin: 12vh auto 0; }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 5px; }
.field .help { font-size: 13px; color: var(--muted); margin-top: 5px; }
.field .err { font-size: 13px; color: var(--bad-text); margin-top: 5px; }
.input {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--rule-2);
  background: var(--raised);
  font-size: 16px;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.input.bad { border-color: var(--bad); }
.inline { display: flex; gap: 8px; }
.inline .input { flex: 1; }
.stepper { display: inline-flex; align-items: center; gap: 0; border: 1px solid var(--rule-2); border-radius: 11px; overflow: hidden; background: var(--raised); }
.stepper button { width: 44px; height: 44px; border: 0; background: transparent; cursor: pointer; font-size: 20px; color: var(--ink-2); }
.stepper button:hover { background: var(--hover); }
.stepper output { min-width: 44px; text-align: center; font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.steps { list-style: none; padding: 0; margin: 10px 0 0; }
.steps li { display: flex; gap: 10px; padding: 7px 0; border-top: 1px solid var(--rule); font-size: 14px; }
.steps li:first-child { border-top: 0; }
.steps .mk { flex: none; width: 20px; text-align: center; font-weight: 700; }
.steps .ok .mk { color: var(--good-text); }
.steps .no .mk { color: var(--bad-text); }
.steps .detail { color: var(--muted); }
details.help-box { margin: 4px 0 14px; border-radius: 11px; background: var(--raised); border: 1px solid var(--rule); }
details.help-box summary { cursor: pointer; padding: 10px 12px; font-weight: 600; font-size: 14px; color: var(--accent); }
details.help-box div { padding: 0 14px 10px; font-size: 14px; color: var(--ink-2); }
details.help-box ol { padding-left: 18px; margin: 6px 0; }
details.help-box li { margin: 3px 0; }
.ipbox { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 11px; background: var(--sunk); }
.ipbox code { font-size: 18px; font-weight: 700; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink); color: var(--page);
  padding: 9px 16px; border-radius: 10px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow-pop);
  z-index: 20;
}
.totp { font-size: 13px; color: var(--ink-2); margin-top: 6px; }
.totp code { font-weight: 700; letter-spacing: 0.08em; font-size: 15px; }

@media (prefers-reduced-motion: reduce) {
  .card, .pill.good .dot, .btn .spin { animation: none !important; }
}

/* small helpers (no inline styles: the page's CSP forbids them) */
.sm { font-size: 14px; font-weight: 400; }
.xs { font-size: 12px; font-weight: 400; }
.sm13 { font-size: 13px; }
.mt6 { margin-top: 6px; }
.mt10 { margin-top: 10px; }
.mt12 { margin-top: 12px; }
.m0 { margin-bottom: 0; }
.gap8 { height: 8px; }
.opt { font-family: var(--sans); font-size: 14px; }
.ip-steps { font-size: 14px; color: var(--ink-2); padding-left: 18px; margin: 12px 0 0; }
.legend i.sw-in { background: var(--ink); border-radius: 50%; }
.legend i.sw-out { border: 2px solid var(--ink); border-radius: 50%; background: transparent; }
.legend i.sw-pos { background: var(--good); }
.legend i.sw-neg { background: var(--bad); }
.legend i.sw-paper { background: var(--ink-2); opacity: 0.38; }
.chart text.mk-lab { fill: var(--ink); font-weight: 700; }
