:root{--navy:#06234B;--navy2:#164E82;--bg:#F4F7FA;--card:#fff;--border:#DCE5EF;--teal:#009B98;--orange:#FF8700;--green:#16A34A;--red:#DC2626;--muted:#5B6B7F;--text:#1B2B41;--soft-orange:#FFF4E5;--soft-yellow:#FFF1D6;--radius:14px;--gap:14px}
[hidden]{display:none !important}
*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{margin:0;background:var(--bg);color:var(--text);font-family:Inter,Arial,"Segoe UI",Roboto,sans-serif;font-size:14px;line-height:1.45;min-height:100vh;display:flex;flex-direction:column}
.sprite{position:absolute;width:0;height:0;overflow:hidden}
.ico{width:18px;height:18px;flex:none;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
button,select,input{font:inherit}
:focus-visible{outline:3px solid #7CC7F5;outline-offset:2px}

.app-header{display:flex;align-items:center;gap:24px;padding:14px 28px;color:#fff;background:linear-gradient(90deg,var(--navy),var(--navy2))}
.brand{display:flex;align-items:center;gap:10px}
.logo{width:42px;height:42px}
.brand-text{display:flex;flex-direction:column;line-height:1.05}
.brand-text strong{font-size:22px;letter-spacing:.5px}
.brand-text span{font-size:12px;opacity:.85}
.titles{flex:1;text-align:center}
.titles h1{margin:0;font-size:24px;letter-spacing:.8px}
.titles p{margin:4px 0 0;font-size:13px;opacity:.9}

.page{width:100%;max-width:1680px;margin:0 auto;padding:14px 20px 24px;flex:1}
.toolbar{display:flex;flex-wrap:wrap;gap:12px;align-items:center;justify-content:space-between;background:var(--card);border:1px solid var(--border);border-radius:var(--radius);padding:10px 14px}
.filters{display:grid;grid-template-columns:repeat(4,minmax(150px,1fr));gap:12px;flex:1 1 640px}
.field{display:flex;align-items:center;gap:8px;border:1px solid var(--border);border-radius:10px;padding:6px 10px;background:#FAFCFE;color:var(--navy2);min-width:0}
.field .lbl{font-size:12px;color:var(--muted);white-space:nowrap}
.field select{flex:1;min-width:0;border:0;background:transparent;color:var(--navy);font-weight:600;cursor:pointer;text-overflow:ellipsis}
.field select:disabled{cursor:not-allowed;opacity:.6}
.actions{display:flex;flex-wrap:wrap;gap:8px}
.btn{display:inline-flex;align-items:center;gap:6px;border:1px solid var(--border);background:#fff;color:var(--navy);border-radius:10px;padding:8px 14px;font-weight:600;cursor:pointer}
.btn:hover:not(:disabled){background:#EEF5FB}
.btn.primary{background:var(--teal);border-color:var(--teal);color:#fff}
.btn.primary:hover:not(:disabled){background:#008785}
.btn:disabled{opacity:.5;cursor:not-allowed}

.status-row{display:flex;flex-wrap:wrap;align-items:center;gap:10px;margin:10px 2px;font-size:13px}
.pill{border-radius:999px;padding:3px 12px;font-weight:700;font-size:12px;border:1px solid transparent}
.pill-empty{background:#EEF2F6;color:var(--muted);border-color:var(--border)}
.pill-loading{background:#E5F1FB;color:var(--navy2)}
.pill-ok{background:#E3F6EA;color:#11753A}
.pill-cache{background:#E1F5F4;color:#00716F}
.pill-warn{background:#FFF1D6;color:#9A5B00}
.pill-error{background:#FDE7E7;color:#A61B1B}
.status-msg{color:var(--text)}
.source-info{color:var(--muted);margin-left:auto}
.banner{border-radius:10px;padding:10px 14px;margin:0 0 var(--gap);border:1px solid var(--border);display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.banner.warn{background:#FFF8E6;border-color:#F5D58A}
.banner.info{background:#EAF4FD;border-color:#B7D8F3}

.card{background:var(--card);border:1px solid var(--border);border-radius:var(--radius);padding:14px 16px;min-width:0}
.card-h{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:8px}
.card-h h2{margin:0;font-size:15px;color:var(--navy)}
.note{margin:6px 0 0;font-size:12px;color:var(--muted)}
.empty-state{text-align:center;padding:36px 20px}
.empty-state h2{margin:0 0 8px;color:var(--navy)}
.empty-state p{max-width:720px;margin:0 auto;color:var(--muted)}

.kpi-row{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:var(--gap);margin-bottom:var(--gap)}
.kpi{background:#fff;border:1px solid var(--border);border-radius:var(--radius);padding:12px 14px;display:flex;flex-direction:column;gap:4px;min-height:112px}
.kpi.accent{background:var(--soft-orange);border-color:#FFD9A8}
.kpi-top{display:flex;align-items:center;gap:8px;color:var(--muted);font-size:12.5px;font-weight:600}
.kpi-top .ico{color:var(--teal);width:20px;height:20px}
.kpi.accent .kpi-top .ico{color:var(--orange)}
.kpi-val{font-size:24px;font-weight:800;color:var(--navy);line-height:1.15;word-break:break-word}
.kpi-sub{font-size:12px;color:var(--muted)}
.kpi-sub.up{color:var(--red);font-weight:700}
.kpi-sub.down{color:var(--green);font-weight:700}

.analysis{display:grid;grid-template-columns:43fr 30fr 27fr;grid-template-areas:"trend donut ceo" "bar sum ceo";gap:var(--gap);margin-bottom:var(--gap)}
.a-trend{grid-area:trend}.a-donut{grid-area:donut}.a-ceo{grid-area:ceo}.a-bar{grid-area:bar}.a-sum{grid-area:sum}
.chart-box{position:relative;height:270px}
.chart-box canvas{max-width:100%}
.placeholder{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;height:100%;color:var(--muted);text-align:center;border:1px dashed var(--border);border-radius:10px;padding:10px}
.legend-mini{font-size:12px;color:var(--muted);display:flex;align-items:center;gap:6px}
.dot{display:inline-block;width:10px;height:10px;border-radius:50%}
.dot.hi{background:var(--orange)}.dot.lo{background:var(--green)}

.ceo-h{background:var(--soft-orange);margin:-14px -16px 10px;padding:12px 16px;border-radius:var(--radius) var(--radius) 0 0}
.ceo-h .ico{color:var(--orange);width:22px;height:22px}
.ceo-list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:12px}
.ceo-list li{border-left:4px solid var(--border);padding:2px 0 2px 10px}
.ceo-list li.up{border-color:var(--red)}.ceo-list li.down{border-color:var(--green)}.ceo-list li.neutral{border-color:var(--teal)}
.ceo-list strong{display:block;color:var(--navy);font-size:13px}
.ceo-list span{font-size:13px}

.table-wrap{overflow:auto;max-width:100%}
table{border-collapse:collapse;width:100%;font-variant-numeric:tabular-nums}
th,td{padding:7px 10px;border-bottom:1px solid var(--border);text-align:right;white-space:nowrap}
th:first-child,td:first-child{text-align:left}
thead th{background:var(--navy);color:#fff;position:sticky;top:0;z-index:2;font-size:12.5px}
thead th button{all:unset;cursor:pointer;display:inline-flex;gap:4px;align-items:center;color:#fff;font-weight:700}
thead th button:focus-visible{outline:2px solid #fff;outline-offset:2px}
tr.total td{background:var(--soft-yellow);font-weight:800;color:var(--navy)}
td.total-col{font-weight:700;background:#FBFDFF}
tr.total td.total-col{background:var(--soft-yellow)}
td.nodata{color:var(--muted)}
.pivot-wrap{max-height:560px}
.pivot-wrap table{min-width:1180px}
.pivot-wrap th:first-child,.pivot-wrap td:first-child{position:sticky;left:0;z-index:1;background:#fff;box-shadow:1px 0 0 var(--border)}
.pivot-wrap thead th:first-child{z-index:3;background:var(--navy)}
.pivot-wrap tr.total td:first-child{background:var(--soft-yellow)}
.pivot-card{margin-bottom:var(--gap)}
.a-sum .table-wrap{max-height:300px}

.app-footer{display:flex;justify-content:space-between;flex-wrap:wrap;gap:8px;padding:12px 28px;background:linear-gradient(90deg,var(--navy),var(--navy2));color:#fff;font-size:13px}

dialog{border:1px solid var(--border);border-radius:var(--radius);padding:0;width:min(900px,94vw);max-height:90vh;color:var(--text)}
dialog::backdrop{background:rgba(6,35,75,.45)}
.dlg-h{display:flex;justify-content:space-between;align-items:center;padding:12px 18px;background:var(--navy);color:#fff;position:sticky;top:0}
.dlg-h h2{margin:0;font-size:16px}
.dlg-b{padding:14px 18px 18px;overflow:auto;max-height:calc(90vh - 56px)}
.dlg-b h3{margin:16px 0 6px;font-size:14px;color:var(--navy)}
.dlg-b dl{display:grid;grid-template-columns:200px 1fr;gap:4px 12px;margin:0}
.dlg-b dt{color:var(--muted)}.dlg-b dd{margin:0;word-break:break-word}
.dlg-b ul{margin:4px 0;padding-left:20px}
.dlg-b .ok{color:#11753A;font-weight:700}.dlg-b .bad{color:#A61B1B;font-weight:700}.dlg-b .warn{color:#9A5B00;font-weight:700}
.dlg-b table th,.dlg-b table td{white-space:normal}

@media (max-width:1280px){.kpi-row{grid-template-columns:repeat(3,minmax(0,1fr))}.filters{grid-template-columns:repeat(2,minmax(150px,1fr))}}
@media (max-width:1100px){.analysis{grid-template-columns:1fr 1fr;grid-template-areas:"trend trend" "donut ceo" "bar sum"}}
@media (max-width:760px){
  .app-header{flex-direction:column;align-items:flex-start;padding:12px 16px;gap:8px}.titles{text-align:left}.titles h1{font-size:18px}
  .page{padding:10px}.kpi-row{grid-template-columns:repeat(2,minmax(0,1fr))}
  .analysis{grid-template-columns:1fr;grid-template-areas:"trend" "donut" "ceo" "bar" "sum"}
  .filters{grid-template-columns:1fr}.source-info{margin-left:0}.chart-box{height:250px}
  .dlg-b dl{grid-template-columns:1fr}
}
@media (max-width:420px){.kpi-row{grid-template-columns:1fr}}
/* Reference dashboard redesign */
:root{--navy:#081e46;--navy2:#154679;--bg:#fafbfd;--radius:12px;--gap:10px;--soft-yellow:#ffdfad}
body{font-family:Arial,"Segoe UI",sans-serif;line-height:1.3}.app-header{position:relative;isolation:isolate;overflow:hidden;min-height:70px;padding:8px 32px;border-radius:0 0 18px 18px;background:linear-gradient(110deg,#061b40,#174d85)}.brand{border-right:2px solid white;padding-right:25px}.logo{width:48px;height:48px}.brand-text strong{font-size:28px}.brand-text span{font-size:19px;font-weight:bold}.titles{text-align:left}.titles h1{font-size:clamp(22px,2.2vw,36px);letter-spacing:0}.titles p{font-size:17px;color:#c8d9ec;margin:2px 0}.header-art{position:absolute;right:0;bottom:0;width:28%;height:100%;z-index:-1;background:linear-gradient(135deg,transparent 20%,#2979b955 20%,#2979b955 29%,transparent 29%,transparent 40%,#2979b955 40%,#2979b955 50%,transparent 50%)}.header-art:after{content:"";position:absolute;right:-35px;bottom:-40px;width:240px;height:75px;background:#ff9100;transform:rotate(-25deg);border-radius:25px}
.page{max-width:1920px;padding:8px 15px 12px}.toolbar{display:block;padding:0;background:none;border:0}.filters{background:#edf3f9;padding:6px 15px;border-radius:9px;gap:24px;grid-template-columns:repeat(4,minmax(0,1fr))}.field{border:0;background:none;padding:0;gap:10px}.field .lbl{font-size:14px;color:var(--navy);font-weight:700}.field .ico{width:23px;height:23px;color:var(--navy)}.field select{background:#f8fafc;border:1px solid #b0c1d5;border-radius:5px;padding:5px 9px;font-size:13px}.actions{justify-content:flex-end;margin-top:5px;gap:6px}.btn{font-size:12px;padding:4px 9px;border-radius:6px}.status-row{margin:4px 2px 7px;font-size:11px}.pill{font-size:10px;padding:2px 8px}
.kpi-row{grid-template-columns:1.3fr repeat(3,1fr) 1.12fr 1.08fr;gap:12px}.kpi{min-height:100px;padding:10px 12px;background:linear-gradient(135deg,#fff,#f3f6f9);gap:5px}.kpi.accent{background:linear-gradient(135deg,#fff8ef,#fbf1e3)}.kpi:first-child{border-left:5px solid #ff8700}.kpi-top{font-size:clamp(11px,.94vw,15px);color:var(--navy);font-weight:700}.kpi-top .ico{width:22px;height:22px}.kpi-val{font-size:clamp(20px,2vw,34px);padding-left:30px;letter-spacing:-.6px}.kpi-sub{font-size:11px;padding-left:30px}
.analysis{grid-template-columns:minmax(0,43fr) minmax(0,30fr) minmax(0,27fr);gap:10px;align-items:stretch}.card{padding:8px 12px;background:linear-gradient(150deg,#fff,#f8fafc)}.card-h{margin-bottom:5px;min-height:23px}.card-h h2{display:flex;align-items:center;gap:8px;font-size:clamp(13px,1.12vw,18px);line-height:1.2}.card-h h2 .ico{color:#006b77;width:22px;height:22px}.unit{white-space:nowrap;font-size:11px;font-style:italic}.chart-box,.a-donut .chart-box{height:182px}.a-bar .chart-box{height:168px}.note{font-size:10px;margin:3px 0 0}.a-ceo{background:linear-gradient(145deg,#fff,#fffaf4);border-color:#f0e0ca}.ceo-h{justify-content:flex-start;margin:-8px -12px 6px;padding:9px 12px;background:#fff0df}.ceo-list{gap:0}.ceo-list li{display:flex;align-items:flex-start;gap:9px;border-left:0;padding:9px 0;border-bottom:1px solid #f0e8dd}.ceo-list li:last-child{border-bottom:0}.insight-icon{display:grid;place-items:center;width:37px;height:37px;background:#fff0df;border-radius:8px;flex:none;color:#f58200}.insight-icon .ico{width:23px;height:23px}.insight-copy{min-width:0}.ceo-list strong{font-size:14px;margin-bottom:3px}.ceo-list span{font-size:12px}.ceo-list li.up strong{color:#bc1420}
.table-wrap{border-radius:6px}th,td{padding:2px 6px;font-size:11px;line-height:1.25;border:1px solid #d7dce3}thead th{background:linear-gradient(#073861,#09294c);font-size:11px;text-align:center}thead th:first-child{text-align:center}tbody tr:nth-child(even):not(.total){background:#f3f5f7}td.total-col{background:#fff0da}.a-sum .table-wrap{max-height:240px}.a-sum table{min-width:300px}.pivot-card{padding:0 12px 8px;margin-bottom:8px;overflow:hidden}.pivot-card .card-h{background:linear-gradient(90deg,#07446d,#071f48);color:white;margin:0 -12px 5px;padding:5px 12px;gap:10px;flex-wrap:wrap}.pivot-card .card-h h2{color:white;font-size:15px}.pivot-card .card-h .note{color:white;margin:0 0 0 auto;font-style:italic;font-size:11px}.pivot-wrap table{min-width:1120px;table-layout:fixed}.pivot-wrap th:first-child{width:13%}.pivot-wrap th:last-child{width:9%}.pivot-wrap td:not(:first-child){text-align:center}.pivot-wrap th,.pivot-wrap td{padding:1px 5px;font-size:11px;line-height:1.2}.pivot-wrap tr.total td{font-size:12px}.app-footer{padding:7px 25px;background:linear-gradient(100deg,#071e45,#103b70)}.app-footer span:last-child{font-weight:700;font-size:16px}
@media(min-width:1450px){.chart-box,.a-donut .chart-box{height:190px}.a-bar .chart-box{height:177px}.a-sum th,.a-sum td,.pivot-wrap th,.pivot-wrap td{font-size:12px}.ceo-list span{font-size:13px}}
@media(max-width:1200px){.kpi-row{grid-template-columns:repeat(3,minmax(0,1fr))}.filters{grid-template-columns:repeat(2,minmax(0,1fr))}.analysis{grid-template-columns:1fr 1fr;grid-template-areas:"trend trend" "donut ceo" "bar sum"}.chart-box,.a-donut .chart-box,.a-bar .chart-box{height:230px}.pivot-card .card-h .note{margin-left:0}}
@media(max-width:760px){.app-header{padding:12px 15px;gap:8px}.brand{border:0;padding:0}.header-art{opacity:.3}.page{padding:8px}.filters{gap:8px;padding:8px;grid-template-columns:1fr}.kpi-row{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.kpi-val,.kpi-sub{padding-left:0}.analysis{grid-template-columns:1fr;grid-template-areas:"trend" "donut" "ceo" "bar" "sum"}.card-h h2{font-size:15px}.pivot-card .card-h h2{font-size:14px}}
@media(max-width:380px){.kpi-row{grid-template-columns:1fr}}

/* Unified filter and action toolbar: one row on desktop, responsive on narrow screens. */
.toolbar{display:flex;flex-wrap:nowrap;align-items:center;justify-content:space-between;gap:12px;background:#edf3f9;border:1px solid var(--border);border-radius:9px;padding:7px 12px}
.toolbar .filters{display:grid;flex:1 1 auto;min-width:0;grid-template-columns:minmax(0,.8fr) minmax(0,.9fr) minmax(0,1.15fr) minmax(0,1.25fr);gap:10px;padding:0;background:transparent}
.toolbar .field{min-width:0;gap:6px}
.toolbar .field .lbl{white-space:nowrap;font-size:12px}
.toolbar .field .ico{width:18px;height:18px;flex-shrink:0}
.toolbar .field select{min-width:0;width:100%;flex:1 1 0;padding:5px 6px;height:34px}
.toolbar .actions{flex:0 0 auto;flex-wrap:nowrap;align-items:center;gap:6px;margin:0}
.toolbar .btn{white-space:nowrap;height:34px;padding:5px 8px;gap:5px}
@media(max-width:1100px){.toolbar{flex-wrap:wrap}.toolbar .filters{flex:1 1 100%;grid-template-columns:repeat(4,minmax(0,1fr))}.toolbar .actions{margin-left:auto}}
@media(max-width:760px){.toolbar .filters{grid-template-columns:repeat(2,minmax(0,1fr))}.toolbar .actions{flex:1 1 100%;flex-wrap:wrap;justify-content:flex-end}}
@media(max-width:480px){.toolbar .filters{grid-template-columns:1fr}.toolbar .actions .btn{flex:1 1 auto;justify-content:center}}
