:root {
  --bg: #0f1419;
  --panel: #1a222c;
  --text: #e8eef4;
  --muted: #8b9aab;
  --accent: #3d9be8;
  --accent-dim: #1a3a55;
  --border: #2a3544;
  --danger: #e85d5d;
  --ok: #4caf7a;
  --font: "Manrope", "Segoe UI", system-ui, sans-serif;
  --display: "Cormorant Garamond", Georgia, serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 10% -10%, #1a3a55 0%, transparent 55%),
              radial-gradient(900px 500px at 100% 0%, #152238 0%, transparent 50%),
              var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }
.hero {
  padding: 4rem 1.5rem 3rem;
  text-align: center;
}
.brand {
  font-family: var(--display);
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0;
}
.tagline { color: var(--muted); font-size: 1.1rem; margin: 0.75rem 0 1.5rem; }
.btn {
  display: inline-block;
  background: var(--accent);
  color: #041018;
  border: none;
  padding: 0.65rem 1.2rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn.secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); color: #fff; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 1rem 1.5rem; border-bottom: 1px solid var(--border);
  background: rgba(15,20,25,0.85); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.topbar .logo { font-family: var(--display); font-size: 1.4rem; color: var(--text); }
.nav { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.nav a { color: var(--muted); font-size: 0.95rem; }
.nav a.active, .nav a:hover { color: var(--text); }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
h1 { font-family: var(--display); font-weight: 600; margin: 0 0 0.35rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }
.muted { color: var(--muted); }
.error { background: #3a1a1a; color: #ffb4b4; padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.ok { background: #1a3a2a; color: #b4ffd0; padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 1rem; }
.stat b { font-size: 1.6rem; display: block; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.55rem 0.4rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
.excerpt { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.form-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; align-items: center; }
input, select, textarea {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 0.5rem 0.65rem; border-radius: 6px; font-family: inherit; font-size: 0.95rem;
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--accent); }
input.is-invalid, select.is-invalid { border-color: var(--danger); outline-color: var(--danger); }
label { font-size: 0.85rem; color: var(--muted); }

.source-form { margin-bottom: 1rem; }
.source-fields { align-items: flex-end; margin-bottom: 0.35rem; }
.field-slot { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.field-slot[hidden] { display: none !important; }
.field-label { font-size: 0.75rem; color: var(--muted); line-height: 1.2; white-space: nowrap; }
.field-slot .req { color: var(--danger); display: none; font-weight: 600; }
.field-slot.is-required .req { display: inline; }
.field-slot.is-optional .req { display: none; }
.source-hint { margin: 0.35rem 0 0; font-size: 0.85rem; }
.source-field-error {
  margin: 0.5rem 0 0; padding: 0.55rem 0.75rem; border-radius: 6px;
  background: #3a1a1a; color: #ffb4b4; font-size: 0.9rem;
}
.source-field-error[hidden] { display: none; }

.login-box {
  max-width: 380px; margin: 4rem auto; padding: 2rem;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
}
.login-box h1 { text-align: center; margin-bottom: 1.5rem; }
.login-box .field { margin-bottom: 1rem; }
.login-box .field input { width: 100%; }
.login-box .btn { width: 100%; margin-top: 0.5rem; }

.password-wrap {
  display: flex; align-items: stretch; gap: 0.4rem;
}
.password-wrap input { flex: 1; min-width: 0; }
.password-toggle {
  flex-shrink: 0; padding: 0.5rem 0.75rem;
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  border-radius: 6px; cursor: pointer; font-family: inherit; font-size: 0.85rem;
  white-space: nowrap;
}
.password-toggle:hover { color: var(--text); border-color: var(--accent); }
.password-toggle[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }

.tabs { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }
.tabs a, .tabs button {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
  padding: 0.4rem 0.8rem; border-radius: 6px; cursor: pointer; font-family: inherit;
}
.tabs a.active, .tabs button.active { background: var(--accent-dim); color: var(--text); border-color: var(--accent); }

footer { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 2rem 1rem; }
