:root {
  color-scheme: light dark;
  --bg: #0f1216;
  --card: #1a1f26;
  --border: #2c333d;
  --text: #e6e9ec;
  --muted: #93a0ad;
  --accent: #4f8cff;
  --ok: #3ecf6b;
  --err: #ff5c5c;
}

* { box-sizing: border-box; }

/* The browser's default [hidden] { display: none } rule only wins over an
   author rule when nothing else in this stylesheet sets `display` on the
   same element - any class here that does (e.g. `.field`, `.inline-panel`,
   both `display: flex`) silently overrides it, since author CSS always
   beats the UA stylesheet regardless of selector specificity. Force it. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

h1 { font-size: 1.25rem; margin: 0; }

/* --- app shell: sidebar + main --- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--text);
  padding: 0 1.25rem 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.sidebar-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #2f5fd0);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 1.35rem; padding: 0 0.75rem; }

.nav-group { display: flex; flex-direction: column; gap: 0.1rem; }
.nav-group-label {
  padding: 0 0.5rem 0.4rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  opacity: 0.75;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.5rem;
  border-radius: 7px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-icon { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.85; }
.nav-link:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.nav-link.active {
  color: var(--text);
  font-weight: 600;
  background: rgba(79, 140, 255, 0.14);
}
.nav-link.active .nav-icon { color: var(--accent); opacity: 1; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.75rem;
  border-bottom: 1px solid var(--border);
}

.user-menu { display: flex; gap: 0.6rem; align-items: center; }
.username { color: var(--text); font-weight: 600; font-size: 0.9rem; }

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
}
.badge-admin { background: rgba(79, 140, 255, 0.15); color: var(--accent); }
.badge-user { background: rgba(147, 160, 173, 0.15); color: var(--muted); }
.badge-ok { background: rgba(62, 207, 107, 0.15); color: var(--ok); }
.badge-err { background: rgba(255, 92, 92, 0.15); color: var(--err); }

main.content {
  max-width: 1000px;
  width: 100%;
  margin: 1.5rem auto;
  padding: 0 1.75rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* --- login page --- */
.login-body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 340px;
}
.login-card h1 { font-size: 1.1rem; margin: 0 0 1.25rem; text-align: center; }
.login-card .field { flex-direction: column; align-items: stretch; }
.login-card .field label { width: auto; margin-bottom: 0.3rem; }
.login-card button[type="submit"] { width: 100%; margin-top: 0.4rem; }
.login-card .err { margin-top: 0.75rem; text-align: center; }

/* --- inline confirmation panels (redeploy / change owner) --- */
.inline-panel {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  background: #10141a;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-top: 0.75rem;
}
.inline-panel select { padding: 0.4rem; border-radius: 6px; border: 1px solid var(--border); background: var(--card); color: var(--text); }

a.button {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--accent);
  color: white;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
}
a.button:hover { filter: brightness(1.1); }
a.button.ghost { background: #2c333d; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}

.section-header { display: flex; justify-content: space-between; align-items: center; }

.field { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.9rem; flex-wrap: wrap; }
.field label { width: 90px; color: var(--muted); }
.field input, .field select {
  padding: 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #10141a;
  color: var(--text);
  flex: 1;
  min-width: 180px;
}

button {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 600;
}
button:hover { filter: brightness(1.1); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

button.ghost { background: #2c333d; }
.danger { background: var(--err); }

.actions-cell { white-space: nowrap; }
.actions { display: flex; flex-wrap: nowrap; gap: 0.4rem; }

.sql-input { display: flex; flex-direction: column; gap: 0.5rem; flex: 1; min-width: 220px; }
.sql-input textarea {
  padding: 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #10141a;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  resize: vertical;
}

.ok { color: var(--ok); }
.err { color: var(--err); }
.preview { color: var(--muted); font-size: 0.9rem; }

.log {
  margin-top: 1rem;
  background: #0b0e12;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  white-space: pre-wrap;
  max-height: 420px;
  overflow-y: auto;
}

.table-scroll { overflow-x: auto; margin-top: 0.75rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.5rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
th { color: var(--muted); font-weight: 600; }
