/* KPI interface — one shared, compact layout system. */
:root {
  color-scheme:light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 13px;
  color:#38291f;
  background:#ffffff;
  --surface:#ffffff;
  --surface-raised:#ffffff;
  --line: #27374b;
  --muted:#38291f;
  --accent: #71bfff;
  --radius: 9px;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color:inherit; text-decoration: none; }
button, input, select { font: inherit; }
button, summary, a, input, select { -webkit-tap-highlight-color: transparent; }
a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible,
select:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.layout { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100svh; overflow-y: auto;
  padding: 20px 12px; border-right:1px solid var(--line); background:#ffffff;
}
.logo { font-size: 24px; font-weight: 900; letter-spacing: -1.5px; padding: 0 8px; }
.logo span { color:var(--accent); }
.logo small { color:var(--muted); font-size: 10px; letter-spacing: 1.6px; margin-left: 8px; }
.sidebar-navigation > summary { display: none; }
.kpi-side-nav { display: flex; flex-direction: column; gap: 3px; margin-top: 20px; }
.kpi-nav-group { min-width: 0; border-bottom:1px solid #e5d5c8; }
.nav-group-toggle { font-size: 11px; color:#38291f; font-weight: 650; line-height: 1.5; padding: 10px 8px; cursor: pointer; border-radius:5px; }
.nav-group-toggle::marker { color:#9b4308; }
.nav-group-toggle:hover { background:var(--surface-raised); }
.nav-group-links { display: flex; flex-direction: column; gap: 2px; padding: 0 0 8px; }
.kpi-side-nav a { display: block; padding: 8px 10px; border-radius:6px; color:#38291f; font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
.kpi-side-nav a:hover { color:#38291f; background:#ffffff; }
.kpi-side-nav a.nav-selected { background:#fff5ec; color:#38291f; box-shadow: inset 2px 0 #71bfff; font-weight: 650; }
.kpi-nav-group:not([open]) > .nav-group-links { display: none; }
.aside-foot { margin-top: 28px; padding: 0 8px; font-size: 10px; line-height: 1.8; color:#38291f; }
.main { width: 100%; min-width: 0; max-width: 1920px; margin: 0 auto; padding: 20px 24px 40px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.topbar > div:first-child { min-width: 0; }
.eyebrow { color:var(--muted); font-size: 11px; line-height: 1.4; letter-spacing: .3px; }
.topbar h1 { font-size: 22px; line-height: 1.35; letter-spacing: -.5px; margin: 3px 0 0; overflow-wrap: anywhere; }
.topbar p { color:var(--muted); margin: 4px 0 0; font-size: 12px; }
.actions, .langs { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
.actions { flex-shrink: 0; }
.actions form { margin: 0; }
.langs a, .smallbtn { display: inline-flex; align-items: center; justify-content: center; min-height: 32px; padding: 6px 9px; border:1px solid var(--line); border-radius:6px; background:var(--surface); font-size: 11px; color:#38291f; }
.langs a.selected { background:#fff5ec; border-color:#e5d5c8; color:#38291f; }
.smallbtn:hover, .langs a:hover { border-color:#e5d5c8; color:#38291f; }
.panel { min-width: 0; border:1px solid var(--line); border-radius:var(--radius); background:var(--surface); padding: 15px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.panel-heading h2 { font-size: 14px; font-weight: 650; line-height: 1.5; margin: 0; overflow-wrap: anywhere; }
.panel-heading small, .caption { color:var(--muted); font-size: 11px; line-height: 1.65; }
.caption { margin: 6px 0; }
.primary { display: inline-flex; align-items: center; justify-content: center; min-height: 34px; padding: 8px 15px; border:1px solid #e5d5c8; border-radius:6px; background:#fff0e5; color:#38291f; font-weight: 650; }
.primary:hover { background:#fff0e5; }
.period-panel { padding: 11px 14px; margin-bottom: 14px; background:#ffffff; }
.period-form { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; }
.period-form label { display: flex; flex-direction: column; gap: 4px; color:var(--muted); font-size: 11px; }
.period-form label:first-of-type { min-width: 160px; }
.period-form input, .period-form select { height: 34px; min-width: 0; max-width: 100%; padding: 6px 9px; background:#ffffff; border:1px solid #e5d5c8; color:#38291f; border-radius:5px; }
.period-form input { width: 145px; }
.period-panel > .caption { margin: 6px 0 0; font-size: 10px; }
.metric-grid, .insight-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; margin: 0 0 13px; }
.metric-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.metric, .insight { min-width: 0; border:1px solid var(--line); border-radius:7px; padding: 11px 13px; background:#ffffff; }
.metric-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.metric-head > span, .insight > span { display: block; color:#38291f; font-size: 11px; line-height: 1.45; }
.metric-icon { color:#9b4308; font-size: 13px; font-weight: 500; flex-shrink: 0; }
.metric strong, .insight > strong { display: block; margin-top: 6px; font-size: 22px; line-height: 1.25; letter-spacing: -.35px; font-weight: 650; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.metric small, .insight small { font-size: 10px; font-weight: 500; color:var(--muted); letter-spacing: 0; }
.metric > small { display: inline-block; margin-top: 2px; }
.more-metrics { margin: 0 0 13px; border-bottom:1px solid var(--line); }
.more-metrics > summary { display: flex; align-items: center; gap: 8px; padding: 6px 2px 10px; font-size: 12px; color:#9b4308; cursor: pointer; }
.more-metrics > summary::before { content: '+'; display: inline-block; font-size: 15px; width: 14px; }
.more-metrics[open] > summary::before { content: '−'; }
.more-metrics > summary small { border-radius:4px; padding: 1px 6px; background:#ffffff; font-size: 10px; }
.more-metrics .insight-grid { margin-bottom: 12px; }
.method-notes { margin: 9px 0 14px; padding: 0 10px; border-left:2px solid #e5d5c8; }
.method-notes > summary { cursor: pointer; color:#38291f; font-size: 11px; line-height: 1.7; padding: 4px 0; }
.method-notes > summary small { margin-left: 7px; opacity: .75; }
.method-notes .caption { margin: 7px 0; max-width: 125ch; }
.section-title { margin: 19px 0 10px; }
.section-title h2 { margin: 0; font-size: 15px; line-height: 1.5; }
.dashboard-section { margin-top: 14px; scroll-margin-top: 14px; }
.charts-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; margin: 12px 0 15px; }
.charts-grid > .panel { width: 100%; margin: 0; }
.panel.full { grid-column: 1 / -1; }
.chart-box { height: 210px; min-width: 0; position: relative; }
.chart-box.short { height: 190px; }
.chart-box canvas { display: block; width: 100%; height: 100%; }
.dashboard-section > .panel { margin: 12px 0; }
.network-chart { overflow: hidden; padding: 13px; }
.network-chart-box { position: relative; min-width: 0; height: 205px; }
.network-hbar { height: var(--chart-height, 220px); }
.network-heatmap { height: 220px; }
.network-chart-box canvas { display: block; width: 100%; height: 100%; touch-action: pan-y; }
.network-tooltip { position: absolute; z-index: 5; pointer-events: none; max-width: calc(100% - 12px); padding: 8px 10px; border:1px solid #e5d5c8; border-radius:6px; background:#081321f7; color:#38291f; font-size: 11px; line-height: 1.6; white-space: pre-line; overflow-wrap: anywhere; box-shadow: 0 5px 15px #0005; }
.network-legend, .payment-chart-legend { display: flex; flex-wrap: wrap; gap: 5px 12px; margin: 6px 0 0; font-size: 10px; line-height: 1.6; }
.network-legend span { color:var(--series-color); }
.network-data { border-top:1px solid var(--line); margin-top: 9px; }
.network-data summary { cursor: pointer; color:#9b4308; font-size: 10px; padding: 8px 0 0; }
.network-data .table-scroll { max-height: 250px; margin-top: 8px; }
.site-tables { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 12px; margin: 14px 0; }
.site-tables > .table-wide, .site-tables > .site-table:last-child:nth-child(odd) { grid-column: 1 / -1; }
.site-table { margin: 0; }
.site-tables > .site-release { grid-column: 1 / -1; }
.table-scroll { overflow: auto; max-width: 100%; max-height: 360px; scrollbar-width: thin; scrollbar-color: #4b6681 #122031; border-radius:4px; }
.table-scroll[data-scrollable="true"] { border-bottom:2px solid #e5d5c8; }
.table-scroll:focus-visible { outline-offset: 1px; }
table { width: 100%; border-collapse:separate; border-spacing:0; text-align: left; white-space: nowrap; font-size: 12px; }
th, td { padding: 9px 10px; border-bottom:1px solid #e5d5c8; vertical-align: middle; line-height: 1.5; }
th { position: sticky; top: 0; z-index: 2; background:#ffffff; color:#38291f; font-size: 10px; font-weight: 600; }
td { color:#38291f; font-variant-numeric: tabular-nums; }
tbody tr:hover td { background:#ffffff; }
tr:last-child td { border-bottom:0; }
td.numeric { text-align: right; }
.site-table td { overflow-wrap: anywhere; }
.notice, .viewer-notice { border:1px solid #775f35; background:#ffffff; color:#665144; padding: 10px 12px; border-radius:6px; margin: 10px 0; font-size: 12px; line-height: 1.6; }
.notice small { display: block; margin-top: 4px; }
.legend-request { color:#9b4308; }.legend-approved { color:#665144; }.legend-rejected { color:#ef83a8; }
.center-payment-ledger { margin: 14px 0; }
.center-payment-table { min-width: 900px; }
.center-payment-table td { vertical-align: top; font-size: 11px; }
.center-payment-table td:first-child, .center-payment-table th:first-child { position: sticky; left: 0; background:#ffffff; z-index: 1; }
.center-payment-table th:first-child { z-index: 3; background:#ffffff; }
.center-payment-ledger .table-scroll { max-height: 480px; }
.payment-account strong { display: block; max-width: 150px; overflow-wrap: anywhere; white-space: normal; font-size: 12px; }
.center-payment-table small { display: block; font-size: 10px; color:var(--muted); margin-top: 3px; }
.center-payment-table time { display: block; }
.center-payment-table time > span { display: block; color:var(--muted); font-size: 10px; }
.payment-license { white-space: normal; min-width: 130px; max-width: 190px; }
.payment-state { display: inline-block; padding: 3px 7px; border-radius:4px; background:#fff5ec; color:#9b4308; font-size: 10px; line-height: 1.5; }
.payment-state-confirmed { background:#fff5ec; color:#665144; }
.payment-state-cancelled { background:#ffffff; color:#665144; }
.payment-state-review, .payment-state-other { background:#fff5ec; color:#665144; }
.payment-reason-details { margin-top: 5px; max-width: 200px; }
.payment-reason-details > summary { cursor: pointer; color:#38291f; font-size: 10px; }
.payment-reason-details p { white-space: normal; overflow-wrap: anywhere; margin: 5px 0 0; font-size: 11px; line-height: 1.5; }
.payment-pagination { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 10px 0 0; color:var(--muted); font-size: 11px; }
.payment-pagination > div { display: flex; gap: 6px; }
.payment-pagination a, .payment-pagination .disabled { display: inline-block; padding: 5px 10px; border:1px solid #e5d5c8; border-radius:5px; }
.payment-pagination .disabled { opacity: .4; }
.center-payment-summary { margin: 12px 0; padding: 12px 14px; }
.center-payment-summary > summary { cursor: pointer; font-size: 12px; font-weight: 600; line-height: 1.6; }
.center-payment-summary > summary strong { display: inline-block; margin-left: 10px; font-variant-numeric: tabular-nums; color:#9b4308; }
.center-payment-summary[open] > summary { margin-bottom: 10px; }
.payment-amount-equation { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px 16px; padding: 8px 0; color:var(--muted); font-size: 11px; }
.payment-amount-equation strong { color:#38291f; font-size: 20px; }
.viewer-add-form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin: 14px 0 20px; }
.viewer-add-form label { display: flex; flex: 1 1 190px; flex-direction: column; gap: 6px; color:#38291f; font-size: 12px; }
.viewer-add-form input { min-width: 0; width: 100%; height: 36px; padding: 8px 10px; border:1px solid #e5d5c8; border-radius:5px; background:#ffffff; color:#38291f; }
.viewer-admin-panel h3 { margin: 18px 0 8px; font-size: 13px; }
.viewer-notice { border-color:#2d675d; background:#ffffff; color:#38291f; }
.login-wrap { min-height: 100svh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 370px; padding: 28px; border:1px solid #e5d5c8; border-radius:12px; background:var(--surface); }
.login-card .logo { padding: 0; }
.login-card h1 { margin: 25px 0 6px; font-size: 23px; }
.login-card p { color:var(--muted); line-height: 1.6; }
.login-card .langs { margin: 18px 0; }
.login-card label { display: block; margin-top: 14px; font-size: 12px; color:#38291f; }
.login-card input { display: block; width: 100%; margin-top: 6px; padding: 11px; border:1px solid #e5d5c8; border-radius:6px; background:#ffffff; color:#38291f; }
.login-card .primary { width: 100%; margin-top: 22px; min-height: 40px; }
.error { color:#665144 !important; }
@media (min-width: 1280px) { .charts-count-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1680px) {
  .main { padding: 24px 30px 45px; }
  .network-charts:not(.charts-count-4) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .insight-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1199px) {
  .layout { grid-template-columns: 200px minmax(0, 1fr); }
  .main { padding: 18px; }
  .metric-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .insight-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .network-chart-box { height: 210px; }
  .network-hbar { height: var(--chart-height, 220px); }
}
@media (max-width: 1000px) {
  .charts-grid, .site-tables { grid-template-columns: minmax(0, 1fr); }
  .site-tables > .site-table { grid-column: auto; }
  .insight-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { align-items: start; }
  .topbar h1 { font-size: 21px; }
}
@media (max-width: 760px) {
  .layout { display: block; }
  .sidebar { position: sticky; top: 0; z-index: 25; height: auto; overflow: visible; padding: 12px 14px; border-right:0; border-bottom:1px solid var(--line); }
  .sidebar .logo { font-size: 20px; padding: 0; }
  .sidebar-navigation > summary { display: block; position: absolute; top: 10px; right: 14px; border:1px solid #e5d5c8; padding: 5px 10px; border-radius:5px; color:#38291f; cursor: pointer; font-size: 12px; list-style: none; }
  .sidebar-navigation > summary::-webkit-details-marker { display: none; }
  .sidebar-navigation > summary::before { content: '☰ '; }
  .sidebar-navigation[open] > summary::before { content: '× '; }
  .sidebar-navigation-content { max-height: 65svh; overflow-y: auto; padding-top: 6px; }
  .kpi-side-nav { margin-top: 6px; }
  .nav-group-links { flex-direction: row; flex-wrap: wrap; gap: 3px; }
  .nav-group-links a { flex: 1 1 145px; }
  .aside-foot { display: none; }
  .main { padding: 15px 12px 28px; }
  .topbar { margin-bottom: 12px; flex-wrap: wrap; gap: 10px; }
  .topbar h1 { font-size: 20px; }
  .actions { margin-left: auto; }
  .metric-grid, .insight-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; }
  .metric, .insight { padding: 10px; }
  .metric strong, .insight > strong { font-size: 20px; }
  .metric-head > span, .insight > span { font-size: 11px; }
  .panel { padding: 12px; }
  .period-panel { padding: 10px 12px; }
  .period-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px 9px; }
  .period-form label:first-of-type { grid-column: 1; grid-row: 1; min-width: 0; }
  .period-form label:nth-of-type(2) { grid-column: 1; grid-row: 2; }
  .period-form label:nth-of-type(3) { grid-column: 2; grid-row: 2; }
  .period-form .primary { grid-column: 2; grid-row: 1; align-self: end; }
  .period-form input, .period-form select { width: 100%; height: 36px; }
  .period-form .primary { min-height: 36px; }
  .chart-box, .network-chart-box { height: 205px; }
  .network-hbar { height: var(--chart-height, 220px); }
  .network-heatmap { height: 220px; }
  .network-chart { padding: 11px; }
  .panel-heading h2 { font-size: 13px; }
  .table-scroll { max-height: 330px; }
  .center-payment-ledger .table-scroll { max-height: 400px; }
  th, td { padding: 8px 9px; }
  .viewer-add-form { display: grid; gap: 10px; }
  .viewer-add-form .primary { width: 100%; }
}
@media (max-width: 420px) {
  .topbar { align-items: center; }
  .topbar > div:first-child { flex: 1 1 130px; }
  .actions { gap: 3px; }
  .langs { gap: 3px; }
  .langs a, .smallbtn { padding: 5px 7px; font-size: 10px; min-height: 31px; }
  .topbar h1 { font-size: 18px; }
  .eyebrow { font-size: 10px; }
  .center-payment-summary > summary strong { margin: 2px 0 0 12px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
@media print {
  .sidebar, .actions, .period-form .primary, .network-data, .payment-pagination { display: none; }
  .layout { display: block; }.main { max-width: none; padding: 0; }.panel, .metric, .insight { break-inside: avoid; }
  .table-scroll { overflow: visible; max-height: none; }
}
.site-tables:empty { display: none; }
.site-tables > .section-title, .site-tables > .insight-grid { grid-column: 1 / -1; }
.skip-link { position: fixed; top: -80px; left: 12px; z-index: 100; padding: 9px 14px; border-radius:5px; background:#e1f1ff; color:#824018; }
.skip-link:focus { top: 10px; }
.empty-charts { margin: 10px 0 14px; border:1px dashed #e5d5c8; border-radius:6px; padding: 9px 12px; }
.empty-charts > summary { font-size: 11px; color:var(--muted); cursor: pointer; }
.empty-charts > summary small { margin-left: 7px; color:#9b4308; }
@media (min-width: 1200px) { .insight-grid.metrics-count-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1360px) { .insight-grid.metrics-count-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

/* Report publishing */
.report-form { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:10px; align-items:end; margin:14px 0; }
.report-form label { display:flex; flex-direction:column; gap:6px; min-width:0; color:#38291f; font-size:12px; }
.report-form input,.report-form select { width:100%; min-width:0; }
.report-form .report-enabled { flex-direction:row; align-items:center; padding-bottom:10px; }
.report-enabled input { width:auto; }
.report-schedule { border-top:1px solid #e5d5c8; padding:14px 0; overflow-wrap:anywhere; }
.report-schedule h3 { font-size:14px; margin:0; }
.report-schedule .actions { margin-top:10px; flex-wrap:wrap; }
@media(max-width:480px){.report-form{grid-template-columns:minmax(0,1fr);} .report-schedule .panel-heading{flex-wrap:wrap;}}

.report-page > .panel { margin-bottom:12px; }
.report-form input:not([type="checkbox"]), .report-form select { min-height:36px; border:1px solid #e5d5c8; border-radius:6px; background:#ffffff; color:#38291f; padding:8px 10px; font:inherit; color-scheme:light; }
.report-form input:focus-visible, .report-form select:focus-visible { outline:2px solid #53b6ff; outline-offset:2px; }
