/* ============================================================
   polish-2026.css — Linear / open-design inspired refresh.
   Loads LAST so it overrides legacy styles.css + tdp-polish.css.
   Keeps every existing class name and DOM ID intact; only visual
   tokens change. Pair with /css/tokens.css for spacing/motion.
   ============================================================ */

:root {
    /* Brand shift: blue → indigo. Tightens the relationship between
       the auth surfaces and the dashboard chrome without rewriting
       tokens.css. */
    --p2026-primary:        var(--mg-blue);
    --p2026-primary-hover:  var(--mg-blue-hi);
    --p2026-primary-soft:   rgba(94, 106, 210, 0.14);
    --p2026-primary-glow:   rgba(94, 106, 210, 0.22);
    --p2026-bg:             var(--mg-bg-2);
    --p2026-card:           rgba(255, 255, 255, 0.025);
    --p2026-card-border:    rgba(255, 255, 255, 0.08);
    --p2026-card-strong:    rgba(255, 255, 255, 0.16);
    --p2026-input:          rgba(255, 255, 255, 0.03);
    --p2026-input-hover:    rgba(255, 255, 255, 0.05);
    --p2026-text:           var(--mg-text);
    --p2026-text-muted:     #8a8f98;
    --p2026-text-faint:     #62666d;
}

body {
    background:
        radial-gradient(ellipse 60% 40% at 50% 0%, rgba(94, 106, 210, 0.06), transparent 70%),
        var(--p2026-bg);
    color: var(--p2026-text);
    -webkit-font-smoothing: antialiased;
}

/* ── Page container / generic spacing ─────────────────────────── */
.dashboard-container { padding: 24px 28px 80px; max-width: 1400px; margin: 0 auto; }

/* ── Topbar ───────────────────────────────────────────────────── */
.dashboard-header {
    background: var(--p2026-card);
    border: 1px solid var(--p2026-card-border);
    border-radius: 12px;
    padding: 14px 20px;
    margin-bottom: 16px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
    backdrop-filter: blur(20px);
}
.dashboard-header h1 {
    font-size: 16px;
    font-weight: 600;
    background: none;
    -webkit-text-fill-color: var(--p2026-text);
    color: var(--p2026-text);
    letter-spacing: -0.01em;
    background-clip: initial;
}
.header-subtitle {
    font-size: 11px;
    font-weight: 510;
    color: var(--p2026-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* Sync info pill (Demo Data · updated …) — slimmer, monospace timestamp */
.sync-info {
    background: var(--p2026-input);
    border: 1px solid var(--p2026-card-border);
    border-radius: 7px;
    padding: 6px 10px;
    font-size: 12px;
    color: var(--p2026-text-muted);
    gap: 8px;
}
.sync-info .data-source-label { color: var(--p2026-text); font-weight: 510; }
.sync-info .last-sync-label    { font-family: var(--font-mono, ui-monospace, "SF Mono", Menlo, monospace); font-size: 11.5px; }

.header-actions { gap: 8px; }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn-primary,
.btn-secondary,
.btn-icon {
    padding: 7px 12px;
    font-size: 13px;
    font-weight: 510;
    letter-spacing: -0.005em;
    border-radius: 7px;
    border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
}
.btn-primary {
    background: var(--p2026-primary);
    border-color: var(--p2026-primary);
    color: #ffffff;
}
.btn-primary:hover:not(:disabled) {
    background: var(--p2026-primary-hover);
    border-color: var(--p2026-primary-hover);
    box-shadow: none;
    transform: none;
}
.btn-primary:disabled {
    opacity: 0.55;
    box-shadow: none;
    transform: none;
}
.btn-secondary {
    background: var(--p2026-input);
    border-color: var(--p2026-card-border);
    color: var(--p2026-text);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--p2026-input-hover);
    border-color: var(--p2026-card-strong);
    color: var(--p2026-text);
}
.btn-icon {
    background: var(--p2026-input);
    border-color: var(--p2026-card-border);
    color: var(--p2026-text-muted);
    width: 32px;
    height: 32px;
    border-radius: 7px;
}
.btn-icon:hover {
    background: var(--p2026-input-hover);
    border-color: var(--p2026-card-strong);
    color: var(--p2026-text);
}

/* The connection-count badge inside the Connections button */
.btn-secondary .badge,
#connCount {
    background: var(--p2026-card-border);
    color: var(--p2026-text-muted);
    font-size: 11px;
    font-weight: 510;
    padding: 1px 7px;
    border-radius: 999px;
    margin-left: 4px;
}

/* ── Status dot ──────────────────────────────────────────────── */
.status-indicator {
    width: 7px;
    height: 7px;
    box-shadow: 0 0 0 3px rgba(110, 231, 183, 0.16);
}
.status-indicator.disconnected { box-shadow: 0 0 0 3px rgba(245, 183, 105, 0.18); }

/* ── User menu (avatar + dropdown) ───────────────────────────── */
.user-menu {
    position: relative;
    display: inline-flex; align-items: center; gap: 8px;
    padding: 4px 10px 4px 4px; border-radius: 999px;
    background: var(--p2026-input);
    border: 1px solid var(--p2026-card-border);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    outline: none;
}
.user-menu:hover, .user-menu:focus-visible { background: var(--p2026-input-hover); border-color: var(--p2026-card-strong); }
.user-menu:focus-visible { box-shadow: 0 0 0 3px rgba(94, 106, 210, 0.25); }
.user-avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px;
    border-radius: 50%;
    /* TD Pro indigo gradient — was #5e6ad2/#828fff (Linear); now #3f7bff/#6f9bff */
    background: linear-gradient(135deg, #3f7bff 0%, #6f9bff 100%);
    color: #ffffff;
    font-size: 12px; font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
    user-select: none;
    flex-shrink: 0;
}
.user-menu .user-menu-name {
    font-size: 13px; font-weight: 510;
    color: var(--p2026-text);
    letter-spacing: -0.01em;
    max-width: 140px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-menu::after {
    content: "▾";
    color: var(--p2026-text-muted);
    font-size: 9px;
    line-height: 1;
    margin-left: 2px;
}
.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    background: #11141b;
    border: 1px solid var(--p2026-card-strong);
    border-radius: 10px;
    padding: 6px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
    display: none;
    z-index: 50;
}
.user-menu:hover .user-menu-dropdown,
.user-menu:focus-within .user-menu-dropdown { display: block; }
.user-menu-id {
    padding: 6px 10px 8px;
    font-size: 11px;
    color: var(--p2026-text-muted);
    border-bottom: 1px solid var(--p2026-card-border);
    margin-bottom: 4px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-menu-id:empty { display: none; }
.user-menu-dropdown a {
    display: block;
    padding: 7px 10px;
    font-size: 13px;
    font-weight: 510;
    color: var(--p2026-text);
    text-decoration: none;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}
.user-menu-dropdown a:hover {
    background: var(--p2026-input-hover);
    color: #ffffff;
}
#logoutLink { color: #f47174; }
#logoutLink:hover { background: rgba(244, 113, 116, 0.12); color: #ff8e8e; }

/* ── Section nav (Wheel Dashboard / Command Center / …) ───────── */
.section-nav {
    background: var(--p2026-card);
    border: 1px solid var(--p2026-card-border);
    border-radius: 10px;
    padding: 4px 6px;
    margin-bottom: 14px;
    gap: 2px;
    backdrop-filter: blur(20px);
}
.section-nav-link {
    padding: 7px 12px;
    font-size: 12.5px;
    font-weight: 510;
    border-radius: 6px;
    color: var(--p2026-text-muted);
    letter-spacing: -0.005em;
    border: 1px solid transparent;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
/* Suppress the per-group color tinting in favour of a single muted palette
   — colored nav links read as link-rot when half are blue and half are
   yellow on the same surface. */
.section-nav-link.nav-group-analyst,
.section-nav-link.nav-group-core,
.section-nav-link.nav-group-bots,
.section-nav-link.nav-group-tools { color: var(--p2026-text-muted); }
.section-nav-link:hover {
    background: var(--p2026-input-hover);
    color: var(--p2026-text);
    border-color: transparent;
}
.section-nav-link.is-active,
.section-nav-link.active {
    background: var(--p2026-primary-soft);
    border-color: rgba(94, 106, 210, 0.35);
    color: #c2c8f4;
}
.section-nav-link.is-active:hover,
.section-nav-link.active:hover {
    background: var(--p2026-primary-soft);
    color: #d6daf7;
}
.section-nav-link .nav-icon { opacity: 0.8; font-size: 0.9em; }
.section-nav-divider {
    width: 1px;
    background: var(--p2026-card-border);
    margin: 3px 4px;
}

/* ── Sub-nav (P&L / Strategies / Active / Expirations / Stocks / Intel)
     Lives inside the dashboard container, currently styled as a row of
     anchors. Apply the same pill aesthetic. */
.section-subnav {
    display: flex;
    gap: 2px;
    margin-bottom: 18px;
    padding: 4px 6px;
    background: var(--p2026-card);
    border: 1px solid var(--p2026-card-border);
    border-radius: 10px;
    overflow-x: auto;
    scrollbar-width: none;
}
.section-subnav a,
.section-subnav .subnav-link {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 510;
    border-radius: 6px;
    color: var(--p2026-text-muted);
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}
.section-subnav a:hover,
.section-subnav .subnav-link:hover {
    background: var(--p2026-input-hover);
    color: var(--p2026-text);
}
.section-subnav a.active,
.section-subnav .subnav-link.active {
    background: var(--p2026-primary-soft);
    color: #c2c8f4;
}

/* ── Filter pills (All / CSP / CC / CALL / PUT / Equity) ──────── */
.filter-buttons { gap: 4px; }
.filter-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--p2026-text-muted);
    padding: 5px 11px;
    font-size: 12px;
    font-weight: 510;
    border-radius: 999px;
    letter-spacing: -0.005em;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.filter-btn:hover {
    background: var(--p2026-input-hover);
    color: var(--p2026-text);
}
.filter-btn.active {
    background: var(--p2026-primary);
    color: #ffffff;
    border-color: var(--p2026-primary);
}

/* ── KPI / metric cards ───────────────────────────────────────── */
.metric-card {
    background: var(--p2026-card);
    border: 1px solid var(--p2026-card-border);
    border-radius: 12px;
    padding: 18px 20px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
    backdrop-filter: blur(20px);
    transition: border-color 0.15s, background 0.15s;
}
.metric-card:hover {
    transform: none;
    background: rgba(255, 255, 255, 0.035);
    border-color: var(--p2026-card-strong);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
}
.metric-card.primary {
    background: linear-gradient(135deg, rgba(94, 106, 210, 0.18), rgba(94, 106, 210, 0.06));
    border: 1px solid rgba(94, 106, 210, 0.4);
}
.metric-card.primary .metric-label {
    color: rgba(255, 255, 255, 0.75);
}
.metric-label {
    font-size: 10.5px;
    font-weight: 590;
    color: var(--p2026-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
}
.metric-value {
    font-size: 26px;
    font-weight: 590;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}
.metric-change {
    font-size: 12px;
    font-weight: 510;
}

/* ── Tables ───────────────────────────────────────────────────── */
.positions-table,
.table-container table {
    border-collapse: collapse;
    width: 100%;
    font-size: 13px;
}
.positions-table th,
.table-container table th {
    text-align: left;
    padding: 9px 14px;
    color: var(--p2026-text-faint);
    font-size: 11px;
    font-weight: 590;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--p2026-card-border);
    background: rgba(255, 255, 255, 0.02);
}
.positions-table td,
.table-container table td {
    padding: 10px 14px;
    color: var(--p2026-text);
    border-bottom: 1px solid var(--p2026-card-border);
    vertical-align: middle;
}
.positions-table tbody tr,
.table-container table tbody tr { transition: background 0.1s; }
.positions-table tbody tr:hover,
.table-container table tbody tr:hover { background: rgba(255, 255, 255, 0.02); }

/* ── Market-closed banner ─────────────────────────────────────── */
.market-banner {
    background: rgba(245, 183, 105, 0.06);
    border: 1px solid rgba(245, 183, 105, 0.25);
    border-left: 3px solid #f5b769;
    border-radius: 8px;
    padding: 9px 14px;
    color: #f3c891;
    font-size: 12.5px;
    margin: 10px 0 14px;
}
.market-banner-dot {
    width: 6px; height: 6px;
    background: #f5b769;
    box-shadow: 0 0 0 3px rgba(245, 183, 105, 0.18);
}
.market-banner-text {
    font-weight: 590;
    color: #f3c891;
    letter-spacing: -0.005em;
}
.market-banner-meta {
    font-size: 11.5px;
    color: rgba(243, 200, 145, 0.65);
}

/* ── Page section heads (P&L 2026, etc.) ──────────────────────── */
.section-head, .panel-title {
    font-size: 13px;
    font-weight: 590;
    color: var(--p2026-text);
    letter-spacing: -0.005em;
}

/* ── Inputs (globally) ────────────────────────────────────────── */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
    background: var(--p2026-input);
    border: 1px solid var(--p2026-card-border);
    border-radius: 7px;
    color: var(--p2026-text);
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
input:hover:not(:disabled),
select:hover:not(:disabled),
textarea:hover:not(:disabled) { background: var(--p2026-input-hover); }
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--p2026-primary);
    background: var(--p2026-input-hover);
    box-shadow: 0 0 0 3px var(--p2026-primary-soft);
}
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--p2026-text);
    -webkit-box-shadow: 0 0 0 1000px #11141b inset;
    box-shadow: 0 0 0 1000px #11141b inset;
    caret-color: var(--p2026-text);
    transition: background-color 9999s ease-in-out 0s;
}

/* ── Year selector / generic select ───────────────────────────── */
.year-selector,
select {
    padding: 6px 28px 6px 10px;
    font-size: 12.5px;
    font-weight: 510;
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path fill='%238a8f98' d='M0 0l5 6 5-6z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

/* ── Panels (P&L by ticker, etc.) ─────────────────────────────── */
.panel,
.section-panel {
    background: var(--p2026-card);
    border: 1px solid var(--p2026-card-border);
    border-radius: 12px;
    padding: 18px 20px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
}

/* ── Error / failure messages on dashboard panels ─────────────── */
.error-message:not(.alert):not(.tradier-form-result) {
    color: #f47174;
    font-size: 13px;
    background: rgba(244, 113, 116, 0.05);
    border: 1px solid rgba(244, 113, 116, 0.2);
    border-radius: 8px;
    padding: 10px 14px;
    margin: 8px 0;
}

/* ============================================================
   2026-05-05 fixes — ported from TraderDaddy Pro Whop
   1. TD Pro dot-grid + blue glow page background
   2. Header above nav (user dropdown z-index)
   3. Centered native <dialog> for connections popups
   4. Section padding on Wheel Dashboard
   ============================================================ */

/* ── TD Pro background: dot grid + top blue glow over deep navy ─ */
html {
    background:
        radial-gradient(circle, rgba(63, 123, 255, 0.08) 1px, transparent 1px),
        radial-gradient(ellipse 110% 45% at 50% 0%, rgba(63, 123, 255, 0.09) 0%, transparent 65%),
        linear-gradient(160deg, #0a0e27 0%, #0d1230 40%, #0a0e27 100%);
    background-size: 28px 28px, 100% 100%, 100% 100%;
    background-attachment: fixed;
    background-color: #0a1430;
}
body {
    /* Let the html dot-grid show through the previous solid body bg */
    background:
        radial-gradient(ellipse 60% 40% at 50% 0%, rgba(94, 106, 210, 0.05), transparent 70%),
        transparent;
}

/* ── Header stacking: lift above the section-nav so the user
       dropdown renders over the nav instead of sliding under it.
       Both .dashboard-header and .section-nav use backdrop-filter,
       which creates separate stacking contexts; explicit z-index
       guarantees the header (and its dropdown) wins. ─────────── */
.dashboard-header {
    position: relative;
    z-index: 100;
}
.section-nav {
    position: relative;
    z-index: 1;
}
/* Bump the dropdown itself just in case any inner element sets a
   stacking context inside the header card. */
.user-menu-dropdown { z-index: 200; }

/* ── Native <dialog> centering. .showModal() is supposed to center
       by default, but legacy `dialog { ... }` rules in styles.css
       (max-width + width with no inset) can leave it pinned to the
       top-left/right depending on user agent. Force explicit
       viewport centering. ─────────────────────────────────────── */
dialog[open] {
    position: fixed;
    inset: 0;
    margin: auto;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
}

/* ── Wheel Dashboard (index.html) section padding. The page wraps
       major blocks in <section> elements that have no card/border/
       padding of their own — which makes their headers and inner
       grids sit flush against the dashboard-container edge. Give
       them a consistent inset so content has room to breathe. ── */
#section-pnl,
#section-active,
#section-stocks,
#section-expiration,
#section-intel {
    padding: 20px 24px;
    background: var(--p2026-card);
    border: 1px solid var(--p2026-card-border);
    border-radius: 12px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
    backdrop-filter: blur(20px);
}
#section-pnl > .page-tabs,
#section-active > .section-header,
#section-stocks > .section-header,
#section-expiration > .section-header,
#section-intel > .section-header {
    margin-bottom: 14px;
}
@media (max-width: 720px) {
    #section-pnl,
    #section-active,
    #section-stocks,
    #section-expiration,
    #section-intel { padding: 16px 14px; }
}
