:root {
  --canvas: #f4f6f9;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --ink: #172033;
  --muted: #687386;
  --line: #dfe5ec;
  --line-strong: #cdd5df;
  --navy: #0d2138;
  --navy-soft: #173451;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-soft: #edf4ff;
  --green: #17835c;
  --green-soft: #eaf7f1;
  --amber: #b96f08;
  --amber-soft: #fff6e6;
  --orange: #d65320;
  --red: #c9343b;
  --red-soft: #fff0f1;
  --purple: #7156c7;
  --shadow: 0 8px 24px rgba(20, 36, 58, .055);
  --radius: 12px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #08121f;
  --surface: #101d2c;
  --surface-muted: #162536;
  --ink: #eef4fb;
  --muted: #9cacc0;
  --line: #26394e;
  --line-strong: #40566f;
  --navy: #050e19;
  --navy-soft: #173450;
  --blue: #73a2ff;
  --blue-dark: #94b8ff;
  --blue-soft: #172d4c;
  --green: #48c99a;
  --green-soft: #12372f;
  --amber: #f0ae4f;
  --amber-soft: #3b2c14;
  --orange: #f0804f;
  --red: #ff727c;
  --red-soft: #3c1d25;
  --purple: #a88cff;
  --shadow: 0 12px 32px rgba(0, 0, 0, .24);
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(37, 99, 235, .22);
  outline-offset: 2px;
}
svg { display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }

.app-shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky;
  inset: 0 auto 0 0;
  z-index: 20;
  height: 100vh;
  padding: 22px 14px 16px;
  color: #fff;
  background: var(--navy);
  display: flex;
  flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 24px; color: #fff; text-decoration: none; }
.brand-mark { width: 42px; height: 42px; border: 1px solid rgba(78,179,255,.35); border-radius: 11px; display: grid; place-items: center; overflow: hidden; background: #020b1f; color: var(--navy); box-shadow: 0 0 22px rgba(26,161,255,.16); }
.brand-mark img { width: 100%; height: 100%; display: block; object-fit: cover; transform: scale(1.1); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; line-height: 1.05; letter-spacing: -.35px; }
.brand small { margin-top: 3px; color: #9fb1c4; font-size: 11px; letter-spacing: .02em; }
.nav { display: grid; gap: 4px; }
.nav-item {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 11px;
  color: #b7c5d4;
  background: transparent;
  text-align: left;
  font-size: 13px;
  font-weight: 650;
  transition: color .16s ease, background .16s ease, border-color .16s ease;
}
.nav-item svg { width: 19px; height: 19px; flex: 0 0 auto; }
.nav-item:hover { color: #fff; background: rgba(255,255,255,.055); }
.nav-item.active { color: #fff; border-left-color: #6da0ff; background: var(--navy-soft); }
.sidebar-footer { margin-top: auto; padding: 15px 7px 0; border-top: 1px solid rgba(255,255,255,.11); }
.source-status, .operator-card { display: flex; align-items: center; gap: 9px; }
.source-status { padding-bottom: 15px; }
.source-status strong, .source-status small, .operator-card strong, .operator-card small { display: block; }
.source-status strong, .operator-card strong { font-size: 11px; font-weight: 700; }
.source-status small, .operator-card small { margin-top: 2px; color: #91a6ba; font-size: 10px; line-height: 1.35; }
.status-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: #3bc987; box-shadow: 0 0 0 4px rgba(59,201,135,.11); }
.operator-card { padding-top: 14px; border-top: 1px solid rgba(255,255,255,.08); }
.avatar { width: 31px; height: 31px; border-radius: 8px; display: grid; place-items: center; background: #244564; color: #dbe8f4; font-size: 10px; font-weight: 800; }

.main { min-width: 0; padding: 22px 26px 40px; }
.topbar { min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 15px; }
.page-heading { min-width: 210px; }
.page-heading h1 { margin: 0; color: var(--ink); font-size: clamp(22px, 2vw, 28px); line-height: 1.1; letter-spacing: -.7px; }
.page-heading p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.topbar-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.theme-toggle { width: 40px; height: 40px; flex: 0 0 auto; padding: 0; border: 1px solid var(--line); border-radius: 9px; display: grid; place-items: center; color: var(--muted); background: var(--surface); transition: color .16s ease, border-color .16s ease, background .16s ease, transform .16s ease; }
.theme-toggle:hover { color: var(--blue); border-color: var(--line-strong); background: var(--surface-muted); transform: translateY(-1px); }
.theme-toggle:active { transform: translateY(0); }
.theme-icon { grid-area: 1 / 1; }
.theme-icon svg { width: 18px; height: 18px; }
.theme-icon-sun { display: none; }
html[data-theme="dark"] .theme-icon-moon { display: none; }
html[data-theme="dark"] .theme-icon-sun { display: block; }
.search-box { width: min(300px, 25vw); height: 40px; display: flex; align-items: center; gap: 8px; padding: 0 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.search-box svg { width: 18px; height: 18px; flex: 0 0 auto; color: #7e8999; }
.search-box input { min-width: 0; width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 12px; }
.search-box input::placeholder { color: #97a0ad; }
.button { min-height: 40px; padding: 0 14px; border: 1px solid transparent; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-size: 12px; font-weight: 750; white-space: nowrap; transition: background .15s ease, border-color .15s ease, color .15s ease; }
.button svg { width: 17px; height: 17px; }
.button.primary { color: #fff; background: var(--blue); border-color: var(--blue); }
.button.primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.button.secondary { color: #344054; background: var(--surface); border-color: var(--line); }
.button.secondary:hover { border-color: var(--line-strong); background: var(--surface-muted); }
.button.compact { min-height: 35px; padding-inline: 12px; }
.export-actions { display: flex; gap: 7px; }
.button.export { min-width: 66px; }
.button.export.csv { color: #127050; background: #f2faf6; border-color: #bfe2d3; }
.button.export.csv:hover { background: #e8f6ef; }
.button.export.pdf { color: #b52d36; background: #fff5f5; border-color: #efc6c8; }
.button.export.pdf:hover { background: #ffebec; }
.button.export[aria-busy="true"] { min-width: 104px; cursor: wait; opacity: .78; }
.button.export[aria-busy="true"]::after { content: ""; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.button.export:disabled { pointer-events: none; }

.filterbar { min-height: 64px; margin-bottom: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; display: flex; align-items: flex-end; flex-wrap: wrap; gap: 11px; background: var(--surface); box-shadow: var(--shadow); }
.period-filter { display: flex; align-items: flex-end; gap: 10px; padding-right: 12px; border-right: 1px solid var(--line); }
.period-filter label, .select-field, .multi-select-field { display: grid; gap: 4px; color: #5f6b7c; font-size: 9px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.period-filter input, .select-field select { height: 35px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: var(--surface); font-size: 11px; font-weight: 600; }
.period-filter input { width: 145px; padding: 0 9px; }
.select-field select { min-width: 165px; padding: 0 30px 0 9px; }
.multi-select-field { flex: 1 1 165px; min-width: 155px; max-width: 245px; }
.filter-label { min-height: 11px; }
.multi-select { position: relative; text-transform: none; letter-spacing: 0; }
.multi-select-trigger { width: 100%; height: 35px; padding: 0 9px 0 11px; border: 1px solid var(--line); border-radius: 7px; display: flex; align-items: center; gap: 7px; color: var(--ink); background: var(--surface); font-size: 11px; font-weight: 650; text-align: left; transition: border-color .16s ease, box-shadow .16s ease, background .16s ease; }
.multi-select-trigger:hover { border-color: #b7c4d4; background: #fbfcfe; }
.multi-select-trigger:focus-visible, .multi-select.open .multi-select-trigger { border-color: #7aa4ee; outline: 0; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.multi-select-summary { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.multi-select-count { min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; color: #fff; background: var(--blue); font-size: 9px; font-weight: 800; }
.multi-select-trigger > svg { width: 15px; height: 15px; flex: 0 0 auto; color: #718096; transition: transform .16s ease; }
.multi-select.open .multi-select-trigger > svg { transform: rotate(180deg); }
.multi-select-menu { width: max(100%, 260px); max-width: min(340px, calc(100vw - 32px)); margin-top: 6px; padding: 8px; border: 1px solid #cfd8e5; border-radius: 10px; position: absolute; z-index: 80; left: 0; top: 100%; color: var(--ink); background: var(--surface); box-shadow: 0 18px 45px rgba(15,39,68,.18); text-transform: none; letter-spacing: 0; }
#departmentFilter .multi-select-menu, #categoryFilter .multi-select-menu { right: 0; left: auto; }
.multi-select-search { height: 34px; padding: 0 9px; border: 1px solid var(--line); border-radius: 7px; display: flex; align-items: center; gap: 7px; background: var(--surface-muted); }
.multi-select-search:focus-within { border-color: #8eb0ed; box-shadow: 0 0 0 3px rgba(37,99,235,.09); }
.multi-select-search svg { width: 15px; height: 15px; flex: 0 0 auto; color: #7b8797; }
.multi-select-search input { min-width: 0; width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; font-family: inherit; font-size: 11px; font-weight: 600; line-height: 1.2; }
.multi-select-search input::placeholder { color: #929dad; }
.multi-select-options { max-height: 248px; margin: 7px -2px 5px; padding: 0 2px; overflow-y: auto; display: grid; gap: 2px; scrollbar-width: thin; }
.multi-select-option { width: 100%; min-height: 34px; padding: 6px 8px; border: 0; border-radius: 7px; display: flex; align-items: center; gap: 9px; color: #344054; background: transparent; font-size: 11px; font-weight: 600; line-height: 1.25; text-align: left; }
.multi-select-option:hover, .multi-select-option:focus-visible { outline: 0; background: #f0f5ff; }
.multi-select-option[aria-selected="true"] { color: #174ea6; background: #edf4ff; }
.multi-check { width: 17px; height: 17px; flex: 0 0 auto; border: 1.5px solid #b7c2d1; border-radius: 5px; display: grid; place-items: center; color: transparent; background: #fff; }
.multi-check svg { width: 12px; height: 12px; stroke-width: 2.5; }
.multi-select-option[aria-selected="true"] .multi-check { color: #fff; border-color: var(--blue); background: var(--blue); }
.multi-option-label { min-width: 0; overflow-wrap: anywhere; }
.multi-select-empty { padding: 18px 10px; color: var(--muted); font-size: 11px; font-weight: 600; text-align: center; }
.multi-select-clear { width: 100%; min-height: 31px; padding: 5px 8px; border: 0; border-top: 1px solid var(--line); color: var(--blue); background: transparent; font-size: 10px; font-weight: 750; text-align: left; }
.multi-select-clear:hover { text-decoration: underline; }
.period-status { min-height: 35px; padding: 0 3px; display: inline-flex; align-items: center; color: var(--green); font-size: 9px; font-weight: 750; white-space: nowrap; }
.period-status::before { content: ""; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: currentColor; }
.text-button { min-height: 35px; padding: 0 7px; border: 0; color: var(--blue); background: transparent; font-size: 11px; font-weight: 750; }
.text-button:hover { text-decoration: underline; }
.expiry-risk-actions { min-height: 35px; display: flex; align-items: stretch; gap: 6px; }
.expiry-risk-actions .button { min-height: 35px; white-space: nowrap; }
.expiry-risk-gear { width: 37px; min-width: 37px !important; padding: 0 !important; display: grid; place-items: center; color: var(--blue); background: var(--blue-soft); border-color: #bed4f7; }
.expiry-risk-gear svg { width: 17px; height: 17px; }

.loading { display: none; min-height: 40px; margin-bottom: 14px; padding: 10px 13px; border: 1px solid #cbdcf9; border-radius: 8px; align-items: center; gap: 9px; color: #315a94; background: var(--blue-soft); font-size: 12px; }
.loading.visible { display: flex; }
.spinner { width: 15px; height: 15px; border: 2px solid #b6cdf2; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-state { margin-bottom: 14px; padding: 12px 14px; border: 1px solid #efc2c5; border-radius: 8px; color: #93252b; background: var(--red-soft); font-size: 12px; }
.view { display: none; }
.view.active { display: block; }

.kpi-rail { margin-bottom: 12px; border: 1px solid var(--line); border-radius: var(--radius); display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.kpi { min-width: 0; min-height: 118px; padding: 17px 15px 14px; border-right: 1px solid var(--line); position: relative; }
.kpi:last-child { border-right: 0; }
.kpi-head { display: flex; align-items: center; justify-content: space-between; gap: 7px; color: var(--muted); font-size: 10px; font-weight: 750; }
.kpi-icon { width: 27px; height: 27px; flex: 0 0 auto; border-radius: 7px; display: grid; place-items: center; color: var(--blue); background: var(--blue-soft); }
.kpi-icon svg { width: 15px; height: 15px; }
.kpi-value { margin-top: 9px; color: var(--ink); font-size: clamp(19px, 1.55vw, 25px); line-height: 1; font-weight: 820; letter-spacing: -.55px; white-space: nowrap; }
.kpi-foot { margin-top: 7px; overflow: hidden; color: var(--muted); font-size: 9px; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.kpi.danger .kpi-value { color: var(--red); }
.kpi.warning .kpi-value { color: var(--amber); }
.kpi.success .kpi-value { color: var(--green); }
.kpi.danger .kpi-icon { color: var(--red); background: var(--red-soft); }
.kpi.warning .kpi-icon { color: var(--amber); background: var(--amber-soft); }
.kpi.success .kpi-icon { color: var(--green); background: var(--green-soft); }

.dashboard-grid { display: grid; gap: 12px; margin-bottom: 12px; }
.charts-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.operations-grid { grid-template-columns: minmax(380px, .95fr) minmax(520px, 1.35fr); }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.chart-panel { min-height: 286px; padding: 15px; }
.drilldown-trigger { position: relative; cursor: pointer; transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease; }
.drilldown-trigger:hover, .drilldown-trigger:focus-visible { z-index: 1; border-color: #a8c2ef; box-shadow: 0 10px 28px rgba(37, 99, 235, .12); }
.kpi.drilldown-trigger:hover, .kpi.drilldown-trigger:focus-visible { transform: translateY(-1px); }
.chart-panel.drilldown-trigger::after { content: "Clique para detalhar"; position: absolute; right: 14px; bottom: 10px; color: #8b96a5; font-size: 8px; font-weight: 700; opacity: 0; transition: opacity .16s ease; }
.chart-panel.drilldown-trigger:hover::after, .chart-panel.drilldown-trigger:focus-visible::after { opacity: 1; }
.panel-heading { min-height: 34px; margin-bottom: 13px; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.panel-heading h2 { margin: 0 0 3px; color: var(--ink); font-size: 14px; line-height: 1.25; letter-spacing: -.25px; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.4; }
.panel-link { padding: 2px 0; border: 0; color: var(--blue); background: transparent; font-size: 10px; font-weight: 750; white-space: nowrap; }
.panel-link:hover { text-decoration: underline; }
.metric-note, .row-count, .analysis-status { padding: 5px 7px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: var(--surface-muted); font-size: 9px; font-weight: 750; white-space: nowrap; }
.analysis-status.connected { color: var(--green); border-color: #bfe2d3; background: var(--green-soft); }
.analysis-status.fallback { color: var(--amber); border-color: #ecd2a6; background: var(--amber-soft); }
.chart { min-height: 213px; display: grid; align-items: center; }
.empty-chart { padding: 28px 10px; color: var(--muted); text-align: center; font-size: 11px; line-height: 1.5; }

.donut-layout { min-width: 0; display: grid; grid-template-columns: 114px minmax(0, 1fr); align-items: center; gap: 15px; }
.donut { width: 112px; height: 112px; border-radius: 50%; display: grid; place-items: center; }
.donut-center { width: 68px; height: 68px; border-radius: 50%; display: grid; place-content: center; text-align: center; background: var(--surface); box-shadow: 0 0 0 1px rgba(255,255,255,.6); }
.donut-center strong, .donut-center small { display: block; }
.donut-center strong { font-size: 20px; line-height: 1; }
.donut-center small { margin-top: 4px; color: var(--muted); font-size: 8px; text-transform: uppercase; letter-spacing: .05em; }
.legend { min-width: 0; display: grid; gap: 7px; }
.legend-row { display: grid; grid-template-columns: 7px minmax(0, 1fr) auto; align-items: center; gap: 6px; color: #4f5b6c; font-size: 9px; }
.legend-row span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-row span:last-child { color: var(--ink); font-weight: 750; }
.legend-dot { width: 7px; height: 7px; border-radius: 2px; }

.horizontal-chart { display: grid; gap: 12px; }
.horizontal-row { min-width: 0; display: grid; grid-template-columns: minmax(70px, .9fr) minmax(70px, 1.15fr) auto; align-items: center; gap: 7px; }
.horizontal-label { overflow: hidden; color: #566273; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.horizontal-track { height: 7px; border-radius: 2px; overflow: hidden; background: #edf0f4; }
.horizontal-fill { height: 100%; min-width: 2px; border-radius: 2px; background: var(--blue); }
.horizontal-row:nth-child(2n) .horizontal-fill { background: #5584e8; }
.horizontal-value { color: var(--ink); font-size: 9px; font-variant-numeric: tabular-nums; font-weight: 750; white-space: nowrap; }

.line-chart-wrap { min-width: 0; }
.line-chart { width: 100%; height: 160px; overflow: visible; }
.line-chart .grid-line { stroke: #e8ecf1; stroke-width: 1; }
.line-chart .risk-line { stroke: var(--red); stroke-width: 2.2; }
.line-chart .no-sales-line { stroke: var(--blue); stroke-width: 2.2; }
.line-chart .point-risk { fill: var(--red); stroke: #fff; stroke-width: 1.4; }
.line-chart .point-no-sales { fill: var(--blue); stroke: #fff; stroke-width: 1.4; }
.line-chart text { fill: #7b8594; stroke: none; font-size: 8px; }
.line-legend { display: flex; align-items: center; justify-content: center; gap: 16px; color: var(--muted); font-size: 9px; }
.line-legend span { display: flex; align-items: center; gap: 5px; }
.line-legend i { width: 13px; height: 2px; background: var(--red); }
.line-legend span:last-child i { background: var(--blue); }

.insights-panel, .priorities-panel { min-height: 318px; padding: 16px; }
.insight-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.insight-columns > div + div { padding-left: 14px; border-left: 1px solid var(--line); }
.insight-columns h3 { margin: 0 0 10px; color: #4f5b6b; font-size: 10px; text-transform: uppercase; letter-spacing: .045em; }
.insights-list { display: grid; gap: 8px; }
.insight { padding: 9px 9px 9px 10px; border-left: 3px solid var(--blue); background: var(--surface-muted); }
.insight.critical { border-left-color: var(--red); background: #fff7f7; }
.insight.warning { border-left-color: var(--amber); background: #fffbf2; }
.insight.success { border-left-color: var(--green); background: #f4fbf7; }
.insight strong { display: block; color: #2f3948; font-size: 10px; line-height: 1.35; }
.insight p { margin: 3px 0 0; color: var(--muted); font-size: 9px; line-height: 1.45; }
.insight small { display: block; margin-top: 4px; color: #7d8795; font-size: 8px; line-height: 1.35; }
.ai-insight-state { min-height: 180px; }
.ai-empty { min-height: 180px; padding: 18px 12px; border: 1px dashed var(--line-strong); border-radius: 9px; display: grid; align-content: center; justify-items: center; color: var(--muted); text-align: center; }
.ai-empty svg { width: 28px; height: 28px; margin-bottom: 10px; color: var(--blue); }
.ai-empty strong { color: var(--ink); font-size: 11px; }
.ai-empty p { max-width: 245px; margin: 5px 0 0; font-size: 9px; line-height: 1.45; }
.ai-empty button { margin-top: 10px; border: 0; color: var(--blue); background: transparent; font-size: 9px; font-weight: 750; }

.priority-table-wrap { overflow-x: auto; }
.priority-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.priority-table th { padding: 8px 7px; border-bottom: 1px solid var(--line); color: #798392; text-align: left; font-size: 8px; text-transform: uppercase; letter-spacing: .04em; }
.priority-table td { padding: 9px 7px; border-bottom: 1px solid #edf0f3; color: #4a5666; font-size: 9px; line-height: 1.35; vertical-align: middle; }
.priority-table tr:last-child td { border-bottom: 0; }
.priority-table th:nth-child(1) { width: 17%; }
.priority-table th:nth-child(2) { width: 35%; }
.priority-table th:nth-child(3) { width: 18%; }
.priority-table th:nth-child(4) { width: 16%; }
.priority-table th:nth-child(5) { width: 14%; }
.priority-table td:nth-child(2) { color: var(--ink); font-weight: 650; }
.priority-level { display: inline-flex; align-items: center; gap: 5px; font-weight: 750; }
.priority-level::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--amber); }
.priority-level.high::before { background: var(--red); }

.report-summary { margin-bottom: 12px; border: 1px solid var(--line); border-radius: var(--radius); display: grid; grid-template-columns: repeat(4, minmax(180px, 1fr)); overflow: auto hidden; background: var(--surface); box-shadow: var(--shadow); }
.summary-item { min-height: 92px; padding: 15px 18px; border-right: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.summary-item:last-child { border-right: 0; }
.summary-icon { width: 31px; height: 31px; flex: 0 0 auto; border-radius: 8px; display: grid; place-items: center; color: var(--blue); background: var(--blue-soft); }
.summary-icon svg { width: 17px; height: 17px; }
.summary-item.danger .summary-icon { color: var(--red); background: var(--red-soft); }
.summary-item.warning .summary-icon { color: var(--amber); background: var(--amber-soft); }
.summary-item.success .summary-icon { color: var(--green); background: var(--green-soft); }
.summary-label { color: var(--muted); font-size: 9px; font-weight: 700; }
.summary-value { margin-top: 3px; color: var(--ink); font-size: 18px; line-height: 1.1; font-weight: 820; letter-spacing: -.35px; }
.summary-note { margin-top: 3px; color: #87909c; font-size: 8px; }
.table-panel { overflow: hidden; }
.table-heading { min-height: 66px; margin: 0; padding: 15px 16px 12px; align-items: center; }
.table-heading-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; }
.milestone-button { color: #155f98; border-color: #a9d7f3; background: #eff9ff; }
.milestone-button:hover { color: #0d4e80; border-color: #78bfe9; background: #e2f4ff; }
.table-wrap { width: 100%; overflow-x: auto; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.report-table { width: 100%; min-width: 1040px; border-collapse: collapse; }
.report-table th { padding: 9px 10px; border-bottom: 1px solid var(--line); color: #6f7b8b; background: var(--surface-muted); text-align: left; font-size: 8px; font-weight: 800; letter-spacing: .035em; text-transform: uppercase; white-space: nowrap; }
.sort-header { width: 100%; min-height: 22px; padding: 0; border: 0; display: inline-flex; align-items: center; justify-content: flex-start; gap: 6px; color: inherit; background: transparent; font: inherit; font-weight: inherit; letter-spacing: inherit; text-align: left; text-transform: inherit; white-space: nowrap; }
.sort-header:hover, .sort-header:focus-visible, .sort-header.active { color: #174e80; }
.sort-header:focus-visible { outline: 2px solid #8bc5ef; outline-offset: 2px; border-radius: 5px; }
.sort-balloon { width: 15px; height: 20px; padding: 2px 3px; border: 1px solid #ccd7e3; border-radius: 7px; display: inline-flex; flex: 0 0 auto; flex-direction: column; align-items: center; justify-content: center; gap: 0; color: #a4b0bd; background: #fff; box-shadow: 0 1px 2px rgba(23, 50, 79, .08); }
.sort-arrow { height: 7px; display: block; font-size: 6px; font-style: normal; line-height: 7px; transition: color .15s ease, transform .15s ease; }
.sort-header:hover .sort-arrow { color: #6184a5; }
.sort-arrow.selected { color: #1769aa; transform: scale(1.2); }
.report-table td { max-width: 250px; padding: 10px; border-bottom: 1px solid #edf0f3; color: #4a5666; font-size: 9px; line-height: 1.4; vertical-align: middle; }
.report-table tbody tr:last-child td { border-bottom: 0; }
.report-table tbody tr:hover { background: #fbfcfe; }
.report-table tfoot td { padding: 11px 10px; border-top: 2px solid #b9c8da; color: #17324f; background: #eaf1f8; font-size: 9px; font-weight: 850; vertical-align: middle; }
.cell-product strong, .cell-product small, .cell-period strong, .cell-period small { display: block; }
.cell-product strong, .cell-period strong { color: var(--ink); font-size: 9px; }
.cell-product small, .cell-period small { margin-top: 3px; color: #818b99; font-size: 8px; }
.number { white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge { min-width: 54px; padding: 4px 6px; border-radius: 999px; display: inline-flex; justify-content: center; color: #506072; background: #eef2f6; font-size: 8px; font-weight: 800; white-space: nowrap; }
.badge.expired, .badge.critical, .badge.high { color: #a92b32; background: var(--red-soft); }
.badge.warning, .badge.medium { color: #93600d; background: var(--amber-soft); }
.badge.low, .badge.success { color: #116947; background: var(--green-soft); }
.shelf-life { min-width: 58px; padding: 4px 7px; border: 1px solid transparent; border-radius: 999px; display: inline-flex; justify-content: center; font-size: 8px; font-weight: 850; white-space: nowrap; }
.shelf-life.critical { border-color: #efb4b7; color: #a5272f; background: #fdebed; }
.shelf-life.high { border-color: #f0c08d; color: #a25008; background: #fff0df; }
.shelf-life.medium { border-color: #e9d486; color: #80610b; background: #fff8d9; }
.shelf-life.low { border-color: #aad9c4; color: #126b49; background: #e9f7f1; }
.inline-action { min-height: 28px; padding: 0 9px; border: 1px solid #b9cdf1; border-radius: 6px; color: var(--blue); background: #f5f8ff; font-size: 8px; font-weight: 800; }
.pagination-bar { min-height: 50px; padding: 9px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 9px; }
.pagination-controls { display: flex; align-items: center; gap: 8px; }
.pagination-controls label { display: flex; align-items: center; gap: 5px; }
.pagination-controls select { height: 28px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); font-size: 9px; }
.page-button { width: 29px; height: 29px; padding: 0; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: #fff; font-size: 18px; line-height: 1; }
.report-insight { margin-top: 12px; padding: 12px 15px; border: 1px solid #cbdcf9; border-left: 4px solid var(--blue); border-radius: 9px; color: #405473; background: var(--blue-soft); font-size: 10px; line-height: 1.5; }
.report-insight strong { color: #28466f; }

.settings-layout { display: grid; grid-template-columns: minmax(420px, 1.1fr) minmax(360px, .9fr); gap: 12px; }
.settings-panel, .ai-settings-panel { padding: 17px; }
.settings-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.settings-form label { display: grid; gap: 6px; color: #566273; font-size: 10px; font-weight: 700; }
.settings-form input { height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: #fff; font-size: 11px; }
.settings-form .button { align-self: end; }
.ai-settings-status { margin-bottom: 14px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; color: #4c5869; background: var(--surface-muted); font-size: 10px; line-height: 1.45; }
.ai-settings-status strong { display: block; margin-bottom: 3px; color: var(--ink); }
.config-list { display: grid; gap: 8px; }
.config-list div { padding: 9px 10px; border: 1px solid #e7ebf0; display: grid; grid-template-columns: 170px 1fr; gap: 10px; align-items: center; }
.config-list code { color: #284f89; font-size: 9px; font-weight: 800; }
.config-list span { color: var(--muted); font-size: 9px; }
.security-note { margin: 14px 0 0; color: var(--muted); font-size: 9px; line-height: 1.55; }

.audit-dialog { width: min(510px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 13px; color: var(--ink); background: var(--surface); box-shadow: 0 20px 65px rgba(7,21,38,.28); }
.audit-dialog::backdrop { background: rgba(6, 18, 32, .58); }
.audit-dialog form { padding: 19px; }
.dialog-head { margin-bottom: 14px; display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.dialog-head p { margin: 0 0 4px; color: var(--blue); font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .055em; }
.dialog-head h2 { margin: 0; font-size: 17px; }
.dialog-close { width: 30px; height: 30px; border: 0; border-radius: 6px; color: var(--muted); background: var(--surface-muted); font-size: 21px; }
.audit-summary { margin-bottom: 13px; border: 1px solid var(--line); border-radius: 8px; display: grid; grid-template-columns: repeat(3, 1fr); overflow: hidden; }
.audit-summary div { padding: 9px; border-right: 1px solid var(--line); color: var(--muted); font-size: 8px; }
.audit-summary div:last-child { border-right: 0; }
.audit-summary strong { display: block; margin-top: 3px; color: var(--ink); font-size: 9px; }
.audit-dialog form > label:not(.checkbox) { margin-top: 10px; display: grid; gap: 5px; color: #586475; font-size: 10px; font-weight: 700; }
.audit-dialog input:not([type="checkbox"]), .audit-dialog textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: #fff; font-size: 11px; }
.checkbox { margin-top: 12px; display: flex; align-items: center; gap: 7px; color: #586475; font-size: 10px; }
.dialog-actions { margin-top: 16px; display: flex; justify-content: flex-end; gap: 8px; }
.milestone-dialog { width: min(1240px, calc(100% - 28px)); max-height: calc(100vh - 30px); padding: 0; border: 0; border-radius: 15px; color: var(--ink); background: var(--surface); box-shadow: 0 24px 80px rgba(7,21,38,.32); }
.milestone-dialog::backdrop { background: rgba(6, 18, 32, .64); }
.milestone-dialog-shell { padding: 20px; }
.milestone-dialog-head { position: sticky; top: -20px; z-index: 3; margin: -20px -20px 14px; padding: 20px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.97); backdrop-filter: blur(8px); }
.milestone-dialog-head small { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; }
.milestone-dialog-actions { display: flex; align-items: center; gap: 7px; }
.milestone-dialog-actions .button { min-width: 64px; }
.milestone-dialog-actions .dialog-close { margin-left: 3px; }
.milestone-overview { margin-bottom: 14px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.milestone-overview div { padding: 12px 14px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-muted); }
.milestone-overview span, .milestone-overview strong { display: block; }
.milestone-overview span { color: var(--muted); font-size: 9px; font-weight: 750; }
.milestone-overview strong { margin-top: 4px; color: var(--ink); font-size: 15px; }
.milestone-report-content { display: grid; gap: 16px; }
.milestone-group { --group-strong: #dff2ff; --group-soft: #f2faff; border: 1px solid #b8d8ed; border-radius: 11px; overflow: hidden; }
.milestone-group[data-days="10"] { --group-strong: #ffe2e5; --group-soft: #fff3f4; border-color: #efb8bd; }
.milestone-group[data-days="20"] { --group-strong: #ffedc8; --group-soft: #fff8e8; border-color: #e9cb91; }
.milestone-group[data-days="30"] { --group-strong: #ddecff; --group-soft: #f0f6ff; border-color: #b6ceed; }
.milestone-group-header { padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; background: var(--group-strong); }
.milestone-group-header h3 { margin: 0; color: #17324f; font-size: 14px; }
.milestone-group-header p { margin: 3px 0 0; color: #52657a; font-size: 9px; }
.milestone-group-stats { display: flex; align-items: center; flex-wrap: wrap; gap: 7px 12px; color: #384d63; font-size: 9px; font-weight: 750; }
.calendar-alert { padding: 5px 8px; border: 1px solid #dc8a21; border-radius: 999px; color: #834b04; background: #fff6df; font-size: 8px; font-weight: 850; }
.milestone-table-wrap { overflow-x: auto; }
.milestone-table { width: 100%; min-width: 970px; border-collapse: collapse; }
.milestone-table th { padding: 9px 10px; border-bottom: 1px solid rgba(23,50,79,.12); color: #536477; background: #f7f9fb; text-align: left; font-size: 8px; font-weight: 850; text-transform: uppercase; white-space: nowrap; }
.milestone-table .sort-header { font-size: 8px; font-weight: 850; }
.milestone-table td { padding: 10px; border-bottom: 1px solid rgba(23,50,79,.08); color: #3f5267; font-size: 9px; vertical-align: middle; }
.milestone-table tbody tr:nth-child(odd) { background: var(--group-strong); }
.milestone-table tbody tr:nth-child(even) { background: var(--group-soft); }
.milestone-table tbody tr:last-child td { border-bottom: 0; }
.milestone-empty { padding: 20px; color: var(--muted); background: var(--group-soft); text-align: center; font-size: 10px; }
.expiry-risk-dialog { width: min(1450px, calc(100% - 28px)); }
.expiry-risk-dialog .milestone-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.expiry-risk-table { min-width: 1320px; }
.expiry-risk-table tbody tr { background: var(--risk-row, #fff); }
.expiry-risk-table tbody tr:nth-child(odd), .expiry-risk-table tbody tr:nth-child(even) { background: var(--risk-row, #fff); }
.risk-product strong, .risk-product small { display: block; }
.risk-product small { margin-top: 3px; color: #6e7c8e; }
.risk-turnover { min-width: 63px; font-weight: 850; }
.risk-classification { display: inline-flex; padding: 4px 7px; border: 1px solid rgba(35,55,78,.16); border-radius: 999px; color: #243c55; background: rgba(255,255,255,.58); font-size: 8px; font-weight: 850; white-space: nowrap; }
.manual-line { min-width: 92px; height: 19px; border-bottom: 1px solid #48586b; }
.risk-technical-note { margin: 0 0 14px; padding: 9px 11px; border: 1px solid #d9e0e9; border-radius: 8px; color: #5b6878; background: #f8fafc; font-size: 9px; line-height: 1.45; }
.expiry-risk-settings-dialog { width: min(680px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 14px; color: var(--ink); background: var(--surface); box-shadow: 0 24px 80px rgba(7,21,38,.32); }
.expiry-risk-settings-dialog::backdrop { background: rgba(6,18,32,.64); }
.expiry-risk-settings-dialog form { padding: 20px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.expiry-risk-settings-dialog .dialog-head, .expiry-risk-settings-dialog .settings-isolation-note, .expiry-risk-settings-dialog .risk-settings-group.exclusion, .expiry-risk-settings-dialog .risk-settings-error, .expiry-risk-settings-dialog .dialog-actions { grid-column: 1 / -1; }
.settings-isolation-note { margin: 0; padding: 10px 12px; border: 1px solid #bdd8cb; border-radius: 8px; color: #275943; background: #f1faf5; font-size: 9px; line-height: 1.45; }
.risk-settings-group { min-width: 0; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 9px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.risk-settings-group label:last-child { grid-column: 1 / -1; }
.risk-settings-group.exclusion { grid-template-columns: 1fr; }
.risk-settings-group legend { padding: 0 5px; color: #42536a; font-size: 10px; font-weight: 800; }
.risk-settings-group label { min-width: 0; display: grid; gap: 5px; color: #5d6979; font-size: 9px; font-weight: 750; }
.risk-settings-group input { width: 100%; min-width: 0; height: 35px; padding: 0 9px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: #fff; }
.risk-settings-group input[type="color"] { padding: 3px; }
.risk-settings-error { margin-top: 11px; padding: 9px 11px; border: 1px solid #efc2c5; border-radius: 8px; color: #93252b; background: var(--red-soft); font-size: 10px; }
.no-sales-risk-settings-dialog .no-sales-risk-example,
.no-sales-risk-settings-dialog #noSalesRiskSettingsError { grid-column: 1 / -1; }
.no-sales-risk-example { margin: 0; padding: 10px 12px; border: 1px solid #c9d8ee; border-radius: 8px; color: #496078; background: #f5f8fd; font-size: 9px; line-height: 1.45; }
.drilldown-popover { position: fixed; z-index: 60; max-height: min(610px, calc(100vh - 24px)); border: 1px solid #cbd8eb; border-radius: 13px; display: grid; grid-template-rows: auto auto auto minmax(80px, 1fr) auto; overflow: hidden; color: var(--ink); background: var(--surface); box-shadow: 0 22px 70px rgba(9, 31, 58, .24); }
.drilldown-popover[hidden] { display: none; }
.drilldown-head { padding: 15px 16px 9px; display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.drilldown-head span { display: block; margin-bottom: 3px; color: var(--blue); font-size: 8px; font-weight: 850; letter-spacing: .07em; text-transform: uppercase; }
.drilldown-head h2 { margin: 0; color: var(--ink); font-size: 16px; line-height: 1.25; letter-spacing: -.25px; }
.drilldown-close { width: 29px; height: 29px; flex: 0 0 auto; padding: 0; border: 0; border-radius: 7px; display: grid; place-items: center; color: var(--muted); background: var(--surface-muted); font-size: 20px; line-height: 1; }
.drilldown-description { margin: 0; padding: 0 16px 10px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.drilldown-meta { min-height: 32px; padding: 7px 16px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; align-items: center; flex-wrap: wrap; gap: 7px 12px; color: var(--muted); background: var(--surface-muted); font-size: 9px; }
.drilldown-meta strong { color: var(--ink); }
.drilldown-content { min-height: 0; overflow: auto; }
.drilldown-loading, .drilldown-empty { min-height: 120px; padding: 24px; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 10px; text-align: center; }
.drilldown-loading[hidden] { display: none; }
.drilldown-loading .spinner { flex: 0 0 auto; }
.drilldown-table-wrap { min-width: 760px; }
.drilldown-table { width: 100%; border-collapse: collapse; }
.drilldown-table th { position: sticky; top: 0; z-index: 1; padding: 8px 9px; border-bottom: 1px solid var(--line); color: #6f7b8b; background: #f5f7fa; text-align: left; font-size: 7px; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
.drilldown-table td { max-width: 180px; padding: 8px 9px; border-bottom: 1px solid #edf0f3; color: #4c5868; font-size: 8px; line-height: 1.35; vertical-align: middle; }
.drilldown-table td strong, .drilldown-table td small { display: block; }
.drilldown-table td strong { color: var(--ink); font-size: 8px; }
.drilldown-table td small { margin-top: 2px; color: #818b99; font-size: 7px; }
.drilldown-table td:nth-child(4), .drilldown-table td:nth-child(5), .drilldown-table td:nth-child(7) { white-space: nowrap; }
.drilldown-actions { padding: 10px 14px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface); }
.drilldown-actions .button { min-height: 34px; font-size: 10px; }
.toast { position: fixed; z-index: 50; right: 22px; bottom: 22px; max-width: 360px; padding: 11px 14px; border-radius: 8px; color: #fff; background: var(--navy); box-shadow: 0 12px 35px rgba(8,24,42,.24); font-size: 11px; opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity .18s ease, transform .18s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }

.login-view { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, .9fr) minmax(460px, 1.1fr); background: #f4f7fb; }
.login-brand-panel { min-height: 100vh; padding: clamp(48px, 7vw, 96px); display: flex; flex-direction: column; justify-content: center; color: #fff; background: radial-gradient(circle at 20% 15%, rgba(48,118,226,.35), transparent 32%), linear-gradient(145deg, #07182c, #0d2f52); }
.login-brand-panel img { width: 74px; height: 74px; margin-bottom: 26px; border-radius: 18px; object-fit: cover; box-shadow: 0 18px 45px rgba(0,0,0,.25); }
.login-brand-panel p { margin: 0 0 18px; color: #85afff; font-size: 13px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.login-brand-panel h1 { max-width: 580px; margin: 0; font-size: clamp(34px, 4.4vw, 62px); line-height: 1.05; letter-spacing: -.045em; }
.login-brand-panel > span { max-width: 510px; margin-top: 24px; color: #c4d5ea; font-size: 16px; line-height: 1.65; }
.login-form-panel { padding: 32px; display: grid; place-items: center; }
.auth-card { width: min(430px, 100%); padding: 38px; display: grid; gap: 20px; border: 1px solid #dce4ef; border-radius: 22px; background: #fff; box-shadow: 0 28px 70px rgba(15,39,68,.12); }
.auth-mark { display: flex; align-items: center; gap: 10px; }.auth-mark img { width: 38px; height: 38px; border-radius: 10px; }.auth-mark span { display: flex; flex-direction: column; color: var(--ink); line-height: 1; }.auth-mark strong { font-size: 17px; }.auth-mark small { margin-top: 4px; color: var(--blue); font-size: 10px; font-weight: 800; letter-spacing: .14em; }
.auth-card > div:nth-child(2) p { margin: 0 0 6px; color: var(--blue); font-size: 10px; font-weight: 850; text-transform: uppercase; letter-spacing: .08em; }.auth-card h2 { margin: 0 0 8px; font-size: 27px; letter-spacing: -.025em; }.auth-card > div:nth-child(2) span { color: var(--muted); font-size: 12px; }
.auth-card label, .registration-form > label, .auth-dialog label { display: grid; gap: 7px; color: #596579; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .035em; }
.auth-card input, .registration-form input, .registration-form select, .registration-form textarea, .auth-dialog input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid #cfd8e5; border-radius: 9px; color: var(--ink); background: #fff; font: inherit; font-size: 12px; font-weight: 600; text-transform: none; letter-spacing: 0; }
.auth-card input:focus, .registration-form input:focus, .registration-form select:focus, .registration-form textarea:focus, .auth-dialog input:focus { outline: 3px solid rgba(37,99,235,.14); border-color: #7ba4f4; }
.password-field { position: relative; display: block; }.password-field input { padding-right: 72px; }.password-toggle { position: absolute; right: 8px; top: 50%; border: 0; color: var(--blue); background: transparent; font-size: 10px; font-weight: 800; transform: translateY(-50%); cursor: pointer; }
.auth-submit, .full-button { width: 100%; justify-content: center; }.auth-link { border: 0; color: var(--blue); background: transparent; font-size: 11px; font-weight: 800; cursor: pointer; }.form-error { padding: 9px 11px; border: 1px solid #f5b9bd; border-radius: 8px; color: #a9212a; background: #fff3f4; font-size: 10px; line-height: 1.45; }
.auth-dialog { width: min(480px, calc(100vw - 32px)); }.dialog-copy { color: var(--muted); font-size: 11px; line-height: 1.6; }.auth-dialog form { display: grid; gap: 16px; }.auth-dialog #resetRequestStep, .auth-dialog #resetConfirmStep { display: grid; gap: 14px; }.auth-dialog #resetConfirmStep[hidden] { display: none; }
.nav-group { width: 100%; }.nav-parent small { margin-left: auto; color: #a8bed5; font-size: 18px; transition: transform .18s; }.nav-group.open .nav-parent small { transform: rotate(90deg); }.nav-submenu { margin: 2px 0 4px 43px; display: grid; gap: 2px; }.nav-submenu button { min-height: 31px; padding: 6px 10px; border: 0; border-left: 1px solid rgba(154,184,216,.3); color: #b8c9dd; background: transparent; text-align: left; font-size: 10px; cursor: pointer; }.nav-submenu button.active, .nav-submenu button:hover { color: #fff; border-left-color: #6da0ff; background: rgba(80,135,201,.12); }
.tenant-card { padding: 9px; display: grid; grid-template-columns: 48px 1fr; gap: 8px; align-items: center; border: 1px solid rgba(151,180,212,.14); border-radius: 9px; background: rgba(255,255,255,.04); }.tenant-card #tenantLogo { width: 48px; height: 38px; padding: 2px; border-radius: 7px; object-fit: contain; object-position: center; background: #fff; }.tenant-card > span { width: 38px; height: 38px; justify-self: center; border-radius: 7px; display: grid; place-items: center; color: #dbe8f6; background: rgba(81,139,207,.25); font-size: 9px; font-weight: 900; }.tenant-card div { min-width: 0; display: grid; gap: 2px; }.tenant-card small { color: #8299b2; font-size: 7px; text-transform: uppercase; letter-spacing: .08em; }.tenant-card strong { overflow: hidden; color: #eef5fb; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.operator-card { grid-template-columns: auto 1fr auto; }.operator-card button { border: 0; color: #9fb5cc; background: transparent; font-size: 8px; font-weight: 800; cursor: pointer; }
.registration-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; }.users-layout { display: grid; grid-template-columns: minmax(360px, .75fr) minmax(520px, 1.25fr); gap: 16px; }.registration-panel, .user-form-panel, .users-list-panel, .company-usage-panel { padding: 16px; }.registration-form { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }.registration-wide { grid-column: 1 / -1; }.registration-form textarea { resize: vertical; }.form-actions { display: flex; justify-content: flex-end; gap: 8px; }
.company-usage-panel h3 { margin: 4px 0 15px; font-size: 14px; }.company-usage-panel ul { margin: 0; padding-left: 18px; color: #596579; font-size: 10px; line-height: 1.8; }.company-usage-panel p { margin: 18px 0 0; padding: 12px; border-radius: 8px; color: #40618c; background: var(--blue-soft); font-size: 9px; line-height: 1.55; }
.logo-upload { padding: 12px; display: grid; grid-template-columns: 100px 1fr; gap: 9px 12px; align-items: center; border: 1px dashed #b8c6d8; border-radius: 9px; background: #f8fafc; }.company-logo-preview { width: 100px; height: 58px; grid-row: span 2; display: grid; place-items: center; overflow: hidden; border-radius: 7px; color: #8190a4; background: #edf2f7; font-size: 9px; text-transform: none; }.company-logo-preview img { width: 100%; height: 100%; object-fit: contain; }.logo-upload input { min-height: auto; padding: 0; border: 0; background: transparent; }.logo-upload small { color: #8792a2; font-size: 8px; font-weight: 500; text-transform: none; letter-spacing: 0; }
.permission-fieldset { margin: 0; padding: 12px; border: 1px solid #dde4ed; border-radius: 9px; }.permission-fieldset legend { padding: 0 6px; color: #596579; font-size: 9px; font-weight: 850; text-transform: uppercase; }.permission-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 7px; }.permission-grid label, .user-active { min-height: 34px; padding: 7px 9px; display: flex; align-items: center; gap: 7px; border: 1px solid #e0e6ee; border-radius: 7px; color: #4e5b6d; background: #fafbfd; font-size: 9px; text-transform: none; letter-spacing: 0; }.permission-grid input, .user-active input { width: 14px; min-height: 14px; padding: 0; }.compact-form { gap: 11px; }
.users-table-wrap { overflow-x: auto; }.users-table { width: 100%; border-collapse: collapse; }.users-table th { padding: 9px; border-bottom: 1px solid var(--line); color: #798392; text-align: left; font-size: 8px; text-transform: uppercase; }.users-table td { padding: 10px 9px; border-bottom: 1px solid #edf0f3; color: #536071; font-size: 9px; vertical-align: middle; }.users-table td strong, .users-table td small { display: block; }.users-table td strong { color: var(--ink); }.users-table td small { margin-top: 3px; color: #8792a2; }.user-actions { display: flex; justify-content: flex-end; gap: 5px; }.user-actions button { padding: 5px 7px; border: 1px solid #d7e0eb; border-radius: 6px; color: var(--blue); background: #fff; font-size: 8px; font-weight: 800; cursor: pointer; }.status-pill { display: inline-flex; padding: 4px 7px; border-radius: 999px; color: #137554; background: #e8f7f1; font-size: 8px; font-weight: 800; }.status-pill.inactive { color: #9b2630; background: #fcebed; }
.insight[data-insight-detail] { width: 100%; border-top: 0; border-right: 0; border-bottom: 0; text-align: left; cursor: pointer; }.insight[data-insight-detail]::after { content: 'Ver cálculo'; display: block; margin-top: 5px; color: var(--blue); font-size: 8px; font-weight: 800; }.insight-evidence { padding: 12px; border-radius: 8px; color: #3f5877; background: var(--blue-soft); font-size: 10px; line-height: 1.55; }

html[data-theme="dark"] .button.secondary { color: var(--ink); }
html[data-theme="dark"] .button.export.csv { color: #68d9ae; border-color: #285d4d; background: #102f28; }
html[data-theme="dark"] .button.export.csv:hover { background: #153d33; }
html[data-theme="dark"] .button.export.pdf { color: #ff949c; border-color: #6b3540; background: #351c24; }
html[data-theme="dark"] .button.export.pdf:hover { background: #46242e; }
html[data-theme="dark"] .period-filter label,
html[data-theme="dark"] .select-field,
html[data-theme="dark"] .multi-select-field,
html[data-theme="dark"] .settings-form label,
html[data-theme="dark"] .audit-dialog form > label:not(.checkbox),
html[data-theme="dark"] .checkbox,
html[data-theme="dark"] .auth-card label,
html[data-theme="dark"] .registration-form > label,
html[data-theme="dark"] .auth-dialog label { color: var(--muted); }
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .settings-form input,
html[data-theme="dark"] .audit-dialog input:not([type="checkbox"]),
html[data-theme="dark"] .audit-dialog textarea,
html[data-theme="dark"] .risk-settings-group input,
html[data-theme="dark"] .auth-card input,
html[data-theme="dark"] .registration-form input,
html[data-theme="dark"] .registration-form select,
html[data-theme="dark"] .registration-form textarea,
html[data-theme="dark"] .auth-dialog input,
html[data-theme="dark"] .pagination-controls select { color: var(--ink); border-color: var(--line); background: var(--surface-muted); }
html[data-theme="dark"] .multi-select-trigger:hover { border-color: var(--line-strong); background: var(--surface-muted); }
html[data-theme="dark"] .multi-select-menu { border-color: var(--line); box-shadow: 0 18px 45px rgba(0,0,0,.42); }
html[data-theme="dark"] .multi-select-option { color: #d7e1ec; }
html[data-theme="dark"] .multi-select-option:hover,
html[data-theme="dark"] .multi-select-option:focus-visible { background: #1a304b; }
html[data-theme="dark"] .multi-select-option[aria-selected="true"] { color: #b8d0ff; background: #1a365f; }
html[data-theme="dark"] .multi-check { border-color: #60758d; background: var(--surface); }
html[data-theme="dark"] .loading { color: #b8d0ff; border-color: #34547d; }
html[data-theme="dark"] .error-state,
html[data-theme="dark"] .risk-settings-error { color: #ffadb3; border-color: #743741; }
html[data-theme="dark"] .legend-row,
html[data-theme="dark"] .horizontal-label,
html[data-theme="dark"] .insight-columns h3,
html[data-theme="dark"] .priority-table td,
html[data-theme="dark"] .report-table td,
html[data-theme="dark"] .users-table td,
html[data-theme="dark"] .drilldown-table td,
html[data-theme="dark"] .ai-settings-status,
html[data-theme="dark"] .company-usage-panel ul,
html[data-theme="dark"] .risk-settings-group legend,
html[data-theme="dark"] .risk-settings-group label { color: var(--muted); }
html[data-theme="dark"] .horizontal-track { background: #25364a; }
html[data-theme="dark"] .insight { background: #14283c; }
html[data-theme="dark"] .insight.critical { background: #351e27; }
html[data-theme="dark"] .insight.warning { background: #392d19; }
html[data-theme="dark"] .insight.success { background: #15342c; }
html[data-theme="dark"] .insight strong { color: #f1f6fc; }
html[data-theme="dark"] .insight p { color: #c6d2df; }
html[data-theme="dark"] .insight small { color: #a5b5c7; }
html[data-theme="dark"] .insight[data-insight-detail]::after { color: #8db5ff; }
html[data-theme="dark"] .priority-table td,
html[data-theme="dark"] .report-table td,
html[data-theme="dark"] .users-table td,
html[data-theme="dark"] .drilldown-table td { border-bottom-color: var(--line); }
html[data-theme="dark"] .report-table tbody tr:hover { background: #142438; }
html[data-theme="dark"] .report-table tfoot td { color: var(--ink); border-top-color: #49617c; background: #1b3047; }
html[data-theme="dark"] .sort-balloon,
html[data-theme="dark"] .page-button,
html[data-theme="dark"] .user-actions button { color: var(--muted); border-color: var(--line); background: var(--surface-muted); }
html[data-theme="dark"] .sort-header:hover .sort-arrow { color: var(--blue); }
html[data-theme="dark"] .report-table th,
html[data-theme="dark"] .priority-table th,
html[data-theme="dark"] .users-table th { color: var(--muted); }
html[data-theme="dark"] .badge { color: #c3d0de; background: #25364a; }
html[data-theme="dark"] .inline-action { border-color: #3d5c86; background: #182e4a; }
html[data-theme="dark"] .milestone-button { color: #b8d8f5; border-color: #386383; background: #17334a; }
html[data-theme="dark"] .milestone-button:hover { color: #d7eaff; border-color: #4c83aa; background: #1c405d; }
html[data-theme="dark"] .report-insight,
html[data-theme="dark"] .company-usage-panel p,
html[data-theme="dark"] .insight-evidence { color: #bfd0e6; border-color: #34547d; }
html[data-theme="dark"] .config-list div,
html[data-theme="dark"] .permission-fieldset,
html[data-theme="dark"] .permission-grid label,
html[data-theme="dark"] .user-active { border-color: var(--line); }
html[data-theme="dark"] .permission-fieldset legend,
html[data-theme="dark"] .permission-grid label,
html[data-theme="dark"] .user-active { color: var(--muted); }
html[data-theme="dark"] .permission-grid label,
html[data-theme="dark"] .user-active { background: var(--surface-muted); }
html[data-theme="dark"] .logo-upload,
html[data-theme="dark"] .company-logo-preview { border-color: var(--line-strong); background: var(--surface-muted); }
html[data-theme="dark"] .milestone-dialog-head { background: rgba(16,29,44,.96); }
html[data-theme="dark"] .milestone-group { --group-strong: #153249; --group-soft: #11283a; border-color: #315a78; }
html[data-theme="dark"] .milestone-group[data-days="10"] { --group-strong: #46242e; --group-soft: #351c24; border-color: #713b47; }
html[data-theme="dark"] .milestone-group[data-days="20"] { --group-strong: #46361b; --group-soft: #352a18; border-color: #765d2d; }
html[data-theme="dark"] .milestone-group[data-days="30"] { --group-strong: #1b3558; --group-soft: #162b47; border-color: #385e8e; }
html[data-theme="dark"] .milestone-group-header h3,
html[data-theme="dark"] .milestone-group-header p,
html[data-theme="dark"] .milestone-group-stats,
html[data-theme="dark"] .milestone-table td { color: var(--ink); }
html[data-theme="dark"] .milestone-table th,
html[data-theme="dark"] .drilldown-table th { color: var(--muted); background: #142235; }
html[data-theme="dark"] .calendar-alert { color: #ffd18d; border-color: #9a6727; background: #402e15; }
html[data-theme="dark"] .expiry-risk-table tbody tr,
html[data-theme="dark"] .expiry-risk-table tbody tr:nth-child(odd),
html[data-theme="dark"] .expiry-risk-table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--risk-row, #ffffff) 20%, var(--surface)); }
html[data-theme="dark"] .expiry-risk-table td { color: var(--ink); }
html[data-theme="dark"] .risk-product small { color: #b1bfd0; }
html[data-theme="dark"] .risk-classification { color: var(--ink); border-color: #63768c; background: rgba(8,18,31,.6); }
html[data-theme="dark"] .risk-technical-note { color: var(--muted); border-color: var(--line); background: var(--surface-muted); }
html[data-theme="dark"] .settings-isolation-note { color: #8fe0bd; border-color: #306751; background: #123329; }
html[data-theme="dark"] .no-sales-risk-example { color: #b8c9de; border-color: #314a68; background: #13243a; }
html[data-theme="dark"] .drilldown-popover { border-color: var(--line-strong); box-shadow: 0 22px 70px rgba(0,0,0,.45); }
html[data-theme="dark"] .login-view { background: var(--canvas); }
html[data-theme="dark"] .login-form-panel { background: radial-gradient(circle at 75% 18%, rgba(46,101,180,.13), transparent 35%), var(--canvas); }
html[data-theme="dark"] .auth-card { border-color: var(--line); background: var(--surface); box-shadow: 0 28px 70px rgba(0,0,0,.35); }
html[data-theme="dark"] .form-error { color: #ffadb3; border-color: #743741; background: var(--red-soft); }

@media (max-width: 1320px) {
  .charts-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .operations-grid { grid-template-columns: 1fr; }
  .kpi-rail { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi:nth-child(3) { border-right: 0; }
  .kpi:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .kpi:nth-child(6) { border-right: 0; }
}

@media (max-width: 1040px) {
  .login-view { grid-template-columns: 1fr; }
  .login-brand-panel { min-height: 300px; padding: 44px 32px; }
  .login-brand-panel h1 { font-size: 36px; }
  .login-form-panel { padding: 28px 18px; }
  .registration-layout, .users-layout { grid-template-columns: 1fr; }
  .app-shell { grid-template-columns: 206px minmax(0, 1fr); }
  .main { padding-inline: 18px; }
  .topbar { align-items: flex-start; }
  .topbar-actions { flex-wrap: wrap; }
  .search-box { width: 250px; }
  .settings-layout { grid-template-columns: 1fr; }
  .report-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-item:nth-child(2) { border-right: 0; }
  .summary-item:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 780px) {
  .login-brand-panel { display: none; }
  .login-form-panel { min-height: 100vh; }
  .auth-card { padding: 26px 22px; }
  .registration-form { grid-template-columns: 1fr; }
  .registration-wide { grid-column: auto; }
  .permission-grid { grid-template-columns: 1fr 1fr; }
  .app-shell { display: block; }
  .sidebar { position: relative; width: 100%; height: auto; padding: 12px; }
  .brand { padding: 0 5px 12px; }
  .brand-mark { width: 34px; height: 34px; }
  .nav { display: flex; gap: 5px; overflow-x: auto; padding-bottom: 3px; }
  .nav-item { width: auto; min-width: max-content; min-height: 38px; padding: 8px 10px; border-left: 0; border-bottom: 2px solid transparent; }
  .nav-item.active { border-left-color: transparent; border-bottom-color: #6da0ff; }
  .sidebar-footer { display: none; }
  .main { padding: 17px 12px 30px; }
  .topbar { display: grid; gap: 12px; }
  .topbar-actions { width: 100%; display: grid; grid-template-columns: 1fr auto auto; justify-content: stretch; }
  .search-box { width: 100%; grid-column: 1 / -1; }
  .export-actions { grid-column: 1 / -1; }
  .button.export { flex: 1; }
  .filterbar { align-items: stretch; }
  .period-filter { width: 100%; padding: 0 0 9px; border-right: 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .period-filter input { width: 100%; }
  .select-field, .multi-select-field { flex: 1 1 145px; max-width: none; }
  .select-field select { width: 100%; min-width: 0; }
  .expiry-risk-actions { width: 100%; }
  .expiry-risk-actions .button:first-child { flex: 1; }
  .kpi-rail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(odd) { border-right: 1px solid var(--line); }
  .kpi:nth-child(even) { border-right: 0; }
  .kpi:nth-child(-n+4) { border-bottom: 1px solid var(--line); }
  .kpi:nth-child(5), .kpi:nth-child(6) { border-bottom: 0; }
  .charts-grid { grid-template-columns: 1fr; }
  .insight-columns { grid-template-columns: 1fr; }
  .insight-columns > div + div { padding: 13px 0 0; border-left: 0; border-top: 1px solid var(--line); }
  .report-summary { grid-template-columns: 1fr; }
  .summary-item { border-right: 0; border-bottom: 1px solid var(--line); }
  .summary-item:last-child { border-bottom: 0; }
  .pagination-bar { align-items: flex-start; flex-direction: column; }
  .pagination-controls { width: 100%; justify-content: space-between; }
  .settings-form { grid-template-columns: 1fr; }
  .config-list div { grid-template-columns: 1fr; gap: 3px; }
  .audit-summary { grid-template-columns: 1fr; }
  .audit-summary div { border-right: 0; border-bottom: 1px solid var(--line); }
  .audit-summary div:last-child { border-bottom: 0; }
  .table-heading { align-items: flex-start; flex-direction: column; }
  .table-heading-actions { width: 100%; justify-content: space-between; }
  .milestone-overview { grid-template-columns: 1fr; }
  .milestone-dialog-shell { padding: 14px; }
  .milestone-dialog-head { top: -14px; margin: -14px -14px 12px; padding: 14px; }
  .milestone-dialog-head { align-items: flex-start; }
  .milestone-dialog-actions { flex-wrap: wrap; justify-content: flex-end; }
  .expiry-risk-settings-dialog form { grid-template-columns: 1fr; }
  .expiry-risk-settings-dialog .dialog-head, .expiry-risk-settings-dialog .settings-isolation-note, .expiry-risk-settings-dialog .risk-settings-group, .expiry-risk-settings-dialog .dialog-actions { grid-column: auto; }
  .drilldown-popover { inset: auto 8px 8px !important; width: auto !important; max-height: min(78vh, 620px); border-radius: 14px; }
}

@media (max-width: 420px) {
  .permission-grid { grid-template-columns: 1fr; }
  .topbar-actions { grid-template-columns: 1fr auto; }
  .topbar-actions > .button { width: 100%; }
  .search-box, .export-actions { grid-column: 1 / -1; }
  .multi-select-field { flex-basis: 100%; }
  .multi-select-menu, #departmentFilter .multi-select-menu, #categoryFilter .multi-select-menu { width: 100%; max-width: none; right: auto; left: 0; }
  .export-actions { grid-column: 1 / -1; }
  .period-filter { grid-template-columns: 1fr; }
  .table-heading-actions { align-items: stretch; flex-direction: column; }
  .milestone-button { width: 100%; }
  .kpi-rail { grid-template-columns: 1fr; }
  .kpi, .kpi:nth-child(odd), .kpi:nth-child(even) { border-right: 0; border-bottom: 1px solid var(--line); }
  .kpi:last-child { border-bottom: 0; }
  .donut-layout { grid-template-columns: 100px minmax(0, 1fr); gap: 10px; }
  .donut { width: 98px; height: 98px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media print {
  html[data-theme="dark"] {
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --ink: #172033;
    --muted: #687386;
    --line: #dfe5ec;
  }
  @page { size: A4 landscape; margin: 8mm; }
  body.expiry-risk-print * { visibility: hidden !important; }
  body.expiry-risk-print #expiryRiskDialog,
  body.expiry-risk-print #expiryRiskDialog * { visibility: visible !important; }
  body.expiry-risk-print #expiryRiskDialog { position: absolute; inset: 0; width: 100%; max-height: none; margin: 0; padding: 0; border: 0; overflow: visible; box-shadow: none; }
  body.expiry-risk-print #expiryRiskDialog::backdrop,
  body.expiry-risk-print .milestone-dialog-actions,
  body.expiry-risk-print #expiryRiskLoading { display: none !important; }
  body.expiry-risk-print .milestone-dialog-shell { padding: 0; }
  body.expiry-risk-print .milestone-dialog-head { position: static; margin: 0 0 5mm; padding: 0 0 3mm; background: #fff; backdrop-filter: none; }
  body.expiry-risk-print .milestone-overview { break-inside: avoid; }
  body.expiry-risk-print .milestone-table-wrap { overflow: visible; }
  body.expiry-risk-print .expiry-risk-table { width: 100%; min-width: 0; table-layout: fixed; }
  body.expiry-risk-print .expiry-risk-table th { padding: 4px; font-size: 6px; white-space: normal; }
  body.expiry-risk-print .expiry-risk-table td { padding: 5px 4px; font-size: 6px; overflow-wrap: anywhere; }
  body.expiry-risk-print .expiry-risk-table tr { break-inside: avoid; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  body.expiry-risk-print .sort-balloon { display: none !important; }
  body.expiry-risk-print .manual-line { min-width: 0; height: 13px; }
  body.no-sales-risk-print * { visibility: hidden !important; }
  body.no-sales-risk-print #noSalesRiskDialog,
  body.no-sales-risk-print #noSalesRiskDialog * { visibility: visible !important; }
  body.no-sales-risk-print #noSalesRiskDialog { position: absolute; inset: 0; width: 100%; max-height: none; margin: 0; padding: 0; border: 0; overflow: visible; box-shadow: none; }
  body.no-sales-risk-print #noSalesRiskDialog::backdrop,
  body.no-sales-risk-print .milestone-dialog-actions,
  body.no-sales-risk-print #noSalesRiskLoading { display: none !important; }
  body.no-sales-risk-print .milestone-dialog-shell { padding: 0; }
  body.no-sales-risk-print .milestone-dialog-head { position: static; margin: 0 0 5mm; padding: 0 0 3mm; background: #fff; backdrop-filter: none; }
  body.no-sales-risk-print .milestone-overview { break-inside: avoid; }
  body.no-sales-risk-print .milestone-table-wrap { overflow: visible; }
  body.no-sales-risk-print .expiry-risk-table { width: 100%; min-width: 0; table-layout: fixed; }
  body.no-sales-risk-print .expiry-risk-table th { padding: 4px; font-size: 6px; white-space: normal; }
  body.no-sales-risk-print .expiry-risk-table td { padding: 5px 4px; font-size: 6px; overflow-wrap: anywhere; }
  body.no-sales-risk-print .expiry-risk-table tr { break-inside: avoid; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  body.no-sales-risk-print .sort-balloon { display: none !important; }
}
