/* Dark is the default; [data-theme="light"] on <html> switches palettes (set by theme.js). */
:root, [data-theme="dark"]{
  color-scheme: dark;
  --ink:#0F1419; --surface:#161C25; --surface2:#1C2330; --border:#262E3A; --border-hover:#3A4456;
  --text:#ECEAE3; --text-dim:#9AA4B2; --gold:#C9A227; --gold-hover:#DBB13C; --gold-soft:#3A331A; --on-gold:#1A1503;
  --teal:#4FD1C5; --green:#34D399; --red:#E8735F; --blue:#7AA2F7;
  --nav-bg:rgba(15,20,25,.94); --shadow:0 6px 24px rgba(0,0,0,.45);
  --err-bg:#2A1714; --err-text:#F2A193; --err-border:#5A2A22;
  --ok-bg:#11261E; --ok-text:#7FE0B5; --ok-border:#1E4A39;
  /* categorical series, dark steps (validated vs #161C25: CVD ΔE 8.4, contrast >= 3:1) */
  --series-1:#3987e5; --series-2:#d95926; --series-3:#199e70; --series-4:#c98500; --series-5:#d55181; --series-6:#9085e9;
  --series-other:#6B7280;
  --status-critical:#E66767; --status-serious:#ec835a; --neutral-bar:#4A5466; --diverge-low:#3987e5;
}
[data-theme="light"]{
  color-scheme: light;
  --ink:#F5F4EF; --surface:#FFFFFF; --surface2:#F0EEE7; --border:#E1DED5; --border-hover:#C9C5B9;
  --text:#1B1F24; --text-dim:#5B6470; --gold:#B8901A; --gold-hover:#A07C12; --gold-soft:#F6EDCF; --on-gold:#FFFFFF;
  --teal:#1A9A8E; --green:#13865C; --red:#C5432D; --blue:#3B62C8;
  --nav-bg:rgba(255,255,255,.92); --shadow:0 6px 24px rgba(20,24,30,.12);
  --err-bg:#FDECE8; --err-text:#A3321F; --err-border:#F2C3B8;
  --ok-bg:#E7F6EF; --ok-text:#0F6B49; --ok-border:#B9E3CF;
  /* categorical series, light steps (validated vs #FFFFFF; 3 slots < 3:1 so every chart carries text labels) */
  --series-1:#2a78d6; --series-2:#eb6834; --series-3:#1baf7a; --series-4:#eda100; --series-5:#e87ba4; --series-6:#4a3aa7;
  --series-other:#9CA3AF;
  --status-critical:#d03b3b; --status-serious:#ec835a; --neutral-bar:#C9C5B9; --diverge-low:#2a78d6;
}
*{box-sizing:border-box; margin:0; padding:0;}
html{scroll-behavior:smooth;}
body{transition:background .2s ease, color .2s ease; background:var(--ink); color:var(--text); font-family:'Inter',system-ui,sans-serif; line-height:1.5; -webkit-font-smoothing:antialiased;}
h1,h2,h3,.logo{font-family:'Sora','Inter',sans-serif;}
a{color:inherit; text-decoration:none;}
button{font:inherit;}
.wrap{max-width:1180px; margin:0 auto; padding:0 28px;}
@media(max-width:640px){.wrap{padding:0 16px;}}
.hidden{display:none !important;}

/* nav */
.nav-wrap{position:sticky; top:0; z-index:50; background:var(--nav-bg); backdrop-filter:blur(10px); border-bottom:1px solid var(--border);}
nav{display:flex; align-items:center; justify-content:space-between; gap:16px; padding:14px 0;}
.logo{font-size:19px; font-weight:700; display:flex; align-items:center; gap:8px; cursor:pointer;}
.logo-mark{width:18px; height:18px; border-radius:5px; background:var(--gold);}
.nav-right{display:flex; align-items:center; gap:12px; font-size:13.5px; color:var(--text-dim);}
.who-link{font-size:13px; color:var(--text-dim); text-decoration:none; border-bottom:1px dotted var(--border-hover); padding:2px 0;}
.who-link:hover, .who-link:focus-visible{color:var(--text); border-bottom-color:var(--gold);}
.wrap.narrow{max-width:560px;}
@media(max-width:640px){.nav-right .who{display:none;} .nav-right .who-link{display:inline; font-size:0; border:none;} .nav-right .who-link::after{content:"Account"; font-size:13px;} .nav-right{gap:8px;} #exportBtn{display:none;} nav{flex-wrap:wrap; row-gap:10px;} .nav-right{flex-wrap:wrap; justify-content:flex-end; margin-left:auto;}}

.btn{display:inline-flex; align-items:center; gap:8px; font-size:13.5px; font-weight:600; padding:9px 16px; border-radius:8px; cursor:pointer; border:1px solid transparent; background:none; color:var(--text);}
.btn-primary{background:var(--gold); color:var(--on-gold);}
.btn-primary:hover{background:var(--gold-hover);}
.btn-ghost{border-color:var(--border);}
.btn-ghost:hover{background:var(--surface2);}
.btn-danger{border-color:var(--err-border); color:var(--red);}
.btn-danger:hover{background:var(--err-bg);}
.btn:disabled{opacity:.5; cursor:not-allowed;}

/* layout */
main{padding:32px 0 64px;}
.page-head{display:flex; justify-content:space-between; align-items:flex-end; gap:16px; flex-wrap:wrap; margin-bottom:22px;}
.eyebrow{font-size:12.5px; color:var(--gold); font-weight:600; letter-spacing:.04em; margin-bottom:6px;}
.page-head h1{font-size:28px; font-weight:700;}
.meta{font-size:13px; color:var(--text-dim);}
.card{background:var(--surface); border:1px solid var(--border); border-radius:14px; overflow:hidden;}
.card-head{display:flex; justify-content:space-between; align-items:center; gap:12px; flex-wrap:wrap; padding:16px 20px; border-bottom:1px solid var(--border);}
.card-head h2{font-size:15px; font-weight:700;}
.grid-2{display:grid; grid-template-columns:1.25fr 1fr; gap:20px; margin-top:20px;}
@media(max-width:900px){.grid-2{grid-template-columns:1fr;}}

/* stats */
.stat-row{display:grid; grid-template-columns:repeat(4,1fr); gap:1px; background:var(--border);}
@media(max-width:760px){.stat-row{grid-template-columns:repeat(2,1fr);}}
.stat{background:var(--surface); padding:18px 20px;}
.stat-num{font-family:'Sora',sans-serif; font-size:24px; font-weight:700;}
.stat-num.green{color:var(--green);}
.stat-num.red{color:var(--red);}
.stat-label{font-size:12.5px; color:var(--text-dim); margin-top:2px;}

/* filters */
.filters{display:flex; gap:6px; flex-wrap:wrap;}
.filter-btn{font-size:12.5px; padding:6px 12px; border-radius:999px; border:1px solid var(--border); background:transparent; color:var(--text-dim); cursor:pointer;}
.filter-btn.active{background:var(--gold); border-color:var(--gold); color:var(--on-gold); font-weight:600;}

/* findings */
.findings{list-style:none; max-height:640px; overflow-y:auto;}
.finding{display:grid; grid-template-columns:10px 1fr auto; gap:14px; padding:14px 20px; border-bottom:1px solid var(--border);}
.finding:last-child{border-bottom:none;}
.sev{width:9px; height:9px; border-radius:50%; margin-top:6px;}
.sev.high{background:var(--red);} .sev.medium{background:var(--gold);} .sev.low{background:var(--green);} .sev.info{background:var(--blue);}
.f-title{font-weight:600; font-size:14px;}
.f-detail{font-size:13px; color:var(--text-dim); margin-top:3px;}
.f-side{text-align:right; font-size:12.5px; color:var(--text-dim); white-space:nowrap;}
.f-amount{font-family:'Sora',sans-serif; font-weight:700; color:var(--text); font-size:13.5px;}
.tag{display:inline-block; font-size:11px; padding:2px 7px; border-radius:5px; background:var(--surface2); color:var(--text-dim); margin-left:6px; font-weight:500;}
.empty{padding:28px 20px; color:var(--text-dim); font-size:14px;}

/* table */
.table-scroll{overflow-x:auto;}
table{width:100%; min-width:640px; border-collapse:collapse; font-size:13.5px;}
th{text-align:left; padding:11px 16px; color:var(--text-dim); font-weight:500; font-size:12px; border-bottom:1px solid var(--border); cursor:pointer; user-select:none; white-space:nowrap;}
th:hover{color:var(--text);}
td{padding:11px 16px; border-bottom:1px solid var(--border);}
tbody tr:last-child td{border-bottom:none;}
tbody tr:hover{background:var(--surface2);}
td.num, th.num{text-align:right;}
.risk{display:inline-flex; align-items:center; gap:6px; font-size:12.5px;}
.risk .sev{margin-top:0;}
.util-bar{display:inline-block; width:54px; height:6px; border-radius:3px; background:var(--surface2); vertical-align:middle; margin-right:8px; overflow:hidden;}
.util-fill{display:block; height:100%; background:var(--teal);}
.util-fill.low{background:var(--red);}
.muted{color:var(--text-dim);}

/* charts */
.chart-pane{padding:18px 20px 20px;}
.chart-title{font-size:12.5px; color:var(--text-dim); margin-bottom:12px;}
.hbars{display:flex; flex-direction:column; gap:10px;}
.hbar-row{display:grid; grid-template-columns:150px 1fr 90px; gap:10px; align-items:center; font-size:12.5px;}
.hbar-track{height:10px; background:var(--surface2); border-radius:5px; overflow:hidden;}
.hbar-fill{display:block; height:100%; background:var(--teal); border-radius:5px; width:0; transition:width .5s ease;}
.vbars{display:flex; align-items:flex-end; gap:6px; height:140px; margin-top:4px;}
.vbar-col{flex:1; display:flex; flex-direction:column; align-items:center; justify-content:flex-end; gap:6px; height:100%;}
.vbar{width:100%; background:var(--gold); border-radius:4px 4px 0 0; min-height:2px; height:0; transition:height .5s ease;}
.vbar-lbl{font-size:10px; color:var(--text-dim);}

/* forms */
.form{display:flex; flex-direction:column; gap:14px; padding:20px;}
.form label{display:flex; flex-direction:column; gap:6px; font-size:13px; color:var(--text-dim);}
.form input{background:var(--ink); border:1px solid var(--border); border-radius:8px; padding:10px 12px; color:var(--text); font-size:14px;}
.form input:focus{outline:2px solid var(--gold); outline-offset:1px; border-color:transparent;}
.form-row{display:grid; grid-template-columns:1fr 1fr; gap:14px;}
@media(max-width:640px){.form-row{grid-template-columns:1fr;}}
.msg{font-size:13px; padding:10px 12px; border-radius:8px;}
.msg.error{background:var(--err-bg); color:var(--err-text); border:1px solid var(--err-border);}
.msg.ok{background:var(--ok-bg); color:var(--ok-text); border:1px solid var(--ok-border);}
.help{font-size:12px; color:var(--text-dim);}

/* login */
.login-wrap{min-height:100vh; display:flex; align-items:center; justify-content:center; padding:24px;}
.login-card{width:100%; max-width:400px;}
.login-card .logo{justify-content:center; margin-bottom:18px; cursor:default;}
.back-site{position:fixed; top:20px; left:20px; font-size:13.5px; color:var(--text-dim); display:inline-flex; gap:6px; align-items:center; padding:8px 4px;}
.back-site:hover, .back-site:focus-visible{color:var(--text);}
.login-links{display:flex; justify-content:space-between; gap:12px; flex-wrap:wrap;}
.login-links .link-btn{margin-top:0;}
.forgot-text{font-size:14px; color:var(--text); line-height:1.55;}
.page-title{font-size:20px; font-weight:700; color:var(--text);}
#forgotView .btn{justify-content:center;}

/* admin */
.cust-list{list-style:none;}
.cust{display:flex; justify-content:space-between; align-items:center; gap:12px; padding:14px 20px; border-bottom:1px solid var(--border); flex-wrap:wrap;}
.cust:last-child{border-bottom:none;}
.cust-actions{display:flex; gap:8px; flex-wrap:wrap;}
.upload-panel{padding:16px 20px; background:var(--surface2); border-bottom:1px solid var(--border);}
.form label.dropzone{position:relative; align-items:center; text-align:center; gap:6px; padding:26px 18px; border:2px dashed var(--border-hover); border-radius:12px; background:var(--surface); cursor:pointer; transition:border-color .15s, background .15s;}
.dropzone:hover, .dropzone.drag{border-color:var(--gold); background:var(--gold-soft);}
.dropzone:focus-within{outline:2px solid var(--gold); outline-offset:2px;}
.form .dropzone input[type=file]{width:1px;}
.dz-icon{width:28px; height:28px; color:var(--gold);}
.dz-title{font-size:15px; font-weight:600; color:var(--text);}
.dz-sub{font-size:12.5px; color:var(--text-dim); max-width:520px; line-height:1.5;}
.dz-list{list-style:none; display:flex; flex-direction:column; gap:6px;}
.dz-list:empty{display:none;}
.dz-file{display:flex; align-items:center; gap:10px; padding:8px 12px; border:1px solid var(--border); border-radius:8px; background:var(--surface); font-size:13px;}
.dz-name{flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--text);}
.dz-remove{background:none; border:none; color:var(--text-dim); font:inherit; font-size:12px; cursor:pointer; text-decoration:underline;}
.dz-remove:hover{color:var(--red);}
.form h1{font-size:20px; font-weight:700; color:var(--text);}
.grid-gap{margin-top:20px;}
.vname{font-weight:600;}
td.warn{color:var(--gold);}
.footnote{margin-top:14px;}
main.wrap{padding-top:32px; padding-bottom:64px;}
.nav-right .btn{white-space:nowrap;}
.form input{width:100%; min-width:0;}
@media(max-width:640px){
  main.wrap{padding-top:20px;}
  .nav-right{gap:8px;}
  .nav-right .btn{padding:8px 11px; font-size:12.5px;}
  .logo{font-size:17px;}
  .page-head h1{font-size:23px;}
  .finding{grid-template-columns:10px 1fr; }
  .f-side{grid-column:2; text-align:left;}
}

/* ---------- theme toggle + back to top ---------- */
.icon-btn{display:inline-flex; align-items:center; justify-content:center; width:38px; height:38px; border-radius:8px;
  border:1px solid var(--border); background:none; color:var(--text); cursor:pointer;}
.icon-btn:hover{background:var(--surface2);}
.icon-btn svg{width:18px; height:18px;}
[data-theme="light"] .icon-sun, [data-theme="dark"] .icon-moon, :root:not([data-theme]) .icon-moon{display:none;}
.back-to-top{position:fixed; right:22px; bottom:22px; width:44px; height:44px; border-radius:50%; border:none;
  background:var(--gold); color:var(--on-gold); font-size:18px; cursor:pointer; box-shadow:var(--shadow);
  opacity:0; pointer-events:none; transform:translateY(8px); transition:opacity .2s ease, transform .2s ease; z-index:60;}
.back-to-top.visible{opacity:1; pointer-events:auto; transform:none;}
.login-theme{position:fixed; top:16px; right:16px;}
:focus-visible{outline:2px solid var(--gold); outline-offset:2px;}

/* ---------- interactive dashboard ---------- */
.sr-only{position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); border:0;}
.filter-bar{padding:14px 16px; display:flex; flex-direction:column; gap:10px; position:sticky; top:67px; z-index:20; box-shadow:var(--shadow);}
@media(max-width:640px){.filter-bar{position:static; box-shadow:none;}}
.filter-controls{display:flex; gap:10px; flex-wrap:wrap; align-items:center;}
.search{flex:1 1 220px;}
.search input, .select select{width:100%; background:var(--ink); border:1px solid var(--border); border-radius:8px;
  padding:9px 12px; color:var(--text); font:inherit; font-size:13.5px;}
.select{flex:0 1 220px;}
.select select{cursor:pointer;}
.seg{display:inline-flex; border:1px solid var(--border); border-radius:9px; overflow:hidden; flex-wrap:wrap;}
.seg-btn{display:inline-flex; align-items:center; gap:7px; padding:8px 13px; font-size:13px; background:none; border:none;
  color:var(--text-dim); cursor:pointer; border-right:1px solid var(--border);}
.seg-btn:last-child{border-right:none;}
.seg-btn:hover{color:var(--text); background:var(--surface2);}
.seg-btn.active{background:var(--gold); color:var(--on-gold); font-weight:600;}
.seg-btn .sev{margin-top:0;}
.chips{display:flex; gap:8px; flex-wrap:wrap;}
.chip{display:inline-flex; align-items:center; gap:8px; font-size:12.5px; padding:5px 8px 5px 11px; border-radius:999px;
  border:1px solid var(--gold); background:var(--gold-soft); color:var(--text); cursor:pointer;}
.chip-x{font-size:15px; line-height:1; color:var(--text-dim);}
.chip:hover .chip-x{color:var(--red);}
.chip-clear{border-color:var(--border); background:none; color:var(--text-dim); padding-right:11px;}

.link-btn{background:none; border:none; padding:0; margin-top:6px; color:var(--gold); font-size:12.5px; cursor:pointer; font-weight:600;}
.link-btn:hover{text-decoration:underline;}
.finding.is-focus{background:var(--gold-soft);}

button.hbar-row{width:100%; background:none; border:none; color:var(--text); text-align:left; cursor:pointer; padding:4px 6px; margin:0 -6px; border-radius:6px; font:inherit; font-size:12.5px;}
button.hbar-row:hover{background:var(--surface2);}
.hbar-row.selected{background:var(--gold-soft);}
.hbar-row.selected .hbar-fill{background:var(--gold);}
.hbar-row.dim{opacity:.55;}
.hbar-name{overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
@media(max-width:640px){.hbar-row{grid-template-columns:110px 1fr 80px;}}
.chart-head{display:flex; justify-content:space-between; align-items:baseline; gap:12px; margin-bottom:12px;}
.chart-head .chart-title{margin-bottom:0;}
.chart-total{font-family:'Sora',sans-serif; font-weight:700; font-size:15px;}
button.vbar-col{background:none; border:none; padding:0; cursor:pointer; font:inherit;}
button.vbar-col:hover .vbar, button.vbar-col:focus-visible .vbar{background:var(--gold-hover);}

tr.clickable{cursor:pointer;}
tr.selected td{background:var(--gold-soft);}
tr.selected td:first-child{box-shadow:inset 3px 0 0 var(--gold);}

.tooltip{position:absolute; z-index:80; min-width:170px; max-width:260px; padding:10px 12px; border-radius:10px;
  background:var(--surface); border:1px solid var(--border); box-shadow:var(--shadow); font-size:12.5px; pointer-events:none;}
.tip-title{color:var(--text-dim);}
.tip-total{font-family:'Sora',sans-serif; font-weight:700; font-size:16px; margin:2px 0 6px;}
.tip-row{display:flex; justify-content:space-between; gap:12px; color:var(--text-dim);}
.tip-row span:last-child{color:var(--text);}

/* ---------- charts v2 ---------- */
.chart-h{font-size:15px; font-weight:700;}
.chart-sub{font-size:12.5px; color:var(--text-dim); margin-top:2px;}
.chart-head{align-items:flex-start;}
.legend{display:flex; flex-wrap:wrap; gap:6px 16px; margin:4px 0 14px; font-size:12.5px; color:var(--text-dim);}
.lg{display:inline-flex; align-items:center; gap:7px;}
.sw{display:inline-block; width:10px; height:10px; border-radius:3px; margin-right:7px; vertical-align:-1px; flex:none;}
.lg .sw{margin-right:0;}
.pad{padding:12px 0;}

/* stacked monthly */
.stack-chart{display:flex; gap:10px; height:220px; align-items:stretch;}
.stack-col-btn{flex:1; display:flex; flex-direction:column; gap:6px; background:none; border:none; padding:0; cursor:pointer; font:inherit; min-width:0;}
.stack-area{flex:1; display:flex; align-items:flex-end;}
.stack{width:100%; height:0; display:flex; flex-direction:column-reverse; border-radius:4px 4px 0 0; overflow:hidden; transition:height .5s ease;}
.stk-seg{display:block; min-height:2px; flex-basis:0;}
.stk-seg + .stk-seg{border-bottom:2px solid var(--surface);}   /* 2px surface gap between stacked segments */
.stack-col-btn:hover .stack, .stack-col-btn:focus-visible .stack{filter:brightness(1.12);}
.stack-col-btn .vbar-lbl{text-align:center;}
@media(max-width:640px){.stack-chart{gap:4px; height:170px;} .stack-col-btn .vbar-lbl{font-size:9px;}}

/* equal-height row: right column sets the height, findings scroll inside it (no dead space) */
.grid-2.equal{align-items:stretch;}
.stack-col{display:flex; flex-direction:column; gap:20px;}
.stack-col > .card{margin:0;}
.findings-card{display:flex; flex-direction:column; min-height:0;}
.findings-scroll{position:relative; flex:1 1 auto; min-height:320px;}
.findings-scroll .findings{position:absolute; inset:0; max-height:none; overflow-y:auto;}
@media(max-width:900px){
  .findings-scroll{min-height:0;}
  .findings-scroll .findings{position:static; max-height:520px;}
}
.grid-2.even{grid-template-columns:1fr 1fr;}
@media(max-width:900px){.grid-2.even{grid-template-columns:1fr;}}
.grid-2 + .grid-2{margin-top:20px;}

/* category bars with swatches */
.hbar-name{display:flex; align-items:center; min-width:0;}
.hbar-row.selected .hbar-fill{filter:none; outline:2px solid var(--text); outline-offset:1px;}

/* seats */
.seat-bars{display:flex; flex-direction:column; gap:6px;}
.seat-row{display:grid; grid-template-columns:110px 1fr 84px; gap:10px; align-items:center; width:100%; background:none; border:none;
  color:var(--text); font:inherit; font-size:12.5px; text-align:left; cursor:pointer; padding:4px 6px; margin:0 -6px; border-radius:6px;}
.seat-row:hover, .seat-row.selected{background:var(--surface2);}
.seat-area{display:block; height:12px;}
.seat-track{display:flex; height:100%; width:0; gap:2px; transition:width .5s ease;}
.seat-used{background:var(--teal); border-radius:3px 0 0 3px; flex-basis:0; min-width:2px;}
.seat-unused{flex-basis:0; border-radius:0 3px 3px 0;
  background:repeating-linear-gradient(135deg, var(--status-serious) 0 3px, transparent 3px 6px); box-shadow:inset 0 0 0 1px var(--status-serious);}

.seat-warn{color:var(--text); font-weight:600;}
.sw-used{display:inline-block; width:10px; height:10px; border-radius:3px; background:var(--teal);}
.sw-unused{display:inline-block; width:10px; height:10px; border-radius:3px;
  background:repeating-linear-gradient(135deg, var(--status-serious) 0 2px, transparent 2px 4px); box-shadow:inset 0 0 0 1px var(--status-serious);}

/* anomalies: diverging bars around a zero line */
.anom-chart{height:230px;}
.anom-cols{display:flex; gap:8px; height:100%;}
.anom-col{flex:1; display:grid; grid-template-rows:1fr 1px .55fr auto; background:none; border:none; padding:0; cursor:pointer; font:inherit; min-width:0;}
.anom-half{display:flex; justify-content:center; position:relative;}
.anom-half.up{align-items:flex-end;}
.anom-half.down{align-items:flex-start;}
.anom-bar{display:block; width:100%; max-width:34px; height:0; transition:height .5s ease;}
.anom-half.up .anom-bar{border-radius:4px 4px 0 0;}
.anom-half.down .anom-bar{border-radius:0 0 4px 4px;}
.anom-bar.spike{background:var(--status-critical);}
.anom-bar.above{background:var(--neutral-bar);}
.anom-bar.below{background:var(--diverge-low);}
.anom-zero{background:var(--chart-axis, var(--border-hover));}
.anom-bar{position:relative;}
.anom-half.up{padding-top:20px;}
.anom-val{position:absolute; bottom:100%; left:50%; transform:translateX(-50%); margin-bottom:4px; font-size:11px; font-weight:700; color:var(--text); white-space:nowrap;}
.anom-na{align-self:flex-end; color:var(--text-dim); font-size:12px; padding-bottom:4px;}
.anom-col .vbar-lbl{text-align:center; padding-top:6px;}
.anom-col:hover .anom-bar, .anom-col:focus-visible .anom-bar{filter:brightness(1.15);}
.sw-spike, .sw-above, .sw-below{display:inline-block; width:10px; height:10px; border-radius:3px;}
.sw-spike{background:var(--status-critical);} .sw-above{background:var(--neutral-bar);} .sw-below{background:var(--diverge-low);}
@media(max-width:640px){.anom-cols{gap:3px;} .anom-val{font-size:9px;} .anom-col .vbar-lbl{font-size:9px;}}

/* renewals timeline */
.timeline{display:flex; flex-direction:column; gap:2px;}
.tl-row{display:grid; grid-template-columns:110px 1fr 104px; gap:10px; align-items:center; width:100%; background:none; border:none;
  color:var(--text); font:inherit; font-size:12.5px; text-align:left; cursor:pointer; padding:7px 6px; margin:0 -6px; border-radius:6px;}
.tl-row:hover, .tl-row.selected{background:var(--surface2);}
.tl-head{cursor:default; padding-bottom:2px;}
.tl-head:hover{background:none;}
.tl-axis{position:relative; height:16px; border-bottom:1px solid var(--border);}
.tl-tick{position:absolute; bottom:3px; transform:translateX(-50%); font-size:11px; color:var(--text-dim);}
.tl-lane{position:relative; height:14px;}
.tl-lane::before{content:""; position:absolute; left:0; right:0; top:50%; height:1px; background:var(--border);}
.tl-today{position:absolute; top:-6px; bottom:-6px; width:2px; background:var(--gold);}
.tl-window{position:absolute; top:50%; height:4px; margin-top:-2px; background:var(--gold); border-radius:2px; opacity:.8;}
.tl-window.missed{background:var(--status-critical);}
.tl-diamond{position:absolute; top:50%; width:10px; height:10px; margin:-5px 0 0 -5px; transform:rotate(45deg); background:var(--gold); box-shadow:0 0 0 2px var(--surface);}
.tl-diamond.missed{background:var(--status-critical);}
.tl-dot{position:absolute; top:50%; width:12px; height:12px; margin:-6px 0 0 -6px; border-radius:50%; background:var(--text); box-shadow:0 0 0 2px var(--surface);}
.tl-status{text-align:right; color:var(--text-dim);}
.tl-status.soon{color:var(--text); font-weight:600;}
.tl-status.missed{color:var(--status-critical); font-weight:600;}
.sw-diamond{display:inline-block; width:9px; height:9px; transform:rotate(45deg); background:var(--gold);}
.sw-diamond.missed{background:var(--status-critical);}
.sw-dot{display:inline-block; width:10px; height:10px; border-radius:50%; background:var(--text);}
@media(max-width:640px){.seat-row, .tl-row{grid-template-columns:84px 1fr 76px;} .tl-status{font-size:11px;}}

/* tooltip rows with swatches */
.tip-row span:first-child{display:inline-flex; align-items:center;}
.tooltip{min-width:200px; max-width:300px;}
.ell{overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0;}
.hbar-row{grid-template-columns:minmax(120px,190px) 1fr 80px;}
@media(max-width:640px){.hbar-row{grid-template-columns:120px 1fr 70px;}}
/* even row: both cards share a height and the anomaly chart grows to fill it */
.grid-2.even{align-items:stretch;}
.grid-2.even > .card{display:flex; flex-direction:column;}
.grid-2.even > .card > .chart-pane{flex:1; display:flex; flex-direction:column;}
.anom-chart{flex:1; display:flex; height:auto; min-height:230px;}
.anom-cols{flex:1; height:auto;}
.chart-total{white-space:nowrap;}
@media(max-width:640px){.tl-tick.odd{display:none;} .tl-tick{font-size:10px;}}

/* =====================================================================================
   PHONES (700px and below). Desktop and tablets are untouched: every rule here is either
   inside the phone media query or only hides the phone-only pieces on bigger screens.
   ===================================================================================== */
@media (min-width:701px){ .m-only{display:none !important;} }
.sheet-backdrop[hidden], .m-menu[hidden]{display:none !important;}

@media (max-width:700px){
  .d-only{display:none !important;}
  .tooltip{display:none !important;}
  main.wrap{padding-top:18px;}
  #content{padding-bottom:70px;}

  /* nav: logo, theme, menu */
  nav.nav-menu{flex-wrap:nowrap;}
  .nav-menu .nav-right{position:relative; flex-wrap:nowrap; gap:8px; margin-left:auto;}
  .nav-menu .nav-right > #adminLink, .nav-menu .nav-right > .who-link,
  .nav-menu .nav-right > #exportBtn, .nav-menu .nav-right > #logoutBtn{display:none !important;}
  .m-menu{position:absolute; right:0; top:calc(100% + 12px); min-width:230px; display:flex; flex-direction:column; padding:6px;
    background:var(--surface); border:1px solid var(--border); border-radius:14px; box-shadow:var(--shadow); z-index:100;}
  .m-menu a, .m-menu button{display:block; padding:13px 14px; border-radius:9px; font-size:15px; color:var(--text);
    background:none; border:none; text-align:left; cursor:pointer;}
  .m-menu a:hover, .m-menu button:hover{background:var(--surface2);}
  .m-menu-who{padding:10px 14px 10px; font-size:12.5px; color:var(--text-dim); border-bottom:1px solid var(--border); margin-bottom:4px;
    overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
  .m-menu #mLogout{color:var(--red);}

  .page-head{margin-bottom:14px;}
  .page-head h1{font-size:23px; line-height:1.2;}
  .page-head .meta{font-size:12px;}
  .m-chips{margin:-4px 0 14px;}

  /* filters become a bottom sheet */
  .filter-bar{position:fixed; left:0; right:0; bottom:0; top:auto; z-index:95; margin:0; border-radius:18px 18px 0 0; border-bottom:none;
    padding:6px 16px calc(18px + env(safe-area-inset-bottom)); max-height:86vh; overflow-y:auto; gap:14px;
    box-shadow:0 -12px 40px rgba(0,0,0,.35); transform:translateY(105%); visibility:hidden;
    transition:transform .3s cubic-bezier(.2,.8,.2,1), visibility 0s linear .3s;}
  .filter-bar.open{transform:none; visibility:visible; transition:transform .3s cubic-bezier(.2,.8,.2,1);}
  .filter-bar::before{content:""; display:block; width:40px; height:4px; border-radius:2px; background:var(--border-hover); margin:6px auto 0;}
  .sheet-head{display:flex; justify-content:space-between; align-items:center; gap:12px;}
  .sheet-head h2{font-size:18px; font-weight:700;}
  .filter-controls{flex-direction:column; align-items:stretch; gap:12px;}
  .search, .select{flex:none; width:100%;}
  .search input, .select select{font-size:16px; padding:12px 13px;}    /* 16px stops iOS zooming in */
  .seg{display:grid; grid-template-columns:repeat(4,1fr);}
  .seg-btn{justify-content:center; padding:12px 4px; font-size:13px; gap:5px;}
  .sheet-backdrop{position:fixed; inset:0; background:rgba(0,0,0,.45); z-index:94;}
  body.sheet-open{overflow:hidden;}

  .filter-fab{position:fixed; left:50%; bottom:calc(18px + env(safe-area-inset-bottom)); transform:translateX(-50%); z-index:70;
    display:inline-flex; align-items:center; gap:8px; padding:12px 20px; border-radius:999px; border:none; cursor:pointer;
    background:var(--text); color:var(--ink); font-weight:600; font-size:14.5px; box-shadow:0 8px 24px rgba(0,0,0,.35);}
  .filter-fab svg{width:18px; height:18px;}
  .fab-count{display:inline-flex; align-items:center; justify-content:center; min-width:20px; height:20px; padding:0 6px;
    border-radius:999px; background:var(--gold); color:var(--on-gold); font-size:12px;}
  .back-to-top{right:16px; bottom:calc(18px + env(safe-area-inset-bottom));}

  /* summary */
  .stat{padding:14px 16px;}
  .stat-num{font-size:21px;}
  .stat-label{font-size:12px;}

  /* findings: top 3, then "show all" */
  .grid-2{gap:16px; margin-top:16px;}
  .grid-2.even, .stack-col{display:none;}          /* their cards move into the chart carousel */
  .findings-scroll{min-height:0;}
  .findings-scroll .findings{position:static; max-height:none; overflow:visible;}
  .findings:not(.expanded) > li:nth-child(n+4){display:none;}
  .finding{padding:14px 16px; gap:12px;}
  .f-title{font-size:14.5px;}
  .link-btn{padding:6px 0;}
  .m-more{display:block; width:100%; padding:15px; border:none; border-top:1px solid var(--border); background:none;
    color:var(--gold); font-weight:600; font-size:14px; cursor:pointer;}

  /* swipeable charts */
  .m-charts{display:block; margin-top:16px;}
  .m-tabs{display:flex; gap:6px; overflow-x:auto; padding:0 0 10px; scrollbar-width:none;}
  .m-tabs::-webkit-scrollbar{display:none;}
  .m-tab{flex:none; padding:8px 14px; border-radius:999px; border:1px solid var(--border); background:var(--surface);
    color:var(--text-dim); font-size:13.5px; cursor:pointer;}
  .m-tab[aria-selected="true"]{background:var(--gold); border-color:var(--gold); color:var(--on-gold); font-weight:600;}
  .m-track{display:flex; gap:12px; overflow-x:auto; scroll-snap-type:x mandatory; align-items:flex-start;
    scrollbar-width:none; overscroll-behavior-x:contain; transition:height .25s ease;}
  .m-track::-webkit-scrollbar{display:none;}
  .m-track > .card{flex:0 0 100%; scroll-snap-align:start; scroll-snap-stop:always; margin:0 !important;}
  .m-dots{display:flex; justify-content:center; gap:6px; padding-top:12px;}
  .m-dot{width:6px; height:6px; border-radius:3px; background:var(--border-hover); transition:width .2s ease, background .2s ease;}
  .m-dot.on{width:18px; background:var(--gold);}
  .chart-pane{padding:16px;}
  .stack-chart{height:200px;}
  .anom-chart{min-height:210px;}

  /* tap-to-see figures */
  .m-readout{margin-top:14px; padding:12px 14px; border-radius:10px; background:var(--surface2); font-size:13px; min-height:52px;}
  .ro-hint{color:var(--text-dim); display:flex; align-items:center; gap:8px;}
  .ro-hint::before{content:""; width:7px; height:7px; border-radius:50%; background:var(--gold); flex:none;}
  .ro-title{color:var(--text-dim); font-size:12.5px;}
  .ro-head{font-family:'Sora',sans-serif; font-weight:700; font-size:18px; margin:2px 0 6px;}
  .ro-row{display:flex; justify-content:space-between; gap:12px; color:var(--text-dim); padding:3px 0; border-top:1px solid var(--border);}
  .ro-row:first-of-type{border-top:none;}
  .ro-row span:first-child{display:inline-flex; align-items:center; min-width:0;}
  .ro-row span:last-child{color:var(--text); white-space:nowrap;}
  .ro-action{margin-top:8px;}
  .stack-col-btn.tapped .stack{outline:2px solid var(--text); outline-offset:2px;}
  .stack-col-btn.tapped .vbar-lbl, .anom-col.tapped .vbar-lbl{color:var(--text); font-weight:700;}
  .anom-col.tapped .anom-bar{outline:2px solid var(--text); outline-offset:1px;}
  .seat-row.tapped, .tl-row.tapped{background:var(--surface2); box-shadow:inset 3px 0 0 var(--gold);}

  /* vendor cards instead of the wide table */
  .table-scroll{display:none;}
  .m-sort{flex:0 1 190px;}
  .m-sort select{font-size:15px; padding:8px 10px;}
  .v-cards{list-style:none;}
  .v-card{display:grid; grid-template-columns:1fr auto; gap:4px 12px; width:100%; padding:14px 16px; text-align:left;
    background:none; border:none; border-bottom:1px solid var(--border); color:var(--text); font:inherit; cursor:pointer;}
  .v-cards li:last-child .v-card{border-bottom:none;}
  .v-card.selected{background:var(--gold-soft); box-shadow:inset 3px 0 0 var(--gold);}
  .v-name{font-weight:600; font-size:15px; min-width:0;}
  .v-spend{font-family:'Sora',sans-serif; font-weight:700; font-size:15px; text-align:right;}
  .v-cat{display:flex; align-items:center; font-size:12.5px; color:var(--text-dim); min-width:0;}
  .v-cat .ell{min-width:0;}
  .v-risk{justify-self:end;}
  .v-meta{grid-column:1 / -1; display:flex; flex-wrap:wrap; gap:6px; margin-top:6px;}
  .pill{font-size:12px; padding:3px 9px; border-radius:999px; background:var(--surface2); color:var(--text-dim);}
  .pill.warn{color:var(--gold);}
  .pill.bad{color:var(--red);}

  /* sections ease in as you scroll, like the landing page */
  .rv{opacity:0; transform:translateY(18px); transition:opacity .55s ease, transform .55s ease;}
  .rv.in{opacity:1; transform:none;}
}
@media (max-width:700px) and (prefers-reduced-motion: reduce){
  .rv{opacity:1; transform:none; transition:none;}
  .filter-bar, .filter-bar.open, .m-track{transition:none;}
}
