/* Rishi Trading App — foundation stylesheet.
 *
 * Copied verbatim from the approved visual contract, design-2-sidebar-app.html
 * (the mockup is canonical; values are preserved exactly). This file holds the
 * SHARED design system only: tokens, reset, typography, and the reusable
 * component vocabulary — app shell, panels, tables, buttons, pills, forms —
 * plus accessibility utilities and the honest placeholder. Screen-specific
 * components arrive with the screens that need them in later tasks.
 *
 * INTERFACE SCALE — changed by Rishi on 25 Jul 2026. He used the built app,
 * said it "looks too big", found 80% browser zoom right, and chose to make
 * that the default at 100% zoom. The whole system is rem-based, so the scale
 * lives at the root and NOWHERE else: `html { font-size: 85% }` (106.25 x 0.8)
 * shrinks type AND every --space-* step together, exactly like 80% zoom.
 * Never re-tune individual font sizes to "fix" this; change the root instead.
 * This deliberately supersedes the earlier "17px base / nothing under 16px"
 * rule — Rishi was told the base lands near 13.6px and confirmed it anyway.
 *
 * Hard rules still in force: no light-grey text (every text colour is
 * --ink-soft or darker, all >= 4.5:1); green/red reserved for Rishi's money —
 * no hover, fill or decoration may borrow them; reduced-motion honoured.
 */

:root {
  --bg: oklch(1 0 0);
  --surface: oklch(0.972 0.005 55);
  --line: oklch(0.9 0.008 55);
  --line-soft: oklch(0.94 0.006 55);
  --ink: oklch(0.235 0.02 40);
  --ink-soft: oklch(0.4 0.02 40);
  --primary: oklch(0.5 0.125 36);
  --primary-deep: oklch(0.44 0.12 36);
  --primary-tint: oklch(0.955 0.02 36);
  --accent: oklch(0.44 0.1 245);
  --accent-bg: oklch(0.95 0.02 245);
  --gain: oklch(0.44 0.12 152);
  --gain-bg: oklch(0.955 0.035 152);
  --loss: oklch(0.47 0.17 25);
  --loss-bg: oklch(0.955 0.028 25);
  /* Destructive actions ("Remove Priya", "Yes, remove it") used to be painted
     in --loss, the exact red that means Rishi LOST MONEY. His rule reserves
     green and red for his money with no exceptions, so a delete button gets
     its own colour: still unmistakably a red warning (the convention that
     stops an accidental click is worth keeping), but a deeper, darker crimson
     at a different hue that never renders the money token. It also only ever
     appears on People and the remove-confirmations, where no money is shown
     at all. 8.0:1 on white. */
  --danger: oklch(0.4 0.15 12);
  --danger-bg: oklch(0.95 0.025 12);
  --dark: oklch(0.245 0.022 40);
  --on-dark: oklch(0.97 0.008 60);
  --on-dark-soft: oklch(0.82 0.015 55);
  --radius: 14px;
  --radius-sm: 9px;
  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem;
  --space-4: 1rem; --space-5: 1.5rem; --space-6: 2rem;
  --space-7: 3rem; --space-8: 4rem;
  --font-ui: 'Public Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Newsreader', Georgia, serif;
  /* single added neutral: sidebar surface, one step warmer/darker than --surface */
  --sidebar-surface: oklch(0.958 0.007 55);
  /* Row / list hover — deliberately ACHROMATIC. It used to be --primary-tint,
     which sits at hue 36 while --loss-bg sits at hue 25 with the same
     lightness: near-indistinguishable. Harmless on a thin table row, but
     Today's stock rows are now tall blocks, so hovering flooded a big area
     with a pinkish wash and Rishi read it as a money state. Green/red are his
     money only, so hover now carries no hue at all: chroma is literally 0, so
     this rasterises to rgb(231,231,231) — red, green and blue identical.
     It is also a stronger signal than the tint it replaces: against the
     sidebar the old tint was 1.013:1 (a hue shift with almost no lightness
     change), this is 1.09:1; on Today's blocks 1.06:1 becomes 1.14:1; on a
     white panel 1.15:1 becomes 1.24:1. */
  --hover-tint: oklch(0.928 0 0);
}

*, *::before, *::after { box-sizing: border-box; }
/* The single interface-scale control for the whole app — see the note at the
   top of this file. 85% of 16px = 13.6px, i.e. the old 17px base at 80%. */
html { font-size: 85%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button { font: inherit; color: inherit; font-variant-numeric: tabular-nums; }
a { color: var(--primary-deep); }
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- app shell ---------- */
.app { display: block; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 240px;
  background: var(--sidebar-surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  z-index: 40;
}
.brand {
  padding: var(--space-5) var(--space-5) var(--space-4);
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}
.brand-mark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.6rem;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.brand-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--primary);
  align-self: center;
}
.side-nav { flex: 1 1 auto; overflow-y: auto; padding: 0 var(--space-3); }
.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 46px;
  padding: var(--space-2) var(--space-3);
  margin-bottom: 2px;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  text-align: left;
  text-decoration: none;   /* rendered as <a> links in the real app */
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  transition: background-color 180ms ease-out;
}
.nav-item:hover { background: var(--hover-tint); }
.nav-item .ico { flex: none; color: var(--ink-soft); display: flex; }
.nav-item .ico svg { width: 19px; height: 19px; }
.nav-item[aria-current="page"] {
  background: var(--bg);
  color: var(--primary-deep);
  font-weight: 600;
  box-shadow: 0 1px 2px oklch(0.235 0.02 40 / 0.06);
}
.nav-item[aria-current="page"] .ico { color: var(--primary); }
.nav-item .dot-badge {
  margin-left: auto;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary);
}

.profile-block {
  border-top: 1px solid var(--line);
  padding: var(--space-3);
  position: relative;
}
.profile-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 52px;
  padding: var(--space-2) var(--space-3);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: border-color 180ms ease-out, background-color 180ms ease-out;
}
/* same neutral hover vocabulary as .btn:hover — no brand/money hue on hover */
.profile-btn:hover { border-color: var(--ink-soft); background: var(--hover-tint); }
.avatar {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: oklch(1 0 0);
  display: grid; place-items: center;
  font-weight: 700; font-size: 0.95rem;
}
.avatar.alt { background: var(--accent); }
.avatar.alt2 { background: var(--dark); }
.profile-name { font-weight: 600; font-size: 0.95rem; line-height: 1.2; }
.profile-role { font-size: 0.95rem; color: var(--ink-soft); line-height: 1.3; }
.chev { margin-left: auto; color: var(--ink-soft); flex: none; }

.profile-menu {
  position: absolute;
  left: var(--space-3); right: var(--space-3);
  bottom: calc(100% - var(--space-2));
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 30px oklch(0.235 0.02 40 / 0.14);
  padding: var(--space-2);
  z-index: 60;
}
.profile-menu[hidden] { display: none; }
.profile-menu .menu-label {
  font-size: 0.95rem; color: var(--ink-soft);
  padding: var(--space-2) var(--space-3) var(--space-1);
}
.menu-item {
  display: flex; align-items: center; gap: var(--space-3);
  width: 100%; min-height: 46px;
  padding: var(--space-2) var(--space-3);
  background: transparent; border: 0; border-radius: var(--radius-sm);
  text-align: left; cursor: pointer; font-size: 0.95rem;
  /* rendered as a mix of <a> (Settings) and <button> (Sign out) */
  color: var(--ink); text-decoration: none;
  transition: background-color 160ms ease-out;
}
/* --surface here was barely a step off the white menu; --hover-tint is the
   same neutral the sidebar nav uses, so the two list vocabularies match */
.menu-item:hover { background: var(--hover-tint); }
.menu-item .avatar { width: 28px; height: 28px; font-size: 0.95rem; }
.menu-item .ico { flex: none; color: var(--ink-soft); display: flex; }
.menu-item .ico svg { width: 18px; height: 18px; }
.menu-sep { height: 1px; background: var(--line-soft); margin: var(--space-2) var(--space-2); }
/* the sign-out control is a <button> wrapped in a form; keep it flush */
.profile-menu .menu-form { margin: 0; }

/* mobile top bar (revealed at <=900px in the responsive block below) */
.topbar { display: none; }

.main {
  margin-left: 240px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.page-head {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  padding: var(--space-5) var(--space-6) var(--space-4);
  border-bottom: 1px solid var(--line-soft);
}
.page-head h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.75rem;
  letter-spacing: -0.01em;
}
.head-date { margin-left: auto; color: var(--ink-soft); font-size: 0.95rem; }

/* The mockup's "market open" chip and its pulsing dot lived here, painted in
   --gain — the money green — for a STATUS. No screen in the built app uses
   either one (phase 1 has no live market-status indicator; that arrives with
   the phase 2 Watchman), and leaving them in was a loaded gun: the next
   person to reach for a ready-made status chip would have painted a non-money
   state in Rishi's profit colour without noticing. Removed in the pre-deploy
   sweep, 25 Jul 2026. When phase 2 needs a market-status chip, build it on the
   brand hue like every other "pay attention" treatment in this file. */

.view { padding: var(--space-6) var(--space-6) var(--space-7); flex: 1 1 auto; }
.view[hidden] { display: none; }

/* ---------- shared pieces ---------- */
.panel {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.panel-head {
  display: flex; align-items: baseline; gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--line-soft);
}
.panel-head h2 { font-size: 1.15rem; }
.panel-head .sub { font-size: 0.95rem; color: var(--ink-soft); }
.panel-head .right { margin-left: auto; }
.panel-body { padding: var(--space-5); }

.section-title {
  font-size: 1.2rem;
  margin-bottom: var(--space-3);
}
.section-note { color: var(--ink-soft); font-size: 0.95rem; }

/* deliberate vertical rhythm: related blocks sit close, new subjects get air */
.stack-tight { margin-top: var(--space-5); }
.stack { margin-top: var(--space-6); }
.stack-loose { margin-top: var(--space-7); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font-weight: 600; font-size: 0.95rem;
  cursor: pointer;
  transition: background-color 180ms ease-out, border-color 180ms ease-out, transform 150ms ease-out;
}
.btn:hover { background: var(--surface); border-color: var(--ink-soft); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--primary); border-color: var(--primary);
  color: oklch(1 0 0);
}
.btn-primary:hover { background: var(--primary-deep); border-color: var(--primary-deep); }
.btn-danger { color: var(--danger); border-color: var(--line); }
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn-small { min-height: 44px; padding: 0 var(--space-3); font-size: 0.95rem; font-weight: 500; }
.btn-link {
  /* An <a> is inline by default, and inline boxes ignore min-height — so the
     44px target below was silently doing nothing wherever a .btn-link was NOT
     already a flex item (e.g. Today's "See the full page", which measured 15px
     tall at the 85% scale). inline-flex makes the declared target real. */
  display: inline-flex; align-items: center;
  background: none; border: 0; padding: 0;
  min-height: 44px;
  color: var(--primary-deep); font-weight: 600; font-size: 0.95rem;
  cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.btn-link:hover { color: var(--primary); }

.pill {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.35;
  white-space: normal;
}
.pill-watch { background: var(--accent-bg); color: var(--accent); }
.pill-gain { background: var(--gain-bg); color: var(--gain); }
.pill-loss { background: var(--loss-bg); color: var(--loss); }
.pill-neutral { background: var(--surface); color: var(--ink-soft); }
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 5px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  vertical-align: 2px;
}
/* money direction — reserved for the owner's gains/losses, never decoration */
.up { color: var(--gain); }
.down { color: var(--loss); }

/* ---------- table ---------- */
.table-wrap { width: 100%; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
table.data th, table.data td {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  vertical-align: top;
  border-bottom: 1px solid var(--line-soft);
}
table.data thead th {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  padding-top: var(--space-3);
  padding-bottom: var(--space-3);
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background-color 160ms ease-out; }
table.data tbody tr:hover { background: var(--hover-tint); }

/* ---------- forms ---------- */
label.field-label { display: block; font-weight: 600; margin-bottom: var(--space-2); }
.field-help { margin-top: var(--space-2); color: var(--ink-soft); font-size: 0.95rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; margin-top: var(--space-4); }

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-4);
  margin: var(--space-4) 0;
}
.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field label { font-weight: 600; font-size: 1rem; color: var(--ink); }
.field .opt { font-weight: 500; color: var(--ink-soft); font-size: 0.95rem; }
.field input, .field select {
  font-family: var(--font-ui);
  font-size: 1rem;
  color: var(--ink);
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.62rem 0.75rem;
  min-height: 45px;
  width: 100%;
}
.field input::placeholder { color: var(--ink-soft); opacity: 1; }
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
.field .field-note { font-size: 0.95rem; color: var(--ink-soft); line-height: 1.45; }

/* ---------- honest placeholder (screens not yet built) ---------- */
.soon {
  text-align: center;
  padding: var(--space-8) var(--space-5);
  max-width: 56ch;
  margin: 0 auto;
}
.soon .badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.95rem; font-weight: 600;
  margin-bottom: var(--space-4);
}
.soon h2 { font-family: var(--font-display); font-size: 1.6rem; margin-bottom: var(--space-3); }
/* plain dark text — never a faint "coming soon" grey */
.soon-lead { color: var(--ink); font-size: 1.1rem; line-height: 1.6; }
.soon-lead strong { font-weight: 700; }

/* ---------- utilities ---------- */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* dark overlay behind the phone drawer (below the sidebar, above content) */
.scrim {
  position: fixed; inset: 0;
  background: oklch(0.235 0.02 40 / 0.42);
  z-index: 35;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease-out;
}
.scrim.show { opacity: 1; pointer-events: auto; }

/* ---------- responsive ---------- */
/* table reflows to stacked rows before columns get cramped */
@media (max-width: 1020px) {
  table.data thead { display: none; }
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data tr {
    border-bottom: 1px solid var(--line);
    padding: var(--space-3) 0;
  }
  table.data tbody tr:last-child { border-bottom: 0; }
  table.data td {
    border-bottom: 0;
    padding: var(--space-1) var(--space-4);
    display: flex;
    gap: var(--space-4);
    align-items: baseline;
    justify-content: space-between;
  }
  table.data td::before {
    content: attr(data-label);
    font-size: 0.95rem;
    color: var(--ink-soft);
    font-weight: 500;
    flex: none;
  }
}

/* sidebar collapses to an off-canvas drawer; mobile top bar appears */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 220ms ease-out;
    width: 268px;
    box-shadow: 0 0 40px oklch(0.235 0.02 40 / 0.18);
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .topbar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    padding: var(--space-2) var(--space-4);
  }
  .menu-btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: var(--space-2);
    min-height: 46px; min-width: 46px;
    padding: 0 var(--space-3);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
  }
  .menu-btn:hover { background: var(--surface); }
  .topbar .brand-mark { font-size: 1.35rem; }
  .page-head { padding: var(--space-4) var(--space-5) var(--space-3); }
  .view { padding: var(--space-5) var(--space-5) var(--space-6); }
}

@media (max-width: 620px) {
  .page-head h1 { font-size: 1.5rem; }
  .head-date { margin-left: 0; flex-basis: 100%; }
  .panel-head, .panel-body { padding-left: var(--space-4); padding-right: var(--space-4); }
  .view { padding: var(--space-4) var(--space-4) var(--space-6); }
  table.data td { padding-left: var(--space-4); padding-right: var(--space-4); }
  .btn, .btn-small { width: 100%; }
  .form-actions .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
