:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #273449;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-fg: #082f49;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--accent); }

.loading { padding: 2rem; color: var(--muted); }

/* Layout */
header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
header.topbar h1 { font-size: 1rem; margin: 0; font-weight: 600; }
header.topbar .who {
  color: var(--muted);
  font-size: 0.85rem;
  margin-right: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Let a long admin email truncate rather than widen the bar. */
header.topbar > div:last-child { display: flex; align-items: center; min-width: 0; }

/* Brand */
.brand { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
/* The logo ships on an opaque white background, so it gets a rounded plate to
   read as a deliberate sticker on the dark panel rather than a bare rectangle.
   Drop the background/padding here if a transparent-background logo replaces it. */
.brand-logo {
  height: 30px;
  width: auto;
  display: block;
  background: #fff;
  border-radius: 6px;
  padding: 3px 5px;
}
.brand h1 { letter-spacing: 0.02em; }
.brand-fallback { font-weight: 700; color: var(--text); }
.brand-sub {
  color: var(--muted);
  font-size: 0.8rem;
  padding-left: 0.5rem;
  border-left: 1px solid var(--border);
  white-space: nowrap;
}

@media (max-width: 640px) {
  .brand-logo { height: 26px; }
  header.topbar .brand-sub { display: none; }
}

nav.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0 1.25rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
nav.tabs button {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  padding: 0.6rem 0.9rem;
  cursor: pointer;
  font-size: 0.9rem;
}
nav.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
nav.tabs button .badge {
  background: var(--amber);
  color: #422006;
  border-radius: 999px;
  padding: 0 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  margin-left: 0.35rem;
}

main { padding: 1.25rem; max-width: 1200px; margin: 0 auto; }
h2.view-title { font-size: 1.1rem; margin: 0 0 1rem; }

/* Cards / tables */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
td.wrap, th.wrap { white-space: normal; }
tr:last-child td { border-bottom: none; }

/* Status pills */
.pill { display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.pill.PENDING { background: #422006; color: #fcd34d; }
.pill.APPROVED { background: #0c4a6e; color: #7dd3fc; }
.pill.ACTIVE { background: #052e16; color: #86efac; }
.pill.TRIAL { background: #1e3a5f; color: #93c5fd; }
.pill.SUSPENDED { background: #431407; color: #fdba74; }
.pill.REJECTED, .pill.REVOKED, .pill.CANCELLED, .pill.EXPIRED { background: #450a0a; color: #fca5a5; }
.pill.ARCHIVED, .pill.DISABLED { background: #1f2937; color: #9ca3af; }

/* Buttons */
button.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 6px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  font-size: 0.83rem;
  margin: 0 0.15rem 0.15rem 0;
}
button.btn:hover { border-color: var(--accent); }
button.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
button.btn.danger { color: #fca5a5; border-color: #7f1d1d; }
button.btn.danger:hover { background: #450a0a; }
button.btn:disabled { opacity: 0.5; cursor: default; }

/* Forms */
label { display: block; margin: 0.5rem 0 0.15rem; color: var(--muted); font-size: 0.82rem; }
input, select {
  width: 100%;
  padding: 0.5rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
}
.row { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 140px; }

/* Login */
.login-wrap { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 360px; }
.login-card h1 { font-size: 1.15rem; margin: 0 0 0.25rem; }
.login-card p.sub { color: var(--muted); margin: 0 0 1rem; font-size: 0.85rem; text-align: center; }
.login-card .brand { flex-direction: column; gap: 0.35rem; margin-bottom: 0.75rem; }
.login-card .brand-logo { height: 38px; max-width: 100%; }
.login-card .brand h1 { margin: 0; }

.empty { color: var(--muted); padding: 1.5rem; text-align: center; }
.muted { color: var(--muted); }
.error-banner { background: #450a0a; color: #fca5a5; border: 1px solid #7f1d1d; border-radius: 6px; padding: 0.5rem 0.75rem; margin-bottom: 0.75rem; font-size: 0.85rem; }
.toast {
  position: fixed; bottom: 1.25rem; right: 1.25rem;
  background: var(--panel-2); border: 1px solid var(--border); border-left: 3px solid var(--green);
  padding: 0.6rem 0.9rem; border-radius: 6px; font-size: 0.85rem; max-width: 320px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.toast.err { border-left-color: var(--red); }
small.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); }
