/* Stage 5 adapter: approved design tokens over the existing Django UI. */
:root { --bg:var(--sm-bg); --surface:var(--sm-surface); --extra:var(--sm-surface-alt); --ink:var(--sm-text-primary); --secondary:var(--sm-text-secondary); --muted:var(--sm-text-muted); --line:var(--sm-border-subtle); --gold:var(--sm-gold-text); --accent:var(--sm-wine); --wine:var(--sm-chart-1); --compare:var(--sm-chart-3); --positive:var(--sm-success); --negative:var(--sm-danger); }
html { min-width:320px; }
body { background:var(--sm-bg); color:var(--sm-text-primary); font-family:var(--sm-font); font-size:1rem; line-height:1.5; font-weight:400; font-synthesis:none; overflow-x:hidden; }
button,input,select,textarea { font-family:inherit; font-size:1rem; }
button { min-height:2.5rem; padding:.4375rem 1rem; border:1px solid var(--sm-border-control); border-radius:var(--sm-radius-control); background:var(--sm-surface); color:var(--sm-text-primary); font-size:1rem; line-height:1.5; font-weight:600; }
button:hover:not(:disabled) { background:var(--sm-surface-hover); border-color:var(--sm-wine); }
button.primary { background:var(--sm-wine); border-color:var(--sm-wine); color:var(--sm-text-inverse); }
button.primary:hover:not(:disabled) { background:var(--sm-wine-hover); border-color:var(--sm-wine-hover); }
button.primary:active:not(:disabled) { background:var(--sm-wine-pressed); }
button.compact { min-height:2.5rem; padding:.4375rem 1rem; font-size:1rem; line-height:1.5; }
button:disabled { opacity:1; background:var(--sm-surface-disabled); border-color:var(--sm-border-strong); color:var(--sm-text-disabled); cursor:not-allowed; }
button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible,a:focus-visible,summary:focus-visible { outline:2px solid var(--sm-wine); outline-offset:2px; }
input,select,textarea { min-height:2.5rem; border:1px solid var(--sm-border-control); border-radius:var(--sm-radius-control); background:var(--sm-surface); color:var(--sm-text-primary); padding:.4375rem .75rem; }
input:hover,select:hover,textarea:hover { border-color:var(--sm-wine); }
input[type=checkbox] { width:1.25rem; height:1.25rem; accent-color:var(--sm-wine); }
label { color:var(--sm-text-secondary); font-size:.875rem; line-height:1.25rem; font-weight:600; }
label.check { min-height:2.75rem; font-size:1rem; font-weight:400; }
fieldset legend { color:var(--sm-text-secondary); font-size:.875rem; line-height:1.25rem; font-weight:600; margin-bottom:.375rem; }
h1,h2,h3,h4,strong { color:var(--sm-text-primary); font-weight:600; }
h1 { font-size:2.25rem; line-height:2.75rem; font-weight:700; letter-spacing:-.02em; }
h2 { font-size:1.375rem; line-height:1.75rem; }
h3 { font-size:1.25rem; line-height:1.75rem; }
p { margin:.5rem 0 1rem; }
a { color:var(--sm-wine); }
.small,.muted,.inline-note,.data-notes { color:var(--sm-text-muted); font-size:.875rem; line-height:1.25rem; }
.eyebrow { color:var(--sm-text-muted); font-size:.875rem; line-height:1.25rem; font-weight:600; letter-spacing:.06em; margin:0 0 .5rem; }
.subheading { color:var(--sm-text-secondary); font-size:1rem; line-height:1.5rem; margin:.25rem 0 .5rem; }
.source-badge { color:var(--sm-text-muted); font-size:.875rem; line-height:1.25rem; margin:0; }
.sm-brand,.gold { color:var(--sm-gold-text); font-weight:600; }
.notice { background:var(--sm-surface-alt); border-left:3px solid var(--sm-wine); border-radius:var(--sm-radius-control); color:var(--sm-text-secondary); padding:.75rem 1rem; margin:.75rem 0; font-size:.875rem; line-height:1.25rem; }
.notice.error { background:var(--sm-danger-bg); border-color:var(--sm-danger); color:var(--sm-danger); }
.notice.warning { background:var(--sm-warning-bg); border-color:var(--sm-warning); color:var(--sm-warning); }
.notice.info { background:var(--sm-info-bg); border-color:var(--sm-info); color:var(--sm-info); }
.applied-context { display:flex; flex-wrap:wrap; align-items:center; gap:.5rem 1rem; min-height:3rem; padding:.75rem 1rem; margin:0 0 1rem; background:var(--sm-surface); border:1px solid var(--sm-border-subtle); border-radius:var(--sm-radius-control); color:var(--sm-text-secondary); font-size:.875rem; line-height:1.25rem; }
.applied-context>span+span { border-left:1px solid var(--sm-border-subtle); padding-left:1rem; }
.sm-benchmark-stage5 { display:flex; align-items:flex-start; gap:.75rem; margin:0 0 1rem; background:var(--sm-surface-alt); }
.sm-benchmark-stage5 .sm-icon { flex:none; color:var(--sm-info); }
.legend>span { display:inline-flex; align-items:center; gap:.5rem; }
.legend-key { display:inline-block; width:1.5rem; height:0; border-top:2.5px solid var(--sm-chart-1); }
.legend-key.previous { border-top:2px dashed var(--sm-chart-3); }
.legend-key.benchmark { border-top:2px dotted var(--sm-chart-5); }
.export-button { display:inline-flex; align-items:center; gap:.5rem; }
.region-preview .table-wrap table { min-width:0; }
.region-preview .table-wrap td:first-child { max-width:16rem; overflow-wrap:anywhere; }
.quality-section { padding:1.25rem; margin:1rem 0; background:var(--sm-surface-alt); border:1px solid var(--sm-border-subtle); border-radius:var(--sm-radius-card); }
.quality-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:.25rem 1.5rem; }
.quality-grid p { margin:.25rem 0; color:var(--sm-text-secondary); font-size:.875rem; line-height:1.25rem; overflow-wrap:anywhere; }
.chart-data { margin-top:.75rem; }
.chart-data summary { color:var(--sm-wine); cursor:pointer; font-size:.875rem; font-weight:600; }
.table-pagination { display:flex; align-items:center; justify-content:flex-end; flex-wrap:wrap; gap:.5rem; margin-top:.75rem; color:var(--sm-text-secondary); font-size:.875rem; line-height:1.25rem; }
.table-pagination label { display:flex; align-items:center; gap:.5rem; margin-right:auto; }
.table-pagination select { width:auto; min-height:2.5rem; }
.app-shell { min-height:100dvh; padding:0; }
.rail.sm-sidebar { position:fixed; inset:0 auto 0 0; width:14rem; padding:1.5rem .75rem 1rem; display:flex; align-items:stretch; background:var(--sm-surface-alt); border-right:1px solid var(--sm-border-subtle); overflow-y:auto; }
.sidebar-brand { display:flex; justify-content:space-between; align-items:center; gap:.25rem; padding:0 .25rem 0 .75rem; min-height:2.5rem; margin-bottom:1.5rem; }
.sidebar-brand .sm-logo-link { margin:0; min-width:0; }
.sidebar-brand .sm-logo { flex:none; }
.icon-control { display:inline-flex; align-items:center; justify-content:center; width:2.5rem; min-width:2.5rem; min-height:2.5rem; padding:.5rem; background:transparent; color:var(--sm-wine); border-color:transparent; }
.icon-control:hover { background:var(--sm-surface-hover); }
.rail nav.sm-nav { display:grid; align-content:start; gap:.25rem; width:100%; margin:0; }
.nav-group-label { color:var(--sm-text-muted); font-size:.875rem; line-height:1.25rem; font-weight:600; letter-spacing:.06em; margin:.25rem .75rem .5rem; }
.nav-owner { border-top:1px solid var(--sm-border-subtle); padding-top:1rem; margin-top:1rem; display:grid; gap:.25rem; }
.rail .nav-item.sm-nav-link { position:relative; width:100%; min-height:2.75rem; display:flex; flex-direction:row; justify-content:flex-start; align-items:center; gap:.75rem; border:0; border-radius:var(--sm-radius-control); padding:.625rem 1rem; background:transparent; color:var(--sm-text-secondary); text-align:left; font-size:1rem; line-height:1.375rem; font-weight:400; white-space:normal; }
.rail .sm-nav-label { min-width:0; overflow-wrap:normal; }
.rail .nav-item.sm-nav-link .sm-icon { color:var(--sm-wine); width:1.5rem; height:1.5rem; flex:0 0 auto; }
.rail .nav-item.sm-nav-link:not(.active):hover { background:var(--sm-surface-hover); color:var(--sm-text-primary); }
.rail .nav-item.sm-nav-link.active { background:var(--sm-surface-selected); color:var(--sm-wine); font-weight:600; }
.rail .nav-item.sm-nav-link.active::after { display:none; }
.rail .nav-item.sm-nav-link.active::before { content:""; position:absolute; left:0; top:.625rem; bottom:.625rem; width:3px; border-radius:2px; background:var(--sm-wine); }
.logout-form { margin-top:auto; width:100%; border-top:1px solid var(--sm-border-subtle); padding-top:1rem; }
.collapse-control { align-self:flex-end; margin-top:.5rem; }
.workarea.sm-workspace { max-width:none; min-width:0; margin-left:14rem; padding:0; }
.topbar.sm-topbar { position:sticky; top:0; z-index:20; min-height:4rem; padding:.75rem 1.5rem; display:flex; align-items:center; justify-content:space-between; background:var(--sm-bg); border-bottom:1px solid var(--sm-border-subtle); color:var(--sm-text-secondary); font-size:.875rem; line-height:1.25rem; }
.topbar-left,.identity { display:flex; align-items:center; gap:.75rem; min-width:0; }
.topbar-context { overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
.divider { margin:0 .25rem; color:var(--sm-border-control); }
.identity #identity { max-width:min(28vw,20rem); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.avatar { display:grid; place-items:center; width:2.25rem; height:2.25rem; min-width:2.25rem; border-radius:50%; background:var(--sm-text-primary); color:var(--sm-text-inverse); font-size:.875rem; line-height:1.25rem; font-weight:700; }
.mobile-menu,.mobile-logo { display:none; }
.nav-scrim { display:none; }
.tab-panel,.tab-panel:not(#tab-metrics) { max-width:100rem; margin:0 auto; padding:1.5rem; min-width:0; }
#global-message { max-width:100rem; margin:1rem auto 0; }
.brand-heading { display:flex; flex-direction:column; align-items:stretch; gap:1rem; margin:0 0 1rem; }
.brand-title { color:var(--sm-text-primary); font-size:2.25rem; line-height:2.75rem; font-weight:700; letter-spacing:-.02em; overflow-wrap:normal; }
.brand-heading .subheading { margin:.25rem 0 .5rem; }
.filters,.wordstat-filters { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); width:100%; align-items:end; gap:.75rem 1rem; padding:1.25rem; background:var(--sm-surface); border:1px solid var(--sm-border-subtle); border-radius:var(--sm-radius-card); box-shadow:var(--sm-shadow-card); }
.filters label { color:var(--sm-text-secondary); font-size:.875rem; line-height:1.25rem; font-weight:600; min-width:0; }
.filters input,.filters select { width:100%; min-height:2.5rem; border:1px solid var(--sm-border-control); border-radius:var(--sm-radius-control); padding:.4375rem .75rem; font-size:1rem; line-height:1.5rem; background:var(--sm-surface); }
.filters select[multiple] { min-height:8rem; border:1px solid var(--sm-border-control); border-radius:var(--sm-radius-control); }
.filters input[type=date],.filters input[type=month] { min-width:0; }
.filters .date-pair { display:flex; gap:.5rem; min-width:0; }
.filters .date-pair input { width:calc(50% - .75rem); min-width:0; }
.filters .date-pair span { align-self:center; color:var(--sm-text-muted); }
.filters button[type=submit] { justify-self:start; align-self:end; }
.filters .wide { grid-column:1/-1; }
.filter-toolbar { min-height:3rem; display:flex; align-items:center; gap:.75rem; padding:.375rem .75rem; background:var(--sm-surface); border:1px solid var(--sm-border-subtle); border-radius:var(--sm-radius-control); }
.filter-summary { min-width:0; display:flex; align-items:center; flex-wrap:wrap; gap:.25rem .625rem; flex:1; color:var(--sm-text-secondary); font-size:.875rem; line-height:1.25rem; }
.filter-summary span { display:inline-block; padding-right:.625rem; border-right:1px solid var(--sm-border-subtle); }
.filter-summary span:last-child { padding-right:0; border:0; }
.filter-summary .sm-brand { color:var(--sm-gold-text); }
.filter-toggle { flex:none; min-height:2.5rem; color:var(--sm-wine); }
.filter-dirty { color:var(--sm-warning); font-size:.875rem; white-space:nowrap; }
.filter-edit-header { display:none; }
.filter-error { grid-column:1/-1; margin:0; }
.filter-edit-actions { display:flex; gap:.75rem; grid-column:1/-1; }
.filter-edit-actions button { min-height:2.5rem; }
body.filter-modal-open { overflow:hidden; }
.filters #brand-select,.filters #wordstat-brand-select,.filters #sales-brand-select,.filters #matrix-brand-select { color:var(--sm-gold-text); font-weight:600; }
.section-label { display:flex; align-items:flex-start; justify-content:space-between; gap:1rem; margin:1.5rem 0 .75rem; flex-wrap:wrap; }
.section-label p { margin:.25rem 0 0; }
.summary-surface { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:1rem; margin:0 0 1rem; padding:0; background:none; border:0; border-radius:0; }
.kpi { min-width:0; min-height:7.75rem; padding:1.25rem; background:var(--sm-surface); border:1px solid var(--sm-border-subtle); border-radius:var(--sm-radius-card); box-shadow:var(--sm-shadow-card); }
.kpi:last-child { border:1px solid var(--sm-border-subtle); }
.wordstat-summary .kpi:first-child { border-top:2px solid var(--sm-wine); }
.kpi-name { color:var(--sm-text-primary); font-size:1rem; line-height:1.375rem; font-weight:600; margin:0; }
.kpi-value { margin-top:.5rem; color:var(--sm-text-primary); font-size:2rem; line-height:2.5rem; font-weight:700; letter-spacing:-.01em; white-space:nowrap; font-variant-numeric:lining-nums tabular-nums; overflow:hidden; text-overflow:ellipsis; }
.kpi-change { margin-top:.25rem; color:var(--sm-text-secondary); font-size:.875rem; line-height:1.25rem; font-weight:400; white-space:normal; overflow-wrap:anywhere; }
.analytics-grid { display:grid; grid-template-columns:minmax(0,7fr) minmax(0,5fr); gap:1rem; margin-top:1rem; }
.chart-surface,.goals-surface,.editor { min-width:0; padding:1.25rem; border:1px solid var(--sm-border-subtle); border-radius:var(--sm-radius-card); background:var(--sm-surface); box-shadow:var(--sm-shadow-card); }
.chart-surface { min-height:22rem; }
.chart-surface.rank-surface { min-height:0; }
.rank-surface .table-wrap { margin-top:.5rem; }
.chart-header { align-items:center; flex-wrap:wrap; }
.chart-header select { max-width:17rem; font-size:1rem; padding:.4375rem .75rem; }
.chart-period { color:var(--sm-text-muted); font-size:.875rem; margin:.25rem 0 .75rem; }
.chart-wrap { min-height:13.75rem; }
.chart-wrap text { font:14px var(--sm-font); fill:var(--sm-text-muted); }
.chart-wrap .guide { stroke:var(--sm-border-control); opacity:1; }
.legend { display:flex; flex-wrap:wrap; gap:.5rem 1rem; color:var(--sm-text-secondary); font-size:.875rem; line-height:1.25rem; margin:.75rem 0; }
.legend label { display:inline-flex; align-items:center; gap:.5rem; color:var(--sm-text-secondary); font-size:.875rem; line-height:1.25rem; font-weight:400; }
.legend label span { width:1.5rem; border-color:var(--sm-chart-1); }
.legend .comparison-line { border-color:var(--sm-chart-3); border-top-style:dashed; }
.legend .trend-line { border-color:var(--sm-chart-5); border-top-style:dashed; }
.insight { display:flex; flex-direction:column; justify-content:flex-start; gap:1rem; min-width:0; padding:1.25rem; background:var(--sm-surface); color:var(--sm-text-primary); border:1px solid var(--sm-border-subtle); border-radius:var(--sm-radius-card); box-shadow:var(--sm-shadow-card); }
.insight::before { display:none; }
.insight h2 { color:var(--sm-text-primary); font-size:1.25rem; line-height:1.75rem; margin:.25rem 0; }
.insight .eyebrow,.insight small { color:var(--sm-text-muted); }
.insight p { color:var(--sm-text-secondary); font-size:.875rem; line-height:1.25rem; }
.insight .fact { border-top:1px solid var(--sm-border-subtle); padding-top:.75rem; font-size:.875rem; line-height:1.25rem; }
.insight>div:last-child { margin-top:0; }
.tooltip { background:var(--sm-text-primary); color:var(--sm-text-inverse); font-size:.875rem; line-height:1.25rem; box-shadow:var(--sm-shadow-popover); }
.data-notes { margin:.75rem 0; }
.goals-surface { margin:1rem 0; }
.goals-surface h2 { margin-bottom:.5rem; }
.table-wrap { width:100%; max-width:100%; min-width:0; overflow-x:auto; overscroll-behavior-inline:contain; margin-top:.75rem; border:1px solid var(--sm-border-subtle); border-radius:var(--sm-radius-control); }
.query-table { min-width:52rem; table-layout:fixed; }
.query-table th:first-child,.query-table td:first-child { width:37%; overflow-wrap:anywhere; }
.query-table th:nth-child(2),.query-table td:nth-child(2) { width:18%; }
.query-table th:nth-child(3),.query-table td:nth-child(3) { width:20%; }
.query-table th:nth-child(4),.query-table td:nth-child(4) { width:25%; }
.query-drill { display:inline; min-height:0; padding:0; border:0; border-radius:0; background:transparent; color:var(--sm-wine); font-weight:600; text-align:left; text-decoration:underline; text-underline-offset:3px; white-space:normal; overflow-wrap:anywhere; }
.query-drill:hover:not(:disabled) { background:transparent; color:var(--sm-wine-hover); }
.partial-value-label { display:block; color:var(--sm-text-muted); font-size:.75rem; font-weight:400; white-space:normal; }
.region-table { min-width:50rem; }
.region-table th:first-child,.region-table td:first-child { min-width:16rem; }
.table-scroll-hint { display:none; }
.selected-coverage { margin:.25rem 0 .75rem; color:var(--sm-text-secondary); font-size:.875rem; line-height:1.25rem; }
.diagnostics { margin-top:.75rem; }
.diagnostics summary { color:var(--sm-wine); font-weight:600; cursor:pointer; }
.diagnostics code { font-size:.8125rem; overflow-wrap:anywhere; }
table { min-width:36rem; width:100%; background:var(--sm-surface); color:var(--sm-text-primary); font-size:1rem; line-height:1.5rem; font-variant-numeric:lining-nums tabular-nums; }
th { background:var(--sm-surface-alt); color:var(--sm-text-secondary); font-size:.875rem; line-height:1.25rem; font-weight:600; }
th,td { padding:.75rem 1rem; border-bottom:1px solid var(--sm-border-subtle); vertical-align:middle; }
tbody tr:hover { background:var(--sm-surface-hover); }
.goal-class,.goal-note,.goal-status { font-size:.875rem; line-height:1.25rem; }
.goal-status { border-radius:var(--sm-radius-badge); padding:.25rem .5rem; font-weight:600; }
.goal-status.exact { color:var(--sm-success); background:var(--sm-success-bg); border-color:transparent; }
.goal-status.legacy,.goal-status.unconfigured { color:var(--sm-warning); background:var(--sm-warning-bg); border-color:transparent; }
.goal-status.diagnostic { color:var(--sm-info); background:var(--sm-info-bg); border-color:transparent; }
.legacy-goals { background:var(--sm-surface-alt); }
.editor { margin:1rem 0; }
.editor summary { color:var(--sm-wine); font-size:1.25rem; line-height:1.75rem; font-weight:600; }
.editor summary .muted { font-size:.875rem; }
.form-grid { gap:1rem; }
.account-email { color:var(--sm-text-muted); font-size:.875rem; }
.brand-checks { gap:.5rem 1rem; }
.empty,.data-state { border:1px solid var(--sm-border-subtle); border-radius:var(--sm-radius-card); background:var(--sm-surface); padding:2rem 1rem; color:var(--sm-text-secondary); font-size:1rem; }
.data-state h2 { margin-bottom:.5rem; }
.auth-shell { max-width:32rem; margin:0 auto; padding:4rem 1rem; min-height:100dvh; display:flex; flex-direction:column; justify-content:center; }
.auth-logo { display:block; width:11rem; height:2.5rem; margin:0 0 1.5rem; }
.auth-logo img { display:block; width:100%; height:100%; }
.auth-panel { padding:2rem; border:1px solid var(--sm-border-subtle); border-radius:var(--sm-radius-card); background:var(--sm-surface); box-shadow:var(--sm-shadow-card); }
.auth-panel h1 { font-size:2.25rem; line-height:2.75rem; font-weight:700; }
.auth-panel p { color:var(--sm-text-secondary); }
.auth-panel form { gap:1rem; }
.auth-panel .text-button { color:var(--sm-wine); background:transparent; border:0; }
.auth-foot { color:var(--sm-text-muted); font-size:.875rem; text-align:left; }
footer { color:var(--sm-text-muted); font-size:.875rem; line-height:1.25rem; padding:1.5rem; margin-top:1.5rem; }
@media (min-width:1600px) { .wordstat-summary { grid-template-columns:repeat(6,minmax(0,1fr)); } }
@media (max-width:1279px) { .rail.sm-sidebar { width:5rem; padding:1.5rem .75rem; } .workarea.sm-workspace { margin-left:5rem; } .sidebar-brand { padding:0; justify-content:center; } .sidebar-brand .sm-logo--lockup,.rail .sm-nav-label,.nav-group-label,.collapse-control { display:none; } .sidebar-brand .sm-logo--mark { display:block; } .rail .nav-item.sm-nav-link { justify-content:center; padding:.625rem .5rem; } .brand-title { font-size:2rem; line-height:2.5rem; } .summary-surface { grid-template-columns:repeat(2,minmax(0,1fr)); } .filters { grid-template-columns:repeat(2,minmax(0,1fr)); } .analytics-grid { grid-template-columns:1fr; } }
@media (min-width:1280px) { .sm-app[data-nav-collapsed="true"] .rail.sm-sidebar { width:5rem; } .sm-app[data-nav-collapsed="true"] .workarea.sm-workspace { margin-left:5rem; } .sm-app[data-nav-collapsed="true"] .sidebar-brand { padding:0; justify-content:center; } .sm-app[data-nav-collapsed="true"] .sidebar-brand .sm-logo--lockup,.sm-app[data-nav-collapsed="true"] .rail .sm-nav-label,.sm-app[data-nav-collapsed="true"] .nav-group-label { display:none; } .sm-app[data-nav-collapsed="true"] .sidebar-brand .sm-logo--mark { display:block; } .sm-app[data-nav-collapsed="true"] .rail .nav-item.sm-nav-link { justify-content:center; padding:.625rem .5rem; } }
@media (max-width:1023px) { .rail.sm-sidebar { display:flex; width:min(18rem,calc(100vw - 2rem)); height:100dvh; bottom:0; flex-direction:column; justify-content:flex-start; transform:translateX(-105%); transition:transform .2s cubic-bezier(.2,0,0,1); z-index:70; box-shadow:var(--sm-shadow-modal); } .sm-app[data-nav-open="true"] .rail.sm-sidebar { transform:none; } .workarea.sm-workspace { margin-left:0; } .topbar.sm-topbar { padding:.75rem 1.25rem; } .tab-panel,.tab-panel:not(#tab-metrics) { padding:1.25rem; } .sidebar-brand .sm-logo--lockup,.rail .sm-nav-label,.nav-group-label { display:block; } .sidebar-brand .sm-logo--mark { display:none; } .rail .nav-item.sm-nav-link { justify-content:flex-start; padding:.625rem 1rem; } .mobile-menu { display:inline-flex; } .mobile-logo { display:block; width:2rem; height:2rem; } .nav-scrim:not([hidden]) { position:fixed; inset:0; z-index:60; display:block; width:100%; height:100%; padding:0; border:0; border-radius:0; background:var(--sm-scrim); } }
@media (max-width:767px) { .tab-panel,.tab-panel:not(#tab-metrics) { padding:1rem; } .topbar.sm-topbar { padding:.625rem 1rem; } .identity #identity { display:none; } .brand-title { font-size:1.75rem; line-height:2.25rem; } .filters,.wordstat-filters { grid-template-columns:1fr; padding:1rem; } .summary-surface,.wordstat-summary { grid-template-columns:1fr; } .kpi { padding:1rem; } .kpi-value { font-size:2rem; } .chart-surface,.goals-surface,.editor,.insight { padding:1rem; } .chart-header select { width:100%; max-width:none; } .chart-wrap { min-height:20rem; } .date-pair { flex-wrap:wrap; } .filters .date-pair input { flex:1 1 100%; width:100%; } .filters .date-pair span { display:none; } .auth-shell { padding:1.5rem 1rem; } .auth-panel { padding:1.25rem; } .auth-panel h1 { font-size:1.75rem; line-height:2.25rem; } .form-grid,.quality-grid { grid-template-columns:1fr; } .section-label button { width:100%; } .applied-context>span+span { border-left:0; padding-left:0; } footer { display:block; } }
@media (max-width:390px) { .topbar.sm-topbar { padding:.625rem 16px; } .topbar-context { display:none; } .topbar-left,.identity { gap:8px; } .mobile-menu { width:44px; min-width:44px; min-height:44px; } .mobile-logo { width:32px; height:32px; } .avatar { width:36px; height:36px; min-width:36px; } .chart-wrap text { font-size:12px; } }
@media (max-width:767px) {
  .wordstat-heading.filters-collapsed { gap:.5rem; margin-bottom:.75rem; }
  .filter-toolbar { align-items:flex-start; flex-direction:column; padding:.75rem; }
  .filter-summary { width:100%; }
  .filter-summary span { border:0; padding-right:0; }
  .filter-toggle { width:100%; }
  #wordstat-filters:not([hidden]),#sales-filters:not([hidden]),#matrix-filters:not([hidden]),#filters:not([hidden]) { position:fixed; inset:0; z-index:100; width:100vw; height:100dvh; max-height:100dvh; margin:0; padding:0 1rem 1rem; display:flex; flex-direction:column; align-items:stretch; gap:.75rem; overflow-y:auto; border:0; border-radius:0; background:var(--sm-bg); }
  #wordstat-filters .filter-edit-header,#sales-filters .filter-edit-header,#matrix-filters .filter-edit-header,#filters .filter-edit-header { position:sticky; top:0; z-index:2; min-height:4rem; display:flex; align-items:center; justify-content:space-between; gap:.75rem; padding:.5rem 0; background:var(--sm-bg); }
  #wordstat-filters .filter-edit-header strong,#sales-filters .filter-edit-header strong,#matrix-filters .filter-edit-header strong,#filters .filter-edit-header strong { font-size:1.25rem; line-height:1.75rem; }
  #wordstat-filters label,#wordstat-filters fieldset,#sales-filters label,#sales-filters fieldset,#matrix-filters label,#matrix-filters fieldset,#filters label,#filters fieldset { width:100%; flex:none; }
  #wordstat-filters .filter-edit-actions,#sales-filters .filter-edit-actions,#matrix-filters .filter-edit-actions,#filters .filter-edit-actions { position:sticky; bottom:-1rem; z-index:2; display:grid; grid-template-columns:1fr 1fr; width:calc(100% + 2rem); margin:auto -1rem -1rem; padding:1rem; background:var(--sm-bg); border-top:1px solid var(--sm-border-subtle); box-shadow:0 -6px 16px #26222910; }
  #wordstat-filters .filter-edit-actions button,#sales-filters .filter-edit-actions button,#matrix-filters .filter-edit-actions button,#filters .filter-edit-actions button { width:100%; min-height:2.75rem; }
  .table-scroll-hint { display:block; margin:.5rem 0 0; color:var(--sm-text-muted); font-size:.875rem; }
  .summary-surface,.analytics-grid,.quality-grid { min-width:0; grid-template-columns:minmax(0,1fr); }
  .kpi-value { white-space:normal; overflow-wrap:anywhere; }
  .kpi-name,.section-label,.sm-benchmark-stage5 span,.applied-context span,.quality-grid p { min-width:0; overflow-wrap:anywhere; }
  .chart-header,.chart-header>div,.chart-surface h2,.goals-surface h2 { min-width:0; overflow-wrap:anywhere; }
  .table-pagination { justify-content:flex-start; }
  .table-pagination label { width:100%; flex-wrap:wrap; margin-right:0; overflow-wrap:anywhere; }
  footer span { display:block; margin-top:.25rem; }
}
@media (pointer:coarse) { button,input,select,textarea { min-height:2.75rem; } .icon-control { width:2.75rem; min-width:2.75rem; } }
@media (prefers-reduced-motion:reduce) { .rail.sm-sidebar { transition:none; } }

/* Standalone demand × sales matrix, using the approved portal palette. */
.matrix-summary { grid-template-columns:repeat(4,minmax(0,1fr)); }
.matrix-grid { grid-template-columns:minmax(0,8fr) minmax(16rem,4fr); }
.matrix-plot { min-height:0; overflow-x:auto; }
.matrix-plot svg { display:block; width:100%; min-width:36rem; height:auto; }
.matrix-plot text { font:14px var(--sm-font); fill:var(--sm-text-muted); }
.matrix-guide { stroke:var(--sm-border-subtle); stroke-width:1; }
.matrix-axis { stroke:var(--sm-text-secondary); stroke-width:1.5; }
.matrix-plot circle[role=button] { cursor:pointer; }
.matrix-plot circle[role=button]:hover,.matrix-plot circle[role=button]:focus-visible { stroke:var(--sm-text-primary); stroke-width:3; outline:none; }
.matrix-plot circle[role=button].selected { stroke:var(--sm-text-primary); stroke-width:3; }
.matrix-short-label { font-size:11px!important; font-weight:700!important; fill:var(--sm-text-primary)!important; paint-order:stroke; stroke:var(--sm-surface); stroke-width:3px; pointer-events:none; }
.matrix-legend { display:flex; flex-wrap:wrap; gap:.5rem 1rem; margin:.75rem 0; font-size:.875rem; color:var(--sm-text-secondary); }
.matrix-legend span { display:inline-flex; gap:.375rem; align-items:center; }
.matrix-dot { display:inline-block; width:.75rem; height:.75rem; border-radius:50%; }
.matrix-dot.rk { background:#6B1F2D; }.matrix-dot.non-rk { background:#856018; }.matrix-dot.unknown { background:#6E645F; }
.matrix-warning { margin:.25rem 0 .75rem; font-size:.875rem; line-height:1.25rem; color:var(--sm-text-secondary); }
.matrix-detail { min-height:0; }
.matrix-quadrant-summary { margin-top:1rem; padding-top:1rem; border-top:1px solid var(--sm-border-subtle); }
.matrix-quadrant-summary h3 { margin:0 0 .75rem; font-size:1.125rem; }
.matrix-quadrant-summary button { width:100%; }
.matrix-detail-list { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:.375rem .75rem; font-size:.875rem; }
.matrix-detail-list dt { color:var(--sm-text-secondary); }.matrix-detail-list dd { text-align:right; font-weight:600; }
.matrix-search-label { min-width:11rem; }
.matrix-search-label input,.matrix-search-label select { display:block; width:100%; margin-top:.25rem; }
.matrix-table { min-width:68rem; }.matrix-table th:first-child,.matrix-table td:first-child { min-width:12rem; }
@media (max-width:1200px) { .matrix-summary { grid-template-columns:repeat(2,minmax(0,1fr)); }.matrix-grid { grid-template-columns:minmax(0,1fr); } }
@media (max-width:767px) { .matrix-summary { grid-template-columns:minmax(0,1fr); }.matrix-search-label { width:100%; }.matrix-plot svg { min-width:34rem; } }
