:root {
  --accent: #0099ff;
  --accent-strong: #007acc;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 12px;
  --pill: 999px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-feature-settings: "cv01", "cv05", "cv09", "cv11", "ss03", "ss07";
}

[data-theme="dark"] {
  color-scheme: dark;
  --page: #000000;
  --panel: #090909;
  --surface: #111111;
  --surface-raised: #171717;
  --text: #ffffff;
  --muted: #a6a6a6;
  --faint: rgba(255, 255, 255, 0.6);
  --line: rgba(255, 255, 255, 0.1);
  --line-soft: rgba(255, 255, 255, 0.06);
  --frost: rgba(255, 255, 255, 0.1);
  --field: #0d0d0d;
  --shadow: rgba(0, 0, 0, 0.35);
  --blue-ring: rgba(0, 153, 255, 0.15);
  --accent-ink: #ffffff;
}

[data-theme="light"] {
  color-scheme: light;
  --page: #f5f5f7;
  --panel: #ffffff;
  --surface: #ffffff;
  --surface-raised: #fafafa;
  --text: #050505;
  --muted: #626267;
  --faint: rgba(0, 0, 0, 0.62);
  --line: rgba(0, 0, 0, 0.12);
  --line-soft: rgba(0, 0, 0, 0.07);
  --frost: rgba(0, 0, 0, 0.055);
  --field: #ffffff;
  --shadow: rgba(0, 0, 0, 0.1);
  --blue-ring: rgba(0, 153, 255, 0.22);
  --accent-ink: #ffffff;
}

* { box-sizing: border-box; }
html { background: var(--page); }
body {
  margin: 0;
  min-width: 320px;
  background: var(--page);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 10;
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  background: var(--panel);
  border-right: 1px solid var(--line-soft);
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  padding: 0 8px 20px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.35px;
}
.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 9px;
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--blue-ring);
}
.sidebar nav { display: grid; gap: 3px; }
.sidebar nav a {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-radius: var(--pill);
  color: var(--muted);
  font-weight: 500;
  letter-spacing: -0.15px;
}
.sidebar nav a:hover,
.sidebar nav a:focus-visible {
  color: var(--text);
  background: var(--frost);
}
.sidebar-foot {
  margin-top: auto;
  padding: 16px 7px 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  border-top: 1px solid var(--line-soft);
}
.sidebar-foot > span { width: 100%; overflow-wrap: anywhere; }
.sidebar-foot form { margin: 0; }

.content {
  width: 100%;
  max-width: 1480px;
  padding: 52px clamp(24px, 4.5vw, 72px) 80px;
}
h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 9px;
  font-size: clamp(38px, 5vw, 62px);
  line-height: 0.98;
  letter-spacing: clamp(-3.1px, -0.05em, -1.5px);
  font-weight: 500;
}
h2 {
  margin-bottom: 7px;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: -0.8px;
  font-weight: 600;
}
.eyebrow {
  margin-bottom: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font: 500 11px/1.5 "Azeret Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
}
.muted { color: var(--muted); }
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 38px;
}
.page-head p { max-width: 620px; font-size: 16px; }
.status-stack { display: grid; justify-items: end; gap: 8px; }

.status, .pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 5px 11px;
  white-space: nowrap;
  border: 1px solid var(--line);
  border-radius: var(--pill);
  color: var(--muted);
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
}
.status i { width: 7px; height: 7px; border-radius: 50%; background: var(--warning); }
.status.active i, .status.running i, .pill.on { color: var(--success); }
.status.active i, .status.running i { background: var(--success); box-shadow: 0 0 0 4px color-mix(in srgb, var(--success) 15%, transparent); }
.status.failed i, .pill.off { color: var(--danger); }
.status.failed i { background: var(--danger); }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--blue-ring), 0 18px 50px var(--shadow);
  margin-bottom: 20px;
}
.metric {
  min-width: 0;
  padding: 23px;
  border-right: 1px solid var(--line-soft);
}
.metric:last-child { border-right: 0; }
.metric > span, .metric small { display: block; color: var(--muted); }
.metric > span { font-size: 13px; font-weight: 500; }
.metric strong {
  display: block;
  margin: 18px 0 4px;
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1;
  font-weight: 500;
  letter-spacing: -1.5px;
  font-variant-numeric: tabular-nums;
}
.metric small { font-size: 12px; }

.panel, .credential-card, .source-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 0 0 1px var(--blue-ring), 0 14px 36px var(--shadow);
}
.panel { padding: 23px; margin-bottom: 20px; }
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}
.panel-head p { margin-bottom: 0; }
.big-number {
  font-size: clamp(54px, 9vw, 90px);
  line-height: 0.9;
  letter-spacing: -5px;
  font-weight: 500;
}
.narrow { max-width: 680px; }

button, .button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  background: var(--frost);
  color: var(--text);
  font-weight: 600;
  line-height: 1;
}
button:hover, .button:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
button:focus-visible, .button:focus-visible, input:focus-visible, select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--blue-ring);
}
.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}
.primary:hover { background: var(--accent-strong); }
.ghost { min-height: 40px; padding: 8px 12px; background: transparent; }
.danger { color: var(--danger); }

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}
input, select {
  width: 100%;
  min-height: 44px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  background: var(--field);
}
input::placeholder { color: var(--faint); }
select:disabled, option:disabled { color: var(--muted); }
.form-stack { display: grid; gap: 17px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  gap: 16px;
}
.form-grid .primary { align-self: end; }
.check {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
}
.check input { width: 18px; min-height: 18px; accent-color: var(--accent); }
.compact { min-height: 38px; max-width: 190px; padding: 7px 10px; }
.notice, .alert {
  padding: 12px 14px;
  border-radius: 9px;
  color: var(--muted);
  background: var(--frost);
  border: 1px solid var(--line);
}
.alert { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }

.source-grid, .node-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.source-card { padding: 20px; min-width: 0; }
.source-card.unavailable { box-shadow: 0 0 0 1px var(--line-soft); }
.source-card dl { display: grid; gap: 0; margin: 0; }
.source-card dl div {
  display: grid;
  grid-template-columns: minmax(110px, 0.75fr) minmax(0, 1.25fr);
  gap: 14px;
  padding: 9px 0;
  border-top: 1px solid var(--line-soft);
}
dt { color: var(--muted); }
dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.node-grid .panel { margin-bottom: 0; }
.node-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.source-select { display: flex; align-items: center; gap: 7px; margin-top: 8px; }
.source-select select { min-width: 145px; }
.source-select button { flex: 0 0 auto; }

.table-panel { padding: 0; overflow: hidden; }
.table-panel > .panel-head { padding: 20px 22px 0; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 850px; }
th, td {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: top;
}
th {
  color: var(--muted);
  background: var(--surface-raised);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
td small { display: block; margin-top: 4px; color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
.actions { display: grid; gap: 7px; min-width: 218px; }
.actions form { display: flex; gap: 7px; }
code {
  font-family: "Azeret Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.82em;
  color: var(--text);
  overflow-wrap: anywhere;
}

.credential-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin-bottom: 20px;
  background: var(--line);
}
.credential-card > div { padding: 20px; background: var(--surface); }
.credential-card span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 12px; }
.credential-card code, .credential-card strong { font-size: 17px; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 50% 20%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 34%),
    var(--page);
}
.auth-card {
  width: min(100%, 460px);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--blue-ring), 0 28px 80px var(--shadow);
}
.auth-card h1 { font-size: clamp(36px, 8vw, 52px); }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n + 2) { border-bottom: 1px solid var(--line-soft); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 808px) {
  .shell { display: block; }
  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
    padding: 12px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }
  .brand { padding: 0 4px 10px; }
  .sidebar nav {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none;
  }
  .sidebar nav::-webkit-scrollbar { display: none; }
  .sidebar nav a { flex: 0 0 auto; padding-inline: 13px; }
  .sidebar-foot { margin-top: 0; padding: 10px 4px 0; border-top: 1px solid var(--line-soft); }
  .sidebar-foot > span { width: auto; margin-right: auto; }
  .content { padding: 34px 18px 60px; }
  h1 { font-size: clamp(38px, 12vw, 52px); letter-spacing: -2.5px; }
  .page-head { display: grid; margin-bottom: 28px; }
  .status-stack { justify-items: start; }
  .metric-grid, .source-grid, .node-grid { grid-template-columns: 1fr; }
  .metric { border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .metric:last-child { border-bottom: 0; }
  .form-grid, .node-form { grid-template-columns: 1fr; }
  .source-card dl div { grid-template-columns: 1fr; gap: 2px; }
  .credential-card { grid-template-columns: 1fr; }
  .panel, .source-card { padding: 18px; }
  .auth-shell { padding: 16px; }
  .auth-card { padding: 25px 20px; }
}

@media (max-width: 480px) {
  .metric-grid { grid-template-columns: 1fr; }
  .metric:nth-child(2) { border-bottom: 1px solid var(--line-soft); }
  .panel-head { align-items: stretch; flex-direction: column; }
  .panel-head .button { width: 100%; }
  .source-select { align-items: stretch; flex-direction: column; }
  .source-select button { width: 100%; }
  .sidebar-foot > span { width: 100%; }
}

@media (prefers-reduced-motion: no-preference) {
  button, a, input, select {
    transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
  }
  button:active, .button:active { transform: scale(0.98); }
}
