/* PutMonitor — global stylesheet.
   ------------------------------------------------------------------ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  /* Brand palette (per the PutMonitor brand book). */
  --navy:      #0B2540;   /* primary brand */
  --navy-2:    #0E2A4A;   /* gradient companion */
  --navy-deep: #081B30;   /* darkest, for sidebar bottom edge */
  --green:     #15A66E;   /* "Verde Prima" — premium / positive accent */
  --green-2:   #34D399;   /* "Verde Señal" — signal / highlight */
  --red:       #E0533D;   /* error / negative */
  --fog:       #F4F7FA;   /* page background */
  --line:      #E3E8EF;   /* hairline borders */
  --muted:     #5C6B7A;   /* secondary text */
  --tint:      #E6F6EF;   /* success tint background (chips) */

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Spacing scale (4px base) */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px;

  /* Radii / shadows */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(11,37,64,.06);
  --shadow-md: 0 4px 12px rgba(11,37,64,.08);
  --shadow-lg: 0 12px 40px rgba(11,37,64,.14);

  /* Layout */
  --sidebar-w: 240px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  background: var(--fog);
  color: var(--navy);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 24px; font-weight: 700; letter-spacing: -.2px; margin: 0 0 4px; }
h2 { font-size: 18px; font-weight: 700; margin: 0 0 8px; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 4px; }
p  { margin: 0 0 12px; }
.mono { font-family: var(--font-mono); }
.muted { color: var(--muted); }


/* ── App shell ─────────────────────────────────────────────────── */
/* Desktop: sidebar fija a la izquierda + main area que ocupa el resto.
   Móvil: la sidebar se transforma en un topbar horizontal compacto.   */

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, var(--navy-2), var(--navy));
  color: #cdd9e5;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
  text-decoration: none;
}
.sidebar-brand img { width: 34px; height: 34px; }
.sidebar-brand .wordmark {
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: .2px;
}
.sidebar-brand .wordmark span { color: var(--green-2); }

/* Hamburger toggle — invisible on desktop, becomes the primary nav
   trigger at ≤768px. Lives inside the sidebar so its position in
   the topbar (right-aligned via margin-left:auto in the foot row)
   stays consistent with the brand. */
.sidebar-toggle {
  display: none;
  background: rgba(255,255,255,.06);
  color: #fff;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: var(--r-sm);
  padding: 6px 8px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: background .12s ease, border-color .12s ease;
}
.sidebar-toggle:hover {
  background: rgba(52,211,153,.16);
  border-color: rgba(52,211,153,.45);
}
.sidebar-toggle svg { display: block; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  color: #aebece;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--r-md);
  text-decoration: none;
}
.sidebar-nav a:hover {
  background: rgba(255,255,255,.05);
  color: #fff;
  text-decoration: none;
}
.sidebar-nav a.active {
  background: rgba(52,211,153,.14);
  color: #fff;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 12px;
  color: #8298ad;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sidebar-foot .user-email { color: #cdd9e5; word-break: break-all; }

/* Sidebar form controls.
   ------------------------------------------------------------------
   The <select> and <button> live inside the navy sidebar, so they
   must keep a dark base AND override the browser's native :hover /
   :focus chrome (without explicit backgrounds, browsers paint white
   on hover and the light text disappears against it). Both `appearance:
   none` calls strip the native chrome so we get a consistent look
   across Chrome / Firefox / Safari. */
.sidebar-foot select,
.sidebar-foot button {
  font: inherit;
  font-weight: 500;
  color: #ffffff;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  transition: background .12s ease, border-color .12s ease;
}
.sidebar-foot select:hover,
.sidebar-foot button:hover {
  background: rgba(52,211,153,.16);   /* green-2 tint, on-brand hover */
  border-color: rgba(52,211,153,.45);
  color: #ffffff;
}
.sidebar-foot select:focus,
.sidebar-foot button:focus {
  outline: 0;
  border-color: var(--green-2);
  box-shadow: 0 0 0 3px rgba(52,211,153,.18);
}

/* The <select> arrow is part of the native chrome we just stripped —
   paint a small chevron SVG via background-image instead. */
.sidebar-foot select {
  padding-right: 28px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none'><path d='M1 1l5 5 5-5' stroke='%23ffffff' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px 7px;
}

/* The dropdown <option> list is rendered by the OS / browser and
   barely respects CSS — but Firefox + recent Chromium honor these,
   so set them anyway. Worst case the native styling kicks in (white
   bg, dark text), which is also legible. */
.sidebar-foot select option {
  background: var(--navy);
  color: #ffffff;
}

.main {
  flex: 1;
  padding: 28px 34px;
  overflow: auto;
}

.page-header {
  display: flex;
  align-items: flex-end;
  margin-bottom: 24px;
  gap: 16px;
}
.page-header .lede { color: var(--muted); font-size: 13px; margin: 0; }


/* ── Cards ──────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}


/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  padding: 11px 18px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .12s ease;
  text-align: center;
}
.btn-primary {
  background: var(--navy);
  color: #fff;
}
.btn-primary:hover { background: var(--navy-2); color: #fff; text-decoration: none; }
.btn-ghost {
  background: transparent;
  color: var(--green);
}
.btn-block { display: block; width: 100%; }


/* ── Forms ──────────────────────────────────────────────────────── */
.form { display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
.form label { font-size: 13px; font-weight: 600; color: var(--navy); }
.form input[type="email"],
.form input[type="text"],
.form input[type="number"] {
  font: inherit;
  padding: 11px 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--navy);
}
.form input:focus {
  outline: 0;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(21,166,110,.15);
}


/* ── Flash messages ─────────────────────────────────────────────── */
.flashes { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-direction: column; gap: 6px; }
.flash {
  padding: 10px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
  border: 1px solid transparent;
}
.flash-info    { background: #EFF4FB; color: #234C82; border-color: #DBE6F4; }
.flash-success { background: var(--tint); color: #0c7a52; border-color: #C9EBD9; }
.flash-error   { background: #FCE6E0; color: #B23A26; border-color: #F5C7BD; }


/* ── Auth pages (login / sent / expired) ────────────────────────── */
/* Auth views render WITHOUT the app shell — they get their own
   centered card layout against a soft navy → fog vertical wash. */

.auth-bg {
  min-height: 100vh;
  background:
    linear-gradient(180deg, var(--navy-2) 0%, var(--navy) 280px, var(--fog) 280px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 20px;
}
.auth-shell {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  font-weight: 700;
  font-size: 22px;
}
.auth-brand img { width: 44px; height: 44px; }
.auth-brand .wordmark span { color: var(--green-2); }

.auth-card {
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
}
.auth-card h1 { font-size: 22px; margin-bottom: 8px; }
.auth-card p  { color: var(--muted); font-size: 14px; }
.auth-card .form { max-width: none; }
.auth-card .form button { margin-top: 8px; }


/* ── Alerts list (#15) ──────────────────────────────────────────── */

.alerts-filters {
  padding: 16px 18px;
  margin-bottom: 16px;
}
.alerts-filters .filter-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}
.filter-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.filter-field > span {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--muted);
}
.filter-field input,
.filter-field select {
  font: inherit;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  color: var(--navy);
  min-width: 0;
}
.filter-field input:focus,
.filter-field select:focus {
  outline: 0;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(21,166,110,.15);
}

.alerts-table-card { padding: 0; overflow: hidden; }

.alerts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.alerts-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
  white-space: nowrap;
}
.alerts-table thead th a {
  color: inherit;
  text-decoration: none;
  display: inline-block;
}
.alerts-table thead th a:hover { color: var(--navy); }
.alerts-table thead th.sorted { color: var(--navy); }
.alerts-table thead th .sort-caret {
  display: inline-block;
  margin-left: 4px;
  font-size: 9px;
  color: var(--green);
}

.alerts-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.alerts-table tbody tr:last-child td { border-bottom: 0; }
.alerts-table .tkr { font-weight: 700; color: var(--navy); }
.alerts-table .mono { font-family: var(--font-mono); }

.alert-row { cursor: pointer; transition: background .08s ease; }
.alert-row:hover  { background: var(--fog); }
.alert-row:focus  { outline: 2px solid var(--green-2); outline-offset: -2px; }

.alerts-table.compact thead th,
.alerts-table.compact tbody td { padding: 10px 12px; }

/* Outcome chips */
.chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: .3px;
  white-space: nowrap;
}
.chip-lg { font-size: 13px; padding: 7px 14px; }
.c-win     { background: var(--tint); color: #0c7a52; }
.c-loss    { background: #FCE6E0;     color: #B23A26; }
.c-open    { background: #E7EDF4;     color: #22507E; }
.c-neutral { background: #F4F7FA;     color: var(--muted); }
/* "Operada" — distinct from Pending (blue) and Win (green) so the
   user can tell at a glance which alerts are already in flight. */
.c-traded  { background: #FFF6DD;     color: #8A5A00; }
.pos { color: var(--green); font-weight: 600; }
.neg { color: var(--red);   font-weight: 600; }

/* §9c move-attribution chips — broad causes read calm (blue/teal), the
   name-specific ones read as caution (amber/red). */
.chip.move-market_wide   { background: #E7EDF4; color: #22507E; }
.chip.move-sector_wide   { background: #E3F0F0; color: #1F6B6B; }
.chip.move-idiosyncratic { background: #FBE8D5; color: #9A5B1A; }
.chip.move-earnings      { background: #FFF6DD; color: #8A5A00; }
.chip.move-offering      { background: #FCE6E0; color: #B23A26; }
.chip.move-unknown       { background: #F4F7FA; color: var(--muted); }
.move-why-line { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0; }
.move-why-nums { font-size: 13px; }
.move-why-note { margin: 10px 0 0; }
/* §9c LLM one-liner — a readable sentence, with a muted "from headlines" tag */
.move-llm { margin: 10px 0 0; font-size: 13.5px; line-height: 1.5; max-width: 68ch; }
.move-llm-label { display: block; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 2px; }

.paginator {
  display: flex;
  align-items: center;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: #fbfcfd;
  font-size: 13px;
}
.paginator-stats { color: var(--muted); margin-right: auto; }
.paginator-buttons { display: flex; gap: 8px; }
.paginator .btn { padding: 6px 14px; font-size: 13px; }
.paginator-summary {
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: #fbfcfd;
  color: var(--muted);
  font-size: 13px;
}

.alerts-empty {
  padding: 64px 18px;
  text-align: center;
  color: var(--muted);
}

/* ── Alert detail (#15) ─────────────────────────────────────────── */

.detail-header { align-items: flex-start; }
.detail-header .tkr  { color: var(--green); }
.detail-outcome      { margin-left: auto; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.kpi {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.kpi .k {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 8px;
}
.kpi .v {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-mono);
}
.kpi .v.green { color: var(--green); }

.detail-card { margin-bottom: 18px; }
.detail-card h2 { margin-bottom: 14px; }

/* §9a company context */
.company-context .company-sector { margin: 0 0 12px; font-size: 14px; color: var(--navy); }
.company-context .company-sector .sep { color: var(--muted); margin: 0 7px; }

/* Two columns on desktop: overview (left, capped to a readable measure)
   and the news rail (right). The left column caps the summary width, so
   the paragraph itself no longer needs its own max-width. */
.company-context .company-body {
  display: grid;
  grid-template-columns: minmax(0, 65ch) minmax(220px, 1fr);
  gap: 28px;
  margin-bottom: 18px;
}
.company-context .business-summary {
  line-height: 1.55;
  font-size: 13.5px;
  margin: 0;
}
/* §9b news rail — top-3 headlines (lazy) + the outbound Yahoo link. */
.company-context .company-news {
  border-left: 1px solid var(--line);
  padding-left: 24px;
}
/* no summary beside it → single column, drop the divider */
.company-context .company-body--solo { grid-template-columns: 1fr; }
.company-context .company-body--solo .company-news { border-left: 0; padding-left: 0; }
.company-context .company-news-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  margin: 0 0 10px;
}
.company-context .news-list { list-style: none; margin: 0 0 12px; padding: 0; }
.company-context .news-item { margin-bottom: 12px; }
.company-context .news-headline {
  display: block;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}
.company-context .news-meta { display: block; margin-top: 2px; }
.company-context .news-link { font-size: 13.5px; font-weight: 600; }

/* the key-stats strip is denser than the headline KPIs above it */
.company-context .stat-strip { margin-bottom: 0; }
.company-context .stat-strip .v { font-size: 18px; }

@media (max-width: 768px) {
  /* stack: summary, then the news rail below it (border on top, not side) */
  .company-context .company-body { grid-template-columns: 1fr; gap: 16px; }
  .company-context .company-news {
    border-left: 0;
    padding-left: 0;
    border-top: 1px solid var(--line);
    padding-top: 14px;
  }
}

.detail-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 24px;
  margin: 0;
  font-size: 13px;
}
.detail-grid dt {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .3px;
}
.detail-grid dd {
  margin: 0;
  font-family: var(--font-mono);
  color: var(--navy);
}

/* Confirm-opened form on alert detail (#11). Two-column grid for
   the small numeric inputs (Contracts, Premium) on desktop; stacks
   on mobile via the existing media query. */
.confirm-position-form { max-width: none; }
.confirm-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 8px;
}
.confirm-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  max-width: none;
}
.confirm-field > span {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .3px;
  color: var(--muted);
  text-transform: uppercase;
}
.confirm-field input[type="number"],
.confirm-field input[type="text"] {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
  color: var(--navy);
  font-family: var(--font-mono);
}
.confirm-field input:focus {
  outline: 0;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(21,166,110,.15);
}

.position-state {
  border-left: 3px solid var(--green);
}

/* Feedback card (#7) — sits on alert detail + as standalone form for
   the email magic-link landing. */
.feedback-card { border-left: 3px solid var(--green-2); }
.feedback-inline-form { max-width: none; }

.feedback-status,
.feedback-reasons {
  border: 0;
  padding: 0;
  margin: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.feedback-status { flex-direction: row; flex-wrap: wrap; gap: 10px; }
.feedback-status legend,
.feedback-reasons legend {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .3px;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 4px;
  padding: 0;
}

/* Status radios styled as pill toggles. */
.feedback-status-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  transition: border-color .12s, background .12s;
}
.feedback-status-option:hover { border-color: var(--green); }
.feedback-status-option input[type="radio"] { margin: 0; accent-color: var(--green); }
.feedback-status-option:has(input:checked) {
  background: var(--tint);
  border-color: var(--green);
  color: #0c7a52;
}

/* Reasons checkboxes — stacked, low-key. */
.feedback-reason {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 14px;
  color: var(--navy);
  cursor: pointer;
}
.feedback-reason input[type="checkbox"] { accent-color: var(--green); }

/* Free-text note styling, reused from form patterns. */
.feedback-inline-form textarea,
.form textarea {
  font: inherit;
  font-family: var(--font-sans);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
  color: var(--navy);
  width: 100%;
  resize: vertical;
}
.feedback-inline-form textarea:focus,
.form textarea:focus {
  outline: 0;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(21,166,110,.15);
}

/* "Current price" card on the detail page — two-up grid with the
   live spot and the distance to strike. */
.spot-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 8px;
}
.spot-grid .k {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 6px;
}
.spot-grid .v {
  font-size: 22px;
  font-weight: 700;
}
.small { font-size: 12px; }

/* ── Metrics dashboard (#16) ───────────────────────────────────── */

/* Two-column row of cards. Collapses to single column on mobile via
   the existing media query. */
.metrics-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}
.metric-card { margin-bottom: 0; }  /* metrics-row already adds margin */
.metric-card h2 { font-size: 15px; margin-bottom: 2px; }
.metric-card .csub { font-size: 12px; margin: 0 0 14px; }

.metrics-kpis .trend {
  font-size: 11px;
  margin-top: 6px;
  letter-spacing: .3px;
}
.metrics-kpis .kpi .v.neg { color: var(--red); }
.metrics-kpis .kpi .v small { font-size: 14px; font-weight: 600; }

.chart { display: block; }
.chart-legend { margin-top: 6px; }

.empty-state {
  padding: 28px 0;
  text-align: center;
}

/* Donut + legend layout (one row on desktop, stack on mobile). */
.donut-wrap {
  display: flex;
  align-items: center;
  gap: 22px;
}
.donut-legend {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 13px;
  flex: 1;
}
.donut-legend li {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--line);
}
.donut-legend li:last-child { border-bottom: 0; }
.donut-legend .sw {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: block;
}
.donut-legend .lg-label { color: var(--navy); }
.donut-legend .lg-val { color: var(--muted); }

/* Bar list — used for "Win rate by DTE" and "Win rate by source". */
.bar-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.bar-list li {
  display: grid;
  grid-template-columns: 80px 1fr 44px auto;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}
.bar-list li:last-child { border-bottom: 0; }
.bar-label { font-size: 13px; font-weight: 600; color: var(--navy); }
.bar-track {
  height: 8px;
  background: var(--fog);
  border-radius: 8px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--green-2));
  border-radius: 8px;
  transition: width .2s ease;
}
.bar-value { font-size: 13px; text-align: right; }
.bar-context { white-space: nowrap; }

/* ── Settings: /settings/capital (#9) ──────────────────────────── */

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.settings-card { margin-bottom: 0; }
.settings-card h2 { font-size: 15px; margin-bottom: 2px; }
.settings-card .csub { font-size: 12px; margin: 0 0 14px; }

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  max-width: 320px;
}
.settings-field .field-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .3px;
  color: var(--muted);
  text-transform: uppercase;
}

.amount-input {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
  overflow: hidden;
}
.amount-input:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(21,166,110,.15);
}
.amount-input .amount-prefix {
  background: var(--fog);
  padding: 11px 14px;
  font-family: var(--font-mono);
  color: var(--muted);
  border-right: 1px solid var(--line);
}
.amount-input input {
  border: 0;
  outline: 0;
  padding: 11px 12px;
  flex: 1;
  font: inherit;
  font-family: var(--font-mono);
  color: var(--navy);
  background: transparent;
}

.settings-note {
  background: var(--fog);
  border-left: 3px solid var(--green-2);
  padding: 10px 14px;
  border-radius: var(--r-sm);
  line-height: 1.55;
  margin-top: 10px;
}

/* Slider + numeric input synced via inline onchange handlers in the
   template. The CSS just makes both feel like one control. */
.pct-control {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 520px;
}
.pct-control input[type="range"] {
  flex: 1;
  /* Vendor-prefixed track + thumb for cross-browser look. */
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: linear-gradient(90deg, var(--green) 0%, var(--green-2) 100%);
  border-radius: 4px;
  outline: none;
}
.pct-control input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--navy);
  border: 2px solid #fff;
  box-shadow: 0 2px 4px rgba(11,37,64,.25);
  cursor: pointer;
}
.pct-control input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--navy);
  border: 2px solid #fff;
  box-shadow: 0 2px 4px rgba(11,37,64,.25);
  cursor: pointer;
}
.pct-number-wrap {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
}
.pct-number-wrap:focus-within {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(21,166,110,.15);
}
.pct-number-wrap input {
  width: 70px;
  border: 0;
  outline: 0;
  padding: 9px 4px 9px 12px;
  font: inherit;
  font-family: var(--font-mono);
  text-align: right;
  background: transparent;
  color: var(--navy);
}
.pct-number-wrap .pct-suffix {
  color: var(--muted);
  font-family: var(--font-mono);
  padding-right: 10px;
}

.pct-readout-line {
  margin-top: 10px;
  margin-bottom: 16px;
}
.pct-readout {
  font-size: 18px;
  color: var(--green);
  font-weight: 700;
}

/* Profile reference table — informational, not interactive. */
.profile-table {
  width: 100%;
  max-width: 400px;
  border-collapse: collapse;
  font-size: 13px;
  margin-bottom: 12px;
}
.profile-table thead th {
  text-align: left;
  padding: 8px 12px;
  background: var(--fog);
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}
.profile-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
}
.profile-table tbody tr:last-child td { border-bottom: 0; }

.settings-explainer p {
  margin-bottom: 8px;
  color: var(--navy);
}
.settings-explainer p:last-child { margin-bottom: 0; }

.settings-actions {
  display: flex;
  justify-content: flex-end;
}

/* Settings index — card grid of sub-sections. */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.settings-tile {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 18px 20px;
  transition: border-color .12s ease, transform .08s ease;
}
.settings-tile:hover {
  border-color: var(--green);
  text-decoration: none;
  transform: translateY(-1px);
}
.settings-tile h2 { font-size: 15px; margin-bottom: 6px; }
.settings-tile p  { font-size: 13px; margin: 0; }
.settings-tile-disabled { opacity: 0.6; cursor: default; }
.settings-tile-disabled:hover { border-color: var(--line); transform: none; }

/* Push notifications status card (#6). Each state surfaces a
   distinct visual cue so the user knows where they stand at a glance. */
.push-state { padding: 10px 14px; border-radius: var(--r-md); border: 1px solid var(--line); }
.push-state-detecting   { background: #FBFCFD; }
.push-state-enabled     { background: var(--tint);  color: #0C7A52; border-color: #C9EBD9; }
.push-state-disabled    { background: #EFF4FB;      color: #234C82; border-color: #DBE6F4; }
.push-state-denied      { background: #FCE6E0;      color: #B23A26; border-color: #F5C7BD; }
.push-state-unsupported { background: var(--fog);   color: var(--muted); }
.push-state p { margin: 0; }

/* ── Positions cockpit (§2 live table + §7 risk band) ───────────── */

/* Assignment-risk band chips (mirror the outcome-chip colour families). */
.band-ok      { background: var(--tint); color: #0c7a52; }
.band-near    { background: #FFF1D6;     color: #8A5A00; }
.band-itm     { background: #FCE6E0;     color: #B23A26; }
.band-unknown { background: #F4F7FA;     color: var(--muted); }

/* §8 events box */
.events-card { margin-bottom: 18px; }
.events-list { list-style: none; margin: 0; padding: 0; }
.events-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}
.events-item:first-child { border-top: 0; }
.events-name { font-weight: 600; font-size: 13px; }
.events-when { margin-left: auto; }
/* per-kind chips (panel) + the same palette for the per-row flag */
.event-fomc     { background: #ECE7F6; color: #5B3FA6; }
.event-cpi      { background: #E7EDF4; color: #22507E; }
.event-nfp      { background: #E3F0F0; color: #1F6B6B; }
.event-earnings { background: #FFF6DD; color: #8A5A00; }
.event-peer     { background: #F4F7FA; color: var(--muted); }
/* compact per-row "nota destacada" flag */
.event-flag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 20px;
  white-space: nowrap;
  letter-spacing: .2px;
}
.pos-card-event { margin-top: 6px; }

/* Distance-% text colour, keyed by the same band. */
.band-text-ok      { color: #0c7a52; font-weight: 600; }
.band-text-near    { color: #8A5A00; font-weight: 600; }
.band-text-itm     { color: #B23A26; font-weight: 700; }
.band-text-unknown { color: var(--muted); }

/* The "en riesgo" KPI pair — amber so the risk headline stands out. */
.kpi-risk {
  background: #FFFBF0;
  border-color: #F2DFAE;
}
.kpi-risk .v { color: #8A5A00; }

.snap-fresh { margin: -8px 0 14px; }

/* Wide open-positions table: tighter padding to fit ~13 columns; scrolls
   horizontally on narrower desktops. Hidden on phones (cards take over). */
.pos-table-wrap { display: block; overflow-x: auto; }
.pos-table thead th,
.pos-table tbody td { padding: 11px 12px; white-space: nowrap; }

/* Phone card list — hidden on desktop, shown ≤768px. */
.pos-cards { display: none; }
.pos-card {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: #fff;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
}
.pos-card:hover { border-color: var(--green); text-decoration: none; }
.pos-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.pos-card-tkr { font-weight: 700; color: var(--navy); font-size: 15px; }
.pos-card-tkr .muted { font-weight: 500; font-family: var(--font-mono); font-size: 13px; }
.pos-card-sub { font-size: 12px; margin-top: 4px; }
.pos-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  margin-top: 12px;
}
.pos-card-cell { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pos-card-cell .cl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
}
.pos-card-cell .cv { font-size: 15px; font-weight: 600; font-family: var(--font-mono); }
.pos-card-hint {
  margin-top: 10px;
  font-size: 12px;
  color: #0c7a52;
  background: var(--tint);
  border-radius: var(--r-sm);
  padding: 6px 10px;
}

.live-card h2 { font-size: 15px; }

/* Concentration breakdown (§6) — three bar lists side by side. */
.conc-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
  margin-top: 12px;
}
.conc-col h3 { font-size: 13px; margin-bottom: 8px; color: var(--navy); }
.conc-list { list-style: none; padding: 0; margin: 0; }
.conc-list li {
  display: grid;
  grid-template-columns: 92px 1fr 34px;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
}
.conc-label {
  font-size: 12px;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conc-bar {
  height: 7px;
  background: var(--fog);
  border-radius: 6px;
  overflow: hidden;
}
.conc-fill {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--navy), var(--green));
  border-radius: 6px;
}
.conc-pct { font-size: 12px; text-align: right; color: var(--muted); }

/* Assigned-share holdings (§4) — equity ledger summary + inline sell. */
.holdings-summary {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
  font-size: 13px;
  color: var(--muted);
}
.holdings-summary strong { color: var(--navy); }
.sell-form { display: flex; align-items: center; gap: 8px; }
.sell-input { width: 108px; flex: 0 0 auto; }
.btn-sell { padding: 7px 12px; font-size: 13px; white-space: nowrap; }

/* Account view (§1) — premiums ledger + equity ledger + the real total. */
.account-card { margin-bottom: 18px; }
.account-grid { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 28px; }
.acc-item { display: flex; flex-direction: column; gap: 3px; }
.acc-k {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
}
.acc-v { font-size: 18px; font-weight: 700; font-family: var(--font-mono); }
.acc-total {
  margin-left: auto;
  padding-left: 24px;
  border-left: 1px solid var(--line);
}
.acc-total .acc-v { font-size: 23px; }

/* §5 dual-currency: converted primary stacked over the native USD. The
   primary inherits its container's size/colour; the USD line is small. */
.dual { display: inline-flex; flex-direction: column; line-height: 1.15; }
.dual .m2 { font-size: 11px; font-weight: 400; margin-top: 1px; }
.currency-form { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.currency-form select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; }

/* Dismiss-reasons list (signal-quality panel on /metrics). */
.reason-list { list-style: none; padding: 0; margin: 0; }
.reason-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
}
.reason-list li:last-child { border-bottom: 0; }


/* ── Mobile: collapse sidebar into a topbar ─────────────────────── */
@media (max-width: 768px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    /* Replace vertical gradient with the navy header tone alone. */
    background: var(--navy);
  }
  .sidebar-brand { margin-bottom: 0; }
  .sidebar-brand img { width: 28px; height: 28px; }
  .sidebar-brand .wordmark { font-size: 15px; }

  /* Hamburger visible only on mobile; sits to the left of the
     language+logout cluster. */
  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    margin-left: auto;
  }

  /* Nav links hidden at rest; pop as a dropdown drawer when
     <body> has the .nav-open class (toggled by the hamburger). */
  .sidebar-nav { display: none; }
  body.nav-open .sidebar-nav {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 52px;            /* below the topbar (≈ 52px tall) */
    left: 0; right: 0;
    background: var(--navy);
    padding: 12px 16px 16px;
    gap: 2px;
    z-index: 100;
    box-shadow: 0 12px 24px rgba(0,0,0,.35);
    border-top: 1px solid rgba(255,255,255,.08);
  }
  body.nav-open .sidebar-nav a {
    padding: 13px 14px;   /* fatter tap target on mobile */
    font-size: 15px;
  }
  /* Backdrop — a real <div> in the markup so it can capture
     tap-to-close. Hidden at rest; shown only when nav-open. */
  .nav-backdrop {
    display: none;
  }
  body.nav-open .nav-backdrop {
    display: block;
    position: fixed;
    inset: 52px 0 0 0;       /* below the topbar */
    background: rgba(11,37,64,.40);
    backdrop-filter: blur(2px);
    z-index: 99;
  }
  body.nav-open { overflow: hidden; }

  .sidebar-foot {
    margin-top: 0;
    margin-left: 0;        /* hamburger already pushed us right */
    padding-top: 0;
    border-top: 0;
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  .sidebar-foot .user-email { display: none; }
  .sidebar-foot select,
  .sidebar-foot button { padding: 4px 8px; font-size: 12px; }

  .main { padding: 18px 16px; }

  /* Tables: let them scroll horizontally rather than crush columns. */
  .alerts-table-card { overflow-x: auto; }
  .alerts-table { min-width: 720px; }

  /* KPI grid: stack tighter on mobile. */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi .v { font-size: 18px; }

  /* Detail grid: stack dt/dd vertically so long values don't overflow. */
  .detail-grid { grid-template-columns: 1fr; gap: 2px 0; }
  .detail-grid dt { margin-top: 10px; }

  /* Metrics: stack everything single-column. */
  .metrics-row { grid-template-columns: 1fr; }
  .donut-wrap { flex-direction: column; align-items: flex-start; }
  .bar-list li {
    grid-template-columns: 60px 1fr 44px;
  }
  .bar-context { display: none; }   /* hide the "(2/3 resolved · 5 total)" hint */

  /* Capital settings: stack the slider + number on small screens. */
  .pct-control { flex-direction: column; align-items: stretch; gap: 12px; }
  .pct-number-wrap { align-self: flex-start; }

  /* Confirm-opened form: stack the contracts + premium pair. */
  .confirm-row { grid-template-columns: 1fr; }

  /* Positions cockpit: the 13-col open table can't render at ~380px —
     hide it and show one card per position instead. KPIs fall to the
     2-col grid from the .kpi-grid rule above (6 → 2×3). */
  .pos-table-wrap { display: none; }
  .pos-cards { display: flex; flex-direction: column; gap: 10px; padding: 12px; }

  /* Concentration: stack the three groupings vertically. */
  .conc-grid { grid-template-columns: 1fr; gap: 18px; }

  /* Account view: let the total flow inline instead of pinning right. */
  .account-grid { gap: 12px 20px; }
  .acc-total { margin-left: 0; padding-left: 0; border-left: 0; }
}
