/* ========================================================================
   RMS design system (2026-08-20 v5 — soft pastel business)
   Goal: airy near-white base (barely-tinted) + a single refined lavender brand
   + pastel accent palette (lavender/blue/green/amber/rose) used sparingly
   on highlights only. Business-grade but not stiff — Stripe / Linear vibe.
   Stock convention preserved: red = up, green = down (CN).
   ======================================================================== */
:root {
  /* === base — barely-tinted off-whites, almost imperceptible gradient === */
  --bg: #FBFAFD;             /* near-white with a hint of cool */
  --bg-2: #F4F6FB;           /* very pale cool gray-blue (subtle bottom) */
  --bg-tint: #F7F9FC;
  --bg-tint-2: #F1F3F8;

  /* surfaces */
  --surface: #ffffff;
  --surface-2: #FAFBFC;
  --sidebar-bg: #ffffff;

  /* ink — softer than pure black, more sophisticated */
  --ink: #1A1F2E;
  --ink-2: #3D4456;
  --ink-3: #5B6276;
  --muted: #71798C;   /* 2026-08-21: darkened from #8B92A8 — light text was too faint, keep hierarchy vs ink-3 */
  --muted-2: #9BA2B4; /* darkened from #B1B7C8 to match */

  /* lines & shadows — almost invisible */
  --line: #ECEEF2;
  --line-2: #E1E4EB;
  --shadow-xs: 0 1px 2px rgba(20, 24, 40, 0.03);
  --shadow-sm: 0 2px 8px rgba(20, 24, 40, 0.04);
  --shadow-md: 0 6px 20px rgba(20, 24, 40, 0.05);
  --shadow-lg: 0 12px 40px rgba(20, 24, 40, 0.06);

  /* === brand — soft steel blue (derived from screenshot Misty/Ice Blue palette) === */
  --brand: #4A6B91;            /* deep steel blue — primary action, active states (white-text safe) */
  --brand-2: #3A5775;           /* deeper — hover/pressed */
  --brand-soft: rgba(74, 107, 145, 0.10);
  --brand-soft-2: rgba(74, 107, 145, 0.16);
  --brand-tint: #DBEBF2;        /* Ice Blue (screenshot color) — active backgrounds */

  /* === pastel accent palette (used sparingly as highlights) === */
  /* lavender */
  --lavender: #C4B5FD;
  --lavender-bg: #EDE9FE;
  --lavender-ink: #6D28D9;

  /* sky blue */
  --sky: #93C5FD;
  --sky-bg: #DBEAFE;
  --sky-ink: #2563EB;

  /* mint green */
  --mint: #86EFAC;
  --mint-bg: #DCFCE7;
  --mint-ink: #16A34A;

  /* amber */
  --amber: #FCD34D;
  --amber-bg: #FEF3C7;
  --amber-ink: #B45309;

  /* rose */
  --rose: #FDA4AF;
  --rose-bg: #FCE7E7;
  --rose-ink: #E11D48;

  /* === stock convention (CN): red=up, green=down === */
  --up: #DC2626;
  --down: #16A34A;
  --pos: #DC2626;
  --neg: #16A34A;
  --neu: #8B92A8;

  /* status */
  --warn: #B45309;
  --warn-bg: #FEF3C7;
  --danger: #DC2626;
  --danger-bg: #FCE7E7;
  --ok: #16A34A;
  --ok-bg: #DCFCE7;

  /* radii */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-2xl: 24px;
  --r-pill: 999px;

  /* typography */
  --font-display: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Display",
    "Segoe UI", "PingFang SC", "Hiragino Sans GB", Roboto, sans-serif;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter",
    "PingFang SC", "Hiragino Sans GB", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --sidebar-w: 240px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  color: var(--ink);
  font: 14.5px/1.6 var(--font);
  letter-spacing: -0.005em;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; transition: color .15s; }
a:hover { color: var(--brand); }
h1, h2, h3, h4 { font-family: var(--font-display); letter-spacing: -0.02em; color: var(--ink); margin: 0; font-weight: 700; }
.boot { padding: 40px; text-align: center; color: var(--muted); }

/* ====================================================================
   shell — desktop layout (sidebar + main, refined business)
   ==================================================================== */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 20px;
  max-width: 1440px;
  margin: 20px auto;
  padding: 0 24px 32px;
}

.sidebar {
  position: sticky;
  top: 20px;
  align-self: start;
  background: var(--sidebar-bg);
  border: 1px solid var(--line);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-xs);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: calc(100vh - 40px);
  max-height: calc(100vh - 40px);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 14px; margin-bottom: 4px;
}
.brand-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: block;
  box-shadow: 0 2px 8px rgba(74, 107, 145, 0.18);
}
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: -0.01em; color: var(--ink); }
.brand-caret { margin-left: auto; color: var(--muted); font-size: 12px; }

.sidenav-search {
  position: relative;
  margin: 6px 0 12px;
}
.sidenav-search input {
  width: 100%; padding: 8px 12px 8px 32px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-md); font-size: 12.5px; color: var(--ink);
}
.sidenav-search input:focus { background: var(--surface); border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.sidenav-search .kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 10px; color: var(--muted); background: var(--surface);
  border: 1px solid var(--line); padding: 1px 5px; border-radius: 4px;
}
.sidenav-search .ico {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 12px;
}

.sidenav { display: flex; flex-direction: column; gap: 1px; }
.sidenav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--r-md);
  color: var(--ink-2); font-size: 13.5px; font-weight: 500;
  transition: background .15s, color .15s;
}
.sidenav a:hover { background: var(--bg-tint); color: var(--ink); }
.sidenav a.active { background: var(--brand-tint); color: var(--brand-2); font-weight: 600; }
.sidenav a .ico {
  width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; opacity: .75;
  color: var(--ink-3);
}
.sidenav a:hover .ico { opacity: 1; }
.sidenav a.active .ico { opacity: 1; color: var(--brand); }
.sidenav a .ico svg, .nav-ico svg { display: block; width: 16px; height: 16px; }

.sidebar-section {
  margin: 16px 0 4px; padding: 0 12px;
  font-size: 10px; font-weight: 700; color: var(--muted);
  letter-spacing: .08em; text-transform: uppercase;
}

.sidebar-foot {
  margin-top: auto;
  padding: 14px 8px 4px;
  border-top: 1px solid var(--line);
}
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-md);
  transition: background .15s;
}
.user-card:hover { background: var(--bg-tint); }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #fde68a 0%, #fca5a5 100%);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--ink); font-size: 13px;
  flex-shrink: 0;
}
.user-info { line-height: 1.25; min-width: 0; }
.user-name { font-weight: 600; font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--muted); }
.user-card .menu-ico { margin-left: auto; color: var(--muted); font-size: 14px; }

.main-area { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

.main-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 6px 6px 2px;
}
.main-header h1 {
  font-family: var(--font-display);
  font-size: 26px; font-weight: 700; letter-spacing: -0.02em;
  color: var(--ink);
}
.title-group { display: inline-flex; align-items: center; gap: 0; min-width: 0; }
.title-count {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 700; color: var(--brand);
  background: var(--brand-tint);
  padding: 2px 10px; border-radius: var(--r-pill);
  margin-left: 10px; letter-spacing: 0;
  line-height: 1.4; min-width: 22px; text-align: center;
}
.main-header .reload {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--r-pill);
  background: transparent; color: var(--brand); border: 1px solid var(--brand-soft);
  font-size: 12.5px; font-weight: 600; cursor: pointer;
  position: relative;
}
.main-header .reload:hover { background: var(--brand-soft); }
.main-header .logout-btn {
  color: var(--ink-3); border-color: var(--line);
  background: transparent; font-family: inherit;
}
.main-header .logout-btn:hover { background: #FCE7E7; color: var(--danger); border-color: rgba(220, 38, 38, 0.18); }
.bell-dot { position: absolute; top: -3px; right: -3px; min-width: 16px; height: 16px;
  background: var(--brand); color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 999px; padding: 0 5px; display: inline-flex; align-items: center; justify-content: center;
}

.main-body {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-xs);
  padding: 24px;
}

/* ====================================================================
   generic
   ==================================================================== */
.grid { display: grid; gap: 16px; }
@media (min-width: 860px) {
  .grid.cols-2 { grid-template-columns: 1fr 1fr; }
  .grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
  .grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xs);
  padding: 20px;
  transition: box-shadow .15s;
}
.card:hover { box-shadow: var(--shadow-sm); }
.card h3 {
  margin: 0 0 14px; font-size: 15px; font-weight: 600;
  letter-spacing: -0.01em; color: var(--ink);
  display: flex; align-items: center; justify-content: space-between;
}
.card h3 .right-ico { color: var(--muted); font-size: 14px; }

.card-tabs {
  display: flex; gap: 20px; border-bottom: 1px solid var(--line);
  margin: -4px 0 16px;
}
.card-tabs .tab {
  background: none; border: 0; padding: 8px 0;
  font: inherit; font-weight: 500; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.card-tabs .tab.active { color: var(--ink); border-bottom-color: var(--brand); font-weight: 600; }

.stat { font-family: var(--font-display); font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.empty { color: var(--muted); padding: 24px; text-align: center; font-size: 13px; }

/* ====================================================================
   tables
   ==================================================================== */
.tablewrap { overflow-x: auto; margin: -2px; }
.tablewrap table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.tablewrap th, .tablewrap td {
  padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left;
}
.tablewrap th {
  background: var(--surface-2);
  font-weight: 600; font-size: 12px; color: var(--muted);
  letter-spacing: .02em;
}
.tablewrap tbody tr:hover { background: var(--bg-tint); }
.tablewrap .num-col { text-align: right; font-variant-numeric: tabular-nums; }
.tablewrap .small { color: var(--muted); font-size: 11.5px; }
.tablewrap a { color: var(--ink-2); font-weight: 500; }
.tablewrap a:hover { color: var(--brand); }

/* ====================================================================
   badges / chips — pastel palette
   ==================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: var(--r-pill);
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 11.5px; font-weight: 600; color: var(--ink-2);
  white-space: nowrap;
}
.badge.brand     { background: var(--brand-tint); color: var(--brand-2); border-color: transparent; }
.badge.lavender  { background: var(--lavender-bg); color: var(--lavender-ink); border-color: transparent; }
.badge.sky       { background: var(--sky-bg); color: var(--sky-ink); border-color: transparent; }
.badge.mint      { background: var(--mint-bg); color: var(--mint-ink); border-color: transparent; }
.badge.amber     { background: var(--amber-bg); color: var(--amber-ink); border-color: transparent; }
.badge.rose      { background: var(--rose-bg); color: var(--rose-ink); border-color: transparent; }
.badge.ok        { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.warn      { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.danger    { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.badge.escalated { background: linear-gradient(135deg, #fb923c 0%, #ef4444 100%); color: #fff; border: 0; }
.badge.sample    { background: linear-gradient(135deg, var(--lavender) 0%, var(--sky) 100%); color: var(--ink); border: 0; }

/* ====================================================================
   forms / inputs / buttons
   ==================================================================== */
button, .btn {
  font: inherit; font-size: 13px; font-weight: 500;
  padding: 8px 14px; border-radius: var(--r-pill);
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  cursor: pointer; transition: background .15s, transform .1s, border-color .15s;
}
button:hover, .btn:hover { background: var(--bg-tint); border-color: var(--brand-soft); }
button:active, .btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--brand); color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(74, 107, 145, 0.22);
}
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { background: var(--danger); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--bg-tint); color: var(--ink); }

input, select, textarea {
  font: inherit; color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-2); border-radius: var(--r-md);
  padding: 10px 14px; outline: none; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
label { font-size: 12px; font-weight: 600; color: var(--ink-2); display: block; margin: 8px 0 4px; }

/* ====================================================================
   text-color helpers (stock up/down — CN convention)
   ==================================================================== */
.num { font-variant-numeric: tabular-nums; font-weight: 600; }
.num.pos { color: var(--pos); }
.num.neg { color: var(--neg); }
.num.neu { color: var(--neu); }

/* ====================================================================
   mobile shell
   ==================================================================== */
@media (max-width: 859px) {
  /* prevent horizontal page scroll from wide tables / charts */
  html, body { overflow-x: hidden; }
  .app-layout { grid-template-columns: 1fr; margin: 8px; padding: 0 0 96px; gap: 0; max-width: none; }
  .sidebar { display: none; }
  .main-area { gap: 10px; }
  .main-body { border-radius: var(--r-lg); padding: 14px 12px; overflow: hidden; min-width: 0; }
  .main-header { padding: 2px 2px 0; gap: 10px; flex-wrap: wrap; }
  .main-header h1 { font-size: 19px; }

  /* cards: clip overflow + tighten */
  .card { padding: 12px; border-radius: var(--r-md); min-width: 0; overflow: hidden; }

  /* tables: smooth horizontal scroll inside cards */
  .tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0; }
  .tablewrap table { font-size: 12.5px; min-width: 560px; }
  .tablewrap th, .tablewrap td { padding: 7px 8px; white-space: nowrap; }
  .tablewrap td.small, .tablewrap .small { font-size: 11px; }

  /* action rows: allow wrapping */
  .page-actions-row { flex-wrap: wrap; gap: 8px; }
  .page-actions-row .btn, .page-actions-row select, .page-actions-row input { max-width: 100%; }
  .row { flex-wrap: wrap; }

  /* two-col grids collapse to one */
  .grid.cols-2 { grid-template-columns: 1fr; }
  .grid { gap: 10px; }

  /* summary stat cards: 2 per row on phones */
  .summary-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
  .summary-card { padding: 10px 12px; }
  .summary-value { font-size: 20px; }

  /* filters stack */
  .filtergrid { grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px; }
  .filtergrid input, .filtergrid select { min-width: 0; }

  /* news type / impact / cta button groups wrap */
  .seg { flex-wrap: wrap; }
  .seg button { flex: 0 1 auto; }
  .chips { flex-wrap: wrap; }

  /* charts fit width */
  #stock-chart canvas { max-width: 100%; height: auto; }

  /* notification cards: stack Open button below on very narrow screens */
  .notif-item .row { flex-wrap: nowrap; }
  .notif-open-btn { padding: 5px 14px !important; font-size: 12px; }

  /* logout in header: icon only on phones */
  .logout-label { display: none; }
  .main-header .logout-btn { padding: 6px 9px; }

  /* forms: full width inputs */
  .filter-bar { flex-wrap: wrap; gap: 6px; }
  .filter-bar input, .filter-bar select { min-width: 0; flex: 1 1 120px; }

  /* headings tighten */
  .card h3 { font-size: 13px; }
  .mt16 { margin-top: 12px; } .mt24 { margin-top: 14px; }

  .bottomnav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex;
    background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -4px 16px rgba(20, 24, 40, 0.04);
  }
  .bottomnav a { flex: 1; text-align: center; padding: 8px 1px; font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; min-width: 0; }
  .bottomnav a.active { color: var(--brand); font-weight: 600; }
  .bottomnav a span { display: block; font-size: 16px; margin-bottom: 1px; }
  .bottomnav a .nav-ico svg { width: 18px; height: 18px; }
}
@media (min-width: 860px) { .bottomnav { display: none; } }

/* ====================================================================
   chart canvas
   ==================================================================== */
#stock-chart canvas { display: block; border-radius: var(--r-md); }

/* ====================================================================
   Toasts
   ==================================================================== */
#toast-stack { position: fixed; right: 16px; top: 16px; z-index: 999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
#toast-stack > div {
  background: var(--ink); color: #fff; padding: 10px 14px; border-radius: var(--r-md);
  box-shadow: var(--shadow-md); font-size: 13px; max-width: 340px; pointer-events: auto;
}

/* ====================================================================
   misc utilities
   ==================================================================== */
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.mb8 { margin-bottom: 8px; } .mb16 { margin-bottom: 16px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
a.btn { display: inline-flex; align-items: center; gap: 6px; }

/* ====================================================================
   Inbox news cards — each item in its own light framed card
   ==================================================================== */
.newscard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  margin-bottom: 12px;
  transition: box-shadow .15s, border-color .15s;
}
.newscard:hover { box-shadow: var(--shadow-sm); border-color: var(--brand-soft-2); }
.newscard .hl { font-size: 15px; font-weight: 600; margin: 8px 0; line-height: 1.45; }
.newscard .hl a { color: var(--ink); }
.newscard .hl a:hover { color: var(--brand); }
.newscard .meta { font-size: 12px; color: var(--muted); }
.source-links { margin-top: 4px; }
.source-links .src-link {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: var(--r-pill);
  background: var(--bg-tint); color: var(--ink-2); margin-right: 4px; margin-top: 2px;
  border: 1px solid var(--line);
}
.source-links .src-link:hover { background: var(--brand-soft); color: var(--brand); }

/* ====================================================================
   Summary stat cards (Portfolio / Trades) — horizontal auto-fit row
   ==================================================================== */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.summary-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow .15s;
}
.summary-card:hover { box-shadow: var(--shadow-sm); }
.summary-label { font-size: 11.5px; font-weight: 600; color: var(--muted); letter-spacing: .02em; margin-bottom: 6px; }
.summary-value { font-family: var(--font-display); font-size: 24px; font-weight: 700; letter-spacing: -0.02em; color: var(--ink); line-height: 1.2; }
.summary-value .small { font-size: 13px; font-weight: 500; }

/* page-level action row (upload buttons etc., placed below the shell title) */
.page-actions-row {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.page-actions-row .muted { margin-right: auto; }

/* ====================================================================
   Portfolio / Trades page-specific styles
   ==================================================================== */
/* summary card colored top-stripe accents */
.summary-card.accent-brand { border-top: 3px solid var(--brand); }
.summary-card.accent-sky   { border-top: 3px solid var(--sky-ink); }
.summary-card.accent-rose  { border-top: 3px solid var(--rose-ink); }
.summary-card.accent-mint  { border-top: 3px solid var(--mint-ink); }
.summary-card.accent-amber { border-top: 3px solid var(--amber-ink); }

/* sector / attribution bars */
.sector-bars { display: flex; flex-direction: column; gap: 9px; margin-top: 4px; }
.sector-row { display: flex; align-items: center; gap: 12px; }
.sector-name { width: 200px; font-size: 13px; font-weight: 500; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
.sector-name a { color: var(--ink-2); }
.sector-name a:hover { color: var(--brand); }
.bar-track { flex: 1; height: 8px; background: var(--bg-tint-2); border-radius: var(--r-pill); overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--brand) 0%, var(--lavender) 100%); border-radius: var(--r-pill); transition: width .3s; min-width: 2px; }
.sector-pct { width: 55px; text-align: right; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink-2); flex-shrink: 0; }

/* filter bar */
.filter-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-input, .filter-select { width: auto; min-width: 140px; }
.filter-bar .muted { margin-left: auto; }

/* table links */
.ticker-link { font-weight: 700; color: var(--brand); }
.company-link { color: var(--ink-2); }
.company-link:hover { color: var(--brand); }

/* market badges */
.badge.market-hk { background: var(--rose-bg); color: var(--rose-ink); border-color: transparent; }
.badge.market-us { background: var(--sky-bg); color: var(--sky-ink); border-color: transparent; }
.badge.market-sh, .badge.market-sz { background: var(--amber-bg); color: var(--amber-ink); border-color: transparent; }

/* recommendation badges */
.badge.rec-core    { background: var(--brand-tint); color: var(--brand-2); border-color: transparent; }
.badge.rec-buy     { background: var(--mint-bg); color: var(--mint-ink); border-color: transparent; }
.badge.rec-hold    { background: var(--amber-bg); color: var(--amber-ink); border-color: transparent; }
.badge.rec-sell    { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.badge.rec-reduce  { background: var(--rose-bg); color: var(--rose-ink); border-color: transparent; }
.badge.rec-top     { background: linear-gradient(135deg, var(--brand) 0%, var(--lavender) 100%); color: #fff; border: 0; }

/* flag chips (US / China) */
.flag { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: var(--r-pill); font-size: 11px; font-weight: 600; }
.flag.us { background: var(--sky-bg); color: var(--sky-ink); }
.flag.china { background: var(--rose-bg); color: var(--rose-ink); }

/* sortable table headers */
.portfolio-table th.sortable { cursor: pointer; user-select: none; }
.portfolio-table th.sortable:hover { color: var(--brand); }
.portfolio-table th.sortable::after { content: ' ↕'; opacity: .3; font-size: 10px; }
.portfolio-table th.sorted-asc::after { content: ' ↑'; opacity: .8; color: var(--brand); }
.portfolio-table th.sorted-desc::after { content: ' ↓'; opacity: .8; color: var(--brand); }

/* row-clickable */
tr.row-clickable { cursor: pointer; }
tr.row-clickable:hover { background: var(--bg-tint); }

/* ====================================================================
   Shared components — filters, chips, details, impact badges
   (applies to Inbox, Digest, Add News, News detail, Admin, Company)
   ==================================================================== */
/* collapsible filter panel */
.filters { margin-bottom: 16px; }
.filters > summary {
  cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-2);
  padding: 8px 14px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-md); display: inline-block; transition: background .15s;
}
.filters > summary:hover { background: var(--bg-tint); }
.filtergrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-top: 12px; padding: 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); }
.filtergrid label { margin-top: 0; }

/* chip / tab buttons (news detail assessment tabs) */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 14px; border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--line-2);
  font-size: 13px; font-weight: 500; color: var(--ink-2); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.chip:hover { background: var(--bg-tint); border-color: var(--brand-soft); }
.chip.on { background: var(--brand-tint); color: var(--brand-2); border-color: transparent; font-weight: 600; }

/* details / summary (collapsible sections everywhere) */
details { margin-top: 8px; }
details > summary {
  cursor: pointer; font-size: 13px; color: var(--muted);
  padding: 4px 0; transition: color .15s;
}
details > summary:hover { color: var(--brand); }

/* impact badge variants (impactBadge generates these dynamically) */
.badge:has-text("Very positive"), .badge:has-text("Positive"), .badge:has-text("Mildly positive") { }
/* (impactBadge already uses .badge.ok/.warn/.danger/.brand classes — those are styled above) */

/* seg buttons (segmented control for Yes/No etc.) */
.seg { display: inline-flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--line-2); border-radius: var(--r-pill); overflow: hidden; max-width: 100%; }
.seg button {
  border: 0; border-radius: 0; padding: 6px 16px; background: transparent;
  font-weight: 500; color: var(--muted); cursor: pointer; transition: background .15s;
}
.seg button:hover { background: var(--bg-tint); }
.seg button.on, .seg button.selected { background: var(--brand-tint); color: var(--brand-2); font-weight: 600; }

/* analyst selector box (Add News page) */
.analyst-selector-box {
  background: var(--brand-tint); border: 2px solid var(--brand-soft-2);
  border-radius: var(--r-md); padding: 12px; margin-bottom: 16px;
}

/* review form key-points list */
.key-points-list { display: flex; flex-direction: column; gap: 6px; }
.key-point-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); }
.key-point-row input { flex: 1; }

/* news detail sections */
.news-detail-back { font-size: 13px; color: var(--muted); margin-bottom: 12px; display: inline-block; }
.news-detail-back:hover { color: var(--brand); }

/* admin page section cards */
.admin-section { margin-bottom: 16px; }
.admin-section h3 { display: flex; align-items: center; gap: 8px; }
.admin-conn-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.admin-conn-row:last-child { border-bottom: 0; }
.conn-status { display: inline-flex; align-items: center; gap: 4px; }
.conn-status.connected { color: var(--ok); }
.conn-status.disconnected { color: var(--muted); }
.conn-status.deprecated { color: var(--warn); }

/* restricted list badge */
.restricted-item { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }

/* company page thesis version */
.thesis-version { padding: 10px 0; border-bottom: 1px solid var(--line); }
.thesis-version:last-child { border-bottom: 0; }

/* company multi-select chips (Add News page) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 200px; overflow-y: auto; padding: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); }
.chips .chip { font-size: 12px; padding: 4px 10px; }
.chips .chip.on { background: var(--brand-tint); color: var(--brand-2); border-color: transparent; }

/* toast / notifications list */
.notif-item { padding: 12px; border-bottom: 1px solid var(--line); }
.notif-item:last-child { border-bottom: 0; }
.notif-item.unread { background: var(--brand-tint); border-radius: var(--r-md); }
.notif-item.card { padding: 14px 16px; }
.notif-open-btn {
  padding: 6px 18px !important;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .2px;
}