:root {
  --background: #07151b;
  --surface: #0d2029;
  --surface-raised: #112a35;
  --border: #244550;
  --border-strong: #367080;
  --text: #effcff;
  --muted: #a9c2ca;
  --primary: #22d3ee;
  --primary-strong: #67e8f9;
  --healthy: #34d399;
  --healthy-bg: #0d352d;
  --degraded: #fbbf24;
  --degraded-bg: #392e10;
  --offline: #fb7185;
  --offline-bg: #3b1720;
  --starting: #60a5fa;
  --starting-bg: #122d4d;
  --focus: #a5f3fc;
  --radius: 12px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .24);
  font-family: "Fira Sans", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--background);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--background); }
body { min-height: 100vh; margin: 0; background: radial-gradient(circle at 88% -12%, #123b49 0, transparent 34rem), var(--background); }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; padding: 10px 14px; color: #04242d; background: var(--focus); border-radius: 8px; transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }
.app-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 24px clamp(16px, 4vw, 56px); border-bottom: 1px solid var(--border); background: rgba(7, 21, 27, .88); backdrop-filter: blur(16px); }
.brand, .header-actions, .input-row, .section-heading, .filters { display: flex; align-items: center; }
.brand { gap: 14px; }
.brand-mark { width: 36px; height: 36px; color: var(--primary); flex: 0 0 auto; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.25rem, 2.4vw, 1.75rem); letter-spacing: -.025em; }
h2 { margin-bottom: 4px; font-size: 1.1rem; letter-spacing: -.015em; }
.eyebrow { margin-bottom: 5px; color: var(--primary-strong); font: 600 .72rem/1.2 "Fira Code", ui-monospace, monospace; letter-spacing: .12em; text-transform: uppercase; }
.muted, .updated-at { color: var(--muted); }
.updated-at { margin: 0; font-size: .8rem; }
.header-actions { gap: 16px; }
.button { min-height: 44px; padding: 9px 15px; border: 1px solid var(--border-strong); border-radius: 9px; color: var(--text); background: var(--surface-raised); transition: border-color 160ms ease, background 160ms ease; }
.button:hover { border-color: var(--primary); background: #163744; }
.button-primary { color: #03252e; border-color: var(--primary); background: var(--primary); font-weight: 700; }
.button-primary:hover { background: var(--primary-strong); }
.shell { width: min(1440px, 100%); margin: 0 auto; padding: clamp(18px, 3vw, 40px); }
.auth-panel, .overall-card, .panel, .worker-card, .metrics { border: 1px solid var(--border); border-radius: var(--radius); background: linear-gradient(145deg, rgba(17, 42, 53, .94), rgba(9, 28, 36, .96)); box-shadow: var(--shadow); }
.auth-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, .7fr); align-items: end; gap: 24px; margin-bottom: 24px; padding: 20px; border-color: var(--degraded); }
.auth-panel[hidden] { display: none; }
.auth-panel p { margin-bottom: 0; color: var(--muted); }
.auth-form label { display: block; margin-bottom: 7px; color: var(--muted); font-size: .8rem; }
.input-row { gap: 8px; }
input, select { min-height: 44px; color: var(--text); border: 1px solid var(--border-strong); border-radius: 8px; background: #071a22; }
input { width: 100%; padding: 9px 12px; }
select { padding: 8px 34px 8px 10px; }
.overview { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(360px, 1fr); gap: 16px; margin-bottom: 32px; }
.overall-card { display: flex; align-items: center; justify-content: space-between; min-height: 142px; padding: 24px; border-left: 5px solid var(--border-strong); }
.overall-card h2 { font-size: clamp(1.5rem, 3vw, 2.35rem); }
.overall-card p:last-child { margin-bottom: 0; }
.overall-card.status-healthy { border-left-color: var(--healthy); }
.overall-card.status-degraded { border-left-color: var(--degraded); }
.overall-card.status-unhealthy { border-left-color: var(--offline); }
.overall-card.status-starting { border-left-color: var(--starting); }
.status-badge { padding: 8px 11px; border: 1px solid var(--border); border-radius: 999px; font: 600 .76rem/1 "Fira Code", ui-monospace, monospace; text-transform: uppercase; }
.status-healthy .status-badge, .status-dot.healthy { color: var(--healthy); background: var(--healthy-bg); border-color: #1f765d; }
.status-degraded .status-badge, .status-dot.degraded { color: var(--degraded); background: var(--degraded-bg); border-color: #7c641e; }
.status-unhealthy .status-badge, .status-dot.offline { color: var(--offline); background: var(--offline-bg); border-color: #7f3040; }
.status-starting .status-badge, .status-dot.starting { color: var(--starting); background: var(--starting-bg); border-color: #2f6098; }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; overflow: hidden; }
.metrics div { display: flex; flex-direction: column; justify-content: center; padding: 18px; border-left: 1px solid var(--border); }
.metrics div:first-child { border-left: 0; }
.metrics dt { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }
.metrics dd { margin: 7px 0 0; font: 600 clamp(1.25rem, 2vw, 1.65rem)/1 "Fira Code", ui-monospace, monospace; }
.section-heading { justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.section-heading p { margin-bottom: 0; }
.section-heading.compact { align-items: flex-end; }
.worker-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 32px; }
.worker-card { min-width: 0; padding: 18px; box-shadow: none; }
.worker-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.worker-name { margin: 0; font: 600 .92rem/1.3 "Fira Code", ui-monospace, monospace; overflow-wrap: anywhere; }
.status-dot { display: inline-flex; align-items: center; gap: 7px; padding: 6px 8px; border: 1px solid; border-radius: 999px; font-size: .7rem; text-transform: uppercase; }
.status-dot::before { width: 7px; height: 7px; content: ""; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 18%, transparent); }
.worker-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; margin: 0; }
.worker-facts div { min-width: 0; }
.worker-facts dt { color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; }
.worker-facts dd { margin: 4px 0 0; font: 500 .78rem/1.4 "Fira Code", ui-monospace, monospace; overflow-wrap: anywhere; }
.worker-summary { margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; }
.detail-grid { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.35fr); gap: 16px; }
.panel { min-width: 0; padding: 18px; box-shadow: none; }
.count { min-width: 30px; padding: 5px 8px; border-radius: 999px; text-align: center; color: var(--primary-strong); background: #0b3540; font: 600 .75rem/1 "Fira Code", ui-monospace, monospace; }
.feed, .logs { max-height: 560px; overflow: auto; scrollbar-color: var(--border-strong) transparent; }
.feed-item { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; padding: 12px 0; border-top: 1px solid var(--border); }
.feed-item:first-child { border-top: 0; }
.activity-line { margin: 0 0 3px; font-size: .86rem; overflow-wrap: anywhere; }
.meta { color: var(--muted); font: 400 .7rem/1.5 "Fira Code", ui-monospace, monospace; }
.activity-level { width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: var(--primary); }
.activity-level.error { background: var(--offline); }
.activity-level.warn { background: var(--degraded); }
.filters { flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.filters label { color: var(--muted); font-size: .72rem; }
.filters select { min-height: 36px; font-size: .78rem; }
.log-row { display: grid; grid-template-columns: 82px 116px 62px minmax(0, 1fr); gap: 9px; padding: 9px 0; border-top: 1px solid var(--border); font: 400 .72rem/1.5 "Fira Code", ui-monospace, monospace; }
.log-row:first-child { border-top: 0; }
.log-worker, .log-time { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-level { text-transform: uppercase; }
.log-level.error { color: var(--offline); }
.log-level.warn { color: var(--degraded); }
.log-message { min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.empty { padding: 28px 12px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: 8px; }
.page-error { position: fixed; right: 18px; bottom: 18px; max-width: min(440px, calc(100vw - 36px)); margin: 0; padding: 13px 16px; color: #ffe9ed; background: var(--offline-bg); border: 1px solid var(--offline); border-radius: 9px; box-shadow: var(--shadow); }

@media (max-width: 980px) {
  .overview, .detail-grid { grid-template-columns: 1fr; }
  .worker-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .app-header, .header-actions, .overall-card { align-items: flex-start; }
  .app-header, .header-actions { flex-direction: column; }
  .header-actions { width: 100%; gap: 10px; }
  .header-actions .button { width: 100%; }
  .auth-panel { grid-template-columns: 1fr; }
  .input-row { align-items: stretch; flex-direction: column; }
  .worker-grid { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metrics div { border-top: 1px solid var(--border); }
  .metrics div:nth-child(2) { border-left: 1px solid var(--border); }
  .metrics div:nth-child(3) { grid-column: 1 / -1; border-left: 0; }
  .log-row { grid-template-columns: 72px 1fr 55px; }
  .log-message { grid-column: 1 / -1; padding-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
