:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f6f8;
  color: #17202a;
  --border: #d8dee8;
  --muted: #647184;
  --panel: #ffffff;
  --accent: #1f6f8b;
  --accent-dark: #164c61;
  --danger: #a33a36;
  --danger-dark: #742824;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

a {
  color: #155f7a;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
.button-link,
input,
select,
textarea {
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
  min-height: 36px;
}

button,
.button-link {
  align-items: center;
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  line-height: 1;
  padding: 0 12px;
  text-decoration: none;
  white-space: nowrap;
}

button:hover,
.button-link:hover {
  background: var(--accent-dark);
  text-decoration: none;
}

button:disabled {
  cursor: default;
  opacity: 0.6;
}

button.secondary,
.button-link.secondary {
  background: #ffffff;
  border-color: #aeb8c6;
  color: #233142;
}

button.secondary:hover,
.button-link.secondary:hover {
  background: #eef2f6;
}

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

button.danger:hover,
.button-link.danger:hover {
  background: var(--danger-dark);
}

button.danger:disabled {
  background: #b7bec8;
  border-color: #b7bec8;
}

button.success {
  background: #267447;
  border-color: #267447;
}

button.success:hover {
  background: #185c35;
}

button.ssh-revoke {
  background: #ffffff;
  border-color: var(--danger);
  color: var(--danger);
}

button.ssh-revoke:hover,
button.ssh-revoke.is-revoking {
  background: var(--danger);
  color: #ffffff;
}

input,
select,
textarea {
  background: #ffffff;
  color: #17202a;
  padding: 6px 9px;
  width: 100%;
}

textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.45;
  resize: vertical;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.95em;
}

h1,
h2 {
  letter-spacing: 0;
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 650;
}

h2 {
  font-size: 16px;
  font-weight: 650;
}

p {
  margin: 0;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.app-shell {
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: #ffffff;
  border-right: 1px solid var(--border);
  padding: 18px 14px;
}

.brand {
  color: #101820;
  font-size: 18px;
  font-weight: 700;
  margin: 0 6px 18px;
}

.nav {
  display: grid;
  gap: 4px;
}

.nav-link {
  align-items: center;
  border-radius: 5px;
  color: #263445;
  display: flex;
  font-weight: 600;
  justify-content: space-between;
  min-height: 38px;
  padding: 0 10px;
}

.nav-link:hover {
  background: #eef2f6;
  text-decoration: none;
}

.nav-link.active {
  background: #dfeaf0;
  color: #123f52;
}

.badge {
  background: #ffffff;
  border: 1px solid #bdc8d5;
  border-radius: 999px;
  color: #344456;
  font-size: 12px;
  min-width: 26px;
  padding: 2px 8px;
  text-align: center;
}

.workspace {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
}

.topbar {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  min-height: 64px;
  padding: 12px 24px;
}

.topbar-actions,
.button-row,
.actions-cell,
.page-actions,
.section-heading {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.username {
  color: #344456;
  font-weight: 600;
  min-width: 0;
}

.content {
  display: grid;
  gap: 12px;
  padding: 16px 20px 32px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 12px;
}

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

.detail-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.detail-stack {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr);
  width: 100%;
}

.section-heading {
  justify-content: space-between;
}

.stack-form {
  display: grid;
  gap: 12px;
}

.inline-form {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(180px, 1.2fr) minmax(220px, 1.3fr) auto auto;
}

.row-form {
  display: grid;
  gap: 9px;
  max-width: 720px;
}

.row-form label {
  align-items: center;
  color: #344456;
  display: grid;
  font-size: 13px;
  font-weight: 600;
  gap: 10px;
  grid-template-columns: 9rem minmax(0, 1fr);
}

.row-form-actions {
  padding-left: calc(9rem + 10px);
}

.stack-form label,
.checkbox-label {
  color: #344456;
  display: grid;
  font-size: 13px;
  font-weight: 600;
  gap: 5px;
}

.checkbox-label {
  align-items: center;
  display: flex;
  min-height: 36px;
}

.checkbox-label input {
  height: 16px;
  min-height: 16px;
  width: 16px;
}

.table-wrap {
  overflow-x: auto;
  width: 100%;
}

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

th,
td {
  border-bottom: 1px solid #e4e9f0;
  font-size: 14px;
  padding: 7px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 650;
}

tbody tr:hover {
  background: #f8fafc;
}

.bundle-artifact-secondary {
  background: #f8fafc;
  color: var(--muted);
}

.bundle-artifact-primary:has(+ .bundle-artifact-secondary) td {
  border-bottom-color: transparent;
}

tr.warning-row {
  background: #fff5d8;
}

.kv-table {
  min-width: 0;
}

.kv-table th {
  width: 190px;
}

.config-editor {
  border-top: 1px solid #e4e9f0;
  display: grid;
  gap: 12px;
  padding-top: 12px;
}

.config-help,
.config-row-status {
  color: var(--muted);
  font-size: 12px;
}

.config-group {
  display: grid;
  gap: 6px;
}

.config-group h3 {
  color: #263445;
  font-size: 14px;
  margin: 0;
}

.config-table {
  min-width: 860px;
}

.config-table th:first-child {
  width: 230px;
}

.config-table td:nth-child(2) {
  width: 40%;
}

.config-field-label {
  cursor: help;
}

.config-actions {
  text-align: right;
  white-space: nowrap;
  width: 150px;
}

.password-config-control {
  display: grid;
  gap: 6px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.password-config-control input {
  min-width: 0;
}

.vhost-config-control {
  display: grid;
  gap: 0.45rem;
}

.vhost-config-control select,
.vhost-config-control input {
  width: 100%;
}

button.compact,
.button-link.compact {
  font-size: 12px;
  min-height: 30px;
  padding: 0 9px;
}

.config-row.is-default-diff {
  background: #eef7ff;
}

.config-row.is-dirty {
  background: #fff7df;
}

.config-row.is-invalid {
  background: #fff0ef;
}

.config-row.is-invalid .config-row-status {
  color: #7c2e2a;
  font-weight: 600;
}

.config-row.is-dirty input,
.config-row.is-dirty select {
  border-color: #d4a52a;
}

.config-row.is-default-diff input,
.config-row.is-default-diff select {
  border-color: #80b9d4;
}

.config-row.is-invalid input,
.config-row.is-invalid select {
  border-color: #d78d88;
}

option.unsupported-option {
  color: #a33a36;
}

.status-pill {
  border: 1px solid #cbd5df;
  border-radius: 999px;
  display: inline-block;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.2;
  max-width: 100%;
  overflow-wrap: anywhere;
  padding: 3px 8px;
}

.status-pill.green {
  background: #e8f5ee;
  border-color: #9fd0b4;
  color: #1f6b3d;
}

.status-pill.blue {
  background: #e8f2fb;
  border-color: #9cc3e1;
  color: #185c86;
}

.status-pill.yellow {
  background: #fff5d8;
  border-color: #dcb85a;
  color: #775313;
}

.status-pill.red {
  background: #fdebea;
  border-color: #dda09b;
  color: #8f302b;
}

.status-pill.neutral {
  background: #f4f6f8;
  color: #435267;
}

.hotfix-marker {
  color: #b42318;
  display: inline-block;
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  margin-left: 6px;
  vertical-align: middle;
}

.connection-light {
  border-radius: 50%;
  box-shadow: 0 0 4px currentColor;
  display: inline-block;
  height: 11px;
  margin-right: 8px;
  width: 11px;
}

.connection-light.green { background: #22a35a; color: #22a35a; }
.connection-light.red { background: #d64d46; color: #d64d46; }

.topbar h1 > span { align-items: center; display: inline-flex; }
.topbar h1 small { color: var(--muted); display: block; font-size: 11px; font-weight: 500; margin-top: 3px; }

.usage-meter { background: #e7ecf1; display: block; height: 10px; min-width: 110px; overflow: hidden; }
.usage-meter span { display: block; height: 100%; }
.usage-meter.green span { background: #2b9b57; }
.usage-meter.yellow span { background: #d99c24; }
.usage-meter.red span { background: #cf514a; }
.section-actions { align-items: center; display: flex; gap: 10px; }
.unit-switch { align-items: center; color: var(--muted); display: inline-flex; font-size: 12px; gap: 6px; }
.unit-switch input { height: 0; opacity: 0; position: absolute; width: 0; }
.unit-switch i { background: #8b98a8; border-radius: 10px; height: 18px; position: relative; width: 34px; }
.unit-switch i::after { background: #fff; border-radius: 50%; content: ""; height: 14px; left: 2px; position: absolute; top: 2px; transition: transform 120ms ease; width: 14px; }
.unit-switch input:checked + i { background: #287fbb; }
.unit-switch input:checked + i::after { transform: translateX(16px); }
.unit-switch input:focus-visible + i { outline: 2px solid #287fbb; outline-offset: 2px; }
.expandable-row { cursor: pointer; }
.expand-arrow { color: var(--muted); text-align: center; width: 28px; }
.expanded-detail td { background: #f8fafc; padding: 8px 14px; }
.expanded-detail ul { margin: 6px 0 0; padding-left: 18px; }
.storage-path-list { margin: 0; padding-left: 18px; }

.hotfix-overlay {
  display: grid;
  gap: 6px;
}

.hotfix-overlay h3 {
  color: #263445;
  font-size: 14px;
  margin: 0;
}

.hotfix-table {
  min-width: 1120px;
}

.hotfix-table code {
  overflow-wrap: anywhere;
}

.hotfix-upper {
  background: #fffdf5;
}

.hotfix-lower {
  color: var(--muted);
}

.ssh-keys-table {
  min-width: 900px;
}

.ssh-public-key {
  overflow-wrap: anywhere;
}

.ssh-key-row.ssh-pending {
  background: #e8f2fb;
}

.ssh-key-row.ssh-revoking {
  background: #fdebea;
}

.ssh-key-row.ssh-unsaved {
  background: #fff5d8;
}

.ssh-key-dialog,
.purge-dialog {
  border: 1px solid var(--border);
  border-radius: 6px;
  max-width: 680px;
  padding: 18px;
  width: calc(100% - 32px);
}

.ssh-key-dialog::backdrop,
.purge-dialog::backdrop {
  background: rgb(23 32 42 / 45%);
}

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

.danger-zone .section-heading {
  align-items: center;
}

.danger-zone .section-heading p {
  margin-bottom: 0;
}

.field-error {
  color: var(--danger);
  font-size: 13px;
}

.empty {
  color: var(--muted);
  padding: 14px 8px;
}

.notice {
  border: 1px solid #b9c8d1;
  border-radius: 5px;
  color: #17394a;
  background: #edf6fa;
  padding: 10px 12px;
}

.notice.error {
  background: #fff0ef;
  border-color: #e7b7b4;
  color: #7c2e2a;
}

.login-page {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: 24px;
}

.login-panel {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 6px;
  display: grid;
  gap: 18px;
  margin: 0 auto;
  max-width: 380px;
  padding: 24px;
  width: 100%;
}

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

  .sidebar {
    border-bottom: 1px solid var(--border);
    border-right: 0;
    padding: 12px;
  }

  .brand {
    margin-bottom: 10px;
  }

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

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 16px;
  }

  .content {
    padding: 16px;
  }

  .inline-form {
    grid-template-columns: 1fr;
  }

  .row-form {
    max-width: none;
  }

  .row-form label {
    align-items: stretch;
    gap: 5px;
    grid-template-columns: 1fr;
  }

  .row-form-actions {
    padding-left: 0;
  }

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

  table {
    min-width: 680px;
  }
}
