/* ---------- Tokens ---------- */
:root {
  --bg-page:        #021627;
  --bg-sidebar:     #042035;
  --bg-elevated:    #052B47;
  --bg-input:       #07304F;
  --border-soft:    rgba(255,255,255,.07);
  --border-mid:     rgba(255,255,255,.12);
  --border-strong:  rgba(255,255,255,.18);

  --text-primary:   #E6EEF7;
  --text-secondary: #94A8BE;
  --text-muted:     #5E7388;

  --accent:         #4FB6F0;   /* Sonar-ish cyan-blue */
  --accent-hover:   #6FC4F4;
  --accent-soft:    rgba(79,182,240,.12);
  --accent-ring:    rgba(79,182,240,.35);

  --success:        #34D399;
  --warning:        #F5B544;
  --danger:         #F87171;

  --radius-sm:      4px;
  --radius:         8px;
  --radius-lg:      12px;

  --topbar-h:       65px;
  --sidebar-w:      17.5rem;
  --sidebar-w-min:  5rem;

  --shadow-sm:      0 1px 0 rgba(0,0,0,.25);
  --shadow-md:      0 8px 24px rgba(0,0,0,.35);

  --font-display:   'Sora', system-ui, sans-serif;
  --font-body:      'Manrope', system-ui, sans-serif;
  --font-mono:      'JetBrains Mono', ui-monospace, monospace;
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
code, pre { font-family: var(--font-mono); font-size: .92em; }

/* ---------- App shell ---------- */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(79,182,240,.06), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(79,182,240,.04), transparent 60%),
    var(--bg-page);
}

/* ---------- Topbar ---------- */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  background: var(--bg-page);
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: saturate(140%) blur(6px);
}
.brand {
  display: flex; align-items: center; gap: 12px;
  width: var(--sidebar-w);
  padding-left: 8px;
  flex-shrink: 0;
}
.brand__mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent) 0%, #2A78AC 100%);
  display: grid; place-items: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 4px 12px rgba(79,182,240,.35);
}
.brand__mark svg { width: 18px; height: 18px; }
.brand__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .01em;
  color: var(--text-primary);
}
.brand__name span { color: var(--accent); }

.topbar__spacer { flex: 1; }
.topbar__actions { display: flex; align-items: center; gap: 8px; }
.top-icon-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: transparent; border: 1px solid var(--border-soft);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.top-icon-btn:hover { background: var(--bg-elevated); color: var(--text-primary); border-color: var(--border-mid); }
.top-icon-btn svg { width: 16px; height: 16px; }

.user-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  color: var(--text-secondary);
  font-weight: 500;
}
.user-pill .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, #2A78AC, #4FB6F0);
  color: #02121F; font-weight: 700; font-size: 12px;
  display: grid; place-items: center;
}

/* ---------- Body layout ---------- */
.shell { flex: 1; display: flex; min-height: 0; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-soft);
  display: flex; flex-direction: column;
  padding: 12px 12px 16px;
  flex-shrink: 0;
}
.sidebar__group-label {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 14px 12px 8px;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-weight: 500;
  cursor: pointer;
  position: relative;
  transition: background .15s ease, color .15s ease;
}
.nav__item:hover { background: rgba(255,255,255,.04); color: var(--text-primary); }
.nav__item.is-active {
  background: var(--accent-soft);
  color: var(--text-primary);
}
.nav__item.is-active::before {
  content: "";
  position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.nav__item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav__rule { height: 1px; background: var(--border-soft); margin: 12px 4px; }
.nav__spacer { flex: 1; }

.sidebar__footer {
  padding: 10px 12px;
  border-top: 1px solid var(--border-soft);
  margin: 12px -12px -16px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex; justify-content: space-between; align-items: center;
}
.sidebar__footer code { color: var(--text-secondary); }

/* ---------- Page ---------- */
.page {
  flex: 1;
  min-width: 0;
  padding: 28px 32px 48px;
  overflow-y: auto;
}
.page__header { margin-bottom: 22px; }
.crumbs {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-muted);
  margin-bottom: 8px;
}
.crumbs a { color: var(--text-muted); }
.crumbs a:hover { color: var(--text-secondary); }
.crumbs__sep { opacity: .5; }
.page__title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  letter-spacing: -.01em;
  margin: 0;
  color: var(--text-primary);
}
.page__subtitle { color: var(--text-secondary); margin: 4px 0 0; }

/* ---------- Card / surfaces ---------- */
.card {
  background: linear-gradient(180deg, var(--bg-elevated) 0%, #04243C 100%);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  width: fit-content;       /* shrink to widest child */
  max-width: 100%;          /* but don't overflow on narrow screens */
}
.card__header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-soft);
}
.card__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  margin: 0;
}
.card__body { padding: 22px; }

/* ---------- Forms (default Django widgets get themed) ---------- */
.field {
  margin-bottom: 16px;
  max-width: 28rem;       /* keep inputs from stretching the page */
}
.field--wide  { max-width: 44rem; }   /* for file inputs / long values */
.field--full  { max-width: none; }    /* opt-out: full container width */

/* Neutralize stray <br> tags between label and input (e.g. from
   hand-written templates). Labels are already display:block. */
.field br { display: none; }

.field > label,
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.field .helptext, .field .help { color: var(--text-muted); font-size: 12px; margin-top: 6px; display: block; }
.field .errorlist {
  list-style: none; padding: 0; margin: 6px 0 0;
  color: var(--danger); font-size: 12px;
}

input[type="text"], input[type="email"], input[type="number"],
input[type="password"], input[type="url"], input[type="search"],
select, textarea {
  width: 100%;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  padding: 10px 12px;
  font: 500 14px/1.4 var(--font-body);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
  background: #08385C;
}
input[type="file"] {
  width: 100%;
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px dashed var(--border-mid);
  border-radius: var(--radius);
  padding: 10px 12px;
}
input[type="file"]::file-selector-button {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-mid);
  border-radius: 6px;
  padding: 6px 10px;
  margin-right: 12px;
  cursor: pointer;
  font: 600 12px/1 var(--font-body);
}
input[type="file"]::file-selector-button:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px;
  font: 600 13.5px/1 var(--font-body);
  letter-spacing: .01em;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .05s ease, background .15s ease, border-color .15s ease, color .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: linear-gradient(180deg, var(--accent) 0%, #3CA3DD 100%);
  color: #02121F;
  box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 6px 16px rgba(79,182,240,.25);
}
.btn--primary:hover { background: linear-gradient(180deg, var(--accent-hover) 0%, var(--accent) 100%); }
.btn--ghost {
  background: transparent; color: var(--text-primary);
  border-color: var(--border-mid);
}
.btn--ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Alerts ---------- */
.alert {
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
  border: 1px solid var(--border-mid);
  background: var(--bg-elevated);
  font-size: 13px;
}
.alert--error   { border-color: rgba(248,113,113,.4); background: rgba(248,113,113,.08); color: #FCA5A5; }
.alert--warn    { border-color: rgba(245,181,68,.4); background: rgba(245,181,68,.08); color: #FBD38D; }
.alert--success { border-color: rgba(52,211,153,.4); background: rgba(52,211,153,.08); color: #6EE7B7; }
.alert strong { color: inherit; }

/* ---------- Misc ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font: 600 11px/1 var(--font-body);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.kbd {
  font: 600 11px/1 var(--font-mono);
  padding: 3px 6px;
  border-radius: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border-mid);
  color: var(--text-secondary);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .brand { width: auto; }
  .page { padding: 20px; }
}
