/* ============================================================
   ftm – application stylesheet
   Sleek, minimal, dark-first with light-mode override
   ============================================================ */

/* ── Design tokens ─────────────────────────────────────────── */
:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-input: #13161f;
  --border: #2a2d3a;
  --accent: #7c6af7;
  --accent-h: #9d8fff;
  --text: #e2e4ef;
  --text-dim: #7b7f96;
  --danger: #f06a6a;
  --success: #5cb85c;
  --radius: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, .45);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --trans: 160ms ease;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6fa;
    --bg-card: #ffffff;
    --bg-input: #eef0f7;
    --border: #dde0ed;
    --accent: #5b4cf0;
    --accent-h: #7c6af7;
    --text: #1a1c2a;
    --text-dim: #6b7080;
    --shadow: 0 4px 24px rgba(0, 0, 0, .10);
  }
}

/* ── Reset ─────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Layout ────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.container-wide {
  max-width: 1600px;
  /* Allow children to shrink inside flex/grid so wide tables scroll instead of spill */
  min-width: 0;
}

/* ── Table scroll containers (rank, holdings, momentum, allocation, …) ──
   Parent tiles/cards must use min-width:0 so grid tracks can shrink. */
.table-scroll,
.table-responsive {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: auto;
  max-height: min(70vh, 42rem);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  border-radius: 6px;
}
.table-scroll > table,
.table-responsive > table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
}
/* Keep header labels readable when scrolling horizontally */
.table-scroll th,
.table-responsive th {
  white-space: nowrap;
}

/* ── Navigation ────────────────────────────────────────────── */
nav {
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
}

nav .container {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding-top: .75rem;
  padding-bottom: .75rem;
}

.nav-brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -.02em;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
}

.nav-links a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: .9rem;
  transition: color var(--trans);
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
}

.nav-links a.nav-profile {
  margin-left: 1.5rem;
}

.nav-links a.nav-logout {
  margin-left: 0.75rem;
  color: #8183f0;
}

/* ── Main content ──────────────────────────────────────────── */
main {
  flex: 1;
  padding: 3rem 0 4rem;
}

/* ── Typography ────────────────────────────────────────────── */
h1 {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -.04em;
  line-height: 1.2;
}

h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -.02em;
  margin-bottom: .75rem;
}

h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: .5rem;
}

p {
  color: var(--text-dim);
}

p+p {
  margin-top: .75rem;
}

.hero {
  text-align: center;
  padding: 3.5rem 0 2.5rem;
}

.hero .subtitle {
  font-size: 1.15rem;
  color: var(--text-dim);
  margin-top: .75rem;
  max-width: 520px;
  margin-inline: auto;
}

.badge {
  display: inline-block;
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent-h);
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 999px;
  padding: .15rem .75rem;
  font-size: .8rem;
  font-weight: 600;
  margin-bottom: 1rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* ── Home GO / NO-GO banner ────────────────────────────────── */
.gng-banner {
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 1.15rem 1.35rem 1rem;
  margin-bottom: 0.25rem;
  box-shadow: var(--shadow);
}

.gng-banner.gng-go {
  background: linear-gradient(135deg, rgba(92, 184, 92, 0.14), rgba(26, 29, 39, 0.95));
  border-color: color-mix(in srgb, var(--success) 55%, var(--border));
}

.gng-banner.gng-caution {
  background: linear-gradient(135deg, rgba(241, 196, 15, 0.14), rgba(26, 29, 39, 0.95));
  border-color: color-mix(in srgb, #f1c40f 55%, var(--border));
}

.gng-banner.gng-nogo {
  background: linear-gradient(135deg, rgba(240, 106, 106, 0.16), rgba(26, 29, 39, 0.95));
  border-color: color-mix(in srgb, var(--danger) 55%, var(--border));
}

.gng-banner-top {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.25rem;
  align-items: flex-start;
}

.gng-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 0.55rem 1rem;
  border-radius: 10px;
  line-height: 1.1;
  flex-shrink: 0;
}

.gng-go .gng-badge {
  background: color-mix(in srgb, var(--success) 22%, transparent);
  color: #7ddea0;
  border: 1px solid color-mix(in srgb, var(--success) 50%, transparent);
}

.gng-caution .gng-badge {
  background: rgba(241, 196, 15, 0.18);
  color: #f5d76e;
  border: 1px solid rgba(241, 196, 15, 0.45);
}

.gng-nogo .gng-badge {
  background: color-mix(in srgb, var(--danger) 22%, transparent);
  color: #ff9b9b;
  border: 1px solid color-mix(in srgb, var(--danger) 50%, transparent);
}

.gng-icon {
  font-weight: 700;
  font-size: 1.15rem;
}

.gng-headline-block {
  flex: 1;
  min-width: 220px;
}

.gng-headline {
  margin: 0 0 0.35rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.01em;
}

.gng-summary {
  margin: 0 0 0.4rem;
  color: var(--text-dim);
  font-size: 0.98rem;
  line-height: 1.55;
  max-width: 52rem;
}

.gng-meta {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-dim);
  opacity: 0.9;
}

.gng-details {
  margin-top: 0.9rem;
  border-top: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  padding-top: 0.65rem;
}

.gng-details > summary {
  cursor: pointer;
  color: var(--accent-h);
  font-weight: 600;
  font-size: 0.9rem;
  list-style: none;
  user-select: none;
}

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

.gng-details > summary::before {
  content: "▸ ";
  color: var(--text-dim);
}

.gng-details[open] > summary::before {
  content: "▾ ";
}

.gng-check-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.gng-check {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}

.gng-check-mark {
  flex-shrink: 0;
  min-width: 4.4rem;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.2rem 0.35rem;
  border-radius: 999px;
  margin-top: 0.1rem;
}

.gng-check-pass .gng-check-mark {
  background: rgba(92, 184, 92, 0.18);
  color: #7ddea0;
}

.gng-check-fail .gng-check-mark {
  background: rgba(240, 106, 106, 0.2);
  color: #ff9b9b;
}

.gng-check-warn .gng-check-mark {
  background: rgba(241, 196, 15, 0.18);
  color: #f5d76e;
}

.gng-check-info .gng-check-mark,
.gng-check-unknown .gng-check-mark {
  background: rgba(124, 106, 247, 0.16);
  color: var(--accent-h);
}

.gng-check-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.gng-check-body strong {
  color: var(--text);
  font-size: 0.92rem;
}

.gng-check-detail {
  color: var(--text-dim);
  font-size: 0.86rem;
  line-height: 1.45;
}

/* ── Admin job schedules ───────────────────────────────────── */
.sched-status-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  background: color-mix(in srgb, var(--bg-card) 90%, var(--accent));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.sched-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem 1rem;
  align-items: end;
}

.sched-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sched-card-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
}

.sched-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.sched-card-disabled {
  opacity: 0.72;
  border-style: dashed;
}

.sched-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin-top: 0.65rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.accounts-sort-th:hover {
  color: var(--accent) !important;
  text-decoration: underline !important;
}

.accounts-table th {
  white-space: nowrap;
}

.sched-runs,
.sched-edit {
  margin-top: 0.75rem;
  border-top: 1px solid var(--border);
  padding-top: 0.5rem;
}

.sched-runs > summary,
.sched-edit > summary {
  cursor: pointer;
  color: var(--accent-h);
  font-weight: 600;
  font-size: 0.88rem;
  user-select: none;
}

.sched-edit .sched-form {
  background: color-mix(in srgb, var(--bg) 40%, transparent);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1rem 1rem;
}

.sched-editor .cred-form-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 0.25rem;
}

.sched-editor input[type="text"],
.sched-editor input[type="number"],
.sched-editor select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
}

/* ── Cards ─────────────────────────────────────────────────── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-top: 2.5rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: border-color var(--trans), transform var(--trans);
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.card-icon {
  font-size: 1.6rem;
  margin-bottom: .75rem;
}

.card a {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  color: var(--accent-h);
  text-decoration: none;
  font-size: .85rem;
  font-weight: 600;
  margin-top: 1rem;
  transition: gap var(--trans);
}

.card a:hover {
  gap: .5rem;
}

/* ── Demo section ──────────────────────────────────────────── */
.demo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
  /* Critical for nested wide tables: grid items default to min-width:auto and spill */
  min-width: 0;
}

.demo-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.demo-box h3 {
  color: var(--text);
}

/* ── Buttons ────────────────────────────────────────────────── */
button,
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: .55rem 1.25rem;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--trans), transform var(--trans), box-shadow var(--trans);
  text-decoration: none;
  font-family: var(--font);
}

button:hover,
.btn:hover {
  background: var(--accent-h);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 50%, transparent);
}

button:active,
.btn:active {
  transform: translateY(0);
}

.btn-sm {
  padding: .35rem .8rem;
  font-size: .8rem;
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-row {
  display: flex;
  gap: .75rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-top: .75rem;
}

label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: .3rem;
  color: var(--text);
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="month"],
select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: .9rem;
  padding: .5rem .85rem;
  transition: border-color var(--trans);
}

/* Native date/time pickers — always-visible calendar glyph.
   Chromium's default indicator is often black-on-dark (or inverted wrong
   under prefers-color-scheme: light while the field stays dark). Replace it
   with an explicit light SVG so ML / screener dark inputs always show a icon. */
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="month"] {
  color-scheme: dark;
  padding-right: 2.6rem !important;
  position: relative;
  min-height: 2.4rem;
}

/* Light calendar icon (stroke #e2e4ef) — used on dark fields */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 1 !important;
  width: 1.35rem !important;
  height: 1.35rem !important;
  margin: 0;
  padding: 0.15rem;
  border-radius: 4px;
  position: absolute;
  right: 0.4rem;
  top: 50%;
  transform: translateY(-50%);
  filter: none !important;
  color: transparent;
  background-color: rgba(255, 255, 255, 0.12) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e2e4ef' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  background-size: 1.1rem 1.1rem !important;
}

/* Dark-card date fields (ML page, screener) — force dark scheme + light icon */
.date-input,
input[type="date"].date-input,
input[type="date"][style*="background"],
input[type="date"][style*="0c0d14"],
input[type="date"][style*="131722"] {
  color-scheme: dark !important;
  color: #e2e4ef !important;
  padding-right: 2.6rem !important;
  position: relative;
  min-height: 2.4rem;
}

.date-input::-webkit-calendar-picker-indicator,
input[type="date"].date-input::-webkit-calendar-picker-indicator,
input[type="date"][style*="background"]::-webkit-calendar-picker-indicator,
input[type="date"][style*="0c0d14"]::-webkit-calendar-picker-indicator,
input[type="date"][style*="131722"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 1 !important;
  width: 1.4rem !important;
  height: 1.4rem !important;
  margin: 0 !important;
  padding: 0.2rem !important;
  border-radius: 4px;
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  filter: none !important;
  color: transparent !important;
  background-color: rgba(124, 106, 247, 0.35) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  background-size: 1.15rem 1.15rem !important;
}

/* OS light theme only when the field itself is not a forced dark .date-input */
@media (prefers-color-scheme: light) {
  input[type="date"]:not(.date-input):not([style*="0c0d14"]):not([style*="131722"]),
  input[type="datetime-local"]:not(.date-input),
  input[type="time"]:not(.date-input),
  input[type="month"]:not(.date-input) {
    color-scheme: light;
  }

  input[type="date"]:not(.date-input):not([style*="0c0d14"]):not([style*="131722"])::-webkit-calendar-picker-indicator,
  input[type="datetime-local"]:not(.date-input)::-webkit-calendar-picker-indicator,
  input[type="time"]:not(.date-input)::-webkit-calendar-picker-indicator,
  input[type="month"]:not(.date-input)::-webkit-calendar-picker-indicator {
    filter: none !important;
    background-color: rgba(0, 0, 0, 0.08) !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231a1c2a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-size: 1.1rem 1.1rem !important;
  }
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
}

.field {
  flex: 1;
  min-width: 160px;
}

/* ── HTMX result area ───────────────────────────────────────── */
.result-area {
  margin-top: 1.25rem;
  min-height: 3rem;
  padding: .85rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: .9rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  transition: background var(--trans);
}

.result-area:empty::before {
  content: 'Result will appear here…';
  color: var(--text-dim);
  font-family: var(--font);
  font-style: italic;
}

/* Counter badge */
.counter-display {
  font-size: 3rem;
  font-weight: 800;
  color: var(--accent-h);
  line-height: 1;
  margin: .75rem 0;
  letter-spacing: -.05em;
}

/* ── Code ───────────────────────────────────────────────────── */
code {
  font-family: var(--font-mono);
  font-size: .85em;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .1em .4em;
}

/* ── Footer ─────────────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 0;
  text-align: center;
  font-size: .8rem;
  color: var(--text-dim);
}

footer a {
  color: var(--accent-h);
  text-decoration: none;
}

/* ── Compact company name under ticker symbols ──────────────── */
.ftm-ticker-name {
  display: block;
  margin-top: 0.12rem;
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1.2;
  color: #8a8d9b;
  font-family: var(--font);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 11rem;
  letter-spacing: 0.01em;
}

/* ── HTMX loading indicator ─────────────────────────────────── */
.htmx-indicator {
  opacity: 0;
  transition: opacity 200ms;
}

.htmx-request .htmx-indicator {
  opacity: 1;
}

.htmx-request.htmx-indicator {
  opacity: 1;
}

#screener-results-container.htmx-request {
  opacity: 0.5;
  pointer-events: none;
  transition: opacity 0.15s ease-in-out;
}

/* spinner */
.spinner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  font-size: 0.625rem;
  line-height: 1;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Grok market note (home card) ───────────────────────────── */
.grok-error {
  color: var(--danger);
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
}

.grok-md {
  line-height: 1.55;
  font-size: 0.92rem;
  color: #d1d4dc;
  margin: 0;
}

.grok-md h2,
.grok-md h3,
.grok-md h4 {
  margin: 1.15rem 0 0.45rem;
  padding: 0 0 0.35rem;
  color: #e8eaf2;
  font-weight: 700;
  letter-spacing: 0.01em;
  border-bottom: 1px solid rgba(93, 104, 168, 0.28);
}

.grok-md h2 {
  font-size: 1.05rem;
}

.grok-md h3 {
  font-size: 0.98rem;
  color: #c7d2fe;
  border-bottom-color: rgba(129, 140, 248, 0.35);
}

.grok-md h4 {
  font-size: 0.92rem;
  color: #a5b4fc;
  border-bottom: none;
  padding-bottom: 0;
}

.grok-md h2:first-child,
.grok-md h3:first-child,
.grok-md h4:first-child {
  margin-top: 0.15rem;
}

.grok-md p {
  margin: 0.45rem 0 0.65rem;
  color: #c8cbd8;
}

.grok-md ul,
.grok-md ol {
  margin: 0.35rem 0 0.85rem;
  padding-left: 1.2rem;
}

.grok-md li {
  margin: 0.35rem 0;
  padding-left: 0.2rem;
  color: #d1d4dc;
}

.grok-md li::marker {
  color: #818cf8;
}

.grok-md strong {
  color: #f3f4f8;
  font-weight: 700;
}

.grok-md em {
  color: #c4b5fd;
  font-style: italic;
}

.grok-md code {
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 0.84em;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(129, 140, 248, 0.25);
  border-radius: 4px;
  padding: 0.08em 0.35em;
  color: #c7d2fe;
}

.grok-md a.grok-link {
  color: #93c5fd;
  text-decoration: none;
  border-bottom: 1px solid rgba(147, 197, 253, 0.35);
  transition: color 0.12s ease, border-color 0.12s ease;
}

.grok-md a.grok-link:hover {
  color: #bfdbfe;
  border-bottom-color: rgba(191, 219, 254, 0.75);
}

/* Compact citation chips for [[n]](url) / [n](url) */
.grok-md a.grok-cite {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  height: 1.2rem;
  margin: 0 0.12rem;
  padding: 0 0.35rem;
  vertical-align: 0.12em;
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: #c7d2fe;
  text-decoration: none;
  background: rgba(99, 102, 241, 0.18);
  border: 1px solid rgba(129, 140, 248, 0.4);
  border-radius: 999px;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.grok-md a.grok-cite:hover {
  color: #fff;
  background: rgba(99, 102, 241, 0.4);
  border-color: rgba(165, 180, 252, 0.75);
}

.grok-md hr.grok-hr {
  border: none;
  border-top: 1px solid rgba(75, 85, 99, 0.55);
  margin: 0.9rem 0;
}

.home-grok-card-inner {
  min-width: 0;
}

/* ── Utility ────────────────────────────────────────────────── */
.mt-1 {
  margin-top: .5rem;
}

.mt-2 {
  margin-top: 1rem;
}

.mt-3 {
  margin-top: 1.5rem;
}

.text-dim {
  color: var(--text-dim);
  font-size: .875rem;
}

.section-title {
  margin-bottom: 1.5rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border);
}

/* ── Popover backdrop styling ───────────────────────────────── */
[popover]::backdrop {
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* ── Settings Saved fade-out message ────────────────────────── */
.fade-out-msg {
  animation: fadeOut 2s ease-in-out forwards;
}

@keyframes fadeOut {
  0% {
    opacity: 1;
  }

  70% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

#schwab-order-card.htmx-request,
#schwab-parking-card.htmx-request {
  opacity: 0.6;
  pointer-events: none;
  transition: opacity 0.15s ease-in-out;
}
/* ── Shared collapsible sections (Holdings and friends) ─────────────────── */
details.ftm-collapse > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.65rem;
  min-height: 2.75rem;
  padding: 0.2rem 0;
  margin: 0;
  color: #c8ccd6;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
details.ftm-collapse > summary::-webkit-details-marker { display: none; }
details.ftm-collapse > summary .ftm-collapse-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  color: #6b7280;
  font-size: 0.72rem;
  line-height: 1;
  transition: transform 0.15s ease, color 0.12s ease;
  flex-shrink: 0;
}
details.ftm-collapse[open] > summary .ftm-collapse-chevron {
  transform: rotate(90deg);
  color: #9ca3af;
}
details.ftm-collapse > summary:hover .ftm-collapse-chevron,
details.ftm-collapse > summary:focus-visible .ftm-collapse-chevron {
  color: #c8ccd6;
}
details.ftm-collapse > summary:focus-visible {
  outline: 2px solid rgba(124, 156, 255, 0.55);
  outline-offset: 3px;
  border-radius: 6px;
}
details.ftm-collapse .ftm-collapse-body {
  padding-top: 0.55rem;
}
details.ftm-collapse > summary .ftm-collapse-title {
  color: #fff;
  font-weight: 700;
  font-size: 1.02rem;
}
details.ftm-collapse > summary .ftm-collapse-meta {
  font-size: 0.78rem;
  color: #8a8d9b;
  font-weight: 600;
}
@media (max-width: 640px) {
  details.ftm-collapse > summary {
    min-height: 3rem;
    gap: 0.4rem 0.5rem;
  }
}

/* ── Watch Radar chips ───────────────────────────────────────────────────── */
.watch-chip {
  display: inline-flex;
  align-items: center;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  border: 1px solid var(--border);
  line-height: 1.2;
  white-space: nowrap;
}
.watch-chip-etf { color: #93c5fd; background: rgba(59,130,246,0.14); border-color: rgba(59,130,246,0.4); }
.watch-chip-eq { color: #c8ccd6; background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.12); }
.watch-chip-park { color: #8a8d9b; background: rgba(138,141,155,0.12); border-color: rgba(138,141,155,0.35); }
.watch-chip-ready { color: #2ecc71; background: rgba(46,204,113,0.16); border-color: rgba(46,204,113,0.45); }
.watch-chip-almost { color: #f1c40f; background: rgba(241,196,15,0.12); border-color: rgba(241,196,15,0.4); }
.watch-chip-wait { color: #6b7280; background: rgba(0,0,0,0.2); border-color: rgba(107,114,128,0.35); }
.watch-chip-up { color: #6ee7b7; background: rgba(16,185,129,0.12); border-color: rgba(16,185,129,0.4); }
.watch-chip-down { color: #fca5a5; background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.4); }
.watch-chip-flat { color: #9ca3af; background: rgba(255,255,255,0.04); border-color: rgba(156,163,175,0.3); }
.watch-chip-new { color: #a5b4fc; background: rgba(99,102,241,0.12); border-color: rgba(99,102,241,0.35); }

.watch-ready-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  white-space: nowrap;
}
.watch-ready-cell .ftm-info-icon {
  flex: 0 0 auto;
}

/* ── Watch list manage + Chart membership ───────────────────── */
.watch-manage-btns {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
}
.watch-drag-handle {
  cursor: grab;
  user-select: none;
  font-size: 0.85rem;
  line-height: 1;
}
.watch-drag-handle:active { cursor: grabbing; }
.sortable-ghost { opacity: 0.4; background: rgba(255,255,255,0.05) !important; }
.watch-actions-cell {
  padding: 0.4rem 0.45rem;
  text-align: right;
  vertical-align: middle;
  width: 1%;
  white-space: nowrap;
}
.watch-row-actions {
  --watch-act-size: 28px;
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.3rem;
  height: var(--watch-act-size);
  line-height: 0; /* avoid baseline drift between <a>/<button>/<details> */
}
.watch-act {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  height: var(--watch-act-size);
  min-height: var(--watch-act-size);
  max-height: var(--watch-act-size);
  min-width: var(--watch-act-size);
  padding: 0 0.65rem;
  margin: 0;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: #1c1f2e;
  color: #d1d4dc;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  vertical-align: middle;
  flex: 0 0 auto;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.watch-act:hover {
  background: #2a2f45;
  border-color: rgba(165,180,252,0.45);
  color: #fff;
}
.watch-act-enter {
  background: #243048;
  border-color: rgba(96,165,250,0.45);
  color: #93c5fd;
  padding: 0 0.7rem;
  letter-spacing: 0.01em;
}
.watch-act-enter:hover {
  background: rgba(59,130,246,0.22);
  border-color: rgba(96,165,250,0.7);
  color: #dbeafe;
}
/* details/summary must match sibling button boxes exactly */
.watch-act-menu {
  position: relative;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  flex: 0 0 var(--watch-act-size);
  width: var(--watch-act-size);
  height: var(--watch-act-size);
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}
.watch-act-menu > summary.watch-act-more {
  list-style: none;
  display: inline-flex !important; /* override UA list-item */
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: var(--watch-act-size);
  height: var(--watch-act-size);
  min-width: var(--watch-act-size);
  padding: 0;
  margin: 0;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: #1c1f2e;
  color: #9ca3af;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
  cursor: pointer;
}
.watch-act-menu > summary.watch-act-more::-webkit-details-marker { display: none; }
.watch-act-menu > summary.watch-act-more::marker { content: ""; }
.watch-act-menu > summary.watch-act-more:hover {
  background: #2a2f45;
  border-color: rgba(165,180,252,0.45);
  color: #fff;
}
.watch-act-menu[open] > summary.watch-act-more {
  background: rgba(165,180,252,0.14);
  border-color: rgba(165,180,252,0.55);
  color: #e0e7ff;
}
.watch-act-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 40;
  min-width: 12.5rem;
  padding: 0.55rem 0.6rem;
  background: #161824;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.45);
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  line-height: normal;
}
.watch-act-menu-section {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: stretch;
}
.watch-act-menu-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #6b7280;
  line-height: 1.2;
}
.watch-xfer-select {
  width: 100%;
  background: #0c0d14;
  border: 1px solid var(--border);
  color: #e5e7eb;
  padding: 0.35rem 0.45rem;
  border-radius: 5px;
  font-size: 0.78rem;
  cursor: pointer;
  line-height: normal;
}
.watch-xfer-select:focus {
  outline: none;
  border-color: rgba(165,180,252,0.55);
}
.watch-act-remove {
  width: var(--watch-act-size);
  min-width: var(--watch-act-size);
  padding: 0;
  background: transparent;
  border-color: transparent;
  color: #6b7280;
  font-size: 1rem;
  font-weight: 500;
}
.watch-act-remove:hover {
  background: rgba(239,83,80,0.12);
  border-color: rgba(239,83,80,0.4);
  color: #ef9a9a;
}
@media (max-width: 640px) {
  .watch-act-menu-panel {
    position: fixed;
    left: 0.75rem;
    right: 0.75rem;
    top: auto;
    bottom: 0.75rem;
    min-width: 0;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.5);
  }
}

.chart-watchlist-bar {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  margin-left: 0.15rem;
}
.chart-wl-label {
  font-size: 11px;
  color: #6b7280;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.chart-wl-empty {
  font-size: 12px;
  color: #6b7280;
  font-style: italic;
}
.chart-wl-chip {
  font-size: 11px;
  font-weight: 600;
  color: #c4b5fd;
  background: rgba(124,106,247,0.14);
  border: 1px solid rgba(124,106,247,0.35);
  padding: 2px 7px;
  border-radius: 999px;
  text-decoration: none;
  line-height: 1.3;
}
.chart-wl-chip:hover {
  color: #fff;
  border-color: rgba(167,139,250,0.7);
  background: rgba(124,106,247,0.28);
}
.chart-wl-add { display: inline-flex; align-items: center; }
.chart-wl-select {
  background: #2a2d3a !important;
  color: #fff !important;
  border: 1px solid var(--border) !important;
  border-radius: 4px !important;
  padding: 2px 6px !important;
  font-size: 0.75rem !important;
  cursor: pointer;
}

