/*
 * Minimal dashboard styling.
 *
 * The brief says not to spend development time on elaborate visual design, so this is a
 * small, legible system: one accent colour, generous spacing, and status colours that
 * survive a glance across a room. No framework, no build step.
 */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1c1e21;
  --muted: #6b7280;
  --accent: #2563eb;
  --online: #15803d;
  --offline: #b91c1c;
  --warn: #b45309;
  --radius: 8px;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/*
 * `!important` is load-bearing here, not laziness.
 *
 * `hidden` is a native HTML attribute, and any author rule that sets `display` overrides
 * the user-agent default. `#login { display: grid }` below has specificity (1,0,0) against
 * this rule's (0,2,0), so without this the login screen stays on screen after signing in
 * and the dashboard renders below the fold - which looks exactly like "nothing happens".
 *
 * Applying it to the bare attribute covers every element that uses `hidden`, including any
 * added later, rather than leaving the same trap for the next ID-scoped rule.
 */
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ login */

#login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card { width: min(380px, 100%); }

.login-card h1 { margin: 0 0 4px; font-size: 22px; }

/* ----------------------------------------------------------------- topbar */

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap;
}

.brand { font-weight: 650; margin-right: 12px; }
.spacer { flex: 1; }

nav { display: flex; gap: 2px; flex-wrap: wrap; }

.nav {
  background: none;
  border: 0;
  padding: 7px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--muted);
  font: inherit;
}
.nav:hover { background: var(--bg); color: var(--text); }
.nav.active { background: var(--accent); color: #fff; }

main { padding: 20px; max-width: 1280px; margin: 0 auto; }

/* ------------------------------------------------------------------ cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.card h2 { margin: 0 0 12px; font-size: 16px; }
.card h3 { margin: 20px 0 8px; font-size: 14px; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat .value { font-size: 26px; font-weight: 650; line-height: 1.2; }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }

/* ------------------------------------------------------------------ table */

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tbody tr:hover { background: var(--bg); }
td.actions { white-space: nowrap; }

.table-wrap { overflow-x: auto; }

/* ----------------------------------------------------------------- badges */

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge.online   { background: #dcfce7; color: var(--online); }
.badge.offline  { background: #fee2e2; color: var(--offline); }
.badge.revoked  { background: #f3f4f6; color: var(--muted); }
.badge.success  { background: #dcfce7; color: var(--online); }
.badge.failed   { background: #fee2e2; color: var(--offline); }
.badge.pending,
.badge.sent,
.badge.running  { background: #fef3c7; color: var(--warn); }
.badge.info     { background: #e0e7ff; color: #3730a3; }
.badge.warning  { background: #fef3c7; color: var(--warn); }
.badge.error    { background: #fee2e2; color: var(--offline); }

/* ----------------------------------------------------------------- forms */

label { display: block; margin-bottom: 12px; font-weight: 500; }

input[type=text], input[type=email], input[type=password], input[type=url],
input[type=number], select, textarea {
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  background: var(--surface);
  color: var(--text);
}

input[type=checkbox] { margin-right: 8px; }

label.inline { display: flex; align-items: center; font-weight: 400; }

button {
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font: inherit;
}
button:hover { background: var(--bg); }

button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover { filter: brightness(1.08); }
button.ghost { background: none; border: 0; color: var(--muted); }
button.ghost:hover { color: var(--text); }
button.danger { color: var(--offline); border-color: #fecaca; }
button.small { padding: 4px 9px; font-size: 12px; }
button:disabled { opacity: .5; cursor: not-allowed; }

.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------------ misc */

.muted { color: var(--muted); }
.error { color: var(--offline); }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }

.warning-banner {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: var(--warn);
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.token-display {
  background: #f8fafc;
  border: 1px dashed var(--border);
  padding: 12px;
  border-radius: 6px;
  word-break: break-all;
  margin: 10px 0;
}

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 11px 20px;
  border-radius: var(--radius);
  z-index: 100;
  max-width: 90vw;
}
.toast[hidden] { display: none; }


/* -------------------------------------------------------------- two-factor */

.totp-qr {
  /* The QR is an SVG data URI sized by its own viewBox; without a cap it fills the card.
     Kept generous - a phone camera needs a reasonable target. */
  width: 220px;
  max-width: 100%;
  height: auto;
  background: #fff;
  padding: 8px;
  border-radius: 8px;
}

.recovery-codes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: 0.35rem 1rem;
  margin: 0.75rem 0;
  /* These get printed. Selectable and readable matters more than compact. */
  user-select: all;
}

.card.warning {
  border-left: 4px solid #d97706;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.small {
  font-size: 0.85em;
}
