:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --line: #d9e1ea;
  --line-strong: #c7d1dc;
  --text: #16202c;
  --muted: #657386;
  --accent: #0f6b57;
  --accent-dark: #0a4f41;
  --danger: #b83f47;
  --warning: #a76c18;
  --ok: #21764f;
  --shadow: 0 18px 50px rgb(35 48 67 / 0.08);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  background:
    linear-gradient(180deg, rgb(244 246 248 / 0.92), rgb(244 246 248 / 1)),
    radial-gradient(circle at top left, rgb(15 107 87 / 0.12), transparent 34%);
}

h1,
h2,
h3,
p {
  margin: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

button:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.64;
}

button.secondary,
button.ghost-button {
  border-color: var(--line-strong);
  background: #fff;
  color: var(--text);
}

button.secondary:hover,
button.ghost-button:hover {
  border-color: var(--accent);
  background: #f5fbf9;
}

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

button.danger:hover {
  background: #96343b;
  border-color: #96343b;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgb(15 107 87 / 0.12);
}

textarea {
  min-height: 96px;
  padding: 11px 12px;
  resize: vertical;
  line-height: 1.45;
}

label {
  display: grid;
  gap: 7px;
  color: #3d4b5d;
  font-size: 13px;
  font-weight: 700;
}

.auth-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(440px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgb(255 255 255 / 0.92);
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
}

.login-panel h1 {
  margin-top: 18px;
  font-size: 30px;
  letter-spacing: 0;
}

.login-panel p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.form-error {
  margin-top: 16px;
  padding: 10px 12px;
  border: 1px solid rgb(184 63 71 / 0.28);
  border-radius: 8px;
  background: rgb(184 63 71 / 0.08);
  color: #873039;
  font-weight: 700;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgb(255 255 255 / 0.86);
  backdrop-filter: blur(14px);
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.side-brand strong {
  display: block;
  font-size: 16px;
}

.side-brand span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

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

.side-nav a {
  display: block;
  border-radius: 8px;
  padding: 10px 12px;
  color: #334155;
  text-decoration: none;
  font-weight: 700;
}

.side-nav a.active,
.side-nav a:hover {
  background: #e8f3f0;
  color: var(--accent-dark);
}

.ghost-button {
  margin-top: auto;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

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

.workspace-head h1 {
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: 0;
  line-height: 1.08;
}

.workspace-head p,
.section-head p {
  margin-top: 7px;
  color: var(--muted);
  line-height: 1.5;
}

.config {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  color: #455569;
  white-space: nowrap;
}

.badge.warn {
  border-color: rgb(167 108 24 / 0.32);
  background: #fff7e8;
  color: var(--warning);
}

.badge.ok {
  border-color: rgb(33 118 79 / 0.3);
  background: #ecf8f3;
  color: var(--ok);
}

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

.metrics article {
  min-height: 92px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.metrics span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metrics strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgb(35 48 67 / 0.04);
  margin-bottom: 18px;
  padding: 18px;
}

[hidden] {
  display: none !important;
}

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

.section-head h2 {
  font-size: 20px;
}

.add-form {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) 260px auto;
  gap: 12px;
  align-items: end;
}

.domain-list-field {
  align-self: stretch;
}

.domain-list-field textarea {
  min-width: 100%;
}

.toolbar {
  align-items: end;
}

.filters {
  display: grid;
  grid-template-columns: minmax(180px, 240px) 130px 180px;
  gap: 10px;
}

.domain-groups {
  display: grid;
  gap: 18px;
}

.domain-groups.loading {
  opacity: 0.72;
}

.date-group {
  display: grid;
  gap: 10px;
}

.date-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 2px;
}

.date-head h3 {
  font-size: 15px;
}

.date-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.domain-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.domain-table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
}

.domain-table th,
.domain-table td {
  padding: 9px 10px;
  border-bottom: 1px solid #edf1f5;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

.domain-table th {
  background: #f8fafc;
  color: #5c697a;
  font-size: 12px;
  font-weight: 900;
}

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

.domain-table tbody tr {
  transition: background 120ms ease, box-shadow 120ms ease;
}

.domain-table tbody tr.row-queued {
  background: #fff;
}

.domain-table tbody tr.row-purchased {
  background: #edf9f1;
}

.domain-table tbody tr.row-purchased td {
  border-bottom-color: #d2ecdc;
}

.domain-table tbody tr.row-available {
  background: #f0fbf4;
}

.domain-table tbody tr.row-active {
  background: #eef6ff;
}

.domain-table tbody tr.row-dry-run {
  background: #fff8eb;
}

.domain-table tbody tr.row-failed {
  background: #fff0f1;
}

.domain-table tbody tr.row-failed td {
  border-bottom-color: #f3d1d5;
}

.domain-table tbody tr:hover {
  box-shadow: inset 3px 0 0 var(--accent);
}

.domain-table tbody tr.row-failed:hover {
  box-shadow: inset 3px 0 0 var(--danger);
}

.domain-cell {
  min-width: 220px;
}

.domain-cell strong {
  display: block;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.domain-cell span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: nowrap;
}

.status {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--surface-2);
  color: #334155;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.status.purchased {
  background: #e4f7ec;
  color: #17643e;
}

.status.available_now {
  background: #dcfce7;
  color: #166534;
}

.status.failed,
.status.unavailable {
  background: #fde7e9;
  color: #873039;
}

.status.scheduled,
.status.retrying,
.status.checking,
.status.lookup_pending,
.status.lookup_running {
  background: #e8f3f0;
  color: var(--accent-dark);
}

.status.available_dry_run {
  background: #fff7e8;
  color: var(--warning);
}

.note-cell {
  max-width: 360px;
  color: #536173;
  font-size: 12px;
  line-height: 1.35;
}

.note-cell strong {
  display: inline-block;
  margin-right: 6px;
  color: var(--accent-dark);
}

.row-actions {
  min-width: 270px;
  white-space: nowrap;
}

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

.actions-row button,
.icon-button {
  min-height: 34px;
  padding: 0 10px;
  font-size: 12px;
}

.empty-state {
  padding: 38px 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: #fbfcfd;
  text-align: center;
}

.empty-state h3 {
  font-size: 18px;
}

.empty-state p {
  margin-top: 6px;
  color: var(--muted);
}

.empty-state.error {
  border-color: rgb(184 63 71 / 0.32);
  background: rgb(184 63 71 / 0.06);
}

.settings-grid {
  display: grid;
  gap: 10px;
}

.setting-row {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 54px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfd;
}

.setting-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.setting-row strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.setting-row em {
  justify-self: end;
  border-radius: 999px;
  background: #e8f3f0;
  color: var(--accent-dark);
  padding: 5px 8px;
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

dialog {
  width: min(860px, calc(100vw - 32px));
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgb(22 32 44 / 0.36);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

pre {
  max-height: 520px;
  overflow: auto;
  margin: 0;
  background: #111827;
  color: #e5e7eb;
  padding: 12px;
  border-radius: 10px;
  white-space: pre-wrap;
}

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

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .side-nav {
    display: flex;
    overflow-x: auto;
  }

  .ghost-button {
    margin-top: 0;
    margin-left: auto;
  }

  .workspace {
    padding: 18px;
  }

  .workspace-head,
  .section-head {
    display: grid;
  }

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

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

  .add-form,
  .filters {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .auth-shell {
    padding: 14px;
  }

  .login-panel {
    padding: 22px;
  }

  .sidebar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .side-nav {
    order: 3;
    width: 100%;
  }

  .workspace {
    padding: 14px;
  }

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

  .setting-row {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .setting-row em {
    justify-self: start;
  }

  .actions-row button {
    flex: 1 1 auto;
  }
}
