/* Self-hosted brand fonts (variable weight; no external CDN). */
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/outfit.woff2') format('woff2');
}
@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/dm-sans.woff2') format('woff2');
}

/* Palette + type mirror evomedia.net/www: navy brand (#003366 / #336699),
   Outfit for headings, DM Sans for body. */
:root {
  --font-display: 'Outfit', system-ui, sans-serif;
  --font-sans: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, 'Cascadia Code', 'Segoe UI Mono', monospace;
  --radius: 12px;
}
:root, :root[data-theme="dark"] {
  --bg: #102a42; --panel: #163457; --panel2: #1d4067; --border: #2b5480;
  --text: #eaf1f8; --muted: #9fb6cd; --accent: #5b9bd5; --danger: #e5736b;
  --ok: #46c06a; --warn: #e0a53a;
  --tip-bg: #0a1f33; --tip-text: #eaf1f8;
  --mesh-1: rgba(51, 102, 153, 0.20); --mesh-2: rgba(10, 30, 55, 0.45);
}
/* Light = the same navy theme, ~50% lighter: airy blue-tinted surfaces that
   still read as the dark theme's sibling, not a generic white theme. */
:root[data-theme="light"] {
  --bg: #cfe0f0; --panel: #c3d7f0; --panel2: #e4eef9; --border: #a9c6e2;
  --text: #14304a; --muted: #556f8a; --accent: #3574b8; --danger: #d05a51;
  --ok: #2ea457; --warn: #c98f2e;
  --tip-bg: #14304a; --tip-text: #eaf1f8;
  --mesh-1: rgba(51, 102, 153, 0.16); --mesh-2: rgba(51, 102, 153, 0.09);
}
* { box-sizing: border-box; }
/* Author display rules (flex etc.) must never defeat the hidden attribute. */
[hidden] { display: none !important; }
body {
  margin: 0; color: var(--text);
  font: 14px/1.5 var(--font-sans);
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 120% 80% at 100% -20%, var(--mesh-1), transparent 50%),
    radial-gradient(ellipse 80% 60% at -10% 60%, var(--mesh-2), transparent 45%);
  background-attachment: fixed;
}
h1, h2 { font-family: var(--font-display); }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 14px 0 6px; }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }
.error { color: var(--danger); }
.spacer { flex: 1; }
code { background: var(--panel2); padding: 1px 6px; border-radius: 6px;
  font-size: 12px; font-family: var(--font-mono); }

header { display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--border); }
.brand { font-family: var(--font-display); font-weight: 700; font-size: 16px;
  color: var(--text); letter-spacing: -0.01em; }
.brand:hover { color: var(--accent); }
.brand .muted { font-weight: 500; }

.layout { display: flex; min-height: calc(100vh - 49px); }
nav { width: 160px; padding: 12px; border-right: 1px solid var(--border); }
nav a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); }
nav a.active { background: var(--panel2); color: var(--accent); }
main { flex: 1; padding: 18px; max-width: 1100px; }

.card { background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px; margin-bottom: 14px; }
.cardhead { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.cardhead h2 { margin: 0; }

/* Two-column grid form (tenant create overlay; also reused for user forms). */
.userform { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; max-width: 620px; }
.userform .full { grid-column: 1 / -1; }
.userform label { display: block; font-size: 13px; }
.userform .actions { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; margin-top: 4px; }
.userform .check { display: flex; align-items: center; gap: 6px; }
.userform .check input { width: auto; margin-top: 0; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 320px; }
.login-card label { display: block; margin: 10px 0; }

label { font-size: 13px; color: var(--muted); }
input, select {
  width: 100%; margin-top: 4px; padding: 7px 9px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel2); color: var(--text);
}
/* A bare select in an inline form (filter/scope pickers) must stay usable even
   when its flex label is narrow. */
form.inline select { min-width: 140px; }

/* Password field with an inline show/hide toggle. */
.pw-field { position: relative; margin-top: 4px; margin-bottom: 4px; }
.pw-field input { margin-top: 0; padding-right: 38px; }
.pw-toggle {
  position: absolute; right: 4px; top: 0; bottom: 0; width: 32px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; padding: 0; cursor: pointer; color: var(--muted);
}
.pw-toggle:hover { color: var(--accent); }
input[type="checkbox"] { width: auto; margin-right: 6px; }
form.inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
form.inline label { flex: 1; min-width: 130px; }
form.inline .grow0 { flex: 0; min-width: auto; }

.btn { padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel2); color: var(--text); cursor: pointer; font-size: 13px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 3px 8px; font-size: 12px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border);
  vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
tr:last-child td { border-bottom: none; }
/* Pinned widths so a Suspend↔Activate toggle (or badge change) never reflows
   the table. Status is centered and sized to the badge; actions holds the
   widest button combo without shifting. */
th.col-status, td.col-status { width: 96px; text-align: center; }
th.col-actions, td.col-actions { width: 172px; white-space: nowrap; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 11px; border: 1px solid var(--border);
  white-space: nowrap; flex-shrink: 0; }
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.badge.bad { color: var(--danger); border-color: var(--danger); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: var(--panel2); border: 1px solid var(--border);
  padding: 1px 8px; border-radius: 999px; font-size: 12px; }
.chip button { background: none; border: none; color: var(--muted);
  cursor: pointer; padding: 0 1px; font-size: 12px; line-height: 1; }
.chip button:hover { color: var(--accent); }
.chip button[data-role-act="delete"]:hover { color: var(--danger); }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 20; }
.modal-card { width: 440px; }
.modal-card .btn { margin-top: 12px; }

#toast { position: fixed; bottom: 18px; right: 18px; background: var(--panel2);
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  padding: 10px 14px; border-radius: 8px; z-index: 30; max-width: 380px; }
#toast.err { border-left-color: var(--danger); }

.roleselect { display: flex; gap: 6px; align-items: center; margin: 2px 0; }
.roleselect .muted { font-size: 11px; min-width: 88px; }
.roleselect select { margin-top: 0; width: auto; min-width: 110px; }

/* ── Tooltips ────────────────────────────────────────────────────────────────
   Instant, themed, keyboard-accessible. Add data-tip="…" to any element;
   data-tip-pos="bottom" flips it below (for header controls). Pure CSS — the
   pseudo-elements only render on hover/focus, so there is no idle footprint. */
[data-tip] { position: relative; }
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  content: attr(data-tip);
  position: absolute; left: 50%; bottom: calc(100% + 7px);
  transform: translateX(-50%);
  width: max-content; max-width: 230px; white-space: normal; text-align: left;
  background: var(--tip-bg); color: var(--tip-text);
  padding: 6px 9px; border-radius: 8px;
  font-size: 12px; font-weight: 400; line-height: 1.35;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35); z-index: 60; pointer-events: none;
}
[data-tip]:hover::before, [data-tip]:focus-visible::before {
  content: ""; position: absolute; left: 50%; bottom: calc(100% + 2px);
  transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: var(--tip-bg);
  z-index: 60; pointer-events: none;
}
[data-tip-pos="bottom"]:hover::after, [data-tip-pos="bottom"]:focus-visible::after {
  bottom: auto; top: calc(100% + 7px);
}
[data-tip-pos="bottom"]:hover::before, [data-tip-pos="bottom"]:focus-visible::before {
  bottom: auto; top: calc(100% + 2px);
  border-top-color: transparent; border-bottom-color: var(--tip-bg);
}
