:root {
  color-scheme: light;
  --bg: #eef2f6;
  --panel: #ffffff;
  --panel-soft: #f7f9fb;
  --text: #17202a;
  --muted: #627084;
  --line: #d8e0ea;
  --accent: #1769aa;
  --accent-dark: #0f4f85;
  --danger: #b42318;
  --ok: #16784c;
  --warn: #a15c00;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.shell {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 18px 50px rgba(31, 45, 61, 0.12);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
}

.login-form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea,
button {
  min-height: 40px;
  border-radius: 6px;
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 0 12px;
}

button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button.secondary {
  border-color: var(--line);
  background: #fff;
  color: var(--text);
}

button.danger {
  border-color: #f2b8b5;
  background: #fff;
  color: var(--danger);
}

button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.dashboard-view {
  min-height: 100vh;
}

.admin-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-right: 1px solid var(--line);
  background: #0f1720;
  color: #edf5ff;
  padding: 20px 14px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #2dd4bf;
  color: #061016;
  font-weight: 900;
}

.sidebar-brand strong,
.sidebar-brand span {
  display: block;
}

.sidebar-brand span {
  color: #9fb0c3;
  font-size: 12px;
}

.admin-nav {
  display: grid;
  gap: 6px;
}

.admin-nav button {
  min-height: 44px;
  justify-content: flex-start;
  display: flex;
  align-items: center;
  gap: 10px;
  border-color: transparent;
  background: transparent;
  color: #cbd5e1;
  padding: 0 12px;
  text-align: left;
}

.admin-nav button:hover,
.admin-nav button.active {
  background: rgba(45, 212, 191, 0.12);
  border-color: rgba(45, 212, 191, 0.28);
  color: #fff;
}

.nav-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: inherit;
  flex: 0 0 auto;
}

.nav-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-link {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  color: #cbd5e1;
  padding: 10px 12px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.admin-main {
  min-width: 0;
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.current-user {
  color: var(--muted);
  font-size: 14px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 160px 180px;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
}

.toolbar.users-toolbar {
  grid-template-columns: minmax(240px, 1fr);
}

.settings-panel,
.detail-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-top: 16px;
}

.settings-panel h2,
.settings-panel h3,
.detail-panel h2 {
  margin: 0 0 8px;
}

.settings-panel p,
.detail-panel p {
  margin: 0 0 14px;
  color: var(--muted);
}

textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  font: inherit;
}

.settings-actions,
.detail-header {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.detail-header {
  justify-content: space-between;
}

.summary-grid.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

pre {
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  padding: 12px;
  max-height: 360px;
}

.table-wrap {
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

th {
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

tr:last-child td {
  border-bottom: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-width: 84px;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
}

.status-pill.online {
  background: #e8f6ef;
  color: var(--ok);
}

.status-pill.offline {
  background: #f3f5f7;
  color: var(--muted);
}

.status-pill.pending {
  background: #fff8eb;
  color: var(--warn);
}

.status-pill.completed {
  background: #e8f6ef;
  color: var(--ok);
}

.status-pill.failed,
.status-pill.refunded,
.status-pill.deploy_failed {
  background: #fff0ef;
  color: var(--danger);
}

.settings-panel.inline-panel {
  margin: 14px 0;
}

.status-pill.planned,
.status-pill.queued,
.status-pill.running,
.status-pill.deploying {
  background: #fff8eb;
  color: var(--warn);
}

.status-pill.online {
  background: #e8f6ef;
  color: var(--ok);
}

.online-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--ok);
  vertical-align: middle;
}

.summary-row {
  cursor: pointer;
}

.expanded-row td {
  background: var(--panel-soft);
}

.nested-table {
  min-width: 860px;
  background: #fff;
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.plans-form {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.plans-form button {
  align-self: end;
}

.form-actions {
  display: flex;
  gap: 8px;
  align-items: end;
  flex-wrap: wrap;
}

.wide-field {
  grid-column: span 2;
}

.wide-field textarea {
  min-height: 90px;
}

.plans-table {
  min-width: 1100px;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  margin-right: 8px;
  gap: 6px;
  color: var(--text);
  font-size: 12px;
}

.inline-check input {
  width: auto;
  min-height: 0;
}

.table-input {
  width: 84px;
  min-height: 34px;
}

.node-form {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
}

.compact-form {
  grid-template-columns: repeat(5, minmax(140px, 1fr)) auto auto;
}

.node-form textarea {
  min-height: 112px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}

.checkbox-label {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.checkbox-label input {
  width: auto;
}

.main-text {
  display: block;
  font-weight: 800;
}

.sub-text {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.traffic-bar {
  width: 140px;
  height: 8px;
  margin-top: 6px;
  border-radius: 999px;
  background: #e7edf4;
  overflow: hidden;
}

.traffic-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.traffic-bar span.warn {
  background: var(--warn);
}

.traffic-bar span.danger {
  background: var(--danger);
}

.w-0 { width: 0%; }
.w-5 { width: 5%; }
.w-10 { width: 10%; }
.w-15 { width: 15%; }
.w-20 { width: 20%; }
.w-25 { width: 25%; }
.w-30 { width: 30%; }
.w-35 { width: 35%; }
.w-40 { width: 40%; }
.w-45 { width: 45%; }
.w-50 { width: 50%; }
.w-55 { width: 55%; }
.w-60 { width: 60%; }
.w-65 { width: 65%; }
.w-70 { width: 70%; }
.w-75 { width: 75%; }
.w-80 { width: 80%; }
.w-85 { width: 85%; }
.w-90 { width: 90%; }
.w-95 { width: 95%; }
.w-100 { width: 100%; }

.empty {
  padding: 32px;
  color: var(--muted);
  text-align: center;
}

.config-workspace {
  padding: 18px;
}

.config-workspace-head,
.config-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.config-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.config-stats span,
.radio-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--muted);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 800;
}

.config-stats strong,
.radio-label strong {
  color: var(--text);
}

.config-workspace-grid {
  display: grid;
  grid-template-columns: minmax(520px, 2fr) minmax(280px, 1fr);
  gap: 14px;
  align-items: stretch;
}

.config-bulk-panel,
.config-preview-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 14px;
}

.config-preview-panel h4 {
  margin: 0 0 10px;
}

.config-scope-row,
.preset-row,
.config-actions-wide {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.radio-label {
  cursor: pointer;
}

.radio-label input,
.select-cell input,
.config-field-toggle input {
  width: auto;
  min-height: 0;
}

.config-field-matrix {
  display: grid;
  gap: 8px;
}

.config-field-row {
  display: grid;
  grid-template-columns: 150px minmax(180px, 1fr) 88px;
  align-items: center;
  gap: 10px;
}

.config-field-row > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.config-field-toggle {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.config-table {
  min-width: 1180px;
}

.select-cell {
  width: 44px;
  text-align: center;
}

.selected-row td {
  background: #f3f8fd;
}

.override-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 4px;
}

.config-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  background: #e8f1fa;
  color: var(--accent-dark);
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 800;
}

.config-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.config-actions button {
  min-height: 34px;
}

.config-editor-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 12px;
  margin: 12px 0;
}

.config-editor-head p {
  margin-bottom: 0;
}

@media (max-width: 820px) {
  .admin-main {
    padding: 16px;
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: static;
    height: auto;
  }

  .admin-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .summary-grid,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .config-workspace-head,
  .config-editor-head {
    flex-direction: column;
  }

  .config-workspace-grid,
  .config-editor-grid,
  .plans-form {
    grid-template-columns: 1fr;
  }

  .wide-field {
    grid-column: span 1;
  }

  .config-field-row {
    grid-template-columns: 1fr;
  }
}
