@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=Sora:wght@400;500;600;700&display=swap");

:root {
  color-scheme: light;
  --bg: #f6f3ec;
  --bg-deep: #efe7da;
  --ink: #1f2a34;
  --ink-soft: #5a6470;
  --accent: #0f766e;
  --accent-strong: #0b4d48;
  --accent-soft: #d4f5f0;
  --danger: #b42318;
  --danger-soft: #ffe1db;
  --panel: #ffffff;
  --panel-border: rgba(15, 118, 110, 0.22);
  --shadow: 0 22px 48px rgba(15, 23, 42, 0.12);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Sora", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 10% 10%, rgba(15, 118, 110, 0.14), transparent 60%),
    radial-gradient(circle at 90% 15%, rgba(180, 83, 9, 0.18), transparent 55%),
    linear-gradient(120deg, #f9f5ef, #f1e9dc 60%, #efe6d7);
  padding: clamp(1.5rem, 4vw, 3.5rem);
  position: relative;
  overflow-x: hidden;
}

.backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}

.glow {
  position: absolute;
  border-radius: 50%;
  opacity: 0.6;
}

.glow--one {
  width: 380px;
  height: 380px;
  top: -140px;
  left: -140px;
  background: radial-gradient(circle at 30% 30%, rgba(15, 118, 110, 0.35), transparent 70%);
}

.glow--two {
  width: 420px;
  height: 420px;
  right: -180px;
  bottom: -200px;
  background: radial-gradient(circle at 35% 35%, rgba(217, 119, 6, 0.3), transparent 72%);
}

.grid {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(15, 118, 110, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 118, 110, 0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.35;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), #f59e0b);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.brand-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
}

.brand-subtitle {
  margin: 0.25rem 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.token-box {
  display: grid;
  gap: 0.4rem;
  font-size: 0.8rem;
}

.token-box label {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-soft);
}

.token-box input {
  border-radius: 12px;
  border: 1px solid rgba(15, 118, 110, 0.25);
  padding: 0.6rem 0.8rem;
  font-family: "IBM Plex Mono", "Courier New", monospace;
  background: rgba(255, 255, 255, 0.9);
}

.token-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.token-row input {
  flex: 1 1 160px;
}

.layout {
  display: grid;
  gap: 1.8rem;
}

.panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: clamp(1.5rem, 3vw, 2.4rem);
  box-shadow: var(--shadow);
  border: 1px solid var(--panel-border);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.6rem;
}

.eyebrow {
  margin: 0 0 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  font-size: 0.68rem;
  color: var(--accent-strong);
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
}

h2 {
  font-size: 1.3rem;
}

.components-panel {
  margin-top: 1.2rem;
}

.status-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.status-card {
  border-radius: 14px;
  border: 1px solid rgba(15, 118, 110, 0.16);
  padding: 1rem 1.2rem;
  background: rgba(248, 245, 240, 0.8);
}

.status-label {
  margin: 0 0 0.5rem;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.status-value {
  margin: 0;
  font-size: clamp(0.95rem, 2vw, 1.15rem);
  font-weight: 600;
  word-break: break-word;
}

.status-note {
  margin: 0.35rem 0 0;
  font-size: 0.7rem;
  line-height: 1.35;
  color: var(--ink-soft);
  word-break: break-word;
}

.inline-message {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.form-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: end;
}

.replication-grid {
  margin-bottom: 1rem;
}

.replication-note {
  margin: 0 0 1rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.1);
  color: var(--accent-strong);
  font-size: 0.85rem;
}

.replication-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.field--span {
  grid-column: 1 / -1;
}

.field {
  display: grid;
  gap: 0.4rem;
  font-size: 0.9rem;
}

.field input,
.field select {
  border-radius: 12px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  padding: 0.65rem 0.75rem;
  font-size: 0.95rem;
  font-family: "Sora", sans-serif;
  background: rgba(255, 255, 255, 0.95);
}

.field textarea {
  border-radius: 12px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  padding: 0.7rem 0.75rem;
  font-size: 0.95rem;
  font-family: "IBM Plex Mono", "Courier New", monospace;
  background: rgba(255, 255, 255, 0.95);
  resize: vertical;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
}

.maintenance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.maintenance-note {
  margin: 0;
  color: var(--ink-soft);
}

.backup-note {
  margin: 0 0 1rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.backup-summary {
  display: grid;
  gap: 1.2rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin-bottom: 1.5rem;
}

.backup-usage {
  border-radius: 14px;
  border: 1px solid rgba(15, 118, 110, 0.16);
  padding: 1rem 1.2rem;
  background: rgba(255, 255, 255, 0.7);
}

.summary-title {
  margin: 0 0 0.6rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.24em;
  color: var(--accent-strong);
}

.usage-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.12);
  overflow: hidden;
}

.usage-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #f59e0b);
  transition: width 0.4s ease;
}

.usage-bar--mini {
  height: 6px;
  margin-top: 0.4rem;
}

.usage-meta {
  margin-top: 0.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.backup-stats {
  display: grid;
  gap: 0.8rem;
}

.stat-tile {
  border-radius: 14px;
  border: 1px solid rgba(15, 118, 110, 0.12);
  padding: 0.85rem 1rem;
  display: grid;
  gap: 0.35rem;
  background: rgba(255, 255, 255, 0.75);
}

.stat-tile span {
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.stat-tile strong {
  font-size: 1.05rem;
}

.backup-tools {
  display: grid;
  gap: 1.5rem;
  margin-bottom: 1.6rem;
}

.backup-tool {
  border-radius: 16px;
  border: 1px solid rgba(15, 118, 110, 0.14);
  padding: 1.2rem;
  background: rgba(255, 255, 255, 0.8);
}

.backup-tool h3 {
  margin: 0;
  font-size: 1.05rem;
}

.backup-tool-grid {
  align-items: end;
}

#backup_latest_age[data-tone="warn"] {
  color: var(--danger);
}

#backup_latest_age[data-tone="ok"] {
  color: var(--accent-strong);
}

.table {
  display: grid;
  gap: 0.6rem;
}

.table-head,
.table-row {
  display: grid;
  grid-template-columns: 1.9fr 0.6fr 0.8fr 0.9fr 0.6fr;
  gap: 0.8rem;
  align-items: center;
}

.table--repl .table-head,
.table--repl .table-row {
  grid-template-columns: 1.4fr 0.7fr 0.5fr 0.7fr 1fr 1fr 1.1fr;
}

.table--rows .table-head,
.table--rows .table-row {
  grid-template-columns: 1fr 1.4fr 0.7fr;
}

.table--migration .table-head,
.table--migration .table-row {
  grid-template-columns: 1.2fr 0.5fr 2fr;
}

.table--components .table-head,
.table--components .table-row {
  grid-template-columns: 1.1fr 0.8fr 0.6fr 1.5fr;
}

.table-head {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--ink-soft);
}

.table-body {
  display: grid;
  gap: 0.5rem;
}

.table-row {
  background: rgba(248, 245, 240, 0.7);
  border-radius: 12px;
  padding: 0.8rem;
  border: 1px solid rgba(15, 118, 110, 0.12);
  font-size: 0.86rem;
}

.table-row span:last-child {
  display: flex;
  gap: 0.5rem;
}

.table--components .table-row span:last-child {
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
}

.status-pill--ok {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.status-pill--warn {
  background: #fff2c2;
  color: #a16207;
}

.status-pill--down {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-pill--unknown {
  background: rgba(148, 163, 184, 0.25);
  color: #475569;
}

.cutover-progress {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.cutover-bar {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.15);
  overflow: hidden;
}

.cutover-bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.cutover-list {
  display: grid;
  gap: 0.6rem;
}

.cutover-item {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  background: rgba(248, 245, 240, 0.7);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  border: 1px solid rgba(15, 118, 110, 0.12);
  font-size: 0.92rem;
}

.cutover-item input {
  margin-top: 0.2rem;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 0.65rem 1.1rem;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 24px rgba(15, 118, 110, 0.25);
}

.btn--danger {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 12px 24px rgba(180, 35, 24, 0.25);
}

.btn--ghost {
  background: rgba(15, 118, 110, 0.12);
  color: var(--accent-strong);
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}

.sql-output {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  border: 1px dashed rgba(15, 118, 110, 0.24);
  background: rgba(15, 118, 110, 0.08);
  font-family: "IBM Plex Mono", "Courier New", monospace;
  font-size: 0.85rem;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 140px;
}

@media (max-width: 900px) {
  .table-head {
    display: none;
  }

  .table-row {
    grid-template-columns: 1fr;
  }

  .table-row span:last-child {
    justify-content: flex-start;
  }
}

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

  .token-box {
    width: 100%;
  }
}
