:root {
  /* Haigler Systems brand palette (from haiglersystems.com) */
  --hs-navy: #02386e;
  --hs-navy-dark: #01223f;
  --hs-blue: #115ca5;
  --hs-red: #870e13;
  --hs-red-bright: #b8292f;
  --hs-khaki: #f2ece4;
  --hs-khaki-border: #ddd3c5;
  --hs-charcoal: #3b3d40;
  --hs-gray: #555555;

  --color-bg: #f3f4f7;
  --color-surface: #ffffff;
  --color-text: #1a1d29;
  --color-text-muted: #6b7280;
  --color-border: #e5e7eb;
  --radius: 14px;
  --sidebar-width: 236px;

  --stage-new: #2f8f4e;
  --stage-new-bg: #e5f4ea;
  --stage-dev: #b5650a;
  --stage-dev-bg: #fff0dc;
  --stage-final: #8a6d00;
  --stage-final-bg: #fdf5c6;
  --stage-released: #115ca5;
  --stage-released-bg: #e2eefa;
  --stage-denied: #b8292f;
  --stage-denied-bg: #fbe6e7;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.06);
  --header-height: 60px;

  /* Theme-able roles used by the signed-in pages (light values). */
  --c-heading: var(--hs-navy);
  --c-text-2: var(--hs-charcoal);
  --c-text-3: var(--hs-gray);
  --c-soft: var(--hs-khaki);
  --c-soft-2: #eef0f3;
  --c-border-warm: var(--hs-khaki-border);
  --c-border-strong: #c9ced6;
  --c-input-border: #d5d9e0;
  --c-hover: #f6f8fb;
  --c-stripe-1: #f3f4f7;
  --c-stripe-2: #eef0f4;
  --c-topbar: rgba(255, 255, 255, 0.92);
  --c-note-text: #6b5600;
  color-scheme: light;
}

/* Dark theme (classic UI). Set by js/theme.js as <html data-theme="dark">.
   Built from the two brand anchors:
   - Monochromatic base: every surface is the Haigler navy hue (212deg) at
     low saturation, stepped only by lightness for elevation:
     sidebar 7% < page 9% < panels 12.5% < hover 14.5% < raised 16%.
   - 60-30-10: navy surfaces ~60%, lighter navy-tinted panels/text ~30%,
     accents ~10%.
   - Accents: Haigler red (near-complementary to navy) for actions and
     highlights only; the brand blue, lightened, for links and focus.
   - Stage colours share one lightness/saturation band so no stage
     outshouts another and none vibrates on the dark ground.
   - Every text colour meets WCAG AA (4.5:1) on every surface it sits on
     (muted text 6.4:1, body text 14:1). */
:root[data-theme="dark"] {
  --hs-blue: #77b2ee;
  --hs-red: #ee777d;
  --hs-red-bright: #c22e35;

  --c-sidebar: #0b1119;
  --color-bg: #10161e;
  --color-surface: #171f29;
  --color-text: #e8edf3;
  --color-text-muted: #96a2b0;
  --color-border: #2b3540;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.3);

  --stage-new: #70cd96;
  --stage-new-bg: rgba(112, 205, 150, 0.13);
  --stage-dev: #eaa653;
  --stage-dev-bg: rgba(234, 166, 83, 0.13);
  --stage-final: #e0c952;
  --stage-final-bg: rgba(224, 201, 82, 0.13);
  --stage-released: #77b2ee;
  --stage-released-bg: rgba(119, 178, 238, 0.13);
  --stage-denied: #ee777d;
  --stage-denied-bg: rgba(238, 119, 125, 0.13);

  --c-heading: #c2daf5;
  --c-text-2: #c3cbd5;
  --c-text-3: #96a2b0;
  --c-soft: #1f2833;
  --c-soft-2: #1c242e;
  --c-border-warm: #2b3540;
  --c-border-strong: #3d4957;
  --c-input-border: #3d4957;
  --c-hover: #1c242e;
  --c-stripe-1: #1c242e;
  --c-stripe-2: #1f2833;
  --c-topbar: rgba(16, 22, 30, 0.88);
  --c-note-text: #e0c952;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

/* The hidden attribute always wins over component display rules. */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

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

img {
  max-width: 100%;
}

button {
  font-family: inherit;
}

/* ---------------------------------------------------------------------- */
/* Login page: full-bleed photo hero, styled after the                     */
/* haiglersystems.com homepage                                             */
/* ---------------------------------------------------------------------- */

.login-page {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #fff;
  /* Same hero photo as the haiglersystems.com homepage. */
  background: var(--hs-navy-dark) url("../assets/login-bg.webp") center / cover no-repeat;
  border-bottom: 5px solid var(--hs-red-bright);
}

.login-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.login-overlay {
  background: linear-gradient(90deg, rgba(10, 10, 12, 0.55) 0%, rgba(10, 10, 12, 0.62) 50%, rgba(10, 10, 12, 0.72) 100%),
    linear-gradient(180deg, rgba(0, 0, 0, 0) 60%, rgba(1, 34, 63, 0.55) 100%);
}

.login-header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 64px;
  background: rgba(20, 20, 22, 0.45);
}

.login-header-logo {
  width: 260px;
  height: auto;
  display: block;
}

.login-header-label {
  font-family: "Saira Extra Condensed", "Arial Narrow", sans-serif;
  font-size: 22px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.login-hero {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  max-width: 1100px;
  margin-left: auto;
  padding: 40px 64px 56px 0;
}

/* Thin vertical + horizontal rules framing the headline, as on the site. */
.login-hero-copy {
  border-left: 1px solid rgba(255, 255, 255, 0.35);
  border-bottom: 1px solid rgba(255, 255, 255, 0.35);
  padding: 8px 0 40px 32px;
  margin-left: 48px;
}

.login-hero h1 {
  margin: 0;
  font-family: "Saira Extra Condensed", "Arial Narrow", sans-serif;
  font-size: clamp(44px, 6.4vw, 104px);
  font-weight: 700;
  line-height: 1.05;
  text-transform: uppercase;
}

.login-hero h1 .light {
  font-weight: 300;
}

.login-hero-tagline {
  margin: 14px 0 0;
  font-family: "Saira Extra Condensed", "Arial Narrow", sans-serif;
  font-size: clamp(22px, 2.6vw, 40px);
  font-weight: 400;
  line-height: 1.2;
}

.login-actions {
  margin-left: 48px;
  padding: 40px 0 0 32px;
  border-left: 1px solid rgba(255, 255, 255, 0.35);
  max-width: 520px;
}

.ms-signin-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 18px 34px;
  background: var(--hs-red-bright);
  color: #fff;
  border: none;
  border-radius: 2px;
  font-family: "Public Sans", "Segoe UI", sans-serif;
  font-size: 18px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.15s ease;
}

.ms-signin-btn:hover:not(:disabled) {
  background: var(--hs-blue);
}

.ms-signin-btn:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.ms-signin-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.ms-logo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 1px;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.ms-logo span {
  display: block;
}

.ms-logo span:nth-child(1) { background: #f25022; }
.ms-logo span:nth-child(2) { background: #7fba00; }
.ms-logo span:nth-child(3) { background: #00a4ef; }
.ms-logo span:nth-child(4) { background: #ffb900; }

.login-status {
  margin: 16px 0 0;
  min-height: 20px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
}

.login-status.error {
  color: #ffb4b4;
}

.login-footnote {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.65);
}

/* ---------------------------------------------------------------------- */
/* App shell (protected pages): navy sidebar + topbar                      */
/* ---------------------------------------------------------------------- */

body[data-page] {
  font-family: "Public Sans", "Segoe UI", system-ui, sans-serif;
  background: var(--color-bg);
}

.app-layout {
  min-height: 100vh;
  display: flex;
}

.sidebar {
  position: sticky;
  top: 0;
  flex: 0 0 var(--sidebar-width);
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  color: #fff;
  background: linear-gradient(180deg, var(--hs-navy-dark) 0%, var(--hs-navy) 100%);
  border-right: 4px solid #870e13;
  z-index: 40;
}

.sidebar-brand img {
  display: block;
  width: 168px;
  height: auto;
  margin: 0 6px 6px;
}

.sidebar-label {
  margin: 6px 8px 22px;
  font-family: "Saira Extra Condensed", "Arial Narrow", sans-serif;
  font-size: 15px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  flex-shrink: 0;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav-link.active {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.nav-link.active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 8px;
  bottom: 8px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--hs-red-bright);
}

.sidebar-backdrop {
  display: none;
}

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

.topbar {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 28px;
  background: var(--c-topbar);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar-title {
  font-family: "Saira Extra Condensed", "Arial Narrow", sans-serif;
  font-size: 20px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--c-heading);
}

.hamburger {
  display: none;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  border-radius: 6px;
}

.hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--hs-navy);
  margin: 4px 0;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.theme-toggle {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 2px;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-surface);
  color: var(--c-heading);
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: var(--c-heading);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.theme-toggle .moon,
:root[data-theme="dark"] .theme-toggle .sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .moon {
  display: block;
}

.role-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  background: var(--c-soft-2);
  color: var(--c-text-3);
}

.role-approver {
  background: var(--stage-released-bg);
  color: var(--stage-released);
}

.role-general {
  background: var(--stage-new-bg);
  color: var(--stage-new);
}

.role-blocked {
  margin: 0 0 16px;
  font-weight: 600;
  color: var(--c-text-2);
}

.role-notice {
  padding: 10px 28px;
  background: var(--stage-final-bg);
  border-bottom: 1px solid var(--color-border);
  color: var(--c-note-text);
  font-size: 14px;
  font-weight: 600;
}

.ui-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 6px;
  padding: 6px 12px 6px 6px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--c-heading);
  cursor: pointer;
  white-space: nowrap;
}

.ui-toggle:hover {
  border-color: var(--c-heading);
}

.ui-toggle-track {
  width: 30px;
  height: 18px;
  padding: 2px;
  border-radius: 999px;
  background: #d5d9e0;
}

.ui-toggle-track span {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--hs-navy), var(--hs-blue));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 700;
}

.user-email {
  font-size: 11px;
  color: var(--color-text-muted);
}

.page {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 28px 48px;
}

/* ---------------------------------------------------------------------- */
/* Buttons, pills, tags                                                    */
/* ---------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn:focus-visible,
.icon-btn:focus-visible {
  outline: 3px solid rgba(17, 92, 165, 0.45);
  outline-offset: 2px;
}

.btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.btn-primary {
  background: var(--hs-red-bright);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--hs-red);
}

.btn-secondary {
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--c-heading);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--c-heading);
}

.btn-ghost {
  background: transparent;
  color: var(--c-heading);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--c-soft);
}

.btn-on-dark {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

.btn-on-dark:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.22);
}

.btn-on-dark.spinning svg {
  animation: spin 0.8s linear infinite;
}

.btn-lg {
  padding: 14px 22px;
  font-size: 15px;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

.icon-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: none;
  border-radius: 8px;
  background: var(--color-bg);
  color: var(--c-text-2);
  font-size: 15px;
  cursor: pointer;
}

.icon-btn:hover {
  background: var(--c-soft);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.stage-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.stage-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.stage-new { background: var(--stage-new-bg); color: var(--stage-new); }
.stage-dev { background: var(--stage-dev-bg); color: var(--stage-dev); }
.stage-final { background: var(--stage-final-bg); color: var(--stage-final); }
.stage-released { background: var(--stage-released-bg); color: var(--stage-released); }
.stage-denied { background: var(--stage-denied-bg); color: var(--stage-denied); }
.stage-other { background: var(--c-soft-2); color: var(--c-text-3); }

.tag {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--c-soft);
  border: 1px solid var(--c-border-warm);
  font-size: 12px;
  font-weight: 600;
  color: var(--c-text-2);
}

.muted {
  color: var(--color-text-muted);
}

/* ---------------------------------------------------------------------- */
/* Page headers + panels                                                   */
/* ---------------------------------------------------------------------- */

.page-header {
  margin-bottom: 22px;
}

.page-eyebrow,
.hero-eyebrow,
.modal-eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--hs-red);
}

.page-title {
  margin: 0;
  font-family: "Saira Extra Condensed", "Arial Narrow", sans-serif;
  font-size: clamp(34px, 4vw, 46px);
  font-weight: 300;
  line-height: 1.05;
  text-transform: uppercase;
  color: var(--c-heading);
}

.page-title strong,
.hero-title strong {
  font-weight: 700;
}

.page-subtitle {
  margin: 8px 0 0;
  color: var(--color-text-muted);
}

.panel {
  min-width: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.panel-accent {
  border-top: 4px solid var(--hs-navy);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-header h2 {
  margin: 0;
  font-size: 18px;
  color: var(--c-heading);
}

.panel-sub {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--color-text-muted);
}

.empty-state {
  margin: 0;
  padding: 28px 12px;
  text-align: center;
  color: var(--color-text-muted);
}

.back-link {
  display: inline-block;
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--hs-blue);
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

/* ---------------------------------------------------------------------- */
/* Dashboard                                                               */
/* ---------------------------------------------------------------------- */

.hero {
  position: relative;
  overflow: hidden;
  margin-bottom: 22px;
  padding: 26px 28px 28px;
  border-radius: 16px;
  color: #fff;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(184, 41, 47, 0.55) 0%, rgba(184, 41, 47, 0) 55%),
    linear-gradient(135deg, var(--hs-navy-dark) 0%, var(--hs-navy) 100%);
  box-shadow: 0 18px 40px rgba(1, 34, 63, 0.25);
}

/* Faint diagonal "S" swoosh echoing the Haigler logo. */
.hero::after {
  content: "";
  position: absolute;
  right: -60px;
  bottom: -90px;
  width: 360px;
  height: 220px;
  border-radius: 50%;
  border: 26px solid rgba(255, 255, 255, 0.05);
  transform: rotate(-18deg);
  pointer-events: none;
}

.hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.hero-eyebrow {
  color: rgba(255, 255, 255, 0.72);
}

.hero-title {
  margin: 0;
  font-family: "Saira Extra Condensed", "Arial Narrow", sans-serif;
  font-size: clamp(32px, 4vw, 48px);
  font-weight: 300;
  line-height: 1.05;
  text-transform: uppercase;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.stat-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.stat-tile::before {
  content: "";
  width: 28px;
  height: 4px;
  border-radius: 2px;
  margin-bottom: 10px;
  background: var(--tile-accent);
}

.stat-tile:hover {
  background: rgba(255, 255, 255, 0.13);
  transform: translateY(-2px);
}

.stat-tile.active {
  background: #fff;
  color: var(--c-heading);
  border-color: #fff;
}

.stat-new { --tile-accent: #6fd08c; }
.stat-dev { --tile-accent: #ffb547; }
.stat-final { --tile-accent: #f2e15a; }
.stat-released { --tile-accent: #7cb8f2; }

.stat-count {
  font-family: "Saira Extra Condensed", "Arial Narrow", sans-serif;
  font-size: 44px;
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  font-size: 13px;
  font-weight: 600;
  opacity: 0.85;
}

.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px;
  border-radius: 10px;
  background: var(--color-bg);
}

.field-inline {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 130px;
  min-width: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--c-text-3);
}

input[type="text"],
input[type="search"],
input[type="date"],
select,
textarea {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--c-input-border);
  border-radius: 8px;
  background: var(--color-surface);
  font: inherit;
  font-size: 14px;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
  color: var(--color-text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--hs-blue);
  box-shadow: 0 0 0 3px rgba(17, 92, 165, 0.15);
}

input.invalid {
  border-color: var(--hs-red-bright);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-text-3);
  border-bottom: 2px solid var(--color-border);
}

.data-table td {
  padding: 12px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.data-table tr.clickable {
  cursor: pointer;
  transition: background 0.1s ease;
}

.data-table tr.clickable:hover,
.data-table tr.clickable:focus-visible {
  background: var(--c-hover);
  outline: none;
}

.data-table tr.clickable:hover td:first-child {
  box-shadow: inset 3px 0 0 var(--hs-red-bright);
}

.cell-strong {
  font-weight: 600;
}

.cell-sub {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--color-text-muted);
}

.nowrap {
  white-space: nowrap;
}

.queue-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 560px;
  overflow-y: auto;
}

.queue-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--stage-new);
  border-radius: 8px;
  background: var(--color-surface);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.queue-item:hover {
  box-shadow: var(--shadow);
  border-color: var(--c-border-strong);
  border-left-color: var(--stage-new);
}

.queue-title {
  font-weight: 700;
  color: var(--c-heading);
}

.queue-meta {
  font-size: 12px;
  color: var(--color-text-muted);
}

/* ---------------------------------------------------------------------- */
/* Dialogs                                                                 */
/* ---------------------------------------------------------------------- */

.modal {
  background: var(--color-surface);
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 24px;
  border: none;
  border-radius: 16px;
  box-shadow: 0 30px 80px rgba(1, 34, 63, 0.35);
  color: var(--color-text);
}

.modal::backdrop {
  background: rgba(1, 20, 40, 0.6);
  backdrop-filter: blur(3px);
}

.modal[open] {
  animation: modal-in 0.18s ease-out;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

.modal-narrow {
  width: min(520px, calc(100vw - 32px));
}

.modal-wide {
  width: min(1000px, calc(100vw - 32px));
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--color-border);
}

.modal-head h2 {
  margin: 0;
  font-size: 22px;
  color: var(--c-heading);
  overflow-wrap: anywhere;
}

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.modal-tags:empty {
  display: none;
}

.modal-note {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--stage-final-bg);
  color: var(--c-note-text);
  font-size: 13px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 20px;
  margin: 0;
}

.detail {
  min-width: 0;
}

.detail.wide {
  grid-column: 1 / -1;
}

.detail dt {
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--c-text-3);
}

.detail dd {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.plain-list,
.checklist {
  margin: 8px 0 12px;
  padding-left: 22px;
}

.checklist li {
  margin-bottom: 8px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  cursor: pointer;
}

.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--hs-red-bright);
}

/* ---------------------------------------------------------------------- */
/* Forms                                                                   */
/* ---------------------------------------------------------------------- */

.form-panel {
  padding: 28px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 36px;
}

.form-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: none;
}

.field-label {
  padding: 0;
  font-weight: 700;
  font-size: 15px;
  color: var(--c-text-2);
}

.field-label em {
  color: var(--hs-red-bright);
  font-style: normal;
}

.field-hint {
  font-size: 12px;
  color: var(--color-text-muted);
}

.field-error {
  font-size: 13px;
  font-weight: 600;
  color: var(--hs-red-bright);
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
}

.segmented label {
  position: relative;
  cursor: pointer;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: block;
  padding: 8px 18px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 700;
  color: var(--c-text-3);
  transition: background 0.15s ease, color 0.15s ease;
}

.segmented input:checked + span {
  background: var(--hs-navy);
  color: #fff;
  box-shadow: var(--shadow);
}

.segmented input:focus-visible + span {
  outline: 3px solid rgba(17, 92, 165, 0.45);
}

.segmented-decision {
  display: flex;
}

.segmented-decision label {
  flex: 1;
  text-align: center;
}

.segmented-decision .decision-approve input:checked + span {
  background: var(--stage-new);
}

.segmented-decision .decision-reject input:checked + span {
  background: var(--hs-red-bright);
}

.form-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--color-border);
}

/* ---------------------------------------------------------------------- */
/* Review                                                                  */
/* ---------------------------------------------------------------------- */

.stepper {
  display: flex;
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  counter-reset: step;
}

.stepper li {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

.stepper li + li::before {
  content: "";
  position: absolute;
  top: 15px;
  right: 50%;
  width: 100%;
  height: 3px;
  background: var(--color-border);
  z-index: 0;
}

.stepper li.done + li::before,
.stepper li.done + li.current::before {
  background: var(--hs-navy);
}

.step-dot {
  position: relative;
  z-index: 1;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--color-surface);
  border: 3px solid var(--color-border);
  font-size: 13px;
  font-weight: 800;
  color: var(--c-text-3);
}

.stepper li.done .step-dot {
  background: var(--hs-navy);
  border-color: var(--c-heading);
  color: #fff;
}

.stepper li.current .step-dot {
  border-color: var(--hs-red-bright);
  color: var(--hs-red-bright);
  box-shadow: 0 0 0 5px rgba(184, 41, 47, 0.12);
}

.step-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--c-text-3);
}

.stepper li.current .step-label {
  color: var(--c-heading);
}

.review-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
}

.empty-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
}

.empty-panel p {
  margin: 0;
}

/* ---------------------------------------------------------------------- */
/* Material library                                                        */
/* ---------------------------------------------------------------------- */

.library-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.search-box {
  position: relative;
  flex: 1 1 320px;
}

.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 20px;
  height: 20px;
  transform: translateY(-50%);
  fill: var(--c-text-3);
}

.search-box input {
  padding: 12px 14px 12px 42px;
  font-size: 15px;
}

.material-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

.material-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-surface);
  box-shadow: var(--shadow);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.material-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 30px rgba(1, 34, 63, 0.14);
}

.material-thumb {
  aspect-ratio: 16 / 10;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: repeating-linear-gradient(135deg, var(--c-stripe-1) 0 12px, var(--c-stripe-2) 12px 24px);
}

.material-thumb img,
.material-thumb canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.material-thumb.loading,
.material-preview.loading {
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.6;
  }
}

.file-icon {
  width: 64px;
  height: 80px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 12px;
  border-radius: 6px 18px 6px 6px;
  background: var(--color-surface);
  border: 2px solid var(--c-border-warm);
  box-shadow: var(--shadow);
}

.file-icon span {
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--hs-navy);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.material-caption {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px 14px;
  border-top: 3px solid var(--hs-navy);
}

.material-name {
  font-weight: 700;
  color: var(--c-heading);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.material-meta {
  font-size: 12px;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.material-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(1, 34, 63, 0.82);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.material-detail {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 24px;
}

.material-preview {
  min-height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 12px;
  border: 2px dashed var(--c-border-warm);
  background: var(--c-hover);
}

.material-preview img,
.material-preview canvas {
  max-width: 100%;
  max-height: 60vh;
  object-fit: contain;
}

.material-side {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.locations-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.locations-head h3 {
  margin: 0;
  font-size: 16px;
  color: var(--c-heading);
}

.location-form {
  margin-bottom: 12px;
  padding: 14px;
  border-radius: 10px;
  background: var(--color-bg);
}

.inline-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.location-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
}

.location-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------------- */
/* Toasts                                                                  */
/* ---------------------------------------------------------------------- */

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(380px, calc(100vw - 32px));
}

.toast {
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--hs-navy-dark);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  border-left: 4px solid #7cb8f2;
  animation: modal-in 0.2s ease-out;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast-success {
  border-left-color: #6fd08c;
}

.toast-error {
  border-left-color: #ff7b7b;
}

.toast.leaving {
  opacity: 0;
  transform: translateY(6px);
}

/* ---------------------------------------------------------------------- */
/* Data sources page                                                       */
/* ---------------------------------------------------------------------- */

.source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.source-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding: 18px;
  text-align: left;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-top: 4px solid var(--hs-navy);
  border-radius: 4px;
  box-shadow: var(--shadow);
  cursor: pointer;
  color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.source-card:hover:not(:disabled) {
  border-color: var(--c-border-warm);
  border-top-color: var(--hs-red);
}

.source-card.active {
  border-top-color: var(--hs-red);
  box-shadow: 0 0 0 2px var(--hs-navy) inset, var(--shadow);
}

.source-card:disabled {
  cursor: default;
}

.source-card.error {
  border-top-color: var(--color-border);
  background: var(--c-hover);
}

.source-kind {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--hs-red);
}

.source-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--c-heading);
}

.source-meta {
  font-size: 13px;
  color: var(--color-text-muted);
}

.source-card.error .source-meta {
  color: var(--hs-red-bright);
}

.item-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  box-shadow: var(--shadow);
  padding: 18px;
  min-width: 0;
}

.item-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.item-panel-header h2 {
  margin: 0;
  font-size: 19px;
  color: var(--c-heading);
}

.item-panel-header .btn-secondary {
  text-decoration: none;
}

.folder-crumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  font-size: 14px;
}

.crumb-link,
.folder-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--hs-blue);
  cursor: pointer;
  text-align: left;
}

.crumb-link:hover,
.folder-link:hover,
.item-link:hover {
  text-decoration: underline;
}

.crumb-sep {
  color: var(--color-text-muted);
}

.crumb-current {
  font-weight: 600;
}

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

.item-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.item-table th {
  text-align: left;
  white-space: nowrap;
  padding: 10px 12px;
  background: var(--c-soft);
  color: var(--c-text-2);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--c-border-warm);
}

.item-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
  min-width: 110px;
  max-width: 320px;
  overflow-wrap: break-word;
}

.item-table td:first-child {
  min-width: 170px;
}

.item-table tbody tr:hover {
  background: var(--c-hover);
}

.item-link {
  color: var(--hs-blue);
  font-weight: 600;
  text-decoration: none;
}

.folder-link {
  font-weight: 600;
}

.table-status {
  margin: 12px 0 0;
  color: var(--color-text-muted);
  font-size: 14px;
}

.table-status:empty {
  display: none;
}

.table-status.error {
  color: var(--hs-red-bright);
}

.load-more {
  margin-top: 12px;
}


/* ---------------------------------------------------------------------- */
/* Dark theme: brand surfaces                                              */
/* Sidebar and dashboard banner drop the bright navy fill for the darkest  */
/* and most-raised steps of the navy ladder; brand navy and red return as  */
/* soft light sources (glows, edge, active marker) - the 10% accent.       */
/* ---------------------------------------------------------------------- */

:root[data-theme="dark"] .sidebar {
  background: var(--c-sidebar);
  border-right: 1px solid var(--color-border);
  box-shadow: inset -2px 0 0 rgba(194, 46, 53, 0.45);
}

:root[data-theme="dark"] .sidebar-label {
  color: var(--color-text-muted);
}

:root[data-theme="dark"] .nav-link {
  color: var(--c-text-2);
}

:root[data-theme="dark"] .nav-link:hover {
  background: rgba(194, 218, 245, 0.05);
  color: var(--color-text);
}

:root[data-theme="dark"] .nav-link.active {
  background: rgba(119, 178, 238, 0.12);
  color: var(--c-heading);
}

:root[data-theme="dark"] .hero {
  background:
    radial-gradient(110% 130% at 100% 0%, rgba(194, 46, 53, 0.18) 0%, rgba(194, 46, 53, 0) 55%),
    radial-gradient(90% 120% at 0% 100%, rgba(119, 178, 238, 0.12) 0%, rgba(119, 178, 238, 0) 60%),
    linear-gradient(135deg, #1f2833 0%, #171f29 100%);
  border: 1px solid var(--color-border);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

:root[data-theme="dark"] .hero-eyebrow {
  color: var(--color-text-muted);
}

:root[data-theme="dark"] .hero::after {
  border-color: rgba(194, 218, 245, 0.04);
}

:root[data-theme="dark"] .stat-tile {
  background: rgba(16, 22, 30, 0.55);
  border-color: var(--color-border);
}

:root[data-theme="dark"] .stat-tile:hover {
  background: rgba(16, 22, 30, 0.8);
  border-color: var(--c-border-strong);
}

/* Selected tile inverts to the navy-tint heading colour, so its number and
   label stay readable (12.7:1). */
:root[data-theme="dark"] .stat-tile.active {
  background: var(--c-heading);
  border-color: var(--c-heading);
  color: var(--color-bg);
}

:root[data-theme="dark"] .btn-on-dark {
  background: rgba(194, 218, 245, 0.06);
  border-color: var(--c-border-strong);
}

/* ---------------------------------------------------------------------- */
/* Responsive                                                              */
/* ---------------------------------------------------------------------- */

@media (max-width: 860px) {
  .login-header {
    padding: 16px;
  }

  .login-header-logo {
    width: 170px;
  }

  .login-header-label {
    font-size: 18px;
  }

  .login-hero {
    padding: 32px 16px 40px;
  }

  .login-hero-copy,
  .login-actions {
    margin-left: 0;
    padding-left: 18px;
  }

  .login-hero-copy {
    padding-bottom: 28px;
  }

  .login-actions {
    padding-top: 28px;
  }

  .ms-signin-btn {
    width: 100%;
    justify-content: center;
    padding: 16px 20px;
    font-size: 16px;
  }
}

@media (max-width: 1100px) {
  .dash-grid,
  .review-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .sidebar.open {
    transform: none;
  }

  .sidebar-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(1, 20, 40, 0.5);
  }

  .hamburger {
    display: block;
  }

  .topbar {
    padding: 0 16px;
  }

  .page {
    padding: 20px 16px 40px;
  }

  .form-grid,
  .material-detail {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-panel {
    padding: 20px;
  }
}

@media (max-width: 600px) {
  .user-meta {
    display: none;
  }

  .role-badge {
    display: none;
  }

  .ui-toggle {
    font-size: 0;
    gap: 0;
    margin-right: 0;
    padding: 6px;
  }

  .user-chip {
    gap: 6px;
  }

  .hero {
    padding: 20px;
  }

  .stat-count {
    font-size: 34px;
  }

  .detail-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Requests table becomes stacked cards: title + status, then requestor + date. */
  .data-table thead {
    display: none;
  }

  .data-table tr.clickable {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 12px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--color-border);
  }

  .data-table tr.clickable td {
    padding: 0;
    border: none;
  }

  .data-table tr.clickable td:nth-child(1) { grid-area: 2 / 1; color: var(--color-text-muted); }
  .data-table tr.clickable td:nth-child(2) { grid-area: 1 / 1; font-weight: 700; }
  .data-table tr.clickable td:nth-child(3) { grid-area: 1 / 2; justify-self: end; }
  .data-table tr.clickable td:nth-child(4) { grid-area: 2 / 2; justify-self: end; color: var(--color-text-muted); }

  .data-table tr.clickable:hover td:first-child {
    box-shadow: none;
  }

  .step-label {
    font-size: 11px;
  }

  .form-footer {
    flex-direction: column-reverse;
  }

  .form-footer .btn {
    width: 100%;
  }
}
