:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8faff;
  --ink: #162033;
  --muted: #66758a;
  --line: #e3e9f2;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-soft: #eef4ff;
  --green: #138a5b;
  --green-soft: #ebfaf3;
  --red: #c73a4a;
  --red-soft: #fff1f3;
  --shadow: 0 8px 28px rgba(37, 62, 108, .07);
}

* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-dark); }

header {
  position: sticky; top: 0; z-index: 40; min-height: 68px; display: flex; align-items: center; gap: 30px;
  padding: 0 32px; background: rgba(255, 255, 255, .96); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px);
}
header > b { flex: 0 0 auto; color: #12366f; font-size: 22px; font-weight: 800; letter-spacing: -.7px; }
header > b::after { content: "Управление бизнесом"; display: block; margin-top: -2px; color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .02em; }
.context-switcher { display: inline-flex; align-items: center; min-height: 34px; max-width: 280px; padding: 7px 10px; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); color: #52627a; font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.context-switcher:hover, .context-switcher:focus { color: var(--blue); border-color: #c4d6fa; outline: none; }
header nav { display: flex; flex: 1; align-items: center; min-width: 0; gap: 3px; }
header nav > a, .header-menu__toggle {
  display: inline-flex; align-items: center; min-height: 38px; padding: 8px 10px; border: 0; border-radius: 8px;
  background: transparent; color: #52627a; font: inherit; font-weight: 600; white-space: nowrap; cursor: pointer;
}
header nav > a:hover, header nav > a:focus, header nav > a.is-active, .header-menu__toggle:hover, .header-menu__toggle:focus, .header-menu.is-open .header-menu__toggle {
  color: var(--blue); background: var(--blue-soft); outline: none;
}
.nav-section { display: none; }
.header-menu { position: relative; }
.header-menu--company { margin-left: auto; }
.header-menu__toggle::after { content: "⌄"; margin-left: 6px; font-size: 13px; transform: translateY(-1px); }
.header-menu__panel { position: absolute; top: calc(100% + 8px); right: 0; display: none; min-width: 188px; padding: 7px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.header-menu.is-open .header-menu__panel { display: grid; }
.header-menu__panel a { min-height: 38px; padding: 9px 10px; border-radius: 8px; color: var(--ink); font-weight: 600; }
.header-menu__panel a:hover, .header-menu__panel a:focus { color: var(--blue); background: var(--blue-soft); outline: none; }

main { width: min(1440px, 100%); margin: 0 auto; padding: 32px 34px 52px; }
.page-heading, .toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-heading > div, .toolbar > div { min-width: 0; }
h1 { margin: 0; font-size: 30px; line-height: 1.2; letter-spacing: -.8px; }
h2 { margin: 0; font-size: 18px; line-height: 1.3; letter-spacing: -.25px; }
h3 { margin: 0 0 12px; font-size: 15px; }
.eyebrow { margin: 0 0 5px; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.muted { color: var(--muted); }
.page-heading .muted { margin: 7px 0 0; }

.card { margin: 16px 0; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.card-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.card-heading h2 { margin: 0; }
.auth { width: min(460px, calc(100% - 24px)); margin: 9vh auto; padding: 30px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }

form { display: grid; gap: 13px; }
label { display: grid; gap: 6px; color: #34435a; font-size: 13px; font-weight: 700; }
input, select, textarea {
  width: 100%; min-height: 40px; padding: 9px 11px; border: 1px solid #cfd9e7; border-radius: 9px; background: var(--surface); color: var(--ink); font: inherit;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: 3px solid #dce9ff; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 9px 14px; border: 1px solid var(--blue); border-radius: 9px;
  background: var(--blue); color: #fff; font: inherit; font-weight: 750; line-height: 1.15; cursor: pointer; text-decoration: none; transition: background .16s ease, border-color .16s ease, transform .16s ease;
}
button:hover, .button:hover { color: #fff; background: var(--blue-dark); border-color: var(--blue-dark); }
button:active, .button:active { transform: translateY(1px); }
button:disabled { cursor: not-allowed; opacity: .5; }
.secondary { border-color: #d9e3f1; background: #f3f7fc; color: #38506f; }
.secondary:hover { border-color: #bfcef0; background: var(--blue-soft); color: var(--blue); }
.danger { border-color: #efc3ca; background: var(--red-soft); color: var(--red); }
.danger:hover { border-color: var(--red); background: var(--red); color: #fff; }
.status-badge { display: inline-flex; align-items: center; min-height: 28px; padding: 5px 9px; border: 1px solid #d6deea; border-radius: 999px; background: var(--surface-soft); color: #64748b; font-size: 12px; font-weight: 750; white-space: nowrap; }
.status-badge--active { border-color: #bcead5; background: var(--green-soft); color: var(--green); }
.text-link { display: inline-flex; margin-top: 14px; font-weight: 750; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.metric { min-width: 0; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 2px 8px rgba(37, 62, 108, .03); }
.metric small { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.metric b { display: block; overflow-wrap: anywhere; font-size: 21px; line-height: 1.25; }

.toolbar > div { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.ui-search { width: min(400px, 100%); margin: 0 0 14px; }
.scroll { max-width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); -webkit-overflow-scrolling: touch; }
table { width: 100%; min-width: 680px; border-collapse: collapse; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: #f8faff; color: #66758a; font-size: 11px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafcff; }
.inline { display: inline-flex; gap: 6px; margin: 2px; vertical-align: middle; }
.inline input[type="hidden"] { display: none; }

.error, .flash, .ok { margin: 0 0 16px; padding: 11px 13px; border: 1px solid; border-radius: 10px; font-weight: 600; }
.error { border-color: #f1c1c8; background: var(--red-soft); color: #a32737; }
.flash, .ok { border-color: #bcead5; background: var(--green-soft); color: #08714b; }
.ui-hidden { display: none !important; }
.ui-launch { margin: 0 0 16px; }

.ui-modal { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 18px; background: rgba(18, 32, 51, .45); }
.ui-modal[hidden] { display: none; }
.ui-modal__content { width: min(720px, 100%); max-height: calc(100vh - 36px); overflow: auto; padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 24px 70px rgba(14, 26, 47, .25); }
.ui-modal__head { position: sticky; top: -22px; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 3px 0 14px; background: var(--surface); }
.ui-modal__head h2 { margin: 0; }
.ui-modal__close { min-height: 34px; min-width: 34px; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 25px; }
.ui-modal__close:hover { background: #f1f5f9; color: var(--ink); }

.mobile-topbar, .mobile-nav-overlay, .mobile-nav-close { display: none; }

/* Главная */
.dashboard-heading { margin-bottom: 24px; }
.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; }
.kpi-card { min-width: 0; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.kpi-card > span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.kpi-card strong { display: block; margin: 7px 0 5px; overflow-wrap: anywhere; font-size: clamp(19px, 1.8vw, 27px); line-height: 1.14; letter-spacing: -.6px; }
.kpi-card small { color: var(--muted); font-size: 12px; }
.kpi-card--highlight { border-color: #a7e2c4; background: linear-gradient(135deg, #effcf5, #ffffff); }
.kpi-card--highlight strong { color: var(--green); }
.dashboard-overview { display: grid; grid-template-columns: minmax(0, 1.85fr) minmax(260px, .85fr); gap: 16px; align-items: stretch; margin-top: 18px; }
.dashboard-overview .card { margin: 0; }
.segmented { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: #f8faff; }
.segmented button { min-height: 32px; padding: 6px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 12px; }
.segmented button:hover { color: var(--blue); background: var(--blue-soft); }
.segmented button.is-selected { background: var(--surface); box-shadow: 0 1px 4px rgba(37, 62, 108, .12); color: var(--blue); }
.dashboard-chart { position: relative; min-height: 260px; padding-top: 4px; }
.dashboard-chart svg { display: block; width: 100%; height: 260px; overflow: visible; }
.dashboard-chart__empty { display: grid; min-height: 220px; place-items: center; margin: 0; color: var(--muted); text-align: center; }
.dashboard-chart__empty[hidden] { display: none; }
.dashboard-heading__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.dashboard-refresh-result .attention-list > div { display: grid; gap: 2px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; }
.dashboard-refresh-result .attention-list span { color: var(--muted); font-size: 12px; }
.dashboard-summary dl { display: grid; gap: 0; margin: 0; }
.dashboard-summary dl > div { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.dashboard-summary dl > div:last-child { border-bottom: 0; }
.dashboard-summary dt { color: var(--muted); }
.dashboard-summary dd { margin: 0; color: var(--ink); font-weight: 800; text-align: right; }
.quick-actions { margin-top: 18px; }
.quick-actions__grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.quick-actions__grid a { display: flex; align-items: center; gap: 11px; min-width: 0; padding: 13px; border: 1px solid var(--line); border-radius: 13px; color: var(--ink); transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease; }
.quick-actions__grid a:hover { border-color: #c4d6fa; box-shadow: 0 8px 20px rgba(37, 99, 235, .1); transform: translateY(-1px); color: var(--ink); }
.quick-actions__grid b, .quick-actions__grid small { display: block; }
.quick-actions__grid b { font-size: 13px; }
.quick-actions__grid small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.quick-actions__icon { display: grid; flex: 0 0 34px; width: 34px; height: 34px; place-items: center; border-radius: 10px; background: var(--blue-soft); color: var(--blue); font-size: 19px; font-weight: 800; }
.quick-actions__grid em { margin-left: auto; color: #9aa8bb; font-size: 18px; font-style: normal; }
.dashboard-bottom-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 18px; }
.dashboard-bottom-grid .card { margin: 0; }
.operational-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.operational-stats a { padding: 13px; border-radius: 12px; background: var(--surface-soft); color: var(--ink); }
.operational-stats a:hover { background: var(--blue-soft); color: var(--blue); }
.operational-stats strong, .operational-stats span { display: block; }
.operational-stats strong { font-size: 24px; letter-spacing: -.5px; }
.operational-stats span { margin-top: 2px; color: var(--muted); font-size: 12px; }
.attention-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.attention-list li { display: grid; gap: 2px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; }
.attention-list li b { font-size: 13px; }
.attention-list li span { color: var(--muted); font-size: 12px; }
.attention-list__danger { border-color: #f0c0c8 !important; background: var(--red-soft); }
.attention-list__ok { border-color: #c2ead7 !important; background: var(--green-soft); }

/* Global redirect-safe notifications. They never take part in page layout. */
#toast-container { position: fixed; z-index: 120; top: 18px; right: 18px; display: grid; width: min(390px, calc(100vw - 36px)); gap: 10px; pointer-events: none; }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 13px 12px 13px 14px; border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 13px; background: rgba(255,255,255,.98); box-shadow: 0 16px 40px rgba(23, 46, 82, .17); color: var(--ink); pointer-events: auto; animation: toast-in .18s ease-out; }
.toast--success { border-left-color: var(--green); }
.toast--warning { border-left-color: #d58512; background: #fffaf0; }
.toast--error { border-left-color: #d64555; background: #fff5f6; }
.toast__body { display: grid; flex: 1; min-width: 0; gap: 4px; }
.toast__body > b { font-size: 13px; }
.toast__body > span, .toast__body > small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.toast__close { flex: 0 0 28px; min-width: 28px; min-height: 28px; padding: 0; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 20px; line-height: 1; }
.toast__close:hover { background: rgba(37,99,235,.08); color: var(--ink); }
.toast__details summary { margin-top: 3px; color: var(--blue); cursor: pointer; font-size: 12px; font-weight: 700; }
.toast__details ul { display: grid; gap: 4px; margin: 8px 0 0; padding: 0; list-style: none; }
.toast__details li { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 12px; }
.toast__details li b { color: var(--ink); }
.toast.is-leaving { opacity: 0; transform: translateX(10px); transition: opacity .18s ease, transform .18s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: translateX(0); } }

/* Компактная ручная синхронизация Ozon в строке заголовка. */
.operations-heading { align-items: flex-start; }
.operations-heading__sync { display: flex; flex: 0 0 auto; justify-content: flex-end; max-width: 100%; padding-top: 2px; }
.operations-sync-form { display: flex; align-items: end; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.operations-sync-period { flex: 0 1 206px; }
.operations-sync-period > span { display: none; }
.operations-sync-form > button { min-height: 40px; white-space: nowrap; }
.operations-sync-unavailable { max-width: 280px; color: var(--muted); font-size: 12px; line-height: 1.35; text-align: right; }
.period-custom-fields { display: grid; grid-template-columns: repeat(2, minmax(150px, 1fr)); gap: 12px; }
.operations-sync-note { margin: -9px 0 15px; font-size: 12px; }
.integration-status-list { display: grid; max-width: 680px; }
.integration-status-list > div { display: flex; justify-content: space-between; gap: 20px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.integration-status-list > div:last-child { border-bottom: 0; }
.integration-status-list span { color: var(--muted); text-align: right; }
.alerts-group { margin-top: 16px; }
.alerts-group:first-of-type { margin-top: 0; }
.alerts-group h3 { margin: 0 0 8px; color: #40516a; font-size: 13px; }

/* Каталоги, отчёты и расчёты */
.catalog-list-card, .report-list-card, .candidate-list-card { padding: 18px; }
.catalog-list-card .ui-search, .report-list-card .ui-search, .candidate-list-card .ui-search { margin-bottom: 16px; }
.catalog-list-card .scroll, .report-list-card .scroll, .candidate-list-card .scroll { border: 0; border-radius: 12px; }
.catalog-list-card table, .report-list-card table, .candidate-list-card table { min-width: 720px; }
.catalog-page td:first-child { color: var(--muted); font-size: 12px; }
.catalog-page td:nth-child(2) > a { color: var(--ink); font-weight: 750; }
.catalog-page td:nth-child(2) > a:hover { color: var(--blue); }
.row-actions { position: relative; display: inline-block; }
.row-actions summary { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid var(--line); border-radius: 9px; color: #5f6f84; cursor: pointer; font-size: 20px; line-height: 1; list-style: none; }
.row-actions summary::-webkit-details-marker { display: none; }
.row-actions[open] summary { border-color: #c8d8f8; background: var(--blue-soft); color: var(--blue); }
.row-actions__menu { position: absolute; z-index: 10; top: calc(100% + 6px); right: 0; display: grid; min-width: 174px; gap: 5px; padding: 7px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow); }
.row-actions__menu .button, .row-actions__menu button { width: 100%; min-height: 35px; padding: 7px 9px; font-size: 12px; }
.row-actions__menu .inline { display: block; margin: 0; }

.reports-overview { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 0 0 18px; }
.report-section { overflow: hidden; }
.report-detail-heading { align-items: flex-start; }
.report-metrics { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.report-metrics .metric { box-shadow: none; }
.report-economy .metric:nth-child(4), .report-economy .metric:nth-child(9), .report-economy .metric:nth-child(10) { border-color: #c9d9fa; background: #f7faff; }
.report-economy .metric:nth-child(4) b, .report-economy .metric:nth-child(9) b, .report-economy .metric:nth-child(10) b { font-size: 23px; }
.report-economy .report-net-profit { border-color: #b9e6cf !important; background: var(--green-soft) !important; }
.report-economy .report-net-profit b { color: var(--green); }
.report-money { background: linear-gradient(135deg, #fff, #f8fbff); }
.report-expense-total { min-width: 200px !important; padding: 12px 14px !important; border-color: #d6e2f7 !important; border-radius: 12px !important; background: var(--blue-soft) !important; }
.report-expense-total small { color: var(--muted) !important; }
.report-expense-total b { color: var(--blue) !important; font-size: 20px !important; }
.report-expenses .metric b { color: #40516a; }
.report-total-row td { background: #f4f7fc !important; }
.report-products-section .scroll { border: 0; }
.report-operations { padding: 18px 20px; }
.report-operations summary { color: var(--ink); }

.calculator-page .page-heading { margin-bottom: 16px; }
.calculator-tabs { display: inline-flex; margin: 0 0 20px; }
.calculator-tabs a { display: inline-flex; align-items: center; min-height: 32px; padding: 6px 11px; border-radius: 7px; color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
.calculator-tabs a:hover { background: var(--blue-soft); color: var(--blue); }
.calculator-tabs a.active { background: var(--surface); box-shadow: 0 1px 4px rgba(37, 62, 108, .12); color: var(--blue); }
.calculator-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(340px, .8fr); gap: 18px; align-items: start; }
.calculator-layout > .card, .calculator-results > .card { margin-top: 0; }
.calculator-form-heading { margin-bottom: 18px; }
.calculator-form-heading h2 { font-size: 20px; }
.calculator-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.calculator-fields h3 { grid-column: 1 / -1; margin: 10px 0 -2px; padding-top: 15px; border-top: 1px solid var(--line); color: #40516a; font-size: 13px; }
.calculator-fields h3:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.calculator-wide { grid-column: 1 / -1; }
.calculator-results { position: sticky; top: 86px; }
.calculator-results .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.calculator-results .metric { padding: 13px; }
.calculator-results > .card:first-child .metric:nth-child(4), .calculator-results > .card:first-child .metric:nth-child(5), .calculator-results > .card:first-child .metric:nth-child(6) { background: #f7faff; border-color: #d6e2f7; }
.calculator-results > .card:first-child .metric:nth-child(4) b { color: var(--green); }
.calculator-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.calculator-actions button:first-child { flex: 1 1 220px; }
.candidate-status { display: inline-flex; margin-top: 5px; padding: 3px 7px; border-radius: 99px; background: var(--blue-soft); color: var(--blue); font-size: 11px; font-weight: 750; }
.status-converted { background: var(--green-soft); color: var(--green); }
.status-rejected { background: #f1f5f9; color: var(--muted); }

.users-page .card, .settings-page .card { max-width: 900px; }
.settings-page .card { display: grid; gap: 16px; }
.settings-page form { max-width: 480px; }
.role-field { display: grid; gap: 5px; min-width: 0; }
.role-description { color: var(--muted); font-size: 12px; font-weight: 500; line-height: 1.35; }
.back-link { margin: 0 0 14px; font-weight: 700; }
.product-metrics { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.metric-positive { border-color: #b9e6cf; background: var(--green-soft); }
.metric-positive b { color: var(--green); }
.product-batches-card { max-width: 980px; }

@media (max-width: 1120px) {
  header { gap: 18px; padding: 0 20px; }
  header nav > a, .header-menu__toggle { padding-left: 8px; padding-right: 8px; font-size: 13px; }
  main { padding-left: 24px; padding-right: 24px; }
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .quick-actions__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media(max-width:768px) {
  #toast-container { top: 68px; right: 10px; width: calc(100vw - 20px); }
  body.mobile-menu-open { overflow: hidden; }
  header { position: fixed; inset: 0 auto 0 0; z-index: 60; display: block; width: min(84vw, 340px); min-height: 100dvh; padding: 20px 14px; transform:translateX(-105%); transition: transform .22s ease; border: 0; box-shadow: 16px 0 38px rgba(18, 32, 51, .18); }
  body.mobile-menu-open header { transform: translateX(0); }
  header > b { display: block; margin: 7px 12px 22px; color: #12366f; font-size: 22px; }
  .context-switcher { display: flex; max-width: none; min-height: 44px; margin: -12px 8px 15px; padding: 11px 12px; font-size: 14px; }
  header nav { display: flex; flex-direction: column; align-items: stretch; gap: 4px; overflow-y: auto; }
  header nav > a, .header-menu__toggle { width: 100%; min-height: 48px; padding: 13px 14px; color: #34435a; font-size: 16px; text-align: left; }
  header nav > a.is-active { color: var(--blue); background: var(--blue-soft); }
  .nav-section { display: none; }
  .header-menu, .header-menu--company { display: contents; margin-left: 0; }
  .header-menu__toggle { display: none; }
  .header-menu__panel, .header-menu.is-open .header-menu__panel { position: static; display: contents; padding: 0; border: 0; box-shadow: none; }
  .header-menu__panel a { display: flex; align-items: center; min-height: 48px; padding: 13px 14px; border-radius: 8px; color: #34435a; font-size: 16px; }
  .mobile-topbar { position: fixed; inset: 0 0 auto 0; z-index: 50; display: flex; align-items: center; min-height: 58px; gap: 12px; padding: 0 14px; background: rgba(255, 255, 255, .96); border-bottom: 1px solid var(--line); box-shadow: 0 2px 10px rgba(37, 62, 108, .04); backdrop-filter: blur(14px); }
  .mobile-topbar__menu, .mobile-nav-close { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; min-height:44px; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: #27405f; font-size: 24px; line-height: 1; }
  .mobile-topbar__brand { color: #12366f; font-size: 19px; font-weight: 800; letter-spacing: -.4px; }
  .mobile-topbar__profile { margin-left: auto; min-height: 36px; padding: 6px 10px; border: 0; border-radius: 8px; background: transparent; color: #52627a; font-size: 13px; }
  .mobile-nav-close { position: absolute; top: 10px; right: 12px; border: 0; background: transparent; color: #52627a; font-size: 28px; }
  .mobile-nav-overlay { position: fixed; inset: 0; z-index: 55; display: block; background: rgba(18, 32, 51, .45); opacity: 0; pointer-events: none; transition: opacity .22s ease; }
  body.mobile-menu-open .mobile-nav-overlay { opacity: 1; pointer-events: auto; }
  .mobile-nav-group { display: block; margin: 18px 13px 3px; color: #8291a5; font-size: 10px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
  main { width: 100%; margin: 0; padding: 82px 14px 34px; }
  h1 { font-size: 26px; }
  .page-heading, .toolbar { align-items: flex-start; flex-direction: column; }
  .page-heading > .button, .toolbar > div { width: 100%; }
  .toolbar > div { justify-content: stretch; }
  .toolbar > div > .button, .toolbar > div > button { flex: 1 1 180px; }
  .card { padding: 16px; border-radius: 16px; }
  .grid { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .metric b { font-size: 18px; }
  input, select, textarea { min-height:44px; padding: 10px 12px; font-size: 16px; }
  button, .button { min-height:44px; }
  .ui-search { width: 100%; min-height:44px; }
  .inline { display: flex; flex-wrap: wrap; margin: 4px 0; }
  .inline button, .inline .button { min-height:44px; }
  .operations-heading__sync { width: 100%; justify-content: stretch; padding-top: 0; }
  .operations-sync-form { align-items: stretch; width: 100%; }
  .operations-sync-period, .operations-sync-form > button { flex-basis: 100%; width: 100%; }
  .operations-sync-unavailable { max-width: none; text-align: left; }
  .period-custom-fields { grid-template-columns: 1fr; width: 100%; }
  .integration-status-list > div { align-items: flex-start; flex-direction: column; gap: 3px; }
  .integration-status-list span { text-align: left; }
  .scroll { border-radius: 12px; }
  .ui-modal { align-items: flex-end; padding: 10px; }
  .ui-modal__content { width: 100%; max-height: calc(100dvh - 20px); padding: 20px; border-radius: 18px; }
  .ui-modal__head { top: -20px; }
  .ui-modal__content form { grid-template-columns: 1fr; }
  .ui-modal__content form button { width: 100%; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi-card { padding: 15px; border-radius: 14px; }
  .kpi-card strong { font-size: 20px; }
  .dashboard-overview, .dashboard-bottom-grid { grid-template-columns: 1fr; gap: 14px; }
  .dashboard-chart { min-height: 230px; }
  .dashboard-chart svg { height: 230px; }
  .quick-actions__grid { grid-template-columns: 1fr; }
  .quick-actions__grid a { min-height: 64px; }
  .operational-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .operational-stats strong { font-size: 21px; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; }
  .calculator-tabs { overflow: auto; padding-bottom: 2px; }
  .calculator-tabs a { min-height:44px; white-space: nowrap; }
  .calculator-actions button { width: 100%; }
  .report-operations .scroll { margin-top: 12px; }
}

@media(max-width:480px) {
  main { padding-right: 10px; padding-left: 10px; }
  .card { padding: 15px 14px; }
  .metrics, .kpi-grid { grid-template-columns: 1fr; }
  .toolbar > div > .button, .toolbar > div > button { flex-basis: 100%; }
  .ui-modal { padding: 6px; }
  .ui-modal__content { padding: 16px; border-radius: 15px; }
  .ui-modal__head { top: -16px; }
  .operational-stats { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
  .report-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .reports-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calculator-layout { grid-template-columns: 1fr; }
  .calculator-results { position: static; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
  .calculator-results > .card { margin: 0; }
  .product-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media(max-width:768px) {
  .catalog-list-card, .report-list-card, .candidate-list-card { padding: 12px; }
  .row-actions { display: block; }
  .row-actions summary { width: 100%; min-height: 44px; height: 44px; justify-content: flex-end; padding-right: 13px; }
  .row-actions__menu { position: static; width: 100%; margin-top: 6px; box-shadow: none; }
  .row-actions__menu .button, .row-actions__menu button { min-height: 44px; font-size: 14px; }
  .reports-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-economy .metric:nth-child(4), .report-economy .metric:nth-child(9), .report-economy .metric:nth-child(10) { grid-column: auto; }
  .report-economy .metric:nth-child(4) b, .report-economy .metric:nth-child(9) b, .report-economy .metric:nth-child(10) b { font-size: 19px; }
  .report-detail-heading { align-items: flex-start; }
  .report-detail-heading > div { width: 100%; }
  .report-expense-total { width: 100%; }
  .calculator-tabs { width: 100%; overflow-x: auto; }
  .calculator-tabs a { flex: 1 0 auto; min-height: 44px; }
  .calculator-fields, .calculator-results { grid-template-columns: 1fr; }
  .calculator-results .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .calculator-actions { display: grid; grid-template-columns: 1fr; }
  .calculator-actions button:first-child { width: 100%; }
  .product-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media(max-width:480px) {
  .reports-overview, .report-metrics, .calculator-results .metrics, .product-metrics { grid-template-columns: 1fr; }
}
