/*
 * ApprovalFlow design system (PRD §9, design direction: Image 2).
 * 1. Tokens  2. Base  3. Layout shells  4. Components  5. Utilities
 * No build step: plain CSS served as-is on shared hosting.
 */

@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("../fonts/plus-jakarta-sans-latin-wght.woff2") format("woff2");
  font-weight: 200 800;
  font-style: normal;
  font-display: swap;
}

/* 1. Tokens ---------------------------------------------------------------- */
:root {
  /* Brand */
  --navy-950: #070d24;
  --navy-900: #0b1437;
  --navy-800: #142056;
  --navy-700: #1d2b6e;
  --blue-700: #1846c9;
  --blue-600: #1f5af0;
  --blue-500: #2f6bff;
  --blue-100: #e3ecff;
  --blue-50: #f2f6ff;
  --sky-400: #22b8ff;
  --violet-600: #6a2fe0;
  --violet-500: #7a3cf0;
  --violet-100: #efe7ff;

  /* Status (always paired with an icon or text, never colour alone) */
  --mint-700: #087a50;
  --mint-500: #14b87a;
  --mint-100: #dcf7ec;
  --amber-700: #9a5b00;
  --amber-500: #f5a524;
  --amber-100: #fff1d6;
  --red-700: #b42318;
  --red-500: #e5484d;
  --red-100: #fde5e6;

  /* Neutrals */
  --gray-900: #111733;
  --gray-700: #3a4363;
  --gray-500: #5b6480;
  --gray-400: #8a93a6;
  --gray-300: #c4cad8;
  --gray-200: #e3e7f0;
  --gray-100: #eef1f7;
  --gray-50: #f6f8fc;

  /* Semantic */
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-muted: var(--gray-50);
  --text: var(--gray-900);
  --text-muted: var(--gray-500);
  --border: var(--gray-200);
  --primary: var(--blue-600);
  --primary-hover: var(--blue-700);
  --focus: var(--sky-400);

  /* Text-bearing gradient: every stop keeps white text at >= 5.5:1 (WCAG AA). */
  --gradient-brand: linear-gradient(135deg, var(--blue-600) 0%, #3b4ff2 50%, var(--violet-600) 100%);
  --gradient-header: radial-gradient(120% 140% at 100% 0%, rgba(122, 60, 240, .85) 0%, transparent 55%),
                     linear-gradient(135deg, var(--blue-600) 0%, #3b4ff2 55%, var(--violet-600) 100%);
  --gradient-night: radial-gradient(100% 70% at 80% 0%, #3b2a8f 0%, transparent 60%),
                    linear-gradient(170deg, var(--navy-800) 0%, var(--navy-950) 70%);

  /* Type */
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --text-xs: .75rem;
  --text-sm: .875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;

  /* Space, shape, depth */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(17, 23, 51, .06);
  --shadow: 0 1px 2px rgba(17, 23, 51, .05), 0 6px 20px rgba(17, 23, 51, .07);
  --shadow-lg: 0 12px 40px rgba(11, 20, 55, .18);

  /* Shell */
  --appbar-h: 56px;
  --bottom-nav-h: 68px;
  --sidebar-w: 264px;
  --content-max: 1080px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(.2, .8, .2, 1);
}

/* 2. Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
/* Components set their own display; "hidden" must still win. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--appbar-h) + 8px); }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
/* Links inside running text are underlined so they never rely on colour alone (WCAG 1.4.1). */
p a:not(.btn), .help a, .card-sub a, .alert__body a:not(.btn) { text-decoration: underline; text-underline-offset: 2px; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--blue-100); }
code { font-size: .9em; background: var(--gray-100); padding: 1px 6px; border-radius: 6px; }

.icon {
  width: 20px; height: 20px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.icon-sm { width: 16px; height: 16px; }
/* Icons inside running text sit on the text line. */
p > .icon, li > .icon, .help > .icon { display: inline-block; vertical-align: -3px; }
.icon-lg { width: 24px; height: 24px; }
.icon-xl { width: 32px; height: 32px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  background: var(--surface); padding: 8px 14px; border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.skip-link:focus { top: 12px; }

/* 3. Layout shells ----------------------------------------------------------- */

/* App shell: bottom nav on phones, sidebar on desktop */
.shell { min-height: 100vh; min-height: 100dvh; }
.shell-main { min-width: 0; padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + var(--space-6)); }
/* minmax(0, 1fr): grid tracks must be allowed to shrink below long unbroken content. */
.page {
  width: 100%; max-width: var(--content-max); margin: 0 auto; padding: var(--space-4);
  display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; row-gap: var(--space-5);
}

.appbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: var(--space-2);
  height: var(--appbar-h); padding: 0 var(--space-2) 0 var(--space-4);
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(12px); -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.appbar__back { margin-left: calc(var(--space-2) * -1); }
.appbar__title { flex: 1; min-width: 0; font-size: var(--text-lg); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar__actions { display: flex; align-items: center; gap: var(--space-1); }

.icon-btn {
  position: relative; display: inline-grid; place-items: center;
  width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: transparent; color: var(--gray-700); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--gray-100); text-decoration: none; }
.icon-btn--light { color: #fff; background: rgba(255, 255, 255, .14); }
.icon-btn--light:hover { background: rgba(255, 255, 255, .24); }
.dot-count {
  position: absolute; top: 6px; right: 5px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--radius-pill); background: var(--red-500); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
  box-shadow: 0 0 0 2px #fff;
}

/* Bottom navigation with raised centre action */
.bottom-nav {
  position: fixed; inset: auto 0 0 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  height: calc(var(--bottom-nav-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -6px 24px rgba(17, 23, 51, .06);
}
.bottom-nav a {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  height: var(--bottom-nav-h); color: var(--gray-500); font-size: 11px; font-weight: 600; text-decoration: none;
}
.bottom-nav a .icon { width: 22px; height: 22px; }
.bottom-nav a[aria-current="page"] { color: var(--primary); }
.bottom-nav a[aria-current="page"]::before {
  content: ""; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--primary);
}
.bottom-nav .fab {
  display: grid; place-items: center; width: 56px; height: 56px; margin-top: -22px;
  border-radius: 50%; background: var(--gradient-brand); color: #fff;
  box-shadow: 0 8px 20px rgba(47, 107, 255, .45), 0 0 0 5px #fff;
  transition: transform .2s var(--ease);
}
.bottom-nav .fab .icon { width: 26px; height: 26px; stroke-width: 2.5; }
.bottom-nav a:active .fab { transform: scale(.94); }
.bottom-nav .badge-dot {
  position: absolute; top: 10px; left: calc(50% + 6px); width: 9px; height: 9px; border-radius: 50%;
  background: var(--red-500); box-shadow: 0 0 0 2px #fff;
}

/* Desktop sidebar */
.sidebar { display: none; }

@media (min-width: 1024px) {
  .shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; }
  .shell-main { padding-bottom: var(--space-8); }
  .bottom-nav { display: none; }
  .page { padding: var(--space-6) var(--space-8); }
  .appbar { padding: 0 var(--space-6) 0 var(--space-8); }
  .appbar__back { display: none; }

  .sidebar {
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column; gap: var(--space-2);
    padding: var(--space-5) var(--space-4);
    background: var(--gradient-night); color: #c9d3f5; overflow-y: auto;
  }
  .sidebar__brand { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-1) var(--space-2) var(--space-5); color: #fff; text-decoration: none; }
  .sidebar__brand:hover { text-decoration: none; }
  .sidebar__cta { margin: 0 0 var(--space-3); }
  .sidebar__section { margin: var(--space-4) var(--space-3) var(--space-1); font-size: var(--text-xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #7f8bbd; }
  .sidebar__link {
    display: flex; align-items: center; gap: var(--space-3);
    min-height: 44px; padding: 0 var(--space-3); border-radius: var(--radius-sm);
    color: #c9d3f5; font-weight: 600; font-size: var(--text-sm); text-decoration: none;
  }
  .sidebar__link:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
  .sidebar__link[aria-current="page"] { background: rgba(47, 107, 255, .22); color: #fff; box-shadow: inset 3px 0 0 var(--sky-400); }
  .sidebar__link .count { margin-left: auto; min-width: 22px; padding: 0 7px; border-radius: var(--radius-pill); background: var(--red-500); color: #fff; font-size: 11px; line-height: 20px; text-align: center; }
  .sidebar__footer { margin-top: auto; padding-top: var(--space-4); border-top: 1px solid rgba(255, 255, 255, .08); }
  .sidebar__user { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2); color: #fff; }
  .sidebar__user small { display: block; color: #8f9ac7; font-size: var(--text-xs); }
}

/* Hero header (home dashboard) */
.hero {
  position: relative; overflow: hidden;
  margin: calc(var(--space-4) * -1) calc(var(--space-4) * -1) 0;
  padding: calc(var(--space-6) + env(safe-area-inset-top, 0px)) var(--space-4) 72px;
  background: var(--gradient-header); color: #fff;
}
.hero::after {
  content: ""; position: absolute; right: -60px; bottom: -90px; width: 260px; height: 260px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .16), transparent 70%); pointer-events: none;
}
.hero__skyline {
  position: absolute; right: 0; bottom: 0; width: min(78%, 560px); height: auto; pointer-events: none;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 35%); mask-image: linear-gradient(to right, transparent, #000 35%);
}
.hero__top { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.hero__greeting { font-size: var(--text-sm); opacity: .85; }
.hero__name { font-size: var(--text-3xl); font-weight: 800; letter-spacing: -.02em; }
.hero__sub { margin-top: var(--space-1); font-size: var(--text-sm); opacity: .85; }
.hero__actions { display: flex; align-items: center; gap: var(--space-2); }
.hero + * { position: relative; margin-top: -52px !important; }
/* Home: the tiles sit below the bar (in accordions), not overlapping it. */
.hero--flat { padding-bottom: var(--space-6); }
.hero--flat + * { margin-top: 0 !important; }

@media (min-width: 1024px) {
  .hero { margin: 0; border-radius: var(--radius-lg); padding: var(--space-8) var(--space-8) 80px; }
  .hero--flat { padding-bottom: var(--space-8); }
}

/* Auth shell (login, password change, errors) */
.auth {
  position: relative; min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; justify-content: center;
  padding: calc(var(--space-8) + env(safe-area-inset-top, 0px)) var(--space-4) calc(var(--space-6) + var(--safe-bottom));
  color: #fff; background: var(--gradient-night); overflow: hidden;
}
.auth__scenery { position: absolute; inset: auto 0 0 0; height: 46%; pointer-events: none; opacity: .9; }
.auth__scenery svg { width: 100%; height: 100%; }
.auth__panel { position: relative; z-index: 1; width: 100%; max-width: 420px; margin: 0 auto; }
.auth__brand { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: var(--space-8); }
.auth__logo { width: 72px; height: 72px; filter: drop-shadow(0 10px 22px rgba(47, 107, 255, .45)); }
.wordmark { margin-top: var(--space-3); font-size: 1.75rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.wordmark span { background: linear-gradient(90deg, var(--sky-400), #8fb1ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.wordmark-tag { margin-top: 6px; font-size: 10px; font-weight: 600; letter-spacing: .38em; text-transform: uppercase; color: #9fb0e8; }
.auth__title { font-size: var(--text-2xl); font-weight: 800; }
.auth__lead { margin-top: var(--space-1); color: #b6c2ee; font-size: var(--text-sm); }
.auth__footer { position: relative; z-index: 1; margin-top: var(--space-8); text-align: center; font-size: var(--text-xs); color: #8f9ac7; }

@media (min-width: 640px) {
  .auth__card {
    padding: var(--space-8); border-radius: 24px;
    background: rgba(11, 20, 55, .55); border: 1px solid rgba(255, 255, 255, .08);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: var(--shadow-lg);
  }
}

/* Dark ("glass") inputs on auth screens */
.auth .label { color: #dbe3ff; }
.auth .input {
  background: rgba(255, 255, 255, .07); border-color: rgba(255, 255, 255, .14); color: #fff;
}
.auth .input::placeholder { color: #8f9ac7; }
.auth .input:hover { border-color: rgba(255, 255, 255, .28); }
.auth .input:focus { border-color: var(--sky-400); background: rgba(255, 255, 255, .1); box-shadow: 0 0 0 4px rgba(34, 184, 255, .2); }
.auth .input-wrap > .icon { color: #8f9ac7; }
.auth .input-wrap .icon-btn { color: #b6c2ee; }
.auth .input-wrap .icon-btn:hover { background: rgba(255, 255, 255, .08); }
.auth .help { color: #9fb0e8; }
.auth .field-error { color: #ffb4b6; }
.auth .is-invalid { border-color: #ff8a8f !important; }
.auth .check { color: #c9d3f5; }
.auth .select { background-color: rgba(255, 255, 255, .07); border-color: rgba(255, 255, 255, .14); color: #fff; }
.auth .select option { color: var(--gray-900); }

/* First-run installer (dark auth shell) */
.install-section { display: grid; gap: var(--space-3); padding-top: var(--space-4); border-top: 1px solid rgba(255, 255, 255, .1); }
.install-section__title { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-lg); font-weight: 800; color: #fff; }
.install-section__title span { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: rgba(143, 177, 255, .18); color: #cfdcff; font-size: var(--text-sm); }
.install-checks { display: grid; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.install-check { display: flex; align-items: flex-start; gap: var(--space-2); font-size: var(--text-sm); }
.install-check.is-ok { color: #8ff0c4; }
.install-check.is-bad { color: #ffb4b6; }
.auth .link-light { color: #8fb1ff; font-weight: 600; font-size: var(--text-sm); background: none; border: 0; padding: 0; cursor: pointer; }

/* 4. Components ------------------------------------------------------------ */

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 48px; padding: 0 var(--space-5);
  border: 1px solid transparent; border-radius: var(--radius);
  font-weight: 700; font-size: var(--text-base); line-height: 1; text-decoration: none; white-space: nowrap;
  cursor: pointer; user-select: none;
  transition: background-color .15s, border-color .15s, box-shadow .15s, transform .1s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(47, 107, 255, .28); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-gradient { background: var(--gradient-brand); color: #fff; box-shadow: 0 8px 22px rgba(47, 107, 255, .35); }
.btn-gradient:hover { filter: brightness(1.05); }
.btn-violet { background: var(--violet-500); color: #fff; box-shadow: 0 6px 16px rgba(122, 60, 240, .28); }
.btn-violet:hover { background: var(--violet-600); }
.btn-success { background: var(--mint-700); color: #fff; box-shadow: 0 6px 16px rgba(8, 122, 80, .28); }
.btn-success:hover { background: #066440; }
.btn-danger { background: var(--red-700); color: #fff; box-shadow: 0 6px 16px rgba(180, 35, 24, .25); }
.btn-danger:hover { background: #912018; }
.btn-secondary { background: var(--surface); color: var(--gray-900); border-color: var(--gray-300); }
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-400); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--blue-50); }
.btn-danger-ghost { background: transparent; color: var(--red-700); }
.btn-danger-ghost:hover { background: var(--red-100); }
.btn-sm { min-height: 36px; padding: 0 var(--space-3); font-size: var(--text-sm); border-radius: var(--radius-sm); }
.btn-block { width: 100%; }
.btn[aria-busy="true"] { position: relative; color: transparent !important; pointer-events: none; }
.btn[aria-busy="true"]::after {
  content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, .5); border-top-color: #fff; animation: spin .7s linear infinite;
}
.btn-secondary[aria-busy="true"]::after, .btn-ghost[aria-busy="true"]::after { border-color: var(--gray-300); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }

.btn-row { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.btn-row > .btn { flex: 1 1 auto; }

/* Sticky primary actions above the bottom nav (mobile) */
.sticky-actions {
  position: sticky; bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + var(--space-3)); z-index: 20;
  display: flex; gap: var(--space-3); padding: var(--space-3);
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
.sticky-actions > .btn { flex: 1; min-width: 0; }
@media (max-width: 400px) {
  .sticky-actions { gap: var(--space-2); padding: var(--space-2); }
  .sticky-actions > .btn { padding: 0 var(--space-3); }
  .sticky-actions > .btn > .icon { display: none; }
}
@media (min-width: 1024px) {
  .sticky-actions { bottom: var(--space-4); }
}

/* Forms */
.form { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
.field { display: grid; gap: 6px; }
.label { font-size: var(--text-sm); font-weight: 700; color: var(--gray-700); }
.label .req { color: var(--red-500); }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 0 var(--space-4);
  border: 1.5px solid var(--gray-200); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font-size: var(--text-base);
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.textarea { min-height: 112px; padding: var(--space-3) var(--space-4); resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 44px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235b6480' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; background-size: 18px; }
.input::placeholder, .textarea::placeholder { color: var(--gray-400); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--gray-300); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(47, 107, 255, .15); }
.is-invalid { border-color: var(--red-500) !important; }
.is-invalid:focus { box-shadow: 0 0 0 4px rgba(229, 72, 77, .15) !important; }
.help { font-size: var(--text-xs); color: var(--text-muted); }
.field-error { display: flex; align-items: center; gap: 6px; font-size: var(--text-sm); font-weight: 600; color: var(--red-700); }

.input-wrap { position: relative; }
.input-wrap > .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--gray-400); pointer-events: none; }
.input-wrap > .icon ~ .input { padding-left: 46px; }
.input-wrap > .input.has-trailing { padding-right: 52px; }
.input-wrap > .icon-btn { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); }

.check { display: inline-flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); cursor: pointer; min-height: 44px; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }

/* Selectable option cards (roles, permissions) */
.option-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-2); }
.option {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); border: 1.5px solid var(--gray-200); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; transition: border-color .15s, background-color .15s;
}
.option:hover { border-color: var(--gray-300); }
.option input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--primary); }
.option:has(input:checked) { border-color: var(--primary); background: var(--blue-50); }
.option:has(input:disabled) { cursor: default; opacity: .75; }
.option__title { display: block; font-weight: 700; }
.option__desc { display: block; font-size: var(--text-sm); color: var(--text-muted); }
@media (min-width: 720px) {
  .option-list--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.card-body { padding: var(--space-4); }
.card-body + .card-body { border-top: 1px solid var(--border); }
@media (min-width: 640px) { .card-body { padding: var(--space-5) var(--space-6); } }
.card-title { font-size: var(--text-lg); font-weight: 800; }
fieldset.card { margin: 0; padding: 0; min-width: 0; }
fieldset.card legend { float: left; width: 100%; padding: 0; }
fieldset.card legend + * { clear: both; }
.req { color: var(--red-500); }
.card-sub { margin-top: 2px; font-size: var(--text-sm); color: var(--text-muted); }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.section-title { font-size: var(--text-lg); font-weight: 800; }
.section-link { font-size: var(--text-sm); font-weight: 700; }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-3); }
@media (min-width: 900px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat {
  display: flex; flex-direction: column; gap: var(--space-2);
  padding: var(--space-4); border-radius: var(--radius-lg);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  color: inherit; text-decoration: none; transition: transform .15s var(--ease), box-shadow .15s;
}
a.stat:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat__icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; }
.stat__value { font-size: var(--text-3xl); font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.stat__label { font-size: var(--text-sm); font-weight: 600; color: var(--text-muted); }

.tone-amber { background: var(--amber-100); color: var(--amber-700); }
.tone-blue { background: var(--blue-100); color: var(--blue-700); }
.tone-mint { background: var(--mint-100); color: var(--mint-700); }
.tone-red { background: var(--red-100); color: var(--red-700); }
.tone-violet { background: var(--violet-100); color: var(--violet-600); }
.tone-gray { background: var(--gray-100); color: var(--gray-700); }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 26px; padding: 0 10px; border-radius: var(--radius-pill);
  font-size: var(--text-xs); font-weight: 700; white-space: nowrap;
}
.badge .icon { width: 14px; height: 14px; stroke-width: 2.5; }
.badge-pending { background: var(--amber-100); color: var(--amber-700); }
.badge-progress { background: var(--blue-100); color: var(--blue-700); }
.badge-success { background: var(--mint-100); color: var(--mint-700); }
.badge-danger { background: var(--red-100); color: var(--red-700); }
.badge-neutral { background: var(--gray-100); color: var(--gray-700); }
.badge-violet { background: var(--violet-100); color: var(--violet-600); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); min-height: 64px;
  color: inherit; text-decoration: none;
}
.list > li + li > .list-item, .list > .list-item + .list-item { border-top: 1px solid var(--border); }
a.list-item:hover, button.list-item:hover { background: var(--gray-50); text-decoration: none; }
button.list-item { width: 100%; border: 0; background: none; text-align: left; cursor: pointer; }
.list-item__icon { display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 12px; }
.list-item__body { flex: 1; min-width: 0; }
.list-item__title { display: block; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item__meta { display: block; font-size: var(--text-sm); color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item__meta--wrap { white-space: normal; }
.list-item--compact { min-height: 52px; }
.list-item__aside { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: var(--text-xs); color: var(--text-muted); }
.list-item__chevron { color: var(--gray-300); }
.list-item.is-unread { background: var(--blue-50); }
.list-item.is-unread .list-item__title::after { content: ""; display: inline-block; width: 8px; height: 8px; margin-left: 8px; border-radius: 50%; background: var(--primary); vertical-align: middle; }

/* Avatar */
.avatar {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border-radius: 50%; background: var(--gradient-brand); color: #fff;
  font-size: var(--text-sm); font-weight: 800; letter-spacing: .02em;
}
.avatar-sm { width: 36px; height: 36px; font-size: var(--text-xs); }
.avatar-lg { width: 64px; height: 64px; font-size: var(--text-xl); }
.avatar--ring { box-shadow: 0 0 0 3px rgba(255, 255, 255, .35); }
.avatar--muted { background: var(--gray-300); }

/* Empty state */
.empty { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); padding: var(--space-8) var(--space-4); text-align: center; }
.empty__icon { display: grid; place-items: center; width: 64px; height: 64px; margin-bottom: var(--space-2); border-radius: 50%; background: var(--blue-50); color: var(--primary); }
.empty__title { font-size: var(--text-lg); font-weight: 800; }
.empty__text { max-width: 34ch; color: var(--text-muted); font-size: var(--text-sm); }
.empty .btn { margin-top: var(--space-3); }

/* Alerts / flash */
.alert {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius); border: 1px solid;
  font-size: var(--text-sm); animation: slide-in .25s var(--ease);
}
.alert .icon { margin-top: 1px; }
.alert__body { flex: 1; }
.alert__title { font-weight: 800; }
.alert-success { background: var(--mint-100); border-color: #b4ecd5; color: #075e3e; }
.alert-error { background: var(--red-100); border-color: #f9c5c7; color: #8c1d14; }
.alert-info { background: var(--blue-50); border-color: var(--blue-100); color: var(--blue-700); }
.alert-warning { background: var(--amber-100); border-color: #fbdca0; color: #7a4800; }
.alert-dark { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .14); color: #e6ebff; }
.alert__close { margin: -8px -10px -8px 0; width: 36px; height: 36px; color: inherit; }
@keyframes slide-in { from { opacity: 0; transform: translateY(-6px); } }

/* Secret reveal (temporary passwords) */
.secret {
  display: flex; align-items: center; gap: var(--space-2);
  margin-top: var(--space-2); padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  border-radius: var(--radius-sm); background: #fff; border: 1px dashed #8adfbd;
}
.secret code { flex: 1; background: none; padding: 0; font-size: var(--text-lg); font-weight: 800; letter-spacing: .06em; color: var(--gray-900); }

/* Filter chips / segmented */
.filters { display: flex; gap: var(--space-2); overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.filters::-webkit-scrollbar { display: none; }
.filter {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; flex: none;
  border-radius: var(--radius-pill); border: 1px solid var(--gray-200); background: var(--surface);
  font-size: var(--text-sm); font-weight: 700; color: var(--gray-700); text-decoration: none;
}
.filter:hover { text-decoration: none; border-color: var(--gray-300); }
.filter[aria-current="true"] { background: var(--navy-900); border-color: var(--navy-900); color: #fff; }
.filter .count { font-size: var(--text-xs); opacity: .7; }

.toolbar { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: center; }
.toolbar .input-wrap { flex: 1 1 220px; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline__item { position: relative; display: flex; gap: var(--space-3); padding-bottom: var(--space-4); }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__item:not(:last-child)::before { content: ""; position: absolute; left: 13px; top: 30px; bottom: 2px; width: 2px; background: var(--gray-200); }
.timeline__item.is-done:not(:last-child)::before { background: var(--mint-500); }
.timeline__dot { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 50%; border: 2px solid var(--gray-300); background: var(--surface); color: var(--gray-400); }
.timeline__dot .icon { width: 14px; height: 14px; stroke-width: 3; }
.is-done .timeline__dot { border-color: var(--mint-500); background: var(--mint-500); color: #fff; }
.is-current .timeline__dot { border-color: var(--amber-500); background: var(--amber-100); color: var(--amber-700); box-shadow: 0 0 0 4px rgba(245, 165, 36, .18); }
.is-rejected .timeline__dot { border-color: var(--red-500); background: var(--red-500); color: #fff; }
.timeline__title { font-weight: 700; }
.timeline__meta { font-size: var(--text-sm); color: var(--text-muted); }
.is-current .timeline__body { flex: 1; padding: var(--space-2) var(--space-3); margin: -8px 0 0 -4px; border-radius: var(--radius-sm); background: var(--amber-100); }

/* Key/value details */
.details { display: grid; gap: var(--space-3); margin: 0; }
.details div { display: grid; gap: 2px; }
.details dt { font-size: var(--text-xs); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); }
.details dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
@media (min-width: 640px) { .details--2 { grid-template-columns: 1fr 1fr; } }

/* Dialog / bottom sheet */
.sheet {
  width: 100%; max-width: 480px; margin: auto auto 0; padding: 0; border: 0;
  border-radius: 24px 24px 0 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.sheet::backdrop { background: rgba(7, 13, 36, .55); backdrop-filter: blur(2px); }
.sheet[open] { animation: sheet-up .25s var(--ease); }
.sheet__body { padding: var(--space-6) var(--space-5) calc(var(--space-5) + var(--safe-bottom)); display: grid; gap: var(--space-4); }
.sheet__grip { width: 40px; height: 4px; margin: 10px auto 0; border-radius: 4px; background: var(--gray-200); }
.sheet__title { font-size: var(--text-xl); font-weight: 800; }
.sheet__text { color: var(--text-muted); }
@media (min-width: 640px) {
  .sheet { margin: auto; border-radius: 24px; }
  .sheet__grip { display: none; }
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } }

/* Pagination */
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); font-size: var(--text-sm); color: var(--text-muted); }

/* Page heading (non-hero pages) */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-3); }
.page-title { font-size: var(--text-2xl); font-weight: 800; letter-spacing: -.02em; }
.page-sub { margin-top: 2px; color: var(--text-muted); font-size: var(--text-sm); }

/* Profile card on "More" */
.profile { display: flex; align-items: center; gap: var(--space-4); }
.profile__name { font-size: var(--text-lg); font-weight: 800; }
.profile__email { font-size: var(--text-sm); color: var(--text-muted); overflow-wrap: anywhere; }

/* Swatches (UI kit) */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: var(--space-2); }
.swatch { border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border); font-size: var(--text-xs); }
.swatch span { display: block; height: 48px; }
.swatch p { padding: 6px 8px; }

/* Number input with a currency suffix ("RM") */
.input-wrap > .input.has-suffix { padding-right: 56px; }
.input-suffix {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  font-size: var(--text-sm); font-weight: 700; color: var(--gray-500); pointer-events: none;
}
.value-lg { font-size: var(--text-2xl); font-weight: 800; letter-spacing: -.01em; }

/* File upload */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  padding: var(--space-5) var(--space-4); border: 2px dashed var(--gray-300); border-radius: var(--radius);
  background: var(--gray-50); color: var(--primary); cursor: pointer; transition: border-color .15s, background-color .15s;
}
.dropzone:hover { border-color: var(--primary); background: var(--blue-50); }
.dropzone:has(+ input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.dropzone.is-invalid { border-color: var(--red-500); }
.dropzone__title { font-weight: 700; }
.dropzone__hint { font-size: var(--text-xs); color: var(--text-muted); }
.dropzone__chosen { font-size: var(--text-sm); font-weight: 600; color: var(--gray-900); overflow-wrap: anywhere; }
.dropzone__chosen:empty { display: none; }

.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-2); }
.file-item {
  display: flex; align-items: center; gap: var(--space-3); min-height: 48px;
  padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
}
.file-item__icon { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 8px; background: var(--blue-50); color: var(--primary); }
.file-item__name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item__size { font-size: var(--text-xs); color: var(--text-muted); white-space: nowrap; }
.file-item__remove { min-height: 36px; font-size: var(--text-xs); color: var(--red-700); }

/* Form catalogue / type picker cards */
.form-cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-3); }
@media (min-width: 720px) { .form-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.form-card {
  display: flex; align-items: center; gap: var(--space-4); padding: var(--space-4);
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-sm);
  color: inherit; text-decoration: none; transition: transform .15s var(--ease), box-shadow .15s, border-color .15s;
}
.form-card:hover { text-decoration: none; border-color: var(--blue-100); box-shadow: var(--shadow); transform: translateY(-1px); }
.form-card__icon { display: grid; place-items: center; width: 52px; height: 52px; flex: none; border-radius: 16px; background: var(--violet-100); color: var(--violet-600); }
.form-card__body { flex: 1; min-width: 0; }
.form-card__title { display: block; font-weight: 800; }
.form-card__desc { display: block; font-size: var(--text-sm); color: var(--text-muted); }

/* Builder */
.action-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--space-2); }
@media (max-width: 400px) { .action-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.action-tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: var(--space-3) var(--space-1);
  border: 0; border-radius: var(--radius); background: var(--gray-50); color: var(--gray-700);
  font-size: var(--text-xs); font-weight: 700; text-decoration: none; cursor: pointer;
}
.action-tile:hover { background: var(--blue-50); color: var(--primary); text-decoration: none; }
.builder-field { display: flex; align-items: center; }
.builder-field + .builder-field { border-top: 1px solid var(--border); }
.builder-field > .list-item { flex: 1; min-width: 0; }
.builder-field__moves { display: flex; flex-direction: column; padding-right: var(--space-2); }
.builder-field__moves .icon-btn { width: 36px; height: 30px; border-radius: 8px; }
.builder-field__moves .icon-btn[disabled] { opacity: .25; cursor: default; }
:target { scroll-margin-top: calc(var(--appbar-h) + 16px); }
.builder-field:target, .field:target { animation: highlight 1.6s var(--ease); }
@keyframes highlight { from { background: var(--amber-100); } }

/* Accordion: a card-like bar that reveals content below it (home "My requests"). */
.accordion > summary {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-4); border-radius: var(--radius-lg); list-style: none; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.accordion > summary::-webkit-details-marker { display: none; }
.accordion[open] > summary { margin-bottom: var(--space-3); }
.accordion__text { display: grid; gap: 2px; min-width: 0; }
.accordion__digest { display: flex; flex-wrap: wrap; column-gap: 4px; font-size: var(--text-sm); color: var(--text-muted); }
.accordion__digest > span { white-space: nowrap; }
.accordion__digest strong { color: var(--text); font-variant-numeric: tabular-nums; }
.accordion__chevron { display: inline-flex; color: var(--gray-500); transition: transform .2s var(--ease); }
.accordion[open] .accordion__chevron { transform: rotate(90deg); }

details.card > summary { list-style: none; cursor: pointer; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::after { content: "▾"; color: var(--gray-400); transition: transform .2s; }
details.card[open] > summary::after { transform: rotate(180deg); }

/* Segmented control */
.segmented { display: inline-flex; padding: 3px; border-radius: var(--radius-pill); background: var(--gray-100); width: fit-content; }
.segmented a { padding: 6px 16px; border-radius: var(--radius-pill); font-size: var(--text-sm); font-weight: 700; color: var(--gray-500); text-decoration: none; }
.segmented a[aria-current="true"] { background: var(--surface); color: var(--gray-900); box-shadow: var(--shadow-sm); }

/* Icon picker and chip checkboxes */
.icon-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: var(--space-2); }
.icon-picker__option { position: relative; cursor: pointer; }
.icon-picker__option input { position: absolute; opacity: 0; }
.icon-picker__option span {
  display: grid; place-items: center; height: 56px; border-radius: var(--radius);
  border: 1.5px solid var(--gray-200); color: var(--gray-500); background: var(--surface);
}
.icon-picker__option input:checked + span { border-color: var(--violet-500); background: var(--violet-100); color: var(--violet-600); }
.icon-picker__option input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.chip-check { position: relative; cursor: pointer; }
.chip-check input { position: absolute; opacity: 0; }
.chip-check span { display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: var(--radius-pill); border: 1.5px solid var(--gray-200); font-size: var(--text-sm); font-weight: 700; color: var(--gray-500); }
.chip-check input:checked + span { border-color: var(--primary); background: var(--blue-50); color: var(--blue-700); }
.chip-check input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Phone preview frame */
.phone-frame {
  width: 100%; max-width: 410px; margin: 0 auto; padding: 14px;
  border-radius: 44px; background: var(--navy-900); box-shadow: var(--shadow-lg);
}
.phone-frame__screen { max-height: 760px; overflow-y: auto; padding: var(--space-4); border-radius: 32px; background: var(--bg); }
@media (max-width: 480px) {
  .phone-frame { padding: 0; background: none; box-shadow: none; }
  .phone-frame__screen { max-height: none; padding: 0; border-radius: 0; }
}

/* Request progress timeline (workflow) */
.timeline__item.is-returned .timeline__dot { border-color: var(--amber-500); background: var(--amber-500); color: #fff; }
.timeline__item.is-skipped .timeline__dot { border-style: dashed; color: var(--gray-400); }
.timeline__item.is-skipped .timeline__title, .timeline__item.is-waiting .timeline__title { color: var(--gray-500); }
.timeline__item.is-current .timeline__body { padding: var(--space-2) var(--space-3); }
.timeline__item--route { padding-bottom: var(--space-3); }
.timeline__item--route .timeline__dot { width: 28px; height: 28px; border-style: dashed; }
.timeline__people { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 4px; font-size: var(--text-sm); }
.timeline__comment { margin-top: 2px; font-size: var(--text-sm); font-style: italic; color: var(--gray-700); overflow-wrap: anywhere; }
.timeline-branches { display: grid; gap: var(--space-3); margin-top: var(--space-3); }
@media (min-width: 720px) { .timeline-branches { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); } }
.timeline-branch { padding: var(--space-3); border: 1px dashed var(--gray-300); border-radius: var(--radius); background: var(--surface); }
.timeline-branch__name { margin-bottom: var(--space-2); font-size: var(--text-xs); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.timeline--compact .timeline__item { padding-bottom: var(--space-3); }
.timeline-end { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-4); padding: var(--space-3); border-radius: var(--radius-sm); background: var(--mint-100); color: var(--mint-700); font-weight: 700; font-size: var(--text-sm); }
.task-callout { display: flex; align-items: flex-start; gap: var(--space-3); border-color: var(--amber-100); background: linear-gradient(0deg, var(--surface), #fffaf0); }
.readonly-value { min-height: 48px; padding: var(--space-3) var(--space-4); border-radius: var(--radius); background: var(--gray-100); color: var(--gray-700); }
.text-danger { color: var(--red-700) !important; }
.filter .count { margin-left: 2px; padding: 0 6px; border-radius: var(--radius-pill); background: var(--red-500); color: #fff; opacity: 1; }

/* Workflow builder tree */
.wf { display: grid; grid-template-columns: minmax(0, 1fr); justify-items: stretch; }
.wf-node {
  display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.wf-node strong, .wf-node .wf-card__meta { display: block; }
.wf-node--end { border-color: #b4ecd5; background: var(--mint-100); }
.wf-seq { position: relative; display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; }
.wf-seq::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; background: var(--gray-200); z-index: 0; }
.wf-seq > * { position: relative; z-index: 1; }
.wf-step { width: 100%; display: grid; gap: var(--space-2); }
.wf-add {
  display: grid; place-items: center; width: 32px; height: 32px; margin: 6px 0; border-radius: 50%;
  border: 2px dashed var(--gray-300); background: var(--bg); color: var(--gray-500); text-decoration: none;
}
.wf-add:hover { border-style: solid; border-color: var(--primary); color: var(--primary); background: var(--blue-50); text-decoration: none; }
.wf-card { display: flex; align-items: stretch; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); overflow: hidden; }
.wf-step--approval > .wf-card { border-left: 4px solid var(--violet-500); }
.wf-step--execution > .wf-card { border-left: 4px solid var(--mint-500); }
.wf-step--condition > .wf-card { border-left: 4px solid var(--amber-500); }
.wf-step--parallel > .wf-card { border-left: 4px solid var(--blue-500); }
.wf-card__main { flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4); color: inherit; text-decoration: none; }
.wf-card__main:hover { background: var(--gray-50); text-decoration: none; }
.wf-card__type { display: block; font-size: var(--text-xs); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.wf-card__name { display: block; font-weight: 800; }
.wf-card__meta { display: block; font-size: var(--text-sm); color: var(--text-muted); overflow-wrap: anywhere; }
.wf-card__moves { display: flex; flex-direction: column; justify-content: center; padding: 0 var(--space-2); border-left: 1px solid var(--border); }
.wf-card__moves .icon-btn { width: 36px; height: 32px; border-radius: 8px; }
.wf-card__moves .icon-btn[disabled] { opacity: .25; cursor: default; }
.wf-branches { display: grid; gap: var(--space-3); padding-left: var(--space-3); border-left: 2px solid var(--gray-200); margin-left: var(--space-4); }
@media (min-width: 900px) {
  .wf-step--parallel > .wf-branches { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
}
.wf-branch { padding: var(--space-3); border-radius: var(--radius-lg); background: var(--gray-50); border: 1px dashed var(--gray-300); }
.wf-branch--default { background: transparent; }
.wf-branch__head { display: flex; align-items: center; gap: var(--space-2); color: inherit; text-decoration: none; }
a.wf-branch__head:hover { text-decoration: none; color: var(--primary); }
.wf-branch__head strong { display: block; }
.wf-branch__label { padding: 2px 8px; border-radius: var(--radius-pill); background: var(--amber-100); color: var(--amber-700); font-size: var(--text-xs); font-weight: 800; text-transform: uppercase; }
.wf-step--parallel .wf-branch__label { background: var(--blue-100); color: var(--blue-700); }
.wf-branch .wf-seq::before { background: var(--gray-300); }
.wf-branch .wf-add { background: var(--gray-50); }
.wf-empty { padding: 4px 10px; border-radius: var(--radius-sm); background: var(--gray-50); font-size: var(--text-xs); color: var(--text-muted); }
.wf-branch-add { justify-self: start; }
.problem-list { margin: 4px 0 0; padding-left: 18px; }

/* Condition rule rows */
.rule-row { display: grid; gap: var(--space-2); }
.rule-row__label { font-size: var(--text-xs); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); }
.rule-row__inputs { display: grid; gap: var(--space-2); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 720px) { .rule-row__inputs { grid-template-columns: 2fr 1.5fr 2fr; } }
.is-invalid-row .select, .is-invalid-row .input { border-color: var(--red-500); }
.help-box { font-size: var(--text-sm); color: var(--text-muted); }
.help-box summary { cursor: pointer; font-weight: 700; color: var(--primary); }
.help-box ul { margin: var(--space-2) 0 0; padding-left: 18px; display: grid; gap: 4px; }

/* Install-the-app card (revealed by app.js when installable) */
.install-card {
  display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow-sm);
}
.install-card__icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px; background: var(--blue-50); color: var(--primary); }
.install-card--dark { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .12); color: #dbe3ff; box-shadow: none; }
.install-card--dark .install-card__icon { background: rgba(255, 255, 255, .1); color: #8fb1ff; }

/* Reports */
.report-filters { display: grid; gap: var(--space-3); grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: end; }
.report-filters .field:nth-child(3) { grid-column: 1 / -1; }
.report-filters__actions { grid-column: 1 / -1; }
@media (min-width: 900px) {
  .report-filters { grid-template-columns: 1fr 1fr 2fr auto; }
  .report-filters .field:nth-child(3), .report-filters__actions { grid-column: auto; }
}
.bar-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.bar-list__row { display: grid; grid-template-columns: 140px minmax(0, 1fr) 40px; align-items: center; gap: var(--space-3); }
.bar-list__track { display: block; height: 8px; border-radius: 4px; background: var(--gray-100); overflow: hidden; }
.bar-list__fill { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--blue-500); }
.bar-list__value { font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.inline-bar { display: grid; grid-template-columns: minmax(60px, 1fr) auto; align-items: center; gap: var(--space-2); min-width: 140px; }
.hero-numbers { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.hero-number { font-size: var(--text-3xl); font-weight: 800; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th, .table td { padding: var(--space-2) var(--space-4); border-top: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table thead th { border-top: 0; font-size: var(--text-xs); font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--text-muted); white-space: nowrap; }
.table tbody th { font-weight: 700; white-space: nowrap; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.audit-filters { display: grid; gap: var(--space-3); grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: end; }
.audit-filters__actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: var(--space-2); }
@media (min-width: 900px) { .audit-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.audit-entry { padding: var(--space-3) var(--space-4); }
.audit-entry + .audit-entry { border-top: 1px solid var(--border); }
.code-block { margin: 0; padding: var(--space-3); border-radius: var(--radius-sm); background: var(--gray-50); font-size: var(--text-xs); white-space: pre-wrap; overflow-wrap: anywhere; }

/* 5. Utilities --------------------------------------------------------------- */
.row-start { align-items: flex-start; }
.pre-line { white-space: pre-line; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
.stack-sm { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-2); }
.row { display: flex; align-items: center; gap: var(--space-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-muted); }
.small { font-size: var(--text-sm); }
.xsmall { font-size: var(--text-xs); }
.bold { font-weight: 700; }
.center { text-align: center; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.divider { height: 1px; background: var(--border); border: 0; margin: 0; }
.grid-2 { display: grid; gap: var(--space-4); }
@media (min-width: 900px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
.toolbar__select { flex: 0 1 220px; }
.select--multi { height: auto; padding: var(--space-2); background-image: none; }
.admin-task { padding: var(--space-3) 0; border-top: 1px dashed var(--border); }
.table-wrap:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
