/* Dashboard demo styles. Data colors: one blue series, a grey comparison
   series, and reserved status colors (ok / warn / crit) for state only. */
.demo-page { --series-1: #2d5bbf; --series-prev: #a7afba; --grid: #e6eae4; }
.demo-head { padding-block: clamp(40px, 5vw, 64px) 28px; border-bottom: 0; }
.demo-head h1 { font-size: var(--step-4); max-width: none; }
.demo-head-inner { display: flex; justify-content: space-between; align-items: end; gap: 24px; flex-wrap: wrap; }
.demo-head .lead { margin: 0; }

.dash-wrap { padding-bottom: clamp(48px, 7vw, 96px); }
.app { background: var(--paper-2); border: 1px solid var(--rule); border-radius: var(--radius-l); padding: clamp(12px, 2vw, 20px); }
.app-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 14px; }
.app-id { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.app-id strong { font-size: 1.1rem; font-stretch: 88%; }
.refresh { font-size: 13px; color: var(--ink-3); }
.app-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.filters { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 10px 12px; margin-bottom: 14px; }
.seg { display: inline-flex; background: var(--paper); border-radius: var(--radius-s); padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 4px; font-size: 14px; font-weight: 600; color: var(--ink-3); min-height: 34px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgb(23 34 56 / 12%); }
.sel { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-3); }
.sel select { border: 1px solid var(--rule-strong); border-radius: var(--radius-s); background: var(--surface); padding: 6px 30px 6px 10px; min-height: 36px; font-size: 14px; color: var(--ink); appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%); background-position: calc(100% - 15px) 15px, calc(100% - 11px) 15px; background-size: 4px 4px; background-repeat: no-repeat; }
.reset, .link-btn { border: 0; background: none; color: var(--blue); font-size: 14px; font-weight: 600; padding: 6px 4px; text-decoration: underline; text-underline-offset: 3px; }
.reset[disabled] { color: var(--ink-3); text-decoration: none; cursor: default; opacity: .6; }
.period-label { margin-left: auto; font-size: 13px; color: var(--ink-3); }
@media (max-width: 700px) { .period-label { margin-left: 0; width: 100%; } }

.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 14px 16px; min-width: 0; }
.kpi .k-label { font-size: 13.5px; color: var(--ink-3); display: block; }
.kpi .k-val { font-size: clamp(1.5rem, 1.1rem + 1vw, 1.9rem); font-weight: 700; font-stretch: 85%; line-height: 1.15; display: block; margin: 4px 0 2px; white-space: nowrap; }
.kpi .k-delta { font-size: 13px; font-weight: 600; display: inline-flex; gap: 4px; align-items: center; }
.kpi .k-delta.up { color: var(--ok); }
.kpi .k-delta.down { color: var(--crit); }
.kpi .k-delta.flat { color: var(--ink-3); }
.kpi .k-delta .vs { color: var(--ink-3); font-weight: 400; }
.kpi.alert { border-color: #efc2bb; background: linear-gradient(var(--surface), var(--surface)) padding-box; box-shadow: inset 3px 0 0 var(--crit); }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpis .kpi:last-child { grid-column: 1 / -1; } }

.grid { display: grid; gap: 14px; margin-bottom: 14px; }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-1-1 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 1000px) { .g-2-1, .g-1-1 { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 16px 18px; min-width: 0; position: relative; }
.card + .card { margin-top: 0; }
.app > .card { margin-bottom: 0; }
.card-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 10px; }
.card-head h2 { font-size: 1.05rem; font-weight: 650; font-stretch: 100%; }
.card-head p { margin: 2px 0 0; font-size: 13.5px; color: var(--ink-3); }

.legend { display: flex; gap: 18px; font-size: 13px; color: var(--ink-2); margin-bottom: 4px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 16px; height: 2px; border-radius: 2px; }
.legend .k-cur { background: var(--series-1); height: 3px; }
.legend .k-prev { background: var(--series-prev); }
.chart { width: 100%; height: 260px; position: relative; outline-offset: 4px; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart text { font-family: var(--sans); font-size: 12px; fill: var(--ink-3); font-variant-numeric: tabular-nums; }
.chart-tip { position: absolute; pointer-events: none; background: var(--ink); color: #fff; border-radius: var(--radius-s); padding: 8px 10px; font-size: 13px; line-height: 1.45; white-space: nowrap; z-index: 3; box-shadow: 0 8px 20px rgb(0 0 0 / 20%); }
.chart-tip b { font-weight: 650; }
.chart-tip .sw { display: inline-block; width: 10px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
@media (max-width: 560px) { .chart { height: 210px; } }

.regions { display: grid; gap: 14px; margin-top: 4px; }
.reg-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; font-size: 14px; }
.reg-row .nm { font-weight: 600; }
.reg-row .vl { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.reg-row .track { grid-column: 1 / -1; height: 10px; background: var(--paper); border-radius: 0 4px 4px 0; }
.reg-row .fill { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; transition: width .35s ease; }
.reg-row.dim .fill { background: #c9d4ec; }

.inv-scroll { max-height: 560px; overflow: auto; border-top: 1px solid var(--rule); }
.inv-scroll .dt thead th { box-shadow: 0 1px 0 var(--rule); }
.inv-tools { display: flex; gap: 10px 18px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.search input { border: 1px solid var(--rule-strong); border-radius: var(--radius-s); padding: 7px 12px; min-height: 38px; font-size: 14px; width: min(280px, 100%); background: #fbfcfa; }
.search { flex: 1 1 200px; }
.toggle { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; color: var(--ink-2); }
.toggle input { width: 18px; height: 18px; accent-color: var(--ink); }

.dt { width: 100%; border-collapse: collapse; font-size: 14px; }
.dt th, .dt td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.dt thead th { font-size: 12.5px; font-weight: 600; color: var(--ink-3); position: sticky; top: 0; background: var(--surface); }
.dt td.num, .dt th.num { text-align: right; font-variant-numeric: tabular-nums; }
.dt td.wrap { white-space: normal; min-width: 160px; }
.dt .sku { font-family: var(--mono); font-size: 12px; color: var(--ink-3); display: block; }
.dt tbody tr:hover { background: #f7f9f6; }
.dt tr.is-new { animation: flash 2.4s ease; }
@keyframes flash { 0%, 40% { background: var(--blue-wash); } 100% { background: transparent; } }
.dt .empty td { text-align: center; color: var(--ink-3); padding: 24px; white-space: normal; }
.dt th button { border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.dt th button:hover { color: var(--ink); text-decoration: underline; }
.dt th[aria-sort="ascending"] button::after { content: " \2191"; }
.dt th[aria-sort="descending"] button::after { content: " \2193"; }
.cover-bar { display: inline-block; vertical-align: middle; width: 54px; height: 6px; background: var(--paper); border-radius: 3px; margin-left: 8px; overflow: hidden; }
.cover-bar i { display: block; height: 100%; border-radius: 3px; }
.inline-bar { display: block; height: 6px; margin-top: 5px; background: var(--paper); border-radius: 3px; max-width: 220px; }
.inline-bar i { display: block; height: 100%; background: var(--series-1); border-radius: 0 3px 3px 0; }
.delta-up { color: var(--ok); font-weight: 600; }
.delta-down { color: var(--crit); font-weight: 600; }

.alerts { list-style: none; display: grid; gap: 10px; }
.alerts li { display: grid; grid-template-columns: 12px 1fr; gap: 10px; padding: 10px 12px; border-radius: var(--radius-s); background: var(--paper); font-size: 14px; line-height: 1.45; }
.alerts li.crit { background: var(--crit-wash); }
.alerts li.warn { background: var(--warn-wash); }
.alerts .t { font-weight: 650; display: block; }
.alerts .d { color: var(--ink-2); }
.alerts .status-dot { margin-top: 5px; }
.alerts li.ok-all { grid-template-columns: 1fr; color: var(--ink-2); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: var(--radius-m); font-size: 14.5px; max-width: min(92vw, 560px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; margin: 0; box-shadow: 0 16px 40px rgb(0 0 0 / 25%); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.panel-strong { border-color: var(--ink); box-shadow: inset 0 3px 0 var(--ink); }
.plain-steps { padding-left: 1.3em; color: var(--ink-2); margin-top: 10px; }
.plain-steps li { padding: 6px 0; border-bottom: 1px solid var(--rule); }
.plain-steps li:last-child { border-bottom: 0; }
@media (max-width: 760px) { .compare { grid-template-columns: 1fr; } }

dialog.summary { width: min(640px, 94vw); max-height: 90vh; border: 1px solid var(--rule); border-radius: var(--radius-l); padding: 24px; color: var(--ink); background: var(--surface); box-shadow: 0 40px 80px rgb(0 0 0 / 30%); }
dialog.summary::backdrop { background: rgb(23 34 56 / 45%); }
.summary-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 6px; }
.summary-head h2 { font-size: 1.3rem; font-stretch: 85%; }
.close { border: 0; background: var(--paper); width: 36px; height: 36px; border-radius: 50%; font-size: 22px; line-height: 1; }
.email { border: 1px solid var(--rule); border-radius: var(--radius-m); padding: 16px 18px; background: #fbfcfa; font-size: 14.5px; line-height: 1.6; }
.email .subj { font-weight: 650; border-bottom: 1px solid var(--rule); padding-bottom: 10px; margin-bottom: 12px; }
.email ul { padding-left: 1.2em; margin: 4px 0 12px; }
.email p { margin: 0 0 10px; }
