:root {
  --bg: #f3f5f8;
  --ink: #152033;
  --muted: #5b6b7c;
  --paper: #ffffff;
  --line: #e4e9ef;
  --line-strong: #d5dde7;
  --accent: #1f5eff;
  --accent-soft: #e8efff;
  --core: #1d4ed8;
  --sat: #0f766e;
  --loss: #c62828;
  --gain: #0f7a4c;
  --rail: #fbfcfe;
  --rail-ink: #3a4a5c;
  --head: #f7f9fc;
  --head-ink: #3d4f63;
  --shadow: 0 1px 2px rgba(21, 32, 51, 0.04), 0 8px 24px rgba(21, 32, 51, 0.06);
  --radius: 12px;
  --radius-sm: 8px;
  --ease: 160ms ease;
  --font: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", monospace;
  font-family: var(--font);
  font-feature-settings: "ss01" 1, "tnum" 1;
}

:root[data-theme="dark"] {
  --bg: #0b1220;
  --ink: #e8eef7;
  --muted: #93a4b8;
  --paper: #121a2a;
  --line: #243247;
  --line-strong: #31445d;
  --accent: #6b9bff;
  --accent-soft: #1a2b4d;
  --core: #6b9bff;
  --sat: #2dd4bf;
  --loss: #f07178;
  --gain: #3dd68c;
  --rail: #0a101c;
  --rail-ink: #c5d0de;
  --head: #152033;
  --head-ink: #b7c5d6;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 12px 28px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }
html, body {
  margin: 0; background: var(--bg); color: var(--ink); min-height: 100%;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
body {
  background-image:
    radial-gradient(1200px 500px at 12% -10%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 60%),
    radial-gradient(900px 420px at 100% 0%, color-mix(in srgb, var(--sat) 6%, transparent), transparent 55%);
  background-attachment: fixed;
}
.hidden { display: none !important; }
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.rail {
  background: color-mix(in srgb, var(--rail) 92%, transparent);
  backdrop-filter: blur(10px);
  color: var(--rail-ink);
  padding: 1.1rem 0.85rem 1rem;
  display: flex; flex-direction: column; gap: 1rem;
  border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh; overflow: auto;
}
.brand { display: flex; gap: 0.7rem; align-items: center; padding: 0.2rem 0.4rem 0.55rem; }
.brand-mark {
  width: 2.2rem; height: 2.2rem; border-radius: 11px;
  background: linear-gradient(145deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #0b3db8));
  color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 0.76rem; letter-spacing: 0.03em;
  box-shadow: 0 6px 14px color-mix(in srgb, var(--accent) 28%, transparent);
}
.mark { font-size: 1rem; margin: 0; font-weight: 700; letter-spacing: -0.03em; color: var(--ink); }
.mark-sub { margin: 0.08rem 0 0; color: var(--muted); font-size: 0.72rem; letter-spacing: 0.01em; }
.rail-section {
  margin: 0.35rem 0.55rem 0.2rem; font-size: 0.66rem; font-weight: 650;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
}
.rail nav { display: flex; flex-direction: column; gap: 0.16rem; }
.nav-link {
  color: var(--rail-ink); text-decoration: none;
  padding: 0.5rem 0.65rem; border-radius: 10px;
  display: flex; align-items: center; gap: 0.55rem; font-size: 0.86rem; font-weight: 500;
  transition: background var(--ease), color var(--ease), transform var(--ease);
}
.nav-link svg { flex: 0 0 auto; opacity: 0.8; }
.nav-link:hover { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.nav-link.active {
  background: var(--accent-soft); color: var(--accent); font-weight: 650;
  box-shadow: inset 3px 0 0 var(--accent);
}
.nav-link.active svg { opacity: 1; }
.nav-link.muted { opacity: 0.45; pointer-events: none; }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 0.4rem; padding-top: 0.5rem; }
.theme-btn {
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--line); padding: 0.45rem 0.7rem; cursor: pointer; border-radius: 10px;
  font-weight: 550; font-size: 0.8rem; transition: border-color var(--ease), background var(--ease);
}
.theme-btn:hover { border-color: var(--line-strong); background: color-mix(in srgb, var(--accent) 5%, var(--paper)); }
.login-shell {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background:
    radial-gradient(ellipse 80% 60% at 10% 0%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 100%, color-mix(in srgb, var(--ink) 6%, transparent), transparent 50%),
    var(--bg);
}
.login-card {
  width: min(26rem, 100%); background: var(--paper); border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px); box-shadow: var(--shadow); padding: 1.5rem 1.4rem 1.55rem;
  display: flex; flex-direction: column; gap: 0.7rem;
}
.signup-card { width: min(32rem, 100%); }
.signup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
@media (max-width: 560px) { .signup-grid { grid-template-columns: 1fr; } }
.login-brand { padding: 0; }
.login-card h1 { font-size: 1.25rem; }
.login-submit { align-self: stretch; text-align: center; padding: 0.55rem 0.8rem; }
.login-card .field input,
.login-card .field select { width: 100%; }
.hint.error { color: var(--loss); }
.hint.ok { color: var(--gain, #1a7f4e); }
.oauth-stack { display: flex; flex-direction: column; gap: 0.45rem; margin-top: 0.35rem; }
.oauth-btn { text-align: center; text-decoration: none; }
.oauth-btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.auth-home {
  min-height: 100vh;
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--accent) 12%, var(--bg)), var(--bg) 45%),
    var(--bg);
}
.auth-home-top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.1rem 1.6rem; border-bottom: 1px solid var(--line);
}
.auth-home-main {
  display: grid; grid-template-columns: 1.2fr 0.9fr; gap: 2rem;
  max-width: 960px; margin: 0 auto; padding: 3rem 1.5rem 4rem; align-items: center;
}
@media (max-width: 800px) { .auth-home-main { grid-template-columns: 1fr; padding-top: 2rem; } }
.auth-hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); line-height: 1.12; letter-spacing: -0.04em; }
.auth-cta-row { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.2rem; }
.auth-panel { width: 100%; }
.admin-form { grid-template-columns: 1fr 1fr; }
.admin-form .check { grid-column: 1 / -1; }
.admin-form-actions {
  grid-column: 1 / -1;
  display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.35rem;
}
.admin-password-box {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem 0.9rem;
  display: flex; flex-direction: column; gap: 0.55rem;
  background: color-mix(in srgb, var(--accent) 4%, var(--paper));
}
.admin-password-box h3 { margin: 0; font-size: 0.9rem; }
main { padding: 1.25rem 1.6rem 2.6rem; min-width: 0; width: 100%; }
.page-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-end; margin-bottom: 0.45rem; }
.analysis-head { flex-direction: column; align-items: stretch; gap: 0.7rem; }
.filter-row { display: flex; flex-direction: row; flex-wrap: wrap; gap: 0.7rem 0.9rem; align-items: flex-end; }
.filter-row .field { min-width: 8rem; }
.journal-toolbar { margin: 0.7rem 0 0.6rem; }
.journal-toolbar .chip { align-self: flex-end; }
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable .sort-ind { color: var(--head-ink); opacity: 0.8; font-size: 0.72em; margin-left: 0.2rem; }
h1, h2, h3 { font-weight: 650; margin: 0; letter-spacing: -0.035em; }
h1 { font-size: 1.45rem; line-height: 1.15; }
h2 { font-size: 1rem; }
.lede { color: var(--muted); margin: 0.35rem 0 0; font-size: 0.86rem; max-width: 54rem; line-height: 1.45; }
.field {
  display: flex; flex-direction: column; gap: 0.22rem;
  font-size: 0.74rem; font-weight: 600;
}
/* Label only — do not put muted color on the whole field (breaks Windows <select> popups). */
.field > span { color: var(--muted); }
button { font: inherit; }
select, input, textarea {
  font-family: var(--font);
  font-size: 0.86rem;
  font-weight: 500;
  background: var(--paper); color: var(--ink); border: 1px solid var(--line);
  padding: 0.42rem 0.55rem; border-radius: var(--radius-sm);
  transition: border-color var(--ease), box-shadow var(--ease);
  /* Keep native dropdown colors in sync with page theme (fixes blank options until hover on Windows). */
  color-scheme: light;
}
:root[data-theme="dark"] select,
:root[data-theme="dark"] input,
:root[data-theme="dark"] textarea {
  color-scheme: dark;
}
select:focus, input:focus, textarea:focus {
  outline: none; border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
textarea { min-height: 4.5rem; width: 100%; }
.banner {
  margin: 0.8rem 0; padding: 0.7rem 0.95rem; background: #fff7ed; color: #9a3412;
  display: flex; justify-content: space-between; gap: 1rem; align-items: center; border-radius: 10px;
  border: 1px solid #fed7aa;
}
:root[data-theme="dark"] .banner { background: #3a2a18; color: #f3eadc; border-color: #5b4330; }
.summary {
  display: grid; grid-template-columns: repeat(4, 1fr) 170px; gap: 0.75rem; margin: 0.9rem 0;
}
.holdings-summary {
  grid-template-columns: repeat(5, minmax(0, 1fr)) 160px;
}
.kpi-sub.muted { color: var(--muted); }
.kpi {
  background: var(--paper); border: 1px solid var(--line);
  padding: 0.8rem 0.9rem; border-radius: var(--radius); box-shadow: var(--shadow);
  transition: transform var(--ease), border-color var(--ease);
}
.kpi:hover { border-color: var(--line-strong); }
.kpi span { display: block; color: var(--muted); font-size: 0.7rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; }
.kpi strong {
  display: block; margin-top: 0.28rem;
  font-size: 1.18rem; font-weight: 700; letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
}
.kpi-break { list-style: none; margin: 0.35rem 0 0; padding: 0; font-size: 0.74rem; color: var(--muted); }
.kpi-break li { display: flex; justify-content: space-between; gap: 0.8rem; margin-top: 0.12rem; }
.kpi-sub { margin: 0.35rem 0 0; font-size: 0.78rem; color: var(--muted); }
.donut-wrap {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.45rem; box-shadow: var(--shadow);
}
.toolbar { display: flex; justify-content: space-between; gap: 0.8rem; flex-wrap: wrap; align-items: center; margin: 0.45rem 0 0.7rem; }
.chips { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.chip, .bulk button, .banner button, .empty button, .drawer-body button, .modal-actions button {
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  padding: 0.36rem 0.72rem; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 0.8rem;
  transition: background var(--ease), border-color var(--ease), color var(--ease), transform var(--ease);
}
.chip:hover, .bulk button:hover, .modal-actions button:hover {
  border-color: var(--line-strong);
  background: color-mix(in srgb, var(--accent) 6%, var(--paper));
}
.chip:active { transform: translateY(1px); }
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip.on:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.logout-chip { margin-left: auto; }
.bulk { display: flex; gap: 0.35rem; align-items: center; font-size: 0.8rem; }
.table-wrap {
  overflow: auto; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  max-height: min(70vh, 56rem);
}
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.8rem; }
th, td { padding: 0.48rem 0.65rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
thead th {
  background: var(--head); color: var(--head-ink); font-weight: 650; font-size: 0.7rem;
  text-transform: uppercase; letter-spacing: 0.045em;
  position: sticky; top: 0; z-index: 2;
  border-bottom: 1px solid var(--line-strong);
  box-shadow: 0 1px 0 var(--line);
}
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 0.78rem; }
tbody tr { cursor: pointer; transition: background var(--ease); }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
tbody tr:last-child td { border-bottom: 0; }
.neg { color: var(--loss); }
.pos { color: var(--gain); }
.class-toggle { display: flex; gap: 0; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.class-toggle button { border: 0; border-radius: 0; padding: 0.15rem 0.4rem; font-size: 0.68rem; background: var(--paper); }
.class-toggle button.on.CORE { background: var(--core); color: #fff; }
.class-toggle button.on.SATELLITE { background: var(--sat); color: #fff; }
.empty {
  padding: 2.2rem 1.4rem; text-align: center; color: var(--muted);
  display: grid; gap: 0.45rem; justify-items: center;
}
.empty-title { margin: 0; color: var(--ink); font-size: 1rem; font-weight: 650; }
.empty-copy { margin: 0; max-width: 28rem; font-size: 0.86rem; line-height: 1.45; }
.drawer {
  position: fixed; top: 0; right: 0; width: min(400px, 100%); height: 100vh; background: var(--paper);
  border-left: 1px solid var(--line); box-shadow: var(--shadow); overflow: auto; z-index: 20; padding: 1rem 1.05rem 2rem;
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; }
.drawer-body h3 { margin: 1rem 0 0.35rem; font-size: 0.92rem; }
.mini { width: 100%; font-size: 0.76rem; }
.evo, .timeline { padding-left: 1.1rem; margin: 0; }
.hint { color: var(--muted); font-size: 0.78rem; margin: 0.35rem 0 0.7rem; line-height: 1.4; }
.journal-wrap { max-height: calc(100vh - 11rem); }
.journal-table { font-size: 0.74rem; }
.journal-table th { position: sticky; top: 0; background: var(--head); z-index: 1; }
.journal-table .stock-row { cursor: pointer; }
.journal-table .stock-row td { background: color-mix(in srgb, var(--accent) 7%, var(--paper)); font-size: 0.82rem; }
.journal-table .tranche-row { cursor: default; }
.modal {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.48); display: grid; place-items: center; z-index: 30;
  backdrop-filter: blur(2px);
}
.modal-card { background: var(--paper); padding: 1.25rem; border-radius: 14px; width: min(480px, 92vw); box-shadow: var(--shadow); border: 1px solid var(--line); }
.modal-card ul { max-height: 240px; overflow: auto; padding-left: 1.1rem; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }
.kpis-8 { grid-template-columns: repeat(4, 1fr); }
.upload-advanced {
  margin: 0.85rem 0 0.5rem; padding: 0.65rem 0.8rem;
  border: 1px dashed var(--line); border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--paper) 70%, transparent);
}
.upload-advanced summary {
  cursor: pointer; font-weight: 650; font-size: 0.84rem; color: var(--ink);
  list-style: none;
}
.upload-advanced summary::-webkit-details-marker { display: none; }
.upload-advanced[open] summary { margin-bottom: 0.65rem; }
.upload-advanced .field { margin-top: 0.55rem; }
.mix-section { margin: 0.85rem 0 1.2rem; }
.mix-head { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.mix-head h2 { margin: 0; }
.mix-layout {
  display: grid; grid-template-columns: minmax(240px, 300px) 1fr;
  gap: 1.1rem; align-items: start; margin-top: 0.45rem;
}
.mix-visual { display: flex; flex-direction: column; gap: 0.75rem; min-width: 0; }
.mix-donut { min-height: 200px; display: grid; place-items: center; padding: 0.7rem; }
.mix-legend {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 0.45rem;
  text-align: left;
}
.mix-legend li {
  display: grid; grid-template-columns: 0.7rem 1fr auto; gap: 0.45rem 0.55rem;
  align-items: start; font-size: 0.78rem; line-height: 1.25;
}
.mix-swatch {
  width: 0.7rem; height: 0.7rem; border-radius: 2px; margin-top: 0.2rem;
}
.mix-legend-main { display: flex; flex-direction: column; gap: 0.08rem; min-width: 0; }
.mix-legend-name { font-weight: 600; color: var(--ink); }
.mix-legend-perf { color: var(--muted); font-size: 0.72rem; font-variant-numeric: tabular-nums; }
.mix-legend-pct {
  font-family: var(--mono); font-weight: 650; font-size: 0.78rem;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.mix-section .class-grid { margin: 0; }
.class-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; margin: 0.85rem 0; }
.class-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.85rem 0.95rem; box-shadow: var(--shadow); }
.class-card h3 { font-size: 0.95rem; margin-bottom: 0.35rem; }
.class-card dl { display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 0.8rem; margin: 0; font-size: 0.82rem; }
.class-card dt { color: var(--muted); }
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; margin-top: 0.85rem; }
.vs-nifty { margin: 1rem 0 1.35rem; }
.vs-nifty h2 { margin: 0 0 0.15rem; font-size: 1.05rem; }
.verdict {
  padding: 0.85rem 1rem; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--paper); font-weight: 600; margin: 0.55rem 0 0.75rem;
}
.verdict.beat { background: color-mix(in srgb, var(--gain) 12%, var(--paper)); color: var(--gain); }
.verdict.miss { background: color-mix(in srgb, var(--loss) 10%, var(--paper)); color: var(--loss); }
.verdict.muted { color: var(--muted); font-weight: 500; }
.vs-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.7rem; margin-bottom: 0.85rem; }
.vs-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem 0.9rem; box-shadow: var(--shadow); }
.vs-card h3 { font-size: 0.95rem; margin: 0 0 0.4rem; }
.vs-card dl { display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 0.8rem; margin: 0; font-size: 0.82rem; }
.vs-card dt { color: var(--muted); }
.vs-card.beat { border-color: color-mix(in srgb, var(--gain) 45%, var(--line)); }
.vs-card.miss { border-color: color-mix(in srgb, var(--loss) 45%, var(--line)); }
.cash-chart { grid-template-columns: 1fr; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem; }
.chart-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.85rem 0.95rem 1.05rem; box-shadow: var(--shadow); }
.chart-card h3 { font-size: 0.92rem; margin-bottom: 0.55rem; color: var(--ink); }
.chart-card.wide { grid-column: 1 / -1; }
.warn-list { color: var(--sat); font-size: 0.82rem; }
.flag {
  display: inline-block; padding: 0.1rem 0.45rem; border-radius: 999px; font-size: 0.7rem;
  border: 1px solid var(--line); font-weight: 650;
}
.flag-watch { background: #fef3c7; color: #92400e; }
.account-totals { font-size: 0.78rem; color: var(--muted); min-width: 12rem; margin-bottom: 0.5rem; }
.account-totals table { width: auto; }
.account-totals th, .account-totals td { padding: 0.18rem 0.45rem; }
.alloc-panels {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; margin: 0 0 0.35rem;
}
.alloc-card { padding: 0.45rem 0.5rem 0.1rem; }
.alloc-card h2 { margin: 0.15rem 0.25rem 0.4rem; font-size: 0.88rem; }
.alloc-table th[colspan] { text-align: center; }
.alloc-table tfoot .alloc-total td { font-weight: 700; border-top: 2px solid var(--line); background: color-mix(in srgb, var(--accent) 6%, var(--paper)); }
select.cell-edit {
  max-width: 6.6rem; font: inherit; color: inherit; background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px; padding: 0.12rem 0.22rem; font-size: 0.75rem;
}
.gap-panel { margin: 1rem 0 1.4rem; }
.gap-head { display: flex; justify-content: space-between; gap: 1rem; align-items: baseline; margin-bottom: 0.4rem; }
.gap-head h2 { font-size: 1.05rem; }
tr.gap-mismatch { background: color-mix(in srgb, var(--loss) 10%, transparent); }
tr.gap-only { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.flag-review { background: #ffedd5; color: #9a3412; }
.flag-exit { background: #fee2e2; color: #991b1b; }
:root[data-theme="dark"] .flag-watch { background: #3a3420; color: #efe4c8; }
:root[data-theme="dark"] .flag-review { background: #3a2a18; color: #f3d7b8; }
:root[data-theme="dark"] .flag-exit { background: #3a1818; color: #f3c8c8; }
.reasons { margin: 0; padding-left: 1.1rem; color: var(--muted); font-size: 0.8rem; white-space: normal; max-width: 28rem; }
.note-snip { color: var(--muted); font-size: 0.78rem; white-space: normal; max-width: 16rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.85rem; margin: 1rem 0; }
.form-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.form-card h2 { font-size: 1.05rem; margin-bottom: 0.7rem; }
.form-card label.field { margin-bottom: 0.55rem; }
.check { display: flex; gap: 0.45rem; align-items: center; font-size: 0.85rem; margin: 0.4rem 0; }
.drop {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 1.5rem; text-align: center;
  background: var(--paper); margin: 1rem 0;
}
.drop.on { border-color: var(--accent); }
#journalPreview h2 { margin-top: 1.2rem; }
.issues { font-size: 0.85rem; }
.issues .error { color: var(--loss); }
.issues .warning { color: var(--sat); }
.alias-list { font-size: 0.8rem; color: var(--muted); }
.head-actions { display: flex; gap: 0.55rem; align-items: flex-end; flex-wrap: wrap; }
.head-actions a.chip { text-decoration: none; display: inline-block; }
.asset-multi { position: relative; min-width: 11.5rem; }
.asset-btn {
  text-align: left; min-width: 11.5rem; max-width: 18rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: var(--paper); color: var(--ink); border: 1px solid var(--line);
  padding: 0.42rem 0.55rem; border-radius: var(--radius-sm); cursor: pointer; font-weight: 550;
}
.asset-menu {
  position: absolute; z-index: 20; top: calc(100% + 0.25rem); left: 0;
  min-width: 14rem; max-height: 18rem; overflow: auto;
  background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); padding: 0.4rem 0.55rem;
}
.asset-menu .check { margin: 0.15rem 0; color: var(--ink); font-weight: 500; }
.asset-menu .check.indent { padding-left: 1.1rem; font-size: 0.78rem; }
.kpi.metric, .metric { cursor: pointer; }
.insights { padding-left: 1.2rem; max-width: 52rem; }
.insights li { margin: 0.35rem 0; }
.wide-modal { width: min(860px, 96vw); max-height: 80vh; overflow: auto; }
.mf-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.65rem; }
.mf-grid[hidden] { display: none !important; }
.mf-grid-2 { grid-template-columns: 1fr 1fr; }
.ie-tabs { display: flex; gap: 0.35rem; flex-wrap: wrap; margin: 0.45rem 0 0.9rem; }
.ie-tabs .chip { border-radius: 9px; }
.ie-panel[hidden] { display: none !important; }
.conf-pill {
  display: inline-block; min-width: 2.4rem; text-align: center;
  font-size: 0.68rem; font-weight: 700; border-radius: 999px;
  padding: 0.1rem 0.4rem; border: 1px solid var(--line);
}
.conf-pill.low { color: #9a3412; background: #ffedd5; border-color: #fdba74; }
.conf-pill.mid { color: #854d0e; background: #fef9c3; border-color: #fde047; }
.conf-pill.high { color: #166534; background: #dcfce7; border-color: #86efac; }
.ie-bulkbar {
  display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: end;
  margin: 0 0 0.7rem; padding: 0.65rem 0.8rem;
  border: 1px solid var(--line); border-radius: 12px; background: var(--paper);
  box-shadow: var(--shadow);
}
.ie-bulkbar[hidden] { display: none !important; }
.ie-analysis-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; margin-top: 0.85rem;
}
.ie-section-title { font-size: 0.95rem; margin: 0.45rem 0 0.5rem; }
.ie-retire-card {
  margin-top: 1rem; padding: 0.95rem 1.05rem; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow);
}
.ie-retire-card h3 { margin: 0 0 0.25rem; font-size: 1.05rem; }
.ie-calc-steps {
  margin: 0.65rem 0 0.85rem; padding-left: 1.2rem; font-size: 0.85rem; color: var(--ink);
  line-height: 1.45;
}
.ie-retire-cats {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.35rem 0.75rem;
  margin-top: 0.35rem;
}
.ie-retire-cats label.check { font-size: 0.82rem; }
.ie-dash-card {
  margin: 0.85rem 0 1rem; padding: 0.95rem 1.05rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper); box-shadow: var(--shadow);
}
.ie-dash-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.75rem; margin-bottom: 0.55rem;
}
.ie-dash-head h2 { margin: 0; font-size: 1.05rem; }
.ie-plan-forms {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; margin-bottom: 0.85rem;
}
.ie-plan-forms .ie-bulkbar { margin: 0; }
.ie-plan-edit-hint { font-size: 0.78rem; color: var(--muted); margin: 0 0 0.35rem; }
.suggest {
  list-style: none; margin: 0.25rem 0 0; padding: 0;
  border: 1px solid var(--line); border-radius: 10px; background: var(--paper);
  max-height: 220px; overflow: auto;
}
.suggest li button {
  width: 100%; text-align: left; background: none; border: 0; color: var(--ink);
  padding: 0.45rem 0.7rem; cursor: pointer; font-size: 0.82rem;
}
.suggest li button:hover { background: var(--accent-soft); }
.muted { color: var(--muted); font-size: 0.74rem; font-weight: 500; }
#mfSearchField { position: relative; }
button.edit-lot {
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  padding: 0.2rem 0.55rem; border-radius: 999px; cursor: pointer; font-size: 0.75rem;
}
td.row-actions { white-space: nowrap; }
td.row-actions button { margin-right: 0.25rem; }
button.del-lot, button.del-stock { color: var(--loss); }
#editLotForm .field { margin-bottom: 0.55rem; }
#editLotForm input, #editLotForm select {
  border: 1px solid var(--line); border-radius: 8px; padding: 0.35rem 0.5rem; background: var(--bg); color: var(--ink);
}
#editLotError { color: var(--loss); min-height: 1.1rem; }

/* Phase B: loading / toast */
.page-loading { opacity: 0.55; pointer-events: none; transition: opacity var(--ease); }
.skeleton-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; margin: 0.9rem 0; }
.skeleton {
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--paper);
  min-height: 4.6rem; position: relative; overflow: hidden;
}
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 10%, transparent), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer {
  100% { transform: translateX(100%); }
}
.toast-host {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 50;
  display: grid; gap: 0.45rem; width: min(22rem, calc(100vw - 2rem));
}
.toast {
  background: var(--paper); color: var(--ink); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); padding: 0.7rem 0.85rem;
  font-size: 0.84rem; line-height: 1.35;
  animation: toast-in 180ms ease;
}
.toast.ok { border-color: color-mix(in srgb, var(--gain) 40%, var(--line)); }
.toast.err { border-color: color-mix(in srgb, var(--loss) 45%, var(--line)); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 900px) {
  .ie-analysis-grid, .ie-plan-forms { grid-template-columns: 1fr; }
  .skeleton-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .rail {
    position: relative; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center;
    backdrop-filter: none;
  }
  .rail nav { flex-direction: row; flex-wrap: wrap; width: 100%; }
  .rail-foot { width: 100%; flex-direction: row; }
  .summary, .holdings-summary, .kpis-8, .class-grid, .vs-grid, .charts, .alloc-panels, .mix-layout { grid-template-columns: 1fr; }
  .theme-btn { margin-top: 0; }
  main { padding: 1rem 1rem 2rem; }
}
