:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-subtle: #f8fafb;
  --text: #17201c;
  --muted: #64706a;
  --line: #dfe5e1;
  --brand: #176b4d;
  --brand-strong: #0f513a;
  --brand-soft: #e6f3ed;
  --warning: #b96b13;
  --warning-soft: #fff4df;
  --danger: #b33b3b;
  --danger-soft: #fdecec;
  --blue: #3976c6;
  --shadow: 0 12px 32px rgba(32, 45, 38, 0.07);
  --sidebar: #14231d;
  --sidebar-text: #f5faf7;
  --sidebar-muted: #b8c9c0;
  --sidebar-note: #dce9e2;
  --sidebar-note-muted: #91a79c;
  --sidebar-hover: rgba(255,255,255,0.06);
  --sidebar-line: rgba(255,255,255,0.1);
  --sidebar-active: rgba(69, 198, 141, 0.15);
  --sidebar-active-text: #76e4b2;
  --accent: #45c68d;
  --accent-ink: #10261c;
  --button-text: #ffffff;
  --hero-start: #173e2f;
  --hero-end: #0d2a20;
  --hero-line: #214c3b;
  --recommendation-text: #695844;
  --input-border: #cfd8d3;
  --input-hover: #aebdb5;
  --secondary-button: #e8eeeb;
  --chart-area: rgba(23, 107, 77, 0.08);
  --focus-ring: rgba(23, 107, 77, 0.25);
  --radius: 18px;
  --radius-small: 11px;
}

:root[data-theme="ocean"] {
  --bg: #f2f6fb;
  --surface: #ffffff;
  --surface-subtle: #f6f9fd;
  --text: #14243a;
  --muted: #64758a;
  --line: #d9e3ee;
  --brand: #2468d2;
  --brand-strong: #174f9e;
  --brand-soft: #e6efff;
  --blue: #00a0b2;
  --sidebar: #101f35;
  --sidebar-muted: #b8c8dc;
  --sidebar-note: #dce8f6;
  --sidebar-note-muted: #8ea4bf;
  --sidebar-active: rgba(78, 153, 255, 0.18);
  --sidebar-active-text: #8fc1ff;
  --accent: #4e99ff;
  --accent-ink: #0d2444;
  --hero-start: #173f75;
  --hero-end: #0e294d;
  --hero-line: #28568d;
  --chart-area: rgba(36, 104, 210, 0.09);
  --focus-ring: rgba(36, 104, 210, 0.24);
  --shadow: 0 12px 32px rgba(28, 53, 87, 0.08);
}

:root[data-theme="violet"] {
  --bg: #f6f3fb;
  --surface: #ffffff;
  --surface-subtle: #faf8fd;
  --text: #282039;
  --muted: #756b84;
  --line: #e4ddec;
  --brand: #6d4ed4;
  --brand-strong: #5137ac;
  --brand-soft: #eee9ff;
  --blue: #c255a8;
  --sidebar: #211a33;
  --sidebar-muted: #c6bbd7;
  --sidebar-note: #e7e0ef;
  --sidebar-note-muted: #a89ab9;
  --sidebar-active: rgba(168, 133, 255, 0.17);
  --sidebar-active-text: #c5abff;
  --accent: #a885ff;
  --accent-ink: #26164a;
  --hero-start: #513b8f;
  --hero-end: #32245c;
  --hero-line: #644ca4;
  --chart-area: rgba(109, 78, 212, 0.09);
  --focus-ring: rgba(109, 78, 212, 0.24);
  --shadow: 0 12px 32px rgba(64, 42, 96, 0.08);
}

:root[data-theme="midnight"] {
  color-scheme: dark;
  --bg: #0f1419;
  --surface: #171e25;
  --surface-subtle: #1d252e;
  --text: #edf3f6;
  --muted: #9eabb5;
  --line: #2e3944;
  --brand: #49d7a5;
  --brand-strong: #77e7bf;
  --brand-soft: #173c32;
  --warning-soft: #3b2d17;
  --danger-soft: #3c2022;
  --blue: #65a7ff;
  --sidebar: #090d11;
  --sidebar-text: #f0f6f3;
  --sidebar-muted: #a7b4ae;
  --sidebar-note: #dbe7e1;
  --sidebar-note-muted: #899992;
  --sidebar-hover: rgba(255,255,255,0.07);
  --sidebar-line: rgba(255,255,255,0.11);
  --sidebar-active: rgba(73, 215, 165, 0.14);
  --sidebar-active-text: #76e6bd;
  --accent: #49d7a5;
  --accent-ink: #081a13;
  --button-text: #071d15;
  --hero-start: #153f34;
  --hero-end: #0d2922;
  --hero-line: #245949;
  --recommendation-text: #dbc69f;
  --input-border: #3a4652;
  --input-hover: #596978;
  --secondary-button: #26313b;
  --chart-area: rgba(73, 215, 165, 0.09);
  --focus-ring: rgba(73, 215, 165, 0.26);
  --shadow: 0 15px 38px rgba(0, 0, 0, 0.24);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 238px minmax(0, 1fr); }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 18px 20px;
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
  color: var(--sidebar-text);
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0 10px 28px; font-size: 20px; font-weight: 750; letter-spacing: -0.02em; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--accent); color: var(--accent-ink); font-weight: 850; }

.main-nav { display: grid; gap: 7px; }
.nav-item { width: 100%; border: 0; border-radius: 11px; padding: 12px 13px; display: flex; align-items: center; gap: 11px; background: transparent; color: var(--sidebar-muted); text-align: left; }
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }
.nav-item.is-active { background: var(--sidebar-active); color: var(--sidebar-active-text); }
.nav-item span { width: 18px; text-align: center; font-size: 17px; }
.nav-badge { min-width: 21px; margin-left: auto; padding: 2px 6px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 10px; line-height: 1.4; text-align: center; }

.sidebar-note { margin-top: auto; display: flex; align-items: flex-start; gap: 10px; padding: 14px; border: 1px solid var(--sidebar-line); border-radius: 13px; color: var(--sidebar-note); }
.sidebar-note .status-dot { flex: 0 0 auto; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--sidebar-active); }
.sidebar-note strong, .sidebar-note small { display: block; }
.sidebar-note strong { font-size: 13px; }
.sidebar-note small { margin-top: 2px; color: var(--sidebar-note-muted); font-size: 11px; }

.main-content { min-width: 0; padding: 30px clamp(20px, 4vw, 54px) 60px; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 28px; }
.topbar h1 { margin: 1px 0 0; font-size: clamp(27px, 3vw, 36px); line-height: 1.15; letter-spacing: -0.035em; }
.eyebrow { margin: 0; color: var(--brand); font-size: 12px; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; }

.button { border: 0; border-radius: 10px; padding: 11px 17px; font-weight: 700; transition: transform 120ms ease, background 120ms ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--brand); color: var(--button-text); }
.button-primary:hover { background: var(--brand-strong); }
.button-secondary { background: var(--secondary-button); color: var(--text); }
.button-danger { background: var(--danger-soft); color: var(--danger); }
.button-danger:hover { background: var(--danger); color: #fff; }
.text-button { border: 0; padding: 4px 0; background: transparent; color: var(--brand); font-weight: 700; }
.icon-button { border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; background: var(--surface); color: var(--muted); }
.icon-button:hover { border-color: #b9c6bf; color: var(--text); }
.icon-button.danger:hover { border-color: #e2afaf; background: var(--danger-soft); color: var(--danger); }

.page[hidden] { display: none; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; }
.stat-card, .panel, .table-card, .result-hero, .recommendation-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-card { padding: 19px; }
.stat-card span, .stat-card small { display: block; color: var(--muted); }
.stat-card span { font-size: 13px; }
.stat-card strong { display: block; margin: 7px 0 3px; font-size: 27px; line-height: 1.1; letter-spacing: -0.035em; }
.stat-card small { font-size: 11px; }

.recommendation-card { margin-top: 15px; padding: 19px 21px; display: flex; align-items: flex-start; gap: 15px; border-color: #f0cf9e; background: linear-gradient(120deg, var(--warning-soft), var(--surface)); }
.recommendation-icon { flex: 0 0 auto; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: #efb35a; color: #4c2a00; font-weight: 850; }
.recommendation-card h2 { margin: 4px 0 2px; font-size: 17px; }
.recommendation-card p { margin: 0; color: var(--recommendation-text); font-size: 13px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, 0.8fr); gap: 15px; margin-top: 15px; }
.panel { padding: 21px; }
.panel-heading, .page-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.panel-heading h2, .page-toolbar h2, .result-panel h2 { margin: 0; font-size: 17px; }
.panel-heading p, .page-toolbar p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.pill { display: inline-flex; align-items: center; min-height: 27px; padding: 4px 9px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-strong); font-size: 11px; font-weight: 750; }

.forecast-chart { width: 100%; height: auto; display: block; margin-top: 14px; overflow: visible; }
.forecast-chart .grid { stroke: var(--line); stroke-width: 1; }
.forecast-chart .revenue-path { fill: none; stroke: var(--brand); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.forecast-chart .profit-path { fill: none; stroke: var(--blue); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.forecast-chart .area { fill: var(--chart-area); }
.forecast-chart text { fill: var(--muted); font-size: 11px; }
.chart-legend { display: flex; gap: 18px; color: var(--muted); font-size: 11px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend-line { width: 20px; height: 3px; border-radius: 3px; }
.legend-line.revenue { background: var(--brand); }
.legend-line.profit { background: var(--blue); }

.ranking { margin-top: 14px; display: grid; gap: 4px; }
.ranking-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.ranking-row:last-child { border-bottom: 0; }
.ranking-row strong, .ranking-row small { display: block; }
.ranking-row strong { font-size: 13px; }
.ranking-row small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.ranking-value { text-align: right; }
.ranking-value span { display: block; font-weight: 750; }

.page-toolbar { align-items: flex-end; margin-bottom: 16px; }
.select-label, .field, .compact-field { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 650; }
select, input { width: 100%; border: 1px solid var(--input-border); border-radius: 9px; background: var(--surface); color: var(--text); }
select { padding: 9px 34px 9px 11px; }
input { padding: 10px 11px; }
input:hover, select:hover { border-color: var(--input-hover); }
input:focus, select:focus { border-color: var(--brand); }

.table-card { overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 16px; border-bottom: 1px solid var(--line); text-align: right; font-size: 13px; }
th { background: var(--surface-subtle); color: var(--muted); font-size: 11px; letter-spacing: 0.02em; }
th:first-child, td:first-child { text-align: left; }
tbody tr:last-child td { border-bottom: 0; }
.product-name { display: flex; align-items: center; gap: 10px; }
.product-status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brand); }
.product-status-dot.warning { background: var(--warning); }
.product-status-dot.loss { background: var(--danger); }
.product-name strong, .product-name small { display: block; }
.product-name small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.negative { color: var(--danger); }
.actions { display: flex; justify-content: flex-end; gap: 6px; }

.empty-state { max-width: 520px; margin: 70px auto; padding: 30px; text-align: center; }
.empty-state h2 { margin: 13px 0 5px; }
.empty-state p { margin: 0 0 18px; color: var(--muted); }
.empty-icon { width: 46px; height: 46px; margin: 0 auto; display: grid; place-items: center; border-radius: 14px; background: var(--brand-soft); color: var(--brand); font-size: 22px; }

.calculator-layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(290px, 0.65fr); gap: 16px; align-items: start; }
.calculator-form { min-width: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
.field-wide { grid-column: 1 / -1; }
.input-suffix { position: relative; display: block; }
.input-suffix input { padding-right: 48px; }
.input-suffix em { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-style: normal; font-size: 12px; }
.vat-settings { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-top: 18px; padding-top: 17px; border-top: 1px solid var(--line); }
.switch-row { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 650; }
.switch-row input { width: 17px; height: 17px; accent-color: var(--brand); }
.compact-field { grid-template-columns: auto 90px; align-items: center; }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }

.calculator-result { display: grid; gap: 15px; position: sticky; top: 24px; }
.result-hero { padding: 24px; background: linear-gradient(145deg, var(--hero-start), var(--hero-end)); color: #ffffff; border-color: var(--hero-line); }
.result-hero.warning { background: linear-gradient(145deg, #744a16, #4c310f); border-color: #84561d; }
.result-hero.loss { background: linear-gradient(145deg, #692a2a, #451919); border-color: #7a3333; }
.result-status { display: inline-flex; padding: 4px 8px; border-radius: 999px; background: rgba(255,255,255,0.12); font-size: 11px; font-weight: 750; }
.result-hero p { margin: 24px 0 3px; color: rgba(255,255,255,0.72); font-size: 12px; }
.result-hero strong { display: block; font-size: 38px; line-height: 1.05; letter-spacing: -0.04em; }
.result-hero small { display: block; margin-top: 7px; color: rgba(255,255,255,0.72); }
.result-panel p { margin: 9px 0 0; color: var(--muted); font-size: 13px; }
.result-list { margin: 17px 0 0; }
.result-list div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.result-list dt { color: var(--muted); font-size: 12px; }
.result-list dd { margin: 0; font-size: 12px; font-weight: 750; text-align: right; }

.alerts-stats, .simulator-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-bottom: 22px; }
.alert-list { display: grid; gap: 12px; }
.alert-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.alert-item.critical { border-left: 4px solid var(--danger); }
.alert-item.warning { border-left: 4px solid var(--warning); }
.alert-item.info { border-left: 4px solid var(--blue); }
.alert-marker { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px; background: var(--surface-subtle); color: var(--text); font-weight: 850; }
.alert-item.critical .alert-marker { background: var(--danger-soft); color: var(--danger); }
.alert-item.warning .alert-marker { background: var(--warning-soft); color: var(--warning); }
.alert-heading { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.alert-heading strong { font-size: 13px; }
.alert-level { padding: 3px 7px; border-radius: 999px; background: var(--surface-subtle); color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: 0.05em; }
.alert-copy h2 { margin: 8px 0 3px; font-size: 16px; }
.alert-copy p { margin: 0; color: var(--muted); font-size: 12px; }
.alert-copy small { display: block; margin-top: 7px; color: var(--text); font-size: 11px; }
.alert-impact { min-width: 160px; text-align: right; }
.alert-impact span, .alert-impact strong { display: block; }
.alert-impact span { color: var(--muted); font-size: 11px; }
.alert-impact strong { margin: 4px 0 10px; color: var(--brand); font-size: 20px; }

.import-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr); gap: 15px; }
.import-dropzone { margin-top: 20px; padding: 34px 20px; display: grid; justify-items: center; gap: 5px; border: 2px dashed var(--input-border); border-radius: var(--radius-small); background: var(--surface-subtle); text-align: center; cursor: pointer; }
.import-dropzone:hover { border-color: var(--brand); background: var(--brand-soft); }
.import-dropzone strong { font-size: 16px; }
.import-dropzone small, .import-actions span, .muted { color: var(--muted); font-size: 12px; }
.import-dropzone input { max-width: 260px; margin-top: 12px; padding: 7px; background: var(--surface); }
.import-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; background: var(--brand-soft); color: var(--brand); font-size: 22px; }
.import-actions { margin-top: 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.import-help ol { margin: 18px 0; padding-left: 22px; color: var(--muted); font-size: 13px; }
.import-help li + li { margin-top: 10px; }
.import-preview { margin-top: 15px; }
.import-preview .form-actions { padding-top: 16px; border-top: 1px solid var(--line); }
.table-scroll { margin: 17px -21px 0; overflow-x: auto; }

.simulator-panel { margin-bottom: 15px; }
.simulator-panel .select-label { min-width: 240px; }
.simulator-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; margin-top: 24px; }
.range-field { display: grid; gap: 10px; color: var(--muted); font-size: 12px; font-weight: 650; }
.range-field span { display: flex; justify-content: space-between; gap: 10px; }
.range-field output { color: var(--text); font-weight: 750; }
.range-field input { padding: 0; border: 0; accent-color: var(--brand); }
.highlight-card { border-color: var(--brand); background: linear-gradient(145deg, var(--brand-soft), var(--surface)); }
.simulator-recommendation { align-items: center; }
.simulator-recommendation .button { margin-left: auto; white-space: nowrap; }

.report-header { margin-bottom: 18px; display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; }
.report-header h2 { margin: 0; font-size: 21px; }
.report-header p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.report-actions { display: flex; gap: 8px; }
.report-stats { margin-bottom: 15px; }
.report-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr); gap: 15px; }
.profit-bars { display: grid; gap: 15px; margin-top: 22px; }
.profit-bar-row > div:first-child { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; font-size: 12px; }
.profit-bar-row span { color: var(--muted); }
.profit-bar-track { height: 9px; overflow: hidden; border-radius: 999px; background: var(--surface-subtle); }
.profit-bar-track i { display: block; height: 100%; border-radius: inherit; background: var(--brand); }
.profit-bar-track i.loss { background: var(--danger); }
.report-insights { margin: 18px 0 0; padding-left: 20px; color: var(--muted); font-size: 13px; }
.report-insights li + li { margin-top: 13px; }
.report-insights strong { color: var(--text); }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.settings-panel { min-width: 0; }
.settings-fields { margin-top: 18px; }
.settings-switches { display: grid; gap: 0; margin-top: 14px; }
.settings-switch { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.settings-switch:last-child { border-bottom: 0; }
.settings-switch span, .settings-switch strong, .settings-switch small { display: block; }
.settings-switch strong { font-size: 13px; }
.settings-switch small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.settings-switch input { flex: 0 0 auto; width: 19px; height: 19px; accent-color: var(--brand); }
.settings-threshold { max-width: 240px; margin-top: 17px; padding-top: 17px; border-top: 1px solid var(--line); }
.theme-grid { margin: 18px 0 0; padding: 0; border: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; }
.theme-card { position: relative; display: grid; gap: 8px; padding: 9px; border: 1px solid var(--line); border-radius: var(--radius-small); background: var(--surface-subtle); cursor: pointer; }
.theme-card:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 2px var(--focus-ring); }
.theme-card:has(input:focus-visible) { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.theme-card input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.theme-card strong { font-size: 12px; }
.theme-preview { height: 48px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.12); }
.theme-preview.forest { background: linear-gradient(135deg, #14231d 0 42%, #176b4d 42% 65%, #f4f6f8 65%); }
.theme-preview.ocean { background: linear-gradient(135deg, #101f35 0 42%, #2468d2 42% 65%, #f2f6fb 65%); }
.theme-preview.violet { background: linear-gradient(135deg, #211a33 0 42%, #6d4ed4 42% 65%, #f6f3fb 65%); }
.theme-preview.midnight { background: linear-gradient(135deg, #090d11 0 42%, #49d7a5 42% 65%, #171e25 65%); }
.settings-data-panel { grid-column: 1 / -1; }
.data-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line); }
.data-actions:last-child { border-bottom: 0; }
.data-actions strong, .data-actions small { display: block; }
.data-actions strong { font-size: 13px; }
.data-actions small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.danger-zone strong { color: var(--danger); }
.file-button { position: relative; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.settings-save-bar { margin-top: 15px; padding: 13px 15px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border: 1px solid var(--line); border-radius: var(--radius-small); background: var(--surface); box-shadow: var(--shadow); }
.settings-save-bar span { color: var(--muted); font-size: 12px; }

.toast { position: fixed; right: 22px; bottom: 22px; max-width: min(360px, calc(100vw - 44px)); padding: 12px 15px; border-radius: 10px; background: #17201c; color: #ffffff; box-shadow: var(--shadow); font-size: 13px; z-index: 20; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid, .calculator-layout, .import-layout, .report-grid, .settings-grid { grid-template-columns: 1fr; }
  .settings-data-panel { grid-column: auto; }
  .calculator-result { grid-template-columns: 1fr 1fr; position: static; }
  .simulator-controls { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .app-shell { display: block; }
  .sidebar { position: static; height: auto; padding: 14px 16px; flex-direction: row; align-items: center; gap: 14px; }
  .brand { padding: 0; font-size: 17px; }
  .brand-mark { width: 30px; height: 30px; }
  .sidebar { flex-wrap: wrap; }
  .main-nav { width: 100%; order: 2; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-left: 0; gap: 4px; }
  .nav-item { width: auto; justify-content: center; padding: 9px 8px; font-size: 11px; }
  .nav-item span { display: none; }
  .nav-badge { margin-left: 4px; }
  .sidebar-note { display: none; }
  .main-content { padding: 22px 16px 50px; }
  .topbar { margin-bottom: 21px; }
  .topbar h1 { font-size: 27px; }
  th:nth-child(2), td:nth-child(2), th:nth-child(3), td:nth-child(3) { display: none; }
}

@media (max-width: 560px) {
  .sidebar { align-items: flex-start; flex-wrap: wrap; }
  .main-nav { width: 100%; order: 2; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav-item { flex: 1; justify-content: center; }
  .topbar { align-items: flex-end; }
  .topbar .button { padding: 10px 12px; }
  .stats-grid, .form-grid, .calculator-result { grid-template-columns: 1fr; }
  .recommendation-card { align-items: flex-start; }
  .page-toolbar { align-items: stretch; flex-direction: column; }
  .select-label { width: 100%; }
  th, td { padding: 12px 10px; }
  th:nth-child(4), td:nth-child(4) { display: none; }
  .calculator-form, .result-panel { padding: 17px; }
  .field-wide { grid-column: auto; }
  .form-actions .button { flex: 1; }
  .alerts-stats, .simulator-stats { grid-template-columns: 1fr; }
  .alert-item { grid-template-columns: auto minmax(0, 1fr); }
  .alert-impact { grid-column: 1 / -1; text-align: left; padding-left: 52px; }
  .alert-impact .button { width: 100%; }
  .simulator-recommendation { align-items: flex-start; flex-wrap: wrap; }
  .simulator-recommendation .button { width: 100%; margin-left: 49px; }
  .report-header { align-items: stretch; flex-direction: column; }
  .report-actions .button { flex: 1; }
  .theme-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .data-actions { grid-template-columns: 1fr; }
  .data-actions .button { width: 100%; }
  .settings-save-bar { align-items: stretch; flex-direction: column; }
  .settings-save-bar .button { width: 100%; }
}

@media print {
  .sidebar, .topbar, .report-actions, .toast { display: none !important; }
  .app-shell { display: block; }
  .main-content { padding: 0; }
  .stat-card, .panel { box-shadow: none; break-inside: avoid; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
