/* ============================================================
     PAGE / SHELL
     ============================================================ */
  body {
    margin: 0;
    background: #F2F2F7;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
    color: #000;
    -webkit-font-smoothing: antialiased;
  }
  main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  /* ============================================================
     PAGE HEADER (KevBot brand + status)
     ============================================================ */
  .page-header { padding: 4px 4px 0; }
  .header-row-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }
  .brand {
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.4px;
    color: #000;
    margin: 0;
  }
  .header-row-ops {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    flex-wrap: wrap;
    font-size: 12px;
    color: #3C3C43;
  }
  .header-sep {
    width: 1px;
    height: 12px;
    background: rgba(60, 60, 67, 0.18);
    flex-shrink: 0;
  }
  .brand-sub {
    font-size: 12px;
    font-weight: 500;
    color: #8E8E93;
  }
  @media (min-width: 720px) {
    .page-header { padding: 8px 4px 0; }
    .brand { font-size: 30px; }
  }

  .op-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    color: #000;
    font-size: 12px;
  }
  .op-status .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
  }
  .op-status.running .dot { background: #30B65A; }
  .op-status.paused  .dot { background: #FF9500; }
  .op-status.killed  .dot { background: #FF3B30; }
  .op-status.paused  { color: #B45A00; }
  .op-status.killed  { color: #C82C24; }
  .op-meta {
    font-size: 11px;
    color: #8E8E93;
    font-variant-numeric: tabular-nums;
  }

  .pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    line-height: 1.6;
    font-weight: 500;
    letter-spacing: 0.2px;
    background: #F2F2F7;
    color: #3C3C43;
    border: none;
    font-family: inherit;
    font-variant-numeric: tabular-nums;
  }
  .pill-log      { background: #F2F2F7; color: #3C3C43; cursor: pointer; }
  .pill-log.warn { background: #FFF4E5; color: #A25C09; }
  .pill-log.err  { background: #FFE5E3; color: #C82C24; }
  .pill-log:hover { filter: brightness(0.97); }

  /* Risk tier badge (header) */
  .op-tier {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
    font-size: 11px;
  }
  .tier-num {
    background: #E8F1FF;
    color: #0A66C2;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.3px;
  }
  .tier-max {
    color: #8E8E93;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
  }

  /* Feed health row + cycle status (header sub-rows) */
  .feed-status {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 6px;
    font-size: 11px;
    color: #3C3C43;
  }
  .feed-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 500;
  }
  .feed-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
  }
  .feed-ok   .feed-dot { background: #30B65A; }
  .feed-warn .feed-dot { background: #FF9500; }
  .feed-err  .feed-dot { background: #FF3B30; }
  .feed-warn { color: #B45A00; }
  .feed-err  { color: #C82C24; }
  .feed-age {
    color: #8E8E93;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    margin-left: 1px;
  }
  .cycle-status {
    margin-top: 4px;
    font-size: 11px;
    color: #3C3C43;
  }
  .cycle-label {
    color: #8E8E93;
    font-weight: 500;
    margin-right: 4px;
  }
  .cycle-text {
    font-weight: 500;
  }
  .cycle-text .cycle-reason {
    color: #8E8E93;
    font-weight: 400;
  }

  /* Log drawer (toggled by WARN/ERR pill click) */
  .log-drawer {
    background: #FFFFFF;
    border-radius: 14px;
    border: 0.5px solid rgba(60, 60, 67, 0.16);
    padding: 14px 18px;
  }
  @media (min-width: 720px) {
    .log-drawer { padding: 14px 22px; }
  }
  .log-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 10px;
  }
  .log-drawer-title {
    font-size: 11px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: #8E8E93;
    font-weight: 500;
  }
  .log-drawer-close {
    font-size: 11px;
    font-weight: 500;
    color: #0A66C2;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: inherit;
  }
  .log-drawer-close:hover { background: rgba(10,102,194,0.08); }
  .log-list {
    display: flex;
    flex-direction: column;
  }
  .log-entry {
    display: grid;
    grid-template-columns: auto auto auto 1fr;
    gap: 10px;
    padding: 7px 0;
    border-top: 0.5px solid rgba(60, 60, 67, 0.06);
    font-size: 11.5px;
    align-items: baseline;
    line-height: 1.4;
  }
  .log-entry:first-child { border-top: none; }
  .log-time {
    color: #8E8E93;
    font-variant-numeric: tabular-nums;
    font-size: 10.5px;
    white-space: nowrap;
  }
  .log-level {
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 0.4px;
    padding: 1px 5px;
    border-radius: 3px;
    text-transform: uppercase;
  }
  .log-warn .log-level { background: #FFF4E5; color: #A25C09; }
  .log-err  .log-level { background: #FFE5E3; color: #C82C24; }
  .log-info .log-level { background: #F2F2F7; color: #3C3C43; }
  .log-source {
    color: #8E8E93;
    font-size: 10.5px;
    font-style: italic;
    white-space: nowrap;
  }
  .log-msg {
    color: #1C1C1E;
    font-size: 11.5px;
  }
  .log-drawer-footer {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 0.5px solid rgba(60, 60, 67, 0.06);
    text-align: center;
  }
  .log-show-all {
    font-size: 11px;
    font-weight: 500;
    color: #0A66C2;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 4px;
    font-family: inherit;
  }
  .log-show-all:hover { background: rgba(10,102,194,0.08); }
  @media (max-width: 540px) {
    .log-entry {
      grid-template-columns: auto auto;
      grid-template-areas:
        "time level"
        "source source"
        "msg msg";
      gap: 4px 10px;
    }
    .log-time   { grid-area: time; }
    .log-level  { grid-area: level; justify-self: start; }
    .log-source { grid-area: source; }
    .log-msg    { grid-area: msg; }
  }

  /* ============================================================
     PANEL SHELL (used by every panel)
     ============================================================ */
  .summary-bar {
    background: #FFFFFF;
    border-radius: 14px;
    border: 0.5px solid rgba(60, 60, 67, 0.16);
    overflow: hidden;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
  }
  .bar-content.collapsed { display: none; }
  .hidden { display: none !important; }

  .bar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 0.5px solid rgba(60, 60, 67, 0.08);
  }
  .summary-bar:has(.bar-content.collapsed) .bar-header {
    border-bottom: none;
  }
  .bar-header-title {
    font-size: 11px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: #8E8E93;
    font-weight: 500;
  }

  .collapse-btn {
    border: none;
    background: rgba(120, 120, 128, 0.12);
    padding: 6px 14px;
    cursor: pointer;
    color: #3C3C43;
    border-radius: 999px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }
  .collapse-btn:hover { background: rgba(120, 120, 128, 0.20); color: #000; }
  .collapse-btn:focus-visible { outline: 2px solid #0A84FF; outline-offset: 2px; }
  .collapse-btn .chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 12px; height: 12px;
    transition: transform 0.2s ease;
  }
  .collapse-btn .chevron svg { width: 12px; height: 12px; display: block; }
  .collapse-btn.collapsed .chevron { transform: rotate(-90deg); }
  .collapse-btn .label-collapsed { display: none; }
  .collapse-btn.collapsed .label-expanded { display: none; }
  .collapse-btn.collapsed .label-collapsed { display: inline; }

  /* ============================================================
     OVERVIEW PANEL
     ============================================================ */
  .hero { padding: 18px 20px 6px; }
  .hero-label {
    font-size: 11px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #8E8E93;
    font-weight: 500;
  }
  .hero-value {
    font-size: 34px;
    font-weight: 600;
    letter-spacing: -0.5px;
    line-height: 1.05;
    color: #000;
    margin-top: 2px;
  }
  .hero-change-primary {
    margin-top: 6px;
    font-size: 15px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
  }
  .hero-change-primary .arrow { font-size: 11px; }
  .hero-change-primary.up   { color: #30B65A; }
  .hero-change-primary.down { color: #FF3B30; }
  .hero-change-primary.flat { color: #8E8E93; }
  .hero-change-primary .window-tag {
    font-size: 11px;
    letter-spacing: 0.3px;
    color: #8E8E93;
    font-weight: 500;
    margin-left: 4px;
  }
  .hero-change-secondary {
    margin-top: 4px;
    font-size: 12px;
    color: #8E8E93;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
    flex-wrap: wrap;
  }
  .hero-change-secondary .arrow { font-size: 9px; }
  .hero-change-secondary .delta-up   { color: #30B65A; }
  .hero-change-secondary .delta-down { color: #FF3B30; }
  .hero-change-secondary .delta-flat { color: #8E8E93; }
  @media (min-width: 720px) {
    .hero { padding: 22px 24px 10px; }
    .hero-value { font-size: 38px; }
    .hero-change-primary { font-size: 16px; }
    .hero-change-secondary { font-size: 13px; }
  }

  /* Chart block (shared between overview portfolio chart and
     live session chart — same shell, different SVG content) */
  .chart-block { padding: 6px 12px 14px; }
  .chart-svg {
    width: 100%;
    height: 220px;
    display: block;
  }
  .session-chart-svg {
    height: auto;
  }
  .chart-meta {
    margin-top: 6px;
    padding: 0 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: #8E8E93;
  }
  @media (min-width: 720px) {
    .chart-block { padding: 8px 18px 14px; }
    .chart-svg   { height: 300px; }
    .session-chart-svg { height: auto; }
  }

  /* Period toggle (Overview only — All-time / 24h) */
  .toggle-wrap {
    display: flex;
    justify-content: center;
    margin-top: 14px;
  }
  .period-toggle {
    display: inline-flex;
    background: rgba(120, 120, 128, 0.12);
    border-radius: 9px;
    padding: 2px;
    user-select: none;
  }
  .period-toggle button {
    border: none;
    background: transparent;
    padding: 5px 18px;
    font-size: 12px;
    font-weight: 500;
    color: #3C3C43;
    border-radius: 7px;
    cursor: pointer;
    font-family: inherit;
    font-variant-numeric: tabular-nums;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
  }
  .period-toggle button.active {
    background: #FFFFFF;
    color: #000;
    box-shadow: 0 0 0 0.5px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.10);
  }
  .period-toggle button:focus-visible {
    outline: 2px solid #0A84FF;
    outline-offset: 1px;
  }

  /* Metrics row (Overview) */
  .metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-top: 0.5px solid rgba(60, 60, 67, 0.08);
  }
  .metric {
    padding: 12px 14px 14px;
    border-right: 0.5px solid rgba(60, 60, 67, 0.08);
    min-width: 0;
  }
  .metric:last-child { border-right: none; }
  .metric-label {
    font-size: 10.5px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #8E8E93;
    font-weight: 500;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .metric-value {
    font-size: 22px;
    font-weight: 600;
    line-height: 1.1;
    color: #000;
  }
  .metric-value.warn   { color: #B45A00; }
  .metric-value.alert  { color: #C82C24; }
  .metric-value.wr-up  { color: #30B65A; }
  .metric-value.wr-down { color: #FF3B30; }
  .metric-value .unit {
    font-size: 13px;
    font-weight: 500;
    color: #8E8E93;
    margin-left: 1px;
  }
  .metric-sub {
    font-size: 11px;
    color: #8E8E93;
    margin-top: 4px;
  }
  @media (min-width: 720px) {
    .metric { padding: 14px 18px 16px; }
    .metric-label { font-size: 11px; }
    .metric-value { font-size: 24px; }
  }

  /* ============================================================
     LIVE SESSION PANEL
     ============================================================ */
  .session-strip {
    padding: 14px 18px 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .session-meta-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #8E8E93;
    flex-wrap: wrap;
    font-weight: 500;
  }
  .session-meta-row .ticker { color: #3C3C43; font-weight: 500; }
  .session-meta-row .closes-pulse {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #3C3C43;
  }
  .session-meta-row .pulse-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #30B65A;
    animation: livePulse 1.6s ease-in-out infinite;
  }
  @keyframes livePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
  }
  .session-data-row {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
  }
  .btc-block { display: flex; flex-direction: column; gap: 2px; }
  .btc-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #8E8E93;
    font-weight: 500;
  }
  .btc-value {
    font-size: 28px;
    font-weight: 600;
    letter-spacing: -0.4px;
    line-height: 1.05;
    color: #000;
  }
  .btc-delta {
    font-size: 12px;
    font-weight: 500;
    margin-top: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }
  .btc-delta .arrow { font-size: 9px; }
  .btc-delta.delta-up { color: #30B65A; }
  .btc-delta.delta-down { color: #FF3B30; }
  .btc-delta.delta-flat { color: #8E8E93; }
  .btc-delta .vs-strike {
    color: #8E8E93;
    font-weight: 500;
    margin-left: 2px;
  }
  .kalshi-block {
    display: flex;
    gap: 14px;
    align-items: flex-end;
  }
  .kalshi-side {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
  }
  .kalshi-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #8E8E93;
    font-weight: 500;
  }
  .kalshi-value {
    font-size: 16px;
    font-weight: 600;
    color: #000;
  }
  @media (min-width: 720px) {
    .session-strip { padding: 16px 22px 10px; }
    .btc-value { font-size: 32px; }
  }

  .overlay-toggles {
    padding: 8px 14px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: center;
  }
  .overlay-chip {
    border: 1px solid rgba(60, 60, 67, 0.18);
    background: #FFFFFF;
    padding: 5px 12px 5px 8px;
    border-radius: 999px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    color: #3C3C43;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
    user-select: none;
  }
  .overlay-chip:hover { border-color: rgba(60, 60, 67, 0.32); }
  .overlay-chip:focus-visible { outline: 2px solid #0A84FF; outline-offset: 2px; }
  .overlay-chip .swatch {
    width: 12px; height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
  }
  .overlay-chip[data-overlay="strike"]       .swatch { background: #FF9500; }
  .overlay-chip[data-overlay="btc"]          .swatch { background: #1C1C1E; }
  .overlay-chip[data-overlay="kalshi-prob"]  .swatch { background: linear-gradient(180deg, #1F7A38 50%, #C82C24 50%); }
  .overlay-chip[data-overlay="trades"]       .swatch {
    background: linear-gradient(90deg, #30B65A 50%, #FF3B30 50%);
  }
  .overlay-chip[data-overlay="triggers"]     .swatch {
    background: #FFFFFF;
    border: 1.5px dashed #6E6E73;
    border-radius: 50%;
    box-sizing: border-box;
  }
  .overlay-chip:not(.active) {
    color: #8E8E93;
    background: #F8F8FA;
    border-color: rgba(60, 60, 67, 0.12);
  }
  .overlay-chip:not(.active) .swatch { opacity: 0.28; }
  @media (min-width: 720px) {
    .overlay-toggles { padding: 10px 18px 18px; gap: 10px; }
  }

  /* Trade & trigger markers — labels hidden by default,
     revealed on hover for a clean default chart. */
  .trade-marker, .trigger-marker {
    cursor: default;
  }
  .trade-marker .trade-label,
  .trigger-marker .trade-label {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
  }
  .trade-marker:hover .trade-label,
  .trigger-marker:hover .trade-label,
  .trade-marker:focus-within .trade-label,
  .trigger-marker:focus-within .trade-label {
    opacity: 1;
  }

  /* ============================================================
     POSITIONS PANEL
     ============================================================ */
  .positions-section {
    padding: 14px 18px 6px;
    border-top: 0.5px solid rgba(60, 60, 67, 0.08);
  }
  .positions-section:first-child {
    border-top: none;
  }
  .positions-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 8px;
  }
  .positions-section-label {
    font-size: 11px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: #8E8E93;
    font-weight: 500;
  }
  .positions-count {
    font-size: 11px;
    color: #C7C7CC;
    font-weight: 500;
  }
  .position-list {
    display: flex;
    flex-direction: column;
  }
  .position-row {
    padding: 10px 0;
    border-top: 0.5px solid rgba(60, 60, 67, 0.06);
  }
  .position-row:first-child { border-top: none; }
  .position-row-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
  }
  .position-row-meta {
    margin-top: 4px;
    font-size: 11px;
    color: #8E8E93;
  }
  .position-identity {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
  }
  .side-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.4px;
  }
  .side-chip.side-yes { background: #DDF5E0; color: #1F7A38; }
  .side-chip.side-no  { background: #FFE5E3; color: #C82C24; }

  /* Thesis chip — v1.6.7 canonical thesis colors.
     Used everywhere thesis is displayed (positions, decisions,
     chart legends). Continuation = pale blue, Reversal = pale
     purple. Replaces the deprecated v1.6.0 green/amber and
     blue/orange systems flagged in the audit. */
  .thesis-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: 5px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.3px;
  }
  .thesis-chip.thesis-continuation { background: #E8F1FF; color: #0A66C2; }
  .thesis-chip.thesis-reversal     { background: #F0E5FF; color: #6B45D9; }
  .entry-type {
    color: #000;
    font-weight: 600;
    font-size: 13px;
    margin-right: 6px;
  }
  .position-type {
    font-size: 12px;
    color: #3C3C43;
    font-weight: 500;
  }
  .position-size {
    font-size: 13px;
    font-weight: 500;
    color: #000;
  }
  .position-size .size-sep {
    color: #C7C7CC;
    margin: 0 5px;
    font-weight: 400;
  }
  .position-fill {
    text-align: right;
    white-space: nowrap;
  }
  .fill-price {
    font-size: 17px;
    font-weight: 600;
    color: #000;
  }
  .fill-implied {
    font-size: 11px;
    color: #8E8E93;
    margin-left: 3px;
  }
  .trigger-condition {
    font-size: 12px;
    color: #6E6E73;
    font-weight: 500;
  }
  .trigger-price {
    font-size: 15px;
    font-weight: 600;
    color: #000;
    margin-left: 4px;
  }
  .position-row.pending {
    opacity: 0.92;
  }
  .position-empty {
    font-size: 12px;
    color: #8E8E93;
    padding: 6px 0 14px;
  }

  @media (min-width: 720px) {
    .positions-section { padding: 16px 22px 8px; }
  }

  /* ============================================================
     RECENT SESSIONS PANEL
     ============================================================ */
  .session-card {
    padding: 14px 18px;
    border-top: 0.5px solid rgba(60, 60, 67, 0.10);
  }
  .session-card:first-child {
    border-top: none;
  }
  @media (min-width: 720px) {
    .session-card { padding: 16px 22px; }
  }

  .session-card-header {
    margin-bottom: 4px;
  }
  .session-time-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
  }
  .session-time {
    font-size: 14px;
    font-weight: 600;
    color: #000;
    letter-spacing: -0.1px;
  }
  .session-pnl {
    font-size: 14px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
  }
  .session-pnl.pnl-up      { color: #30B65A; }
  .session-pnl.pnl-down    { color: #FF3B30; }
  .session-pnl.pnl-pending { color: #8E8E93; font-weight: 500; }
  .session-pnl .arrow      { font-size: 10px; }
  .session-pnl .pnl-pct    { font-size: 12px; font-weight: 500; margin-left: 4px; opacity: 0.85; }

  .session-meta-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 3px;
    font-size: 11px;
    color: #8E8E93;
    flex-wrap: wrap;
  }
  .session-ticker {
    font-variant-numeric: tabular-nums;
  }
  .session-trade-count {
    margin-left: auto;
  }

  .session-state {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 1px 7px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-transform: lowercase;
  }
  .session-state.state-settling {
    background: #FFF4E5;
    color: #A25C09;
  }
  .session-state.state-settling .state-dot {
    width: 5px; height: 5px;
    border-radius: 50%;
    background: #FF9500;
    animation: livePulse 1.6s ease-in-out infinite;
  }
  .session-state.state-settled {
    color: #8E8E93;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    padding: 0;
    background: transparent;
  }

  /* Trade list inside a session */
  .trade-list {
    margin-top: 10px;
  }
  .trade-row {
    border-top: 0.5px solid rgba(60, 60, 67, 0.06);
  }
  .trade-row:first-child {
    border-top: none;
  }
  .trade-row > summary {
    list-style: none;
    cursor: pointer;
    padding: 10px 0;
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
  }
  .trade-row > summary::-webkit-details-marker { display: none; }
  .trade-row > summary::marker { content: ""; }
  .trade-row-fill-mini {
    font-size: 12px;
    color: #8E8E93;
    font-weight: 500;
  }
  .trade-outcome {
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }
  .trade-outcome.won  { color: #30B65A; }
  .trade-outcome.lost { color: #FF3B30; }
  .trade-outcome.pending {
    color: #A25C09;
    font-weight: 500;
  }
  .trade-outcome .arrow { font-size: 9px; }

  .row-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 12px; height: 12px;
    color: #C7C7CC;
    transition: transform 0.2s ease, color 0.15s ease;
    margin-left: 4px;
  }
  .row-chevron svg { width: 12px; height: 12px; display: block; }
  .trade-row[open] > summary .row-chevron {
    transform: rotate(180deg);
    color: #8E8E93;
  }

  /* Expanded trade body — reasoning blocks */
  .trade-row-body {
    padding: 4px 0 16px;
  }

  .trade-stats-row {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    padding: 10px 0 12px;
    border-top: 0.5px solid rgba(60, 60, 67, 0.06);
    border-bottom: 0.5px solid rgba(60, 60, 67, 0.06);
    margin-bottom: 14px;
  }
  .trade-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .trade-stat-label {
    font-size: 9.5px;
    color: #8E8E93;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
  }
  .trade-stat-value {
    font-size: 13px;
    color: #000;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
  }

  .reasoning-section {
    margin-bottom: 14px;
  }
  .reasoning-section:last-child {
    margin-bottom: 0;
  }
  .reasoning-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #8E8E93;
    font-weight: 600;
    margin-bottom: 4px;
  }
  .reasoning-body {
    font-size: 13px;
    color: #1C1C1E;
    line-height: 1.55;
  }

  .validator-warnings {
    background: #FFF8EC;
    border-left: 3px solid #FF9500;
    padding: 10px 12px;
    border-radius: 4px;
    margin-bottom: 14px;
  }
  .validator-warnings .reasoning-label {
    color: #A25C09;
  }
  .validator-warnings ul {
    margin: 0;
    padding-left: 18px;
  }
  .validator-warnings li {
    font-size: 12px;
    color: #1C1C1E;
    line-height: 1.5;
    margin-bottom: 3px;
  }
  .validator-warnings li:last-child { margin-bottom: 0; }

  /* ============================================================
     PERFORMANCE CHARTS PANEL
     ============================================================ */
  .chart-card {
    padding: 14px 18px;
  }
  @media (min-width: 720px) {
    .chart-card { padding: 16px 22px; }
  }
  .chart-card-wide {
    border-bottom: 0.5px solid rgba(60, 60, 67, 0.10);
  }

  .charts-grid {
    display: grid;
    grid-template-columns: 1fr;
  }
  .charts-grid .chart-card {
    border-top: 0.5px solid rgba(60, 60, 67, 0.08);
  }
  .charts-grid .chart-card:first-child {
    border-top: none;
  }
  @media (min-width: 720px) {
    .charts-grid {
      grid-template-columns: 1fr 1fr;
    }
    .charts-grid .chart-card {
      border-right: 0.5px solid rgba(60, 60, 67, 0.08);
    }
    .charts-grid .chart-card:nth-child(2n) {
      border-right: none;
    }
    .charts-grid .chart-card:nth-child(-n+2) {
      border-top: none;
    }
  }

  .chart-card-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 12px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .chart-card-title {
    font-size: 11px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: #8E8E93;
    font-weight: 500;
  }
  .chart-card-meta {
    font-size: 10px;
    color: #C7C7CC;
    font-weight: 500;
  }

  /* Smaller period toggle inside chart card headers */
  .period-toggle-mini button {
    padding: 3px 12px;
    font-size: 11px;
  }

  /* P&L compound toggles (period × mode) — mirror .period-toggle styling */
  .pnl-period-toggle, .pnl-mode-toggle {
    display: inline-flex;
    background: rgba(120, 120, 128, 0.12);
    border-radius: 9px;
    padding: 2px;
    user-select: none;
  }
  .pnl-period-toggle button, .pnl-mode-toggle button {
    border: none;
    background: transparent;
    padding: 3px 12px;
    font-size: 11px;
    font-weight: 500;
    color: #3C3C43;
    border-radius: 7px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
  }
  .pnl-period-toggle button.active, .pnl-mode-toggle button.active {
    background: #FFFFFF;
    color: #000;
    box-shadow: 0 0 0 0.5px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.10);
  }
  .pnl-period-toggle button:focus-visible, .pnl-mode-toggle button:focus-visible {
    outline: 2px solid #0A84FF;
    outline-offset: 1px;
  }

  .chart-card-svg {
    width: 100%;
    display: block;
    height: auto;
  }

  .chart-legend {
    display: flex;
    gap: 14px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 10px;
    font-size: 11px;
    color: #8E8E93;
    font-weight: 500;
  }
  .legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }
  .legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    display: inline-block;
    flex-shrink: 0;
  }
  .legend-dash {
    width: 14px;
    height: 0;
    border-top: 1.5px dashed #C7C7CC;
    display: inline-block;
    flex-shrink: 0;
  }

  /* Thesis × outcome matrix layout */
  .thesis-matrix {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }
  .thesis-matrix-section {
    /* one per thesis */
  }
  .thesis-matrix-section-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
  }
  .thesis-matrix-section-name {
    font-size: 12px;
    font-weight: 600;
  }
  .thesis-matrix-section-name.section-continuation { color: #0A66C2; }
  .thesis-matrix-section-name.section-reversal     { color: #6B45D9; }
  .thesis-matrix-wr {
    font-size: 12px;
    font-weight: 600;
    color: #000;
    font-variant-numeric: tabular-nums;
  }
  .thesis-matrix-wr-meta {
    font-size: 11px;
    color: #8E8E93;
    font-weight: 500;
    margin-left: 4px;
  }
  .thesis-matrix-cells {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .thesis-cell {
    padding: 8px 10px 9px;
    border-radius: 6px;
  }
  .thesis-cell.cell-won  { background: #EAF7EC; }
  .thesis-cell.cell-lost { background: #FCEAEA; }
  .cell-outcome-label {
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
  }
  .cell-outcome-label.label-won  { color: #1F7A38; }
  .cell-outcome-label.label-lost { color: #C82C24; }
  .cell-numbers {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-top: 4px;
  }
  .cell-n {
    font-size: 15px;
    font-weight: 600;
    color: #000;
    font-variant-numeric: tabular-nums;
  }
  .cell-pnl {
    font-size: 11px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
  }
  .cell-pnl.pnl-up   { color: #30B65A; }
  .cell-pnl.pnl-down { color: #FF3B30; }

  /* ============================================================
     SIGNAL × STRENGTH × THESIS HEATMAP
     ============================================================ */
  .heatmap-card {
    border-top: 0.5px solid rgba(60, 60, 67, 0.10);
  }

  .heatmap-section {
    margin-top: 18px;
  }
  .heatmap-section:first-of-type {
    margin-top: 4px;
  }

  details.heatmap-section > summary {
    cursor: pointer;
    list-style: none;
  }
  details.heatmap-section > summary::-webkit-details-marker { display: none; }
  details.heatmap-section > summary::marker { content: ""; }
  details.heatmap-section > summary::after {
    content: "▾";
    margin-left: auto;
    color: #8E8E93;
    font-size: 12px;
    transition: transform 0.18s ease;
  }
  details.heatmap-section[open] > summary::after {
    transform: rotate(-180deg);
  }

  .heatmap-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
  }
  .heatmap-section-name {
    font-size: 12px;
    font-weight: 600;
  }
  .heatmap-section-name.section-continuation { color: #0A66C2; }
  .heatmap-section-name.section-reversal     { color: #6B45D9; }
  .heatmap-section-meta {
    font-size: 11px;
    color: #8E8E93;
    font-weight: 500;
  }

  .heatmap-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -18px;
    padding: 0 18px;
  }
  @media (min-width: 720px) {
    .heatmap-scroll {
      margin: 0 -22px;
      padding: 0 22px;
    }
  }

  .heatmap-grid {
    display: grid;
    grid-template-columns: 150px repeat(4, minmax(80px, 1fr));
    gap: 1px;
    background: rgba(60, 60, 67, 0.10);
    border-radius: 8px;
    border: 0.5px solid rgba(60, 60, 67, 0.12);
    min-width: 530px;
    overflow: hidden;
    font-variant-numeric: tabular-nums;
  }
  .heatmap-row { display: contents; }

  .heatmap-cell,
  .heatmap-signal-label,
  .heatmap-strength-label {
    background: #FFFFFF;
    padding: 6px 6px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 30px;
  }
  .heatmap-signal-label {
    text-align: left;
    align-items: flex-start;
    padding: 6px 10px;
    background: #F8F8FA;
    color: #3C3C43;
    font-weight: 500;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .heatmap-strength-label {
    background: #F8F8FA;
    color: #8E8E93;
    font-weight: 600;
    font-size: 10px;
    letter-spacing: 0.4px;
  }
  .heatmap-cell .cell-wr {
    font-weight: 600;
    font-size: 11px;
    line-height: 1.05;
  }
  .heatmap-cell .cell-n {
    font-size: 9px;
    opacity: 0.7;
    line-height: 1.2;
    margin-top: 1px;
  }

  /* WR color tiers (light Apple-style tints matching chip palette) */
  .heatmap-cell.wr-strong-high { background: #B5E5BD; color: #145228; }
  .heatmap-cell.wr-high        { background: #DDF5E0; color: #1F7A38; }
  .heatmap-cell.wr-mid         { background: #F2F2F7; color: #3C3C43; }
  .heatmap-cell.wr-low         { background: #FFE5E3; color: #C82C24; }
  .heatmap-cell.wr-strong-low  { background: #FFC4BD; color: #8B1B14; }
  .heatmap-cell.wr-low-n       { background: #FAFAFA; color: #8E8E93; }
  .heatmap-cell.wr-empty       { background: #FAFAFA; color: #C7C7CC; }

/* ============================================================
   REFRESH INDICATOR
   ============================================================ */
#refresh-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  opacity: 0.65;
  margin-left: 8px;
}
.refresh-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #888;
  flex-shrink: 0;
}
.refresh-dot.refresh-ok    { background: #4caf50; }
.refresh-dot.refresh-error { background: #e53935; }
.refresh-dot.refresh-init  {
  background: #888;
  animation: _rfpulse 1.2s ease-in-out infinite;
}
@keyframes _rfpulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.25; }
}
