:root {
  color-scheme: dark;
  --bg: #07111f;
  --surface: #0c1929;
  --surface-2: #101f31;
  --surface-3: #14263a;
  --border: #203249;
  --text: #eff6ff;
  --muted: #8ca0b8;
  --primary: #27d8a1;
  --primary-dark: #0d9f78;
  --danger: #fb7185;
  --warning: #fbbf24;
  --cyan: #22d3ee;
  --violet: #a78bfa;
  --sidebar: 250px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 80% -10%, rgba(39, 216, 161, .08), transparent 30%), var(--bg); color: var(--text); }
.login-screen { position: fixed; inset: 0; z-index: 9999; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at top, #102b3d, var(--bg) 55%); }
.login-screen[hidden] { display: none; }
.login-card { width: min(420px, 100%); border: 1px solid var(--border); border-radius: 18px; background: var(--surface); padding: 32px; box-shadow: 0 30px 80px rgba(0,0,0,.45); }
.login-card h1 { margin: 8px 0; }
.login-card p:not(.eyebrow) { margin: 0 0 24px; color: var(--muted); }
.login-card label { display: grid; gap: 7px; margin-top: 15px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.login-card input { border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text); padding: 13px; }
.login-card .button { width: 100%; margin-top: 18px; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; display: flex; width: var(--sidebar); flex-direction: column; overflow-y: auto; border-right: 1px solid var(--border); background: rgba(7, 17, 31, .96); padding: 24px 16px; backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 22px; }
.brand-mark { display: grid; width: 40px; height: 40px; place-items: center; border-radius: 12px; background: linear-gradient(135deg, var(--primary), #16a2cb); color: #032019; font-weight: 900; box-shadow: 0 8px 24px rgba(39,216,161,.2); }
.brand strong, .brand span { display: block; }
.brand strong { letter-spacing: -.02em; }
.brand span { margin-top: 2px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; }
.navigation { display: grid; gap: 5px; }
.nav-section-label { margin: 13px 13px 3px; color: #627890; font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .16em; }
.nav-section-label:first-child { margin-top: 0; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; border-radius: 10px; background: transparent; color: var(--muted); padding: 11px 13px; text-align: left; transition: .18s ease; }
.nav-item span { width: 20px; color: #6d839c; text-align: center; }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: linear-gradient(90deg, rgba(39,216,161,.16), rgba(39,216,161,.05)); color: var(--primary); box-shadow: inset 3px 0 var(--primary); }
.nav-item.active span { color: var(--primary); }
.sidebar-close { display: none; margin-left: auto; width: 40px; height: 40px; place-items: center; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2); color: var(--muted); font-size: 24px; line-height: 1; }
.sidebar-footer { margin-top: auto; }
.connection-card { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); padding: 12px; }
.connection-card strong, .connection-card span { display: block; }
.connection-card strong { font-size: 12px; }
.connection-card div span { margin-top: 2px; color: var(--muted); font-size: 10px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 4px rgba(251,191,36,.1); }
.status-dot.online { background: var(--primary); box-shadow: 0 0 0 4px rgba(39,216,161,.1); }
.status-dot.offline { background: var(--danger); box-shadow: 0 0 0 4px rgba(251,113,133,.1); }

.content-shell { min-height: 100vh; margin-left: var(--sidebar); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; min-height: 82px; align-items: center; gap: 18px; border-bottom: 1px solid rgba(32,50,73,.8); background: rgba(7,17,31,.88); padding: 14px clamp(18px, 3vw, 40px); backdrop-filter: blur(18px); }
.topbar h1 { margin: 1px 0 0; font-size: 23px; letter-spacing: -.03em; }
.eyebrow { margin: 0; color: var(--primary); font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: .14em; }
.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.currency-toolbar { display: flex; align-items: center; gap: 7px; }
.exchange-rate-button { white-space: nowrap; }
.last-update { color: var(--muted); font-size: 11px; margin-right: 4px; }
.last-update.syncing { display: inline-flex; align-items: center; gap: 7px; color: #b9c9d9; }
.last-update.syncing::before { content: ""; width: 11px; height: 11px; border: 2px solid rgba(39,216,161,.24); border-top-color: var(--primary); border-radius: 50%; animation: spin .75s linear infinite; }
.last-update.sync-error { color: var(--danger); }
@keyframes spin { to { transform: rotate(360deg); } }
.menu-button { display: none; border: 0; background: transparent; color: var(--text); font-size: 22px; }
.main-content { padding: 28px clamp(18px, 3vw, 40px) 48px; }
.view { display: none; }
.view.active { display: block; animation: appear .22s ease; }
@keyframes appear { from { opacity: 0; transform: translateY(4px); } }

.button { min-height: 42px; border: 1px solid transparent; border-radius: 9px; padding: 9px 14px; color: var(--text); font-size: 12px; font-weight: 700; transition: .18s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .6; transform: none; }
.button.primary { background: linear-gradient(135deg, var(--primary-dark), #0b8dac); box-shadow: 0 7px 18px rgba(13,159,120,.18); }
.button.danger { border-color: rgba(251,113,133,.35); background: linear-gradient(135deg, #be3450, #9f2941); box-shadow: 0 7px 18px rgba(190,52,80,.18); }
.button.secondary, .button.ghost { border-color: var(--border); background: var(--surface-2); }
.button.ghost { color: var(--muted); }
.text-button { min-height: 36px; border: 0; border-radius: 7px; background: transparent; color: var(--primary); padding: 7px 6px; font-size: 12px; }
.text-button:hover { background: rgba(39,216,161,.07); }

.metrics-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 18px; }
.metric-card { display: flex; min-height: 126px; align-items: center; gap: 14px; border: 1px solid var(--border); border-radius: 14px; background: linear-gradient(145deg, var(--surface-2), rgba(12,25,41,.76)); padding: 20px; box-shadow: 0 14px 36px rgba(0,0,0,.12); }
.metric-card > div:last-child { flex: 1; min-width: 0; }
.metric-icon { display: grid; flex: 0 0 38px; height: 38px; place-items: center; border-radius: 11px; font-weight: 900; }
.metric-icon.cyan { background: rgba(34,211,238,.12); color: var(--cyan); }
.metric-icon.emerald { background: rgba(39,216,161,.12); color: var(--primary); }
.metric-icon.violet { background: rgba(167,139,250,.12); color: var(--violet); }
.metric-icon.amber { background: rgba(251,191,36,.12); color: var(--warning); }
.metric-card span, .metric-card small, .metric-card strong { display: block; }
.metric-card span { color: var(--muted); font-size: 11px; }
.metric-card strong { margin: 7px 0 5px; font-size: clamp(18px, 2vw, 25px); font-variant-numeric: tabular-nums; letter-spacing: -.04em; white-space: nowrap; }
.metric-card small { color: var(--muted); font-size: 10.5px; line-height: 1.35; }
.metric-card.negative strong { color: var(--danger); }
.metric-card.positive strong { color: var(--primary); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(270px, .7fr); gap: 18px; margin-bottom: 18px; }
.panel { overflow: hidden; border: 1px solid var(--border); border-radius: 14px; background: rgba(12,25,41,.82); box-shadow: 0 16px 40px rgba(0,0,0,.12); }
.panel + .panel { margin-top: 18px; }
.dashboard-grid .panel + .panel { margin-top: 0; }
.panel-header { display: flex; min-height: 70px; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--border); padding: 16px 20px; }
.panel-header h2 { margin: 4px 0 0; font-size: 15px; }
.panel-description { max-width: 620px; margin: 8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.panel-actions { display: flex; align-items: center; gap: 8px; }
.table-wrap { overflow-x: auto; scrollbar-color: #7a8794 #30343a; scrollbar-width: auto; }
.table-wrap:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.scroll-hint { display: none; margin: 0; border-top: 1px solid var(--border); background: rgba(7,17,31,.5); color: var(--muted); padding: 8px 14px; font-size: 10.5px; text-align: right; }
.scroll-hint.visible { display: block; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { border-bottom: 1px solid rgba(32,50,73,.65); padding: 13px 18px; text-align: left; }
th { border-bottom-color: #2b4058; background: rgba(7,17,31,.92); color: #9bb0c7; font-size: 10.5px; font-weight: 750; text-transform: uppercase; letter-spacing: .07em; }
td { color: #d7e2ee; font-size: 12px; }
.numeric-column { text-align: right; font-variant-numeric: tabular-nums; }
.numeric-column strong, .numeric-column small { font-variant-numeric: tabular-nums; }
.table-wrap.priority-column th:first-child, .table-wrap.priority-column td:first-child { position: sticky; left: 0; z-index: 1; background: #0c1929; box-shadow: 8px 0 14px rgba(3,10,18,.24); }
.table-wrap.priority-column th:first-child { z-index: 3; background: #091522; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:nth-child(even):not(.cancelled-row) { background: rgba(255,255,255,.012); }
tbody tr:hover { background: rgba(39,216,161,.035); }
.table-wrap.priority-column tbody tr:nth-child(even):not(.cancelled-row) td:first-child { background: #0d1b2c; }
.table-wrap.priority-column tbody tr:hover td:first-child { background: #102337; }
#view-portfolio td:last-child, #view-assets td:last-child, #view-history td:last-child, #view-quotes td:last-child, #view-alerts td:last-child, #view-dividends td:last-child { min-width: 145px; white-space: normal; }
#view-portfolio td:last-child .text-button, #view-assets td:last-child .text-button, #view-history td:last-child .text-button, #view-quotes td:last-child .text-button, #view-alerts td:last-child .text-button, #view-dividends td:last-child .text-button { margin: 2px 3px 2px 0; }
#view-quotes table, #view-quotes tbody, #view-quotes tbody tr { height: auto; }
#view-quotes tbody td { height: auto; padding-top: 10px; padding-bottom: 10px; line-height: 1.3; vertical-align: middle; }
#view-quotes .asset-cell { min-height: 32px; }
#view-quotes td:last-child { min-width: 250px; white-space: nowrap; }
#view-quotes .text-button { min-height: 32px; padding-top: 5px; padding-bottom: 5px; }
.asset-cell { display: flex; align-items: center; gap: 10px; }
.asset-avatar { display: grid; width: 30px; height: 30px; place-items: center; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-3); color: var(--primary); font-size: 10px; font-weight: 800; }
.asset-cell strong, .asset-cell span { display: block; }
.asset-cell span { margin-top: 2px; color: var(--muted); font-size: 10.5px; }
.positive { color: var(--primary) !important; }
.negative { color: var(--danger) !important; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 8px; font-size: 10px; font-weight: 750; }
.badge.buy { background: rgba(39,216,161,.12); color: var(--primary); }
.badge.sell { background: rgba(251,113,133,.12); color: var(--danger); }
.badge.neutral { border: 1px solid var(--border); background: var(--surface-3); color: var(--muted); }
.badge.cancelled { color: #fecdd3; background: rgba(225, 29, 72, .22); }
.cancelled-row { opacity: .72; background: rgba(225, 29, 72, .035); }
.cancellation-detail { display: block; min-width: 150px; margin-top: 6px; color: var(--muted); line-height: 1.35; }
.danger-link { color: var(--danger); }
.empty-cell { height: 160px; color: var(--muted); text-align: center; white-space: normal; }

.allocation-content { display: grid; justify-items: center; gap: 22px; padding: 26px 20px; }
.donut { display: grid; width: 154px; height: 154px; place-items: center; border-radius: 50%; background: conic-gradient(var(--surface-3) 0 100%); position: relative; }
.donut::after { content: ""; position: absolute; width: 104px; height: 104px; border-radius: 50%; background: var(--surface); }
.donut div { position: relative; z-index: 1; text-align: center; }
.donut strong, .donut span { display: block; }
.donut strong { font-size: 17px; }
.donut span { color: var(--muted); font-size: 9px; margin-top: 3px; }
.legend { display: grid; width: 100%; gap: 9px; }
.legend-row { display: grid; grid-template-columns: 8px 1fr auto; align-items: center; gap: 8px; color: var(--muted); font-size: 10px; }
.legend-color { width: 7px; height: 7px; border-radius: 50%; }
.legend-row strong { color: var(--text); font-size: 10px; }

.search, .select, input, select { border: 1px solid var(--border); border-radius: 9px; outline: none; background: #091522; color: var(--text); }
.search { width: 210px; min-height: 38px; padding: 8px 12px; font-size: 11px; }
.select.compact { min-height: 38px; padding: 7px 11px; font-size: 11px; }
input:focus, select:focus { border-color: var(--primary-dark); box-shadow: 0 0 0 3px rgba(39,216,161,.08); }

.modal { width: min(620px, calc(100% - 28px)); max-height: calc(100dvh - 28px); overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); padding: 0; box-shadow: 0 30px 90px rgba(0,0,0,.55); }
.modal.wide-modal { width: min(980px, calc(100% - 28px)); max-width: none; }
.modal.compact-modal { width: min(520px, calc(100% - 28px)); }
.modal::backdrop { background: rgba(1,8,16,.76); backdrop-filter: blur(5px); }
.modal form { padding: 22px; }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; }
.modal-header h2 { margin: 4px 0 0; font-size: 20px; }
.close-button { display: grid; width: 44px; height: 44px; place-items: center; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 26px; line-height: 1; }
.close-button:hover { background: var(--surface-2); color: var(--text); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.form-grid label { display: grid; gap: 7px; }
.form-grid label.full { grid-column: 1 / -1; }
.form-grid label span { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.form-grid label small, .form-help { color: var(--muted); font-size: 11px; line-height: 1.45; }
.form-help { margin: 14px 0 0; }
.fx-current-info { margin: 14px 0 0; color: var(--text); font-size: 11px; line-height: 1.5; }
.fx-warning { margin: 10px 0 0; border-left: 3px solid var(--warning); padding-left: 10px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.form-grid input, .form-grid select { width: 100%; min-height: 43px; padding: 9px 11px; font-size: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.form-error { display: none; margin-top: 14px; border-radius: 9px; background: rgba(251,113,133,.1); color: var(--danger); padding: 10px 12px; font-size: 11px; }
.form-error.visible { display: block; }
.confirmation-message { margin: 0; border-left: 3px solid var(--warning); background: rgba(251,191,36,.045); color: #cbd8e6; padding: 12px 14px; font-size: 12px; line-height: 1.55; }
.manual-batch-summary { margin: 14px 0 10px; color: var(--muted); font-size: 12px; }
.manual-batch-table { max-height: 52vh; border: 1px solid var(--border); border-radius: 10px; }
.manual-batch-table thead { position: sticky; top: 0; z-index: 1; background: var(--surface); }
.manual-batch-table input { min-width: 150px; width: 100%; padding: 9px 10px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 100; max-width: 360px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-3); padding: 12px 15px; color: var(--text); font-size: 11px; box-shadow: 0 18px 50px rgba(0,0,0,.38); opacity: 0; pointer-events: none; transform: translateY(10px); transition: .2s ease; }
.toast.visible { opacity: 1; transform: none; }
.toast.error { border-color: rgba(251,113,133,.5); color: #fecdd3; }
.mobile-overlay { display: none; }
.charts-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.charts-grid .panel + .panel { margin-top: 0; }
.chart-panel .panel-header { min-width: 0; }
.chart-panel .panel-header.responsive-header { align-items: flex-start; flex-direction: column; }
.chart-panel .panel-header.responsive-header .panel-actions { display: grid; width: 100%; grid-template-columns: minmax(0,1fr) auto; }
.chart-panel .panel-header.responsive-header .select { width: 100%; min-width: 0; }
.chart-panel .panel-header.responsive-header .button { white-space: nowrap; }
.chart-container { min-height: 290px; padding: 16px 18px 12px; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid-line { stroke: var(--border); stroke-width: 1; opacity: .65; }
.chart-axis-label { fill: var(--muted); font-size: 10px; }
.chart-line { fill: none; stroke: var(--primary); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.chart-area { fill: rgba(39,216,161,.08); }
.chart-hit-area { fill: transparent; pointer-events: all; }
.chart-point { fill: var(--surface); stroke: var(--primary); stroke-width: 3; transition: r .15s ease, fill .15s ease; pointer-events: none; }
.chart-point-group:hover .chart-point, .chart-point-group:focus .chart-point { r: 7px; fill: var(--primary); }
.chart-point-group:focus { outline: none; }
.chart-value { fill: var(--text); font-size: 11px; font-weight: 700; }
.chart-summary { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 1px; overflow: hidden; margin-top: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--border); }
.chart-summary div { min-width: 0; background: rgba(7,17,31,.76); padding: 10px 12px; }
.chart-summary span, .chart-summary strong { display: block; }
.chart-summary span { overflow: hidden; color: var(--muted); font-size: 9.5px; text-overflow: ellipsis; white-space: nowrap; }
.chart-summary strong { margin-top: 5px; font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-help { margin: 8px 2px 0; color: var(--muted); font-size: 9.5px; }
.chart-empty { display: grid; min-height: 250px; place-items: center; color: var(--muted); font-size: 12px; text-align: center; }
.modal.chart-modal { width: min(1180px, calc(100% - 28px)); max-width: none; }
.chart-modal-inner { padding: 22px; }
.chart-modal-content { min-height: 420px; }
.chart-modal-content .chart-svg { width: 100%; }
.chart-modal-content .chart-axis-label { font-size: 12px; }
.chart-modal-content .chart-value { font-size: 13px; }
.chart-modal-content .chart-point { r: 6px; }
.system-details { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 1px; background: var(--border); }
.system-details > div { background: var(--surface); padding: 20px; }
.system-details span, .system-details strong { display: block; }
.system-details span { color: var(--muted); font-size: 10px; margin-bottom: 7px; text-transform: uppercase; letter-spacing: .05em; }
.system-details strong { font-size: 12px; overflow-wrap: anywhere; }
.notification-panel { margin-bottom: 18px; }
.notification-panel small { display: block; margin-top: 6px; color: var(--muted); }
.file-input { max-width: 310px; min-height: 38px; padding: 7px 10px; font-size: 11px; }
.file-input::file-selector-button { margin-right: 10px; border: 0; border-radius: 7px; background: var(--surface-3); color: var(--text); padding: 6px 9px; cursor: pointer; }
.import-safety { margin: 0 20px 18px; border: 1px solid rgba(39,216,161,.22); border-radius: 10px; background: rgba(39,216,161,.06); color: var(--primary); padding: 11px 13px; font-size: 11px; line-height: 1.5; }
.import-metrics { margin-top: 18px; }
.import-table { max-height: 620px; overflow: auto; }
.import-table thead { position: sticky; top: 0; z-index: 2; background: var(--surface); }
.import-excluded { opacity: .58; }
.import-excluded td { background: rgba(148,163,184,.025); }
.adjustment-row td { background: rgba(139,92,246,.035); }
.text-button.negative { color: var(--danger); }

button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.broker-list { display: flex; flex-wrap: wrap; gap: 5px; min-width: 72px; }
.portfolio-type-filter { min-width: 140px; }

@media (max-width: 1480px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 1280px) {
  #view-portfolio th:nth-child(6), #view-portfolio td:nth-child(6),
  #view-assets th:nth-child(3), #view-assets td:nth-child(3),
  #view-assets th:nth-child(4), #view-assets td:nth-child(4),
  #view-assets th:nth-child(6), #view-assets td:nth-child(6),
  #view-history th:nth-child(6), #view-history td:nth-child(6),
  #view-history th:nth-child(7), #view-history td:nth-child(7),
  #view-quotes th:nth-child(2), #view-quotes td:nth-child(2),
  #view-quotes th:nth-child(5), #view-quotes td:nth-child(5),
  #view-quotes th:nth-child(8), #view-quotes td:nth-child(8) { display: none; }
}

@media (max-width: 1120px) {
  #view-portfolio .responsive-header { align-items: flex-start; flex-direction: column; }
  #view-portfolio .portfolio-controls { width: 100%; flex-wrap: wrap; }
  #view-portfolio .portfolio-controls .search { flex: 1 1 220px; width: auto; }
  #view-portfolio th:nth-child(3), #view-portfolio td:nth-child(3),
  #view-portfolio th:nth-child(4), #view-portfolio td:nth-child(4),
  #view-history th:nth-child(5), #view-history td:nth-child(5),
  #view-quotes th:nth-child(4), #view-quotes td:nth-child(4),
  #view-quotes th:nth-child(6), #view-quotes td:nth-child(6),
  #view-quotes th:nth-child(7), #view-quotes td:nth-child(7) { display: none; }
  #view-quotes td:last-child { min-width: 250px; white-space: nowrap; }
}

@media (max-width: 1120px) {
  .metrics-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .allocation-content { grid-template-columns: auto 1fr; align-items: center; }
}

@media (max-width: 800px) {
  .sidebar { width: min(310px, 88vw); transform: translateX(-101%); transition: transform .22s ease; box-shadow: 24px 0 60px rgba(0,0,0,.35); }
  .sidebar.open { transform: none; }
  .sidebar-close { display: grid; }
  body.mobile-menu-open { overflow: hidden; }
  .mobile-overlay.open { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(0,0,0,.55); }
  .content-shell { margin-left: 0; }
  .menu-button { display: block; }
  .topbar { min-height: 72px; }
  .topbar-actions .last-update, .topbar-actions .secondary, .exchange-rate-button { display: none; }
  .responsive-header { align-items: flex-start; flex-direction: column; }
  .panel-actions { width: 100%; flex-wrap: wrap; }
  .search { flex: 1 1 180px; width: auto; }
  .charts-grid { grid-template-columns: 1fr; }
  .system-details { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 560px) {
  .main-content { padding: 18px 12px 36px; }
  .topbar { flex-wrap: wrap; gap: 10px; padding: 12px; }
  .topbar h1 { font-size: 19px; }
  .topbar-actions { width: 100%; justify-content: flex-end; gap: 6px; margin-left: 0; }
  .topbar-actions .button, .topbar-actions .select.compact { min-height: 40px; padding: 7px 9px; }
  .topbar-actions .button { padding: 7px 10px; }
  .metrics-grid { grid-template-columns: 1fr; gap: 10px; }
  .metric-card { min-height: 102px; padding: 16px; }
  .panel-header { padding: 14px; }
  th, td { padding: 12px 14px; }
  .allocation-content { grid-template-columns: 1fr; }
  .chart-summary { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .chart-help { display: none; }
  .chart-panel .panel-header.responsive-header .panel-actions { grid-template-columns: 1fr; }
  .chart-panel .panel-header.responsive-header .button { width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid label.full { grid-column: auto; }
  .system-details { grid-template-columns: 1fr; }
  .modal { width: calc(100% - 16px); max-height: calc(100dvh - 16px); border-radius: 14px; }
  .modal form { padding: 18px; }
  .modal-header { position: sticky; top: 0; z-index: 5; margin: -18px -18px 18px; border-bottom: 1px solid var(--border); background: rgba(12,25,41,.98); padding: 18px 18px 12px; backdrop-filter: blur(12px); }
  .modal-header h2 { font-size: 18px; }
  .modal .form-grid input, .modal .form-grid select, .modal textarea { min-height: 46px; font-size: 16px; }
  .modal .button { min-height: 44px; }
  .modal-actions { position: sticky; bottom: 0; z-index: 5; margin: 18px -18px -18px; border-top: 1px solid var(--border); background: rgba(12,25,41,.98); padding: 12px 18px; backdrop-filter: blur(12px); }
  .wide-modal .modal-actions { flex-wrap: wrap; }
  .scroll-hint { text-align: left; }
  #view-portfolio th:nth-child(3), #view-portfolio td:nth-child(3),
  #view-assets th:nth-child(2), #view-assets td:nth-child(2),
  #view-history th:nth-child(4), #view-history td:nth-child(4) { display: none; }
  #view-portfolio td:last-child, #view-assets td:last-child, #view-history td:last-child, #view-quotes td:last-child { min-width: 132px; }
  #view-quotes td:last-child { min-width: 250px; white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
  .last-update.syncing::before { border-color: var(--primary); }
}
