:root {
  color-scheme: dark;
  --bg: #0b1220;
  --sidebar: #101d31;
  --surface: #111e32;
  --surface-2: #15243a;
  --surface-3: #1a2c46;
  --border: #263a55;
  --text: #edf4ff;
  --muted: #91a5be;
  --blue: #4e98ff;
  --blue-2: #2676e7;
  --green: #32c9a4;
  --red: #ff6674;
  --orange: #ffad6a;
  --shadow: 0 12px 32px rgba(0, 0, 0, .14);
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
  min-height: 100vh;
  margin: 0;
  padding-bottom: var(--footer-height, 56px);
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 Roboto, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.app-shell { display: flex; min-height: calc(100vh - var(--footer-height, 56px)); }
.sidebar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex: 0 0 208px;
  flex-direction: column;
  height: calc(100vh - var(--footer-height, 56px));
  border-right: 1px solid #29405f;
  background: linear-gradient(165deg, #172b46 0%, #101d31 62%, #102039 100%);
}
.brand { padding: 24px 18px 26px; text-align: center; }
.brand-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 76px;
  padding: 9px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.brand-logo img { display: block; width: 100%; height: auto; max-height: 62px; object-fit: contain; }
.brand p { margin: 13px 0 0; color: #bacde4; font-size: 10px; font-weight: 800; letter-spacing: .2em; }
.side-nav { display: flex; flex-direction: column; gap: 5px; padding: 10px 8px; }
.side-link {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 45px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #b6c6db;
  font-weight: 550;
  transition: background .2s, color .2s;
}
.side-link:hover { background: #1b3353; color: #fff; }
.side-link.is-active { border-color: #33619a; background: #234875; color: #fff; box-shadow: inset 3px 0 var(--blue); }
.side-icon { display: grid; flex: 0 0 25px; place-items: center; color: #a8c6ed; font-size: 23px; line-height: 1; }
.side-link.is-active .side-icon { color: #fff; }
.side-divider { height: 1px; margin: 13px 14px; background: #34506d; }

.main-shell { display: flex; flex: 1; flex-direction: column; min-width: 0; min-height: calc(100vh - var(--footer-height, 56px)); }
.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  min-height: 94px;
  padding: 14px 24px 17px;
  border-bottom: 1px solid var(--border);
  background: #0f1b2d;
}
.title-wrap { display: flex; align-items: center; gap: 12px; min-width: 280px; }
.eyebrow { margin: 0 0 3px; color: #71aeff; font-size: 9px; font-weight: 800; letter-spacing: .17em; }
h1 { margin: 0; font-size: 30px; line-height: 1.1; letter-spacing: -.04em; }
.subtitle { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.menu-button { display: none; border: 0; background: transparent; color: #fff; font-size: 23px; }
.filters { display: flex; align-items: end; justify-content: flex-end; gap: 9px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 5px; color: #a9bdd6; font-size: 10px; font-weight: 650; white-space: nowrap; }
.field select, .field input { width: 100%; min-width: 0; height: 37px; padding: 0 28px 0 10px; border: 1px solid #344865; border-radius: 6px; outline: none; background: #17263c; color: var(--text); }
.field select:focus, .field input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px #4e98ff2b; }
.field-season { width: 83px; }
.field-umpire { width: 122px; }
.field-team { width: 107px; }
.field-extra { width: 100px; }
.field-date { width: 280px; }
.date-range-inputs { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 5px; }
.date-range-inputs label { min-width: 0; }
.field .date-range-inputs input { width: 100%; padding: 0 4px; font-size: 10px; color-scheme: dark; }
.date-range-separator { color: #a9bdd6; font-size: 10px; }
.field-date .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.field[hidden] { display: none !important; }
.export-button { height: 37px; margin-bottom: 0; padding: 0 15px; border: 1px solid #4f9aff; border-radius: 6px; background: #2679e9; color: #fff; font-weight: 700; white-space: nowrap; }
.export-button:hover { background: #3989f3; }

.tabbar { display: flex; align-items: center; justify-content: space-between; min-height: 57px; padding: 0 24px; border-bottom: 1px solid var(--border); background: #101c2e; }
.tabs { display: flex; align-self: stretch; align-items: stretch; gap: 24px; }
.tab { display: flex; align-items: center; gap: 10px; padding: 0 16px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: #a8bdd5; font-size: 14px; font-weight: 650; white-space: nowrap; }
.tab i { font-size: 15px; }
.tab:hover { color: #fff; }
.tab.is-active { border-bottom-color: var(--blue); color: #75b3ff; }
.tagline { margin: 0; color: #71849f; font-size: 10px; font-weight: 800; letter-spacing: .28em; white-space: nowrap; }
.dashboard { flex: 1; min-width: 0; padding: 20px 24px 28px; }
.cards-grid { display: grid; gap: 12px; }
.cards-grid.overview, .cards-grid.context { grid-template-columns: repeat(12, minmax(0, 1fr)); }
.cards-grid.zone { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cards-grid.context .card[data-size="quarter"] { grid-column: span 4; }
.card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 235px;
  padding: 15px 16px;
  border: 1px solid #273b57;
  border-radius: 8px;
  background: linear-gradient(160deg, #15243a, #122034);
  box-shadow: var(--shadow);
}
.card:hover { border-color: #355476; }
.card[data-size="quarter"] { grid-column: span 3; }
.card[data-size="third"], .card[data-size="sixth"] { grid-column: span 4; }
.card[data-size="half"] { grid-column: span 6; }
.card.metric { min-height: 180px; }
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 7px; margin-bottom: 10px; }
.card-title { margin: 0; font-size: 15px; font-weight: 750; line-height: 1.25; letter-spacing: -.02em; }
.card-description { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.card-description[hidden] { display: none; }
.info-button { display: grid; flex: 0 0 18px; width: 18px; height: 18px; padding: 0; place-items: center; border: 1px solid #7d95b2; border-radius: 50%; background: transparent; color: #a8c2e3; font-size: 11px; }
.info-button:hover { border-color: var(--blue); color: var(--blue); }
.metric-body { display: flex; flex: 1; align-items: center; gap: 16px; }
.metric-ring { display: grid; flex: 0 0 112px; width: 112px; height: 112px; place-items: center; border: 9px solid #274362; border-top-color: var(--blue); border-right-color: var(--blue); border-radius: 50%; background: #132238; color: #b9d6f8; font-size: 24px; font-weight: 800; }
.metric-ring.green { border-top-color: var(--green); border-right-color: var(--green); }
.metric-ring.cyan { border-top-color: #56b8e8; border-right-color: #56b8e8; }
.metric-list { display: grid; flex: 1; gap: 11px; margin: 0; }
.metric-list div { display: flex; justify-content: space-between; gap: 8px; }
.metric-list dt { color: var(--muted); font-size: 11px; }
.metric-list dd { margin: 0; color: #edf4ff; font-size: 12px; font-weight: 750; }
.error-pair { display: grid; flex: 1; grid-template-columns: 1fr 1fr; gap: 12px; }
.error-stat { padding: 8px 9px 8px 12px; border-left: 4px solid var(--red); border-radius: 4px; background: #1e293c; }
.error-stat:last-child { border-color: var(--orange); }
.error-stat span { display: block; color: var(--muted); font-size: 11px; }
.error-stat strong { display: block; margin: 5px 0; color: var(--text); font-size: 25px; line-height: 1; }
.error-stat small { color: var(--muted); font-size: 10px; }
.canvas-slot { position: relative; display: flex; flex: 1; align-items: center; justify-content: center; min-height: 145px; overflow: hidden; border: 1px dashed #38516e; border-radius: 6px; background: linear-gradient(#ffffff08 1px, transparent 1px), linear-gradient(90deg, #ffffff08 1px, transparent 1px), #101c2d; background-size: 34px 34px, 34px 34px, auto; }
.canvas-slot::before { position: absolute; inset: 14px 16px 20px 22px; border-bottom: 1px solid #49617f; border-left: 1px solid #49617f; content: ""; opacity: .7; }
.slot-label { position: relative; z-index: 1; padding: 7px 10px; border: 1px solid #355477; border-radius: 5px; background: #13253acc; color: #8fb8e9; font-size: 11px; font-weight: 700; text-align: center; }
.segmented { display: flex; gap: 2px; margin-bottom: 10px; padding: 3px; border-radius: 6px; background: #1b2a40; }
.segmented button { flex: 1; padding: 5px 3px; border: 0; border-radius: 4px; background: transparent; color: #9eb3ce; font-size: 10px; }
.segmented button.is-active { background: #287be9; color: #fff; }
.table-body { max-width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.data-table th { background: #1a2c44; color: #a8bdd6; font-weight: 700; text-align: left; }
.data-table th, .data-table td { padding: 6px 7px; border-bottom: 1px solid #2a3c54; }
.data-table td:last-child { color: #d7eaff; font-weight: 750; }
.data-table tr:last-child td { border-bottom: 0; }
.card-footer { display: flex; align-items: center; justify-content: flex-end; min-height: 18px; margin-top: 9px; }
.text-link { padding: 0; border: 0; background: transparent; color: #73b3ff; font-size: 11px; font-weight: 700; }
.text-link:hover { text-decoration: underline; }

.toast { position: fixed; right: 22px; bottom: 20px; z-index: 20; max-width: 340px; padding: 11px 15px; transform: translateY(10px); border: 1px solid #3c648d; border-radius: 7px; background: #1b3553; color: #e8f3ff; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .2s; }
.toast.is-visible { transform: none; opacity: 1; }
.section-load-error { padding: 22px; border: 1px solid #8a5058; border-radius: 8px; background: #482932; color: #ffe8e8; }
.site-footer { position: fixed; inset: auto 0 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: var(--footer-height, 56px); padding: 14px 24px; border-top: 1px solid var(--border); background: #0f1b2d; color: #91a5be; font-size: 12px; font-weight: 600; box-shadow: 0 -8px 24px rgba(0, 0, 0, .18); }

@media (max-width: 1400px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .filters { justify-content: flex-start; }
  .tagline { display: none; }
}
@media (max-width: 1100px) {
  .cards-grid.overview .card[data-size="quarter"], .cards-grid.overview .card[data-size="third"] { grid-column: span 6; }
  .cards-grid.zone { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards-grid.context .card[data-size="quarter"], .cards-grid.context .card[data-size="sixth"] { grid-column: span 6; }
}
@media (max-width: 760px) {
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.is-open { transform: none; }
  .menu-button { display: block; }
  .topbar { padding: 16px; }
  .title-wrap { min-width: 0; }
  h1 { font-size: 25px; }
  .filters { display: grid; width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .field, .field-season, .field-umpire, .field-team, .field-extra, .field-date { width: auto; }
  .field-date, .export-button { grid-column: span 2; }
  .tabbar { padding: 0 10px; overflow-x: auto; }
  .tabs { gap: 0; }
  .tab { padding: 0 11px; font-size: 12px; }
  .dashboard { padding: 14px; }
  .cards-grid.overview .card[data-size], .cards-grid.context .card[data-size] { grid-column: span 12; }
  .cards-grid.zone { grid-template-columns: 1fr; }
  .card { min-height: 220px; }
  .card.metric { min-height: 180px; }
  .site-footer { align-items: flex-start; flex-direction: column; justify-content: center; gap: 4px; padding: 12px 14px; }
  :root { --footer-height: 76px; }
}
@media print {
  body { padding-bottom: 0; background: #fff; color: #111; }
  .sidebar, .filters, .tabbar, .info-button, .text-link, .toast, .menu-button { display: none !important; }
  .topbar { background: #fff; }
  .app-shell, .main-shell { min-height: 0; }
  .dashboard { padding: 10px; }
  .site-footer { position: static; box-shadow: none; }
  .card { break-inside: avoid; border-color: #aaa; background: #fff; color: #111; box-shadow: none; }
  .card-title, .metric-list dd, .impact-copy strong { color: #111; }
  .canvas-slot { background: #f5f7fa; }
  .slot-label { background: #fff; color: #333; }
}
.cards-grid.zone .card[data-size="quarter"]{grid-column:span 1}
.brand-logo{height:65px;padding:0;background:transparent;border-radius:0;box-shadow:none}
.brand-logo img{display:block;width:100%;height:auto;max-height:65px;object-fit:contain}
.brand{padding-inline:10px}
.brand-logo{height:auto}
.brand p{margin-top:-6px}

.main-shell{display:flex;flex-direction:column;min-height:100vh}
.dashboard{flex:1}
:root{--footer-height:56px}
body{padding-bottom:var(--footer-height)}
.app-shell,.main-shell{min-height:calc(100vh - var(--footer-height))}
.sidebar{height:calc(100vh - var(--footer-height))}
.site-footer{position:fixed;inset:auto 0 0;z-index:10;display:flex;align-items:center;justify-content:space-between;gap:18px;min-height:var(--footer-height);padding:14px 24px;border-top:1px solid var(--border);background:#0f1b2d;color:#91a5be;font-size:12px;font-weight:600;box-shadow:0 -8px 24px rgba(0,0,0,.18)}
@media(max-width:520px){:root{--footer-height:76px}.site-footer{align-items:flex-start;flex-direction:column;justify-content:center;gap:4px;padding:12px 14px}}
@media print{body{padding-bottom:0}.app-shell,.main-shell{min-height:0}.site-footer{position:static;box-shadow:none}}
.cards-grid.zone .card{min-height:470px}

.cards-grid.context .card{min-height:470px}
.cards-grid.context .table-card .table-body{display:flex;flex:1;min-height:0}
.cards-grid.context .table-card .data-table{height:100%;table-layout:fixed;font-size:13px}
.cards-grid.context .table-card .data-table th{height:42px;color:#bcd0e9;font-size:11px;letter-spacing:.03em;text-transform:uppercase}
.cards-grid.context .table-card .data-table td{font-size:13px}
.cards-grid.context .table-card .data-table th,.cards-grid.context .table-card .data-table td{padding:10px 12px;vertical-align:middle}
.cards-grid.context .table-card .data-table th:first-child,.cards-grid.context .table-card .data-table td:first-child{width:48%}
.cards-grid.context .table-card .data-table th:not(:first-child),.cards-grid.context .table-card .data-table td:not(:first-child){text-align:right}
.cards-grid.context .table-card .data-table tbody tr:nth-child(even){background:#17283e}
.cards-grid.context .table-card .card-footer{padding-top:12px}
.cards-grid.context .table-card .text-link{font-size:12px}

.canvas-slot{border-style:solid;border-color:#2e4765;background:radial-gradient(circle at 50% 48%,#1f528055,transparent 38%),linear-gradient(#ffffff08 1px,transparent 1px),linear-gradient(90deg,#ffffff08 1px,transparent 1px),#101c2d;background-size:auto,34px 34px,34px 34px,auto}
.slot-label{padding:8px 14px;border-color:#3a5c82;border-radius:999px;background:#1a314d;color:#a9c9eb;font-size:12px;font-weight:650}

.error-card .card-header{padding-bottom:9px;border-bottom:1px solid var(--border)}
.error-comparison{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;flex:1}
.error-type{display:flex;flex-direction:column;min-width:0}
.error-card .error-stat{display:flex;flex-direction:column;justify-content:center;min-height:108px;padding:10px 11px;border:1px solid #82909b;border-left-width:4px;border-radius:7px;background:linear-gradient(145deg,#53616e,#414d58)}
.error-card .error-stat-false{border-left-color:var(--red)}
.error-card .error-stat-missed{border-left-color:var(--orange)}
.error-card .error-stat span{color:#e1e9f0;font-size:11px;font-weight:700}
.error-card .error-stat strong{margin:5px 0 3px;color:var(--text);font-size:27px;line-height:1}
.error-card .error-stat b{color:#dbe6ed;font-size:12px}
.error-explanation{margin:10px 0 0;color:#d1dce4;font-size:11px;line-height:1.35}
.error-explanation span{display:block;color:#f4f8fb;font-weight:650}
.cards-grid.overview .card-tall{min-height:380px}
.ranking-table-body{max-width:100%;overflow-x:auto}
.data-table-ranking{min-width:380px;table-layout:fixed;font-size:11px}
.data-table-ranking th,.data-table-ranking td{padding:6px 5px;white-space:nowrap}
.data-table-ranking th:first-child,.data-table-ranking td:first-child{width:6%}
.data-table-ranking th:nth-child(2),.data-table-ranking td:nth-child(2){width:31%}
.data-table-ranking th:nth-child(3),.data-table-ranking td:nth-child(3){width:13%;text-align:right}
.data-table-ranking th:nth-child(4),.data-table-ranking td:nth-child(4){width:27%;text-align:right}
.data-table-ranking th:nth-child(5),.data-table-ranking td:nth-child(5){width:23%;text-align:right}
.cards-grid.overview .ranking-card{min-height:330px}
.ranking-card .ranking-table-body{display:flex;flex:1;min-height:0}
.ranking-card .data-table-ranking{height:100%;font-size:12px}
.ranking-card .data-table-ranking th,.ranking-card .data-table-ranking td{padding-top:9px;padding-bottom:9px;line-height:1.35}

/* Section HTML fragments keep each view's card grid independently editable. */
.section-load-error{padding:22px;border:1px solid #8a5058;border-radius:8px;background:#482932;color:#ffe8e8}
