/* Layout and components from the supplied redesign; existing palette is retained. */
:root { --sans: 'Inter', system-ui, sans-serif; --brand: 'Space Grotesk', var(--sans); color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }
body { font-family: var(--sans); font-size: 14px; line-height: 1.5; font-variant-numeric: tabular-nums; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: not-allowed; opacity: .55; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.skip-link { position: fixed; top: -80px; left: 16px; z-index: 500; padding: 12px 18px; background: var(--surface); color: var(--text); border: 1px solid var(--accent); border-radius: 8px; }
.skip-link:focus { top: 12px; }
.app-shell .sidebar { width: 232px; transform: translateX(-232px); padding: 24px 12px 12px; height: 100dvh; overflow-y: auto; overscroll-behavior: contain; }
.app-shell.sidebar-open .sidebar { transform: translateX(0); }
.sidebar-logo { font-family: var(--brand); font-size: 23px; padding: 0 12px 4px; text-decoration: none; color: var(--text); font-weight: 700; }
.sidebar-user { font: 400 12px var(--sans); text-transform: none; letter-spacing: 0; padding: 2px 12px 18px; margin-bottom: 8px; overflow-wrap: anywhere; }
.sidebar-close-btn { top: 27px; right: 14px; }
.nav-links { flex: 1 0 auto; padding-bottom: 16px; }
.nav-group { padding: 17px 12px 7px; font-size: 11px; font-weight: 600; letter-spacing: .09em; color: var(--muted); text-transform: uppercase; }
.nav-link { min-height: 40px; padding: 9px 12px; gap: 10px; border: 0; border-radius: 8px; font-size: 13px; font-weight: 500; margin: 2px 0; line-height: 1.45; }
html .nav-link.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-left: 0; font-weight: 600; }
.nav-icon { display: inline-flex; width: 18px; height: 18px; flex: 0 0 18px; }
.nav-icon svg { width: 100%; height: 100%; }
.nav-divider { border-top: 1px solid var(--border); margin-top: 18px; padding-top: 14px; }
.sidebar-footer { padding: 12px 0 0; margin-top: 8px; }
.sidebar-footer .nav-link { margin-bottom: 8px; }
.theme-toggle { padding: 8px 12px; font: 500 12px var(--sans); border-radius: 8px; margin-bottom: 8px; }
.logout-btn { display: block; padding: 8px 12px; font: 400 12px var(--sans); text-transform: none; letter-spacing: 0; }
.sidebar-toggle { top: 16px; left: 16px; border: 1px solid var(--border); background: var(--surface); color: var(--text); box-shadow: none; }
.sidebar-toggle:hover { background: var(--surface2); color: var(--accent); box-shadow: none; }
.app-shell .main-content { padding: 0 32px 40px; overflow: visible; max-width: 100%; }
.app-shell.sidebar-open .main-content { margin-left: 232px; }
.workspace-bar { height: 72px; display: flex; justify-content: space-between; align-items: center; gap: 16px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); margin-bottom: 28px; }
.workspace-bar > span:first-child { display: flex; gap: 12px; flex-wrap: wrap; }
.workspace-brand { font-family: var(--brand); font-weight: 700; color: var(--text); }
body:not(.sidebar-open) .workspace-bar { padding-left: 42px; }
.page-container { max-width: 1240px; margin: 0 auto; min-width: 0; }
.page-header { align-items: center; margin-bottom: 24px; gap: 16px; padding-left: 0; }
.page-title { font-size: 26px; font-weight: 700; letter-spacing: -.6px; line-height: 1.25; }
.page-sub { font: 400 13px/1.6 var(--sans); margin-top: 6px; }
.header-actions { gap: 8px; }
.btn-primary, .btn-secondary, .btn-ghost, .btn-accent { display: inline-flex; justify-content: center; align-items: center; gap: 6px; min-height: 36px; padding: 8px 14px; border-radius: 8px; font: 500 13px/1.4 var(--sans); text-decoration: none; letter-spacing: 0; text-transform: none; }
.header-actions .btn-primary { width: auto; }
.form-label { font: 500 12px/1.5 var(--sans); letter-spacing: 0; text-transform: none; }
.form-input { font: 400 14px/1.5 var(--sans); border-radius: 8px; padding: 10px 12px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
.tabs { gap: 4px; flex-wrap: wrap; max-width: 100%; padding: 4px; border-radius: 10px; }
.tab { font: 500 13px/1.4 var(--sans); letter-spacing: 0; text-transform: none; padding: 8px 14px; }
.feature-card { padding: 22px; }
.feature-title { font-size: 16px; font-weight: 600; }
.section-links { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.section-links a { color: var(--muted); text-decoration: none; padding: 6px 12px; border: 1px solid var(--border); border-radius: 999px; font-size: 12px; }
.section-links a:hover { color: var(--text); background: var(--surface2); }
[id$="-title"] { scroll-margin-top: 24px; }
/* Authentication uses the same card and type system without the application menu. */
.login-body { padding: 32px 16px; }
.login-card { width: min(440px, 100%); padding: 32px; border-radius: 12px; box-shadow: 0 16px 50px color-mix(in srgb, var(--bg) 50%, transparent); }
.brand { font-family: var(--brand); font-size: 28px; }
.brand-sub { font: 400 13px var(--sans); letter-spacing: 0; text-transform: none; }
.login-card .divider, .login-card .toggle-reg, .login-card .reg-title, .login-card .reg-hint { font-family: var(--sans); font-size: 12px; letter-spacing: 0; text-transform: none; }
/* Position view changes layout only; the original cards keep their data and actions. */
.positions-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 24px 0 12px; flex-wrap: wrap; }
.positions-toolbar h2 { font-size: 16px; font-weight: 600; }
.positions-toolbar p { font-size: 12px; color: var(--muted); margin-top: 3px; }
.view-switch { display: flex; gap: 4px; border: 1px solid var(--border); border-radius: 8px; padding: 3px; background: var(--surface); }
.view-switch button { background: transparent; color: var(--muted); border: 0; border-radius: 6px; padding: 6px 12px; font-size: 12px; cursor: pointer; }
.view-switch button[aria-pressed="true"] { background: var(--surface2); color: var(--text); font-weight: 600; }
.positions-scroll { max-width: 100%; overflow-x: auto; }
#pos-cards-grid.positions-table { display: flex; flex-direction: column; gap: 0; min-width: 1000px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); overflow: hidden; }
.positions-table .pos-cards-header { padding: 14px 18px; margin: 0; border-bottom: 1px solid var(--border); }
.positions-table .pos-card { display: grid; grid-template-columns: minmax(220px, 1.6fr) minmax(140px, 1fr) minmax(130px, 1fr) minmax(240px, 1.6fr) minmax(140px, 1fr); align-items: center; gap: 16px; padding: 16px 18px; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; }
.positions-table .pos-card:last-child { border-bottom: 0; }
.positions-table .pos-card:hover { background: var(--surface2); box-shadow: none; transform: none; }
.positions-table .pc-header { margin: 0; gap: 12px; }
.positions-table .pc-info { min-width: 0; }
.positions-table .pc-ticker { font-size: 15px; }
.positions-table .pc-name { max-width: 120px; }
.positions-table .pc-price-block { flex-shrink: 0; }
.positions-table .pc-cur-price { font-size: 14px; }
.positions-table .pc-daily-chg { font-size: 12px; }
.positions-table .pc-price-row { flex-direction: column-reverse; align-items: flex-end; gap: 2px; }
.positions-table .pc-subheader, .positions-table .pc-bar-row, .positions-table .pc-data-row, .positions-table .pc-pnl-section { margin: 0; padding: 0; border: 0; background: none; }
.positions-table .pc-divider { display: none; }
.positions-table .pc-data-val, .positions-table .pc-pnl-section-val { font-size: 15px; }
.positions-table .pc-pnl-section { text-align: right; }
.positions-table .pc-pnl-section-label { font-size: 12px; }
@media (min-width: 701px) { body:not(.sidebar-open) .sidebar { visibility: hidden; } }
@media (max-width: 1000px) { .app-shell .main-content { padding-right: 20px; padding-left: 20px; } }
@media (max-width: 700px) {
  .app-shell .main-content, .app-shell.sidebar-open .main-content { margin-left: 0; padding: 0 16px 28px; width: 100%; }
  .app-shell .sidebar { width: 250px; transform: translateX(-250px); }
  .app-shell:not(.sidebar-open) .sidebar { visibility: hidden; }
  .workspace-bar, body.sidebar-open .workspace-bar { padding-left: 48px; height: 70px; margin-bottom: 22px; }
  .workspace-brand { display: none; }
  .page-title { font-size: 24px; }
  .page-header { padding-left: 0; margin-top: 0; }
  .header-actions { width: 100%; }
  .login-card { padding: 24px; }
}
@media (prefers-reduced-motion: reduce) { .app-shell .sidebar, .app-shell .main-content { transition: none; } }
/* Override module card geometry only in the compact positions layout. */
#tab-positions .positions-table .pos-card { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: 16px 18px; }
#tab-positions .positions-table .pos-card:last-child { border-bottom: 0; }
#tab-positions .positions-table .pos-card:hover { box-shadow: none; }
.distribution-toolbar { width: fit-content; margin-bottom: 16px; }
.distribution-bars { display: flex; flex-direction: column; gap: 4px; max-height: 360px; overflow-y: auto; }
.distribution-bars[hidden], .donut-chart-area[hidden] { display: none; }
.distribution-row { display: grid; grid-template-columns: 60px minmax(60px, 1fr) 52px 78px; gap: 10px; align-items: center; padding: 10px 4px; background: none; color: var(--text); border: 0; border-radius: 6px; font-size: 12px; text-align: left; cursor: pointer; }
.distribution-row:hover { background: var(--surface2); }
.distribution-row strong { font-weight: 600; }
.distribution-track { height: 6px; background: var(--surface2); border-radius: 999px; overflow: hidden; }
.distribution-fill { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.distribution-fill.positive { background: var(--green); }
.distribution-fill.negative { background: var(--red); }
.distribution-weight, .distribution-value { text-align: right; }
.distribution-value { color: var(--muted); }
@media (max-width: 420px) { .distribution-row { grid-template-columns: 48px minmax(40px, 1fr) 44px 64px; gap: 6px; } }
