/* ----- Reset + base ----- */
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  :root {
    --bg: #F7FAFC;
    --card: #FFFFFF;
    --card-border: #EDF2F7;
    --sidebar: #FFFFFF;
    --mint: #4FD1C5;
    --mint-dark: #2AD2C9;
    --mint-deep: #319795;
    --mint-tint: #E6FFFA;
    --navy: #1A202C;
    --text: #1A202C;
    --text-soft: #4A5568;
    --muted: #718096;
    --muted-2: #A0AEC0;
    --green: #01B574;
    --green-tint: #E6F9F0;
    --red: #E31A1A;
    --red-tint: #FFEBEB;
    --divider: #EDF2F7;
    --shadow-sm: 0 1px 3px rgba(26,32,44,0.04), 0 1px 2px rgba(26,32,44,0.03);
    --shadow-md: 0 4px 12px rgba(26,32,44,0.06), 0 2px 4px rgba(26,32,44,0.04);
    --shadow-lg: 0 12px 24px rgba(26,32,44,0.08), 0 4px 8px rgba(26,32,44,0.05);
    --radius: 16px;
    --radius-sm: 10px;
    --radius-pill: 999px;
  }
  html, body { height: 100%; }
  body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }
  .mono { font-family: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace; font-feature-settings: 'tnum'; }
  button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
  input { font-family: inherit; }

  /* ----- App shell ----- */
  .app-boot {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 28px;
    background: var(--bg);
    color: var(--text);
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.28s ease, visibility 0.28s ease, transform 0.28s ease;
  }
  .app-boot.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-8px);
  }
  .app-boot-mark {
    width: 62px;
    height: 62px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--mint) 0%, var(--mint-dark) 100%);
    box-shadow: 0 16px 34px rgba(49,151,149,0.25);
  }
  .app-boot-mark img {
    width: 38px;
    height: 38px;
    display: block;
  }
  .app-boot-title {
    margin-top: 4px;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0;
  }
  .app-boot-status {
    min-height: 18px;
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 700;
  }
  .app-boot-status::after {
    content: '';
    display: inline-block;
    width: 16px;
    text-align: left;
    animation: appBootDots 1.1s steps(4, end) infinite;
  }
  @keyframes appBootDots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75%, 100% { content: '...'; }
  }

  /* ----- Layout ----- */
  .app {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
  }

  /* ----- Sidebar ----- */
  .sidebar {
    background: var(--sidebar);
    border-right: 1px solid var(--divider);
    padding: 28px 20px;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
  }
  .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px 28px;
    border-bottom: 1px solid var(--divider);
    margin-bottom: 20px;
  }
  .brand-mark {
    width: 32px; height: 32px; border-radius: 10px;
    background: linear-gradient(135deg, var(--mint) 0%, var(--mint-dark) 100%);
    display: grid; place-items: center;
    box-shadow: 0 4px 10px rgba(79,209,197,0.3);
    flex-shrink: 0;
  }
  .brand-mark img { width: 22px; height: 22px; display: block; }
  .brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
  .brand-sub { color: var(--muted); font-size: 11px; margin-top: 1px; }

  .nav { display: flex; flex-direction: column; gap: 4px; min-height: 0; }
  .nav-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--muted-2);
    text-transform: uppercase;
    padding: 16px 12px 8px;
  }
  .nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-soft);
    font-weight: 500;
    font-size: 13.5px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    text-align: left;
    width: 100%;
    outline: none;
    border: 1px solid transparent;
    position: relative;
  }
  .nav-item:hover { background: var(--mint-tint); color: var(--mint-deep); }
  .nav-item:focus-visible { box-shadow: 0 0 0 3px rgba(79,209,197,0.28); border-color: rgba(79,209,197,0.55); }
  .nav-item:active { transform: translateY(0.5px); }
  .nav-item.active {
    background: linear-gradient(135deg, var(--mint) 0%, var(--mint-dark) 100%);
    color: white;
    box-shadow: 0 6px 14px rgba(49,151,149,0.28), inset 0 0 0 1px rgba(255,255,255,0.18);
  }
  .nav-item.active::before {
    content: '';
    position: absolute;
    left: -12px; top: 10px; bottom: 10px;
    width: 3px; border-radius: 2px;
    background: var(--mint-deep);
  }
  .nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
  .nav-item .nav-brand {
    width: 22px; height: 22px; border-radius: 6px;
    background: white; border: 1px solid var(--divider);
    display: grid; place-items: center; overflow: hidden;
    padding: 2px; flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(26,32,44,0.04);
  }
  .nav-item .nav-brand img { width: 100%; height: 100%; object-fit: contain; display: block; }
  .nav-item.active .nav-brand { background: white; border-color: rgba(255,255,255,0.6); }
  .provider-logo {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--divider);
    display: grid;
    place-items: center;
    font-weight: 800;
    letter-spacing: 0;
    line-height: 1;
  }
  .nav-brand.provider-logo {
    padding: 3px;
    font-size: 8.5px;
  }
  .nav-item.active .nav-brand.provider-logo {
    background: white;
    color: var(--text);
  }
  .bot-avatar.provider-logo {
    padding: 5px;
    border: 1px solid var(--divider);
    color: var(--text);
    font-size: 11px;
    overflow: hidden;
  }
  .provider-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
  }
  .provider-logo span {
    display: none;
    width: 100%;
    height: 100%;
    place-items: center;
    border-radius: inherit;
    background: linear-gradient(135deg, var(--mint) 0%, var(--mint-dark) 100%);
    color: white;
  }
  .provider-polymarket span { background: linear-gradient(135deg, #2F6FED 0%, #1D4ED8 100%); }
  .provider-etoro span { background: linear-gradient(135deg, #6EC531 0%, #2F9E44 100%); }
  .provider-capital span { background: linear-gradient(135deg, #1F8A99 0%, #126A75 100%); }
  .provider-betfair span { background: linear-gradient(135deg, #FFB80C 0%, #C68F00 100%); color: #1A1A1A; }
  .provider-psa span {
    background: #ED0000;
    color: #fff;
    font-size: 7px;
    font-weight: 900;
    letter-spacing: 0;
  }
  .provider-logo .psa-nav-logo,
  .nav-item.active .nav-brand.provider-logo .psa-nav-logo {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: #ED0000;
    color: #fff;
    font-size: 7px;
    font-weight: 900;
    letter-spacing: 0;
    line-height: 1;
  }
  .provider-nt { background: linear-gradient(135deg, var(--mint) 0%, var(--mint-dark) 100%); }
  .nav-sub { font-size: 12px; opacity: 0.7; margin-left: 2px; font-weight: 400; }
  .nav-item.active .nav-sub { opacity: 0.9; }
  .nav-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
  }
  .nav-parent {
    justify-content: flex-start;
  }
  .nav-parent > span {
    flex: 1;
  }
  .nav-caret {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    color: currentColor;
    opacity: 0.7;
    transition: transform 0.16s ease, opacity 0.16s ease;
  }
  .nav-group.open .nav-caret {
    transform: rotate(180deg);
    opacity: 1;
  }
  .nav-submenu {
    display: none;
    flex-direction: column;
    gap: 4px;
    margin: -2px 0 2px 34px;
    padding-left: 10px;
    padding-right: 4px;
    border-left: 1px solid var(--divider);
    max-height: 320px;
    overflow-y: auto;
  }
  .nav-group.open .nav-submenu {
    display: flex;
  }
  .nav-subitem {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    padding: 6px 10px;
    border-radius: 10px;
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 600;
    text-align: left;
    transition: background 0.15s ease, color 0.15s ease;
  }
  .nav-subitem:hover {
    background: var(--mint-tint);
    color: var(--mint-deep);
  }
  .nav-subitem.active {
    background: rgba(79, 209, 197, 0.14);
    color: var(--mint-deep);
  }
  .nav-subitem-meta {
    margin-left: auto;
    color: var(--muted-2);
    font-size: 11px;
    font-weight: 700;
  }
  .nav-subitem.active .nav-subitem-meta {
    color: var(--mint-deep);
  }

  .sidebar-footer {
    margin-top: auto;
    padding: 16px;
    background: linear-gradient(135deg, var(--mint) 0%, var(--mint-dark) 100%);
    border-radius: var(--radius);
    color: white;
    position: relative;
    overflow: hidden;
  }
  .sidebar-footer::after {
    content: ''; position: absolute; right: -20px; bottom: -20px;
    width: 80px; height: 80px; border-radius: 50%;
    background: rgba(255,255,255,0.12);
  }
  .sidebar-footer-title { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
  .sidebar-footer-sub { font-size: 11.5px; opacity: 0.85; margin-bottom: 10px; line-height: 1.4; }
  .sidebar-footer-btn {
    background: white; color: var(--mint-deep);
    padding: 6px 12px; border-radius: 8px;
    font-size: 11px; font-weight: 600;
    display: inline-flex; align-items: center; gap: 4px;
    cursor: pointer; transition: transform 0.12s, box-shadow 0.12s;
  }
  .sidebar-footer-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(26,32,44,0.14); }
  .sidebar-footer-btn svg { width: 14px; height: 14px; flex-shrink: 0; }

  /* ----- Clickability affordances ----- */
  .sidebar .brand { cursor: pointer; transition: opacity 0.12s; }
  .sidebar .brand:hover { opacity: 0.85; }
  .user-pill { transition: all 0.15s ease; }
  .user-pill:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(79,209,197,0.18); }
  .icon-btn { cursor: pointer; }
  .icon-btn:hover { background: var(--mint-tint); color: var(--mint-deep); }

  /* ----- Main ----- */
  .main { padding: 28px 36px 48px; max-width: 1400px; width: 100%; min-width: 0; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 28px;
    position: relative; z-index: 30;
  }
  .page-title h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
  .page-title p { color: var(--muted); font-size: 13px; margin-top: 2px; }
  .topbar-right { display: flex; align-items: center; gap: 12px; }
  .search {
    display: flex; align-items: center; gap: 8px;
    background: var(--card); border: 1px solid var(--divider);
    padding: 8px 14px; border-radius: var(--radius-pill);
    width: 220px; box-shadow: var(--shadow-sm);
  }
  .search input { border: none; outline: none; background: none; flex: 1; font-size: 13px; color: var(--text); }
  .search svg { width: 15px; height: 15px; color: var(--muted); }
  .icon-btn {
    width: 36px; height: 36px; border-radius: 10px;
    background: var(--card); border: 1px solid var(--divider);
    display: grid; place-items: center;
    box-shadow: var(--shadow-sm);
    transition: all 0.15s;
    position: relative;
  }
  .icon-btn:hover { background: var(--mint-tint); border-color: var(--mint); }
  .icon-btn svg { width: 16px; height: 16px; color: var(--text-soft); }
  .icon-btn.live::after {
    content: ''; position: absolute; top: 8px; right: 8px;
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 2px var(--card), 0 0 0 4px rgba(1,181,116,0.2);
    animation: pulse 1.8s infinite;
  }
  @keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px rgba(1,181,116,0.25); }
    50% { box-shadow: 0 0 0 2px var(--card), 0 0 0 6px rgba(1,181,116,0.1); }
  }

  /* ----- User menu ----- */
  .user-menu { position: relative; z-index: 40; }
  .user-pill {
    display: flex; align-items: center; gap: 10px;
    background: var(--card); border: 1px solid var(--divider);
    padding: 4px 12px 4px 4px; border-radius: var(--radius-pill);
    box-shadow: var(--shadow-sm);
    transition: all 0.15s;
    cursor: pointer;
    user-select: none;
  }
  .user-pill:hover { border-color: var(--mint); background: var(--mint-tint); }
  .user-pill:active { transform: translateY(0) scale(0.98); }
  .user-pill svg { transition: transform 0.18s ease; }
  .user-menu.open .user-pill svg:last-child { transform: rotate(180deg); }
  .avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: linear-gradient(135deg, var(--mint) 0%, var(--mint-dark) 100%);
    color: white; font-weight: 700; font-size: 12px;
    display: grid; place-items: center;
    box-shadow: 0 2px 6px rgba(79,209,197,0.35);
  }
  .user-meta { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; }
  .user-name { font-weight: 600; font-size: 12.5px; }
  .user-role { font-size: 10.5px; color: var(--muted); margin-top: 1px; }
  .user-dropdown {
    position: absolute; top: calc(100% + 8px); right: 0;
    background: var(--card); border: 1px solid var(--divider);
    border-radius: 12px; box-shadow: 0 12px 32px rgba(26,32,44,0.16);
    min-width: 240px; padding: 8px;
    opacity: 0; pointer-events: none; transform: translateY(-6px) scale(0.98);
    transform-origin: top right;
    transition: opacity 0.16s ease, transform 0.16s ease;
    z-index: 100;
  }
  .user-dropdown.open { opacity: 1; pointer-events: auto; transform: translateY(0) scale(1); }
  .dropdown-header { padding: 10px 12px 12px; border-bottom: 1px solid var(--divider); margin-bottom: 6px; }
  .dropdown-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 9px 12px; border-radius: 8px;
    font-size: 13px; color: var(--text-soft);
    text-align: left; cursor: pointer;
    transition: background 0.1s ease, color 0.1s ease, transform 0.08s ease;
  }
  .dropdown-item:hover { background: var(--bg); color: var(--text); }
  .dropdown-item:active { transform: scale(0.98); }
  .dropdown-item svg { width: 15px; height: 15px; color: var(--muted); }
  .dropdown-item.logout { color: var(--red); }
  .dropdown-item.logout:hover { background: var(--red-tint); }
  .dropdown-item.logout svg { color: var(--red); }
  .dropdown-divider { height: 1px; background: var(--divider); margin: 6px 4px; }

  /* ----- KPI row ----- */
  .kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
  }
  .kpi {
    background: var(--card);
    border: 1px solid var(--divider);
    border-radius: var(--radius);
    padding: 22px 22px 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
  }
  .kpi:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--mint);
  }
  .kpi.hero {
    background: linear-gradient(135deg, var(--mint) 0%, var(--mint-dark) 60%, var(--mint-deep) 120%);
    color: white;
    border: none;
  }
  .kpi.hero::before {
    content: ''; position: absolute; top: -40px; right: -40px;
    width: 160px; height: 160px; border-radius: 50%;
    background: rgba(255,255,255,0.08);
  }
  .kpi.hero::after {
    content: ''; position: absolute; bottom: -30px; right: 30px;
    width: 90px; height: 90px; border-radius: 50%;
    background: rgba(255,255,255,0.06);
  }
  .kpi-label {
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--muted);
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px;
    position: relative; z-index: 1;
  }
  .kpi.hero .kpi-label { color: rgba(255,255,255,0.75); }
  .kpi-icon {
    width: 32px; height: 32px; border-radius: 8px;
    background: var(--mint-tint);
    display: grid; place-items: center;
    color: var(--mint-deep);
  }
  .kpi.hero .kpi-icon { background: rgba(255,255,255,0.18); color: white; }
  .kpi-icon svg { width: 14px; height: 14px; }
  .kpi-value {
    font-size: 30px; font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
    position: relative; z-index: 1;
  }
  .kpi-delta {
    font-size: 12px; font-weight: 600;
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 8px; border-radius: var(--radius-pill);
    position: relative; z-index: 1;
  }
  .kpi-delta.up { color: var(--green); background: var(--green-tint); }
  .kpi-delta.down { color: var(--red); background: var(--red-tint); }
  .kpi.hero .kpi-delta { background: rgba(255,255,255,0.22); color: white; }
  .kpi-sub { font-size: 12px; color: var(--muted); margin-left: 8px; }
  .kpi.hero .kpi-sub { color: rgba(255,255,255,0.75); }

  /* ----- Focus row (Health page at-a-glance cards) ----- */
  .focus-row {
    display: grid;
    /* Auto-fit gives us 5-up on wide desktops, gracefully collapsing
       to 4/3/2 columns as the viewport narrows, without explicit
       breakpoints. The mobile @media below forces a single column on
       phones. */
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
  }
  .focus {
    background: var(--card);
    border: 1px solid var(--divider);
    border-radius: var(--radius);
    padding: 18px 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    box-shadow: var(--shadow-sm);
    min-width: 0; /* let grid items shrink without overflowing */
  }
  .focus[onclick],
  .focus[data-drill] { cursor: pointer; }
  .focus[onclick]:hover,
  .focus[data-drill]:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--mint);
  }

  .focus-head {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .focus-ico {
    flex: 0 0 auto;
    width: 28px; height: 28px;
    border-radius: 8px;
    background: var(--mint-tint);
    color: var(--mint-deep);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.02em;
  }
  .focus-ico svg { width: 14px; height: 14px; }
  .focus-label {
    flex: 1 1 auto;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .focus-status-pill {
    flex: 0 0 auto;
    font-size: 10.5px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: var(--radius-pill);
    background: var(--green-tint);
    color: var(--green);
    white-space: nowrap;
  }
  .focus-status-pill.amber { background: #FFF5E6; color: #D69E2E; }
  .focus-status-pill.red   { background: var(--red-tint); color: var(--red); }
  .focus-status-pill.gray,
  .focus-status-pill.grey  { background: var(--bg); color: var(--muted); }

  /* Tone modifiers tint the icon (and slightly the card) */
  .focus.green  .focus-ico { background: var(--green-tint); color: var(--green); }
  .focus.amber  .focus-ico { background: #FFF5E6; color: #D69E2E; }
  .focus.red    .focus-ico { background: var(--red-tint);   color: var(--red); }
  .focus.indigo .focus-ico { background: #EBF4FF;            color: #4C51BF; }
  .focus.amber { border-color: rgba(214,158,46,0.28); }
  .focus.red   { border-color: rgba(227,26,26,0.22); }

  .focus-dots {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
  }
  .focus-bot-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 2px var(--green-tint);
    flex: 0 0 auto;
  }
  .focus-bot-dot.amber { background: #FFB547; box-shadow: 0 0 0 2px #FFF5E6; }
  .focus-bot-dot.red   { background: var(--red); box-shadow: 0 0 0 2px var(--red-tint); }
  .focus-bot-dot.grey,
  .focus-bot-dot.gray  { background: var(--muted-2); box-shadow: 0 0 0 2px var(--bg); }

  .focus-headline {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.15;
    color: var(--text);
    word-break: break-word;
  }
  .focus-sub {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.45;
  }

  .focus-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
    border-top: 1px solid var(--divider);
    padding-top: 10px;
  }
  .focus-line {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    font-size: 12px;
  }
  .focus-line .k {
    color: var(--muted);
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .focus-line .v {
    color: var(--text);
    font-weight: 600;
    flex: 0 0 auto;
    text-align: right;
    white-space: nowrap;
  }
  .focus-line .v.up   { color: var(--green); }
  .focus-line .v.down { color: var(--red); }

  .focus-action-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
    border-top: 1px solid var(--divider);
    padding-top: 10px;
  }
  .focus-action {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-soft);
    min-width: 0;
  }
  .focus-action .sym {
    font-weight: 700;
    color: var(--text);
    flex: 0 0 auto;
  }
  .focus-action > span:nth-child(3) {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .focus-action .when {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 11px;
  }

  .dot-sm {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--green);
    flex: 0 0 auto;
  }
  .dot-sm.amber { background: #FFB547; }
  .dot-sm.red   { background: var(--red); }
  .dot-sm.grey,
  .dot-sm.gray  { background: var(--muted-2); }

  /* ----- Section grid ----- */
  .grid-two { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 24px; }
  .card {
    background: var(--card);
    border: 1px solid var(--divider);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
  }
  .card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 18px;
  }
  .card-title { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
  .card-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
  .card-actions { display: flex; gap: 4px; }
  .chip {
    font-size: 11.5px; font-weight: 500;
    padding: 5px 11px; border-radius: var(--radius-pill);
    color: var(--muted); background: transparent;
    cursor: pointer; transition: all 0.15s;
  }
  .chip:hover { color: var(--mint-deep); background: var(--mint-tint); }
  .chip.active { color: var(--mint-deep); background: var(--mint-tint); font-weight: 600; }

  /* ----- Equity chart ----- */
  .chart-wrap { position: relative; height: 260px; }
  .chart-wrap svg { width: 100%; height: 100%; display: block; }
  .chart-hover {
    position: absolute; top: 0; left: 0;
    background: var(--navy); color: white;
    padding: 8px 12px; border-radius: 8px;
    font-size: 12px; font-weight: 500;
    pointer-events: none; opacity: 0;
    transition: opacity 0.15s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    z-index: 5;
  }

  /* ----- Win-rate radial ----- */
  .radial-group { display: flex; flex-direction: column; gap: 14px; margin-top: 4px; }
  .radial-row {
    display: flex; align-items: center; gap: 14px;
    padding: 12px; border-radius: 10px;
    cursor: pointer; transition: background 0.15s;
  }
  .radial-row:hover { background: var(--bg); }
  .radial-svg { width: 54px; height: 54px; flex-shrink: 0; }
  .radial-bg { fill: none; stroke: var(--divider); stroke-width: 5; }
  .radial-fg { fill: none; stroke-linecap: round; stroke-width: 5; transition: stroke-dashoffset 1s ease; }
  .radial-label { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
  .radial-value { font-weight: 700; font-size: 15px; }
  .radial-meta { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
  .radial-row-right { margin-left: auto; color: var(--muted-2); font-size: 11px; font-weight: 500; }

  /* ----- Bot tile row ----- */
  .bot-row {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
    margin-bottom: 24px;
  }
  .bot-tile {
    background: var(--card); border: 1px solid var(--divider);
    border-radius: var(--radius); padding: 22px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
  }
  .bot-tile:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--mint);
  }
  .bot-tile-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
  .bot-avatar {
    width: 40px; height: 40px; border-radius: 11px;
    display: grid; place-items: center;
    color: white; font-weight: 700; font-size: 14px;
    background: linear-gradient(135deg, var(--mint) 0%, var(--mint-dark) 100%);
  }
  .bot-avatar.sports { background: linear-gradient(135deg, #FFB547 0%, #F6AD55 100%); }
  .bot-avatar.brand {
    background: white;
    border: 1px solid var(--divider);
    overflow: hidden;
    padding: 4px;
  }
  .bot-avatar.brand img { width: 100%; height: 100%; object-fit: contain; display: block; }
  .bot-name { font-weight: 600; font-size: 14.5px; }
  .bot-status {
    font-size: 11px; color: var(--green); font-weight: 600;
    display: inline-flex; align-items: center; gap: 5px;
    margin-top: 2px;
  }
  .bot-status-dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 0 3px rgba(1,181,116,0.18);
    animation: pulse 2s infinite;
  }
  .bot-arrow {
    margin-left: auto;
    width: 28px; height: 28px; border-radius: 8px;
    display: grid; place-items: center;
    color: var(--muted); transition: all 0.2s;
  }
  .bot-tile:hover .bot-arrow { background: var(--mint); color: white; transform: translateX(2px); }
  .bot-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
  .bot-stat-label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
  .bot-stat-value { font-weight: 700; font-size: 17px; margin-top: 3px; letter-spacing: -0.01em; }
  .bot-stat-value.up { color: var(--green); }
  .bot-stat-value.down { color: var(--red); }
  .bot-spark { margin-top: 14px; height: 44px; }
  .bot-spark svg { width: 100%; height: 100%; }

  /* ----- Trades feed ----- */
  .trade-row {
    display: grid;
    grid-template-columns: 36px 1fr auto auto;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--divider);
    align-items: center;
    cursor: pointer;
    transition: background 0.15s;
    padding-left: 8px; padding-right: 8px;
    border-radius: 8px;
  }
  .trade-row:last-child { border-bottom: none; }
  .trade-row:hover { background: var(--bg); }
  .trade-icon {
    width: 32px; height: 32px; border-radius: 8px;
    display: grid; place-items: center;
    background: var(--mint-tint); color: var(--mint-deep);
    font-weight: 700; font-size: 11px;
  }
  .trade-icon.sports { background: #FFF5E6; color: #D69E2E; }
  .trade-main-label { font-weight: 600; font-size: 13.5px; }
  .trade-meta { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
  .trade-size { font-size: 12px; color: var(--muted); }
  .trade-pnl { font-weight: 700; font-size: 14px; }
  .trade-pnl.up { color: var(--green); }
  .trade-pnl.down { color: var(--red); }

  /* ----- Right panel (drill-in) ----- */
  .drawer-backdrop {
    position: fixed; inset: 0;
    background: rgba(26,32,44,0.45);
    opacity: 0; pointer-events: none;
    transition: opacity 0.25s;
    z-index: 40;
    backdrop-filter: blur(2px);
  }
  .drawer-backdrop.open { opacity: 1; pointer-events: auto; }
  .drawer {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: 480px; max-width: 100vw;
    background: var(--card);
    box-shadow: -10px 0 30px rgba(26,32,44,0.1);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.22,0.61,0.36,1);
    z-index: 50;
    display: flex; flex-direction: column;
    overflow: hidden;
  }
  .drawer.open { transform: translateX(0); }
  .drawer-header {
    padding: 24px 28px; border-bottom: 1px solid var(--divider);
    display: flex; align-items: center; justify-content: space-between;
  }
  .drawer-title { font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
  .drawer-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
  .drawer-body { flex: 1; overflow-y: auto; padding: 24px 28px; }
  .drawer-close {
    width: 34px; height: 34px; border-radius: 10px;
    background: var(--bg); display: grid; place-items: center;
    color: var(--muted); transition: all 0.15s;
  }
  .drawer-close:hover { background: var(--red-tint); color: var(--red); }
  .drawer-close svg { width: 16px; height: 16px; }

  .stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 24px; }
  .stat-box {
    background: var(--bg);
    border-radius: 12px; padding: 14px 16px;
  }
  .stat-box-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
  .stat-box-value { font-size: 18px; font-weight: 700; margin-top: 4px; letter-spacing: -0.01em; }
  .stat-box-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

  .section-label {
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--muted);
    margin: 20px 0 10px;
  }

  /* ----- Page switching ----- */
  .page { display: none; animation: fadeIn 0.25s ease; }
  .page.active { display: block; }
  @keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
  }

  /* ----- Empty "coming soon" states for other pages ----- */
  .placeholder {
    padding: 80px 40px; text-align: center;
    background: var(--card); border-radius: var(--radius);
    border: 1px dashed var(--divider);
  }
  .placeholder-icon {
    width: 56px; height: 56px; border-radius: 14px;
    background: var(--mint-tint); color: var(--mint-deep);
    margin: 0 auto 16px;
    display: grid; place-items: center;
  }
  .placeholder-icon svg { width: 24px; height: 24px; }
  .placeholder h2 { font-size: 18px; font-weight: 700; margin-bottom: 6px; letter-spacing: -0.01em; }
  .placeholder p { color: var(--muted); font-size: 13px; max-width: 380px; margin: 0 auto; }

  /* ----- Chart tooltip marker ----- */
  .chart-marker { fill: white; stroke: var(--mint); stroke-width: 3; opacity: 0; transition: opacity 0.15s; }

  /* ----- Generic data table ----- */
  .data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
  .data-table th {
    text-align: left; font-weight: 600; font-size: 11px;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--muted); padding: 12px 14px;
    border-bottom: 1px solid var(--divider);
    background: var(--bg);
  }
  .data-table th:first-child { border-top-left-radius: 10px; }
  .data-table th:last-child { border-top-right-radius: 10px; }
  .data-table td {
    padding: 14px; border-bottom: 1px solid var(--divider);
    vertical-align: middle;
  }
  .data-table tr { transition: background 0.12s; cursor: pointer; }
  .data-table tbody tr:hover { background: var(--bg); }
  .data-table tbody tr:last-child td { border-bottom: none; }

  /* ----- Health page polish ----- */
  #page-health .topbar { margin-bottom: 14px; }
  #page-health .health-focus-row {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
  }
  #page-health .focus {
    padding: 16px 16px 14px;
    border-radius: 16px;
    gap: 8px;
    min-height: 154px;
  }
  #page-health .focus-head { gap: 7px; }
  #page-health .focus-ico {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    font-size: 11px;
  }
  #page-health .focus-label { font-size: 10px; letter-spacing: 0.075em; }
  #page-health .focus-status-pill {
    font-size: 10px;
    padding: 3px 7px;
    max-width: 96px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #page-health .focus-headline { font-size: 20px; line-height: 1.1; }
  #page-health .focus-sub {
    min-height: 32px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  #page-health .focus-list,
  #page-health .focus-action-list {
    gap: 5px;
    padding-top: 8px;
    margin-top: 2px;
  }
  #page-health .focus-line,
  #page-health .focus-action { font-size: 11.5px; }
  #page-health .focus-dots {
    min-height: 15px;
    max-height: 23px;
    overflow: hidden;
  }
  #page-health .focus-bot-dot {
    width: 7px;
    height: 7px;
  }

  #page-health .health-status-strip {
    gap: 12px;
    margin-bottom: 16px;
  }
  #page-health .health-status-strip .kpi {
    padding: 16px;
    border-radius: 16px;
    min-height: 118px;
  }
  #page-health .health-status-strip .kpi.hero {
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--divider);
  }
  #page-health .health-status-strip .kpi.hero::before,
  #page-health .health-status-strip .kpi.hero::after { display: none; }
  #page-health .health-status-strip .kpi.hero .kpi-label { color: var(--muted); }
  #page-health .health-status-strip .kpi.hero .kpi-delta {
    background: var(--green-tint);
    color: var(--green);
  }
  #page-health .health-status-strip .kpi.hero .kpi-sub { color: var(--muted); }
  #page-health .health-status-strip .kpi-label { margin-bottom: 8px; }
  #page-health .health-status-strip .kpi-value {
    font-size: 25px;
    margin-bottom: 6px;
  }

  #page-health .health-services-card { padding: 20px; }
  #page-health .health-services-scroll {
    max-height: 520px;
    overflow: auto;
    padding-right: 2px;
  }
  #page-health .health-services-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
  }
  #page-health .health-services-table td {
    padding: 12px 14px;
  }
  #page-health .health-service-name {
    font-size: 12.8px;
    font-weight: 700;
    color: var(--text);
  }
  #page-health .health-service-note {
    font-size: 11px;
    color: var(--muted);
    margin-top: 3px;
    max-width: 420px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #page-health .health-alert-count {
    min-width: 22px;
    justify-content: center;
  }
  #page-health .health-detail-grid {
    grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
    gap: 16px;
    margin-bottom: 18px;
  }
  #page-health .health-detail-grid .card,
  #page-health .health-infra-card {
    padding: 20px;
  }
  #page-health .health-log-feed {
    max-height: 340px;
    overflow-y: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11.5px;
    padding-right: 2px;
  }

  .table-scroll {
    overflow-y: scroll;
    scrollbar-gutter: stable;
    padding-right: 4px;
  }
.table-scroll-5 { max-height: 322px; }
.table-scroll-10 { max-height: 612px; }
  .table-scroll-6 { max-height: 420px; }
  .psa-deal-scroll {
    max-height: min(72vh, 760px);
    min-height: 560px;
    overflow-x: auto;
  }
  .stack-scroll {
    overflow-y: scroll;
    scrollbar-gutter: stable;
    padding-right: 4px;
  }
  .stack-scroll-5 { max-height: 322px; }
  .stack-scroll-6 { max-height: 420px; }
  /* Always-visible, on-brand scrollbar (Mac hides auto-scrollbars by default) */
  html::-webkit-scrollbar,
  body::-webkit-scrollbar,
  .main::-webkit-scrollbar,
  .sidebar::-webkit-scrollbar,
  .nav-submenu::-webkit-scrollbar,
  .drawer-body::-webkit-scrollbar,
  #cryptoFeed::-webkit-scrollbar,
  #sportsFeed::-webkit-scrollbar,
  #healthLogs::-webkit-scrollbar,
  .table-scroll::-webkit-scrollbar,
  .stack-scroll::-webkit-scrollbar {
    width: 10px;
    background: transparent;
  }
  html::-webkit-scrollbar-track,
  body::-webkit-scrollbar-track,
  .main::-webkit-scrollbar-track,
  .sidebar::-webkit-scrollbar-track,
  .nav-submenu::-webkit-scrollbar-track,
  .drawer-body::-webkit-scrollbar-track,
  #cryptoFeed::-webkit-scrollbar-track,
  #sportsFeed::-webkit-scrollbar-track,
  #healthLogs::-webkit-scrollbar-track,
  .table-scroll::-webkit-scrollbar-track,
  .stack-scroll::-webkit-scrollbar-track {
    background: var(--bg);
    border-radius: 5px;
  }
  html::-webkit-scrollbar-thumb,
  body::-webkit-scrollbar-thumb,
  .main::-webkit-scrollbar-thumb,
  .sidebar::-webkit-scrollbar-thumb,
  .nav-submenu::-webkit-scrollbar-thumb,
  .drawer-body::-webkit-scrollbar-thumb,
  #cryptoFeed::-webkit-scrollbar-thumb,
  #sportsFeed::-webkit-scrollbar-thumb,
  #healthLogs::-webkit-scrollbar-thumb,
  .table-scroll::-webkit-scrollbar-thumb,
  .stack-scroll::-webkit-scrollbar-thumb {
    background: var(--mint-tint);
    border-radius: 5px;
    border: 2px solid var(--bg);
  }
  html::-webkit-scrollbar-thumb:hover,
  body::-webkit-scrollbar-thumb:hover,
  .main::-webkit-scrollbar-thumb:hover,
  .sidebar::-webkit-scrollbar-thumb:hover,
  .nav-submenu::-webkit-scrollbar-thumb:hover,
  .drawer-body::-webkit-scrollbar-thumb:hover,
  #cryptoFeed::-webkit-scrollbar-thumb:hover,
  #sportsFeed::-webkit-scrollbar-thumb:hover,
  #healthLogs::-webkit-scrollbar-thumb:hover,
  .table-scroll::-webkit-scrollbar-thumb:hover,
  .stack-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--mint);
  }
  html,
  body,
  .main,
  .sidebar,
  .nav-submenu,
  .drawer-body,
  #cryptoFeed,
  #sportsFeed,
  #healthLogs,
  .table-scroll,
  .stack-scroll {
    scrollbar-width: thin;
    scrollbar-color: var(--mint-tint) var(--bg);
  }
  .tag {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: 6px;
    font-size: 11px; font-weight: 600;
  }
  .tag.mint { background: var(--mint-tint); color: var(--mint-deep); }
  .tag.green { background: var(--green-tint); color: var(--green); }
  .tag.red { background: var(--red-tint); color: var(--red); }
  .tag.amber { background: #FFF5E6; color: #D69E2E; }
  .tag.blue { background: #EBF4FF; color: #4C51BF; }
  .tag.purple { background: #F3E8FF; color: #7E22CE; }
  .tag.gray { background: var(--bg); color: var(--muted); }

  /* ----- Progress bar ----- */
  .pbar { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
  .pbar-fill { height: 100%; background: var(--mint); border-radius: 3px; transition: width 0.4s; }
  .pbar-fill.amber { background: #FFB547; }
  .pbar-fill.red { background: var(--red); }
  .pbar-fill.blue { background: #667EEA; }
  .pbar-fill.green { background: var(--green); }

  /* ----- Section grid 3-col ----- */
  .grid-three { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; margin-bottom: 24px; }
  .grid-onethird-twothirds { display: grid; grid-template-columns: 1fr 2fr; gap: 20px; margin-bottom: 24px; }

  /* ----- Toggle switch ----- */
  .toggle { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
  .toggle input { display: none; }
  .toggle-slider {
    position: absolute; inset: 0;
    background: #CBD5E0; border-radius: var(--radius-pill);
    transition: background 0.2s; cursor: pointer;
  }
  .toggle-slider::after {
    content: ''; position: absolute; top: 2px; left: 2px;
    width: 16px; height: 16px; border-radius: 50%;
    background: white; box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    transition: transform 0.2s;
  }
  .toggle input:checked + .toggle-slider { background: var(--mint); }
  .toggle input:checked + .toggle-slider::after { transform: translateX(16px); }

  /* ----- Filter bar ----- */
  .filter-bar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 14px 18px;
    background: var(--card); border: 1px solid var(--divider);
    border-radius: var(--radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
  }
  .filter-label {
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--muted);
    margin-right: 4px;
  }
  .filter-select, .filter-input {
    padding: 6px 12px; border-radius: 8px;
    border: 1px solid var(--divider);
    background: var(--bg); font-size: 12.5px;
    color: var(--text); font-family: inherit;
    font-weight: 500;
    outline: none;
    transition: all 0.15s;
  }
  .filter-select:focus, .filter-input:focus { border-color: var(--mint); background: white; box-shadow: 0 0 0 3px rgba(79,209,197,0.12); }
  .sports-mode-picker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    border-radius: 10px;
    border: 1px solid var(--divider);
    background: var(--card);
    box-shadow: var(--shadow-sm);
  }
  .sports-mode-picker .filter-label {
    margin-right: 0;
    white-space: nowrap;
  }
  .sports-mode-select {
    min-width: 88px;
    padding: 5px 28px 5px 10px;
    border-radius: 8px;
    background: transparent;
    border: 0;
    box-shadow: none;
  }
  .sports-mode-select:focus {
    background: white;
    border: 1px solid rgba(79,209,197,0.35);
    box-shadow: 0 0 0 3px rgba(79,209,197,0.12);
  }
  .btn-sm {
    padding: 6px 14px; border-radius: 8px;
    font-size: 12px; font-weight: 600;
    background: linear-gradient(135deg, var(--mint) 0%, var(--mint-dark) 100%);
    color: white;
    cursor: pointer;
    transition: all 0.15s;
    outline: none; border: 1px solid transparent;
  }
  .btn-sm:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(79,209,197,0.3); }
  .btn-sm:focus-visible { box-shadow: 0 0 0 3px rgba(79,209,197,0.28); border-color: rgba(79,209,197,0.55); }
  .btn-sm.ghost { background: var(--card); color: var(--text-soft); border: 1px solid var(--divider); box-shadow: var(--shadow-sm); }
  .btn-sm.ghost:hover { background: var(--mint-tint); color: var(--mint-deep); border-color: var(--mint); }
  .btn-sm.ghost:focus-visible { box-shadow: 0 0 0 3px rgba(79,209,197,0.28); border-color: rgba(79,209,197,0.55); }

  /* ----- PSA Vault desk ----- */
  .psa-provider-card { margin-bottom: 18px; padding: 14px 16px; }
  #page-psa-vault .topbar { flex-wrap: wrap; }
  #page-psa-vault .topbar .page-title { min-width: 260px; }
  #page-psa-vault .topbar-right {
    flex-wrap: wrap;
    justify-content: flex-end;
    min-width: 0;
  }
  .psa-provider-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }
  .psa-provider-link {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 12px 14px;
    border: 1px solid var(--divider);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, transform 0.15s;
  }
  .psa-provider-link:hover {
    background: var(--mint-tint);
    border-color: rgba(79,209,197,0.45);
    transform: translateY(-1px);
  }
  .psa-provider-mark {
    width: 44px;
    height: 30px;
    border-radius: 7px;
    background: white;
    border: 1px solid var(--divider);
    display: grid;
    place-items: center;
    padding: 3px;
    flex: 0 0 auto;
  }
  .psa-provider-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
  .psa-provider-link strong { display: block; font-size: 13px; font-weight: 800; line-height: 1.15; }
  .psa-provider-link small { display: block; margin-top: 2px; color: var(--muted); font-size: 11.5px; line-height: 1.25; }
  .psa-research-band {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 0 0 18px;
  }
  .psa-research-band > div {
    min-width: 0;
    padding: 14px 16px;
    border: 1px solid var(--divider);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 22px rgba(26,32,44,0.04);
  }
  .psa-research-band span {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }
  .psa-research-band strong {
    display: block;
    color: var(--text);
    font-size: 12.3px;
    line-height: 1.35;
  }
  .psa-control-card { margin-bottom: 20px; padding: 18px 18px 20px; }
  .psa-control-grid,
  .psa-calc-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(112px, 1fr));
    gap: 12px;
  }
  .psa-calc-grid { grid-template-columns: repeat(4, minmax(140px, 1fr)); }
  .psa-control {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
  }
  .psa-control > span {
    font-size: 10.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
  }
  .psa-control .filter-select,
  .psa-control .filter-input {
    width: 100%;
    min-height: 36px;
    flex: 0 0 auto;
  }
  .psa-import-card,
  .psa-comps-card,
  .psa-workflow-card {
    margin: 24px 0;
  }
  .psa-import-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(118px, 1fr));
    gap: 12px;
  }
  .psa-import-grid .psa-wide {
    grid-column: span 2;
  }
  .psa-check-panel {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 14px;
    padding: 12px 14px;
    border: 1px solid var(--divider);
    border-radius: 8px;
    background: var(--bg);
  }
  .psa-check-panel > div {
    min-width: 220px;
    flex: 1 1 260px;
  }
  .psa-check-panel strong {
    display: block;
    font-size: 12.8px;
    line-height: 1.25;
  }
  .psa-check-panel span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 11.5px;
    line-height: 1.35;
  }
  .psa-check-panel label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
    padding: 5px 8px;
    border-radius: 7px;
    background: #fff;
    border: 1px solid var(--divider);
    color: var(--text-soft);
    font-size: 11.5px;
    font-weight: 800;
    white-space: nowrap;
  }
  .psa-check-panel input { accent-color: var(--mint); }
  .psa-comps-target {
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 11px 13px;
    border: 1px solid var(--divider);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text-soft);
    font-size: 12.5px;
    font-weight: 800;
    line-height: 1.35;
  }
  .psa-comps-input {
    width: 100%;
    min-height: 130px;
    margin-top: 12px;
    padding: 12px 13px;
    border: 1px solid var(--divider);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font: 12.5px/1.45 'Inter', system-ui, sans-serif;
    resize: vertical;
    outline: none;
  }
  .psa-comps-input:focus {
    border-color: var(--mint);
    box-shadow: 0 0 0 3px rgba(48, 196, 181, 0.12);
  }
  .psa-comps-result {
    min-height: 22px;
    margin-top: 9px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
  }
  .psa-comps-result strong { color: var(--text); }
  .psa-deal-table {
    min-width: 980px;
    table-layout: fixed;
  }
  .psa-deal-table th:nth-child(1) { width: 30%; }
  .psa-deal-table th:nth-child(2) { width: 12%; }
  .psa-deal-table th:nth-child(3) { width: 22%; }
  .psa-deal-table th:nth-child(4) { width: 12%; }
  .psa-deal-table th:nth-child(5) { width: 13%; }
  .psa-deal-table th:nth-child(6) { width: 11%; }
  .psa-deal-table td { vertical-align: top; }
  .psa-card-cell {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
  }
  .psa-card-badge {
    width: 42px;
    height: 48px;
    border-radius: 8px;
    background: linear-gradient(145deg, #ffffff 0%, #fff 44%, #1f2937 45%, #111827 100%);
    border: 1px solid var(--divider);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 5px 4px 4px;
    color: white;
    font-weight: 900;
    font-size: 11px;
    flex: 0 0 auto;
    box-shadow: 0 2px 6px rgba(26,32,44,0.08);
  }
  .psa-card-badge img {
    width: 32px;
    height: 18px;
    object-fit: contain;
    display: block;
    border-radius: 2px;
  }
  .psa-card-badge span {
    margin-top: 9px;
    color: white;
    line-height: 1;
  }
  .psa-card-thumb {
    width: 46px;
    height: 58px;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--divider);
    box-shadow: 0 2px 6px rgba(26,32,44,0.08);
    flex: 0 0 auto;
  }
  .psa-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }
  .psa-deal-title { font-weight: 800; font-size: 13px; line-height: 1.25; color: var(--text); text-decoration: none; }
  .psa-deal-title:hover { color: var(--mint-deep); text-decoration: underline; text-underline-offset: 2px; }
  .psa-deal-meta { margin-top: 4px; font-size: 11.5px; color: var(--muted); line-height: 1.35; }
  .psa-source-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
  }
  .psa-source-row span {
    display: inline-flex;
    align-items: center;
    min-height: 20px;
    padding: 2px 7px;
    border-radius: 6px;
    background: #F7FAFC;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 800;
  }
  .psa-history-list {
    display: grid;
    gap: 4px;
    margin-top: 7px;
    min-width: 150px;
  }
  .psa-history-row {
    display: grid;
    grid-template-columns: 44px 68px minmax(80px, 1fr);
    gap: 6px;
    align-items: center;
    font-size: 11px;
    color: var(--muted);
  }
  .psa-history-row strong {
    color: var(--text);
    font-size: 11px;
  }
  .psa-history-row em {
    font-style: normal;
    line-height: 1.25;
  }
  .psa-deal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 120px;
  }
  .psa-score {
    display: inline-grid;
    place-items: center;
    min-width: 42px;
    height: 28px;
    border-radius: 8px;
    background: var(--mint-tint);
    color: var(--mint-deep);
    font-weight: 900;
  }
  .psa-score.hot { background: #FEF3C7; color: #B45309; }
  .psa-score.warm { background: #EBF4FF; color: #4C51BF; }
  .psa-typo-list,
  .psa-watch-grid {
    display: grid;
    gap: 10px;
  }
  .psa-typo-item,
  .psa-watch-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--divider);
    border-radius: 8px;
    background: var(--bg);
  }
  .psa-typo-item strong,
  .psa-watch-item strong { display: block; font-size: 12.8px; line-height: 1.25; }
  .psa-typo-item span,
  .psa-watch-item span { display: block; margin-top: 3px; font-size: 11.5px; color: var(--muted); line-height: 1.35; }
  .psa-empty-state {
    padding: 22px 18px;
    border: 1px dashed var(--divider);
    border-radius: 8px;
    background: var(--bg);
    color: var(--muted);
    text-align: center;
    font-size: 12.5px;
  }
  .psa-output-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 16px;
  }
  .psa-output {
    padding: 14px;
    border: 1px solid var(--divider);
    border-radius: 8px;
    background: var(--bg);
  }
  .psa-output span {
    display: block;
    font-size: 10.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 6px;
  }
  .psa-output strong { font-size: 18px; color: var(--text); }
  .psa-workflow-board {
    display: grid;
    grid-template-columns: repeat(6, minmax(130px, 1fr));
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 2px;
  }
  .psa-workflow-column {
    min-width: 130px;
    padding: 10px;
    border: 1px solid var(--divider);
    border-radius: 8px;
    background: var(--bg);
  }
  .psa-workflow-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }
  .psa-workflow-title span:last-child {
    min-width: 22px;
    height: 22px;
    display: inline-grid;
    place-items: center;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--divider);
    color: var(--text);
    letter-spacing: 0;
  }
  .psa-flow-list {
    display: grid;
    gap: 8px;
  }
  .psa-flow-card {
    padding: 10px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--divider);
    box-shadow: 0 3px 10px rgba(26,32,44,0.04);
  }
  .psa-flow-card strong {
    display: block;
    color: var(--text);
    font-size: 12px;
    line-height: 1.25;
  }
  .psa-flow-card span {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.35;
  }
  .psa-flow-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 8px;
  }
  .psa-flow-actions .btn-sm {
    min-height: 28px;
    padding: 5px 8px;
    font-size: 11px;
  }

  /* ----- Live dot ----- */
  .live-dot {
    display: inline-block;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--green); flex-shrink: 0;
    box-shadow: 0 0 0 3px rgba(1,181,116,0.18);
    animation: pulse 1.8s infinite;
    vertical-align: middle;
    margin: 0 8px 0 4px;
  }
  .live-dot.red { background: var(--red); box-shadow: 0 0 0 3px rgba(227,26,26,0.2); }
  .live-dot.amber { background: #FFB547; box-shadow: 0 0 0 3px rgba(255,181,71,0.2); }

  /* ----- Section header ----- */
  .section-head {
    display: flex; align-items: center; justify-content: space-between;
    margin: 8px 0 14px;
  }
  .section-head h2 {
    font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
  }
  .section-head .card-sub { margin-top: 2px; }

  /* ----- Asset icons (crypto + stocks + sports) ----- */
  .a-icon {
    border-radius: 10px;
    display: grid; place-items: center;
    color: white; font-weight: 700;
    flex-shrink: 0; overflow: hidden;
    background: white;
    border: 1px solid #EDF2F7;
    box-shadow: 0 1px 2px rgba(26,32,44,0.05);
  }
  .a-icon svg { width: 78%; height: 78%; display: block; }
  .a-icon img { width: 82%; height: 82%; object-fit: contain; display: block; }
  .a-icon.fallback {
    background: linear-gradient(135deg,#A0AEC0,#718096);
    border: none;
  }

  /* ----- Coin chip (legacy — kept for lane-row indicators) ----- */
  .coin-chip {
    width: 34px; height: 34px; border-radius: 10px;
    display: grid; place-items: center;
    color: white; font-weight: 700; font-size: 11px;
    flex-shrink: 0;
  }
  .coin-chip.btc { background: linear-gradient(135deg, #F7931A 0%, #E37B00 100%); }
  .coin-chip.eth { background: linear-gradient(135deg, #627EEA 0%, #4557C9 100%); }
  .coin-chip.sol { background: linear-gradient(135deg, #9945FF 0%, #14F195 100%); }
  .coin-chip.xrp { background: linear-gradient(135deg, #000 0%, #333 100%); }
  .coin-chip.doge { background: linear-gradient(135deg, #C2A633 0%, #A68F28 100%); }
  .coin-chip.bnb { background: linear-gradient(135deg, #F3BA2F 0%, #D4A017 100%); }
  .coin-chip.hype { background: linear-gradient(135deg, #97FCE4 0%, #4FD1C5 100%); color: #1A202C; }

  /* ----- Big number display ----- */
  .big-num-row {
    display: flex; align-items: baseline; gap: 12px;
    margin-bottom: 6px;
  }
  .big-num {
    font-size: 34px; font-weight: 700;
    letter-spacing: -0.02em;
  }

  /* ----- Settings ----- */
  .settings-tab {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 10px;
    font-size: 13.5px; font-weight: 500;
    color: var(--text-soft);
    background: transparent; border: none; cursor: pointer;
    text-align: left; width: 100%;
    transition: all 0.15s;
  }
  .settings-tab:hover { background: var(--mint-tint); color: var(--mint-deep); }
  .settings-tab.active {
    background: linear-gradient(135deg, var(--mint) 0%, var(--mint-dark) 100%);
    color: white; font-weight: 600;
    box-shadow: 0 4px 10px rgba(79,209,197,0.25);
  }
  .settings-tab svg { width: 16px; height: 16px; flex-shrink: 0; }
  .settings-panel { display: none; }
  .settings-panel.active { display: block; }
  .settings-label {
    display: block; font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--muted); margin-bottom: 6px;
  }
  .settings-input {
    width: 100%; padding: 10px 14px; border-radius: 10px;
    border: 1px solid var(--divider);
    background: var(--bg); font-size: 13.5px;
    color: var(--text); font-family: inherit;
    outline: none; transition: all 0.15s;
  }
  .settings-input:focus { border-color: var(--mint); background: white; box-shadow: 0 0 0 3px rgba(79,209,197,0.12); }
  .api-row, .notif-row, .team-row, .danger-row {
    display: flex; align-items: center; gap: 12px;
    padding: 14px; background: var(--bg); border-radius: 12px;
  }
  .api-left { flex: 1; }
  .api-name { font-weight: 600; font-size: 13.5px; }
  .api-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
  .notif-title { font-weight: 600; font-size: 13.5px; }
  .notif-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

  /* ----- P&L history drill-in (crypto-pnl / sports-pnl) ----- */
  .pnl-summary {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
    margin-bottom: 14px;
  }
  .pnl-summary .stat-box { padding: 12px; }
  .pnl-spark {
    width: 100%; height: 70px;
    background: var(--bg); border-radius: 10px; padding: 8px 10px;
    margin-bottom: 14px;
  }
  .pnl-spark svg { width: 100%; height: 100%; display: block; }
  .pnl-period-tabs {
    display: flex; gap: 6px;
    background: var(--bg); padding: 4px; border-radius: 10px;
    margin-bottom: 12px;
  }
  .ppt {
    flex: 1; padding: 6px 10px; font-size: 12px; font-weight: 600;
    color: var(--text-soft); background: transparent;
    border: 1px solid transparent; border-radius: 7px;
    cursor: pointer; transition: all 0.15s;
    outline: none;
  }
  .ppt:hover { color: var(--mint-deep); }
  .ppt.active {
    background: white; color: var(--text);
    box-shadow: 0 1px 3px rgba(26,32,44,0.08);
  }
  .ppt:focus-visible { box-shadow: 0 0 0 3px rgba(79,209,197,0.28); border-color: rgba(79,209,197,0.55); }
  .pnl-panel { display: none; }
  .pnl-panel.active { display: block; }
  .pnl-table {
    background: var(--bg); border-radius: 10px;
    padding: 6px 0;
    max-height: 360px; overflow-y: auto;
  }
  .pnl-row {
    display: grid;
    grid-template-columns: 80px 64px 84px 1fr;
    align-items: center;
    padding: 8px 14px;
    font-size: 12.5px;
    border-bottom: 1px solid var(--divider);
  }
  .pnl-row:last-child { border-bottom: none; }
  .pnl-row.today { background: var(--mint-tint); font-weight: 600; }
  .pnl-row .pnl-date { color: var(--text-soft); font-variant-numeric: tabular-nums; }
  .pnl-row .pnl-result { font-size: 11px; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; }
  .pnl-row .pnl-result.win { color: var(--green); }
  .pnl-row .pnl-result.loss { color: var(--red); }
  .pnl-row .pnl-val { font-variant-numeric: tabular-nums; font-family: var(--font-mono, ui-monospace, Menlo, monospace); text-align: right; font-weight: 600; }
  .pnl-row .pnl-val.win { color: var(--green); }
  .pnl-row .pnl-val.loss { color: var(--red); }
  .pnl-row .pnl-meta { color: var(--muted); font-size: 11.5px; text-align: right; }

  /* ================================================================
     MOBILE + TABLET (≤900px)
     Desktop-only UI (mobile-topbar, mobile-scrim, bottom-nav) is
     hidden by default; shown only in the media query below.
     ================================================================ */
  .mobile-topbar { display: none; }
  .mobile-scrim { display: none; }
  .bottom-nav { display: none; }
  .app-install-control[hidden] { display: none !important; }
  .app-offline-bar[hidden],
  .app-status-toast[hidden] { display: none !important; }
  .app-offline-bar {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 16px;
    z-index: 120;
    padding: 10px 14px;
    border-radius: 12px;
    background: #1A202C;
    color: #fff;
    box-shadow: 0 16px 34px rgba(26,32,44,0.22);
    font-size: 12.5px;
    font-weight: 700;
    text-align: center;
  }
  .app-status-toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 130;
    max-width: min(360px, calc(100vw - 32px));
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--mint-deep);
    color: #fff;
    box-shadow: 0 16px 34px rgba(26,32,44,0.22);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.35;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }
  .app-status-toast button {
    min-height: 32px;
    padding: 6px 10px;
    border-radius: 8px;
    background: rgba(255,255,255,0.18);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
  }

  @media (max-width: 900px) {
    html { -webkit-text-size-adjust: 100%; }
    body {
      /* Prevent horizontal overflow; leave room for bottom nav + home bar */
      overflow-x: hidden;
    }

    /* App becomes single-column; sidebar becomes a slide-in drawer */
    .app { grid-template-columns: 1fr; }

    /* ---------- Sidebar → mobile drawer ---------- */
    .sidebar {
      position: fixed;
      top: 0; left: 0; bottom: 0;
      width: 278px; max-width: 85vw;
      height: 100vh; height: 100dvh;
      padding: calc(env(safe-area-inset-top) + 20px) 18px calc(env(safe-area-inset-bottom) + 20px);
      transform: translateX(-100%);
      transition: transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
      z-index: 90;
      box-shadow: 4px 0 24px rgba(26,32,44,0.18);
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
    }
    .sidebar.open { transform: translateX(0); }

    .mobile-scrim {
      display: block;
      position: fixed; inset: 0;
      background: rgba(26,32,44,0.48);
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.24s ease;
      z-index: 80;
      backdrop-filter: blur(2px);
      -webkit-backdrop-filter: blur(2px);
    }
    .mobile-scrim.open { opacity: 1; pointer-events: auto; }

    /* ---------- Mobile topbar (fixed, replaces page topbars visually) ---------- */
    .mobile-topbar {
      display: flex;
      align-items: center;
      gap: 10px;
      position: sticky;
      top: 0;
      padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
      background: rgba(255,255,255,0.92);
      backdrop-filter: saturate(160%) blur(8px);
      -webkit-backdrop-filter: saturate(160%) blur(8px);
      border-bottom: 1px solid var(--divider);
      z-index: 50;
    }
    .mobile-hamburger {
      width: 44px; height: 44px;
      border-radius: 12px;
      background: var(--card);
      border: 1px solid var(--divider);
      display: grid; place-items: center;
      color: var(--text);
      flex-shrink: 0;
      box-shadow: var(--shadow-sm);
    }
    .mobile-hamburger:active { transform: scale(0.96); }
    .mobile-hamburger svg { width: 20px; height: 20px; }
    .mobile-brand {
      display: flex; align-items: center; gap: 9px;
      flex: 1; min-width: 0;
    }
    .mobile-brand-mark {
      width: 32px; height: 32px; border-radius: 9px;
      background: linear-gradient(135deg, var(--mint) 0%, var(--mint-dark) 100%);
      display: grid; place-items: center;
      box-shadow: 0 3px 8px rgba(79,209,197,0.3);
      flex-shrink: 0;
    }
    .mobile-brand-mark img { width: 20px; height: 20px; }
    .mobile-brand-name {
      font-weight: 700;
      font-size: 15px;
      letter-spacing: -0.01em;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .mobile-topbar-btn {
      width: 44px; height: 44px; border-radius: 12px;
      background: var(--card); border: 1px solid var(--divider);
      display: grid; place-items: center;
      box-shadow: var(--shadow-sm);
      position: relative;
      flex-shrink: 0;
    }
    .mobile-topbar-btn:active { transform: scale(0.96); }
    .mobile-topbar-btn.install {
      color: var(--mint-deep);
    }
    .mobile-topbar-btn.install svg {
      width: 19px;
      height: 19px;
    }
    .mobile-live-dot {
      width: 10px; height: 10px; border-radius: 50%;
      background: var(--green);
      box-shadow: 0 0 0 3px rgba(1,181,116,0.2);
      animation: pulse 1.8s infinite;
    }

    /* ---------- Main content ---------- */
    .main {
      padding: 16px 14px calc(env(safe-area-inset-bottom) + 100px);
      max-width: 100%;
    }

    /* Hide the per-page topbar content on mobile; mobile-topbar replaces it.
       We keep page-title H1 + subtitle visible because they introduce each page. */
    .topbar {
      flex-direction: column;
      align-items: flex-start;
      gap: 12px;
      margin-bottom: 18px;
    }
    .topbar-right {
      display: none; /* search/live/settings/user all accessible via sidebar drawer */
    }
    .page-title h1 { font-size: 22px; }
    .page-title p { font-size: 12.5px; }

    /* ---------- KPIs ---------- */
    .kpi-row {
      grid-template-columns: 1fr 1fr;
      gap: 12px;
      margin-bottom: 18px;
    }
    .kpi {
      padding: 16px 16px 14px;
      border-radius: 14px;
    }
    .kpi-value { font-size: 22px; }
    .kpi-label { font-size: 10px; margin-bottom: 6px; }
    .kpi-icon { width: 28px; height: 28px; }

    /* ---------- Focus row collapses to 1 col on phone ---------- */
    .focus-row {
      grid-template-columns: 1fr;
      gap: 12px;
      margin-bottom: 18px;
    }
    .focus { padding: 14px 14px 12px; border-radius: 14px; }
    .focus-headline { font-size: 18px; }
    #page-health .health-focus-row { grid-template-columns: 1fr 1fr; }
    #page-health .health-detail-grid { grid-template-columns: 1fr; }
    #page-health .health-services-scroll {
      max-height: 480px;
      overflow-x: auto;
    }
    #page-health .health-services-table { min-width: 760px; }

    /* Hero KPI spans full width on narrow phones */
    .kpi.hero { grid-column: 1 / -1; }

    /* ---------- Bot tiles ---------- */
    .bot-row { grid-template-columns: 1fr; gap: 12px; margin-bottom: 20px; }
    .bot-tile { padding: 16px; border-radius: 14px; }
    .bot-stats { gap: 8px; }
    .bot-stat-value { font-size: 15px; }

    /* ---------- Grids collapse ---------- */
    .grid-two,
    .grid-onethird-twothirds,
    .grid-three { grid-template-columns: 1fr; gap: 14px; margin-bottom: 18px; }

    .psa-provider-strip,
    .psa-research-band,
    .psa-control-grid,
    .psa-import-grid,
    .psa-calc-grid,
    .psa-output-grid,
    .psa-workflow-board { grid-template-columns: 1fr; }
    .psa-import-grid .psa-wide { grid-column: span 1; }
    .psa-provider-card,
    .psa-control-card { padding: 14px; }
    .psa-provider-link,
    .psa-typo-item,
    .psa-watch-item { align-items: flex-start; }
    .psa-deal-table { min-width: 980px; }

    /* ---------- Cards ---------- */
    .card { padding: 16px; border-radius: 14px; }
    .card-header {
      flex-wrap: wrap;
      gap: 10px;
      margin-bottom: 14px;
    }
    .card-title { font-size: 14px; }

    /* ---------- Filter bar ---------- */
    .filter-bar {
      padding: 12px;
      gap: 8px;
      border-radius: 14px;
      margin-bottom: 14px;
    }
    .filter-select, .filter-input {
      min-height: 40px;
      font-size: 13px;
      padding: 8px 12px;
      flex: 1 1 120px;
    }
    .filter-label { font-size: 10px; width: 100%; }
    .btn-sm { min-height: 40px; padding: 9px 16px; font-size: 13px; }

    /* ---------- Tables: make horizontally scrollable with hint ---------- */
    .card .table-scroll,
    .card .stack-scroll {
      overflow-x: auto;
      overflow-y: auto;
      -webkit-overflow-scrolling: touch;
      scrollbar-gutter: auto;
      padding-right: 0;
    }
    .card .table-scroll-5,
    .card .table-scroll-6,
    .card .stack-scroll-5,
    .card .stack-scroll-6 { max-height: 380px; }
    .card .psa-deal-scroll {
      max-height: 70vh;
      min-height: 480px;
    }

    .data-table { min-width: 560px; font-size: 12.5px; }
    .data-table th { padding: 10px 10px; font-size: 10.5px; }
    .data-table td { padding: 10px; }

    /* Give mobile tables a subtle right-edge fade to hint at scroll */
    .card { position: relative; }
    .card .table-scroll::after,
    .card .stack-scroll::after {
      content: none; /* optional; disabled for now to keep layout predictable */
    }

    /* ---------- Trade rows ---------- */
    .trade-row {
      grid-template-columns: 32px 1fr auto;
      gap: 10px;
      padding: 10px 6px;
    }
    .trade-row .trade-size { display: none; }
    .trade-main-label { font-size: 13px; }
    .trade-meta { font-size: 11px; }

    /* ---------- Drawer: go full-width, leave room for bottom nav ---------- */
    .drawer {
      width: 100%; max-width: 100vw;
      border-radius: 0;
    }
    .drawer-header {
      padding: calc(env(safe-area-inset-top) + 14px) 16px 14px;
    }
    .drawer-body {
      padding: 16px 16px calc(env(safe-area-inset-bottom) + 90px);
    }
    .drawer-title { font-size: 16px; }

    /* ---------- Radial / stat boxes ---------- */
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .pnl-summary { grid-template-columns: 1fr 1fr; gap: 8px; }

    /* ---------- Chart heights ---------- */
    .chart-wrap { height: 200px; }

    /* ---------- Sidebar footer (hide promo card, cramped on mobile) ---------- */
    .sidebar-footer { margin-top: 16px; }

    /* ---------- Settings: full-width tabs ---------- */
    .settings-tab { min-height: 44px; }
    .settings-input { min-height: 44px; }

    /* ---------- Chips: larger hit area ---------- */
    .chip { min-height: 32px; padding: 7px 13px; font-size: 12.5px; }

    /* ---------- Dropdown (user menu) - if it leaks through ---------- */
    .user-dropdown { min-width: 260px; right: auto; left: 0; }

    /* ---------- Bottom navigation ---------- */
    .bottom-nav {
      display: flex;
      position: fixed;
      bottom: 0; left: 0; right: 0;
      padding: 6px 6px calc(env(safe-area-inset-bottom) + 6px);
      background: rgba(255,255,255,0.96);
      backdrop-filter: saturate(160%) blur(10px);
      -webkit-backdrop-filter: saturate(160%) blur(10px);
      border-top: 1px solid var(--divider);
      box-shadow: 0 -4px 20px rgba(26,32,44,0.06);
      z-index: 60;
      justify-content: space-around;
      align-items: stretch;
      gap: 2px;
    }
    .bn-item {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 3px;
      padding: 8px 4px;
      min-height: 52px;
      border-radius: 10px;
      color: var(--muted);
      font-size: 10.5px;
      font-weight: 600;
      letter-spacing: 0.01em;
      transition: background 0.14s ease, color 0.14s ease, transform 0.1s ease;
    }
    .bn-item svg { width: 20px; height: 20px; }
    .bn-item:active { transform: scale(0.94); }
    .bn-item.active {
      color: var(--mint-deep);
      background: var(--mint-tint);
    }
    .bn-item.active svg { color: var(--mint-deep); }
    .app-offline-bar {
      left: 10px;
      right: 10px;
      bottom: calc(env(safe-area-inset-bottom) + 78px);
    }
    .app-status-toast {
      left: 10px;
      right: 10px;
      bottom: calc(env(safe-area-inset-bottom) + 78px);
      max-width: none;
      text-align: center;
      justify-content: center;
      flex-wrap: wrap;
    }

    /* ---------- Scrollbar hygiene on mobile (hide the chunky one used on desktop) ---------- */
    .table-scroll::-webkit-scrollbar,
    .stack-scroll::-webkit-scrollbar { height: 4px; width: 4px; }
    .table-scroll, .stack-scroll { scrollbar-width: thin; }
  }

  /* ================================================================
     NARROW PHONE (≤480px) — one-column KPIs, tighter type
     ================================================================ */
  @media (max-width: 480px) {
    .kpi-row { grid-template-columns: 1fr; }
    .kpi.hero { grid-column: auto; }
    #page-health .health-focus-row { grid-template-columns: 1fr; }
    .big-num { font-size: 26px; }
    .page-title h1 { font-size: 19px; }
    .page-title p { font-size: 12px; }
    .main { padding: 14px 12px calc(env(safe-area-inset-bottom) + 96px); }
    .mobile-topbar { padding-left: 10px; padding-right: 10px; }
    .bn-item span { font-size: 10px; }
  }

  /* ================================================================
     STANDALONE PWA (Add to Home Screen) polish
     ================================================================ */
  @media all and (display-mode: standalone) {
    body { user-select: none; -webkit-user-select: none; }
    .mobile-topbar { background: rgba(255,255,255,0.98); }
    .app-install-control { display: none !important; }
  }

  /* ================================================================
     TOUCH-FIRST tap targets (applies on any coarse pointer)
     ================================================================ */
  @media (pointer: coarse) {
    .nav-item { min-height: 44px; padding: 12px; }
    .nav-subitem { min-height: 40px; }
    .dropdown-item { min-height: 40px; }
    .icon-btn { width: 42px; height: 42px; }
    button, .chip, .bn-item { touch-action: manipulation; }
  }
