/* Mobility Survey Dashboard — design system reused from the original ISON interactive dashboard. Uploads enabled for the persistent (D1-backed) version. */

:root{--canvas:#fff;--surface:#F9F8F7;--text:#2C2C2B;--muted:#7D7A75;--border:#E6E5E3;--blue:#2783DE;--blue2:#E5F2FC;--green:#46A171;--green2:#E8F1EC;--orange:#D5803B;--orange2:#FBEBDE;--red:#E56458;--red2:#FCE9E7;--purple:#BF8EDA;--shadow:0 1px 2px rgba(0,0,0,.05),0 6px 20px rgba(0,0,0,.05)}@media(prefers-color-scheme:dark){:root{--canvas:#191919;--surface:#202020;--text:#fff;--muted:rgba(255,255,255,.65);--border:rgba(255,255,255,.2);--blue:#5E9FE8;--blue2:rgba(94,159,232,.12);--green:#72BC8F;--green2:rgba(114,188,143,.12);--orange:#DE9255;--orange2:rgba(222,146,85,.12);--red:#E97366;--red2:rgba(233,115,102,.12);--purple:#BF8EDA;--shadow:none}}*{box-sizing:border-box}body{margin:0;background:var(--canvas);color:var(--text);font:14px/1.45 -apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif}.wrap{width:min(98vw,1900px);max-width:1900px;margin:0 auto;padding:22px clamp(12px,1.4vw,28px)}.hero{display:grid;grid-template-columns:1.5fr .75fr;gap:16px}.panel,.chartbox{background:var(--surface);border:1px solid var(--border);border-radius:14px;box-shadow:var(--shadow)}.panel{padding:20px}.chartbox{padding:16px;margin-bottom:16px}h1{font-size:30px;line-height:1.08;margin:8px 0 10px}h3{margin:0 0 4px}.muted{color:var(--muted)}.badge{display:inline-flex;border:1px solid var(--border);background:var(--canvas);border-radius:999px;padding:6px 10px;margin-right:8px;color:var(--muted);font-size:12px}.tabs,.subtabs{display:flex;gap:8px;flex-wrap:wrap;margin:18px 0}.tab,.subtab{min-height:44px;border:1px solid var(--border);border-radius:10px;background:var(--surface);color:var(--text);padding:10px 12px;font-weight:700;cursor:pointer}.tab.active,.subtab.active{background:var(--blue);border-color:var(--blue);color:#fff}.view,.subview{display:none}.view.active,.subview.active{display:block}.kpis{display:grid;grid-template-columns:repeat(6,1fr);gap:12px;margin:16px 0}.kpi{background:var(--canvas);border:1px solid var(--border);border-radius:12px;padding:14px}.kpi b{display:block;font-size:24px;margin-top:5px}.kpi span{color:var(--muted);font-size:12px;font-weight:700}.grid{display:grid;grid-template-columns:1fr 1fr;gap:16px}.wide{grid-column:1/-1}.chart{height:330px}.tall{height:460px}.tip{position:fixed;display:none;background:var(--canvas);border:1px solid var(--border);border-radius:8px;padding:9px 10px;box-shadow:var(--shadow);pointer-events:none;z-index:20;font-size:12px;max-width:280px}.callout{background:var(--orange2);border-left:4px solid var(--orange);border-radius:8px;padding:12px;margin-top:12px}.tablewrap{overflow:auto;border:1px solid var(--border);border-radius:12px;background:var(--canvas)}table{border-collapse:collapse;width:100%;min-width:760px}th,td{padding:10px 12px;border-bottom:1px solid var(--border);text-align:left;white-space:nowrap}th{background:var(--surface);color:var(--muted);font-size:12px;position:sticky;top:0}.num{text-align:right;font-variant-numeric:tabular-nums}.axis{fill:var(--muted);font-size:11.5px}.gridline{stroke:var(--border)}.bar{rx:3;cursor:pointer}.bar:hover,circle:hover{opacity:.75}@media(max-width:900px){.hero,.grid{grid-template-columns:1fr}.kpis{grid-template-columns:repeat(2,1fr)}.wrap{padding:18px}}@media(max-width:520px){.kpis{grid-template-columns:1fr}.tab,.subtab{width:100%}h1{font-size:24px}}
.site-header{display:flex;justify-content:flex-end;padding:4px 0 8px}.site-logo{height:30px;width:auto;object-fit:contain}
.filterbar{display:flex;gap:16px;align-items:end;margin:18px 0;flex-wrap:wrap}.filterbar h3{margin:0 0 4px}.filterbar label{font-size:12px;font-weight:800;color:var(--muted);display:flex;flex-direction:column;gap:6px}.filterbar select{min-height:38px;border:1px solid var(--border);border-radius:10px;padding:0 12px;background:var(--canvas);font-weight:700;color:var(--text)}#filter-summary{min-width:260px;padding-bottom:8px}.filterbar input[type=date]{min-height:38px;border:1px solid var(--border);border-radius:10px;padding:0 12px;background:var(--canvas);font-weight:700;color:var(--text)}.kpis{grid-template-columns:repeat(auto-fit,minmax(155px,1fr))}.chartbox{overflow:hidden}.chart svg text{font-size:10.5px}.tall{height:540px}#agents{height:560px}#campaign{height:520px}/* wide-dashboard */@media (min-width:1400px){.hero{grid-template-columns:1.7fr .8fr}.grid{grid-template-columns:repeat(3,minmax(0,1fr))}.grid .wide{grid-column:span 3}.kpis{grid-template-columns:repeat(auto-fit,minmax(170px,1fr))}.chart{height:440px}.tall{height:580px}.tablewrap{max-height:620px}}@media (min-width:1700px){.wrap{width:98.5vw;max-width:2200px}.chart{height:480px}.tall{height:640px}}
/* compact-header */
.wrap{width:min(98.5vw,2200px)!important;max-width:2200px!important;padding:12px clamp(8px,1vw,18px)!important}
.hero{grid-template-columns:2fr .9fr!important;gap:10px!important;margin-bottom:10px!important}
.panel{padding:12px 16px!important}
h1{font-size:24px!important;line-height:1.05!important;margin:4px 0 6px!important}
.hero .muted{margin:4px 0!important;font-size:12px!important}.badge{padding:4px 8px!important;font-size:11px!important}.callout{padding:8px 10px!important;margin-top:8px!important;font-size:12px!important}.tabs{margin:8px 0 10px!important;gap:6px!important}.tab{padding:8px 12px!important}.filterbar{padding:14px 16px!important;margin-bottom:12px!important}.filterbar h3{margin-bottom:4px!important}.kpi{padding:12px!important}.kpi b{font-size:22px!important}.chartbox{padding:12px!important;margin-bottom:12px!important}
@media (max-width:900px){.hero{grid-template-columns:1fr!important}.wrap{padding:10px!important}h1{font-size:22px!important}}
/* v3-dashboard-fixes */.upload-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:12px;margin:12px 0}.upload-grid input{display:block;margin-top:6px;width:100%;border:1px solid var(--border);border-radius:10px;padding:9px;background:var(--canvas)}.chart svg .data-label{font-weight:700;fill:var(--text);font-size:10px}.legend-top{font-size:11px}.filterbar{grid-template-columns:1.4fr repeat(5,auto)!important}#agents{height:640px!important}.tall{height:620px!important}
/* v4-accuracy-stretch */
#overview .grid{grid-template-columns:1fr 1fr!important;gap:14px!important}
#overview .chartbox{min-height:470px!important}
#overview #funnel,#overview #mergeq{height:400px!important}
#campaign,#campaignCompare,#agents{height:680px!important}
#arate,#compday,#talktime,#occupancy,#disp{height:520px!important}
.chart svg{width:100%!important;height:100%!important}.chartbox.wide{grid-column:1 / -1!important}.chartbox{overflow:visible!important}.axis.data-label{paint-order:stroke;stroke:var(--surface);stroke-width:3px;stroke-linejoin:round}.legend-top{font-weight:700}.accuracy-note{font-size:12px;color:var(--muted);margin-top:6px}.chart svg .axis-title{font-size:12.5px!important;fill:var(--text)!important}

/* agent-pattern-fix */
#agents{height:760px!important}
#agent-rank .chartbox{min-height:830px!important}
#arate,#compday,#talktime,#occupancy{height:620px!important}

/* tables-agent-filter-fix */
.filterbar{grid-template-columns:minmax(260px,1.7fr) repeat(5,minmax(120px,.7fr)) auto minmax(260px,1fr)!important;align-items:end}
#agent-filter{min-width:150px}
#tables .tablewrap{max-height:72vh;overflow:auto}
#tables table th{position:sticky;top:0;z-index:2}
@media(max-width:1100px){.filterbar{grid-template-columns:1fr 1fr!important}}

/* kpi-info-hints */
.kpi[title]{cursor:help}
.kpi-info{opacity:.6;font-weight:700;font-size:11px}
.kpi-note{font-size:12px;line-height:1.5;margin:4px 0 14px;padding:10px 12px;background:var(--surface);border:1px solid var(--border);border-radius:10px}

/* upload-disabled-fix */
/* uploads enabled in persistent version */

/* export-download-fix */
.export-actions{display:flex;gap:8px;align-items:end;flex-wrap:wrap}
.export-actions .tab{background:#0b5fff;color:#fff;border-color:#0b5fff;font-weight:800;min-height:40px}
.export-actions .tab:hover{filter:brightness(.96)}
.export-report{display:none}
@media print{
  body>*:not(.export-report){display:none!important}
  .export-report{display:block!important;padding:24px!important;color:#111!important;background:#fff!important;font-family:Arial,Helvetica,sans-serif!important}
  .export-report h1{font-size:22px;margin:0 0 6px}.export-report h2{font-size:16px;margin:22px 0 8px;border-bottom:2px solid #0b5fff;padding-bottom:4px}.export-report h3{font-size:13px;margin:14px 0 6px}.export-report .export-meta{font-size:11px;color:#555;margin-bottom:14px}.export-report table{border-collapse:collapse;width:100%;font-size:9px;margin:6px 0 14px;page-break-inside:auto}.export-report th{background:#0b5fff;color:#fff;text-align:left}.export-report th,.export-report td{border:1px solid #b7c0cc;padding:5px;vertical-align:top}.export-report .kpi-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;margin:10px 0}.export-report .kpi-card{border:1px solid #b7c0cc;border-radius:8px;padding:8px;break-inside:avoid}.export-report .kpi-card span{display:block;font-size:10px;color:#555}.export-report .kpi-card b{font-size:16px}.export-report svg{max-width:100%;height:auto;break-inside:avoid}.no-print{display:none!important}
}

/* KPI tiles — even 7 x 2 grid, tiles stretched to fill the row evenly (overrides auto-fit above) */
.kpis{grid-template-columns:repeat(7,1fr)!important;align-items:stretch}
.kpis .kpi{min-width:0}
@media(max-width:1200px){.kpis{grid-template-columns:repeat(4,1fr)!important}}
@media(max-width:760px){.kpis{grid-template-columns:repeat(2,1fr)!important}}

/* expand-toggle — fullscreen/normal toggle for any chart box or table */
.chartbox,.tablewrap-shell{position:relative}
.expand-btn{position:absolute;top:10px;right:10px;z-index:5;width:30px;height:30px;padding:0;border:1px solid var(--border);border-radius:8px;background:var(--canvas);color:var(--muted);cursor:pointer;font-size:15px;line-height:1;display:flex;align-items:center;justify-content:center}
.expand-btn:hover{background:var(--surface);color:var(--text)}
.chartbox.expanded,.tablewrap-shell.expanded{position:fixed;inset:16px;z-index:1000;margin:0;overflow:auto;background:var(--canvas);box-shadow:0 8px 40px rgba(0,0,0,.35);padding-top:48px}
.chartbox.expanded .chart{height:calc(100vh - 160px)!important}
.tablewrap-shell.expanded .tablewrap{max-height:calc(100vh - 100px)}
body.has-expanded{overflow:hidden}
@media print{.expand-btn{display:none!important}}

/* sticky-filterbar — filter bar stays visible while scrolling (Andy standing preference) */
.filterbar{position:sticky;top:0;z-index:30;background:var(--canvas);box-shadow:var(--shadow)}
@media print{.filterbar{position:static;box-shadow:none}}

/* hd-interactive-svg-charts — smaller font for wrapped category tick labels
   (see the skill of the same name); axis/gridline value text stays at the
   base .axis size. */
.chart svg .tick-label{font-size:10px}

/* interactive-data-tables — numbered rows, sortable headers, download menu,
   two-directional scroll with frozen header row + first two columns. See
   the skill of the same name. */
.tablewrap table .rownum{color:var(--muted);width:1%;white-space:nowrap;text-align:right;padding-right:10px!important;font-variant-numeric:tabular-nums}
.tablewrap table th.sortable{cursor:pointer;user-select:none}
.tablewrap table th.sortable:hover{color:var(--text)}
.tablewrap table .sort-arrow{display:inline-block;margin-left:5px;font-size:10px;opacity:.4}
.tablewrap table .sort-arrow.active{opacity:1;color:var(--blue)}
/* frozen header row (top) */
.tablewrap table thead th{position:sticky;top:0;z-index:4}
/* frozen first two columns (row number + the row's label) while scrolling
   horizontally — only matters on wide tables, harmless otherwise */
.tablewrap table th:nth-child(1),.tablewrap table td:nth-child(1){position:sticky;left:0;z-index:2;min-width:36px;max-width:44px}
.tablewrap table th:nth-child(2),.tablewrap table td:nth-child(2){position:sticky;left:40px;z-index:2}
.tablewrap table td:nth-child(1),.tablewrap table td:nth-child(2){background:var(--canvas)}
.tablewrap table th:nth-child(1),.tablewrap table th:nth-child(2){background:var(--surface);z-index:5}

.table-toolbar{display:flex;justify-content:flex-end;align-items:center;gap:8px;padding:4px 46px 8px 2px}
.dl-wrap{position:relative}
.dl-btn{min-height:34px;padding:6px 14px;font-size:12px}
.dl-menu{position:absolute;right:0;top:calc(100% + 4px);background:var(--canvas);border:1px solid var(--border);border-radius:8px;box-shadow:var(--shadow);z-index:15;min-width:150px;overflow:hidden}
.dl-menu[hidden]{display:none}
.dl-menu button{display:block;width:100%;text-align:left;padding:10px 14px;background:none;border:none;color:var(--text);cursor:pointer;font-size:13px}
.dl-menu button:hover{background:var(--surface)}

/* Expand/enlarge button on a table sits on the shell's outer border corner
   (above the toolbar/header band reserved by .table-toolbar's right padding
   above), never overlapping column titles — chart boxes keep the original
   inside-corner placement since they don't have this toolbar band. */
.tablewrap-shell{padding-top:4px}
.tablewrap-shell .expand-btn{top:-2px;right:2px}
@media print{.table-toolbar{display:none!important}}
