@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

:root {
  --admin-bg: #f0f2f6;
  --admin-panel: #ffffff;
  --admin-panel-muted: #f8f9fb;
  --admin-border: #e2e8f0;
  --admin-border-strong: #cbd5e1;
  --admin-text: #0f172a;
  --admin-muted: #64748b;
  --admin-accent: #0d9488;
  --admin-accent-hover: #0f766e;
  --admin-accent-soft: rgba(13, 148, 136, 0.1);
  --admin-gold: #b45309;
  --admin-gold-soft: rgba(180, 83, 9, 0.08);
  --admin-danger: #dc2626;
  --admin-danger-soft: rgba(220, 38, 38, 0.08);
  --admin-radius: 12px;
  --admin-radius-sm: 8px;
  --admin-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --admin-shadow-lg: 0 10px 40px rgba(15, 23, 42, 0.08);
  --admin-font: "DM Sans", "Segoe UI", system-ui, sans-serif;
  --sidebar-w: 260px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--admin-font);
  background: var(--admin-bg);
  color: var(--admin-text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--admin-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }

code {
  font-size: 0.85em;
  background: var(--admin-panel-muted);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  border: 1px solid var(--admin-border);
}

/* Login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse at 15% 10%, rgba(13, 148, 136, 0.12), transparent 45%),
    radial-gradient(ellipse at 85% 90%, rgba(180, 83, 9, 0.08), transparent 45%),
    var(--admin-bg);
}

.login-card {
  width: min(420px, 100%);
  background: var(--admin-panel);
  border: 1px solid var(--admin-border);
  border-radius: calc(var(--admin-radius) + 4px);
  padding: 2.25rem;
  box-shadow: var(--admin-shadow-lg);
}

.login-card h1 {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-card p { color: var(--admin-muted); font-size: 0.92rem; margin: 0 0 1.75rem; }

.field { margin-bottom: 1.1rem; }

.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--admin-text);
  margin-bottom: 0.4rem;
}

.field input, .field select, .field textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border-radius: var(--admin-radius-sm);
  border: 1px solid var(--admin-border-strong);
  background: var(--admin-panel);
  color: var(--admin-text);
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--admin-accent);
  box-shadow: 0 0 0 3px var(--admin-accent-soft);
}

.field textarea { min-height: 88px; resize: vertical; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.62rem 1.15rem;
  border-radius: var(--admin-radius-sm);
  border: none;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--admin-accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(13, 148, 136, 0.25);
}
.btn-primary:hover { background: var(--admin-accent-hover); }

.btn-ghost {
  background: var(--admin-panel);
  border: 1px solid var(--admin-border-strong);
  color: var(--admin-text);
}
.btn-ghost:hover { background: var(--admin-panel-muted); }

.btn-danger {
  background: var(--admin-danger-soft);
  color: var(--admin-danger);
  border: 1px solid rgba(220, 38, 38, 0.2);
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.error-msg {
  color: var(--admin-danger);
  font-size: 0.85rem;
  margin-top: 0.75rem;
}

/* Dashboard layout */
.admin-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--admin-panel);
  border-right: 1px solid var(--admin-border);
  padding: 1.25rem 1rem;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  box-shadow: var(--admin-shadow);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar .brand {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 1.75rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 0.65rem;
  letter-spacing: -0.02em;
}

.sidebar .brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(13, 148, 136, 0.35);
}

.login-logo {
  display: block;
  width: 72px;
  height: 72px;
  margin: 0 auto 1rem;
  border-radius: 18px;
  object-fit: cover;
  box-shadow: 0 8px 24px rgba(13, 148, 136, 0.25);
}

.sidebar nav { display: flex; flex-direction: column; gap: 0.2rem; flex: 1; }

.sidebar nav button {
  text-align: left;
  padding: 0.62rem 0.85rem;
  border: none;
  background: transparent;
  color: var(--admin-muted);
  border-radius: var(--admin-radius-sm);
  cursor: pointer;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
}

.sidebar nav button.active {
  background: var(--admin-accent-soft);
  color: var(--admin-accent);
  font-weight: 600;
}

.sidebar nav button:hover:not(.active) {
  background: var(--admin-panel-muted);
  color: var(--admin-text);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 1.5rem;
  border-top: 1px solid var(--admin-border);
}

.main {
  flex: 1;
  padding: 1.75rem 2rem 2.5rem;
  overflow-x: auto;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.topbar h2 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.topbar-sub {
  color: var(--admin-muted);
  font-size: 0.88rem;
  margin: 0.25rem 0 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.75rem;
  background: var(--admin-panel);
  border: 1px solid var(--admin-border);
  border-radius: 999px;
  font-size: 0.82rem;
  color: var(--admin-muted);
}

.content-card {
  background: var(--admin-panel);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 1.5rem;
  box-shadow: var(--admin-shadow);
  margin-bottom: 1rem;
}

.content-card > p:first-child { margin-top: 0; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat-box {
  background: var(--admin-panel);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--admin-shadow);
  transition: transform 0.15s, box-shadow 0.15s;
}

.stat-box:hover {
  transform: translateY(-1px);
  box-shadow: var(--admin-shadow-lg);
}

.stat-box strong {
  display: block;
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--admin-accent);
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.stat-box span {
  font-size: 0.78rem;
  color: var(--admin-muted);
  font-weight: 500;
  margin-top: 0.25rem;
  display: block;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 1rem;
  align-items: center;
}

.toolbar input, .toolbar select {
  padding: 0.55rem 0.85rem;
  border-radius: var(--admin-radius-sm);
  border: 1px solid var(--admin-border-strong);
  background: var(--admin-panel);
  color: var(--admin-text);
  font: inherit;
  font-size: 0.88rem;
  min-height: 40px;
}

.toolbar input[type="search"] {
  min-width: 220px;
  flex: 1;
  max-width: 320px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  background: var(--admin-panel);
  box-shadow: var(--admin-shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--admin-border);
}

th {
  background: var(--admin-panel-muted);
  color: var(--admin-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr:last-child td { border-bottom: none; }

tr:hover td { background: rgba(13, 148, 136, 0.04); }

.pill {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.status-not_started { background: #f1f5f9; color: #475569; }
.status-stub { background: #e2e8f0; color: #334155; }
.status-ui_only { background: #fee2e2; color: #b91c1c; }
.status-partial { background: #fef3c7; color: #b45309; }
.status-in_progress { background: #dbeafe; color: #1d4ed8; }
.status-live_static { background: #dcfce7; color: #15803d; }
.status-live { background: #ccfbf1; color: #0f766e; }

.backend-needs_backend { color: #dc2626; font-weight: 600; }
.backend-needs_api { color: #ea580c; font-weight: 600; }
.backend-partial { color: #ca8a04; }
.backend-static { color: #16a34a; }
.backend-live { color: #0d9488; font-weight: 600; }

.row-actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.row-actions button {
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--admin-border);
  background: var(--admin-panel);
  cursor: pointer;
  font-weight: 600;
  color: var(--admin-text);
}
.row-actions button:hover { background: var(--admin-panel-muted); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 200;
  padding: 1rem;
}

.modal {
  background: var(--admin-panel);
  border: 1px solid var(--admin-border);
  border-radius: calc(var(--admin-radius) + 2px);
  padding: 1.5rem 1.65rem;
  width: min(520px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--admin-shadow-lg);
}

.modal h3 {
  margin: 0 0 1rem;
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1.35rem;
  padding-top: 1rem;
  border-top: 1px solid var(--admin-border);
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: var(--admin-text);
  color: #fff;
  border: none;
  padding: 0.85rem 1.35rem;
  border-radius: var(--admin-radius-sm);
  z-index: 300;
  box-shadow: var(--admin-shadow-lg);
  font-weight: 500;
  font-size: 0.9rem;
}

@media (max-width: 768px) {
  .admin-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--admin-border);
  }
  .main { padding: 1.25rem; }
}

.nav-section {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--admin-muted);
  font-weight: 700;
  margin: 1.1rem 0 0.4rem 0.85rem;
}

.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.tab-btn {
  padding: 0.48rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--admin-border);
  background: var(--admin-panel);
  color: var(--admin-muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
}

.tab-btn:hover { border-color: var(--admin-accent); color: var(--admin-accent); }

.tab-btn.active {
  background: var(--admin-accent-soft);
  border-color: var(--admin-accent);
  color: var(--admin-accent);
  font-weight: 600;
}

.tab-count {
  opacity: 0.75;
  font-size: 0.75rem;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

@media (max-width: 520px) {
  .field-row { grid-template-columns: 1fr; }
}

.modal-wide { width: min(680px, 100%); }

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.settings-form {
  max-width: 480px;
}

.checkbox-field label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  font-weight: 500;
}

.row-inactive td { opacity: 0.5; }

.detail-grid {
  display: grid;
  gap: 0;
  margin-top: 0.75rem;
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius-sm);
  overflow: hidden;
}

.detail-row {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 0.85rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--admin-border);
  font-size: 0.88rem;
  background: var(--admin-panel);
}

.detail-row:nth-child(even) { background: var(--admin-panel-muted); }
.detail-row:last-child { border-bottom: none; }

.detail-label {
  color: var(--admin-muted);
  font-weight: 600;
  font-size: 0.8rem;
}

.detail-value { word-break: break-word; }

.detail-meta {
  color: var(--admin-muted);
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
}

.import-status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.import-chip {
  background: var(--admin-panel-muted);
  border: 1px solid var(--admin-border);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--admin-text);
}

.import-chip strong { color: var(--admin-accent); }

.empty-hint {
  color: var(--admin-muted);
  font-size: 0.9rem;
  padding: 2rem;
  text-align: center;
}

@media (max-width: 520px) {
  .detail-row { grid-template-columns: 1fr; }
}
