:root {
  --bg: #f5f6f9;
  --surface: #ffffff;
  --surface-hover: #f5f6f9;
  --border: #e2e5eb;
  --text: #14171f;
  --muted: #666e7d;
  --primary: #3a3f47;
  --primary-light: #6b7280;
  --primary-tint: #eef0f2;
  /* Fixed (not re-themed for dark mode) charcoal used for solid button fills,
     so white button text stays readable regardless of page theme. */
  --primary-solid: #2f333b;
  --primary-solid-dark: #1c1f24;
  --accent: #f2c418;
  --accent-dark: #cfa60f;
  --accent-text: #7a5c00;
  --danger: #d1393e;
  --danger-dark: #b02e33;
  --success-bg: #e6f6ec;
  --success-text: #1c7a3e;
  --error-bg: #fdecec;
  --error-text: #a3262b;
  --warning-bg: #fff4e0;
  --warning-text: #9a5b00;
  --active-bg: #e6f6ec;
  --active-text: #1c7a3e;
  --expired-bg: #fdecec;
  --expired-text: #a3262b;
  --revoked-bg: #eceef1;
  --revoked-text: #4b5563;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(20, 23, 31, 0.04);
  --shadow-md: 0 8px 24px -12px rgba(20, 23, 31, 0.18);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101217;
    --surface: #191c23;
    --surface-hover: #21252e;
    --border: #2b2f3a;
    --text: #edeef2;
    --muted: #9aa2ac;
    --primary: #c7cbd1;
    --primary-light: #9aa2ac;
    --primary-tint: #262a31;
    --accent: #f2c418;
    --accent-dark: #f7d34e;
    --accent-text: #f2c418;
    --danger: #e35b60;
    --danger-dark: #ea6f73;
    --success-bg: #143223;
    --success-text: #5fd88a;
    --error-bg: #3a1c1e;
    --error-text: #f18a8d;
    --warning-bg: #3a2c0d;
    --warning-text: #f0b84d;
    --active-bg: #143223;
    --active-text: #5fd88a;
    --expired-bg: #3a1c1e;
    --expired-text: #f18a8d;
    --revoked-bg: #2a2d33;
    --revoked-text: #b7bec7;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 14px 32px -10px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.brand { display: inline-flex; align-items: center; }
.brand-logo { display: block; height: 26px; width: auto; }
.brand-logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
  .brand-logo-light { display: none; }
  .brand-logo-dark { display: block; }
}

/* App shell: fixed sidebar + header, matches the app's existing dark/gold brand palette. */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  /* One shared measure drives the icon column, so the logo, every nav icon,
     every label and the submenu all line up on the same two verticals. */
  --nav-pad-x: 0.7rem;
  --nav-icon: 18px;
  --nav-gap: 0.7rem;
  --nav-text-x: calc(var(--nav-pad-x) + var(--nav-icon) + var(--nav-gap));

  width: 240px;
  flex: none;
  background: #14161f;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  padding: 1rem 0.75rem 0.9rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 30;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 999px; }

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0 1rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand img { height: 36px; width: auto; max-width: 100%; }
.sidebar-brand-name {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.42);
}

.sidebar-nav { display: flex; flex-direction: column; gap: 0.15rem; }
.sidebar-section {
  margin: 0.9rem 0 0.3rem;
  padding: 0 var(--nav-pad-x);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.32);
}
.sidebar-section:first-child { margin-top: 0; }

.sidebar-nav a, .sidebar-group > summary {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--nav-gap);
  padding: 0.55rem var(--nav-pad-x);
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.66);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: color 0.15s ease, background 0.15s ease;
}
.sidebar-nav a:hover, .sidebar-group > summary:hover {
  color: #fff;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.05);
}
/* Active: brand-gold rail + a quiet wash, rather than a heavy filled block. */
.sidebar-nav a.active, .sidebar-group > summary.active {
  color: #fff;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
}
/* Direct children only -- sub-items get the dot on the guide line instead, so
   an open section never shows two competing rails. */
.sidebar-nav > a.active::before, .sidebar-group > summary.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.sidebar-nav a.active .icon, .sidebar-group > summary.active .icon { color: var(--accent); opacity: 1; }
.sidebar-nav .icon { flex: none; width: var(--nav-icon); height: var(--nav-icon); opacity: 0.75; }

.sidebar-group > summary::-webkit-details-marker { display: none; }
.sidebar-group > summary::after {
  content: "";
  margin-left: auto;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translate(-1px, -1px);
  opacity: 0.6;
  transition: transform 0.18s ease;
}
.sidebar-group[open] > summary::after { transform: rotate(-135deg) translate(-2px, -2px); }

/* Sub-items hang off a guide line drawn through the parent's icon centre. */
.sidebar-submenu {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  padding: 0.2rem 0 0.35rem;
}
.sidebar-submenu::before {
  content: "";
  position: absolute;
  left: calc(var(--nav-pad-x) + var(--nav-icon) / 2);
  top: 0.15rem;
  bottom: 0.4rem;
  width: 1px;
  background: rgba(255, 255, 255, 0.11);
}
.sidebar-submenu a {
  position: relative;
  padding: 0.4rem var(--nav-pad-x) 0.4rem var(--nav-text-x);
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.83rem;
  font-weight: 500;
}
.sidebar-submenu a:hover { color: #fff; text-decoration: none; background: rgba(255, 255, 255, 0.05); }
.sidebar-submenu a.active { color: #fff; font-weight: 600; background: rgba(255, 255, 255, 0.06); }
/* Marks the active child directly on the guide line. */
.sidebar-submenu a.active::before {
  content: "";
  position: absolute;
  left: calc(var(--nav-pad-x) + var(--nav-icon) / 2 - 2.5px);
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

/* Anchors the column and surfaces the same "needs attention" figure the bell
   and the dashboard worklist report. */
.sidebar-status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: auto;
  padding: 0.6rem 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  color: rgba(255, 255, 255, 0.7);
}
.sidebar-status:hover { background: rgba(255, 255, 255, 0.06); text-decoration: none; }
.sidebar-status-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex: none;
}
.sidebar-status.is-warning .sidebar-status-icon { background: rgba(242, 196, 24, 0.16); color: var(--accent); }
.sidebar-status.is-ok .sidebar-status-icon { background: rgba(95, 216, 138, 0.14); color: #5fd88a; }
.sidebar-status-body { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.sidebar-status-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-status-sub { font-size: 0.7rem; color: rgba(255, 255, 255, 0.45); }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0 1.25rem;
  height: 48px;
}
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  flex: none;
}
.page-title { font-size: 0.98rem; font-weight: 700; letter-spacing: -0.01em; flex: none; }
.header-search {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: none;
  width: 260px;
  height: 32px;
  padding: 0 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--muted);
  transition: border-color 0.15s ease;
}
.header-search:focus-within { border-color: var(--primary); }
/* Needs to out-specify the global input[type=search] rule further down, which
   would otherwise paint a second border/background inside this pill. */
.header-search input[type=search] {
  border: none;
  background: none;
  outline: none;
  font: inherit;
  font-size: 0.84rem;
  color: var(--text);
  width: 100%;
  padding: 0;
  height: auto;
}
.header-search input[type=search]:focus { box-shadow: none; border: none; }
.topbar-spacer { flex: 1; }

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  flex: none;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.icon-btn-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border-radius: 999px;
  border: 2px solid var(--surface);
  background: var(--danger);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.notif-menu { position: relative; }
.notif-menu > summary { list-style: none; cursor: pointer; }
.notif-menu > summary::-webkit-details-marker { display: none; }
.notif-menu[open] > summary { background: var(--surface-hover); color: var(--text); }
.notif-panel {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  width: 320px;
  max-width: calc(100vw - 1.5rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  z-index: 25;
  overflow: hidden;
}
.notif-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--border);
}
.notif-head .notif-title { font-size: 0.88rem; font-weight: 700; }
.notif-head-count { font-size: 0.76rem; color: var(--muted); }
.notif-list { max-height: 320px; overflow-y: auto; }
.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface-hover); text-decoration: none; }
.notif-item-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex: none;
  margin-top: 0.1rem;
}
.notif-item-icon.notif-expired { background: var(--expired-bg); color: var(--expired-text); }
.notif-item-icon.notif-expiring_soon { background: var(--warning-bg); color: var(--warning-text); }
.notif-item-body { display: flex; flex-direction: column; min-width: 0; }
.notif-item-name { font-size: 0.85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-item-meta { font-size: 0.76rem; color: var(--muted); }
.notif-empty { padding: 1.4rem 0.85rem; text-align: center; color: var(--muted); }
.notif-empty .icon { color: var(--active-text); }
.notif-empty p { margin: 0.35rem 0 0; font-size: 0.85rem; color: var(--text); }
.notif-empty p.muted { color: var(--muted); }
.notif-more { margin: 0; padding: 0.5rem 0.85rem; font-size: 0.76rem; color: var(--muted); border-bottom: 1px solid var(--border); }
.notif-foot {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.85rem;
  background: var(--bg);
}
.notif-foot a { font-size: 0.8rem; font-weight: 600; }

.user-menu { position: relative; }
.user-menu > summary {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  list-style: none;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: var(--radius-sm);
  user-select: none;
  color: var(--text);
}
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu:hover > summary, .user-menu[open] > summary { background: var(--surface-hover); }
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7c6fe6 0%, #5b4bd6 100%);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  flex: none;
}
.user-menu-text { display: flex; flex-direction: column; line-height: 1.25; }
.user-menu-email { font-size: 0.85rem; font-weight: 600; }
.user-menu-role { font-size: 0.74rem; color: var(--muted); }
.user-menu .icon { color: var(--muted); }
.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  min-width: 190px;
  padding: 0.4rem;
  z-index: 20;
  display: flex;
  flex-direction: column;
}
.user-menu-dropdown a, .user-menu-dropdown .link-button {
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  text-align: left;
  width: 100%;
}
.user-menu-dropdown a:hover, .user-menu-dropdown .link-button:hover { background: var(--surface-hover); text-decoration: none; }

.sidebar-backdrop { display: none; }

@media (max-width: 880px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-md);
    transition: transform 0.2s ease;
  }
  .app-shell.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-toggle { display: inline-flex; }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 17, 23, 0.45);
    z-index: 25;
  }
  .app-shell.sidebar-open .sidebar-backdrop { display: block; }
  .page-title { display: none; }
  .header-search { flex: 1; width: auto; min-width: 0; }
  .user-menu-text { display: none; }
  .page { padding: 1.25rem 1rem 3rem; }
}

/* Too cramped to be usable next to the nav controls -- the list pages carry
   their own search box, so drop this one rather than squeezing it. */
@media (max-width: 560px) {
  .header-search { display: none; }
  .topbar { gap: 0.5rem; }
  .page-title { display: block; }
}

.page { max-width: 1240px; margin: 0 auto; padding: 1.75rem 1.75rem 3.5rem; width: 100%; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.35rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-header h1 { margin: 0; font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; }
.page-header > div:first-child > p { margin: 0.2rem 0 0; }
.page-actions { display: flex; gap: 0.5rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1rem;
}
.card-narrow { max-width: 560px; }
/* Wide enough for the two-column .form-grid inside it. */
.card-form { max-width: 900px; }

/* Main content plus a fixed-width info card alongside it (e.g. update-devices'
   "current license" summary). Collapses to a single column on narrow screens,
   with the card-form's own .form-grid free to collapse independently above that. */
.page-columns { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1rem; align-items: start; }
@media (max-width: 860px) {
  .page-columns { grid-template-columns: 1fr; }
}

/* Independent settings cards (account page) side by side instead of one
   narrow column with empty space next to it. Each card keeps its own
   card-narrow cap so a lone card in a row doesn't stretch too wide; the
   grid's own gap replaces each card's normal bottom margin so rows don't
   double up on vertical spacing. */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; align-items: start; }
.settings-grid .card { margin-bottom: 0; }
.card-header { margin-bottom: 1rem; }
.card-header h2 { margin-bottom: 0.2rem; }
.card-header p:last-child { margin-bottom: 0; }
.card h2 { margin-top: 0; font-size: 0.98rem; font-weight: 700; letter-spacing: -0.01em; }
.card-highlight { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary), var(--shadow-md); }

.stack { display: flex; flex-direction: column; gap: 0.9rem; }
.stack label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.86rem; font-weight: 600; }
.inline-label { display: flex; align-items: center; gap: 0.5rem; font-size: 0.86rem; font-weight: 600; }
.checkbox-label { align-items: center; gap: 0.5rem; }
/* These two are row layouts, but `.stack label` above is more specific than a
   lone class -- so re-assert the row direction at matching specificity. */
.stack .inline-label, .stack .checkbox-label { flex-direction: row; align-items: center; }
.stack .inline-label > input, .stack .checkbox-label > input { flex: none; }
/* Submit buttons sit at their natural width rather than stretching to the
   full column (.btn-block still opts in to full width where it's wanted). */
.stack > .btn { align-self: flex-start; }

/* Two-column form layout, so wider forms use the page instead of running as
   one tall narrow column. Collapses back to a single column when there isn't
   room for two. */
.stack.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem 1.25rem;
  align-items: start;
}
.form-grid > .field-full { grid-column: 1 / -1; }
/* Standalone explanatory text placed directly in the grid shouldn't inherit
   the browser's default paragraph margins on top of the grid gap. */
.form-grid > p.hint { margin: 0; }
.form-grid > .btn, .form-grid > .page-actions { grid-column: 1 / -1; justify-self: start; }
/* Keep paired field-groups the same height when one carries more helper text. */
.form-grid > .field-group { height: 100%; }
@media (max-width: 760px) {
  .stack.form-grid { grid-template-columns: 1fr; }
}
.hint { font-weight: 400; color: var(--muted); font-size: 0.82rem; }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  font: inherit;
  font-size: 0.88rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
}
input:disabled, select:disabled { opacity: 0.6; }
textarea { resize: vertical; font-family: inherit; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { border-color: var(--primary-light); text-decoration: none; background: var(--surface-hover); }
.btn-primary {
  background: var(--primary-solid);
  border-color: var(--primary-solid);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-solid-dark);
  border-color: var(--primary-solid-dark);
}
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-dark); border-color: var(--danger-dark); }
.btn-small { padding: 0.34rem 0.7rem; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; }
.link-button { background: none; border: none; color: var(--muted); cursor: pointer; font: inherit; padding: 0; }
.link-button:hover { color: var(--text); text-decoration: underline; }
.inline-form { display: inline; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--border); font-size: 0.875rem; }
.table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-top: 0;
  white-space: nowrap;
}
.table th:first-child, .table td:first-child { padding-left: 0; }
.table th:last-child, .table td:last-child { padding-right: 0; text-align: right; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background 0.1s ease; }
.table tbody tr:hover { background: var(--surface-hover); }
/* Horizontal escape hatch for the wider tables (licenses, audit) on narrow screens. */
.table-scroll { overflow-x: auto; }

.col-when { min-width: 145px; }

.kv-table th { color: var(--muted); font-weight: 600; padding: 0.4rem 1rem 0.4rem 0; vertical-align: top; white-space: nowrap; font-size: 0.85rem; }
.kv-table td { padding: 0.4rem 0; }

.badge { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.2rem 0.6rem; border-radius: 999px; font-size: 0.73rem; font-weight: 600; letter-spacing: 0.01em; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.badge-active { background: var(--active-bg); color: var(--active-text); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); }
.badge-expired { background: var(--expired-bg); color: var(--expired-text); }
.badge-revoked { background: var(--revoked-bg); color: var(--revoked-text); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 0.9rem; margin-bottom: 1.35rem; }
/* Whole card is one anchor, so the entire surface is clickable -- the
   "View all" line is a span, not a nested link. */
.stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.05rem 1.15rem;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.stat-card:hover { border-color: var(--primary-light); box-shadow: var(--shadow-md); text-decoration: none; }
.stat-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.stat-top { display: flex; align-items: center; gap: 0.8rem; }
.stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex: none;
  background: var(--primary-tint);
  color: var(--primary);
}
.stat-value { display: block; font-size: 1.55rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
.stat-label { display: block; color: var(--muted); font-size: 0.82rem; font-weight: 500; }
.stat-link {
  margin-top: auto;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
}
.stat-card:hover .stat-link { gap: 0.3rem; }
.stat-link .icon { transition: transform 0.15s ease; }
.stat-warning .stat-icon { background: var(--warning-bg); color: var(--warning-text); }
.stat-warning .stat-link { color: var(--warning-text); }
.stat-danger .stat-icon { background: var(--expired-bg); color: var(--expired-text); }
.stat-danger .stat-link { color: var(--expired-text); }
.stat-success .stat-icon { background: var(--active-bg); color: var(--active-text); }
.stat-success .stat-link { color: var(--active-text); }

.dashboard-welcome { margin-bottom: 1.35rem; }
.dashboard-welcome .eyebrow { color: var(--muted); font-size: 0.86rem; margin: 0 0 0.1rem; }
.dashboard-welcome h1 { margin: 0; font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; }

.search-form { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.search-form input[type=search] { flex: 1; min-width: 220px; max-width: 380px; }

.table-footer { margin-top: 0.9rem; margin-bottom: 0; color: var(--muted); font-size: 0.82rem; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.9rem;
}
.pagination-meta { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.pagination-summary { margin: 0; color: var(--muted); font-size: 0.82rem; }
.pagination-summary strong { color: var(--text); font-weight: 600; }
.per-page-form { display: flex; align-items: center; gap: 0.4rem; }
.per-page-form label { display: flex; align-items: center; gap: 0.4rem; font-size: 0.82rem; color: var(--muted); }
.per-page-form select {
  font-size: 0.82rem;
  padding: 0.2rem 0.4rem;
  height: 30px;
  cursor: pointer;
}
.pagination-pages { display: flex; align-items: center; gap: 0.25rem; }
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 0.45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.page-btn:hover { border-color: var(--primary-light); background: var(--surface-hover); text-decoration: none; }
.page-btn.is-current {
  background: var(--primary-solid);
  border-color: var(--primary-solid);
  color: #fff;
}
.page-btn.is-disabled { opacity: 0.4; pointer-events: none; }
.page-gap { padding: 0 0.15rem; color: var(--muted); font-size: 0.82rem; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.small { font-size: 0.82rem; }
.muted { color: var(--muted); }

.alert { padding: 0.7rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: 0.9rem; border: 1px solid transparent; font-weight: 500; }
.alert-success { background: var(--success-bg); color: var(--success-text); }
.alert-error { background: var(--error-bg); color: var(--error-text); }

.key-box { display: flex; align-items: center; flex-wrap: wrap; gap: 0.75rem; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.75rem 1rem; word-break: break-all; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; }
.key-box code { flex: 1 1 240px; }

.payload-block { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.9rem 1rem; font-size: 0.85rem; overflow-x: auto; }

.field-group { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.85rem 1rem; display: flex; flex-direction: column; gap: 0.6rem; }
.field-group-label { font-weight: 700; font-size: 0.9rem; }
/* Even columns rather than a wrapping flex row, so the presets stay on one
   line inside a half-width form column instead of orphaning the last one. */
.preset-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(66px, 1fr)); gap: 0.4rem; }
.preset-row .btn { justify-content: center; padding-left: 0.35rem; padding-right: 0.35rem; }
.preset-btn.active { background: var(--primary-solid); border-color: var(--primary-solid); color: #fff; }

.auth-body {
  background:
    radial-gradient(circle at 15% -10%, var(--primary-tint), transparent 45%),
    radial-gradient(circle at 100% 110%, rgba(242, 196, 24, 0.12), transparent 40%),
    var(--bg);
  min-height: 100vh;
}
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 2.25rem 2rem; width: 100%; max-width: 380px; }
.auth-card .brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 1.6rem;
}
.auth-card .brand-logo { height: 40px; }
.brand-name {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
