
/* =========================================================================
   NSDO Policies Portal - shared stylesheet
   Design system: "NSDO Task Management" (reference project).
   Token values are copied verbatim from the reference
   frontend/src/index.css + frontend/tailwind.config.js.
   Theme: light / dark / system (3 states). public/js/theme-init.js sets
   <html data-theme> synchronously in <head> before the first paint.
   Tailwind classes from the reference were translated to plain CSS, e.g.
   rounded-lg=8px, rounded-xl=12px, rounded-2xl=16px, rounded-3xl=24px,
   /20 alpha = rgba(...,0.20). Self-hosted: system font stack, no CDN.
   ========================================================================= */

:root {
  color-scheme: light dark;

  /* -------------------- semantic palette (dark = the default) ----------- */
  --bg: #070A12;
  --bg-2: #0B1220;
  --surface: #0F172A;
  --surface-2: #111E34;
  --surface-3: #142544;
  --text: #ECF3FF;
  --muted: #A9B6CC;
  --border: rgba(255, 255, 255, 0.10);
  --primary: #39B54A;
  --danger: #FF4D4F;
  --success: #22C55E;
  --warning: #F59E0B;
  --ring: rgba(57, 181, 74, 0.55);
  --shadow-soft: 0 24px 60px rgba(0, 0, 0, 0.55);

  /* green ink for text/icons on dark surfaces (AA on --surface/--bg) */
  --primary-ink: #5cc653;
  --primary-hover: #2f9a3d;
  --primary-soft: rgba(57, 181, 74, 0.15);
  --primary-soft-2: rgba(57, 181, 74, 0.07);
  --primary-border: rgba(57, 181, 74, 0.30);
  --primary-border-strong: rgba(57, 181, 74, 0.45);
  --primary-solid: #39B54A;
  --primary-solid-hover: #2f9a3d;
  --primary-shadow: 0 10px 25px rgba(57, 181, 74, 0.18);
  /* ink for text ON a solid green fill: near-black, because white on #39B54A is
     only 2.66:1 and fails WCAG AA (the reference ships white here). */
  --on-primary: #04150b;
  /* AA inks for text sitting on the translucent status fills */
  --success-ink: #4ade80;
  --danger-ink: #ff8a8c;
  /* solid fills used behind white text (kept dark enough for AA) */
  --danger-fill: #b5342c;

  /* status slots: warning/amber + danger/rose + success + info/teal */
  --danger-hover: #ff6b6d;
  --danger-solid: #FF4D4F;
  --danger-soft: rgba(255, 77, 79, 0.15);
  --danger-border: rgba(255, 77, 79, 0.30);
  --on-danger: #ffffff;
  --warning-hover: #fbbf24;
  --warning-soft: rgba(245, 158, 11, 0.15);
  --warning-border: rgba(245, 158, 11, 0.30);
  --success-soft: rgba(34, 197, 94, 0.15);
  --success-border: rgba(34, 197, 94, 0.30);
  --info: #38bdf8;                 /* sky-400 on dark, AA-safe ink */
  --info-solid: #0ea5e9;
  --info-soft: rgba(14, 165, 233, 0.15);
  --info-border: rgba(14, 165, 233, 0.30);
  --on-info: #ffffff;

  /* accent family - sky / cyan / teal (colour rule: cool accents only) */
  --accent: #0ea5e9;               /* sky-500 */
  --accent-deep: #0369a1;
  --accent-ink: #0B1220;
  --accent-teal: #14b8a6;          /* teal-500 */
  --accent-cyan: #06b6d4;          /* cyan-500 */
  --accent-sky: #0ea5e9;           /* sky-500 */
  --accent-amber: #f59e0b;         /* amber-500 */
  --accent-glow: rgba(14, 165, 233, 0.20);
  --accent-glow-2: rgba(34, 197, 94, 0.12);
  /* page background glows (reference body recipe) */
  --page-glow-green: rgba(57, 181, 74, 0.14);
  --page-glow-sky: rgba(14, 165, 233, 0.10);

  /* surfaces that stay dark in BOTH themes */
  --tooltip-bg: var(--surface-3);
  --tooltip-text: var(--text);
  --toast-bg: var(--surface);
  --toast-text: var(--text);
  --overlay: rgba(2, 6, 23, 0.55);
  --dropzone-border: rgba(255, 255, 255, 0.18);
  --skeleton-a: rgba(255, 255, 255, 0.05);
  --skeleton-b: rgba(255, 255, 255, 0.14);

  /* glass card (surface at 70% + 24px blur) used by stat/department cards */
  --glass: rgba(15, 23, 42, 0.70);
  --glass-border: rgba(255, 255, 255, 0.10);
  --card-shadow: var(--shadow-soft);

  /* hero + sign-in panels: CONSTANT dark navy in both themes */
  --hero-gradient: linear-gradient(135deg, rgba(15, 23, 42, 0.94), rgba(17, 24, 39, 0.88));
  --hero-glow: radial-gradient(circle at top right, rgba(14, 165, 233, 0.20), transparent 34%),
               radial-gradient(circle at bottom left, rgba(34, 197, 94, 0.12), transparent 28%);
  --hero-deco: rgba(255, 255, 255, 0.05);
  --hero-deco-2: rgba(255, 255, 255, 0.04);
  --hero-deco-3: rgba(255, 255, 255, 0.035);
  --hero-chip-bg: rgba(255, 255, 255, 0.05);
  --hero-chip-border: rgba(255, 255, 255, 0.10);
  --on-hero: #ffffff;
  --on-hero-muted: #cbd5e1;        /* slate-300 */
  --hero-search-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
  --hero-scrim: transparent;
  --auth-gradient: var(--hero-gradient);
  --auth-scrim: transparent;

  --focus-ring: var(--ring);
  --focus-ring-strong: var(--ring);

  /* brand aliases kept for the rest of the sheet */
  --green: var(--primary);
  --leaf: #22c55e;
  --green-deep: var(--primary-ink);
  --green-deep-hover: #7ed46f;
  --green-tint: var(--primary-soft);
  --green-tint-2: var(--primary-soft-2);
  --ink: var(--text);              /* legacy alias used across the sheet */
  --line: var(--border);
  --border-strong: rgba(255, 255, 255, 0.18);
  --border-hover: var(--border);
  --warn: var(--warning);
  --warn-soft: var(--warning-soft);

  /* spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* shape & elevation (reference radii: lg 8 / xl 12 / 2xl 16 / 3xl 24) */
  --radius: 16px;
  --radius-sm: 8px;
  --radius-lg: 24px;
  --radius-card: 16px;
  --radius-input: 8px;
  --shadow: var(--shadow-soft);
  --shadow-md: 0 24px 60px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 28px 90px rgba(15, 23, 42, 0.22);

  /* structure */
  --sidebar-w: 220px;
  --shell-max: 1280px;      /* max-w-7xl */
  --shell-max-2xl: 1600px;  /* 2xl:max-w-[1600px] */
  --topbar-h: 72px;
  --gutter: 16px;
  --block-gap: 24px;

  --font: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur: 300ms;
}

:root[data-theme="light"] {
  color-scheme: light;
}

/* ============================== light palette ============================= */
:root[data-theme="light"] {
  --bg: #F6F7FB;
  --bg-2: #EEF4F8;                 /* reference #EEF2FF is tinted -> neutral here */
  --surface: #FFFFFF;
  --surface-2: #F4F7FB;
  --surface-3: #EEF4FF;
  --text: #0B1220;
  --muted: #475569;
  --border: rgba(15, 23, 42, 0.12);
  --primary: #239B3C;
  --danger: #DC2626;
  --success: #16A34A;
  --warning: #B45309;
  --ring: rgba(35, 155, 60, 0.35);
  --shadow-soft: 0 18px 45px rgba(2, 6, 23, 0.12);

  --primary-ink: #1a7a2c;          /* AA ink for green text on light surfaces */
  --primary-hover: #1a7a2c;
  --primary-soft: rgba(35, 155, 60, 0.12);
  --primary-soft-2: rgba(35, 155, 60, 0.06);
  --primary-border: rgba(35, 155, 60, 0.30);
  --primary-border-strong: rgba(35, 155, 60, 0.45);
  --primary-solid: #239B3C;
  --primary-solid-hover: #1a7a2c;
  --primary-shadow: 0 10px 25px rgba(35, 155, 60, 0.18);
  /* ink for text ON a solid green fill (white on #239B3C is 3.60:1 -> fails AA) */
  --on-primary: #0B1220;
  /* AA inks for text on the translucent status fills */
  --success-ink: #0f6b2a;
  --danger-ink: #a51f18;
  /* solid fills used behind white text */
  --danger-fill: #b91c1c;

  --danger-hover: #b91c1c;
  --danger-solid: #DC2626;
  --danger-soft: rgba(220, 38, 38, 0.10);
  --danger-border: rgba(220, 38, 38, 0.30);
  --warning-hover: #92400e;
  --warning-soft: rgba(180, 83, 9, 0.10);
  --warning-border: rgba(180, 83, 9, 0.30);
  --success-soft: rgba(22, 163, 74, 0.12);
  --success-border: rgba(22, 163, 74, 0.30);
  --info: #0369a1;                 /* sky-700 for AA on light */
  --info-solid: #0284c7;
  --info-soft: rgba(2, 132, 199, 0.10);
  --info-border: rgba(2, 132, 199, 0.30);

  --accent: #0284c7;
  --accent-deep: #075985;
  --accent-teal: #0d9488;
  --accent-cyan: #0891b2;
  --accent-sky: #0284c7;
  --accent-amber: #d97706;
  --accent-glow: rgba(2, 132, 199, 0.16);
  --accent-glow-2: rgba(22, 163, 74, 0.10);
  --page-glow-green: rgba(35, 155, 60, 0.12);
  --page-glow-sky: rgba(2, 132, 199, 0.08);

  --border-strong: rgba(15, 23, 42, 0.18);
  --border-hover: var(--border);
  --dropzone-border: rgba(15, 23, 42, 0.20);
  --skeleton-a: rgba(15, 23, 42, 0.06);
  --skeleton-b: rgba(15, 23, 42, 0.11);

  --glass: rgba(255, 255, 255, 0.70);
  --glass-border: rgba(15, 23, 42, 0.10);

  /* hero stays constant navy in BOTH themes (reference behaviour) */
  --on-hero: #ffffff;
  --on-hero-muted: #cbd5e1;
  --hero-chip-bg: rgba(255, 255, 255, 0.05);
  --hero-chip-border: rgba(255, 255, 255, 0.10);

  --overlay: rgba(2, 6, 23, 0.55);
  --tooltip-bg: #ffffff;
  --tooltip-text: #0B1220;
  --toast-bg: #ffffff;
  --toast-text: #0B1220;

  --shadow: var(--shadow-soft);
  --shadow-md: 0 18px 45px rgba(2, 6, 23, 0.14);
  --shadow-lg: 0 28px 90px rgba(15, 23, 42, 0.18);
}

/* ------------------------------------------------------------------ base */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  font-weight: 420;
  color: var(--text);
  min-height: 100vh;
  /* reference body recipe: green radial + sky radial + vertical bg->bg-2 */
  background:
    radial-gradient(1200px 700px at 18% -10%, var(--page-glow-green) 0%, rgba(57, 181, 74, 0.0) 55%),
    radial-gradient(900px 500px at 105% 0%, var(--page-glow-sky) 0%, rgba(14, 165, 233, 0.0) 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  /* keep an explicit paint colour under the gradient layers (background:
     shorthand resets background-color to transparent) */
  background-color: var(--bg);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body.no-scroll { overflow: hidden; }

/* scrollbars (reference) */
* { scrollbar-color: rgba(167, 179, 199, 0.45) rgba(17, 27, 46, 0.6); }
:root[data-theme="light"] * { scrollbar-color: rgba(71, 85, 105, 0.55) rgba(241, 245, 249, 1); }

img { max-width: 100%; height: auto; }

[hidden] { display: none !important; }

h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; color: var(--text); }
h1 { font-size: 1.6rem; letter-spacing: -.01em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.08rem; }
p { margin: 0 0 1em; }

a { color: var(--green-deep); }
a:hover { color: var(--green-deep-hover); }

:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--ring); border-radius: 8px; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--surface);
  color: var(--ink);
  padding: 10px 16px;
  z-index: 120;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.muted { color: var(--muted); }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ======================================================== app shell ===== */
.app { min-height: 100vh; }

.app-body {
  min-height: calc(100vh - var(--topbar-h));
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ------------------------------------------- top header (sticky + blur) */
.topbar {
  position: sticky;
  top: 0;
  z-index: 80;
  min-height: var(--topbar-h);          /* 72px: header height */
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 12px 16px;
}
@media (min-width: 1536px) {
  .topbar-inner { max-width: var(--shell-max-2xl); }
}
.topbar-menu {
  width: 40px; height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.topbar-menu:hover { background: var(--surface-3); transform: translateY(-1px); }
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
  min-width: 0;
}
.topbar-brand .logo-swap > img { height: 40px; width: auto; }
.topbar-brand .topbar-brand-text { display: flex; flex-direction: column; justify-content: center; line-height: 1.25; min-width: 0; }
.topbar-brand .topbar-brand-name {
  display: block;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-brand .topbar-brand-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-spacer { flex: 1 1 auto; }
.topbar-user { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.3; min-width: 0; }
.topbar-user .user-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 22ch;
}
.topbar-user .user-role { font-size: 12px; color: var(--muted); }
@media (max-width: 940px) { .topbar-user { display: none; } }
@media (max-width: 560px) { .topbar-brand .topbar-brand-text { display: none; } }

/* ------------------------------------------------- menu panel (sidebar)
   >=1024px: rounded-2xl card (220px) in the 220px + 1fr grid.
   <1024px : slide-in drawer.                                               */
.sidebar {
  position: fixed;
  top: var(--topbar-h);
  bottom: 0;
  left: 0;
  width: min(280px, calc(100vw - 48px));
  max-height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  border-radius: 0 var(--radius-card) var(--radius-card) 0;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  z-index: 70;
  transform: translateX(-100%);
  transition: transform 320ms var(--ease);
  visibility: hidden;
  padding: 8px;
}
.sidebar.is-open { transform: translateX(0); visibility: visible; }

.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 8px; }
.sidebar-brand-link {
  display: flex; align-items: center; gap: 10px; flex: 1 1 auto; min-width: 0;
  text-decoration: none; color: inherit;
}
.sidebar-brand .logo-swap > img { height: 40px; width: auto; }
.sidebar-brand .brand-title { font-weight: 600; font-size: 14px; line-height: 1.2; display: block; }
.sidebar-brand .brand-sub { font-size: 12px; color: var(--muted); display: block; }
.sidebar-close {
  margin-left: auto;
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.sidebar-close:hover { background: var(--surface-2); color: var(--text); }

.sidebar-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;                        /* reference gap-1 */
}
.nav-section-label {
  padding: 12px 12px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  color: var(--muted);
  text-decoration: none;
  font-weight: 400;
  font-size: 14px;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease),
              border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.nav-link .icon { flex: 0 0 auto; color: currentColor; transition: transform var(--dur) var(--ease); }
.nav-link:hover {
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
  color: var(--text);
  transform: translateY(-1px);
}
.nav-link:hover .icon { transform: scale(1.05); }
.nav-link[aria-current="page"] {
  background: var(--surface-2);
  color: var(--text);
  border-color: color-mix(in srgb, var(--border) 60%, transparent);
}
.nav-link[aria-current="page"] .icon { color: var(--text); }

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 8px 4px 2px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-foot .user-meta { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sidebar-foot .user-name { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .user-role { font-size: 12px; color: var(--muted); }
.sidebar-foot .badge { margin-top: 0; }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  z-index: 65;
  animation: fade-in 420ms var(--ease);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* desktop: the sidebar becomes the first grid column of the shell */
@media (min-width: 1024px) {
  .app {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    gap: var(--gutter);
    max-width: var(--shell-max);
    margin: 0 auto;
    padding: var(--gutter);
    align-items: start;
  }
  .sidebar {
    position: sticky;
    top: calc(var(--topbar-h) + var(--gutter));
    left: auto;
    bottom: auto;
    width: var(--sidebar-w);
    max-height: none;
    transform: none;
    visibility: visible;
    border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
    border-radius: var(--radius-card);     /* rounded-2xl = 16px */
    box-shadow: var(--shadow-soft);
    background: var(--surface);
    padding: 8px;                          /* p-2 */
  }
  .sidebar-brand { display: none; }        /* logo lives in the header only */
  .sidebar-close { display: none; }
  .sidebar-backdrop { display: none !important; }
  .topbar-menu { display: none; }
}
@media (min-width: 1536px) {
  .app { max-width: var(--shell-max-2xl); }
}

/* ======================================================== page layout === */
.container { width: 100%; }
@media (min-width: 1536px) {
  .container { max-width: var(--shell-max-2xl); margin-left: auto; margin-right: auto; }
}

.page {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--block-gap);
  padding: 0;
}
/* standalone pages (403/404): their own header sits above the page */
body > .topbar ~ .page { padding-top: 0; }

.page-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.page-head h1 { margin: 0; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.page-head .subtitle { margin: 4px 0 0; color: var(--muted); font-size: .95rem; }

.section-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin: 26px 0 14px;
}
.section-head h2 { margin: 0; }
.section-head .section-sub { margin: 2px 0 0; color: var(--muted); font-size: .92rem; }
.section-head .actions { display: flex; flex-wrap: wrap; gap: 8px; }

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: .92rem;
  color: var(--muted);
  margin-bottom: 16px;
}
.breadcrumb a {
  color: var(--green-deep);
  font-weight: 600;
  text-decoration: none;
}
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .crumb-current { color: var(--ink); font-weight: 600; }
.breadcrumb .icon { color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--green-tint);
  color: var(--green-deep);
  border: 1px solid var(--primary-border);
  font-size: .85rem;
  font-weight: 700;
  white-space: nowrap;
}
.chip.chip-plain {
  background: var(--bg);
  color: var(--ink);
  border-color: var(--line);
}
  .chip.chip-warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warning-border); }
button.chip, .chip-btn {
  cursor: pointer;
  font: inherit;
  font-size: .85rem;
  font-weight: 700;
}
.chip-clear {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
}
  .chip-clear:hover { background: var(--green-tint); border-color: var(--primary-border-strong); color: var(--green-deep); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 18px;
}
.card > h2:first-child,
.card > h1:first-child { margin-top: 0; }
.card-title-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.card-title-row h2 { margin: 0; }

.grid { display: grid; gap: 14px; }
@media (min-width: 720px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

/* ================================================================ hero === */
/* Constant dark navy in BOTH themes (reference Login.jsx marketing panel +
   AdminTaskHistory hero card). Light type guaranteed. */
.hero {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: var(--radius-lg);          /* rounded-3xl = 24px */
  background: var(--hero-gradient);
  color: var(--on-hero);
  padding: 28px;
  box-shadow: 0 28px 90px rgba(15, 23, 42, 0.22);
}
/* glow layers: sky top-right, green bottom-left */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--hero-glow);
  pointer-events: none;
}
.hero-eyebrow {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: #cbd5e1;                            /* slate-300 */
  background: var(--hero-chip-bg);
  border: 1px solid var(--hero-chip-border);
  border-radius: 999px;
  padding: 4px 12px;
  margin: 0 0 16px;
}
.hero h1 {
  position: relative;
  color: #ffffff;
  margin-bottom: 10px;
  font-size: 34px;                           /* reference text-3xl .. text-4xl */
  font-weight: 600;
  letter-spacing: -.02em;                    /* tracking-tight */
  line-height: 1.2;
}
.hero .hero-sub { position: relative; color: #cbd5e1; margin: 0 0 20px; max-width: 62ch; font-size: 15px; }
.hero-search {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 8px;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 12px;                       /* rounded-xl */
  padding: 6px;
  max-width: 680px;
  box-shadow: none;
}
.hero-search .search-icon { color: #cbd5e1; display: inline-flex; flex: 0 0 auto; padding-left: 8px; }
.hero-search input {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  min-height: 40px;
  border: 0;
  background: transparent;
  color: #ffffff;
  border-radius: var(--radius-input);
  padding: 8px 4px;
}
.hero-search input::placeholder { color: #94a3b8; }              /* slate-400 */
.hero-search input:hover { border-color: transparent; }
.hero-search input:focus,
.hero-search input:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--ring);
  border-color: transparent;
}
@media (max-width: 560px) {
  .hero { padding: 22px 18px; }
  .hero h1 { font-size: 26px; }
  .hero-search { flex-wrap: wrap; }
  .hero-search .btn { width: 100%; }
}

/* ============================================================ dept cards = */
/* Reference SummaryMetricCard: Card + bg-surface/70 + backdrop-blur + a
   45deg gradient overlay at opacity .90 + white top-right radial, icon box
   48x48 in the TOP-RIGHT corner, label top-left, 36px value. */
.dept-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.dept-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  border: 1px solid var(--glass-border);
  border-radius: 16px;                          /* rounded-2xl */
  background: var(--glass);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  box-shadow: var(--shadow-soft);
  padding: 20px;
  cursor: pointer;
  font: inherit;
  color: var(--text);
  overflow: hidden;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
/* 45deg gradient overlay, opacity .9 (bg-gradient-to-br ... opacity-90) */
.dept-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--card-gradient, none);
  opacity: .9;
  pointer-events: none;
}
/* white sheen top-right */
.dept-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(255, 255, 255, 0.18), transparent 40%);
  pointer-events: none;
}
.dept-card > * { position: relative; z-index: 1; }
.dept-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 24px 90px rgba(15, 23, 42, 0.22);
}
.dept-card, .dept-card * { text-decoration: none; }

.dept-card-top {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.dept-icon {
  flex: 0 0 auto;
  order: 2;
  width: 48px; height: 48px;
  border-radius: 16px;                          /* rounded-2xl */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  background: rgba(0, 0, 0, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.dept-card-corner { display: none; }            /* the icon box carries the affordance */
.dept-card h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  order: 1;
}
.dept-card .dept-flag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  margin-bottom: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.05);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #e2e8f0;
}
.dept-card .dept-count {
  margin-top: 14px;
  font-size: 36px;                             /* reference text-4xl */
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.1;
  color: var(--text);
}
.dept-card .dept-count small {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 6px;
}
.dept-card .dept-updated {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}
.dept-card.is-org,
.dept-grid .dept-card.is-org,
#department-list .dept-card.is-org {
  --card-gradient: linear-gradient(135deg,
    rgba(16, 185, 129, 0.20) 0%,
    rgba(34, 197, 94, 0.10) 50%,
    rgba(20, 184, 166, 0.25) 100%);
  border: 2px solid #22c55e;
  box-shadow: var(--shadow-soft);
}
#department-list .dept-card { cursor: default; }
#department-list .dept-card:hover {
  transform: none;
  box-shadow: var(--shadow-soft);
}

/* the 4-gradient cycle. Source tones come from the reference's
   from-*/via-*/to-* strings with the warm tones swapped for
   sky/blue/cyan per the colour rule. 135deg = 45deg top-left -> bottom-right. */
.dept-grid .dept-card:nth-child(4n+1), #department-list .dept-card:nth-child(4n+1) {
  --card-gradient: linear-gradient(135deg,
    rgba(16, 185, 129, 0.20) 0%,
    rgba(34, 197, 94, 0.10) 50%,
    rgba(20, 184, 166, 0.25) 100%);
}
.dept-grid .dept-card:nth-child(4n+2), #department-list .dept-card:nth-child(4n+2) {
  --card-gradient: linear-gradient(135deg,
    rgba(14, 165, 233, 0.25) 0%,
    rgba(59, 130, 246, 0.15) 50%,
    rgba(6, 182, 212, 0.20) 100%);
}
.dept-grid .dept-card:nth-child(4n+3), #department-list .dept-card:nth-child(4n+3) {
  --card-gradient: linear-gradient(135deg,
    rgba(20, 184, 166, 0.20) 0%,
    rgba(16, 185, 129, 0.15) 50%,
    rgba(6, 182, 212, 0.20) 100%);
}
.dept-grid .dept-card:nth-child(4n+4), #department-list .dept-card:nth-child(4n+4) {
  --card-gradient: linear-gradient(135deg,
    rgba(245, 158, 11, 0.20) 0%,
    rgba(234, 179, 8, 0.15) 50%,
    rgba(249, 115, 22, 0.20) 100%);
}

/* =============================================================== buttons = */
/* Reference Button.jsx: rounded-lg(8px) h-10 px-4 text-sm font-semibold,
   300ms cubic-bezier(.4,0,.2,1), focus:ring-2 focus:ring-[var(--ring)]. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              color var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              transform var(--dur) var(--ease), filter var(--dur) var(--ease);
}
.btn:focus-visible { box-shadow: 0 0 0 2px var(--ring); }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled,
.btn[aria-disabled="true"] { opacity: .4; pointer-events: none; }

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: var(--primary-shadow);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px); }
.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line-strong);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-3); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.btn-danger {
  background: var(--danger-fill);
  color: #ffffff;
  box-shadow: 0 10px 25px rgba(255, 77, 79, 0.16);
}
.btn-danger:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn-lg { min-height: 44px; padding: 0 20px; font-size: 14px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row-centered { justify-content: center; }

/* icon button - reference: h-10 w-10 rounded-lg border-border/70 bg-surface2 */
.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.icon-btn:hover {
  background: var(--surface-3);
  transform: translateY(-1px);
}
.icon-btn.is-danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger-border);
  color: var(--danger);
}
.icon-btn:disabled,
.icon-btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }

/* ================================================================ forms == */
/* Reference Input.jsx: h-10 rounded-lg border-border/70 bg-surface text-sm,
   hover:border-border, focus:ring-2 focus:ring-[var(--ring)] */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 14px;
}
.field .hint { font-size: 14px; color: var(--muted); margin-top: 5px; }
.field .field-error { font-size: 14px; color: var(--danger); margin-top: 5px; }

input[type="text"],
input[type="password"],
input[type="search"],
input[type="date"],
input[type="email"],
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-input);           /* rounded-lg = 8px */
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
textarea { min-height: 104px; padding: 10px 12px; resize: vertical; }
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:hover, select:hover, textarea:hover { border-color: var(--line-strong); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: transparent;
  box-shadow: 0 0 0 2px var(--ring);
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }

/* hero search input: borderless pill inline with the icon; basis 0 so the
   icon + input share one row at every width (wins ties over the rules above) */
.hero-search input {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  min-height: 40px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 8px 4px;
}
.hero-search input:hover { border-color: transparent; }
.hero-search input:focus,
.hero-search input:focus-visible {
  border-color: transparent;
  box-shadow: 0 0 0 3px var(--focus-ring-strong);
  outline: none;
}

.input-group { display: flex; gap: 8px; align-items: stretch; }
.input-group > * { flex: 1; }
.input-group .btn { flex: 0 0 auto; }

.search-wrap { position: relative; }
.search-wrap input { padding-left: 40px; }
.search-wrap .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.password-wrap { position: relative; display: flex; }
.password-wrap input { padding-right: 78px; }
.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: auto;
  min-width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: .82rem;
  font-weight: 700;
  color: var(--green-deep);
  cursor: pointer;
}
.password-toggle:hover { background: var(--green-tint); }

/* password strength meter */
.pwd-meter { margin-top: 8px; }
.pwd-meter-track {
  height: 6px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.pwd-meter-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--danger);
  transition: width .2s ease, background-color .2s ease;
}
.pwd-meter-label { font-size: .82rem; font-weight: 700; color: var(--muted); margin-top: 4px; }
.pwd-meter.is-fair .pwd-meter-fill { background: var(--warn); }
.pwd-meter.is-good .pwd-meter-fill { background: var(--green); }
.pwd-meter.is-strong .pwd-meter-fill { background: var(--green-deep); }
.pwd-meter.is-fair .pwd-meter-label { color: var(--warn); }
.pwd-meter.is-good .pwd-meter-label { color: var(--green-deep); }
.pwd-meter.is-strong .pwd-meter-label { color: var(--green-deep); }

.select-hint {
  background: var(--green-tint-2);
  border: 1px solid var(--success-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: .86rem;
  color: var(--ink);
  margin-top: 6px;
}

.form-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 14px;
  font-weight: 600;
}
.form-note {
  background: var(--info-soft);
  color: var(--info);
  border: 1px solid var(--info-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 14px;
  font-size: .93rem;
}
.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}
.checkbox-field input { width: 20px; height: 20px; accent-color: var(--green-deep); min-height: 0; }
.checkbox-field label { margin: 0; font-weight: 700; }

.form-cols {
  display: grid;
  gap: 4px 20px;
  grid-template-columns: 1fr;
}
@media (min-width: 860px) {
  .form-cols { grid-template-columns: 1fr 1fr; }
  .span-all { grid-column: 1 / -1; }
}

/* ============================================================= controls == */
.controls {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}
.controls .search-field { grid-column: 1 / -1; }
@media (min-width: 640px) {
  .controls { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .controls { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); align-items: end; }
  .controls .search-field { grid-column: auto; }
}

/* =============================================================== badges == */
/* Reference Badge.jsx: rounded-full border px-2 py-0.5 text-xs font-medium,
   variants use bg-<token>/15 + text-<token> + border-<token>/30. */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-active   { background: var(--success-soft);   color: var(--success-ink);   border-color: var(--success-border); }
/* neutral / muted badge (e.g. a revoked or expired share link) */
.badge-muted    { background: var(--surface-2);      color: var(--muted);        border-color: var(--border); }
/* roles (reference): super_admin = danger, admin = primary, user = neutral */
.badge-super    { background: var(--danger-soft);    color: var(--danger-ink);    border-color: var(--danger-border); }
.badge-role     { background: var(--primary-soft);   color: var(--primary-ink);  border-color: var(--primary-border); }
.badge-user     { background: var(--surface-2);      color: var(--muted);        border-color: rgba(255, 255, 255, 0.10); }
/* --primary-ink on --primary-soft lands at 4.40:1 in light mode, just under AA.
   Darken the text for this badge only; dark mode already clears the bar. */
:root[data-theme="light"] .badge-role { color: #14601f; }
:root[data-theme="light"] .badge-user { border-color: rgba(15, 23, 42, 0.10); }
.badge-current  { background: var(--primary);        color: var(--on-primary);    border-color: var(--primary); }
.badge-inactive { background: var(--danger-soft);    color: var(--danger-ink);    border-color: var(--danger-border); }
.badge-warning  { background: var(--warning-soft);   color: var(--warning);      border-color: var(--warning-border); }

.policy-number {
  display: inline-flex;
  align-items: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .8rem;
  font-weight: 700;
  color: var(--green-deep);
  background: var(--green-tint);
  border: 1px solid var(--primary-border);
  padding: 3px 9px;
  border-radius: 7px;
}

/* ========================================================= policy cards == */
.policy-list { display: grid; gap: 14px; }
@media (min-width: 900px) { .policy-list { grid-template-columns: 1fr 1fr; } }
/* states/skeletons always span their grid */
.policy-list .state { grid-column: 1 / -1; }
.dept-grid .state,
.dept-grid .stack,
.dept-grid .skeleton { grid-column: 1 / -1; }

.policy-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.policy-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-border-strong);
}
.policy-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.policy-card h3 { margin: 0; font-size: 1.05rem; }
.policy-card h3 a { color: var(--ink); text-decoration: none; }
.policy-card h3 a:hover { color: var(--green-deep); text-decoration: underline; }
.policy-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.policy-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  color: var(--muted);
  font-size: .87rem;
}
.policy-meta span { display: inline-flex; align-items: center; gap: 6px; }
.policy-card-desc {
  margin: 0;
  color: var(--muted);
  font-size: .92rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.policy-actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}
.policy-actions .btn { margin-left: auto; }

/* icon tooltips */
[data-tip] { position: relative; }
[data-tip]:hover::after,
[data-tip]:focus-visible::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  font-size: .74rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 80;
  pointer-events: none;
}

/* =============================================================== tables == */
/* Reference TaskTable.jsx: wrapper overflow-hidden rounded-xl border-white/10;
   head bg-surface2 text-xs font-semibold text-muted; rows divide-y white/10. */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 16px;                        /* rounded-2xl */
  background: var(--surface);
}
table.data {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
  font-size: 14px;
}
table.data th,
table.data td {
  text-align: left;
  padding: 10px 12px;
  vertical-align: middle;
}
table.data thead th {
  background: color-mix(in srgb, var(--surface-2) 95%, transparent);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  white-space: nowrap;
}
table.data tbody tr { border-top: 1px solid var(--border); transition: background var(--dur) var(--ease); }
table.data tbody tr:first-child { border-top: 0; }
table.data tbody tr:hover { background: rgba(255, 255, 255, 0.05); }
:root[data-theme="light"] table.data tbody tr:hover { background: rgba(15, 23, 42, 0.04); }
table.data td .btn-row { justify-content: flex-end; }
table.data td strong { font-weight: 600; }
table.data .cell-sub { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

@media (max-width: 760px) {
  table.data,
  table.data tbody,
  table.data tr,
  table.data td { display: block; width: 100%; }
  table.data thead { display: none; }
  table.data tr {
    border: 1px solid var(--border);
    border-radius: 16px;
    margin-bottom: 12px;
    padding: 6px 4px;
    background: var(--surface);
  }
  table.data tbody tr:hover { background: var(--surface); }
  table.data td {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
    text-align: right;
  }
  table.data td:last-child { border-bottom: 0; }
  table.data td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--muted);
    text-align: left;
    flex: 0 0 auto;
    font-size: 12px;
    letter-spacing: .04em;
  }
  table.data td > * { margin-left: auto; }
  table.data td .btn-row { justify-content: flex-end; }
  table.data td .cell-sub { text-align: right; }
}

/* =========================================================== pagination == */
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-top: 22px;
}
.pagination .page-info { color: var(--muted); font-size: .93rem; padding: 0 6px; }
.pagination .btn[aria-current="page"] {
  background: var(--primary-solid);
  color: var(--on-primary);
  border-color: var(--primary-solid);
}

/* ====================================================== states/skeletons = */
.state {
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 42px 20px;
  text-align: center;
  color: var(--muted);
}
.state h2 { color: var(--ink); margin-bottom: 6px; }
.state p { max-width: 46ch; margin-left: auto; margin-right: auto; }
.state-icon {
  width: 68px; height: 68px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--green-tint);
  color: var(--green-deep);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.state .btn { margin-top: 8px; }
.skeleton { height: 168px; }
.skeleton-row { height: 64px; }
.skeleton-stat { height: 116px; }
.skeleton-hero { height: 150px; }

.spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 12px;
  border: 4px solid var(--line);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================================================================ stats == */
/* Same glass + gradient system as the department cards (reference
   SummaryMetricCard). The 4 gradients cycle green -> sky -> teal -> amber. */
.stats {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.stat-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid var(--glass-border);
  border-radius: 16px;                          /* rounded-2xl */
  background: var(--glass);
  -webkit-backdrop-filter: blur(24px);
  backdrop-filter: blur(24px);
  box-shadow: var(--shadow-soft);
  padding: 20px;
  overflow: hidden;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.stat-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--card-gradient, none);
  opacity: .9;
  pointer-events: none;
}
.stat-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(255, 255, 255, 0.18), transparent 40%);
  pointer-events: none;
}
.stat-card > * { position: relative; z-index: 1; }
.stat-card:hover { transform: translateY(-4px); box-shadow: 0 24px 90px rgba(15, 23, 42, 0.22); }

.stats .stat-card:nth-child(4n+1) {
  --card-gradient: linear-gradient(135deg,
    rgba(16, 185, 129, 0.20) 0%,
    rgba(34, 197, 94, 0.10) 50%,
    rgba(20, 184, 166, 0.25) 100%);
}
.stats .stat-card:nth-child(4n+2) {
  --card-gradient: linear-gradient(135deg,
    rgba(14, 165, 233, 0.25) 0%,
    rgba(59, 130, 246, 0.15) 50%,
    rgba(6, 182, 212, 0.20) 100%);
}
.stats .stat-card:nth-child(4n+3) {
  --card-gradient: linear-gradient(135deg,
    rgba(20, 184, 166, 0.20) 0%,
    rgba(16, 185, 129, 0.15) 50%,
    rgba(6, 182, 212, 0.20) 100%);
}
.stats .stat-card:nth-child(4n+4) {
  --card-gradient: linear-gradient(135deg,
    rgba(245, 158, 11, 0.20) 0%,
    rgba(234, 179, 8, 0.15) 50%,
    rgba(249, 115, 22, 0.20) 100%);
}

.stat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.stat-icon {
  order: 2;
  flex: 0 0 auto;
  width: 48px; height: 48px;
  border-radius: 16px;                          /* rounded-2xl */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  background: rgba(0, 0, 0, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.stat-icon.is-total, .stat-icon.is-dept { background: rgba(0, 0, 0, 0.10); color: var(--text); }
.stat-label {
  display: block;
  order: 1;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  margin-top: 6px;
}
.stat-value {
  display: block;
  margin-top: 14px;
  font-size: 36px;                             /* reference text-4xl */
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.1;
  color: var(--text);
}

/* bar list (dashboard) */
.bar-list { display: flex; flex-direction: column; gap: 16px; }
.bar-row {
  display: grid;
  grid-template-columns: minmax(130px, 190px) 1fr auto;
  gap: 6px 14px;
  align-items: center;
}
.bar-name { font-weight: 700; font-size: .95rem; }
.bar-name a { text-decoration: none; color: var(--ink); }
.bar-name a:hover { color: var(--green-deep); }
.bar-track {
  height: 10px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green), var(--leaf));
  transition: width .4s ease;
}
.bar-fill.is-zero { background: var(--line-strong); }
.bar-count { font-weight: 800; font-variant-numeric: tabular-nums; font-size: .92rem; }
.bar-count small { color: var(--muted); font-weight: 600; }
@media (max-width: 640px) {
  .bar-row { grid-template-columns: 1fr auto; }
  .bar-track { grid-column: 1 / -1; }
}

/* quick actions */
.quick-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* recent list */
.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--line);
}
.activity-list li:last-child { border-bottom: 0; }
.activity-list .activity-title { font-weight: 700; text-decoration: none; color: var(--ink); }
.activity-list .activity-title:hover { color: var(--green-deep); text-decoration: underline; }
.activity-list .activity-meta { color: var(--muted); font-size: .86rem; margin-left: auto; }

/* =============================================================== detail == */
.detail-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr;
}
@media (min-width: 980px) { .detail-grid { grid-template-columns: 1.4fr 1fr; } }

.detail-head { padding: 22px; }
.detail-head-top {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}
.detail-head h1 { margin: 0 0 8px; }
.detail-head .detail-desc { color: var(--muted); margin: 10px 0 0; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.detail-actions .actions-secondary { display: flex; flex-wrap: wrap; gap: 8px; }

.def-list { display: grid; gap: 12px; margin: 0; }
.def-list > div {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
}
.def-list > div:last-child { border-bottom: 0; padding-bottom: 0; }
@media (min-width: 560px) {
  .def-list > div { grid-template-columns: 170px 1fr; gap: 10px; align-items: baseline; }
}
.def-list dt { color: var(--muted); font-size: .88rem; }
.def-list dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

/* version timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative;
  padding: 0 0 18px 30px;
  border-left: 2px solid var(--line);
  margin-left: 8px;
}
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: "";
  position: absolute;
  left: -9px;
  top: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--line-strong);
}
.timeline li.is-current::before {
  border-color: var(--green);
  background: var(--green);
  box-shadow: 0 0 0 4px var(--green-tint);
}
.version-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.timeline li.is-current .version-item {
  border-color: var(--green);
  background: linear-gradient(160deg, var(--green-tint-2), var(--surface) 70%);
  box-shadow: var(--shadow);
}
.version-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.version-head .version-number { font-weight: 800; font-size: 1.02rem; }
.version-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  color: var(--muted);
  font-size: .86rem;
}
.version-meta span { display: inline-flex; align-items: center; gap: 6px; }
.version-note { margin: 0; font-size: .93rem; }
.version-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }

/* ============================================================= dropzone == */
.dropzone {
  position: relative;
  border: 2px dashed var(--dropzone-border);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 26px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease;
}
.dropzone:hover { border-color: var(--green); }
.dropzone.is-dragover { border-color: var(--green-deep); background: var(--green-tint); }
.dropzone.has-file { border-style: solid; border-color: var(--green-deep); background: var(--green-tint-2); }
.dropzone input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone:focus-within {
  outline: 3px solid var(--green-deep);
  outline-offset: 2px;
}
.dz-icon {
  width: 56px; height: 56px;
  margin: 0 auto 10px;
  border-radius: 16px;
  background: var(--green-tint);
  color: var(--green-deep);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.dropzone .dz-title { font-weight: 800; display: block; }
.dropzone .dz-hint { color: var(--muted); font-size: .88rem; display: block; margin-top: 2px; }
.dz-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  min-height: 44px;
  padding: 4px 0;
}
.dz-file {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  margin-top: 12px;
}
.dz-file .dz-name { font-weight: 700; overflow-wrap: anywhere; }

.progress {
  height: 10px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 12px;
}
.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--green), var(--leaf));
  transition: width .2s ease;
}
/* ======================================================== dialogs/toasts = */
/* Reference Modal.jsx: rounded-2xl border-border/70 bg-surface shadow-soft
   animate-scale-in, header/footer separated by border-border/60. */
dialog {
  border: 1px solid var(--line-strong);
  border-radius: 16px;                        /* rounded-2xl */
  box-shadow: var(--shadow-soft);
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--text);
  animation: scale-in 420ms var(--ease);
}
dialog::backdrop { background: var(--overlay); }
.dialog-body { padding: 16px; }
.dialog-body h2 { margin-top: 0; font-size: 14px; font-weight: 600; }
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}
.dialog-head h2 { margin: 0; font-size: 14px; font-weight: 600; }
.dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}

/* destructive confirmation: red hairline + a list of irreversible consequences */
dialog.is-danger { border-color: var(--danger-border); }
dialog.is-danger .dialog-body h2 { color: var(--danger-ink); }
.dialog-bullets {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}
.dialog-bullets li + li { margin-top: 2px; }
.confirm-typed {
  width: 100%;
  margin-top: 6px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.confirm-typed:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
  border-color: var(--primary);
}

/* Reference Toast.jsx: rounded-xl border-border/60 bg-surface shadow-soft
   animate-fade-up, fixed bottom-4 right-4 w-[360px]. */
.toast-region {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 110;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
}
.toast {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: 12px;                        /* rounded-xl */
  background: var(--toast-bg);
  color: var(--toast-text);
  padding: 8px 12px;
  box-shadow: var(--shadow-soft);
  font-size: 14px;
  font-weight: 500;
  animation: fade-up 520ms var(--ease);
}
.toast .toast-body { min-width: 0; }
.toast .toast-close {
  margin-left: auto;
  background: transparent;
  border: 0;
  font: inherit;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  min-width: 32px;
  min-height: 32px;
  border-radius: 8px;
  color: var(--muted);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.toast .toast-close:hover { background: var(--surface-2); color: var(--text); }
.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--danger); }
.toast-info    { border-left: 3px solid var(--primary); }

/* ================================================================ footer = */
.site-footer {
  flex-shrink: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
  padding: 16px;
  text-align: center;
}
@media (min-width: 768px) { .site-footer { padding: 16px 24px; } }
.site-footer p { margin: 0; }

/* ======================================================== friendly pages = */
.friendly-wrap {
  max-width: 520px;
  margin: 8vh auto 0;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-soft);
  padding: 44px 30px;
}
.friendly-wrap .state-icon { width: 76px; height: 76px; }
.friendly-logo { display: block; margin: 0 auto 14px; }
.friendly-logo > img { height: 40px; width: auto; display: block; }
.friendly-wrap .code {
  font-size: 3.6rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--primary-ink);
  line-height: 1;
  margin-bottom: 8px;
}
.friendly-wrap .btn-row { justify-content: center; margin-top: 18px; }

/* =================================================================== auth = */
/* Reference Login.jsx: lg:grid-cols-[1.4fr_1fr]; left marketing panel is the
   constant navy rounded-3xl card with a dot-grid texture; right form card
   max-w-[440px] with a 6px green top bar. The logo sits bare in both places -
   .auth-plate / .auth-card-logo are positioning wrappers only. */
.auth-split {
  display: grid;
  grid-template-columns: 1fr;
  min-height: 100vh;
  background:
    radial-gradient(1200px 700px at 18% -10%, var(--page-glow-green) 0%, rgba(57, 181, 74, 0.0) 55%),
    radial-gradient(900px 500px at 105% 0%, var(--page-glow-sky) 0%, rgba(14, 165, 233, 0.0) 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
}
@media (min-width: 1024px) {
  .auth-split { grid-template-columns: 1.4fr 1fr; }
}

.auth-brand {
  position: relative;
  overflow: hidden;
  margin: 16px;
  border-radius: var(--radius-lg);           /* rounded-3xl = 24px */
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: var(--hero-gradient);           /* navy in BOTH themes */
  color: #ffffff;
  padding: 44px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: left;
  box-shadow: 0 28px 90px rgba(15, 23, 42, 0.22);
}
.auth-brand::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top right, rgba(14, 165, 233, 0.20), transparent 34%),
    radial-gradient(circle at bottom left, rgba(34, 197, 94, 0.12), transparent 28%);
  pointer-events: none;
}
.auth-brand::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(rgba(255, 255, 255, 0.9) 1px, transparent 1px);
  background-size: 14px 14px;
  opacity: .05;
  -webkit-mask-image: radial-gradient(ellipse at center, #000 25%, transparent 72%);
  mask-image: radial-gradient(ellipse at center, #000 25%, transparent 72%);
  pointer-events: none;
}
.auth-brand > * { position: relative; z-index: 1; }

/* positioning wrapper for the bare logo - not a plate */
.auth-plate {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
}
.auth-plate .logo-swap > img { height: 40px; width: auto; }

.auth-head { display: block; margin-top: 16px; }
.auth-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.auth-pill {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  gap: 8px;
  margin-top: 32px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;                             /* slate-300 */
  font-size: 12px;
  font-weight: 500;
}
.auth-headline {
  margin: 28px 0 0;
  font-size: 36px;
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.2;
  color: #ffffff;
}
.auth-headline .auth-tagline { display: block; }
.auth-tagline .auth-accent {
  display: block;
  background: linear-gradient(90deg, #6ee7b7 0%, #34d399 50%, #39B54A 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.auth-brand-sub {
  margin: 20px 0 0;
  max-width: 48ch;
  color: #cbd5e1;                             /* slate-300 */
  font-size: 16px;
  line-height: 1.6;
}
.auth-features {
  margin-top: 36px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.05);
  padding: 8px;
}
.auth-features ul { list-style: none; margin: 0; padding: 0; }
.auth-feature { display: flex; align-items: flex-start; gap: 16px; padding: 16px 12px; }
.auth-feature + .auth-feature { border-top: 1px solid rgba(255, 255, 255, 0.10); }
.auth-feature-icon {
  flex: 0 0 auto;
  width: 48px; height: 48px;                  /* reference h-12 w-12 */
  border-radius: 16px;                        /* rounded-2xl */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  background: linear-gradient(135deg,
    rgba(16, 185, 129, 0.20) 0%,
    rgba(34, 197, 94, 0.15) 50%,
    rgba(20, 184, 166, 0.20) 100%);           /* green */
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
/* tile tones: green, teal, sky, amber */
.auth-feature-icon.tint-teal { background: linear-gradient(135deg,
    rgba(20, 184, 166, 0.20) 0%, rgba(16, 185, 129, 0.15) 50%, rgba(6, 182, 212, 0.20) 100%); }
.auth-feature-icon.tint-blue { background: linear-gradient(135deg,
    rgba(14, 165, 233, 0.20) 0%, rgba(59, 130, 246, 0.15) 50%, rgba(6, 182, 212, 0.20) 100%); }
.auth-feature-icon.tint-amber { background: linear-gradient(135deg,
    rgba(245, 158, 11, 0.20) 0%, rgba(234, 179, 8, 0.15) 50%, rgba(249, 115, 22, 0.20) 100%); }
.auth-feature-text { min-width: 0; padding-top: 2px; }
.auth-feature-title { display: block; font-size: 14px; font-weight: 600; color: #ffffff; }
.auth-feature-sub { display: block; margin-top: 4px; font-size: 12px; line-height: 1.6; color: #cbd5e1; }

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  position: relative;
}
.auth-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;                        /* rounded-2xl */
  box-shadow: 0 30px 70px -28px rgba(15, 23, 42, 0.40);
  padding: 32px;
  animation: fade-up 520ms var(--ease);
}
:root[data-theme="dark"] .auth-card { box-shadow: 0 40px 90px -32px rgba(0, 0, 0, 0.75); }
.auth-accent-bar {
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  background: #39B54A;
}
.auth-card h1 { font-size: 24px; font-weight: 600; letter-spacing: -.02em; margin: 0 0 2px; }
.auth-card .auth-sub { color: var(--muted); font-size: 14px; margin: 0 0 24px; }
/* positioning wrapper for the bare logo - not a plate */
.auth-card .auth-card-logo {
  display: inline-flex;
  align-items: center;
  margin-bottom: 20px;
}
.auth-card .auth-card-logo .logo-swap > img { height: 40px; width: auto; }
.auth-card form { text-align: left; }

/* login sign-in button: gradient #39B54A -> #239B3C with green glow */
#login-button.btn-primary {
  background: linear-gradient(90deg, #39B54A 0%, #239B3C 100%);
  color: #04150b;
  box-shadow: 0 10px 28px rgba(57, 181, 74, 0.35);
}
#login-button.btn-primary:hover:not(:disabled) {
  box-shadow: 0 14px 34px rgba(57, 181, 74, 0.45);
  filter: brightness(1.05);
  transform: scale(1.015);
}

/* leading-icon inputs (login): 28px chip, rounded-lg, bg-primary/10 */
.input-icon-wrap { position: relative; }
.input-icon-wrap .input-icon {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  color: var(--primary);
  pointer-events: none;
  z-index: 1;
}
.input-icon-wrap > input { height: 44px; padding-left: 44px; border-radius: 12px; }
.input-icon-wrap .password-toggle { right: 6px; }

@media (max-width: 1023px) {
  .auth-brand { padding: 28px; margin: 16px 16px 0; }
  .auth-headline { font-size: 28px; }
  .auth-brand-sub { display: none; }
  .auth-features { display: none; }
  .auth-card { padding: 24px; }
}
@media (max-width: 640px) {
  .auth-panel { padding: 16px; }
  .auth-card { padding: 22px; }
  .auth-brand { margin: 12px; }
}

/* ============================================================ utilities == */
.stack { display: flex; flex-direction: column; gap: 14px; }
.mt { margin-top: 14px; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.hidden { display: none !important; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-plain li:last-child { border-bottom: 0; }
.list-plain a { font-weight: 700; text-decoration: none; }
.list-plain a:hover { text-decoration: underline; }

.list-count { color: var(--muted); font-size: .92rem; font-weight: 600; }

/* ------------------------------------------------------------- documents */
.doc-list { display: grid; gap: 12px; }

/* ====================================================== motion ========= */
/* Reference tailwind.config.js keyframes + animations (Tailwind -> CSS). */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes scale-in {
  from { opacity: 0; transform: scale(0.98); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes slide-in-left {
  from { opacity: 0; transform: translateX(-16px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes badge-pop {
  0% { transform: scale(0.85); }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
/* page content entrance (reference animate-fade-up 520ms) */
.page > * { animation: fade-up 520ms var(--ease); }

/* reference skeleton: shimmer 1800ms, alpha stops for each theme */
.skeleton {
  background: linear-gradient(90deg,
    rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.05));
  background-size: 200% 100%;
  animation: shimmer 1800ms ease-in-out infinite;
  border-radius: 12px;                        /* reference rounded-xl */
}
:root[data-theme="light"] .skeleton {
  background: linear-gradient(90deg,
    rgba(15, 23, 42, 0.06), rgba(15, 23, 42, 0.11), rgba(15, 23, 42, 0.06));
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}



/* ========================================================== theme UI ==== */
/* Segmented 3-state pill: [Light | Dark | System].
   Reference login control: rounded-xl border-border/60 bg-surface/80 p-1
   shadow-soft backdrop-blur; active segment bg-surface3. */
.theme-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 12px;                        /* rounded-xl */
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-soft);
  padding: 4px;
}
.theme-seg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  padding: 6px 12px;
  border-radius: 8px;                         /* rounded-lg */
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.theme-seg:hover:not([aria-pressed="true"]) { color: var(--text); }
.theme-seg[aria-pressed="true"] {
  background: var(--surface-3);
  color: var(--text);
}
@media (max-width: 700px) {
  .theme-seg span { display: none; }
  .theme-seg { padding: 6px 9px; }
}

/* Login page: pill pinned to the top right of the sign-in column. */
.auth-topbar {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 8px;
  z-index: 5;
}
.auth-panel { position: relative; }

/* ------------------------------------------------------------------- logo --
   NO plate, NO box, NO background behind the logo in ANY theme.

   The small gray line in the wordmark ("NEW WAY SOCIAL & DEVELOPMENT
   ORGANIZATION") is unreadable on the dark theme, so the dark build has its
   own asset in which ONLY those gray pixels were recolored to #E6ECE8; every
   brand color and the whole alpha channel are untouched. Generated once by
   tools/make-logo-dark.ps1.

   Both files are plain <img> tags inside .logo-swap and the swap is pure CSS
   driven by <html data-theme>, which theme-init.js sets synchronously in
   <head> BEFORE the stylesheet, so the right logo is painted on the first
   frame - no flash, and no JavaScript involvement in the swap itself.
   This also holds while the mode is 'system': theme-init.js resolves that to
   a concrete light/dark data-theme and re-applies it on every
   prefers-color-scheme change.                                               */
.logo-swap {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  line-height: 0;
}
.logo-swap > img {
  height: 40px;
  width: auto;
  display: block;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}
.logo-swap > .logo-dark-img { display: none; }
:root[data-theme="dark"] .logo-swap > .logo-light-img { display: none; }
:root[data-theme="dark"] .logo-swap > .logo-dark-img { display: block; }

/* ============================================== public share page ========== */
/* shared.html?t=TOKEN: standalone viewer for a share link. The PDF is the
   focus: one slim sticky bar, then a continuous scroll of lazily-rendered
   pages. No sidebar, no navigation, no login. Layout only - the theme tokens
   above supply colors. */
.share-body {
  min-height: 100vh;
  background: var(--bg);
}

/* -------- slim sticky top bar: brand · title · chips · info · tools ------- */
.share-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.share-bar-inner {
  width: 100%;
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 0 var(--gutter);
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.share-brand { display: inline-flex; align-items: center; flex: 0 0 auto; }
.share-brand .logo-swap > img {
  height: 34px;
  width: auto;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}
.share-title {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  font-size: .96rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.share-chips { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; min-width: 0; }
.share-chips .chip {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.share-badge { flex: 0 0 auto; padding: 5px 8px; }
.share-badge .icon { display: block; }

.share-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 1 auto;   /* natural width, but shrinks (and scrolls) when the bar is tight */
  min-width: 0;
  margin-left: auto;
}
.share-group { display: flex; align-items: center; gap: 4px; }
.share-page-field input { width: 48px; min-height: 34px; }
.share-page-total { font-size: .85rem; }
.share-zoom-level { min-width: 46px; }
.share-bar .is-prev svg { transform: scaleX(-1); }
.share-bar .zoom-fit.is-active,
.share-bar .icon-btn.is-active {
  background: var(--green-tint);
  border-color: var(--primary-border-strong);
  color: var(--green-deep);
}
/* slim bar: the theme pill is icon-only here (labels cost too much width) */
.share-bar .theme-seg span { display: none; }
.share-bar .theme-seg { padding: 6px 7px; }

/* details popover keeps the reading surface clean while staying reachable */
.share-info-btn { position: relative; }
.share-info-pop {
  position: absolute;
  right: var(--gutter);
  top: calc(100% + 8px);
  z-index: 40;
  width: min(320px, calc(100vw - 2 * var(--gutter)));
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card, 16px);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}
.share-info-list { margin: 0; display: grid; gap: 8px; }
.share-info-list > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.share-info-list dt { margin: 0; font-size: .8rem; color: var(--muted); font-weight: 600; }
.share-info-list dd { margin: 0; font-size: .88rem; font-weight: 700; text-align: right; }
.share-copyright {
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: .78rem;
  color: var(--muted);
}

/* -------- loading / generic failure states -------- */
.share-state {
  width: 100%;
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 80px var(--gutter);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.share-state h1 { font-size: 22px; margin: 0; }
.share-state a { color: var(--green-deep); }
.share-logo-lg { margin: 0 0 4px; }
.share-logo-lg > img { height: 48px; }

/* -------- document stage: continuous scroll of lazy-rendered pages -------- */
.share-stage {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px var(--gutter) 48px;
  outline: none;
  touch-action: pan-x pan-y pinch-zoom;
}
.share-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  min-height: 240px;
}
.share-pages .skeleton { width: min(760px, 100%); height: 320px; }
.share-pages .state { width: min(560px, 100%); }
.share-page {
  position: relative;
  width: 100%;
  max-width: 100%;
  scroll-margin-top: calc(var(--share-bar-h, 56px) + 12px);
  background: #ffffff;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}
.share-page .share-canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #ffffff;
  opacity: 0;
  transition: opacity .18s ease;
}
.share-page.is-rendered .share-canvas { opacity: 1; }
.share-page::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px var(--border);
}

/* floating page pill (mobile, while scrolling) */
.share-pagepill {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 30;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  font-size: .85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  opacity: 0;
  transition: opacity .18s ease;
  pointer-events: none;
}
.share-pagepill.is-on { opacity: 1; }
.share-foot {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: 4px var(--gutter) 28px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* highlighted chip used for the current version in the share bar */
.chip-current {
  background: var(--primary-soft-2);
  color: var(--green-deep);
  border-color: var(--primary-border-strong);
}

/* -------- responsive -------- */
/* Below the 1280 shell the full toolbar cannot fit on one line: let it shrink
   and scroll sideways instead of pushing the theme toggle off-screen. (The
   department chip already lives only in the details popover, not the bar.) */
@media (max-width: 1279px) {
  .share-toolbar { overflow-x: auto; scrollbar-width: none; }
  .share-toolbar::-webkit-scrollbar { display: none; }
}
@media (max-width: 640px) {
  .share-bar-inner { height: 52px; gap: 8px; padding: 0 12px; }
  .share-brand .logo-swap > img { height: 28px; }
  .share-title, .share-chips, .share-badge { display: none; }
  .share-page-field, .share-page-total, .share-zoom-level { display: none; }
  .share-stage { padding: 12px 10px 40px; }
  .share-pages { gap: 10px; }
}

/* share-link dialog */
.share-dialog { max-width: 620px; }
.share-list { display: flex; flex-direction: column; gap: 12px; max-height: 46vh; overflow-y: auto; }
.share-link-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.share-link-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.share-link-chips { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.share-link-meta { font-size: 13px; margin: 0; }
.share-onetime {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--primary-border-strong);
  border-radius: var(--radius-sm);
  background: var(--green-tint);
}
.share-onetime-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.share-url {
  flex: 1 1 260px;
  min-width: 0;
  font-family: var(--mono, ui-monospace, Consolas, monospace);
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
}
.share-warn {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.share-warn .icon { flex: 0 0 auto; color: var(--primary); }

/* ======================================================== PDF viewer ===== */
/* viewer.html: full-page document viewer rendered with self-hosted PDF.js. */
.icon-btn:disabled,
.icon-btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.icon-btn:disabled:hover { background: var(--surface); border-color: var(--line); color: var(--ink); }

.viewer-body {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.viewer {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.viewer-top {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--topbar-h);
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.viewer-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  font-size: .9rem;
}
.viewer-back:hover { background: var(--green-tint); color: var(--green-deep); border-color: var(--primary-border-strong); }
.viewer-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: .92rem;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.viewer-brand .logo-swap > img {
  height: 40px;
  width: auto;
  background: transparent;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}
.viewer-title {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.viewer-title h1 {
  margin: 0;
  font-size: .98rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.viewer-top-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.viewer-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.toolbar-group { display: flex; align-items: center; gap: 6px; }
.toolbar-sep { width: 1px; height: 26px; background: var(--line); }
.toolbar-spacer { flex: 1 1 auto; }
.toolbar-actions .btn { min-height: 38px; }

.page-field input {
  width: 58px;
  min-height: 38px;
  text-align: center;
  padding: 4px 6px;
  font-weight: 700;
}
.page-total { font-size: .88rem; font-weight: 700; color: var(--muted); white-space: nowrap; }
.zoom-level {
  min-width: 54px;
  text-align: center;
  font-size: .85rem;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.viewer-toolbar .is-prev svg { transform: scaleX(-1); }
.viewer-toolbar .zoom-fit.is-active {
  background: var(--green-tint);
  border-color: var(--primary-border-strong);
  color: var(--green-deep);
}

.viewer-stage {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 24px 16px 40px;
}
.viewer-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 220px;
}
.viewer-pages .skeleton { width: min(760px, 100%); height: 320px; }
.viewer-pages .state { width: min(560px, 100%); }
.viewer-status { margin-top: 12px; text-align: center; font-size: .92rem; }
.pdf-canvas {
  display: block;
  max-width: 100%;
  height: auto;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
}
@media (max-width: 640px) {
  .viewer-brand span { display: none; }
  .viewer-back-text { display: none; }
  .viewer-toolbar { gap: 6px; }
}

/* ---------------------------------------------------------- print output */
.print-root { display: none; }
.print-page { text-align: center; page-break-after: always; break-after: page; }
.print-page:last-child { page-break-after: auto; break-after: auto; }
.print-page canvas { max-width: 100%; height: auto; }

@media print {
  body.viewer-body,
  body.share-body { height: auto; overflow: visible; background: #ffffff; }
  .skip-link,
  .viewer,
  .share-bar,
  .share-foot,
  .share-pagepill,
  .toast-region { display: none !important; }
  .print-root,
  .print-root[hidden] { display: block !important; }
  .print-page canvas { box-shadow: none; border-radius: 0; }
  @page { margin: 12mm; }
}





