:root {
  color-scheme: dark;
  --bg: #0a0b0d;
  --card: #111317;
  --card-2: #16191e;
  --cell: #191c22;
  --border: #20242b;
  --grid: #1b1f25;
  --axis: #343a43;
  --text: #eceef1;
  --text-2: #a3a9b2;
  --muted: #6c727c;
  --up: #2ebd85;
  --down: #f1555a;
  --s-total: #eceef1;
  --s-weather: #5aa2ff;
  --s-pump: #f5a623;
  --shadow: none;
  font-family: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f5f7;
  --card: #ffffff;
  --card-2: #f7f8fa;
  --cell: #f0f1f4;
  --border: #e4e6ea;
  --grid: #eef0f3;
  --axis: #c9cdd4;
  --text: #0f1115;
  --text-2: #4b515b;
  --muted: #8a909a;
  --up: #12a36b;
  --down: #e0393e;
  --s-total: #0f1115;
  --s-weather: #2f7de1;
  --s-pump: #e48f00;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
html, body { background: var(--bg); }
body { margin: 0; color: var(--text); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; font-feature-settings: "tnum" 1; }
button { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
.muted { color: var(--muted); }
.up { color: var(--up); }
.down { color: var(--down); }

/* header */
.top { position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.top-row { max-width: 1360px; margin: 0 auto; padding: 0 20px; height: 60px; display: flex; align-items: center; gap: 28px; }
h1 { font-size: 17px; font-weight: 650; margin: 0; letter-spacing: -.01em; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs button { background: none; border: 0; padding: 7px 14px; border-radius: 8px; cursor: pointer; color: var(--text-2); font-weight: 500; white-space: nowrap; }
.tabs button:hover { color: var(--text); background: var(--card-2); }
.tabs button.active { color: var(--text); background: var(--card); box-shadow: inset 0 0 0 1px var(--border); }
.top-actions { display: flex; align-items: center; gap: 14px; }
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.status i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.status.live { color: var(--text-2); }
.status.live i { background: var(--up); box-shadow: 0 0 0 3px color-mix(in srgb, var(--up) 22%, transparent); }
.btn { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.btn:hover { color: var(--text); }
@media (max-width: 720px) { .top-row { gap: 12px; padding: 0 12px; } h1, .btn { display: none; } }

#errors { max-width: 1360px; margin: 0 auto; padding: 0 20px; }
#errors .error { margin-top: 12px; padding: 10px 14px; border-radius: 10px; border: 1px solid color-mix(in srgb, var(--down) 35%, var(--border)); background: color-mix(in srgb, var(--down) 8%, var(--card)); font-size: 13px; }
main { max-width: 1360px; margin: 0 auto; padding: 20px 20px 64px; }
.loading { padding: 96px 0; text-align: center; color: var(--muted); }
.page { display: grid; gap: 16px; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 540px), 1fr)); gap: 16px; }

/* tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(146px, 1fr)); gap: 10px; }
.tile { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 15px 16px; min-width: 0; box-shadow: var(--shadow); }
.tile.hero { grid-column: span 2; background: linear-gradient(160deg, var(--card-2), var(--card) 60%); }
.tile-label { color: var(--text-2); font-size: 13px; font-weight: 500; }
.tile-value { font-size: 22px; font-weight: 600; margin-top: 6px; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-value.small { font-size: 17px; margin-top: 9px; }
.tile.hero .tile-value { font-size: 44px; line-height: 1.05; letter-spacing: -.035em; margin-top: 8px; }
.tile-sub { color: var(--muted); font-size: 12.5px; margin-top: 6px; white-space: pre; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 560px) { .tile.hero { grid-column: 1 / -1; } .tile.hero .tile-value { font-size: 36px; } }

/* cards */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 18px 20px 20px; min-width: 0; box-shadow: var(--shadow); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card h2 { font-size: 15px; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.card-sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.card-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.note { color: var(--muted); font-size: 12.5px; margin: 10px 0 0; }

.seg { display: inline-flex; background: var(--cell); border-radius: 9px; padding: 3px; }
.seg button { border: 0; background: none; padding: 4px 11px; border-radius: 7px; cursor: pointer; color: var(--text-2); font-size: 13px; font-weight: 500; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .25), inset 0 0 0 1px var(--border); }
.chips, .legend { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border); background: none; border-radius: 999px; padding: 4px 12px; cursor: pointer; font-size: 13px; color: var(--muted); }
.chip.on { color: var(--text); background: var(--card-2); }
.chip:not(.on) .line-key { opacity: .3; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); }
.line-key { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }

.nav { display: inline-flex; align-items: center; gap: 2px; background: var(--cell); border-radius: 9px; padding: 3px; }
.nav-label { min-width: 82px; text-align: center; font-size: 13px; font-weight: 600; }
.icon-btn { border: 0; background: none; border-radius: 7px; width: 26px; height: 26px; cursor: pointer; font-size: 17px; line-height: 1; color: var(--text-2); }
.icon-btn:hover:not(:disabled) { background: var(--card); color: var(--text); }
.icon-btn:disabled { opacity: .3; cursor: default; }

/* charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; overflow: visible; }
.chart-empty { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; }
.axis { fill: var(--muted); font-size: 11.5px; }
.end-label { fill: var(--text); font-size: 12px; font-weight: 600; }
.tip { position: absolute; display: none; pointer-events: none; z-index: 5; background: var(--card-2); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; font-size: 12.5px; min-width: 170px; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); }
.tip-title { color: var(--muted); margin-bottom: 6px; white-space: nowrap; }
.tip-row { display: grid; grid-template-columns: 12px 1fr auto; align-items: center; gap: 8px; white-space: nowrap; padding: 1px 0; }
.tip-key { width: 12px; height: 3px; border-radius: 2px; }
.tip-name { color: var(--text-2); }
.tip-val { font-weight: 600; text-align: right; }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; }
.cal-dow { color: var(--muted); font-size: 12px; text-align: center; padding-bottom: 4px; }
.cal-cell, .month-cell { background: var(--cell); border-radius: 9px; min-height: 64px; padding: 7px 8px; display: flex; flex-direction: column; justify-content: space-between; min-width: 0; transition: transform .12s ease; }
.cal-cell:not(.blank):not(.none):hover { transform: translateY(-1px); box-shadow: 0 0 0 1px var(--axis); }
.cal-cell.blank { background: none; }
.cal-cell.none, .month-cell.none { opacity: .4; }
.cal-cell.today { box-shadow: inset 0 0 0 1.5px var(--text-2); }
.cal-day { font-size: 12px; color: var(--text-2); }
.cal-val { font-size: 13px; font-weight: 600; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strong .cal-day { color: rgba(255, 255, 255, .8); }
.strong .cal-val { color: #fff; }
@media (max-width: 560px) { .cal { gap: 3px; } .cal-cell { min-height: 48px; padding: 4px; } .cal-val { font-size: 10.5px; } }
.year-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 5px; margin-bottom: 18px; }
.month-cell { border: 0; text-align: left; cursor: pointer; min-height: 60px; }
.month-cell:disabled { cursor: default; }
.month-cell.selected { box-shadow: inset 0 0 0 1.5px var(--text); }
.mini-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.mini-label { color: var(--muted); font-size: 12.5px; }
.mini-value { font-weight: 600; margin-top: 2px; }

/* breakdown bars */
.hbars { display: grid; gap: 8px; }
.hbar-row { display: grid; grid-template-columns: minmax(110px, 1fr) 2fr minmax(84px, auto); gap: 14px; align-items: center; }
.hbar-label { display: flex; flex-direction: column; min-width: 0; font-size: 13.5px; }
.hbar-label span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-label .muted { font-size: 11.5px; }
.hbar-track { position: relative; height: 10px; }
.hbar-track::before { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--axis); }
.hbar { position: absolute; top: 0; bottom: 0; min-width: 2px; }
.hbar.up { background: var(--up); border-radius: 0 5px 5px 0; }
.hbar.down { background: var(--down); border-radius: 5px 0 0 5px; }
.hbar-val { text-align: right; font-size: 13.5px; font-weight: 600; }

/* tables */
.table-bar { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; font-size: 12.5px; }
.search { background: var(--cell); border: 1px solid transparent; border-radius: 9px; padding: 7px 12px; color: var(--text); font: inherit; font-size: 13px; width: min(280px, 100%); outline: none; }
.search:focus { border-color: var(--axis); }
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th button { background: none; border: 0; padding: 8px 10px; cursor: pointer; color: inherit; font-weight: inherit; width: 100%; text-align: inherit; }
th button:hover { color: var(--text); }
td { padding: 9px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--card-2); }
.num { text-align: right; }
.empty-row { text-align: center; padding: 22px; }
.more { margin-top: 12px; background: var(--cell); border: 0; border-radius: 9px; padding: 7px 14px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.more:hover { color: var(--text); }

/* phones */
.cal-val .compact { display: none; }
@media (max-width: 640px) {
  .tabs .venue { display: none; }
  .tabs button { padding: 7px 11px; }
  main { padding: 12px 12px 48px; }
  #errors { padding: 0 12px; }
  .page, .two-col { gap: 12px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tile { padding: 12px 13px; border-radius: 12px; }
  .tile.hero { grid-column: 1 / -1; }
  .tile.hero .tile-value { font-size: 34px; }
  .tile-label { font-size: 12px; }
  .tile-value { font-size: 18px; margin-top: 4px; }
  .tile-value.small { font-size: 15px; margin-top: 6px; }
  .tile-sub { font-size: 11.5px; white-space: nowrap; }
  .card { padding: 14px 14px 16px; border-radius: 14px; }
  .card-head { margin-bottom: 10px; }
  .card-controls { width: 100%; }
  .seg button { padding: 4px 9px; }
  .cal-val .full { display: none; }
  .cal-val .compact { display: inline; }
  .cal-cell { min-height: 46px; padding: 4px 5px; border-radius: 7px; }
  .cal-day { font-size: 10.5px; }
  .cal-val { font-size: 11.5px; }
  .month-cell { min-height: 50px; }
  .mini-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hbar-row { grid-template-columns: minmax(84px, 1fr) 1.3fr minmax(70px, auto); gap: 10px; }
  table { font-size: 12.5px; }
  td { padding: 8px 8px; }
  th button { padding: 7px 8px; }
}
@media (max-width: 640px) { .tiles .tile:last-child:nth-child(even) { grid-column: 1 / -1; } }
@media (min-width: 1000px) {
  .tiles { grid-template-columns: minmax(0, 1.7fr) repeat(6, minmax(0, 1fr)); }
  .tile.hero { grid-column: auto; }
  .tile-value { font-size: clamp(17px, 1.55vw, 22px); }
  .tile-value.small { font-size: clamp(14px, 1.2vw, 17px); }
  .tile.hero .tile-value { font-size: clamp(30px, 3vw, 44px); }
}
