:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6f6d68;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --wash: rgba(11, 11, 11, 0.05);
  --critical: #d03b3b;
  --warning: #fab219;
  --good: #0ca30c;
  --line: #2a78d6;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #989690;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --wash: rgba(255, 255, 255, 0.06);
    --line: #3987e5;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
h1, h2, h3, p { margin: 0; }
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 13px; font-weight: 600; margin-top: 18px; }
button, input, select { font: inherit; color: inherit; }
button {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}
button:hover { background: var(--wash); }
button.primary { background: var(--ink); border-color: var(--ink); color: var(--surface); font-weight: 600; }
button:disabled { opacity: 0.55; cursor: default; }
input {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--axis);
  border-radius: 8px;
}
:focus-visible { outline: 2px solid var(--line); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--critical); font-size: 14px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(360px, 100%);
  display: grid;
  gap: 10px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.login-card h1 { font-size: 20px; margin-bottom: 6px; }
.login-card label { font-size: 13px; color: var(--ink-2); }

.app { max-width: 1120px; margin: 0 auto; padding: 16px; display: grid; gap: 16px; }
.api-usage { display: grid; gap: 6px; font-size: 13px; }
.api-usage-text { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; color: var(--ink-2); }
.api-usage-text strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.api-usage-text .muted { margin-left: auto; }
.meter { height: 6px; border-radius: 3px; background: var(--grid); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 3px; background: var(--line); }
.meter-fill.near { background: var(--warning); }
.topbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.topbar-actions { display: flex; gap: 8px; }
.profile-tabs { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.profile-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 220px;
  padding: 4px 12px 4px 4px;
  border-radius: 999px;
}
.profile-tab span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-tab[aria-selected="true"] { background: var(--surface); border-color: var(--ink-2); font-weight: 600; }
.profile-tab img, .avatar-blank { width: 28px; height: 28px; border-radius: 50%; flex: none; background: var(--grid); }

.notice { padding: 10px 12px; border: 1px solid var(--warning); border-radius: 8px; background: var(--surface); font-size: 14px; }
.now { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; align-items: baseline; }
.now-state { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--axis); flex: none; }
.dot.active { background: var(--good); }
.dot.away { background: var(--warning); }

.ranges { display: flex; flex-wrap: wrap; gap: 4px; }
.ranges button { padding: 4px 12px; font-variant-numeric: tabular-nums; }
.ranges button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--surface); font-weight: 600; }

#content { display: grid; gap: 16px; transition: opacity 120ms; }
#content.loading { opacity: 0.55; }
.label { font-size: 13px; color: var(--ink-2); }
.hero-value { font-size: 52px; line-height: 1.1; font-weight: 600; letter-spacing: -0.01em; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tile, .card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.tile { padding: 12px 14px; }
.tile-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.tile-value { font-size: 22px; font-weight: 600; margin-top: 2px; }

.card { padding: 14px 16px; display: grid; gap: 10px; align-content: start; min-width: 0; position: relative; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card-actions { display: flex; gap: 8px; }
.chart { min-height: 300px; width: 100%; border-radius: 4px; }
.chart svg { display: block; width: 100%; height: 300px; touch-action: pan-y; cursor: crosshair; user-select: none; }
.chart-empty { display: grid; place-items: center; min-height: 300px; color: var(--muted); text-align: center; padding: 16px; }
.status-line { fill: none; stroke: var(--line); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.status-line.open { stroke-dasharray: 2 6; }
.line-end { fill: var(--line); stroke: var(--surface); stroke-width: 2; }
.hover-slot { fill: var(--wash); }
.tickline { stroke: var(--grid); stroke-width: 1; }
.slotline { stroke: var(--grid); stroke-width: 1; opacity: 0.55; }
.zoom-selection { fill: var(--wash); stroke: var(--axis); stroke-width: 1; }
.tick.level { fill: var(--ink-2); font-size: 13px; }
.gridline { stroke: var(--grid); stroke-width: 1; }
.baseline { stroke: var(--axis); stroke-width: 1; }
.tick { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.tooltip {
  position: absolute;
  z-index: 5;
  min-width: 170px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
  font-size: 13px;
  pointer-events: none;
}
.tooltip-title { color: var(--ink-2); margin-bottom: 4px; }
.tooltip-status { font-weight: 600; }

.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 4px 8px 4px 0; }
td { padding: 5px 8px 5px 0; border-top: 1px solid var(--grid); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding-right: 0; padding-left: 8px; }
.empty { color: var(--muted); font-size: 14px; }

.dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 20px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.dialog h2 { font-size: 18px; margin-bottom: 12px; }
.dialog label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 4px; }
.input-row { display: flex; gap: 8px; }
#add-error { margin-top: 8px; }
.profile-list { list-style: none; margin: 6px 0 0; padding: 0; }
.profile-list select {
  padding: 6px 8px;
  background: var(--surface);
  border: 1px solid var(--axis);
  border-radius: 8px;
}
#request-estimate { margin-top: 8px; }
.profile-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 6px 0; border-top: 1px solid var(--grid); }
.profile-list li > span:not(.avatar-blank) { flex: 1 1 120px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-list img { width: 28px; height: 28px; border-radius: 50%; }
.dialog-foot { display: flex; justify-content: flex-end; margin-top: 16px; }
