:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef1f4;
  --text: #17202a;
  --muted: #667085;
  --line: #d8dee6;
  --primary: #226f54;
  --primary-dark: #18543f;
  --accent: #b7791f;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --success-soft: #ecfdf3;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 20px;
  align-items: center;
  min-height: 64px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 720;
  white-space: nowrap;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
}

.topnav {
  display: flex;
  gap: 6px;
}

.topnav a {
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 7px;
  color: var(--muted);
}

.topnav a:hover,
.topnav a.is-active {
  background: var(--surface-2);
  color: var(--text);
}

.logout-form {
  margin: 0;
}

.logout-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.logout-button:hover {
  background: var(--surface-2);
}

.page {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 34px 0 56px;
}

.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 48px;
  align-items: center;
  min-height: calc(100vh - 150px);
}

.auth-copy h1,
.page-head h1,
.empty-state h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 56px);
  line-height: 1.02;
}

.auth-copy p:not(.eyebrow) {
  max-width: 540px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0;
  text-transform: uppercase;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.page-head h1 {
  font-size: clamp(28px, 4vw, 44px);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric,
.summary-panel,
.form-panel,
.empty-state,
.table-wrap,
.monitor-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric {
  padding: 16px;
}

.metric span,
.row-price span,
.summary-price span,
.field span,
.select-field span,
.facts dt {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 28px;
  line-height: 1;
}

.toolbar {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 14px;
}

.select-field {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.select-field select,
.field input,
.field select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
}

.select-field select {
  min-width: 150px;
  padding: 0 34px 0 12px;
}

.monitor-list {
  display: grid;
  gap: 10px;
}

.monitor-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px 140px 150px;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
}

.row-title {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 720;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
}

.status-active,
.status-triggered {
  background: var(--primary);
}

.status-paused,
.status-draft {
  background: var(--accent);
}

.status-failed,
.status-error,
.status-unsupported,
.status-disabled,
.status-deleted {
  background: var(--danger);
}

.url-line {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.row-price strong {
  display: block;
  margin-top: 2px;
  white-space: nowrap;
}

.row-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 680;
  white-space: nowrap;
}

.form-panel {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.wide-form {
  max-width: 760px;
}

.form-panel h2,
.summary-panel h2,
.section-head h2,
.empty-state h2 {
  margin: 0;
  font-size: 20px;
}

.form-grid,
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field {
  display: grid;
  gap: 6px;
}

.field input,
.field select {
  padding: 9px 11px;
}

.field input:focus,
.field select:focus {
  outline: 3px solid rgba(34, 111, 84, 0.16);
  border-color: var(--primary);
}

.field small,
.form-note,
.muted {
  color: var(--muted);
}

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

.toggle-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-weight: 720;
  cursor: pointer;
}

.button-primary {
  background: var(--primary);
  color: #fff;
}

.button-primary:hover {
  background: var(--primary-dark);
}

.button-secondary {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}

.button-danger {
  border-color: #f3b8b2;
  background: var(--danger-soft);
  color: var(--danger);
}

.spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.is-submitting .spinner {
  display: inline-block;
}

.is-submitting .button-label {
  opacity: 0.7;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.alert {
  padding: 12px 14px;
  border-radius: 7px;
  border: 1px solid var(--line);
}

.alert-error {
  background: var(--danger-soft);
  border-color: #f3b8b2;
  color: var(--danger);
}

.alert-success {
  background: var(--success-soft);
  border-color: #abefc6;
  color: var(--primary-dark);
}

.compact {
  margin-top: 12px;
}

.empty-state {
  display: grid;
  gap: 10px;
  justify-items: start;
  padding: 34px;
}

.empty-state p {
  max-width: 640px;
  margin: 0;
  color: var(--muted);
}

.summary-panel {
  padding: 22px;
}

.summary-price {
  margin-bottom: 18px;
}

.summary-price strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1;
}

.facts {
  display: grid;
  gap: 10px;
  margin: 0;
}

.facts div {
  display: grid;
  grid-template-columns: minmax(110px, 0.7fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin: 26px 0 12px;
}

.section-head a {
  color: var(--primary);
  font-weight: 700;
}

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

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

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}

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

.danger-zone {
  display: flex;
  justify-content: flex-end;
  margin-top: 18px;
}

.admin-toolbar {
  justify-content: flex-start;
  align-items: end;
  gap: 10px;
}

.compact-field {
  min-width: 220px;
}

.admin-create-form {
  margin-bottom: 18px;
}

.admin-inline-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(110px, 1fr)) auto;
  gap: 8px;
  align-items: center;
}

.admin-inline-grid input,
.admin-inline-grid select,
.password-form input {
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.password-form {
  display: flex;
  gap: 8px;
}

.inline-form {
  display: inline;
  margin-left: 8px;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 700;
  cursor: pointer;
}

.badge-db {
  background: var(--success-soft);
}

.badge-env {
  background: #fff7ed;
}

.badge-missing {
  background: var(--danger-soft);
  color: var(--danger);
}

@media (max-width: 820px) {
  .topbar {
    grid-template-columns: 1fr auto;
    gap: 12px;
    padding: 12px 16px;
  }

  .topnav {
    grid-column: 1 / -1;
    order: 3;
  }

  .page {
    width: min(100vw - 24px, 1120px);
    padding-top: 24px;
  }

  .auth-layout,
  .detail-grid,
  .form-grid,
  .metrics {
    grid-template-columns: 1fr;
  }

  .auth-layout {
    gap: 22px;
    align-items: start;
    min-height: 0;
  }

  .monitor-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .admin-inline-grid,
  .password-form {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .row-meta {
    justify-content: flex-start;
  }

  .page-head {
    flex-direction: column;
  }

  .actions {
    justify-content: flex-start;
  }
}

@media (max-width: 520px) {
  .brand span:last-child {
    display: none;
  }

  .topnav a {
    flex: 1;
    text-align: center;
  }

  .form-panel,
  .summary-panel,
  .empty-state {
    padding: 18px;
  }

  .facts div {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .button {
    width: 100%;
  }

  .logout-button {
    width: auto;
  }

  .danger-zone {
    justify-content: stretch;
  }
}
