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

/* ============================================================
   Trading Bot — Stripe.com design language
   Font: Inter (Söhne substitute). Accent: #533afd (blurple).
   Light surfaces, #f6f9fc sections, Stripe layered shadows.
   ============================================================ */

:root {
    /* Surfaces (Stripe) */
    --bg: #f1f3f2;
    --surface: #ffffff;
    --surface-2: #f8f9f8;
    --surface-3: #edf0ef;
    --dark: #0d1718;
    --dark-2: #142324;

    /* Lines */
    --border: #dde3e1;
    --border-strong: #c9d1cf;

    /* Ink (Stripe) */
    --text: #10201f;
    --text-soft: #425250;
    --muted: #6f7d7a;
    --muted-2: #93a09d;

    /* Brand blurple */
    --accent: #2457f5;
    --accent-hover: #1847da;
    --accent-press: #1239b7;
    --accent-soft: #eef2ff;
    --accent-line: #cdd8ff;

    /* Semantic */
    --pos: #087a55;
    --pos-soft: #e6f4ee;
    --neg: #c93643;
    --neg-soft: #faecee;
    --warn: #9a5a08;
    --warn-soft: #faf1df;

    /* Stripe shadows */
    --ring: 0 0 0 1px var(--accent), 0 0 0 4px rgba(36, 87, 245, 0.14);
    --shadow-xs: 0 1px 1px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 1px rgba(50, 50, 93, 0.04), 0 2px 4px rgba(50, 50, 93, 0.06);
    --shadow-card: 0 1px 2px rgba(13, 23, 24, 0.04), 0 8px 22px rgba(13, 23, 24, 0.035);
    --shadow-md: 0 12px 30px rgba(13, 23, 24, 0.09);
    --shadow-pop: 0 24px 70px rgba(13, 23, 24, 0.2);

    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 7px;
    --radius-lg: 20px;
    --radius-pill: 999px;

    --mono: 'IBM Plex Mono', ui-monospace, "SF Mono", Menlo, monospace;
    --sans: 'Manrope', "Segoe UI", system-ui, sans-serif;

    /* Stripe signature gradient */
    --grad: linear-gradient(90deg, #2457f5 0%, #1b73b8 50%, #087a55 100%);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    font-size: 14px;
    line-height: 1.5;
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* ============================================================
   APP SHELL (sidebar + topbar + full-width content)
   ============================================================ */

.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }

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

.sidebar {
    --sidebar-w: 248px;
    width: var(--sidebar-w);
    flex: none;
    position: sticky;
    top: 0;
    align-self: flex-start;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 26px;
    padding: 22px 16px;
    background: var(--surface);
    border-right: 1px solid var(--border);
}

.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 4px; }
.sidebar-brand .brand-mark {
    width: 40px; height: 40px; border-radius: 10px;
    background: var(--accent); color: #fff;
    display: grid; place-items: center;
    font-weight: 800; font-size: 16px; letter-spacing: 0.02em;
    box-shadow: var(--shadow-sm);
}
.brand-text { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.brand-text strong { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; color: var(--text); }
.brand-text .badge { align-self: flex-start; }

.sidebar-nav { display: flex; flex-direction: column; gap: 3px; }
.sidebar-label {
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-2);
    padding: 0 10px 8px;
}
.nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 9px 11px; border-radius: var(--radius-xs);
    font-size: 14px; font-weight: 600; letter-spacing: -0.01em;
    color: var(--text-soft); transition: background .12s, color .12s;
}
.nav-item svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: stroke .12s; }
.nav-item:hover { color: var(--text); background: var(--surface-3); }
.nav-item:hover svg { stroke: var(--text-soft); }
.nav-item.active { color: var(--accent); background: var(--accent-soft); }
.nav-item.active svg { stroke: var(--accent); }

.sidebar-group { display: flex; flex-direction: column; gap: 10px; }
.sidebar-group .mode-switch { gap: 8px; }
.sidebar-group .mode-switch form { flex: 1; }
.sidebar-group .mode-switch .btn { width: 100%; }
.sidebar-caption { margin: 0; padding: 0 4px; font-size: 12px; color: var(--muted); line-height: 1.5; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 18px; border-top: 1px solid var(--border); }
.sidebar-foot .user-pill { justify-content: center; }
.sidebar-foot .btn { width: 100%; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 15px 34px;
    background: rgba(255, 255, 255, 0.85);
    border-bottom: 1px solid var(--border);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
}
.topbar-title { min-width: 0; flex: 1; }
.topbar-title h1 { font-size: 22px; }
.topbar .subtitle { margin-top: 9px; }
.topbar-actions { display: flex; align-items: center; gap: 11px; flex-wrap: wrap; }
.topbar-actions form { margin: 0; }

.nav-burger { display: none; cursor: pointer; padding: 8px; border-radius: var(--radius-xs); border: 1px solid var(--border); background: var(--surface); }
.nav-burger svg { width: 20px; height: 20px; fill: none; stroke: var(--text); stroke-width: 2; stroke-linecap: round; }
.nav-scrim { display: none; }

.app-content { width: 100%; max-width: 1640px; margin: 0 auto; padding: 30px 34px 90px; }

/* Staggered entrance */
.app-content > section,
.app-content > details { animation: rise .5s cubic-bezier(.2, .7, .2, 1) backwards; }
.app-content > *:nth-child(2) { animation-delay: .03s; }
.app-content > *:nth-child(3) { animation-delay: .06s; }
.app-content > *:nth-child(4) { animation-delay: .09s; }
.app-content > *:nth-child(5) { animation-delay: .12s; }
.app-content > *:nth-child(n+6) { animation-delay: .15s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Typography ---------- */

h1 { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.025em; color: var(--text); }
h2 { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
h3 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.02em; display: flex; align-items: center; gap: 9px; color: var(--text); }

.muted { color: var(--muted); font-size: 13px; }
small { color: var(--muted-2); font-size: 12px; }
strong { font-weight: 600; }
code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-3); border: 1px solid var(--border); border-radius: 6px; padding: 2px 7px; color: var(--text-soft); }
a { color: var(--accent); text-decoration: none; transition: color .12s; }
a:hover { color: var(--accent-press); }

/* Flat <section> blocks -> Stripe cards */
.app-content > section {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 24px 26px;
    margin: 18px 0;
}
.app-content > section:first-child { margin-top: 0; }
.app-content > section > h2 { margin-bottom: 18px; }

.section-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.section-head h2 { margin: 0; }
.section-body { margin-top: 4px; }

/* ---------- HUD chips in topbar ---------- */

.subtitle { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 12px; }
.hud-stat {
    display: inline-flex; align-items: center; gap: 5px;
    background: var(--surface-3); border: 1px solid var(--border);
    border-radius: var(--radius-pill); padding: 4px 11px; white-space: nowrap;
    font-weight: 600; color: var(--muted);
}
.hud-meta { color: var(--muted-2); font-size: 11.5px; white-space: nowrap; }
.subtitle strong { color: var(--text); font-weight: 600; }
.market-open, .engine-running { color: var(--pos); }
.market-closed, .engine-stopped { color: var(--muted-2); }

.user-pill {
    display: inline-flex; align-items: center; gap: 8px;
    background: var(--accent-soft); color: var(--accent-press);
    border: 1px solid var(--accent-line); padding: 7px 14px;
    border-radius: var(--radius-pill); font-size: 13px; font-weight: 600;
}
.user-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

.auto-refresh-indicator {
    width: 9px; height: 9px; border-radius: 50%; background: var(--pos); color: transparent; font-size: 0;
    box-shadow: 0 0 0 0 rgba(26, 130, 69, 0.5); animation: pulse 2.4s ease-out infinite;
}
.auto-refresh-indicator.paused { background: var(--muted-2); box-shadow: none; animation: none; }
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(26, 130, 69, 0.45); }
    70% { box-shadow: 0 0 0 6px rgba(26, 130, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(26, 130, 69, 0); }
}

/* ============================================================
   BADGES / TAGS / PILLS
   ============================================================ */

.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: var(--radius-pill); font-weight: 700; font-size: 11px; letter-spacing: 0.04em; }
.badge.paper { background: var(--warn-soft); color: var(--warn); border: 1px solid #f1dcc0; }
.badge.live { background: var(--neg-soft); color: var(--neg); border: 1px solid #f6c9d2; }

.tag { display: inline-flex; align-items: center; font-size: 11px; padding: 3px 9px; border-radius: var(--radius-pill); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; line-height: 1.5; white-space: nowrap; }
.tag-long { background: var(--pos-soft); color: var(--pos); }
.tag-recovery { background: var(--warn-soft); color: var(--warn); }
.tag-flat { background: var(--surface-3); color: var(--muted); border: 1px solid var(--border); }
.tag-off { background: var(--neg-soft); color: var(--neg); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: var(--radius-pill); background: var(--surface-3); color: var(--text-soft); border: 1px solid var(--border); }
.pill-wide { font-weight: 500; color: var(--muted); background: var(--surface-2); }
.pill-stop { background: var(--neg-soft); color: var(--neg); border-color: #f6c9d2; }
.pill-buy, .pill-rebuy, .pill-recovery, .pill-recovery-buy,
.pill-next-buy, .pill-next-rebuy, .pill-next-recovery, .pill-next-recovery-buy { background: var(--pos-soft); color: var(--pos); border-color: #c5e8d2; }
.pill-sell, .pill-sell-or-stop, .pill-manual-sell, .pill-order-failed, .pill-order-blocked,
.pill-next-sell, .pill-next-stop, .pill-next-sell-or-stop { background: var(--neg-soft); color: var(--neg); border-color: #f6c9d2; }
.pill-wait, .pill-none, .pill-disabled, .pill-recovery-cooldown,
.pill-next-wait, .pill-next-none, .pill-next-disabled { background: var(--surface-3); color: var(--muted); border-color: var(--border); }
.pill-retry-order, .pill-next-retry-order { background: var(--warn-soft); color: var(--warn); border-color: #f1dcc0; }
.pill-no-quote, .pill-next-no-quote { background: var(--warn-soft); color: var(--warn); border-color: #f1dcc0; }

/* ============================================================
   BUTTONS (Stripe)
   ============================================================ */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    background: var(--surface); color: var(--text-soft);
    border: 1px solid var(--border-strong);
    padding: 8px 15px; border-radius: var(--radius-xs);
    cursor: pointer; font-family: var(--sans); font-size: 13px; font-weight: 600; line-height: 1.25;
    box-shadow: var(--shadow-xs); white-space: nowrap;
    transition: background .12s, border-color .12s, box-shadow .12s, transform .04s;
}
.btn:hover { background: var(--surface-3); border-color: #c4ccd8; }
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { cursor: not-allowed; opacity: 0.5; box-shadow: none; }
.btn:disabled:hover { background: var(--surface); border-color: var(--border-strong); }

.btn-primary { background: var(--accent); border-color: transparent; color: #fff; box-shadow: 0 1px 1px rgba(10, 37, 64, 0.1), 0 1px 2px rgba(83, 58, 253, 0.25); }
.btn-primary:hover { background: var(--accent-hover); border-color: transparent; }
.btn-primary:active { background: var(--accent-press); }
.btn-primary:disabled:hover { background: var(--accent); }

.btn-danger { background: var(--neg); border-color: transparent; color: #fff; box-shadow: 0 1px 2px rgba(223, 27, 65, 0.22); }
.btn-danger:hover { background: #c41539; border-color: transparent; }

.btn-ghost { background: transparent; color: var(--muted); border-color: transparent; box-shadow: none; }
.btn-ghost:hover { color: var(--neg); background: var(--neg-soft); border-color: transparent; }

.btn-small { padding: 5px 10px; font-size: 12px; }
.btn-attention { box-shadow: 0 0 0 3px rgba(223, 27, 65, 0.2); animation: attn 1.6s ease-in-out infinite; }
@keyframes attn { 0%,100% { box-shadow: 0 0 0 3px rgba(223, 27, 65, 0.16); } 50% { box-shadow: 0 0 0 5px rgba(223, 27, 65, 0.28); } }

.inline-action-form { margin: 0; display: inline; }

/* Button loading spinner (prevents double-clicks; shows it's working) */
.btn-loading { pointer-events: none; opacity: 0.9; }
.btn-loading::before {
    content: ""; display: inline-block; width: 13px; height: 13px; flex: none;
    border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
    margin-right: 7px; vertical-align: -2px; animation: btnspin 0.6s linear infinite;
}
@keyframes btnspin { to { transform: rotate(360deg); } }

/* Background-analysis progress bar */
.analysis-progress { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; padding: 16px 18px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.analysis-progress[hidden] { display: none; }
.analysis-progress-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.analysis-progress-head strong { font-size: 14px; }
.progress-track { height: 8px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border); overflow: hidden; }
.progress-fill { height: 100%; width: 4%; background: var(--accent); border-radius: 999px; transition: width 0.4s ease; }

/* ============================================================
   FORMS
   ============================================================ */

label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-soft); letter-spacing: -0.005em; }
label.checkbox { flex-direction: row; align-items: center; gap: 9px; font-size: 13px; color: var(--text-soft); cursor: pointer; }

input[type="text"], input[type="password"], input[type="number"], select, textarea {
    font-family: var(--sans); font-size: 14px; color: var(--text);
    background: var(--surface); border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs); padding: 9px 12px; width: 100%;
    box-shadow: var(--shadow-xs);
    transition: border-color .12s, box-shadow .12s;
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
textarea { resize: vertical; min-height: 70px; font-family: var(--mono); font-size: 13px; }
input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; flex: none; }
select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23687385' d='M6 8L2 4h8z'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px;
}

.add-stock, .settings-form, .kite-order, .analysis-form, .shortlist-setup-form, .fake-form {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px 18px; align-items: end;
}
.analysis-form .sym-field { grid-column: 1 / -1; }
.kite-order { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); max-width: 640px; }

/* Company chip-picker (Stock Analysis) */
.sym-field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--text); }
.sym-hint { font-size: 11.5px; }
.symbol-picker { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.symbol-picker:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.sym-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sym-chips:empty { display: none; }
.sym-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-soft); color: var(--accent-press); border: 1px solid var(--accent-line); border-radius: var(--radius-pill); padding: 4px 5px 4px 11px; font-size: 12.5px; font-weight: 600; }
.sym-chip .sym-chip-ex { font-size: 9px; font-weight: 700; opacity: 0.7; border: 1px solid currentColor; border-radius: 4px; padding: 0 3px; }
.sym-chip-x { border: none; background: none; cursor: pointer; color: inherit; font-size: 17px; line-height: 1; padding: 0 3px; opacity: 0.65; }
.sym-chip-x:hover { opacity: 1; }
.sym-search { border: none; outline: none; padding: 6px 4px; font-size: 14px; font-family: var(--sans); background: none; width: 100%; color: var(--text); }
.sym-dropdown { position: absolute; left: 0; right: 0; top: 100%; margin-top: 5px; z-index: 60; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-pop); max-height: 300px; overflow-y: auto; }
.sym-dropdown[hidden] { display: none; }
.sym-opt { display: flex; align-items: baseline; gap: 8px; padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.sym-opt:last-child { border-bottom: none; }
.sym-opt:hover, .sym-opt.active { background: var(--surface-2); }
.sym-opt strong { font-size: 13px; color: var(--text); flex: none; }
.sym-opt span { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sym-opt .sym-opt-ex { margin-left: auto; font-size: 9px; font-weight: 700; color: var(--muted); border: 1px solid var(--border-strong); border-radius: 4px; padding: 1px 4px; flex: none; }
.sym-opt-add { color: var(--accent-press); font-weight: 600; font-size: 13px; }

.mt-price { display: block; margin-top: 6px; font-size: 12.5px; font-weight: 600; min-height: 16px; }
.mt-price-ok { color: var(--pos); }
.mt-price-warn { color: var(--warn); }
.log-filter { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.log-filter label { flex: 1 1 240px; max-width: 440px; }

/* Manual trade is a single order-entry rail. Every primary control shares the
   same baseline and height; the asynchronous quote has its own stable row. */
.manual-trade-card { max-width: 1160px; }
.kite-order.manual-order-form {
    grid-template-columns: minmax(280px, 1.65fr) minmax(120px, .55fr) minmax(150px, .72fr) minmax(175px, .8fr);
    gap: 10px 16px;
    max-width: 1010px;
    align-items: end;
}
.manual-order-field { min-width: 0; gap: 8px; }
.manual-order-field > span:first-child { min-height: 18px; }
.manual-order-form input[type="number"],
.manual-order-form select,
.manual-order-form .symbol-picker-single,
.manual-order-submit { height: 46px; min-height: 46px; }
.manual-order-form .symbol-picker-single {
    justify-content: center;
    gap: 0;
    padding: 0 13px;
    border-color: var(--border-strong);
    border-radius: var(--radius-xs);
    box-shadow: var(--shadow-xs);
}
.manual-order-form .symbol-picker-single .sym-search { height: 44px; padding: 0; font-size: 15px; }
.manual-order-submit { width: 100%; }
.manual-order-form .mt-price {
    grid-column: 1 / -1;
    min-height: 21px;
    margin: 0;
    font-size: 13px;
    line-height: 1.45;
}
.manual-trade-note { max-width: 920px; margin: 15px 0 0; line-height: 1.6; }

/* ============================================================
   FLASH / ERROR
   ============================================================ */

.flash { background: var(--warn-soft); border: 1px solid #f0d9bc; color: #8a4b08; border-radius: var(--radius-sm); padding: 11px 15px; margin: 0 0 16px; font-size: 13px; font-weight: 500; }
.action-flash { position: fixed; top: 18px; right: 18px; left: auto; z-index: 1200; max-width: 360px; background: var(--dark); color: #fff; border: none; box-shadow: var(--shadow-pop); animation: toast-in .25s ease; }
.action-flash-error { background: var(--neg); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.error { background: var(--neg-soft); border: 1px solid #f6c9d2; border-radius: var(--radius-sm); padding: 12px 15px; margin: 0 0 16px; }
.error summary { cursor: pointer; font-weight: 600; color: var(--neg); }
.error pre { white-space: pre-wrap; font-family: var(--mono); font-size: 12px; margin: 10px 0 0; color: var(--text-soft); }

.risk-note { display: flex; gap: 10px; align-items: flex-start; background: var(--warn-soft) !important; border-color: #f0d9bc !important; font-size: 13px; color: #7a4708; }
.risk-note strong { color: var(--warn); }

/* ============================================================
   MODE SWITCH
   ============================================================ */

.mode-switch { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mode-switch form { margin: 0; }

/* ============================================================
   ACCORDION PANELS (dashboard) — native <details>
   ============================================================ */

.panel-accordion {
    position: relative; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-card); margin: 18px 0; overflow: hidden;
}
.panel-accordion > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 13px; padding: 17px 24px; transition: background .12s; }
.panel-accordion > summary::-webkit-details-marker { display: none; }
.panel-accordion > summary:hover { background: var(--surface-3); }
.panel-accordion > summary::after {
    content: ""; margin-left: auto; width: 22px; height: 22px; flex: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 24 24' fill='none' stroke='%23687385' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: center;
    transition: transform .22s ease;
}
.panel-accordion[open] > summary::after { transform: rotate(180deg); }
.panel-accordion[open] > summary { border-bottom: 1px solid var(--border); }
.panel-accordion[open]::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.panel-title { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.panel-hint { color: var(--muted); font-size: 12.5px; }
.panel-body { padding: 22px 24px 24px; }
.panel-body > .live-settings { gap: 14px; }

/* Nested sub-accordions inside a panel (Kite live settings) */
.sub-accordion { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.sub-accordion > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; padding: 13px 16px; transition: background .12s; }
.sub-accordion > summary::-webkit-details-marker { display: none; }
.sub-accordion > summary:hover { background: var(--surface-3); }
.sub-accordion > summary::after {
    content: ""; margin-left: auto; width: 18px; height: 18px; flex: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23687385' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: center; transition: transform .2s;
}
.sub-accordion[open] > summary::after { transform: rotate(180deg); }
.sub-accordion[open] > summary { border-bottom: 1px solid var(--border); background: var(--surface-2); }
.sub-title { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; color: var(--text); }
.sub-body { padding: 16px; display: flex; flex-direction: column; gap: 16px; background: var(--surface-2); }
/* avoid double framing where blocks already have their own border */
.sub-body > .live-health, .sub-body > .resume-box { border: none; padding: 0; background: transparent; }

/* ============================================================
   PORTFOLIO SUMMARY (hero)
   ============================================================ */

.portfolio-summary { position: relative; overflow: hidden; }
.portfolio-summary::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--grad); }
.portfolio-negative::before { background: linear-gradient(90deg, var(--neg), #ff7a93); }

.portfolio-summary-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; flex-wrap: wrap; margin-bottom: 20px; }
.portfolio-summary-head .muted { display: block; margin-bottom: 7px; text-transform: uppercase; letter-spacing: 0.06em; font-size: 11px; font-weight: 700; color: var(--muted); }
.portfolio-summary-head strong { font-size: 32px; font-weight: 700; letter-spacing: -0.03em; display: flex; align-items: center; gap: 11px; flex-wrap: wrap; color: var(--text); }
.value-arrow { color: var(--muted-2); font-weight: 400; }
.portfolio-summary-head .tag { font-size: 15px; padding: 8px 14px; text-transform: none; letter-spacing: 0; border-radius: var(--radius-sm); }

.portfolio-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 12px; }
.portfolio-metrics > div { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 13px 15px; display: flex; flex-direction: column; gap: 5px; transition: border-color .12s, box-shadow .12s; }
.portfolio-metrics > div:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.portfolio-metrics span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.portfolio-metrics strong { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.portfolio-note { margin-top: 14px; }

/* ============================================================
   LIVE SETTINGS / KITE
   ============================================================ */

.live-settings { display: flex; flex-direction: column; gap: 18px; }
.settings-head { display: flex; align-items: center; gap: 12px; }
.settings-head h2 { font-size: 17px; text-transform: none; letter-spacing: -0.02em; color: var(--text); font-weight: 700; }

.live-health { border: 1px solid var(--border); border-radius: var(--radius); padding: 17px 19px; background: var(--surface-2); }
.live-health-warn { border-color: #f0d9bc; background: var(--warn-soft); }
.live-health-danger { border-color: #f6c9d2; background: var(--neg-soft); }
.live-health-head { display: flex; justify-content: space-between; align-items: center; gap: 13px; margin-bottom: 15px; }
.live-health-head .muted { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; margin-bottom: 4px; }
.live-health-head strong { font-size: 16px; }
.live-health-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 11px; }
.live-health-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 13px; display: flex; flex-direction: column; gap: 4px; }
.live-health-item span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.live-health-item strong { font-size: 13px; }
.live-health-item-ok { border-left: 3px solid var(--pos); }
.live-health-item-warn { border-left: 3px solid var(--warn); }
.live-health-item-danger { border-left: 3px solid var(--neg); }
.live-health-copy { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-top: 15px; padding: 13px 15px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); flex-wrap: wrap; }
.live-health-copy .muted { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; margin-bottom: 6px; }
.live-health-copy-muted { opacity: 0.82; }
.live-health-alert { margin-top: 15px; padding: 12px 15px; background: var(--neg-soft); border: 1px solid #f6c9d2; border-radius: var(--radius-sm); color: #8a1027; font-size: 13px; }

.live-actions { display: flex; align-items: center; gap: 11px; flex-wrap: wrap; }
.live-actions form { margin: 0; }
/* prominent quick-action bar under Connection status (re-auth / confirm / start engine) */
.live-quick { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.live-quick .btn { font-size: 14px; padding: 10px 18px; }
.callback-box { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; background: var(--surface-3); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }
.callback-box .muted { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }
.callback-box code { word-break: break-all; background: var(--surface); }
.resume-box { border: 1px solid var(--border); border-radius: var(--radius); padding: 17px 19px; background: var(--surface-2); }
.resume-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 15px; }
.resume-head strong { font-size: 15px; }

/* ============================================================
   GENERIC TABLES
   ============================================================ */

table { border-collapse: collapse; width: 100%; }
.trades, .resume-table, .explain-table { font-size: 13px; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.trades thead th, .resume-table thead th, .explain-table thead th {
    background: var(--surface-3); color: var(--muted); text-align: left; font-weight: 600; font-size: 11px;
    text-transform: uppercase; letter-spacing: 0.04em; padding: 11px 14px; border-bottom: 1px solid var(--border);
}
.trades td, .resume-table td, .explain-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text-soft); }
.trades tbody tr:last-child td, .resume-table tbody tr:last-child td, .explain-table tbody tr:last-child td { border-bottom: none; }
.trades tbody tr:hover, .resume-table tbody tr:hover { background: var(--surface-2); }
.trades td:nth-child(4), .trades td:nth-child(5), .resume-table td { font-family: var(--mono); font-size: 12.5px; }
.explain-table td:first-child { font-family: var(--sans); color: var(--text); }
.side-buy td:nth-child(3) strong { color: var(--pos); }
.side-sell td:nth-child(3) strong { color: var(--neg); }
.side-buy { box-shadow: inset 3px 0 0 var(--pos); }
.side-sell { box-shadow: inset 3px 0 0 var(--neg); }
.resume-table-wrap, .explain-table-wrap, .suggestion-table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
.row-check td { background: var(--warn-soft); }

/* ============================================================
   MODAL
   ============================================================ */

.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 37, 64, 0.4); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 1000; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal-backdrop[hidden] { display: none; }
.modal { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); width: min(920px, 100%); max-height: 86vh; overflow: auto; padding: 4px 26px 26px; animation: pop .2s ease; }
@keyframes pop { from { opacity: 0; transform: scale(.97) translateY(8px); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: var(--surface); padding: 22px 0 15px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.modal-head h2 { font-size: 20px; text-transform: none; letter-spacing: -0.02em; color: var(--text); }
.explain-table th { white-space: nowrap; }

/* ============================================================
   WATCHLIST CARDS
   ============================================================ */

#watchlist-section { display: block; }
#watchlist-section h2 { margin-bottom: 0; }

/* Compact watchlist table: one row per stock, expands on click */
.watchlist { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.watchlist-head, .watch-summary {
    display: grid;
    grid-template-columns: minmax(140px, 1.5fr) 120px 110px 130px minmax(120px, 1fr) minmax(120px, 1fr) 36px;
    align-items: center; gap: 12px; padding: 12px 18px;
}
.watchlist-head { background: var(--surface-3); border-bottom: 1px solid var(--border); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.watch-row { border-bottom: 1px solid var(--border); }
.watch-row:last-child { border-bottom: none; }
.watch-summary { cursor: pointer; list-style: none; font-size: 13px; transition: background .12s; }
.watch-summary::-webkit-details-marker { display: none; }
.watch-summary:hover { background: var(--surface-2); }
.watch-row[open] > .watch-summary { background: var(--accent-soft); border-bottom: 1px solid var(--border); }
.watch-cell { display: flex; align-items: center; gap: 7px; min-width: 0; }
.watch-num { font-weight: 600; color: var(--text); }
.watch-sym strong { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.watch-cell .pill { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.watch-paused { box-shadow: inset 3px 0 0 var(--warn); }
.watch-row[open] .analysis-row-toggle { background: var(--surface-3); color: var(--accent); }
.watch-row .card-mid { margin: 0; }
.card { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 20px 22px; margin-bottom: 14px; transition: box-shadow .15s, border-color .15s, transform .15s; }
.card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); transform: translateY(-1px); }
.card-paused { border-left: 3px solid var(--warn); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; }
.card-head h3 { font-size: 20px; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: 15px 20px; flex: 1; max-width: 780px; }
.metrics > div { display: flex; flex-direction: column; gap: 4px; }
.metrics span { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.metrics strong { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; color: var(--text); }
.card-mid { display: flex; gap: 26px; flex-wrap: wrap; margin: 18px 0; padding: 13px 16px; background: var(--surface-3); border-radius: var(--radius-sm); font-size: 13px; color: var(--muted); }
.card-mid strong { color: var(--text); }
.decision-pills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.card-actions { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.card-actions form { margin: 0; }
.fake-panel { margin-top: 18px; padding: 15px 17px; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }
.fake-enabled { border-style: solid; border-color: var(--accent-line); background: var(--accent-soft); }
.fake-head { display: flex; align-items: center; gap: 11px; margin-bottom: 13px; }
.fake-head strong { font-size: 13px; }
.fake-disable { margin-top: 11px; }
.fake-disable button, .fake-form { margin: 0; }
.edit-stock-form { margin-top: 18px; padding: 20px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 16px 18px; align-items: end; }
.edit-stock-form[hidden] { display: none; }
.edit-stock-actions { grid-column: 1 / -1; display: flex; gap: 11px; }

/* ============================================================
   ACCORDION TABLES (Analysis + Shortlist)
   ============================================================ */

.analysis-help { display: flex; gap: 9px; flex-wrap: wrap; padding: 14px 16px; background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 13px; color: var(--text-soft); }
.analysis-help strong { color: var(--accent-press); }
/* Collapsible help / disclaimer boxes */
details.analysis-help, details.risk-note { display: block; }
details.analysis-help > summary, details.risk-note > summary { cursor: pointer; list-style: none; font-size: 13px; display: flex; align-items: center; gap: 6px; }
details.analysis-help > summary::-webkit-details-marker, details.risk-note > summary::-webkit-details-marker { display: none; }
details.analysis-help > summary::after, details.risk-note > summary::after { content: "▸"; margin-left: auto; opacity: 0.6; }
details.analysis-help[open] > summary::after, details.risk-note[open] > summary::after { content: "▾"; }
details.analysis-help > span, details.risk-note > span { display: block; margin-top: 9px; }
.entered-settings-summary { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }
.entered-settings-summary strong { font-size: 13px; margin-right: 4px; color: var(--text); }
.entered-settings-summary span:not(:first-child) { font-size: 12px; background: var(--surface-3); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 4px 10px; color: var(--text-soft); font-weight: 500; }
.analysis-bulk-form { margin-bottom: 16px; }
.analysis-bulk-bar { display: flex; gap: 11px; flex-wrap: wrap; align-items: center; padding: 15px 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.analysis-bulk-bar .muted { flex-basis: 100%; font-size: 12px; }
.row-select-all { flex-direction: row; align-items: center; gap: 9px; font-size: 13px; color: var(--text-soft); }
.bulk-field { min-width: 180px; }
.bulk-checkbox { align-self: center; }

.analysis-table-scroll, .shortlist-table-scroll { overflow-x: auto; }
.analysis-table-accordion { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.shortlist-table-accordion { min-width: 940px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.analysis-table-head, .shortlist-table-head, .analysis-row-summary, .shortlist-row-summary { display: grid; align-items: center; gap: 10px; padding: 12px 16px; }
.analysis-table-head, .analysis-row-summary { grid-template-columns: 34px minmax(110px, 1.5fr) 104px 64px 1fr 1fr 28px; }

/* Analysis decision cards (Best vs Your settings) */
.decision-cards { margin-bottom: 4px; }
.choice-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px 18px; background: var(--surface); display: flex; flex-direction: column; gap: 12px; }
.choice-best { border-color: var(--accent-line); background: var(--accent-soft); }
.choice-head { display: flex; align-items: center; gap: 10px; }
.choice-head strong { font-size: 15px; }
.choice-settings { font-size: 12.5px; color: var(--text-soft); line-height: 1.5; }
.choice-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(86px, 1fr)); gap: 10px; }
.choice-metrics > div { display: flex; flex-direction: column; gap: 3px; }
.choice-metrics span { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.choice-metrics strong { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.choice-card form { margin: 0; }
.choice-card .btn { width: 100%; }
.verdict-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 2px; }
.verdict-line form { margin: 0; }
.breakdown-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 8px; }
.shortlist-table-head, .shortlist-row-summary { grid-template-columns: 34px minmax(90px, 1.2fr) 130px 78px 64px 66px 60px 110px 92px 64px 1fr 28px; }
.analysis-table-head, .shortlist-table-head { background: var(--surface-3); border-bottom: 1px solid var(--border); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

.stock-accordion { border-bottom: 1px solid var(--border); }
.stock-accordion:last-child { border-bottom: none; }
.stock-accordion summary { cursor: pointer; list-style: none; }
.stock-accordion summary::-webkit-details-marker { display: none; }
.analysis-row-summary, .shortlist-row-summary { font-size: 13px; transition: background .12s; }
.analysis-row-summary:hover, .shortlist-row-summary:hover { background: var(--surface-2); }
.stock-accordion[open] > summary { background: var(--accent-soft); }
.analysis-cell, .shortlist-cell { display: flex; align-items: center; gap: 6px; min-width: 0; }
.analysis-cell strong, .shortlist-cell strong { font-weight: 700; color: var(--text); }
.analysis-symbol strong, .shortlist-symbol strong { font-size: 14px; letter-spacing: -0.01em; }
.analysis-row-toggle { justify-content: center; align-items: center; flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-3); color: var(--muted); font-size: 0; transition: background .12s; }
.analysis-row-toggle::after { content: ""; display: block; width: 7px; height: 7px; margin-top: -3px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform .2s; }
.stock-accordion[open] .analysis-row-toggle, .watch-row[open] .analysis-row-toggle { color: var(--accent); }
.stock-accordion[open] .analysis-row-toggle::after, .watch-row[open] .analysis-row-toggle::after { transform: rotate(-135deg); margin-top: 3px; }
.analysis-approved { box-shadow: inset 3px 0 0 var(--pos); }
.analysis-watch { box-shadow: inset 3px 0 0 var(--warn); }
.analysis-reject, .analysis-error { box-shadow: inset 3px 0 0 var(--neg); }
.shortlist-recovery { box-shadow: inset 3px 0 0 var(--warn); }
.shortlist-flat { box-shadow: inset 3px 0 0 var(--muted-2); }

.stock-body { padding: 20px 22px 24px; background: var(--surface-2); border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 18px; }
.quick-takeaways { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 13px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.quick-takeaways > div { display: flex; flex-direction: column; gap: 4px; }
.quick-takeaways span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.quick-takeaways strong { font-size: 13px; color: var(--text); }
.quick-takeaways form { display: flex; flex-direction: column; gap: 7px; align-items: flex-start; }
.quick-takeaways form span { text-transform: none; letter-spacing: 0; font-weight: 500; }
.rerun-stock-form { display: flex; flex-direction: column; gap: 7px; align-items: flex-start; }
.rerun-stock-form span { font-size: 11.5px; color: var(--muted); }

.analysis-section { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.analysis-section > summary { cursor: pointer; list-style: none; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; transition: background .12s; }
.analysis-section > summary::-webkit-details-marker { display: none; }
.analysis-section > summary:hover { background: var(--surface-3); }
.analysis-section > summary span { font-weight: 700; font-size: 14px; letter-spacing: -0.01em; color: var(--text); }
.analysis-section > summary small { color: var(--muted); }
.analysis-section[open] > summary { border-bottom: 1px solid var(--border); }
.analysis-section .section-body { padding: 18px; }
.two-column-analysis { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }
.best-stock-setup, .intraday-panel { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px 18px; background: var(--surface-2); }
.best-intraday-setup { border-color: var(--accent-line); background: var(--accent-soft); }
.best-stock-head, .intraday-head { display: flex; align-items: center; gap: 11px; flex-wrap: wrap; margin-bottom: 9px; }
.best-stock-head strong, .intraday-head strong { font-size: 14px; }
.best-stock-subtitle { font-size: 11.5px; margin-bottom: 11px; line-height: 1.5; }
.selected-settings-note { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 13px; }
.selected-settings-note span { font-size: 11.5px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 3px 10px; color: var(--text-soft); }
.intraday-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 11px; }
.intraday-grid > div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 13px; display: flex; flex-direction: column; gap: 4px; }
.intraday-grid span { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.intraday-grid strong { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; color: var(--text); }
.intraday-notes, .analysis-notes { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 13px; }
.reason-box { padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 13px; }
.reason-box strong { display: block; margin-bottom: 9px; font-size: 13px; color: var(--text); }
.reason-box ul { margin: 0; padding-left: 19px; color: var(--text-soft); font-size: 13px; }
.reason-box li { margin: 5px 0; }
.analysis-metrics { max-width: none; margin-bottom: 15px; }
.cost-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 11px; }
.cost-strip > div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 15px; display: flex; flex-direction: column; gap: 4px; }
.cost-strip span { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.cost-strip strong { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; color: var(--text); }
.suggestion-table, .compact-table { font-size: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; font-family: var(--mono); }
.suggestion-table thead th { background: var(--surface-3); color: var(--muted); text-align: left; font-weight: 600; font-size: 10px; text-transform: uppercase; letter-spacing: 0.03em; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; font-family: var(--sans); }
.suggestion-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); color: var(--text-soft); white-space: nowrap; }
.suggestion-table tbody tr:last-child td { border-bottom: none; }
.suggestion-table tbody tr:hover { background: var(--surface-2); }
.shortlist-row-body { gap: 15px; }
.shortlist-setup-form { padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.shortlist-actions { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }
.shortlist-actions form { margin: 0; }

/* ============================================================
   LOGIN
   ============================================================ */

.login-page {
    min-height: 100vh; margin: 0; display: flex; align-items: center; justify-content: center; padding: 24px;
    background:
        radial-gradient(1000px 600px at 85% -10%, rgba(83, 58, 253, 0.16), transparent 55%),
        radial-gradient(800px 500px at 0% 110%, rgba(33, 212, 253, 0.12), transparent 55%),
        var(--bg);
}
.login-shell { display: grid; grid-template-columns: 1.05fr 0.95fr; width: min(940px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-pop); }
.login-panel { padding: 46px 44px; display: flex; flex-direction: column; gap: 24px; }
.login-brand { display: flex; align-items: center; gap: 15px; }
.brand-mark { width: 48px; height: 48px; border-radius: 12px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 18px; box-shadow: var(--shadow-md); }
.login-brand h1 { font-size: 23px; }
.login-brand p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.login-form { display: flex; flex-direction: column; gap: 16px; margin-top: 6px; }
.login-form .btn { width: 100%; padding: 12px; font-size: 15px; margin-top: 6px; }
.login-aside { position: relative; overflow: hidden; background: linear-gradient(160deg, var(--dark), var(--dark-2)); color: #e8ecf5; padding: 46px 42px; display: flex; flex-direction: column; justify-content: center; gap: 20px; }
.login-aside::before { content: ""; position: absolute; inset: 0; background: var(--grad); opacity: 0.22; }
.login-aside > * { position: relative; }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: 0.16em; font-weight: 700; color: #b6adff; }
.login-aside h2 { color: #fff; font-size: 24px; line-height: 1.3; text-transform: none; letter-spacing: -0.02em; font-weight: 700; }
.login-points { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.login-points span { display: flex; align-items: center; gap: 11px; font-size: 13.5px; color: #cfd5e6; }
.login-points span::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #8d87ff; box-shadow: 0 0 10px rgba(141, 135, 255, 0.8); }
.login-page .flash { background: var(--neg-soft); border-color: #f6c9d2; color: var(--neg); }

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* --- Tablet / small laptop: sidebar becomes an off-canvas drawer --- */
@media (max-width: 960px) {
    .nav-burger { display: inline-flex; }
    .sidebar {
        position: fixed; top: 0; left: 0; bottom: 0; height: 100vh; width: 270px;
        z-index: 200; transform: translateX(-100%);
        transition: transform .26s cubic-bezier(.2, .7, .2, 1); box-shadow: var(--shadow-pop);
    }
    #nav-toggle:checked ~ .app-shell .sidebar { transform: none; }
    #nav-toggle:checked ~ .app-shell .nav-scrim { display: block; position: fixed; inset: 0; z-index: 150; background: rgba(10, 37, 64, 0.45); }
    .app-content { padding: 22px 18px 80px; }
    .topbar { padding: 13px 18px; }
    .app-content > section, .panel-accordion { padding-left: 0; padding-right: 0; }
    .app-content > section { padding: 20px 18px; }
    .panel-accordion > summary { padding: 16px 18px; }
    .panel-body { padding: 18px; }
}

/* --- Phones --- */
@media (max-width: 720px) {
    h1 { font-size: 22px; }
    .topbar { flex-wrap: wrap; gap: 12px 14px; }
    .topbar-title h1 { font-size: 19px; }
    /* HUD: keep the status chips on a single tidy line (scrolls if needed, never wraps) */
    .topbar .subtitle { margin-top: 7px; flex-wrap: nowrap; gap: 6px; overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; }
    .topbar .subtitle::-webkit-scrollbar { display: none; }
    .subtitle .badge { font-size: 9.5px; padding: 3px 7px; flex: none; }
    .hud-stat { font-size: 10.5px; padding: 3px 8px; gap: 4px; flex: none; }
    .auto-refresh-indicator { flex: none; }
    .hud-meta { display: none; }                 /* keep only Market + Engine chips on phones */
    .topbar-actions { width: 100%; }
    .topbar-actions .btn { flex: 1; }

    /* Dashboard stat tiles: compact 2-up density */
    .portfolio-summary-head { flex-direction: column; }
    .portfolio-summary-head strong { font-size: 22px; }
    .portfolio-metrics { grid-template-columns: 1fr 1fr; gap: 8px; }
    .portfolio-metrics > div { padding: 9px 11px; gap: 3px; }
    .portfolio-metrics span { font-size: 9.5px; }
    .portfolio-metrics strong { font-size: 15px; }
    .login-shell { grid-template-columns: 1fr; }
    .login-aside { display: none; }
    .login-panel { padding: 34px 26px; }
    .card-head { flex-direction: column; }
    .section-head { flex-direction: column; align-items: flex-start; gap: 6px; }

    /* Watchlist: collapse the 7-col grid into a tidy stacked row */
    .watchlist-head { display: none; }
    .watch-summary {
        grid-template-columns: 1fr auto 30px;
        grid-template-areas: "sym sym tog" "price unreal tog" "dec next tog";
        gap: 7px 12px; padding: 14px 16px;
    }
    .watch-sym { grid-area: sym; }
    .watch-summary > .watch-cell:nth-child(2) { grid-area: price; }
    .watch-summary > .watch-cell:nth-child(3) { grid-area: unreal; justify-self: end; }
    .watch-summary > .watch-cell:nth-child(4) { display: none; }   /* cash -> only in detail */
    .watch-summary > .watch-cell:nth-child(5) { grid-area: dec; }
    .watch-summary > .watch-cell:nth-child(6) { grid-area: next; justify-self: end; }
    .watch-summary > .analysis-row-toggle { grid-area: tog; align-self: start; }
    .watch-summary > .watch-cell:nth-child(2)::before { content: "Last "; color: var(--muted); font-weight: 500; }
    .watch-summary > .watch-cell:nth-child(3)::before { content: "P/L "; color: var(--muted); font-weight: 500; }

    /* Live Log -> dense 3-line Kite-style row (symbol/time, side/qty/price, reason) */
    .trades thead { display: none; }
    .trades, .trades tbody { display: block; }
    .trades { border: none; }
    .trades tr {
        display: grid;
        grid-template-columns: auto auto 1fr auto;
        grid-template-areas: "sym sym sym time" "side qty price ." "reason reason reason reason";
        align-items: baseline; gap: 3px 9px;
        border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
        box-shadow: var(--shadow-sm); margin-bottom: 8px; padding: 9px 12px;
    }
    .trades td { display: block; border: none; padding: 0; font-size: 12.5px; }
    .trades td::before { display: none; }
    .trades td[data-label="Symbol"] { grid-area: sym; font-weight: 700; font-size: 14px; color: var(--text); }
    .trades td[data-label="Time (IST)"] { grid-area: time; justify-self: end; color: var(--muted); font-size: 11px; white-space: nowrap; }
    .trades td[data-label="Side"] { grid-area: side; }
    .trades td[data-label="Side"] strong { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: var(--radius-pill); }
    .trades tr.side-buy td[data-label="Side"] strong { background: var(--pos-soft); color: var(--pos); }
    .trades tr.side-sell td[data-label="Side"] strong { background: var(--neg-soft); color: var(--neg); }
    .trades td[data-label="Qty"] { grid-area: qty; color: var(--text-soft); }
    .trades td[data-label="Qty"]::after { content: " sh"; color: var(--muted); }
    .trades td[data-label="Price"] { grid-area: price; font-weight: 600; color: var(--text); }
    .trades td[data-label="Reason"] { grid-area: reason; color: var(--muted); font-size: 11.5px; line-height: 1.4; margin-top: 2px; }
    .side-buy { border-left: 3px solid var(--pos); }
    .side-sell { border-left: 3px solid var(--neg); }
    .log-loadmore { display: flex; justify-content: center; margin-top: 6px; }
    .log-loadmore .btn { min-width: 210px; }

    /* Analysis & Shortlist accordion tables: show essentials in the row, full detail on tap */
    .analysis-table-head, .shortlist-table-head { display: none; }
    .analysis-table-accordion, .shortlist-table-accordion { min-width: 0; }
    .analysis-row-summary, .shortlist-row-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
    .analysis-symbol, .shortlist-symbol { flex: 1 1 auto; }
    .analysis-row-toggle, .shortlist-row-summary .analysis-row-toggle { margin-left: auto; }
    /* Analysis cells: 1 check, 3 verdict, 4 score, 5 your-return, 6 best-return */
    .analysis-row-summary > .analysis-cell:nth-child(1),
    .analysis-row-summary > .analysis-cell:nth-child(4),
    .analysis-row-summary > .analysis-cell:nth-child(5) { display: none; }
    .analysis-row-summary > .analysis-cell:nth-child(6)::before { content: "Best "; color: var(--muted); font-weight: 500; }
    /* Shortlist cells: 1 check,2 sym,3 source,4 return,5 sell,6 rebuy,7 SL,8 recov,9 net,10 trades,11 date,12 toggle */
    .shortlist-row-summary > .shortlist-cell:nth-child(1),
    .shortlist-row-summary > .shortlist-cell:nth-child(5),
    .shortlist-row-summary > .shortlist-cell:nth-child(6),
    .shortlist-row-summary > .shortlist-cell:nth-child(7),
    .shortlist-row-summary > .shortlist-cell:nth-child(8),
    .shortlist-row-summary > .shortlist-cell:nth-child(10),
    .shortlist-row-summary > .shortlist-cell:nth-child(11) { display: none; }
    .shortlist-row-summary > .shortlist-cell:nth-child(4)::before { content: "Return "; color: var(--muted); font-weight: 500; }
    .shortlist-row-summary > .shortlist-cell:nth-child(9)::before { content: "Net "; color: var(--muted); font-weight: 500; }

    /* Remaining dense/ops tables (full-breakdown scan, Kite reconcile, explain modal) keep horizontal scroll */
    .suggestion-table-wrap, .resume-table-wrap, .explain-table-wrap { -webkit-overflow-scrolling: touch; }

    /* Expanded analysis body must NOT create a page-wide horizontal scroll */
    .analysis-table-scroll, .shortlist-table-scroll { overflow-x: visible; }
    .two-column-analysis, .decision-cards { grid-template-columns: 1fr; gap: 12px; }
    .choice-card { padding: 14px; }
    .choice-metrics, .intraday-grid, .cost-strip, .analysis-metrics { grid-template-columns: 1fr 1fr; gap: 10px; }
    .choice-metrics strong { font-size: 15px; }
    .verdict-line form[style] { margin-left: 0 !important; }
    .analysis-section .section-body { padding: 12px; }


    /* Inline form grids go single-column */
    .add-stock, .settings-form, .kite-order, .shortlist-setup-form, .fake-form, .edit-stock-form {
        grid-template-columns: 1fr;
    }
    /* Analysis form: short numeric fields pair up 2-up; symbols box & Analyze span full */
    .analysis-form { grid-template-columns: 1fr 1fr; gap: 11px 12px; }
    .analysis-form .sym-field { grid-column: 1 / -1; }
    .analysis-form > button { grid-column: 1 / -1; }
    .analysis-form label { font-size: 11px; }
    .analysis-form label > input,
    .analysis-form label > textarea { padding: 8px 10px; font-size: 13px; }
}

/* ============================================================
   Kite-style mobile: bottom nav, holdings rows, bottom action sheet
   ============================================================ */
.bottom-nav { display: none; }

.kite-summary { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-card); padding: 13px 15px; margin-bottom: 13px; }
.ks-top { display: flex; justify-content: space-between; gap: 16px; }
.ks-top > div { display: flex; flex-direction: column; gap: 3px; }
.ks-top .ks-right { text-align: right; }
.ks-top span { font-size: 11px; color: var(--muted); }
.ks-top strong { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.ks-pnl { display: flex; align-items: center; gap: 10px; margin-top: 11px; padding-top: 11px; border-top: 1px solid var(--border); }
.ks-pnl > span:first-child { font-size: 12px; color: var(--muted); margin-right: auto; }
.ks-pnl strong { font-size: 15px; font-weight: 700; }
.pnl-pill { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: var(--radius-pill); }
.pnl-pill.pos { background: var(--pos-soft); color: var(--pos); }
.pnl-pill.neg { background: var(--neg-soft); color: var(--neg); }

.hold-search { width: 100%; padding: 10px 14px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; font-family: var(--sans); background: var(--surface); color: var(--text); }
.hold-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.holdings-list { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.hold-group { padding: 9px 14px 7px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.hold-noresults { padding: 16px 14px; margin: 0; text-align: center; }
.hold-row { display: block; width: 100%; text-align: left; background: var(--surface); border: none; border-bottom: 1px solid var(--border); padding: 11px 14px; cursor: pointer; font-family: var(--sans); transition: background 0.12s; }
.hold-row:last-child { border-bottom: none; }
.hold-row:hover, .hold-row:active { background: var(--surface-2); }
.hold-paused { box-shadow: inset 3px 0 0 var(--warn); }
.hr-l1, .hr-l2, .hr-l3 { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.hr-l1, .hr-l2 { margin-bottom: 2px; }
.hr-meta { font-size: 11px; color: var(--muted); }
.hr-l1 > span:last-child { font-size: 12px; font-weight: 600; }
.hr-sym { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; color: var(--text); }
.hr-pnl { font-size: 13.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hr-l3 .muted { font-size: 11px; }

.sheet-backdrop { position: fixed; inset: 0; z-index: 1100; background: rgba(10, 37, 64, 0.45); display: flex; align-items: flex-end; justify-content: center; animation: fade 0.15s ease; }
.sheet-backdrop[hidden] { display: none; }
.sheet { display: flex; flex-direction: column; width: 100%; max-width: 640px; max-height: 50vh; overflow: hidden; background: var(--surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: var(--shadow-pop); padding: 8px 20px 0; animation: sheetup 0.25s cubic-bezier(.2, .7, .2, 1); }
.sheet[hidden] { display: none; }
@keyframes sheetup { from { transform: translateY(100%); } to { transform: none; } }
.sheet-grip { flex: none; width: 36px; height: 4px; border-radius: 999px; background: var(--border-strong); margin: 4px auto 10px; }
.sheet-head { flex: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-bottom: 11px; border-bottom: 1px solid var(--border); background: var(--surface); }
.sheet-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
.sheet-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sheet-title strong { font-size: 15px; letter-spacing: -0.01em; }
.sheet-close { background: none; border: none; font-size: 24px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.sheet-actions { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; padding: 10px 0; }
.sheet-actions form { margin: 0; }
.sheet-act, .sheet-actions .btn { width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 6px 2px; font-size: 9.5px; line-height: 1.05; min-height: 44px; }
.sheet-act svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sheet-body { display: flex; flex-direction: column; gap: 12px; }
.edit-stock-form { scroll-margin-top: 8px; border-radius: var(--radius-sm); }
.edit-stock-form.just-opened { animation: editflash 1.1s ease; }
@keyframes editflash {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); }
    30% { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
    100% { box-shadow: 0 0 0 0 transparent; }
}
/* Compact, app-like density inside the sheet */
.sheet .metrics { gap: 11px 14px; }
.sheet .metrics strong { font-size: 13px; }
.sheet .metrics span { font-size: 9.5px; }
.sheet .card-mid { font-size: 12px; gap: 6px 14px; }
.sheet .decision-pills .pill { font-size: 11px; padding: 4px 9px; }
/* Compact 2-up settings grid: short numeric fields shouldn't be full width */
.sheet .edit-stock-form { grid-template-columns: 1fr 1fr; gap: 10px 12px; padding: 14px; margin-top: 0; }
.sheet .edit-stock-form label { font-size: 11px; gap: 4px; }
.sheet .edit-stock-form label > input,
.sheet .edit-stock-form label > select { padding: 7px 9px; font-size: 13px; }
.sheet .edit-stock-form .checkbox { grid-column: 1 / -1; flex-direction: row; align-items: center; gap: 8px; font-size: 12px; }
.sheet .edit-stock-actions { grid-column: 1 / -1; }
body.sheet-open { overflow: hidden; }

/* Engine / live status banner on the dashboard */
.engine-banner { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 16px; }
.engine-banner .eb-main { display: flex; align-items: center; gap: 12px; flex: 1 1 240px; min-width: 0; }
.engine-banner svg { flex: none; width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.engine-banner .eb-main > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.engine-banner strong { font-size: 15px; letter-spacing: -0.01em; }
.engine-banner .eb-main span { font-size: 12.5px; color: var(--text-soft); line-height: 1.4; }
.engine-banner .eb-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.engine-banner .eb-actions form { margin: 0; }
.engine-banner .eb-more { flex-basis: 100%; display: flex; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
.engine-banner .eb-more[hidden] { display: none; }
.engine-banner .eb-more form { margin: 0; }
.engine-banner-danger { background: var(--neg-soft); border-color: color-mix(in srgb, var(--neg) 30%, transparent); color: var(--neg); }
.engine-banner-warn { background: var(--warn-soft, #fff7ed); border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--warn); }
.engine-banner-ok { background: var(--pos-soft); border-color: color-mix(in srgb, var(--pos) 28%, transparent); color: var(--pos); }
.engine-banner strong, .engine-banner .eb-main span { color: var(--text); }
.live-health-iphint { margin: 8px 0 0; font-size: 12px; }
.flash-info { background: var(--accent-soft); border-color: var(--accent-line); color: var(--text); }

/* Multi-row alert banners (failed buys / stuck sells): icon + actions pinned to top,
   each stock on its own clean card row with the action right-aligned (no overlap). */
.banner-stack { align-items: flex-start; }
.banner-stack .eb-main { align-items: flex-start; }
.banner-stack svg { margin-top: 1px; }
.failed-list { list-style: none; margin: 11px 0 3px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.failed-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
    padding: 9px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.failed-row .fr-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 220px; }
.failed-row .fr-sym { font-weight: 600; font-size: 13.5px; color: var(--text); letter-spacing: -0.01em; }
.failed-row .fr-qty { font-weight: 500; font-size: 12px; color: var(--text-soft); }
.failed-row .fr-reason { font-size: 12px; color: var(--text-soft); line-height: 1.45; }
.failed-row form { margin: 0; flex: none; }

@media (max-width: 720px) {
    .engine-banner { padding: 12px 13px; gap: 10px; }
    .engine-banner .eb-actions { flex: 1 1 100%; }
    .engine-banner .eb-actions form { flex: 1; }
    .engine-banner .eb-actions .btn { width: 100%; }
}
@media (max-width: 560px) {
    .failed-row form, .failed-row form .btn { width: 100%; }
}

/* Custom confirmation dialog (replaces native confirm) */
.confirm-backdrop { position: fixed; inset: 0; z-index: 1200; background: rgba(10, 37, 64, 0.5); display: flex; align-items: center; justify-content: center; padding: 24px; animation: fade 0.12s ease; }
.confirm-backdrop[hidden] { display: none; }
.confirm-box { width: 100%; max-width: 380px; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); padding: 22px 22px 18px; animation: sheetup 0.18s cubic-bezier(.2, .7, .2, 1); }
.confirm-msg { margin: 0 0 18px; font-size: 15px; line-height: 1.5; color: var(--text); }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }
.confirm-actions .btn { padding: 10px 18px; }

@media (min-width: 721px) {
    .sheet-backdrop { align-items: center; }
    .sheet { border-radius: var(--radius-lg); max-width: 560px; max-height: 80vh; }
}

@media (max-width: 960px) {
    .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 300; background: rgba(255,255,255,.97); border-top: 1px solid var(--border); box-shadow: 0 -2px 10px rgba(10,37,64,.06); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); backdrop-filter: saturate(180%) blur(8px); }
    .bn-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; color: var(--muted); font-size: 10.5px; font-weight: 600; text-decoration: none; border-radius: 8px; }
    .bn-item svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
    .bn-item.active { color: var(--accent); }
    .app-content { padding-bottom: 86px; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ============================================================
   2026 REDESIGN — CALM INSTITUTIONAL EXECUTION DESK
   The interface is intentionally flatter and less card-heavy:
   navigation owns the dark tone, data owns the page, and color is
   reserved for state, risk, and action.
   ============================================================ */

body.app {
    background-color: var(--bg);
    background-image:
        linear-gradient(rgba(16, 32, 31, 0.018) 1px, transparent 1px),
        linear-gradient(90deg, rgba(16, 32, 31, 0.018) 1px, transparent 1px);
    background-size: 28px 28px;
}

.sidebar {
    --sidebar-w: 264px;
    gap: 22px;
    padding: 20px 15px;
    background:
        radial-gradient(380px 260px at -15% -5%, rgba(36, 87, 245, 0.22), transparent 64%),
        var(--dark);
    border-right: 1px solid rgba(255, 255, 255, 0.07);
    color: #eef5f3;
}

.sidebar-brand {
    gap: 11px;
    min-height: 48px;
    padding: 4px 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand .brand-mark {
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 11px;
    background: #f5f8f7;
    color: var(--dark);
    box-shadow: none;
    font-size: 14px;
    letter-spacing: 0.06em;
}

.brand-text { gap: 1px; }
.brand-text strong { color: #f8fbfa; font-size: 14px; letter-spacing: -0.015em; }
.brand-caption { color: #8fa29e; font-size: 10.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.sidebar-brand > .badge { margin-left: auto; }

.sidebar .badge.live {
    background: rgba(255, 110, 124, 0.11);
    border-color: rgba(255, 135, 146, 0.24);
    color: #ff9aa5;
    font-size: 9px;
    padding: 3px 7px;
}

.sidebar-label {
    color: #617571;
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: 0.13em;
}

.nav-item {
    position: relative;
    gap: 12px;
    min-height: 40px;
    padding: 9px 11px;
    border: 1px solid transparent;
    color: #a9bab6;
    font-size: 12.5px;
    font-weight: 650;
}

.nav-item svg { width: 17px; height: 17px; stroke: #718681; }
.nav-item:hover { color: #f7fbfa; background: rgba(255, 255, 255, 0.045); }
.nav-item:hover svg { stroke: #d9e4e1; }
.nav-item.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.075);
    border-color: rgba(255, 255, 255, 0.07);
}
.nav-item.active::before {
    content: "";
    position: absolute;
    left: -4px;
    top: 9px;
    bottom: 9px;
    width: 2px;
    border-radius: 2px;
    background: #70a0ff;
}
.nav-item.active svg { stroke: #8fb3ff; }
.sidebar-caption { color: #748783; }

.sidebar-foot { border-top-color: rgba(255, 255, 255, 0.08); }
.sidebar-foot .user-pill {
    background: rgba(255, 255, 255, 0.055);
    border-color: rgba(255, 255, 255, 0.09);
    color: #dfe8e6;
}
.sidebar-foot .user-pill::before { background: #51d19a; box-shadow: 0 0 0 3px rgba(81, 209, 154, 0.12); }
.sidebar-foot .btn:not(.btn-primary) { color: #92a6a1; }
.sidebar-foot .btn:not(.btn-primary):hover { color: #fff; background: rgba(255, 255, 255, 0.06); }

.topbar {
    min-height: 94px;
    align-items: center;
    padding: 17px 34px 15px;
    background: rgba(247, 249, 248, 0.91);
    border-bottom-color: rgba(16, 32, 31, 0.1);
    backdrop-filter: saturate(140%) blur(18px);
    -webkit-backdrop-filter: saturate(140%) blur(18px);
}

.page-eyebrow,
.section-kicker {
    display: block;
    color: var(--accent);
    font-family: var(--mono);
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: 0.11em;
    line-height: 1.3;
    text-transform: uppercase;
}

.page-eyebrow { margin-bottom: 3px; }
.topbar-title h1 { font-size: 24px; font-weight: 750; letter-spacing: -0.04em; }
.topbar .subtitle { margin-top: 8px; gap: 7px; }
.hud-stat {
    min-height: 25px;
    padding: 3px 9px;
    background: transparent;
    border-color: var(--border-strong);
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: -0.015em;
}
.hud-meta { font-family: var(--mono); font-size: 10px; letter-spacing: -0.02em; }
.topbar .badge.live { min-height: 25px; padding: 3px 9px; border-radius: var(--radius-pill); font-size: 9.5px; }

.app-content { max-width: 1500px; padding: 30px 34px 100px; }

h1, h2, h3, .panel-title, .sub-title { text-wrap: balance; }
h2 { font-size: 11px; font-weight: 750; letter-spacing: 0.08em; }
h3 { font-weight: 750; }

.app-content > section,
.dashboard-finance-grid > section {
    border-color: rgba(16, 32, 31, 0.12);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
}

.app-content > section { padding: 24px 25px; }
.card { border-color: rgba(16, 32, 31, 0.12); box-shadow: none; }
.card:hover { box-shadow: var(--shadow-card); transform: none; }

.btn {
    min-height: 36px;
    padding: 8px 14px;
    border-color: var(--border-strong);
    box-shadow: none;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.btn:hover { border-color: #aebbb7; box-shadow: 0 3px 9px rgba(13, 23, 24, 0.06); }
.btn-primary { box-shadow: 0 5px 14px rgba(36, 87, 245, 0.18); }
.btn-primary:hover { box-shadow: 0 7px 18px rgba(36, 87, 245, 0.23); }
.btn-small { min-height: 30px; padding: 5px 10px; font-size: 11px; }

input[type="text"], input[type="password"], input[type="number"], select, textarea {
    min-height: 40px;
    border-color: var(--border-strong);
    box-shadow: none;
}

.flash {
    position: relative;
    padding: 11px 14px 11px 17px;
    border-width: 0 0 0 3px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: color-mix(in srgb, var(--warn-soft) 72%, white);
    box-shadow: none;
    font-size: 12px;
}
.flash-info { background: color-mix(in srgb, var(--accent-soft) 65%, white); border-color: var(--accent); }

/* The system state is a command strip, not another colored card. */
.engine-banner {
    position: relative;
    min-height: 74px;
    padding: 15px 17px;
    border-color: rgba(16, 32, 31, 0.13);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}
.engine-banner::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--border-strong);
}
.engine-banner-ok::before { background: var(--pos); }
.engine-banner-warn::before { background: var(--warn); }
.engine-banner-danger::before { background: var(--neg); }
.engine-banner svg {
    width: 34px;
    height: 34px;
    padding: 8px;
    border-radius: 10px;
    background: var(--surface-3);
}
.engine-banner-ok svg { color: var(--pos); background: var(--pos-soft); }
.engine-banner-warn svg { color: var(--warn); background: var(--warn-soft); }
.engine-banner-danger svg { color: var(--neg); background: var(--neg-soft); }
.engine-banner strong { font-size: 14px; font-weight: 750; }
.engine-banner .eb-main span { color: var(--muted); font-size: 11.5px; }
.engine-banner .btn-ghost { color: var(--text-soft); }

/* Related warnings live in one action center instead of many competing boxes. */
.dashboard-alert-stack {
    margin: 0 0 18px;
    padding: 0 19px 3px;
    border: 1px solid rgba(16, 32, 31, 0.13);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}
.queue-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    padding: 16px 1px 14px;
    border-bottom: 1px solid var(--border);
}
.queue-heading > div { display: flex; flex-direction: column; gap: 3px; }
.queue-heading strong { font-size: 16px; font-weight: 750; letter-spacing: -0.025em; }
.queue-heading > span { color: var(--muted); font-size: 10.5px; }
.dashboard-alert-stack > .engine-banner {
    margin: 0;
    padding: 16px 1px;
    border: 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
}
.dashboard-alert-stack > .engine-banner:last-child { border-bottom: 0; }
.dashboard-alert-stack > .engine-banner::before { display: none; }

.banner-stack .eb-main { flex-basis: 70%; }
.failed-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    margin-top: 12px;
}
.failed-row {
    min-height: 68px;
    padding: 10px 11px;
    border-color: var(--border);
    border-radius: 9px;
    background: var(--surface-2);
}
.failed-row .fr-sym { font-family: var(--mono); font-size: 11.5px; }
.failed-row .fr-reason {
    display: block;
    overflow: visible;
    -webkit-line-clamp: initial;
    -webkit-box-orient: initial;
    font-size: 10.5px;
    line-height: 1.45;
}

/* Financial overview: two purposeful surfaces and metrics separated by rhythm, not boxes. */
.dashboard-finance-grid {
    display: grid;
    grid-template-columns: minmax(330px, 0.72fr) minmax(520px, 1.28fr);
    gap: 16px;
    margin: 0 0 18px;
}
.dashboard-finance-grid > section {
    position: relative;
    min-width: 0;
    margin: 0;
    padding: 25px 26px 23px;
    background: var(--surface);
    overflow: hidden;
}
.dashboard-finance-grid > section:only-child { grid-column: 1 / -1; }
.portfolio-summary::before {
    top: 0;
    bottom: auto;
    left: 0;
    right: 0;
    width: auto;
    height: 2px;
    background: var(--accent);
}
.realized-summary::before { background: var(--accent); }
.portfolio-positive::before { background: var(--pos); }
.portfolio-negative::before { background: var(--neg); }
.portfolio-summary-head { margin-bottom: 17px; }
.portfolio-summary-head .muted { margin-bottom: 8px; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.075em; }
.portfolio-summary-head strong { align-items: baseline; font-size: clamp(25px, 2.2vw, 36px); font-weight: 750; letter-spacing: -0.05em; }
.portfolio-summary-head strong .muted { margin: 0; font-family: var(--sans); font-size: 10px; letter-spacing: 0.04em; }
.portfolio-summary-head .tag { padding: 7px 11px; border-radius: 8px; font-family: var(--mono); font-size: 11px; }
.realized-summary > p { max-width: 52ch; }
.portfolio-metrics { gap: 0; border-top: 1px solid var(--border); }
.portfolio-metrics > div {
    min-width: 0;
    padding: 14px 13px 8px;
    border: 0;
    border-right: 1px solid var(--border);
    border-radius: 0;
    background: transparent;
}
.portfolio-metrics > div:last-child { border-right: 0; }
.portfolio-metrics > div:hover { border-color: var(--border); box-shadow: none; }
.portfolio-metrics span { font-family: var(--mono); font-size: 9px; letter-spacing: 0.055em; }
.portfolio-metrics strong { font-size: 16px; font-weight: 750; }
.performance-summary .portfolio-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.performance-summary .portfolio-metrics > div:nth-child(3n) { border-right: 0; }
.performance-summary .portfolio-metrics > div:nth-child(n+4) { border-top: 1px solid var(--border); }
.portfolio-note {
    margin-top: 13px;
    padding: 9px 11px;
    border-left: 2px solid var(--border-strong);
    background: var(--surface-2);
    font-size: 10.5px;
    line-height: 1.5;
}

.panel-accordion {
    border-color: rgba(16, 32, 31, 0.13);
    box-shadow: var(--shadow-card);
}
.panel-accordion > summary { min-height: 64px; padding: 16px 20px; }
.panel-accordion[open]::before { width: 2px; }
.panel-title { font-size: 14px; font-weight: 750; }
.panel-hint { font-family: var(--mono); font-size: 9.5px; }
.panel-body { padding: 18px 20px 21px; background: var(--surface-2); }
.sub-accordion { border-color: var(--border); background: var(--surface); }
.sub-accordion > summary { min-height: 49px; }
.sub-title { font-size: 12.5px; }
.sub-body { background: #fbfcfb; }
.live-health-grid { gap: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.live-health-item { border: 0; border-right: 1px solid var(--border); border-radius: 0; }
.live-health-item:last-child { border-right: 0; }

.analysis-form { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.analysis-lookback-field { grid-column: 1 / span 1; }
.analysis-timeout-field {
    grid-column: 2 / span 3;
    min-height: 40px;
    align-self: end;
    flex-flow: row nowrap;
    align-items: center;
    padding: 0 4px;
    line-height: 1.25;
}
.analysis-timeout-field input[type="number"] { width: 64px !important; min-height: 36px; flex: none; }
.analysis-submit { grid-column: 5 / span 2; width: 100%; }

/* Performance ledger: one auditable story from rupee result to denominator. */
.performance-ledger {
    margin-bottom: 18px;
    overflow: hidden;
    border: 1px solid rgba(16, 32, 31, 0.14);
    border-top: 3px solid var(--pos);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 12px 30px rgba(13, 23, 24, 0.07);
}
.performance-ledger.performance-quality-warn { border-top-color: var(--warn); }
.performance-ledger.performance-quality-danger { border-top-color: var(--neg); }
.performance-ledger-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding: 21px 25px 18px;
    border-bottom: 1px solid var(--border);
}
.performance-ledger-head h2 { margin: 4px 0 2px; font-size: 21px; letter-spacing: -0.035em; }
.performance-ledger-head p { margin: 0; color: var(--muted); font-size: 10.5px; }
.performance-periods {
    display: flex;
    align-items: center;
    gap: 5px;
    overflow-x: auto;
    padding: 10px 25px;
    border-bottom: 1px solid var(--border);
    background: #f7f9f8;
    scrollbar-width: thin;
}
.performance-periods a {
    min-height: 31px;
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    padding: 6px 11px;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 9px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    transition: color .14s, border-color .14s, background .14s, box-shadow .14s;
}
.performance-periods a:hover { border-color: var(--border-strong); background: var(--surface); color: var(--text); }
.performance-periods a.active {
    border-color: #afc0fa;
    background: #e9efff;
    color: #1e48cd;
    box-shadow: inset 0 0 0 1px rgba(36, 87, 245, .04);
}
.performance-periods a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.performance-quality-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex: none;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-soft);
    font-size: 9.5px;
    font-weight: 750;
}
.performance-quality-badge > span { width: 7px; height: 7px; border-radius: 50%; background: var(--pos); box-shadow: 0 0 0 3px var(--pos-soft); }
.performance-quality-warn .performance-quality-badge > span { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.performance-quality-danger .performance-quality-badge > span { background: var(--neg); box-shadow: 0 0 0 3px var(--neg-soft); }
.performance-hero-grid { display: grid; grid-template-columns: minmax(290px, .82fr) minmax(420px, 1.18fr); }
.performance-return-hero {
    min-height: 236px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding: 27px 29px;
    background-color: var(--dark);
    background-image:
        linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px),
        radial-gradient(420px 220px at 10% 0%, rgba(36,87,245,.25), transparent 68%);
    background-size: 24px 24px, 24px 24px, auto;
    color: #edf5f2;
}
.performance-label { color: #93a6a1; font-family: var(--mono); font-size: 9px; font-weight: 600; letter-spacing: .065em; text-transform: uppercase; }
.performance-return-value { margin: 10px 0 1px; color: #edf5f2; font-family: var(--mono); font-size: clamp(42px, 4.5vw, 66px); font-weight: 700; line-height: .98; letter-spacing: -0.065em; }
.performance-return-value.pos { color: #58dda8; }
.performance-return-value.neg { color: #ff7d84; }
.performance-return-value.performance-return-money { font-size: clamp(38px, 4.1vw, 60px); letter-spacing: -0.06em; }
.performance-return-subtitle { display: flex; flex-wrap: wrap; align-items: baseline; gap: 5px 8px; margin-top: 11px; color: #bdcbc7; font-size: 13.5px; font-weight: 650; }
.performance-return-subtitle strong { color: #edf5f2; font-family: var(--mono); font-size: 18px; font-variant-numeric: tabular-nums; letter-spacing: -.025em; }
.performance-return-subtitle.pos strong { color: #82e6bc; }
.performance-return-subtitle.neg strong { color: #ff9ba1; }
.performance-return-subtitle i { color: #91a6a0; font-size: 12.5px; font-style: normal; font-weight: 500; }
.performance-rupee-result { margin-top: 10px; font-size: 14px; font-weight: 750; }
.performance-return-hero .performance-rupee-result.pos { color: #9be9c8; }
.performance-return-hero .performance-rupee-result.neg { color: #ffabb0; }
.performance-return-hero p { max-width: 460px; margin: 18px 0 0; color: #9fb0ac; font-size: 10.5px; line-height: 1.55; }
.performance-return-hero p strong { color: #dbe7e3; }
.performance-equation { display: grid; align-content: center; padding: 20px 26px; background: #fbfcfb; }
.performance-equation > div { display: flex; align-items: center; justify-content: space-between; gap: 20px; min-height: 38px; border-bottom: 1px solid var(--border); }
.performance-equation span { color: var(--text-soft); font-size: 10.5px; }
.performance-equation strong { font-family: var(--mono); font-size: 12px; }
.performance-equation-total { min-height: 50px !important; margin-top: 4px; border-bottom: 0 !important; border-top: 1px solid var(--text); }
.performance-equation-total span { color: var(--text) !important; font-weight: 750; }
.performance-equation-total strong { font-size: 18px; }
.performance-equation-period > div { min-height: 49px; }
.performance-equation-period .performance-equation-total { min-height: 59px !important; }
.capital-usage { padding: 18px 25px 17px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.capital-usage-context { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; margin-bottom: 13px; }
.capital-usage-context strong { color: var(--text-soft); font-size: 10.5px; }
.capital-usage-context span { color: var(--muted); font-family: var(--mono); font-size: 8.5px; text-align: right; }
.capital-usage-head { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 12px; }
.capital-usage-head div { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.capital-usage-head span { color: var(--muted); font-family: var(--mono); font-size: 8.5px; letter-spacing: .045em; text-transform: uppercase; }
.capital-usage-head strong { font-size: 13px; }
.capital-usage-track { height: 8px; overflow: hidden; border-radius: 999px; background: #e1e6e4; }
.capital-usage-track > span { display: block; width: var(--capital-used); height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent), #3b71ff); }
.capital-usage-caption { display: flex; justify-content: space-between; gap: 15px; margin-top: 7px; color: var(--muted); font-size: 8.5px; }
.performance-facts { display: grid; grid-template-columns: repeat(3, 1fr); }
.performance-facts > div { min-height: 84px; display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 15px 20px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.performance-facts > div:nth-child(3n) { border-right: 0; }
.performance-facts span { color: var(--muted); font-family: var(--mono); font-size: 8.5px; letter-spacing: .045em; text-transform: uppercase; }
.performance-facts strong { font-size: 15px; }
.performance-facts small { color: var(--muted); font-size: 9px; }
.performance-reconcile { display: flex; align-items: flex-start; gap: 12px; margin: 18px 20px 0; padding: 13px 14px; border: 1px solid; border-radius: 11px; }
.performance-reconcile-ok { border-color: #bee7d7; background: var(--pos-soft); }
.performance-reconcile-warn { border-color: #f0d59f; background: var(--warn-soft); }
.performance-period-note { border-color: #c5d2ff; background: var(--accent-soft); }
.performance-period-note .performance-reconcile-icon { color: var(--accent); }
.performance-reconcile-icon { width: 27px; height: 27px; flex: none; display: grid; place-items: center; border-radius: 8px; background: rgba(255,255,255,.72); color: var(--pos); font-family: var(--mono); font-size: 11px; font-weight: 750; }
.performance-reconcile-warn .performance-reconcile-icon { color: var(--warn); }
.performance-reconcile > div:last-child { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.performance-reconcile strong { font-size: 11.5px; }
.performance-reconcile span { color: var(--text-soft); font-family: var(--mono); font-size: 9px; }
.performance-reconcile p { margin: 2px 0 0; color: var(--muted); font-size: 9.5px; line-height: 1.45; }
.performance-method { margin: 12px 20px 18px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.performance-method > summary { padding: 11px 13px; color: var(--text-soft); cursor: pointer; font-size: 10px; font-weight: 750; }
.performance-method > div { padding: 0 13px 12px; }
.performance-method p { margin: 7px 0 0; color: var(--muted); font-size: 9.5px; line-height: 1.55; }
.performance-method a { color: var(--accent); font-weight: 700; }
.performance-data-note { margin: -6px 20px 17px; color: var(--muted); font-size: 9.5px; }

/* Compact operations inbox: secondary exceptions live here instead of
   competing with authorization and engine readiness on the dashboard. */
.notification-center { position: relative; }
.notification-center > summary { list-style: none; }
.notification-center > summary::-webkit-details-marker { display: none; }
.notification-trigger {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 11px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text-soft);
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(13, 23, 24, 0.04);
    font-size: 11.5px;
    font-weight: 700;
    transition: border-color .14s, box-shadow .14s, background .14s;
}
.notification-trigger:hover { border-color: #acb8b5; box-shadow: 0 7px 18px rgba(13, 23, 24, 0.08); }
.notification-trigger svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.notification-center.has-notifications .notification-trigger { color: var(--text); }
.notification-count {
    min-width: 19px;
    height: 19px;
    display: inline-grid;
    place-items: center;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--neg);
    color: #fff;
    font-family: var(--mono);
    font-size: 9px;
    line-height: 1;
}
.notification-popover {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 500;
    width: min(480px, calc(100vw - 36px));
    max-height: min(660px, calc(100vh - 128px));
    overflow: hidden;
    border: 1px solid rgba(16, 32, 31, 0.15);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: 0 28px 80px rgba(13, 23, 24, 0.22);
    transform-origin: top right;
    animation: notification-in .18s cubic-bezier(.2, .75, .2, 1);
}
@keyframes notification-in { from { opacity: 0; transform: translateY(-5px) scale(.985); } to { opacity: 1; transform: none; } }
.notification-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 17px 18px 14px;
    border-bottom: 1px solid var(--border);
    background: #fbfcfb;
}
.notification-head > div { display: flex; flex-direction: column; gap: 3px; }
.notification-head strong { font-size: 16px; font-weight: 750; letter-spacing: -0.025em; }
.notification-head-actions { align-items: flex-end; }
.notification-head-actions > span { color: var(--muted); font-family: var(--mono); font-size: 9.5px; }
.notification-read-form { margin: 0; flex: none; }
.notification-mark-all,
.notification-read-toggle {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--accent);
    cursor: pointer;
    font: 700 9.5px/1.2 var(--font);
    padding: 2px 0;
}
.notification-mark-all:hover,
.notification-read-toggle:hover { color: #173fc9; text-decoration: underline; text-underline-offset: 3px; }
.notification-list { max-height: min(590px, calc(100vh - 198px)); overflow-y: auto; overscroll-behavior: contain; }
.notification-group { margin: 0; padding: 15px 17px; border-bottom: 1px solid var(--border); background: var(--surface); }
.notification-group:last-child { border-bottom: 0; }
.notification-group-head { display: flex; align-items: flex-start; gap: 11px; }
.notification-group-head > div { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 3px; }
.notification-group-head .notification-read-form { margin-left: auto; padding-left: 8px; }
.notification-group-head strong { color: var(--text); font-size: 12.5px; font-weight: 750; }
.notification-group-head span:not(.notification-status-icon) { color: var(--muted); font-size: 10.5px; line-height: 1.45; }
.notification-status-icon {
    width: 27px;
    height: 27px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--surface-3);
    color: var(--muted);
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
}
.notification-critical .notification-status-icon { background: var(--neg-soft); color: var(--neg); }
.notification-warning .notification-status-icon { background: var(--warn-soft); color: var(--warn); }
.notification-info .notification-status-icon { background: var(--accent-soft); color: var(--accent); }
.notification-group.is-read { background: #f8faf9; }
.notification-group.is-read .notification-status-icon { background: #e8edeb; color: #76817e; }
.notification-group.is-read .notification-group-head > div,
.notification-group.is-read .notification-detail,
.notification-group.is-read .notification-rows,
.notification-group.is-read .notification-actions { opacity: .68; }
.notification-detail { margin: 9px 0 0 38px; color: var(--text-soft); font-size: 10.5px; line-height: 1.5; }
.notification-rows { margin: 11px 0 0 38px; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.notification-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 10px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.notification-row:last-child { border-bottom: 0; }
.notification-row > div { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.notification-row strong { font-family: var(--mono); font-size: 10.5px; }
.notification-row span {
    display: -webkit-box;
    overflow: hidden;
    color: var(--muted);
    font-size: 9.5px;
    line-height: 1.4;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}
.notification-row form,
.notification-actions form { margin: 0; flex: none; }
.notification-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin: 11px 0 0 38px; }
.notification-actions .btn { min-height: 29px; flex: 0 0 auto; }
.notification-amount { margin-right: auto; color: var(--muted); font-size: 10px; }
.notification-amount strong { display: block; color: var(--text); font-size: 13px; }
.notification-empty { min-height: 190px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; padding: 28px; text-align: center; }
.notification-empty-mark { width: 38px; height: 38px; display: grid; place-items: center; margin-bottom: 4px; border-radius: 12px; background: var(--pos-soft); color: var(--pos); font-size: 18px; }
.notification-empty strong { font-size: 14px; }
.notification-empty > span:last-child { color: var(--muted); font-size: 11px; }
.notification-empty-compact { min-height: 132px; padding-bottom: 19px; }
.notification-empty-compact .notification-empty-mark { width: 32px; height: 32px; border-radius: 10px; font-size: 15px; }
.notification-history { border-top: 1px solid var(--border); background: #f5f7f6; }
.notification-history > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 11px 17px;
    color: var(--text-soft);
    cursor: pointer;
    font-size: 10.5px;
    font-weight: 700;
    list-style: none;
}
.notification-history > summary::-webkit-details-marker { display: none; }
.notification-history > summary::after { content: "+"; margin-left: auto; color: var(--muted); font-family: var(--mono); font-size: 14px; }
.notification-history[open] > summary::after { content: "\2212"; }
.notification-history-count {
    min-width: 18px;
    height: 18px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: #e1e6e4;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 9px;
}
.notification-history-list { border-top: 1px solid var(--border); }

.watchlist,
.analysis-table-accordion,
.shortlist-table-accordion,
.holdings-list,
.trades,
.resume-table,
.explain-table { border-color: rgba(16, 32, 31, 0.13); box-shadow: none; }
.watchlist-head,
.analysis-table-head,
.shortlist-table-head,
.trades thead th,
.resume-table thead th,
.explain-table thead th { background: #f0f3f2; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.055em; }

.login-page {
    background-color: #e9edeb;
    background-image:
        linear-gradient(rgba(13, 23, 24, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(13, 23, 24, 0.035) 1px, transparent 1px);
    background-size: 30px 30px;
}
.login-shell { border-color: rgba(13, 23, 24, 0.13); box-shadow: 0 30px 80px rgba(13, 23, 24, 0.18); }
.login-panel { padding: 50px 46px; }
.login-panel .brand-mark { background: var(--dark); border-radius: 11px; box-shadow: none; }
.login-aside { background: var(--dark); }
.login-aside::before {
    background-image:
        radial-gradient(520px 360px at 100% 0%, rgba(36, 87, 245, 0.42), transparent 65%),
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
    background-size: auto, 30px 30px, 30px 30px;
    opacity: 1;
}
.eyebrow { color: #8fb3ff; font-family: var(--mono); }
.login-points span::before { background: #56d9a1; box-shadow: 0 0 0 4px rgba(86, 217, 161, 0.1); }

@media (max-width: 1180px) {
    .dashboard-finance-grid { grid-template-columns: 1fr; }
    .dashboard-finance-grid > section { grid-column: 1; }
    .performance-hero-grid { grid-template-columns: minmax(270px, .72fr) minmax(390px, 1.28fr); }
}

@media (max-width: 960px) {
    .sidebar { width: 278px; }
    .topbar { min-height: 86px; padding: 14px 18px; }
    .app-content { padding: 22px 18px 88px; }
    .bottom-nav { border-top-color: rgba(16, 32, 31, 0.12); box-shadow: 0 -8px 24px rgba(13, 23, 24, 0.06); }
}

@media (max-width: 720px) {
    body.app { background-image: none; }
    .topbar { min-height: 82px; flex-wrap: wrap; align-items: flex-start; }
    .topbar-actions:empty { display: none; }
    .topbar-actions:not(:empty) { position: absolute; top: 14px; right: 16px; width: auto; }
    .topbar-title { padding-right: 43px; }
    .notification-label { display: none; }
    .notification-trigger { width: 38px; height: 38px; min-height: 38px; justify-content: center; padding: 0; }
    .notification-count { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; border: 2px solid #f7f9f8; }
    .notification-popover {
        position: fixed;
        top: 78px;
        left: 10px;
        right: 10px;
        width: auto;
        max-height: calc(100vh - 164px);
        border-radius: 15px;
    }
    .notification-list { max-height: calc(100vh - 231px); }
    .notification-row { align-items: flex-start; }
    .notification-detail,
    .notification-rows,
    .notification-actions { margin-left: 0; }
    .performance-ledger { margin-bottom: 14px; border-radius: 15px; }
    .performance-ledger-head { flex-direction: column; gap: 12px; padding: 18px 18px 15px; }
    .performance-ledger-head h2 { font-size: 19px; }
    .performance-quality-badge { padding: 6px 9px; }
    .performance-periods { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; overflow: visible; padding: 9px 14px; }
    .performance-periods a { width: 100%; min-height: 32px; padding: 6px 7px; }
    .performance-hero-grid { grid-template-columns: 1fr; }
    .performance-return-hero { min-height: 245px; padding: 26px 20px; }
    .performance-return-value { font-size: 52px; }
    .performance-return-value.performance-return-money { font-size: clamp(38px, 11vw, 50px); }
    .performance-return-subtitle strong { font-size: 17px; }
    .performance-equation { padding: 16px 19px; }
    .performance-equation > div { min-height: 41px; gap: 12px; }
    .performance-equation span { font-size: 9.5px; }
    .performance-equation strong { font-size: 10.5px; }
    .performance-equation-total strong { font-size: 16px; }
    .capital-usage { padding: 17px 18px 15px; }
    .capital-usage-context { align-items: flex-start; flex-direction: column; gap: 3px; }
    .capital-usage-context span { text-align: left; }
    .capital-usage-head { grid-template-columns: 1fr 1fr; gap: 12px 18px; }
    .capital-usage-head > div:first-child { grid-column: 1 / -1; }
    .capital-usage-caption { font-size: 8px; }
    .performance-facts { grid-template-columns: 1fr 1fr; }
    .performance-facts > div { min-height: 78px; padding: 13px 15px; }
    .performance-facts > div:nth-child(3n) { border-right: 1px solid var(--border); }
    .performance-facts > div:nth-child(2n) { border-right: 0; }
    .performance-reconcile { margin: 14px 14px 0; padding: 12px; }
    .performance-reconcile span { line-height: 1.45; }
    .performance-method { margin: 10px 14px 15px; }
    .performance-data-note { margin: -4px 15px 15px; }
    .page-eyebrow { font-size: 8.5px; }
    .topbar-title h1 { font-size: 19px; }
    .topbar .subtitle { margin-top: 6px; }
    .app-content { padding-top: 18px; }
    .engine-banner { min-height: 0; padding: 13px 14px; }
    .engine-banner svg { width: 32px; height: 32px; }
    .dashboard-alert-stack { padding: 0 14px 2px; }
    .queue-heading { align-items: flex-start; padding: 14px 0 12px; }
    .queue-heading > span { display: none; }
    .dashboard-alert-stack > .engine-banner { padding: 14px 0; }
    .failed-list { grid-template-columns: 1fr; }
    .dashboard-finance-grid { gap: 12px; margin-bottom: 14px; }
    .dashboard-finance-grid > section { padding: 21px 18px 19px; }
    .portfolio-summary-head strong { font-size: 27px; }
    .portfolio-metrics { grid-template-columns: 1fr 1fr; }
    .portfolio-metrics > div,
    .performance-summary .portfolio-metrics > div { border-right: 1px solid var(--border); border-top: 1px solid var(--border); padding: 12px 9px 8px; }
    .portfolio-metrics > div:nth-child(odd),
    .performance-summary .portfolio-metrics > div:nth-child(odd) { padding-left: 0; }
    .portfolio-metrics > div:nth-child(even),
    .performance-summary .portfolio-metrics > div:nth-child(even) { border-right: 0; }
    .performance-summary .portfolio-metrics { grid-template-columns: 1fr 1fr; }
    .performance-summary .portfolio-metrics > div:nth-child(3n) { border-right: 1px solid var(--border); }
    .performance-summary .portfolio-metrics > div:nth-child(even) { border-right: 0; }
    .portfolio-metrics strong { font-size: 14px; }
    .panel-hint { display: none; }
    .analysis-form { grid-template-columns: 1fr 1fr; }
    .analysis-form .sym-field { grid-column: 1 / -1; }
    .analysis-lookback-field { grid-column: auto; }
    .analysis-timeout-field { grid-column: 1 / -1; flex-wrap: wrap; }
    .analysis-submit { grid-column: 1 / -1; }
    .bottom-nav { background: rgba(251, 252, 251, 0.95); }
    .bn-item.active { color: var(--accent); background: var(--accent-soft); }
}

/* ============================================================
   READABILITY SCALE
   Operational dashboards are read repeatedly and often at a glance. Keep dense
   metadata compact, but never make it depend on sub-11px type to fit.
   ============================================================ */
:root {
    --type-caption: 12px;
    --type-label: 12.5px;
    --type-supporting: 13px;
    --type-body: 15px;
}

body { font-size: var(--type-body); }
.muted { font-size: 13.5px; }
small { font-size: var(--type-caption); }
.brand-text strong { font-size: 15px; }
.brand-caption { font-size: 12px; }
.sidebar-label { font-size: 12px; }
.nav-item { font-size: 13.5px; }
.sidebar-caption { font-size: 13px; }
.page-eyebrow,
.section-kicker { font-size: 12px; }
h2 { font-size: 12.5px; }
.subtitle,
.hud-stat,
.hud-meta { font-size: 12px; }
.badge,
.tag,
.topbar .badge.live { font-size: 12px; }
.btn { font-size: 13px; }
.btn-small { font-size: 12px; }
input[type="text"], input[type="password"], input[type="number"], input[type="search"], select, textarea { font-size: 14px; }
.flash { font-size: 13px; }

.engine-banner .eb-main span { font-size: 13px; line-height: 1.5; }
.queue-heading > span { font-size: 12.5px; }
.failed-row .fr-sym { font-size: 12px; }
.failed-row .fr-reason { font-size: 12.5px; }
.portfolio-summary-head .muted,
.portfolio-metrics span,
.metrics span,
.choice-metrics span,
.quick-takeaways span,
.intraday-grid span,
.cost-strip span { font-size: 12px; }
.portfolio-summary-head strong .muted { font-size: 12px; }
.portfolio-note { font-size: 12.5px; }
.panel-hint { font-size: 12px; }
.sub-title { font-size: 13.5px; }
.live-health-head .muted,
.live-health-item span,
.live-health-copy .muted,
.callback-box .muted { font-size: 12px; }

.watchlist-head,
.analysis-table-head,
.shortlist-table-head,
.trades thead th,
.resume-table thead th,
.explain-table thead th,
.suggestion-table thead th { font-size: 12px; }
.trades td,
.resume-table td,
.explain-table td,
.suggestion-table td { font-size: 13px; }
.sym-hint,
.sym-opt span,
.rerun-stock-form span,
.best-stock-subtitle,
.selected-settings-note span { font-size: 12.5px; }
.sym-chip .sym-chip-ex,
.sym-opt .sym-opt-ex { font-size: 10.5px; }
.analysis-form label { font-size: 13px; }
.hold-group { font-size: 12px; }
.hr-meta,
.hr-l3 .muted { font-size: 12px; }
.sheet-act,
.sheet-actions .btn { font-size: 12px; }
.sheet .metrics span { font-size: 12px; }
.bn-item { font-size: 12px; }

/* Period switching stays on the current page; these states make the small
   network transition visible without blanking or moving the ledger. */
.performance-ledger { position: relative; transition: opacity .16s ease; }
.performance-ledger.performance-card-switching { opacity: .66; pointer-events: none; }
.performance-ledger.performance-card-switching::after {
    content: "";
    position: absolute;
    z-index: 5;
    top: 0;
    left: -34%;
    width: 34%;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    animation: performance-loading .72s linear infinite;
}
.performance-ledger.performance-card-entering .performance-hero-grid,
.performance-ledger.performance-card-entering .capital-usage,
.performance-ledger.performance-card-entering .performance-facts { animation: performance-content-in .22s ease both; }
@keyframes performance-loading { to { left: 100%; } }
@keyframes performance-content-in { from { opacity: .55; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.performance-ledger-head p { font-size: 13px; line-height: 1.55; }
.performance-quality-badge { font-size: 12px; }
.performance-periods a { min-height: 36px; font-size: 12px; }
.performance-label { font-size: 12px; }
.performance-return-hero p { font-size: 13px; line-height: 1.65; }
.performance-equation span { font-size: 13px; }
.performance-equation strong { font-size: 13.5px; }
.performance-equation-total strong { font-size: 20px; }
.capital-usage-context strong { font-size: 13px; }
.capital-usage-context span { font-size: 12px; }
.capital-usage-head span { font-size: 12px; }
.capital-usage-head strong { font-size: 14px; }
.capital-usage-caption { font-size: 12px; }
.performance-facts span { font-size: 12px; }
.performance-facts strong { font-size: 16px; }
.performance-facts small { font-size: 12px; }
.performance-reconcile strong { font-size: 13.5px; }
.performance-reconcile span { font-size: 12px; line-height: 1.55; }
.performance-reconcile p { font-size: 12.5px; line-height: 1.55; }
.performance-method > summary { font-size: 12.5px; }
.performance-method p { font-size: 12.5px; line-height: 1.65; }
.performance-data-note { font-size: 12px; }

.notification-trigger { font-size: 13px; }
.notification-count { font-size: 10.5px; }
.notification-head-actions > span { font-size: 12px; }
.notification-mark-all,
.notification-read-toggle { font-size: 12px; }
.notification-group-head strong { font-size: 14px; }
.notification-group-head span:not(.notification-status-icon) { font-size: 12.5px; }
.notification-status-icon { font-size: 12px; }
.notification-detail { font-size: 12.5px; }
.notification-row strong { font-size: 12.5px; }
.notification-row span { font-size: 12px; }
.notification-amount { font-size: 12px; }
.notification-empty > span:last-child,
.notification-history > summary { font-size: 12.5px; }

@media (max-width: 720px) {
    body { font-size: 15px; }
    .page-eyebrow { font-size: 12px; }
    .topbar-title h1 { font-size: 21px; }
    .performance-ledger-head h2 { font-size: 21px; }
    .performance-periods a { min-height: 38px; font-size: 12px; }
    .performance-return-hero { min-height: 260px; }
    .performance-equation span { font-size: 12.5px; }
    .performance-equation strong { font-size: 13px; }
    .performance-equation-total strong { font-size: 18px; }
    .capital-usage-caption { font-size: 12px; }
    .performance-facts > div { min-height: 88px; }
    .performance-reconcile { gap: 10px; }
    .performance-reconcile span { font-size: 12px; }
    .bn-item { font-size: 12px; }
}

/* Live execution ledger: a compact money-first treatment. The summary is one
   continuous instrument panel, not a wall of dashboard cards. */
.log-money-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 2px 0 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: linear-gradient(180deg, var(--surface), var(--surface-2));
}
.log-money-strip > div {
    min-width: 0;
    padding: 14px 16px 13px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.log-money-strip > div:last-child { border-right: 0; }
.log-money-strip span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .035em;
    text-transform: uppercase;
}
.log-money-strip strong {
    color: var(--text);
    font-family: var(--mono);
    font-size: 18px;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.025em;
}
.log-money-strip small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.log-money-strip .pos { color: var(--pos); }
.log-money-strip .neg { color: var(--neg); }
.log-summary-result { box-shadow: inset 0 3px 0 color-mix(in srgb, var(--accent) 72%, transparent); }
.log-money-note {
    margin: 10px 2px 14px;
    color: var(--muted);
    font-size: 12.5px;
    line-height: 1.5;
}
.log-ledger-warning {
    margin: -2px 0 14px;
    padding: 9px 12px;
    border: 1px solid #efd5ad;
    border-radius: var(--radius-xs);
    background: var(--warn-soft);
    color: #7a4708;
    font-size: 12.5px;
}
.log-table-wrap { border: 1px solid var(--border); background: var(--surface); }
.log-table-wrap .trades { min-width: 980px; border: 0; }
.log-table-wrap .trades td { vertical-align: middle; }
.trades td[data-label="Symbol"] { color: var(--text); font-weight: 750; letter-spacing: -.01em; }
.trades td[data-label="Side"] strong {
    display: inline-flex;
    min-width: 47px;
    justify-content: center;
    border-radius: var(--radius-pill);
    padding: 3px 8px;
    font-size: 11px;
    letter-spacing: .045em;
}
.trades tr.side-buy td[data-label="Side"] strong { background: var(--pos-soft); color: var(--pos); }
.trades tr.side-sell td[data-label="Side"] strong { background: var(--neg-soft); color: var(--neg); }
.log-order-cell,
.log-money-cell,
.log-result-cell { font-family: var(--sans) !important; }
.log-order-cell,
.log-money-cell,
.log-result-cell { white-space: nowrap; }
.log-order-cell strong,
.log-money-cell > strong,
.log-result-cell > strong {
    display: block;
    color: var(--text);
    font-family: var(--mono);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
.log-order-cell small,
.log-money-cell small,
.log-result-cell small,
.log-result-cell > span:last-child {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 11.5px;
    line-height: 1.3;
}
.log-result-cell > strong.pos,
.log-result-cell > small.pos { color: var(--pos); }
.log-result-cell > strong.neg,
.log-result-cell > small.neg { color: var(--neg); }
.log-money-flow { display: flex; align-items: center; gap: 7px; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.log-money-flow span { color: var(--muted); }
.log-money-flow b { color: var(--muted-2); font-weight: 500; }
.log-money-flow strong { color: var(--text); font-size: 13px; }
.log-pending { color: var(--muted); font-size: 12.5px; font-weight: 650; }

@media (max-width: 720px) {
    .log-filter { gap: 9px; }
    .log-filter label { flex-basis: 100%; max-width: none; }
    .log-money-strip { grid-template-columns: 1fr 1fr; }
    .log-money-strip > div { padding: 12px; border-bottom: 1px solid var(--border); }
    .log-money-strip > div:nth-child(2) { border-right: 0; }
    .log-money-strip > div:nth-child(3),
    .log-money-strip > div:nth-child(4) { border-bottom: 0; }
    .log-money-strip strong { font-size: 16px; }
    .log-money-strip span,
    .log-money-strip small { font-size: 11.5px; }
    .log-money-note { font-size: 12px; }
    .log-table-wrap { border: 0; overflow: visible; background: transparent; }
    .log-table-wrap .trades { min-width: 0; }
    .trades tr {
        grid-template-columns: auto minmax(0, 1fr) auto;
        grid-template-areas:
            "sym sym time"
            "side order result"
            "money money result"
            "reason reason reason";
        gap: 6px 10px;
        padding: 12px 13px;
    }
    .trades td[data-label="Side"] { grid-area: side; align-self: center; }
    .trades td[data-label="Order"] { grid-area: order; align-self: center; }
    .trades td[data-label="Money flow"] { grid-area: money; padding-top: 3px; }
    .trades td[data-label="Net result"] { grid-area: result; justify-self: end; align-self: center; text-align: right; }
    .trades td[data-label="Reason"] { grid-area: reason; border-top: 1px dashed var(--border); padding-top: 7px; margin-top: 2px; }
    .log-money-flow { gap: 5px; }
    .log-order-cell strong,
    .log-money-cell > strong,
    .log-result-cell > strong,
    .log-money-flow strong { font-size: 12.5px; }
    .log-result-cell > span:last-child { font-size: 10.5px; }
}

/* Wide desktop readability. At normal 100% browser zoom this approximates the
   comfortable density users were otherwise creating with 125% zoom, while the
   existing tablet and phone layouts retain their purpose-built scale. */
@media (min-width: 1200px) {
    :root {
        --type-caption: 14px;
        --type-label: 14.5px;
        --type-supporting: 15.5px;
        --type-body: 17px;
    }
    body { font-size: var(--type-body); }
    .sidebar { --sidebar-w: 292px; width: var(--sidebar-w); padding: 23px 18px; gap: 25px; }
    .sidebar-brand { min-height: 56px; }
    .sidebar-brand .brand-mark { width: 44px; height: 44px; font-size: 16px; }
    .brand-text strong { font-size: 17px; }
    .brand-caption { font-size: 13.5px; }
    .sidebar .badge.live { padding: 4px 8px; font-size: 11.5px; }
    .sidebar-label { font-size: 13.5px; }
    .nav-item { min-height: 46px; padding: 11px 13px; font-size: 16px; }
    .nav-item svg { width: 19px; height: 19px; }
    .sidebar-caption { font-size: 15px; }
    .sidebar-foot .btn,
    .sidebar-foot .user-pill { min-height: 44px; font-size: 15px; }

    .topbar { min-height: 112px; padding: 20px 40px 18px; }
    .page-eyebrow,
    .section-kicker { font-size: 13.5px; }
    .topbar-title h1 { font-size: 29px; }
    .subtitle,
    .hud-stat,
    .hud-meta,
    .badge,
    .tag,
    .topbar .badge.live { font-size: 14px; }
    .subtitle,
    .hud-stat,
    .hud-meta,
    .badge,
    .tag { font-size: 14px; }
    .hud-stat,
    .topbar .badge.live { min-height: 31px; padding: 4px 11px; }

    .app-content { max-width: 1620px; padding: 40px 42px 116px; }
    .app-content > section { padding: 30px 32px; margin: 22px 0; }
    .section-head { gap: 17px; margin-bottom: 24px; }
    h2 { font-size: 14.5px; }
    h3 { font-size: 20px; }
    .muted { font-size: 15.5px; }
    small { font-size: 14px; }

    label { gap: 8px; font-size: 15px; }
    input[type="text"],
    input[type="password"],
    input[type="number"],
    input[type="search"],
    select,
    textarea { min-height: 46px; padding: 11px 14px; font-size: 17px; }
    .btn { min-height: 44px; padding: 10px 17px; font-size: 15.5px; }
    .btn-small { min-height: 38px; font-size: 14px; }
    .flash { font-size: 15px; }

    .portfolio-summary-head .muted,
    .portfolio-metrics span,
    .metrics span,
    .choice-metrics span,
    .quick-takeaways span,
    .intraday-grid span,
    .cost-strip span,
    .performance-label,
    .capital-usage-head span,
    .performance-facts span { font-size: 14px; }
    .portfolio-note,
    .panel-hint,
    .performance-ledger-head p,
    .performance-return-hero p,
    .performance-reconcile p,
    .performance-method p { font-size: 15px; }
    .panel-title { font-size: 18px; }
    .sub-title { font-size: 16px; }
    .performance-periods a { min-height: 42px; font-size: 14px; }
    .performance-equation span,
    .performance-equation strong,
    .capital-usage-context strong,
    .capital-usage-context span,
    .capital-usage-caption,
    .performance-facts small,
    .performance-reconcile span,
    .performance-method > summary { font-size: 14.5px; }
    .performance-facts strong { font-size: 19px; }

    .watchlist-head,
    .analysis-table-head,
    .shortlist-table-head,
    .trades thead th,
    .resume-table thead th,
    .explain-table thead th,
    .suggestion-table thead th { font-size: 14px; }
    .trades td,
    .resume-table td,
    .explain-table td,
    .suggestion-table td { font-size: 15px; }
    .notification-trigger,
    .notification-mark-all,
    .notification-read-toggle,
    .notification-detail,
    .notification-row strong,
    .notification-row span { font-size: 14.5px; }

    .manual-order-form input[type="number"],
    .manual-order-form select,
    .manual-order-form .symbol-picker-single,
    .manual-order-submit { height: 52px; min-height: 52px; }
    .manual-order-form .symbol-picker-single .sym-search { height: 50px; font-size: 17px; }
    .manual-order-form .mt-price { font-size: 15px; }
}

@media (min-width: 721px) and (max-width: 1199px) {
    .kite-order.manual-order-form { grid-template-columns: minmax(260px, 1.5fr) minmax(110px, .55fr) minmax(140px, .7fr); }
    .manual-order-submit { grid-column: 1 / -1; width: auto; min-width: 180px; justify-self: start; }
}

@media (max-width: 720px) {
    .kite-order.manual-order-form { grid-template-columns: 1fr; gap: 13px; }
    .manual-order-submit { grid-column: 1; width: 100%; }
    .manual-order-form .mt-price { grid-column: 1; margin-top: -4px; }
}
