/* status.bobchen.net — DESIGN.md inspired system */

:root {
  color-scheme: dark light;
  --page: #0e0e10;
  --surface: #151518;
  --surface-2: #1d1d22;
  --ink: #f4f1ea;
  --ink-2: #c7c0b2;
  --muted: #8e897f;
  --grid: rgba(244, 241, 234, 0.10);
  --baseline: rgba(244, 241, 234, 0.22);
  --border: rgba(244, 241, 234, 0.14);
  --s1: #ff6b00;
  --s2: #ffb1ee;
  --s3: #f5a623;
  --s4: #9cff6e;
  --good: #9cff6e;
  --warning: #f5a623;
  --serious: #ff7b3d;
  --critical: #ff425f;
  --shadow: none;
  --mono: "SFMono-Regular", "Cascadia Code", "IBM Plex Mono", "JetBrains Mono", ui-monospace, monospace;
  --sans: Inter, Manrope, ui-sans-serif, system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --page: #f5f4f2;
    --surface: #ffffff;
    --surface-2: #eee9e2;
    --ink: #0a0a0a;
    --ink-2: #3f3d39;
    --muted: #777168;
    --grid: rgba(10, 10, 10, 0.09);
    --baseline: rgba(10, 10, 10, 0.22);
    --border: rgba(10, 10, 10, 0.14);
    --shadow: 0 18px 38px -28px rgba(10, 10, 10, 0.45);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0e0e10; --surface: #151518; --surface-2: #1d1d22;
  --ink: #f4f1ea; --ink-2: #c7c0b2; --muted: #8e897f;
  --grid: rgba(244, 241, 234, 0.10); --baseline: rgba(244, 241, 234, 0.22);
  --border: rgba(244, 241, 234, 0.14); --shadow: none;
}

:root[data-theme="light"] {
  color-scheme: light;
  --page: #f5f4f2; --surface: #ffffff; --surface-2: #eee9e2;
  --ink: #0a0a0a; --ink-2: #3f3d39; --muted: #777168;
  --grid: rgba(10, 10, 10, 0.09); --baseline: rgba(10, 10, 10, 0.22);
  --border: rgba(10, 10, 10, 0.14); --shadow: 0 18px 38px -28px rgba(10, 10, 10, 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100vh;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--s1) 7%, transparent), transparent 360px),
    repeating-linear-gradient(0deg, transparent 0 3px, color-mix(in srgb, var(--ink) 3.5%, transparent) 3px 4px),
    var(--page);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 0 calc(50% - 1px), var(--grid) calc(50% - 1px) 50%, transparent 50%),
    repeating-linear-gradient(90deg, transparent 0 119px, var(--grid) 119px 120px);
  opacity: 0.72;
  mask-image: linear-gradient(#000, transparent 78%);
}

.wrap {
  width: min(1420px, 100%);
  margin: 0 auto;
  padding: 18px clamp(12px, 3vw, 34px) 34px;
}

.site-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 6px 0 16px;
  border-bottom: 1px solid var(--border);
}

.host {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.host h1 {
  font-size: clamp(25px, 3vw, 42px);
  font-weight: 760;
  line-height: 0.98;
  letter-spacing: 0;
}

.host .sub {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11.5px;
  margin-top: 7px;
}

.pulse {
  width: 10px;
  height: 10px;
  margin-top: 9px;
  border-radius: 2px;
  flex: none;
  background: var(--good);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--good) 35%, transparent), 0 0 18px color-mix(in srgb, var(--good) 42%, transparent);
  animation: pulse 2.4s ease-out infinite;
}

.pulse.down {
  background: var(--critical);
  animation: none;
  box-shadow: 0 0 16px color-mix(in srgb, var(--critical) 45%, transparent);
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 45%, transparent), 0 0 18px color-mix(in srgb, var(--good) 42%, transparent); }
  70% { box-shadow: 0 0 0 9px transparent, 0 0 18px color-mix(in srgb, var(--good) 42%, transparent); }
  100% { box-shadow: 0 0 0 0 transparent, 0 0 18px color-mix(in srgb, var(--good) 42%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
  .pulse { animation: none; }
}

.header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.chip,
.icon-btn,
.range-btn,
.tbl-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 11.5px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 2px;
  padding: 4px 10px;
  white-space: nowrap;
}

.chip.conn.ok { color: var(--good); }
.chip.conn.err { color: var(--critical); }

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 2px;
  cursor: pointer;
}

.icon-btn:hover,
.range-btn:hover,
.tbl-btn:hover {
  border-color: color-mix(in srgb, var(--s2) 45%, var(--border));
  color: var(--ink);
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: wrap;
  width: fit-content;
  margin: 14px 0;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
}

.range-btn {
  min-height: 30px;
  cursor: pointer;
  border: 0;
  border-right: 1px solid var(--border);
  border-radius: 0;
  padding: 5px 13px;
  background: transparent;
}

.range-btn:last-of-type { border-right: 0; }

.range-btn.active {
  color: var(--page);
  background: var(--ink);
  font-weight: 700;
}

.filter-note {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  padding: 0 10px;
}

.tiles {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin-bottom: 12px;
}

.tile,
.card,
.panel {
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border: 1px solid var(--border);
  border-radius: 2px;
  box-shadow: var(--shadow);
}

.tile {
  position: relative;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 12px 13px 13px;
  overflow: hidden;
  transition: transform 0.16s ease, border-color 0.16s ease, background-color 0.16s ease;
}

.tile::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--s1);
}

.tile::after {
  content: "";
  position: absolute;
  right: 9px;
  top: 9px;
  width: 22px;
  height: 22px;
  border-top: 1px solid color-mix(in srgb, var(--ink) 22%, transparent);
  border-right: 1px solid color-mix(in srgb, var(--ink) 22%, transparent);
  opacity: 0.7;
}

.tile:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--s1) 45%, var(--border));
  background: color-mix(in srgb, var(--surface) 82%, var(--s1) 6%);
}

.tile.warn { border-color: color-mix(in srgb, var(--warning) 55%, var(--border)); }
.tile.warn::before { background: var(--warning); }
.tile.crit { border-color: color-mix(in srgb, var(--critical) 62%, var(--border)); }
.tile.crit::before { background: var(--critical); }

.tile-label {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
}

.tile-value {
  color: var(--ink);
  font-family: var(--mono);
  font-size: clamp(22px, 2.2vw, 30px);
  font-weight: 720;
  line-height: 1.02;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.tile-value small {
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
}

.tile-sub {
  min-height: 17px;
  color: var(--muted);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meter {
  height: 7px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--ink) 12%, transparent);
  background: color-mix(in srgb, var(--ink) 7%, transparent);
}

.meter-fill {
  position: relative;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--s1), var(--s2));
  transition: width 0.42s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.22s ease;
}

.meter-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, rgba(255,255,255,0.25) 0 1px, transparent 1px 8px);
  opacity: 0.35;
}

.meter.warn .meter-fill { background: linear-gradient(90deg, var(--warning), var(--serious)); }
.meter.crit .meter-fill { background: linear-gradient(90deg, var(--serious), var(--critical)); }

@media (prefers-reduced-motion: reduce) {
  .meter-fill,
  .tile { transition: none; }
}

.services {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.svc {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 29px;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 4px 10px;
  font-family: var(--mono);
  font-size: 11.5px;
}

.svc .dot {
  width: 7px;
  height: 7px;
  border-radius: 1px;
  flex: none;
}

.svc.up .dot { background: var(--good); }
.svc.down .dot { background: var(--critical); }
.svc .state { font-weight: 700; }
.svc.up .state { color: var(--good); }
.svc.down .state { color: var(--critical); }

.charts {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  margin-bottom: 12px;
}

.card {
  min-width: 0;
  padding: 13px 14px 10px;
  position: relative;
  overflow: hidden;
}

.card::before,
.panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--s2) 46%, transparent), transparent);
}

.card-head {
  display: flex;
  align-items: baseline;
  gap: 7px 10px;
  margin-bottom: 7px;
  flex-wrap: wrap;
}

.card-head h2,
.panel h2 {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12.5px;
  font-weight: 740;
  text-transform: uppercase;
}

.card-now {
  margin-left: auto;
  color: var(--s2);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 720;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.tbl-btn {
  cursor: pointer;
  border-radius: 2px;
  padding: 2px 8px;
  flex: none;
}

.card-legend {
  display: flex;
  gap: 14px;
  margin-bottom: 4px;
}

.card-legend .key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 11.5px;
}

.card-legend .key i {
  display: inline-block;
  width: 14px;
  height: 3px;
}

.card-body { position: relative; }
.card-body svg { display: block; width: 100%; height: auto; }

.chart-tip {
  position: absolute;
  pointer-events: none;
  z-index: 5;
  display: none;
  min-width: 118px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.20);
  font-family: var(--mono);
  font-size: 11.5px;
}

.chart-tip .tip-time {
  color: var(--muted);
  font-size: 10.5px;
  margin-bottom: 4px;
}

.chart-tip .tip-row {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.chart-tip .tip-row i {
  width: 10px;
  height: 3px;
  flex: none;
}

.chart-tip .tip-row b {
  color: var(--ink);
  font-weight: 720;
}

.chart-tip .tip-row span { color: var(--ink-2); }
.chart-empty { color: var(--muted); font-size: 12.5px; padding: 40px 0; text-align: center; }

.panel {
  position: relative;
  min-width: 0;
  margin-bottom: 10px;
  padding: 13px 14px;
  overflow: hidden;
}

.panel h2 { margin-bottom: 10px; }

.panel-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
  margin-bottom: 10px;
}

.panel-grid .panel { margin-bottom: 0; }

.h2-note {
  margin-left: 6px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
}

.quota-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
}

.quota-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 2px;
}

.quota-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quota-head .q-name {
  color: var(--ink);
  font-weight: 740;
}

.quota-head .q-plan {
  color: var(--page);
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 2px;
  padding: 1px 7px;
  font-family: var(--mono);
  font-size: 10.5px;
}

.quota-head .q-stale {
  margin-left: auto;
  color: var(--serious);
  font-size: 11px;
}

.q-row {
  display: grid;
  grid-template-columns: 1fr auto;
  row-gap: 6px;
  align-items: baseline;
}

.q-row .q-label {
  color: var(--ink-2);
  font-size: 12.5px;
}

.q-row .q-val {
  color: var(--muted);
  text-align: right;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 11.5px;
}

.q-row .q-val b {
  color: var(--s2);
  font-weight: 740;
}

.q-row .meter { grid-column: 1 / -1; }
.q-err { color: var(--muted); font-size: 12.5px; }

.cores {
  display: grid;
  gap: 8px 14px;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
}

.core {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
}

.core .meter {
  flex: 1;
  height: 6px;
}

.core .pct {
  min-width: 34px;
  color: var(--ink-2);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.disk-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.disk-row .disk-line1 {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
  font-size: 12.5px;
}

.disk-row .mnt {
  overflow: hidden;
  color: var(--ink);
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.disk-row .nums {
  color: var(--ink-2);
  white-space: nowrap;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.disk-row .disk-sub {
  color: var(--muted);
  font-size: 11px;
  margin-top: 4px;
}

.tablewrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

th,
td {
  text-align: left;
  padding: 7px 10px 7px 0;
  white-space: nowrap;
}

th {
  color: var(--muted);
  border-bottom: 1px solid var(--grid);
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
}

td {
  color: var(--ink-2);
  border-bottom: 1px solid var(--grid);
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

tbody tr:hover td { background: color-mix(in srgb, var(--s2) 7%, transparent); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
td.strong { color: var(--ink); font-weight: 720; }

.chart-table {
  max-height: 240px;
  overflow-y: auto;
}

.chart-table table { font-size: 12px; }
.chart-table th {
  position: sticky;
  top: 0;
  background: var(--surface);
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: 10px;
  font-family: var(--mono);
  font-size: 11px;
}

@media (max-width: 640px) {
  .wrap { padding-inline: 12px; }
  .site-header { align-items: stretch; }
  .header-right { justify-content: flex-start; }
  .filter-row { width: 100%; }
  .range-btn { flex: 1; padding-left: 7px; padding-right: 7px; }
  .filter-note { width: 100%; padding: 5px 8px 2px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile { padding: 12px; }
  .tile-value { font-size: 20px; }
  .host h1 { font-size: 21px; }
  .host .sub { white-space: normal; }
  .card { padding: 12px 12px 8px; }
  .card-now { width: 100%; margin-left: 0; white-space: normal; }
  th, td { padding-right: 12px; }
}

@media (min-width: 641px) and (max-width: 1023px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1100px) {
  .tiles { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}
