:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface-1: #fcfcfb;
  --border: #e4e3df;
  --grid: #ebeae6;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #77766f;
  --series-1: #2a78d6;
  --good-text: #006300;
  --bad-text: #b02a2a;
  --status-good: #0ca30c;
  --status-warning: #b07800;
  --status-critical: #d03b3b;
  --radius: 14px;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #111110;
    --surface-1: #1a1a19;
    --border: #2c2c2a;
    --grid: #262624;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --text-muted: #96958c;
    --series-1: #3987e5;
    --good-text: #3fc23f;
    --bad-text: #ef7a7a;
    --status-good: #0ca30c;
    --status-warning: #fab219;
    --status-critical: #e66767;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text-primary); -webkit-font-smoothing: antialiased; }
#app { max-width: 1180px; margin: 0 auto; padding: max(20px, env(safe-area-inset-top)) 20px 48px; }
a { color: inherit; text-decoration: none; }
h1, h2 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 650; display: flex; align-items: center; gap: 10px; }
h2 { font-size: 17px; font-weight: 620; }
p { margin: 0; }
.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.spacer { flex: 1; }

.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.top p { margin-top: 4px; font-size: 14px; }
.demo { color: var(--status-warning); font-weight: 600; }
.back { color: var(--text-muted); font-weight: 400; padding: 0 4px; border-radius: 8px; }
.back:hover { color: var(--text-primary); background: var(--grid); }
.actions { display: flex; gap: 8px; }
.btn { font: inherit; font-size: 14px; padding: 8px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-1); color: var(--text-primary); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--text-muted); }
.btn.ghost { background: transparent; }
.btn:focus-visible, .seg:focus-visible, .app-card:focus-visible, summary:focus-visible { outline: 2px solid var(--series-1); outline-offset: 2px; }

.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); }
.card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* overview */
.overview { display: grid; gap: 16px; }
.app-card { display: block; padding: 18px 20px 16px; transition: border-color .15s, transform .15s; }
.app-card:hover { border-color: var(--text-muted); }
.app-card:active { transform: scale(0.995); }
.chev { font-size: 24px; color: var(--text-muted); line-height: 1; margin-left: 4px; }
.tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.tile { padding: 12px 12px 10px; border-radius: 10px; background: var(--bg); display: grid; gap: 3px; min-width: 0; }
.tile-label { font-size: 12.5px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-value { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.tile-when { font-size: 11.5px; }
.spark { width: 100%; height: 28px; margin: 4px 0 2px; overflow: visible; }
.spark path { fill: none; stroke: var(--series-1); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.spark.empty { height: 28px; margin: 4px 0 2px; border-bottom: 1px dashed var(--border); }

.delta { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta.good { color: var(--good-text); }
.delta.bad { color: var(--bad-text); }
.delta.flat { color: var(--text-muted); font-weight: 500; }

.status { font-size: 12.5px; display: inline-flex; align-items: center; gap: 5px; color: var(--text-secondary);
  padding: 3px 9px; border-radius: 999px; background: var(--bg); white-space: nowrap; }
.status > span:first-child { font-size: 10px; }
.status.good > span:first-child { color: var(--status-good); }
.status.warning > span:first-child { color: var(--status-warning); }
.status.critical { color: var(--status-critical); }
.status.critical > span:first-child { color: var(--status-critical); }
.status.muted > span:first-child { color: var(--text-muted); }

/* detail */
.toolbar { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin: -6px 0 14px; }
.segs { display: inline-flex; background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.seg { font: inherit; font-size: 13px; border: 0; background: transparent; color: var(--text-secondary); padding: 6px 12px; border-radius: 7px; cursor: pointer; }
.seg.on { background: var(--bg); color: var(--text-primary); font-weight: 600; box-shadow: 0 0 0 1px var(--border); }
.detail { display: grid; gap: 16px; }
.section { padding: 18px 20px; }
.note { margin-top: 4px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 16px 0 6px; }
.stat { display: grid; gap: 3px; padding: 4px 0; }
.stat-value { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 8px 24px; margin-top: 12px; }
.chart-box { margin: 0; min-width: 0; }
.chart-box figcaption { font-size: 13px; color: var(--text-secondary); margin: 8px 0 4px; }
.chart-slot { position: relative; min-height: 150px; }
.chart { display: block; overflow: visible; touch-action: pan-y; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .ylab, .chart .xlab { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .ylab { text-anchor: end; }
.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .end { fill: var(--series-1); stroke: var(--surface-1); stroke-width: 2; }
.chart .cross { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .dot { fill: var(--series-1); stroke: var(--surface-1); stroke-width: 2; }
.tip { position: absolute; pointer-events: none; background: var(--text-primary); color: var(--surface-1); border-radius: 8px;
  padding: 6px 9px; font-size: 12px; display: grid; gap: 1px; white-space: nowrap; box-shadow: 0 4px 14px rgb(0 0 0 / .18); }
.tip strong { font-size: 14px; font-variant-numeric: tabular-nums; }
.nodata { height: 150px; display: grid; place-items: center; color: var(--text-muted); font-size: 13px;
  border: 1px dashed var(--border); border-radius: 10px; margin: 0; }

.table-view { margin-top: 12px; }
.table-view summary { cursor: pointer; font-size: 13px; color: var(--text-secondary); padding: 4px 0; width: max-content; }
.table-wrap { overflow-x: auto; margin-top: 8px; }
table { border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; width: 100%; }
th, td { padding: 6px 10px; text-align: right; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th:first-child { text-align: left; }
thead th { color: var(--text-secondary); font-weight: 600; }
tbody th { font-weight: 500; color: var(--text-secondary); }

/* sign in */
.signin { max-width: 380px; margin: 12vh auto 0; padding: 28px; display: grid; gap: 12px; }
.signin form { display: grid; gap: 8px; margin-top: 8px; }
.signin label { font-size: 13px; color: var(--text-secondary); }
.signin input { font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text-primary); }

@media (max-width: 900px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  #app { padding-left: 14px; padding-right: 14px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tile-value { font-size: 22px; }
  .app-card, .section { padding: 16px 14px; }
  .charts { grid-template-columns: 1fr; }
  .top { align-items: flex-start; }
}

[hidden] { display: none !important; }
