:root {
  color-scheme: light;
  --bg: #f7f7f2;
  --panel: #ffffff;
  --panel-soft: #f1f5f4;
  --ink: #17211f;
  --muted: #60706c;
  --line: #d9dfdc;
  --accent: #1e6f65;
  --accent-dark: #15544c;
  --danger: #a33b32;
  --warn: #936c18;
  --ok: #21764a;
  --shadow: 0 12px 30px rgba(20, 33, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.button-link {
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(30, 111, 101, 0.3);
  outline-offset: 2px;
}

button.secondary,
button.danger,
.button-link.secondary {
  background: #fff;
  color: var(--accent-dark);
}

button.danger {
  border-color: var(--danger);
  color: var(--danger);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

a {
  color: var(--accent-dark);
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 74px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 247, 242, 0.94);
  backdrop-filter: blur(12px);
}

.topbar h1,
.section-head h2 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.session {
  display: flex;
  align-items: center;
  gap: 10px;
}

.session span {
  max-width: 28ch;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shell {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 24px;
  padding: 24px;
}

.sidebar {
  position: sticky;
  top: 98px;
  align-self: start;
  display: grid;
  gap: 6px;
}

.nav-item {
  justify-content: start;
  width: 100%;
  border-color: transparent;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  border-color: var(--line);
  background: #fff;
  color: var(--accent-dark);
}

.requires-auth {
  opacity: 0.62;
  pointer-events: none;
}

.requires-auth button,
.requires-auth input,
.requires-auth select,
.requires-auth textarea {
  pointer-events: none;
}

.content {
  min-width: 0;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
}

.metrics,
.grid {
  display: grid;
  gap: 14px;
}

.metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metrics article,
.panel,
.status-box,
.secret-box,
.alert,
.table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metrics article {
  display: grid;
  gap: 4px;
  padding: 18px;
}

.metrics span {
  font-size: 2rem;
  font-weight: 800;
}

.metrics small,
.muted {
  color: var(--muted);
}

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

.panel,
.status-box,
.secret-box,
.alert {
  padding: 16px;
}

.panel h3 {
  margin: 0 0 12px;
}

.panel-head,
.drawer-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.panel-head h3,
.drawer-head h2 {
  margin: 0;
}

.details {
  display: grid;
  gap: 8px;
}

.details div {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
}

.details dt {
  color: var(--muted);
  font-weight: 700;
}

.compact-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.compact-list li + li {
  margin-top: 8px;
}

.form-row,
.form-grid {
  display: grid;
  gap: 10px;
  align-items: end;
}

.form-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.form-row button {
  width: max-content;
}

.form-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.wide {
  grid-column: 1 / -1;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.row-actions.end {
  justify-content: end;
}

.choice {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 7px;
  color: var(--ink);
}

.choice input {
  width: auto;
}

.pill {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.id-chip {
  min-height: 0;
  border-color: var(--line);
  background: var(--panel-soft);
  color: var(--ink);
  padding: 3px 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  font-weight: 700;
}

.domain-line {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}

.domain-badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 7px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.pill.ok {
  color: var(--ok);
}

.pill.warn {
  color: var(--warn);
}

.pill.danger {
  color: var(--danger);
}

.code-output {
  min-height: 170px;
  max-height: 560px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10201d;
  color: #e9f4ef;
  padding: 14px;
  white-space: pre;
}

.code-output.small {
  min-height: 140px;
  max-height: 320px;
  margin-top: 14px;
  font-size: 0.82rem;
}

.secret-box {
  border-color: var(--warn);
  background: #fff8e6;
}

.secret-value {
  overflow-x: auto;
  margin: 10px 0;
  border: 1px solid #ead393;
  border-radius: 6px;
  background: #fffdf4;
  padding: 12px;
  white-space: pre;
}

.alert {
  border-color: var(--danger);
  color: var(--danger);
  background: #fff4f2;
}

.alert.notice {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: #eef8f5;
}

.hidden {
  display: none !important;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(23, 33, 31, 0.32);
}

.modal {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 14px;
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(20, 33, 31, 0.22);
  padding: 18px;
}

.modal h2,
.modal p {
  margin: 0;
}

.modal-body {
  display: grid;
  gap: 10px;
}

.drawer {
  position: fixed;
  z-index: 15;
  top: 0;
  right: 0;
  display: grid;
  align-content: start;
  gap: 12px;
  width: min(560px, 100vw);
  height: 100vh;
  overflow: auto;
  border-left: 1px solid var(--line);
  background: var(--panel);
  box-shadow: -16px 0 60px rgba(20, 33, 31, 0.16);
  padding: 18px;
}

.rollback-option {
  margin: 0 0 12px;
}

@media (max-width: 960px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metrics,
  .grid.two,
  .form-row,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-row button {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: start;
    flex-direction: column;
    padding: 14px;
  }

  .shell {
    padding: 14px;
  }

  .sidebar {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .session {
    width: 100%;
    flex-wrap: wrap;
  }

  table {
    min-width: 0;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  thead {
    display: none;
  }

  tr {
    display: grid;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid var(--line);
  }

  td {
    display: grid;
    grid-template-columns: minmax(90px, 34%) minmax(0, 1fr);
    gap: 10px;
    padding: 0;
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
  }

  .details div {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}
