/* Manrope 700 -- self-hosted, used sparingly for brand/headings/table-header
   weight only. Body copy stays on the system stack (fast, no download). */
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/manrope-700.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/manrope-700-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+1E00-1E9F, U+2C60-2C7F;
}

:root {
  /* Light, monochrome-first admin-panel palette: black/white/gray with a
     single semantic green reserved for status, not a bright brand accent. */
  --bg: #f7f7f8;
  --surface: #ffffff;
  --border: #e6e6e9;
  --text: #18181b;
  --text-muted: #71717a;
  --text-faint: #a1a1aa;
  --ink: #18181b;
  --ink-contrast: #ffffff;
  --active-bg: #f1f1f3;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;

  --font-display: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  --radius: 12px;
  --topbar-height: 64px;
  --sidebar-width: 248px;
}

/* Light is the only enabled look for now -- deliberately NOT following
   prefers-color-scheme, since the app is being built against a specific
   light reference and auto-switching to dark made every review compare
   against a palette nobody had actually approved. The dark token set
   below is kept ready (unused) for whenever a real, reviewed dark mode
   and a manual toggle are wanted -- see [[project-app-web-scaffold]]. */
:root[data-theme="dark"] {
  --bg: #0f0f11;
  --surface: #18181b;
  --border: #2a2a2e;
  --text: #f1f1f3;
  --text-muted: #a1a1aa;
  --text-faint: #71717a;
  --ink: #f1f1f3;
  --ink-contrast: #18181b;
  --active-bg: #232327;
  --success: #4ade80;
  --danger: #f87171;
  --warning: #fbbf24;
}

:root[data-theme="light"] {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --border: #e6e6e9;
  --text: #18181b;
  --text-muted: #71717a;
  --text-faint: #a1a1aa;
  --ink: #18181b;
  --ink-contrast: #ffffff;
  --active-bg: #f1f1f3;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* Site-wide slim scrollbar (2026-07-28) -- the browser's own outer page
   scrollbar (not any panel's own -- this is the whole document, distinct
   from .table-wrap/.ai-chat-scroll which only cover their own scroll
   containers) was the last remaining spot still using the platform
   default chunky bar with up/down arrow buttons. Same treatment,
   applied globally so nothing on the page stands out as unstyled. */
html {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
html::-webkit-scrollbar {
  width: 8px;
}
html::-webkit-scrollbar-track {
  background: transparent;
}
html::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 100px;
}
html::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* ---- Shell: topbar + sidebar ---- */

.topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.page-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.icon-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 999px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}

.icon-btn:hover {
  background: var(--active-bg);
  color: var(--text);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--ink-contrast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.session-countdown {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--active-bg);
}

.session-countdown-warn {
  color: #dc2626;
  background: color-mix(in srgb, #dc2626 12%, transparent);
}

.avatar svg {
  width: 18px;
  height: 18px;
}

.layout {
  display: flex;
  min-height: calc(100vh - var(--topbar-height));
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: var(--space-4) var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-2) var(--space-5);
}

.brand-mark {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 9px;
  /* Fixed brand color, not a theme token -- a logo mark shouldn't invert
     with light/dark the way UI chrome does. */
  background: #18181b;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

.nav-section-label {
  padding: var(--space-4) var(--space-3) var(--space-1);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: background-color 120ms ease, color 120ms ease;
}

@media (prefers-reduced-motion: reduce) {
  .nav-item {
    transition: none;
  }
}

.nav-item:hover {
  background: var(--active-bg);
  color: var(--text);
}

.nav-item.active {
  background: var(--active-bg);
  color: var(--text);
  font-weight: 700;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: flex;
}

.nav-icon svg {
  width: 100%;
  height: 100%;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.sidebar-footer .avatar {
  background: var(--active-bg);
  color: var(--text-faint);
}

.sidebar-footer-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}

.sidebar-footer-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer-sub {
  font-size: 0.75rem;
  color: var(--text-faint);
}

/* ---- Content ---- */

.content {
  flex: 1;
  padding: var(--space-6);
  min-width: 0;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-5);
  /* Barely-there elevation -- enough to lift cards off the page's flat
     gray background, subtle enough to stay inside the monochrome,
     no-bright-accent direction the palette already commits to. */
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.panel-count {
  font-weight: 600;
  font-size: 0.95rem;
}

.lede {
  max-width: 65ch;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0;
}

/* ---- Reusable components (buttons, badges, table) for pages migrated in ---- */

.stat-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.stat-card {
  flex: 1;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4) var(--space-5);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

/* .table-meta is nowrap site-wide (right for table cells) -- but a stat
   tile's subtitle is free text of unpredictable length (e.g. Overview's
   Momentum/Today's P&L tiles), so scope it back to normal wrapping just
   inside a stat-card instead of letting it run past the card edge. */
.stat-card .table-meta {
  white-space: normal;
  overflow-wrap: break-word;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 var(--space-1);
}

.stat-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.6rem;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.search-input {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text-muted);
  max-width: 360px;
}

.search-input svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.search-input input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.88rem;
  color: var(--text);
  width: 100%;
}

.search-input input::placeholder {
  color: var(--text-faint);
}

.table-meta {
  font-size: 0.82rem;
  color: var(--text-faint);
  white-space: nowrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, opacity 120ms ease;
}

@media (prefers-reduced-motion: reduce) {
  .btn, .icon-btn, .ghost-btn, .meter > span, th.sortable, th.sortable .sort-icon {
    transition: none;
  }
}

.btn:hover {
  background: var(--active-bg);
}

.btn-primary {
  background: var(--ink);
  color: var(--ink-contrast);
  border-color: var(--ink);
}

.btn-primary:hover {
  opacity: 0.88;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px var(--space-3);
  border-radius: 999px;
  background: var(--active-bg);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Tinted status badges (2026-07-23) -- .badge.up/.down previously only
   changed the text color, leaving the same flat neutral-gray background
   regardless of status; a colored badge reads as a status chip faster
   than colored text alone. Same color-mix technique .risk-strip/.pill
   already used elsewhere, just applied consistently here too. */
.badge.up {
  background: color-mix(in srgb, var(--success) 14%, var(--active-bg));
}
.badge.down {
  background: color-mix(in srgb, var(--danger) 14%, var(--active-bg));
}

/* Adjacent badges (e.g. the VSTOP/ADX/RSI/momentum cluster in Holdings)
   were relying on incidental whitespace between inline-flex spans for
   spacing -- explicit and consistent regardless of how the markup wraps. */
.badge + .badge {
  margin-left: 4px;
}

/* Momentum score badge (2026-07-23) -- ported the STRUCTURE of the old
   private-app's MomGauge.jsx (the X/3 score got a distinct bordered
   "headline" treatment, separate from its green/red pass/fail dots), but
   using --ink instead of that app's blue --accent -- this palette is
   deliberately monochrome-first with no bright brand accent (see the
   :root comment at the top of this file), so --ink is the equivalent
   "this is the number that matters" treatment without introducing a new
   color into an otherwise accent-free system. */
.badge-score {
  background: color-mix(in srgb, var(--ink) 8%, var(--surface));
  color: var(--ink);
  border: 1px solid var(--ink);
  font-weight: 700;
}

.status {
  font-size: 0.85rem;
  font-weight: 600;
}

/* Ask AI chat bubbles (2026-07-28 redesign) -- was inline-style-only
   left/right flex divs with a generic .panel for both roles; separating
   into real classes here so user vs. assistant read as distinct chat
   turns at a glance rather than two same-looking cards. --ink/--ink-
   contrast (already used for .badge-score's "this is the number that
   matters" treatment) doubles as "this is you speaking" for the user
   bubble -- no new color introduced into the monochrome palette. */
.chat-row {
  display: flex;
  flex-direction: column;
  max-width: 100%;
  margin-bottom: var(--space-4);
}
.chat-row.user { align-items: flex-end; }
.chat-row.assistant { align-items: flex-start; }

.chat-role {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}

.chat-bubble {
  max-width: 80%;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
  white-space: pre-wrap;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  font-size: 0.88rem;
  line-height: 1.55;
}
.chat-bubble.user {
  background: var(--ink);
  color: var(--ink-contrast);
  border-bottom-right-radius: 4px;
}
.chat-bubble.assistant {
  max-width: 95%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.chat-bubble.assistant p:first-child { margin-top: 0; }
.chat-bubble.assistant :last-child { margin-bottom: 0; }

.chat-drafts {
  margin-top: var(--space-2);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.chat-input-bar {
  display: flex;
  gap: var(--space-2);
  align-items: flex-end;
}

/* Round icon-only button (mic) -- same visual weight as .btn but sized for
   a single icon rather than a text label. .listening swaps it to the
   --danger tint that .badge.down already established as this palette's
   "active/attention" color, so it's obvious when it's capturing audio. */
.chat-icon-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 999px;
}
.chat-icon-btn.listening {
  color: var(--danger);
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
}

/* Ask AI composer (2026-07-28) -- the plain .field-input textarea read as
   just another form field, flat next to the hero's rounded pills/soft
   vignette. This merges textarea + mic + send into one bordered "bar",
   the shape a chat composer actually has (Claude.ai/ChatGPT), rather than
   three separate boxed controls sitting side by side. Scoped to this one
   class, not a .field-input change -- ordinary forms elsewhere (task/
   routine creation) keep the plain field style, which is correct there. */
.ai-composer {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px -16px rgba(0, 0, 0, 0.15);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ai-composer:focus-within {
  border-color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 28px -14px rgba(0, 0, 0, 0.2);
}
.ai-composer-input {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  padding: var(--space-2) 0;
  font-size: 0.95rem;
  font-family: var(--font-body);
  color: var(--text);
  line-height: 1.5;
}
.ai-composer-input:focus,
.ai-composer-input:focus-visible {
  outline: none;
}
.ai-composer-input::placeholder {
  color: var(--text-faint);
}
.ai-composer .chat-icon-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
}
.ai-composer .chat-icon-btn:hover {
  background: var(--active-bg);
  color: var(--text);
}
.ai-composer .chat-icon-btn.listening {
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  color: var(--danger);
}
.ai-composer .btn-primary {
  border-radius: 16px;
}

/* Ask AI landing hero (2026-07-28) -- shown on every fresh page load in
   place of the raw history dump (history is hidden by default, toggled via
   the top-right button). A soft radial vignette gives it depth without
   introducing a new hue -- color-mix off --ink, so it stays inside the
   site's deliberately monochrome palette rather than reaching for an
   accent color the rest of the app doesn't use. */
/* Landing hero that collapses into a chat composer (2026-07-28) --
   #ai-page wraps both the hero/composer and the history panel. Before any
   message, .ai-landing-wrap sits vertically centered in the open page
   like a real blank-canvas start screen (min-height transition -- see
   below). Once "started" (first send, or manually opening History), the
   SAME reference point that this app has followed for chat apps
   generally: history above, a slim composer pinned below it -- achieved
   with a `order` swap rather than moving markup, and the greeting/
   suggestion chips (.ai-hero-decor) disappear since they'd be redundant
   mid-conversation, leaving just the input bar. */
.ai-page {
  display: flex;
  flex-direction: column;
}
.ai-page .ai-landing-wrap {
  order: 1;
}
#ai-history {
  order: 2;
}
.ai-page.ai-started .ai-landing-wrap {
  order: 2;
}
.ai-page.ai-started #ai-history {
  order: 1;
}
.ai-page.ai-started .ai-hero-decor {
  display: none;
}
.ai-page.ai-started #ai-history-toggle {
  display: none; /* redundant once the conversation is already showing */
}
.ai-page.ai-started .ai-hero-panel {
  padding: var(--space-3) var(--space-4);
}
.ai-page.ai-started .ai-hero-panel::before {
  display: none; /* the soft vignette suited a big empty hero, not a slim composer bar */
}

.ai-landing-wrap {
  display: flex;
  align-items: center;
  min-height: calc(100vh - var(--topbar-height) - var(--space-6) * 2);
  transition: min-height 0.5s ease;
}
.ai-page.ai-started .ai-landing-wrap {
  min-height: 0;
}
.ai-landing-wrap > * {
  width: 100%;
}
@media (prefers-reduced-motion: reduce) {
  .ai-landing-wrap {
    transition: none;
  }
}

.ai-hero-panel {
  position: relative;
  overflow: hidden;
}
.ai-hero-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse 640px 280px at 50% 0%,
    color-mix(in srgb, var(--ink) 5%, transparent),
    transparent 70%
  );
  pointer-events: none;
}
.ai-hero {
  position: relative;
  text-align: center;
  padding: var(--space-6) var(--space-4) var(--space-5);
  animation: ai-hero-in 0.5s ease-out;
}
@media (prefers-reduced-motion: reduce) {
  .ai-hero { animation: none; }
}
@keyframes ai-hero-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.ai-hero-icon {
  width: 30px;
  height: 30px;
  margin: 0 auto var(--space-2);
  color: var(--text-faint);
}
.ai-hero-headline {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-wrap: balance;
  margin: 0 0 var(--space-2);
}
.ai-hero-tagline {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--active-bg);
  border: 1px solid var(--border);
  padding: 4px var(--space-3);
  border-radius: 999px;
  margin-bottom: var(--space-3);
}
.ai-hero-subtitle {
  color: var(--text-faint);
  font-size: 1.05rem;
  margin: 0 0 var(--space-5);
}

/* Suggestion chips -- turn "what are we working on today" from a passive
   question into a menu of things this AI can actually do (portfolio,
   routines, memory), doubling as lightweight feature discovery. Click
   fills the textarea, doesn't auto-submit -- these can trigger real
   writes (routines, memory) downstream, so the user should see and
   confirm the exact wording before it goes anywhere. */
.ai-suggestions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  max-width: 680px;
  margin: var(--space-3) auto 0;
}
.ai-suggestion-chip {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px var(--space-3);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.ai-suggestion-chip:hover {
  border-color: var(--ink);
  color: var(--ink);
}
.ai-suggestion-chip:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.status-active {
  color: var(--success);
}

.status-inactive {
  color: var(--text-faint);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

th {
  text-align: left;
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: var(--space-2) var(--space-3);
  /* Heavier than td's 1px -- gives the header a clearer break from the
     body instead of reading as just another row. */
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color 120ms ease;
}

th.sortable:hover {
  color: var(--text);
}

th.sortable .sort-icon {
  display: inline-flex;
  width: 12px;
  height: 12px;
  vertical-align: -2px;
  margin-left: 3px;
  color: var(--text-faint);
  transition: transform 150ms ease;
}

th.sortable .sort-icon svg {
  width: 100%;
  height: 100%;
}

td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:hover {
  background: var(--active-bg);
}

.table-wrap {
  overflow-x: auto;
  /* Slim, theme-matched scrollbar for wide tables (e.g. Holdings' alpha
     tab) instead of the platform-default chunky gray bar. Firefox +
     Chromium/Safari properties both included; no-op elsewhere. */
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.table-wrap::-webkit-scrollbar {
  height: 8px;
}
.table-wrap::-webkit-scrollbar-track {
  background: transparent;
}
.table-wrap::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 100px;
}
.table-wrap::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
}

/* Ask AI chat scroll -- same slim, theme-matched treatment as .table-wrap
   above (2026-07-28), just the vertical-axis version: the platform-default
   scrollbar (with its chunky up/down arrow buttons) stood out against the
   rest of this app's deliberately minimal chrome. */
.ai-chat-scroll {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.ai-chat-scroll::-webkit-scrollbar {
  width: 8px;
}
.ai-chat-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.ai-chat-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 100px;
}
.ai-chat-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
}

/* ---- Overview / analytics widgets (Personal Management) ---- */
/* Reuses .panel/.panel-header from the shell section above; adds a plain
   title+note pairing for panels that don't need .panel-count's styling. */

.panel + .panel {
  margin-top: var(--space-4);
}

.panel-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.panel-note {
  font-size: 0.8rem;
  color: var(--text-faint);
}

.up { color: var(--success); }
.down { color: var(--danger); }
.muted { color: var(--text-faint); }

.hero-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 2.4rem;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-top: var(--space-2);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-weight: 600;
}
.delta svg { width: 14px; height: 14px; }

.meter {
  height: 6px;
  border-radius: 100px;
  background: var(--active-bg);
  overflow: hidden;
}
.meter > span {
  display: block;
  height: 100%;
  border-radius: 100px;
  background: var(--ink);
  transition: width 260ms ease;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px var(--space-3);
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
}

.legend-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
  transition: color 120ms ease;
}
.ghost-btn:hover { color: var(--text); }
.ghost-btn svg { width: 13px; height: 13px; }

.risk-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  /* Muted/tinted border instead of a full-strength warning-colored line --
     the tinted background already reads as "warning" clearly; a
     solid-color border on top of that read as louder than the content
     warranted. */
  border: 1px solid color-mix(in srgb, var(--warning) 35%, var(--border));
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--warning) 8%, var(--surface));
  margin-bottom: var(--space-4);
  font-size: 0.82rem;
}

.risk-chip {
  padding: 2px var(--space-2);
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.78rem;
}

.attrib-row {
  display: grid;
  grid-template-columns: 90px 1fr 100px;
  align-items: center;
  gap: var(--space-3);
  padding: 5px 0;
  font-size: 0.85rem;
}

.attrib-track {
  height: 8px;
  background: var(--active-bg);
  border-radius: 100px;
  position: relative;
  overflow: hidden;
}

.attrib-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 100px;
}
.attrib-bar.up { background: var(--success); left: 50%; }
.attrib-bar.down { background: var(--danger); right: 50%; }

.weight-cell {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  white-space: nowrap;
}
.weight-cell .meter { width: 60px; }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  align-items: center;
}
.filter-bar .field-input {
  padding: var(--space-2) var(--space-3);
  font-size: 0.85rem;
  cursor: pointer;
}
.filter-bar .search-input { margin: 0; }

.pulse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--space-4);
}

.pulse-seg {
  border-left: 1px solid var(--border);
  padding-left: var(--space-4);
}
.pulse-seg:first-child { border-left: none; padding-left: 0; }

.row-hero {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  /* No margin-bottom (removed 2026-07-22): this is only ever the last
     thing rendered inside #overview-top, which now sits in a flex column
     with its own explicit gap (see personal_overview.html) -- keeping a
     margin here as well doubled the gap to the next section. */
}
.row-hero > .hero-col { flex: 5 1 320px; }
.row-hero > .tiles-col { flex: 7 1 420px; }
.row-hero .stat-grid { margin-bottom: 0; height: 100%; }

.row-split {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  align-items: stretch;
}
.row-split > .col-7 { flex: 7 1 420px; }
.row-split > .col-5 { flex: 5 1 320px; }
.row-split > * { margin-bottom: 0; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-2);
  padding: var(--space-6) var(--space-4);
  color: var(--text-muted);
}
.empty-state svg { width: 32px; height: 32px; color: var(--text-faint); }
.empty-state-title { font-weight: 600; color: var(--text); }

/* ---- Form fields (login, entry add/edit) ---- */

.field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: var(--space-3) 0 var(--space-1);
}

.field-input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  font-family: var(--font-body);
}

.field-input:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 1px;
}

.field-input:disabled {
  color: var(--text-faint);
  background: var(--active-bg);
}

.field-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  font-size: 0.9rem;
}

.schedule-toggle {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-1);
}

.schedule-option {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.88rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.schedule-option:has(input:checked) {
  border-color: var(--ink);
  background: var(--active-bg);
}

.schedule-fields {
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

.script-editor {
  font-size: 0.82rem;
  line-height: 1.5;
  tab-size: 4;
}

.field-with-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.field-with-toggle .field-input {
  flex: 1;
  min-width: 0;
}

.field-with-toggle .icon-btn {
  flex-shrink: 0;
}

.json-textarea {
  width: 100%;
  resize: vertical;
  line-height: 1.5;
  min-height: 300px;
}

.secret-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.secret-value.revealed {
  color: var(--text);
  letter-spacing: normal;
}

.group-row {
  width: 100%;
}

.group-summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  cursor: pointer;
  list-style: none;
}

.group-summary::-webkit-details-marker {
  display: none;
}

.group-summary-name {
  font-weight: 600;
}

.group-summary-actions {
  margin-left: auto;
  display: flex;
  gap: var(--space-2);
  white-space: nowrap;
}

.group-children {
  padding: 0 var(--space-3) var(--space-3) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.group-child-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-1) 0;
  border-top: 1px solid var(--border);
}

.group-child-name {
  min-width: 160px;
}

/* ---- Standalone login page (no shell/sidebar) ---- */

.login-body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  font-family: var(--font-body);
  color: var(--text);
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-6);
}

.login-brand {
  padding: 0 0 var(--space-5);
}

.login-form {
  display: flex;
  flex-direction: column;
}

.login-submit {
  margin-top: var(--space-5);
  width: 100%;
  justify-content: center;
}

.login-error {
  background: color-mix(in srgb, #dc2626 12%, transparent);
  color: #dc2626;
  border-radius: 8px;
  padding: var(--space-2) var(--space-3);
  font-size: 0.85rem;
  margin: 0 0 var(--space-4);
}

.login-hint {
  margin: var(--space-5) 0 0;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text-faint);
}

.login-hint code {
  background: var(--active-bg);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.85em;
}

/* ---- Entry add/edit form ---- */

.entry-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 var(--space-4);
}

.entry-form-extra-row {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.entry-form-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

/* ---- Mobile layout (2026-07-28) ---- */
/* Sidebar collapses to an icon-only rail rather than an off-canvas drawer
   -- every nav item stays one tap away with no hamburger/overlay to learn,
   and the freed width goes straight to content. 768px catches phones and
   small tablets in portrait; nothing here changes above that width. */
@media (max-width: 768px) {
  .topbar {
    padding: 0 var(--space-3);
  }
  .page-title {
    font-size: 1rem;
  }
  .topbar-actions {
    gap: var(--space-2);
  }
  .session-countdown {
    display: none; /* the passkey session itself already governs access -- this just crowds a narrow row */
  }

  .sidebar {
    width: 56px;
    padding: var(--space-3) var(--space-1);
  }
  .brand {
    justify-content: center;
    padding: var(--space-2) 0 var(--space-4);
  }
  .brand-text,
  .nav-section-label,
  .nav-label,
  .sidebar-footer-text {
    display: none;
  }
  .nav-item {
    justify-content: center;
    padding: var(--space-3) 0;
    gap: 0;
  }
  .sidebar-footer {
    justify-content: center;
    padding-top: var(--space-3);
  }

  .content {
    padding: var(--space-4) var(--space-3);
  }
  .panel {
    padding: var(--space-4);
  }
  .panel-header {
    flex-wrap: wrap;
    row-gap: var(--space-2);
  }

  /* notebook.html's fixed 260px sidebar (pmsvc-rendered, inline style --
     see the module's own comment on why an override lives here instead of
     there) would eat most of a phone's width sitting next to the note
     body; stacked full-width above it reads correctly instead. */
  .nb-layout {
    flex-direction: column !important;
  }
  .nb-sidebar {
    width: 100% !important;
  }
}

@media (max-width: 480px) {
  .ai-hero {
    padding: var(--space-5) var(--space-3) var(--space-4);
  }
  .ai-hero-headline {
    font-size: 1.5rem;
  }
  .ai-hero-subtitle {
    font-size: 0.92rem;
  }
  /* The textarea + mic + Ask button no longer fit one row at this width --
     squeezing them together made the placeholder text wrap and collide
     with the mic icon. Wrapping to a second row (textarea full-width on
     its own line, buttons on the next) fixes it cleanly instead. */
  .ai-composer {
    flex-wrap: wrap;
    justify-content: flex-end;
    padding: var(--space-3);
  }
  .ai-composer-input {
    flex-basis: 100%;
  }
  .stat-card {
    min-width: 140px;
  }
}
