/* Betki Portal stylesheet — GENERATED by scripts/portal/build-css.js. Edit css/*.css, then rebuild. */

/* ==== tokens.css ==== */
/* ============================================================
   Design Tokens - Betki Portal
   Brand navy for the shell and documents, blue for actions,
   brand red reserved for the logo.
   ============================================================ */
:root {
  /* --- Brand --- */
  --brand-navy:     #1B2A5B;
  --brand-navy-900: #0f1838;
  --brand-navy-800: #15214a;
  --brand-navy-700: #1B2A5B;
  --brand-navy-600: #2a3b72;
  --brand-navy-100: #e6e9f2;
  --brand-navy-50:  #f3f5fa;
  --brand-red:      #C8232C; /* logo only */

  /* --- Action blue --- */
  --color-primary-50:  #f0f6fe;
  --color-primary-100: #e1edfc;
  --color-primary-200: #c3dbf9;
  --color-primary-500: #0077ed;
  --color-primary-600: #0071e3;
  --color-primary-700: #005bb5;
  --color-primary-800: #004a94;

  --color-success-50:  #ecf8f0;
  --color-success-500: #23a455;
  --color-success-700: #17723a;

  --color-danger-50:  #fdeeed;
  --color-danger-500: #e5372b;
  --color-danger-700: #b42318;

  --color-warning-50:  #fff5e6;
  --color-warning-500: #f59e0b;
  --color-warning-700: #a15c07;

  --color-neutral-0:   #ffffff;
  --color-neutral-50:  #f8f9fb;
  --color-neutral-100: #f2f4f7;
  --color-neutral-200: #e4e7ec;
  --color-neutral-300: #d0d5dd;
  --color-neutral-400: #98a2b3;
  --color-neutral-500: #667085;
  --color-neutral-600: #475467;
  --color-neutral-700: #344054;
  --color-neutral-800: #1d2939;
  --color-neutral-900: #101828;

  /* --- Status tones (one palette for every status badge) --- */
  --tone-neutral-bg: #f2f4f7; --tone-neutral-fg: #475467; --tone-neutral-dot: #98a2b3;
  --tone-info-bg:    #e1edfc; --tone-info-fg:    #004a94; --tone-info-dot:    #0071e3;
  --tone-success-bg: #e3f6ea; --tone-success-fg: #17723a; --tone-success-dot: #23a455;
  --tone-warning-bg: #fff1d6; --tone-warning-fg: #93500a; --tone-warning-dot: #f59e0b;
  --tone-danger-bg:  #fde8e7; --tone-danger-fg:  #b42318; --tone-danger-dot:  #e5372b;
  --tone-purple-bg:  #efeafd; --tone-purple-fg:  #5925b5; --tone-purple-dot:  #7a4ee0;
  --tone-navy-bg:    #e6e9f2; --tone-navy-fg:    #1B2A5B; --tone-navy-dot:    #1B2A5B;

  /* --- Semantic aliases (kept for existing pages) --- */
  --bg:      #f4f6f9;
  --panel:   #ffffff;
  --panel2:  var(--color-neutral-50);
  --card:    #ffffff;
  --text:    var(--color-neutral-900);
  --text-2:  var(--color-neutral-700);
  --muted:   var(--color-neutral-500);
  --border:  var(--color-neutral-200);
  --border2: var(--color-neutral-300);
  --primary: var(--color-primary-600);
  --primary2:var(--color-primary-700);
  --primary-soft: var(--color-primary-100);
  --danger:  var(--color-danger-500);
  --danger-soft: var(--color-danger-50);
  --success: var(--color-success-500);
  --success-soft: var(--color-success-50);
  --warning: var(--color-warning-500);
  --warning-soft: var(--color-warning-50);
  --focus-ring: 0 0 0 3px rgba(0, 113, 227, 0.18);

  /* --- Typography --- */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Consolas, monospace;
  --text-2xs:  0.6875rem;
  --text-xs:   0.75rem;
  --text-sm:   0.8125rem;
  --text-base: 0.875rem;
  --text-lg:   1rem;
  --text-xl:   1.125rem;
  --text-2xl:  1.375rem;
  --text-3xl:  1.75rem;
  --lh:        1.5;

  /* --- Spacing (4px grid) --- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-7: 1.75rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* --- Radius & shadow --- */
  --radius-xs:   0.375rem;
  --radius-sm:   0.5rem;
  --radius-md:   0.625rem;
  --radius-lg:   0.875rem;
  --radius-xl:   1.125rem;
  --radius-full: 9999px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 10px -2px rgba(16, 24, 40, 0.08), 0 2px 4px -2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 14px 28px -6px rgba(16, 24, 40, 0.14), 0 4px 8px -4px rgba(16, 24, 40, 0.05);
  --shadow-card: var(--shadow-xs);
  --shadow-card-hover: var(--shadow-md);

  /* --- Motion --- */
  --ease-fast: 140ms ease;
  --ease-base: 220ms ease;
  --ease-spring: 420ms cubic-bezier(0.22, 1, 0.36, 1);

  /* --- Charts: categorical order is fixed (validated with the dataviz palette checker:
         lightness, chroma, CVD ΔE ≥ 8 between neighbours). A series keeps its slot everywhere.
         Navy is the brand shell colour, not a series colour (too dark to read as a hue). --- */
  --chart-1: #2563eb;  /* blue   */
  --chart-2: #e07a00;  /* amber  */
  --chart-3: #14946b;  /* green  */
  --chart-4: #9061f9;  /* violet */
  --chart-5: #d1497b;  /* rose   */
  --chart-6: #0b8aa8;  /* teal   */
  /* status (never reused as series colours) */
  --chart-pos: #23a455;
  --chart-warn: #f59e0b;
  --chart-neg: #e5372b;
  --chart-muted: #c3c9d4;
  --chart-grid: #eceff3;
  --chart-axis: #98a2b3;

  /* --- Layout --- */
  --sidebar-w:   248px;
  --sidebar-cw:  68px;
  --header-h:    60px;
  --content-max: 1480px;
}

/* ==== layout.css ==== */
/* ============================================================
   Layout - navy sidebar, topbar, content area
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--lh);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}

a { color: inherit; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.015em; color: var(--text); }
img, svg { vertical-align: middle; }
:focus-visible { outline: 2px solid var(--color-primary-600); outline-offset: 2px; }
.ic { width: 18px; height: 18px; flex-shrink: 0; }
.ic--sm { width: 14px; height: 14px; }

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 300;
  background: var(--brand-navy); color: #fff; padding: 8px 14px; border-radius: var(--radius-sm);
  text-decoration: none; font-weight: 600;
}
.skip-link:focus { top: 12px; }

/* --- App shell --- */
.app-layout { display: flex; min-height: 100vh; }

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--brand-navy) 0%, var(--brand-navy-800) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--ease-base), width var(--ease-base);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5) var(--space-4);
  text-decoration: none;
  color: #fff;
}
.sidebar-logo {
  width: 40px; height: 40px;
  flex-shrink: 0;
  display: grid; place-items: center;
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}
.sidebar-logo img { width: 34px; height: 34px; object-fit: contain; }
.sidebar-logo b { color: var(--brand-navy); font-size: 18px; }
.sidebar-brand-text { min-width: 0; display: flex; flex-direction: column; }
.sidebar-brand-text strong {
  font-size: var(--text-sm);
  font-weight: 650;
  line-height: 1.25;
  text-transform: capitalize;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.sidebar-brand-text span { font-size: var(--text-2xs); color: rgba(255, 255, 255, 0.55); letter-spacing: 0.02em; margin-top: 2px; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2) var(--space-3) var(--space-4);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.sidebar-group + .sidebar-group { margin-top: var(--space-4); }
.sidebar-section {
  padding: 0 var(--space-3);
  margin: 0 0 var(--space-1);
  font-size: 10.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.42);
}
.sidebar-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 8px var(--space-3);
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.74);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
  transition: background var(--ease-fast), color var(--ease-fast);
  margin-bottom: 1px;
}
.sidebar-item:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.sidebar-item.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 600;
}
.sidebar-item.active::before {
  content: "";
  position: absolute;
  left: -12px; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: #5aa5ff;
}
.sidebar-item .icon { width: 20px; height: 20px; display: grid; place-items: center; flex-shrink: 0; }
.sidebar-item .icon svg { width: 18px; height: 18px; }
.sidebar-item.active .icon { color: #8cc2ff; }
.sidebar-item .label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-footer {
  padding: var(--space-3);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-logout:hover { background: rgba(229, 55, 43, 0.18); color: #ffb4ae; }

/* --- Main area --- */
.app-main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  /* A too-wide page must never push the topbar off screen. clip (not hidden/auto)
     keeps position:sticky working for the topbar and save bars. */
  overflow-x: clip;
}

/* --- Topbar --- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-8);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.crumbs { min-width: 0; flex: 1; }
.crumbs ol { display: flex; align-items: center; gap: 6px; list-style: none; margin: 0; padding: 0; min-width: 0; }
.crumbs li { display: flex; align-items: center; gap: 6px; font-size: var(--text-sm); color: var(--muted); white-space: nowrap; min-width: 0; }
.crumbs li + li::before {
  content: "";
  width: 6px; height: 6px;
  border-right: 1.5px solid var(--color-neutral-400);
  border-top: 1.5px solid var(--color-neutral-400);
  transform: rotate(45deg);
  margin-right: 4px;
  flex-shrink: 0;
}
.crumbs a { text-decoration: none; color: var(--muted); }
.crumbs a:hover { color: var(--color-primary-600); }
.crumbs li[aria-current] { color: var(--text); font-weight: 600; overflow: hidden; }
.crumbs li[aria-current] span { overflow: hidden; text-overflow: ellipsis; }
.crumbs-group { text-transform: uppercase; font-size: var(--text-2xs) !important; letter-spacing: 0.07em; font-weight: 600; color: var(--color-neutral-400) !important; }

.header-tools { display: flex; align-items: center; gap: var(--space-3); flex-shrink: 0; }

.search-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 340px;
  height: 38px;
  padding: 0 8px 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--color-neutral-50);
  color: var(--muted);
  font: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: border-color var(--ease-fast), background var(--ease-fast);
}
.search-trigger:hover { border-color: var(--border2); background: #fff; }
.search-trigger-text { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
kbd {
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--color-neutral-500);
  background: #fff;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 5px;
}

.btn-new { height: 38px; }

.user-chip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: 40px;
  padding: 0 8px 0 4px;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  background: none;
  font: inherit;
  cursor: pointer;
  color: var(--text);
}
.user-chip:hover { background: var(--color-neutral-100); }
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand-navy);
  color: #fff;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.user-chip-text { display: flex; flex-direction: column; line-height: 1.2; text-align: left; }
.user-chip-text strong { font-size: var(--text-sm); font-weight: 600; white-space: nowrap; }
.user-chip-text small { font-size: var(--text-2xs); color: var(--muted); }

/* --- Content --- */
.app-content {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-7) var(--space-8) var(--space-12);
}

/* Hamburger (mobile only) */
.sidebar-toggle {
  display: none;
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  place-items: center;
  flex-shrink: 0;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 24, 56, 0.5);
  z-index: 99;
}
.sidebar-overlay.visible { display: block; }

/* ==== components.css ==== */
/* ============================================================
   Component Library - Betki Portal
   One of each: page header, buttons, status badges, cards, KPI tiles,
   tables, toolbar/filters, pagination, empty states, forms, menus,
   toasts, command palette, modal, tabs, document chain, timeline.
   ============================================================ */

/* ---------------- Page header ---------------- */
.ph { margin-bottom: var(--space-6); }
.ph-back {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--text-sm); font-weight: 500; color: var(--muted);
  text-decoration: none; margin-bottom: var(--space-3);
}
.ph-back:hover { color: var(--color-primary-600); }
.ph-back .ic { width: 16px; height: 16px; }
.ph-row { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-5); flex-wrap: wrap; }
.ph-main { display: flex; gap: var(--space-4); align-items: flex-start; min-width: 0; flex: 1 1 360px; }
.ph-icon {
  width: 46px; height: 46px; border-radius: var(--radius-md);
  background: var(--brand-navy-100); color: var(--brand-navy);
  display: grid; place-items: center; flex-shrink: 0;
}
.ph-icon .ic { width: 22px; height: 22px; }
.ph-text { min-width: 0; }
.ph-eyebrow { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 2px; }
.ph-title-row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.ph-title { font-size: var(--text-2xl); font-weight: 700; line-height: 1.2; word-break: break-word; }
.ph-sub { margin: 4px 0 0; color: var(--text-2); font-size: var(--text-base); }
.ph-meta { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 16px; margin: var(--space-2) 0 0; padding: 0; font-size: var(--text-sm); color: var(--muted); }
.ph-meta li { display: inline-flex; align-items: center; gap: 6px; }
.ph-meta .ic { width: 15px; height: 15px; }
.ph-actions { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; justify-content: flex-end; }

/* ---------------- Section heading ---------------- */
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-3); margin: var(--space-8) 0 var(--space-4); flex-wrap: wrap; }
.section-head:first-child { margin-top: 0; }
.section-title { font-size: var(--text-lg); font-weight: 650; }
.section-sub { font-size: var(--text-sm); color: var(--muted); margin-top: 2px; }

/* ---------------- Buttons ---------------- */
.btn, button.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: #fff;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font: inherit; font-weight: 550; font-size: var(--text-sm);
  line-height: 1;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: background var(--ease-fast), border-color var(--ease-fast), box-shadow var(--ease-fast), color var(--ease-fast);
}
.btn .ic { width: 16px; height: 16px; }
.btn:hover { background: var(--color-neutral-50); border-color: var(--color-neutral-400); }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn:disabled, .btn.is-disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn.primary { color: #fff; background: var(--color-primary-600); border-color: var(--color-primary-600); }
.btn.primary:hover { background: var(--color-primary-700); border-color: var(--color-primary-700); }
.btn.navy { color: #fff; background: var(--brand-navy); border-color: var(--brand-navy); }
.btn.navy:hover { background: var(--brand-navy-600); }
.btn.danger { color: var(--color-danger-700); background: #fff; border-color: #f4c3bf; }
.btn.danger:hover { background: var(--color-danger-50); border-color: var(--color-danger-500); }
.btn.success { color: #fff; background: var(--color-success-500); border-color: var(--color-success-500); }
.btn.success:hover { background: var(--color-success-700); }
.btn.warning { color: var(--color-warning-700); background: var(--color-warning-50); border-color: #f7d9a6; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--color-neutral-100); }
.btn.small { height: 32px; padding: 0 11px; font-size: var(--text-xs); }
.btn.large { height: 44px; padding: 0 20px; font-size: var(--text-base); }
.btn.icon-only { width: 38px; padding: 0; }
.btn.small.icon-only { width: 32px; }
.btn svg { stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn-group { display: inline-flex; gap: var(--space-2); flex-wrap: wrap; }

/* ---------------- Status badges ---------------- */
.st {
  --st-bg: var(--tone-neutral-bg); --st-fg: var(--tone-neutral-fg); --st-dot: var(--tone-neutral-dot);
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 9px 0 8px;
  border-radius: var(--radius-full);
  background: var(--st-bg); color: var(--st-fg);
  font-size: var(--text-xs); font-weight: 600; line-height: 1;
  white-space: nowrap;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.st::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--st-dot); flex-shrink: 0; }
.st--lg { height: 26px; padding: 0 11px 0 10px; font-size: var(--text-sm); }
.st--info    { --st-bg: var(--tone-info-bg);    --st-fg: var(--tone-info-fg);    --st-dot: var(--tone-info-dot); }
.st--success { --st-bg: var(--tone-success-bg); --st-fg: var(--tone-success-fg); --st-dot: var(--tone-success-dot); }
.st--warning { --st-bg: var(--tone-warning-bg); --st-fg: var(--tone-warning-fg); --st-dot: var(--tone-warning-dot); }
.st--danger  { --st-bg: var(--tone-danger-bg);  --st-fg: var(--tone-danger-fg);  --st-dot: var(--tone-danger-dot); }
.st--purple  { --st-bg: var(--tone-purple-bg);  --st-fg: var(--tone-purple-fg);  --st-dot: var(--tone-purple-dot); }
.st--navy    { --st-bg: var(--tone-navy-bg);    --st-fg: var(--tone-navy-fg);    --st-dot: var(--tone-navy-dot); }


/* ---------------- Cards / panels ---------------- */
.card, .panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.panel { padding: var(--space-6); }
.card--pad { padding: var(--space-6); }
.card + .card, .panel + .panel { margin-top: var(--space-5); }
.grid > .card, .grid > .panel, .dash-grid-wide > .card, .grid-main-aside > .card, .kpis > .card { margin-top: 0; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.card-title { font-size: var(--text-base); font-weight: 650; display: flex; align-items: center; gap: var(--space-2); }
.card-title .ic { width: 18px; height: 18px; color: var(--muted); }
.card-sub { font-size: var(--text-xs); color: var(--muted); font-weight: 500; }
.card-body { padding: var(--space-5); }
.card-foot { padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border); background: var(--color-neutral-50); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.card > .table-wrap:last-child .data-table tr:last-child td { border-bottom: 0; }
.tag-internal {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--tone-purple-fg); background: var(--tone-purple-bg); padding: 2px 7px; border-radius: 4px;
}

/* Layout grids */
.grid { display: grid; gap: var(--space-5); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main-aside { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--space-5); align-items: start; }
.aside-sticky { position: sticky; top: calc(var(--header-h) + var(--space-5)); display: flex; flex-direction: column; gap: var(--space-5); }
.aside-sticky > .card + .card { margin-top: 0; }
.stack { display: flex; flex-direction: column; gap: var(--space-5); }
.stack > .card + .card { margin-top: 0; }
@media (max-width: 1100px) { .grid-main-aside { grid-template-columns: minmax(0, 1fr); } .aside-sticky { position: static; } }
.grid-main-aside > *, .stack > * { min-width: 0; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------------- KPI tiles ---------------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-6); }
/* Six tiles read as two even rows of three instead of 5 + an orphan */
.kpis:has(> :nth-child(6):last-child) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi {
  --kpi-c: var(--color-primary-600); --kpi-bg: var(--color-primary-100);
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: var(--space-2);
  min-width: 0;
  padding: var(--space-5);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  text-decoration: none; color: inherit;
  transition: box-shadow var(--ease-fast), border-color var(--ease-fast);
}
a.kpi:hover { box-shadow: var(--shadow-md); border-color: var(--border2); }
.kpi--green { --kpi-c: var(--color-success-700); --kpi-bg: var(--tone-success-bg); }
.kpi--amber { --kpi-c: var(--color-warning-700); --kpi-bg: var(--tone-warning-bg); }
.kpi--red   { --kpi-c: var(--color-danger-700);  --kpi-bg: var(--tone-danger-bg); }
.kpi--navy  { --kpi-c: var(--brand-navy);        --kpi-bg: var(--brand-navy-100); }
.kpi--gray  { --kpi-c: var(--color-neutral-600); --kpi-bg: var(--color-neutral-100); }
.kpi--purple{ --kpi-c: var(--tone-purple-fg);    --kpi-bg: var(--tone-purple-bg); }
.kpi-head { display: flex; align-items: center; gap: var(--space-2); }
.kpi-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--kpi-bg); color: var(--kpi-c); flex-shrink: 0; }
.kpi-icon .ic { width: 16px; height: 16px; }
.kpi-label { font-size: var(--text-xs); font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; line-height: 1.3; }
.kpi-value { font-size: 1.625rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-foot { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; font-size: var(--text-xs); color: var(--muted); }
.kpi-sub b { color: var(--text-2); font-weight: 600; }
.kpi-delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 650; padding: 1px 6px; border-radius: 5px; }
.kpi-delta .ic { width: 13px; height: 13px; }
.kpi-delta.is-good { color: var(--color-success-700); background: var(--tone-success-bg); }
.kpi-delta.is-bad  { color: var(--color-danger-700);  background: var(--tone-danger-bg); }
.kpi-delta.is-flat { color: var(--muted); background: var(--color-neutral-100); }
.kpi-spark { margin-top: auto; height: 34px; color: var(--kpi-c); }
.kpi-spark svg { width: 100%; height: 100%; display: block; overflow: visible; }


@media (max-width: 640px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 14px; gap: 6px; }
  .kpi-value { font-size: 1.2rem; }
  .kpi-label { font-size: 10.5px; }
  .kpi-icon { display: none; }
  .kpi-spark { height: 26px; }
  .ph-actions { width: 100%; justify-content: flex-start; }
  .toolbar-right { width: 100%; }
  .search-field { min-width: 0; flex: 1 1 100%; }
  .search-field input { width: 100%; max-width: none; }
}

/* ---------------- Toolbar / filters ---------------- */
.toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-2);
  font-size: var(--text-sm); font-weight: 550;
  text-decoration: none; white-space: nowrap;
  transition: background var(--ease-fast), border-color var(--ease-fast), color var(--ease-fast);
}
.chip:hover { border-color: var(--border2); background: var(--color-neutral-50); }
.chip.is-active { background: var(--brand-navy); border-color: var(--brand-navy); color: #fff; }
.chip-count { font-size: var(--text-2xs); font-weight: 700; padding: 1px 6px; border-radius: var(--radius-full); background: var(--color-neutral-100); color: var(--muted); }
.chip.is-active .chip-count { background: rgba(255,255,255,0.18); color: #fff; }

.search-field { position: relative; display: flex; align-items: center; min-width: 240px; }
.search-field .ic { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search-field input { padding-left: 34px !important; height: 36px; }
.data-table td a.nowrap, .data-table td .doc-no { white-space: nowrap; }
.toolbar select, .toolbar input[type=date] { height: 36px; padding-top: 0; padding-bottom: 0; width: auto; min-width: 140px; }


/* ---------------- Tables ---------------- */
.table-wrap, .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; background: #fff; font-variant-numeric: tabular-nums; }
.data-table th {
  position: sticky; top: 0; z-index: 1;
  text-align: left;
  padding: 10px var(--space-4);
  font-size: var(--text-2xs); font-weight: 650;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--color-neutral-500);
  background: var(--color-neutral-50);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table th a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.data-table th a:hover { color: var(--text); }
.data-table th.is-sorted { color: var(--text); }
.sort-ind { width: 8px; height: 10px; display: inline-block; position: relative; opacity: 0.35; }
.sort-ind::before, .sort-ind::after { content: ""; position: absolute; left: 1px; border: 3px solid transparent; }
.sort-ind::before { top: -2px; border-bottom-color: currentColor; }
.sort-ind::after { bottom: -2px; border-top-color: currentColor; }
.sort-ind.is-asc, .sort-ind.is-desc { opacity: 1; }
.sort-ind.is-asc::after, .sort-ind.is-desc::before { opacity: 0.2; }
.data-table td {
  padding: 12px var(--space-4);
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--color-neutral-100);
  vertical-align: middle;
}
.data-table tbody tr { transition: background var(--ease-fast); }
.data-table tbody tr:hover td { background: #fafbfd; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tr[data-href] { cursor: pointer; }
.data-table .num, .data-table .align-right, .data-table .text-right { text-align: right; white-space: nowrap; }
.data-table .text-bold, .data-table .strong { font-weight: 650; }
.data-table .col-actions { width: 1%; white-space: nowrap; text-align: right; }
.data-table .doc-link { font-weight: 650; color: var(--color-primary-700); text-decoration: none; }
.data-table .doc-link:hover { text-decoration: underline; }
.data-table tfoot td { background: var(--color-neutral-50); font-weight: 650; border-top: 1px solid var(--border); border-bottom: 0; }
.cell-title { font-weight: 600; color: var(--text); }
.cell-sub { font-size: var(--text-xs); color: var(--muted); margin-top: 1px; }
.cell-party { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.cell-party .avatar { width: 30px; height: 30px; font-size: 11px; background: var(--brand-navy-100); color: var(--brand-navy); }
.muted, .subtle { color: var(--muted); }
.subtle { font-size: var(--text-sm); }
.amount-neg { color: var(--color-danger-700); }
.amount-pos { color: var(--color-success-700); }

/* Mobile cards from table rows (.data-table--stack) */
@media (max-width: 720px) {
  .data-table--stack thead, .data-table--stack tfoot { display: none; }
  .data-table--stack, .data-table--stack tbody, .data-table--stack tr, .data-table--stack td { display: block; width: 100%; }
  .data-table--stack tr { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border); }
  .data-table--stack td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: var(--space-3); text-align: right; }
  .data-table--stack td::before { content: attr(data-label); font-size: var(--text-xs); color: var(--muted); font-weight: 600; text-align: left; }
  .data-table--stack td[data-label=""]::before { content: none; }
  .data-table--stack td.col-primary { display: block; text-align: left; font-size: var(--text-base); padding-bottom: 6px; }
  .data-table--stack td.col-primary::before { content: none; }
  .data-table--stack tr { position: relative; }
  .data-table--stack td.col-actions { position: absolute; top: 8px; right: 10px; width: auto; padding: 0; }
  .data-table--stack td.col-actions::before { content: none; }
  .data-table--stack td.col-primary { padding-right: 48px; }
}

/* ---------------- Pagination ---------------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); border-top: 1px solid var(--border); flex-wrap: wrap; font-size: var(--text-sm); color: var(--muted); }
.pager-info b { color: var(--text); font-weight: 600; }
.pager-links { display: flex; align-items: center; gap: 4px; }
.pager-btn {
  min-width: 32px; height: 32px; padding: 0 8px;
  display: inline-grid; place-items: center;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: #fff; color: var(--text-2); text-decoration: none; font-weight: 550;
}
.pager-btn .ic { width: 16px; height: 16px; }
a.pager-btn:hover { border-color: var(--border2); background: var(--color-neutral-50); }
.pager-btn.is-current { background: var(--brand-navy); border-color: var(--brand-navy); color: #fff; }
.pager-btn.is-disabled { opacity: 0.4; }
.pager-gap { padding: 0 4px; }

/* ---------------- Empty states ---------------- */
.empty { text-align: center; padding: var(--space-12) var(--space-5); }
.empty-art {
  width: 64px; height: 64px; margin: 0 auto var(--space-4);
  border-radius: 18px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand-navy-100), var(--color-primary-100));
  color: var(--brand-navy);
}
.empty-art .ic { width: 28px; height: 28px; }
.empty-title { font-size: var(--text-lg); font-weight: 650; }
.empty-text { color: var(--muted); max-width: 420px; margin: var(--space-2) auto 0; font-size: var(--text-sm); }
.empty-action { margin-top: var(--space-5); }

/* ---------------- Forms ---------------- */
input, select, textarea {
  width: 100%;
  min-height: 40px;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: var(--text-base);
  outline: none;
  box-shadow: var(--shadow-xs);
  transition: border-color var(--ease-fast), box-shadow var(--ease-fast);
}
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; box-shadow: none; accent-color: var(--color-primary-600); }
input[type=file] { padding: 0.45rem; }
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
select {
  appearance: none; -webkit-appearance: none;
  padding-right: 2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
}
input::placeholder, textarea::placeholder { color: var(--color-neutral-400); }
input:focus, select:focus, textarea:focus { border-color: var(--color-primary-600); box-shadow: var(--focus-ring); }
input:disabled, select:disabled, textarea:disabled, input[readonly] { background: var(--color-neutral-50); color: var(--muted); }
input[aria-invalid=true], select[aria-invalid=true], textarea[aria-invalid=true] { border-color: var(--color-danger-500); }
label { display: block; margin-top: var(--space-3); font-size: var(--text-sm); font-weight: 550; color: var(--text-2); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { margin: 0; }
.field .req { color: var(--color-danger-500); margin-left: 2px; }
.field-hint { font-size: var(--text-xs); color: var(--muted); }
.field-error { font-size: var(--text-xs); color: var(--color-danger-700); font-weight: 550; }
.field--full { grid-column: 1 / -1; }

.form-section { margin-bottom: var(--space-6); }
.form-section-title {
  font-size: var(--text-base); font-weight: 650; color: var(--text);
  margin-bottom: var(--space-4); padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
}
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4) var(--space-5); }
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-group { margin-bottom: var(--space-4); }
.form-group label { margin: 0 0 6px; }

.savebar {
  position: sticky; bottom: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  margin: var(--space-6) calc(-1 * var(--space-8)) calc(-1 * var(--space-12));
  padding: var(--space-3) var(--space-8);
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -6px 16px -10px rgba(16,24,40,0.18);
}
.savebar-note { font-size: var(--text-sm); color: var(--muted); }
@media (max-width: 1280px) { .savebar { margin-left: calc(-1 * var(--space-6)); margin-right: calc(-1 * var(--space-6)); padding-left: var(--space-6); padding-right: var(--space-6); } }
@media (max-width: 768px) { .form-grid, .form-grid--3 { grid-template-columns: 1fr; } .savebar { margin-left: calc(-1 * var(--space-4)); margin-right: calc(-1 * var(--space-4)); padding: var(--space-3) var(--space-4); } }

/* ---------------- Alerts ---------------- */
.alert, .alert-success, .alert-error, .alert-warning, .alert-info {
  display: flex; align-items: flex-start; gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  margin: 0 0 var(--space-4);
  border: 1px solid transparent;
}
.alert .ic { width: 18px; height: 18px; margin-top: 1px; }
.alert-success { background: var(--tone-success-bg); border-color: #b9e5c9; color: var(--tone-success-fg); }
.alert-error { background: var(--tone-danger-bg); border-color: #f6c6c2; color: var(--tone-danger-fg); }
.alert-warning { background: var(--tone-warning-bg); border-color: #f5d9a8; color: var(--tone-warning-fg); }
.alert-info { background: var(--tone-info-bg); border-color: #c3dbf9; color: var(--tone-info-fg); }

/* ---------------- Dropdown menus ---------------- */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 220px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
  z-index: 80;
}
.dropdown--left .dropdown-menu { right: auto; left: 0; }
.dropdown.open .dropdown-menu { display: block; animation: pop-in 140ms ease-out; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.dropdown-menu form { margin: 0; }
.dropdown-item, .dropdown-item-danger {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0; border-radius: 6px;
  background: none;
  font: inherit; font-size: var(--text-sm); text-align: left;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}
.dropdown-item .ic { width: 16px; height: 16px; color: var(--muted); }
.dropdown-item:hover { background: var(--color-neutral-100); }
.dropdown-item.is-danger, .dropdown-item-danger { color: var(--color-danger-700); }
.dropdown-item.is-danger .ic { color: currentColor; }
.dropdown-item.is-danger:hover, .dropdown-item-danger:hover { background: var(--tone-danger-bg); }
.dropdown-divider { height: 1px; background: var(--border); margin: 6px -6px; }
.dropdown-label { padding: 6px 10px 4px; font-size: var(--text-2xs); font-weight: 650; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.dropdown-head { padding: 8px 10px; display: flex; flex-direction: column; }
.dropdown-head strong { font-size: var(--text-sm); }
.dropdown-head span { font-size: var(--text-xs); color: var(--muted); }

.row-actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: nowrap; }

/* ---------------- Toasts ---------------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 400; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 40px)); }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 12px 12px 14px;
  border-radius: var(--radius-md);
  background: var(--color-neutral-900);
  color: #fff;
  font-size: var(--text-sm);
  box-shadow: var(--shadow-lg);
  animation: toast-in 260ms cubic-bezier(0.22, 1, 0.36, 1);
}
.toast > .ic { width: 18px; height: 18px; }
.toast--success > .ic { color: #6ee7a0; }
.toast--error > .ic { color: #ff9b94; }
.toast--info > .ic { color: #8cc2ff; }
.toast span { flex: 1; }
.toast-x { border: 0; background: none; color: rgba(255,255,255,0.6); cursor: pointer; padding: 2px; display: grid; }
.toast-x .ic { width: 16px; height: 16px; }
.toast.is-leaving { opacity: 0; transform: translateY(8px); transition: all 200ms ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* ---------------- Command palette ---------------- */
.palette { position: fixed; inset: 0; z-index: 500; background: rgba(15, 24, 56, 0.45); display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 16px; }
.palette[hidden] { display: none; }
.palette-box { width: 100%; max-width: 640px; background: #fff; border-radius: var(--radius-xl); box-shadow: 0 24px 60px -12px rgba(16,24,40,0.45); overflow: hidden; animation: pop-in 160ms ease-out; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.palette-input > .ic { width: 20px; height: 20px; color: var(--muted); }
.palette-input input { border: 0; box-shadow: none; height: 56px; font-size: var(--text-lg); padding: 0; }
/* The box itself is the field: no inner border or focus ring (it was clipped by the rounded box) */
.palette-input input[type=search], .palette-input input[type=search]:focus { border: 0; outline: none; box-shadow: none; background: transparent; border-radius: 0; }
.palette-input:focus-within { box-shadow: inset 0 -2px 0 var(--color-primary-600); }
.palette-list { max-height: 52vh; overflow-y: auto; padding: 6px; }
.palette-group { padding: 10px 10px 4px; font-size: var(--text-2xs); font-weight: 650; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 8px; text-decoration: none; color: var(--text); }
.palette-item .pi-icon { width: 32px; height: 32px; border-radius: 8px; background: var(--brand-navy-50); color: var(--brand-navy); display: grid; place-items: center; flex-shrink: 0; }
.palette-item .pi-icon .ic { width: 16px; height: 16px; }
.palette-item .pi-text { flex: 1; min-width: 0; }
.palette-item .pi-title, .palette-item .pi-sub { display: block; }
.palette-item .pi-title { font-weight: 600; font-size: var(--text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item .pi-sub { font-size: var(--text-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item .pi-meta { font-size: var(--text-xs); color: var(--muted); white-space: nowrap; }
.palette-item.is-active, .palette-item:hover { background: var(--color-primary-50); }
.palette-empty { padding: 28px; text-align: center; color: var(--muted); font-size: var(--text-sm); }
.palette-foot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--border); background: var(--color-neutral-50); font-size: var(--text-xs); color: var(--muted); }
.palette-foot kbd { margin-right: 3px; }

/* ---------------- Modal ---------------- */
.modal { border: 0; padding: 0; border-radius: var(--radius-xl); box-shadow: 0 24px 60px -12px rgba(16,24,40,0.45); width: min(440px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(15, 24, 56, 0.45); }
.modal-box { padding: var(--space-6); }
.modal-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--tone-warning-bg); color: var(--tone-warning-fg); margin-bottom: var(--space-4); }
.modal.is-danger .modal-icon { background: var(--tone-danger-bg); color: var(--tone-danger-fg); }
.modal-icon .ic { width: 22px; height: 22px; }
.modal-title { font-size: var(--text-lg); font-weight: 650; }
.modal-text { color: var(--text-2); font-size: var(--text-sm); margin: var(--space-2) 0 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-6); }
.modal.is-danger #confirmOk { background: var(--color-danger-500); border-color: var(--color-danger-500); }

/* ---------------- Tabs ---------------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 14px;
  border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  background: none; font: inherit; font-size: var(--text-sm); font-weight: 550;
  color: var(--muted); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.is-active, .tab[aria-selected=true] { color: var(--brand-navy); border-bottom-color: var(--brand-navy); font-weight: 650; }
.tab .chip-count { margin-left: 2px; }
.tab-panel[hidden] { display: none; }

/* ---------------- Document chain ---------------- */
.chain { list-style: none; margin: 0 0 var(--space-5); padding: 0; display: flex; gap: 0; flex-wrap: wrap; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); overflow: hidden; }
.chain-step { flex: 1 1 200px; position: relative; min-width: 0; }
.chain-step + .chain-step { border-left: 1px solid var(--border); }
.chain-step > a, .chain-step > div { display: flex; align-items: center; gap: 12px; padding: 12px 16px; text-decoration: none; color: inherit; height: 100%; }
.chain-step > a:hover { background: var(--color-neutral-50); }
.chain-step.is-current { background: var(--brand-navy-50); box-shadow: inset 0 -2px 0 var(--brand-navy); }
.chain-step.is-empty { opacity: 0.6; }
.chain-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-navy-100); color: var(--brand-navy); flex-shrink: 0; }
.chain-step.is-empty .chain-icon { background: var(--color-neutral-100); color: var(--muted); }
.chain-icon .ic { width: 17px; height: 17px; }
.chain-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.chain-label { font-size: var(--text-2xs); font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.chain-num { font-size: var(--text-sm); font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chain-step.is-empty .chain-num { font-weight: 500; color: var(--muted); }

/* ---------------- Description list ---------------- */
.dl { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 10px var(--space-4); margin: 0; font-size: var(--text-sm); }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; color: var(--text); font-weight: 550; word-break: break-word; }
.dl--stack { grid-template-columns: 1fr; gap: 2px; }
.dl--stack dd { margin-bottom: var(--space-3); }

/* Totals block */
.totals { display: flex; flex-direction: column; gap: 8px; font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.totals-row { display: flex; justify-content: space-between; gap: var(--space-3); color: var(--text-2); }
.totals-row b { color: var(--text); font-weight: 600; }
.totals-row.is-grand { padding-top: 10px; margin-top: 2px; border-top: 1px solid var(--border); font-size: var(--text-lg); color: var(--text); font-weight: 700; }
.totals-row.is-grand b { font-weight: 750; }
.totals-row.is-due b { color: var(--color-danger-700); }

/* ---------------- Timeline ---------------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 var(--space-4) 26px; font-size: var(--text-sm); }
.timeline li::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: -6px; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; left: 1px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--color-primary-600); }
.timeline .tl-time { font-size: var(--text-xs); color: var(--muted); }

/* ---------------- Stepper (pipelines) ---------------- */
.stepper { list-style: none; margin: 0; padding: 0; display: flex; counter-reset: step; }
.stepper li { flex: 1; position: relative; text-align: center; font-size: var(--text-xs); font-weight: 600; color: var(--muted); padding-top: 34px; }
.stepper li::before { counter-increment: step; content: counter(step); position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: #fff; border: 2px solid var(--border2); color: var(--muted); z-index: 1; font-size: 11px; }
.stepper li::after { content: ""; position: absolute; top: 12px; left: -50%; width: 100%; height: 2px; background: var(--border2); }
.stepper li:first-child::after { display: none; }
.stepper li.is-done { color: var(--text-2); }
.stepper li.is-done::before { content: "✓"; background: var(--color-success-500); border-color: var(--color-success-500); color: #fff; }
.stepper li.is-done::after, .stepper li.is-current::after { background: var(--color-success-500); }
.stepper li.is-current { color: var(--brand-navy); }
.stepper li.is-current::before { background: var(--brand-navy); border-color: var(--brand-navy); color: #fff; box-shadow: 0 0 0 4px var(--brand-navy-100); }

/* ---------------- Progress bar ---------------- */
.bar { height: 8px; border-radius: 99px; background: var(--color-neutral-100); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: var(--color-primary-600); }
.bar--success > span { background: var(--color-success-500); }
.bar--warning > span { background: var(--color-warning-500); }
.bar--danger > span { background: var(--color-danger-500); }

/* ---------------- Utilities ---------------- */
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: var(--font-mono); font-size: 0.95em; }
.mt-1 { margin-top: var(--space-1); } .mt-2 { margin-top: var(--space-2); } .mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); } .mt-6 { margin-top: var(--space-6); } .mb-4 { margin-bottom: var(--space-4); }
.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; }
.printonly { display: none; }

/* ---------------- Print (app pages) ---------------- */
@media print {
  @page { size: A4; margin: 14mm 12mm; }
  .sidebar, .app-header, .sidebar-overlay, .sidebar-toggle, .toasts, .palette, .savebar, .ph-actions, .noprint, .pager-links { display: none !important; }
  .app-main { margin-left: 0 !important; }
  .app-content { padding: 0 !important; max-width: none !important; }
  .printonly { display: block !important; }
  body { background: #fff !important; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .card, .panel, .kpi { box-shadow: none !important; break-inside: avoid; }
  .data-table th { position: static; }
  .data-table tr { break-inside: avoid; }
  a { text-decoration: none; }
}

/* ---------------- Signature pad ---------------- */
.sig-container { margin-top: var(--space-2); }
.sig-tabs { display: flex; gap: 0; margin-bottom: var(--space-3); border-bottom: 1px solid var(--border); }
.sig-tab { padding: 10px 18px; font: inherit; font-size: var(--text-sm); font-weight: 550; background: none; border: none; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.sig-tab.active { color: var(--brand-navy); border-bottom-color: var(--brand-navy); }
.sig-panel { min-height: 220px; }
.sig-canvas { width: 100%; height: 200px; border: 1px solid var(--border2); border-radius: var(--radius-md); cursor: crosshair; touch-action: none; background: #fff; }
.sig-clear { margin-top: var(--space-2); padding: 6px 14px; font: inherit; font-size: var(--text-xs); background: #fff; border: 1px solid var(--border2); border-radius: var(--radius-sm); cursor: pointer; color: var(--muted); }
.sig-clear:hover { background: var(--color-neutral-50); }
.sig-file-input { width: 100%; padding: var(--space-3); font: inherit; font-size: var(--text-sm); }
.sig-preview { max-height: 100px; margin-top: var(--space-3); border-radius: var(--radius-md); border: 1px solid var(--border2); }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.modal--form { width: min(620px, calc(100vw - 32px)); }
a.cell-title:hover { color: var(--color-primary-700); }

/* Delivery-note editor: an item ticked for removal */
.item-block.removed { background: var(--tone-danger-bg); border-color: #f4c3bf; }
.item-block.removed :is(input:not([type=checkbox]), textarea) { opacity: .55; text-decoration: line-through; }
.remove-toggle { display: inline-flex; align-items: center; gap: 8px; color: var(--color-danger-700); font-weight: 550; cursor: pointer; }
@media (max-width: 640px) { .savebar-note { display: none; } }

/* Searchable picker (svy-combo) used outside the survey pages */
.svy-combo { --svy-accent: var(--color-primary-600); }
.svy-combo__search input { padding-left: 36px; }
@media (max-width: 640px) { .data-table--stack td.num b { margin-left: auto; } }

/* Editable item tables: keep inputs usable on phones (table scrolls instead) */

.items-edit .item-qty { min-width: 80px; }
.items-edit .item-price { min-width: 120px; }
.items-edit input.num { text-align: right; }
.data-table td.cell-desc { min-width: 220px; white-space: normal; }
.email-preview { border: 1px solid var(--border); border-radius: var(--radius-md); background: #f5f5f7; }
.pre-line { white-space: pre-line; }
.grid > * { min-width: 0; }
.data-table td .toolbar-left select { width: auto; min-width: 150px; }
.data-table tr.row-group th { background: var(--color-neutral-50); }
/* Multi-line item descriptions in editable tables keep their line breaks */
.data-table td textarea[name="description[]"], .data-table td textarea[name="item_desc[]"] { min-width: 240px; min-height: 40px; resize: vertical; field-sizing: content; max-height: 220px; }

.card-foot:has(> .btn) { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ==== charts.css ==== */
/* ============================================================
   Charts (includes/charts.php) — HTML axes, SVG/HTML marks
   ============================================================ */
.ch { margin: 0; position: relative; min-width: 0; }
.ch-body { position: relative; display: flex; gap: 8px; }
.ch-yaxis { position: relative; width: 40px; flex-shrink: 0; font-size: 11px; color: var(--chart-axis); font-variant-numeric: tabular-nums; }
.ch-yaxis span { position: absolute; right: 0; transform: translateY(50%); line-height: 1; }
.ch-plot { position: relative; flex: 1; min-width: 0; }
.ch-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.ch-xaxis { display: flex; margin: 8px 0 0 48px; font-size: 11px; color: var(--chart-axis); }
.ch-xaxis span { flex: 1; text-align: center; white-space: nowrap; overflow: hidden; min-width: 0; }
@media (max-width: 640px) { .ch-line .ch-xaxis span:nth-child(even) { visibility: hidden; } }

/* line hover columns */
.ch-hits { position: absolute; inset: 0; display: flex; }
.ch-hit { flex: 1; position: relative; cursor: crosshair; }
.ch-hit::before { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--color-neutral-300); opacity: 0; }
.ch-hit:hover::before { opacity: 1; }
.ch-dot { position: absolute; left: 50%; width: 8px; height: 8px; margin: 0 0 -4px -4px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px #fff; opacity: 0; transition: opacity 120ms; }
.ch-hit:hover .ch-dot, .ch-line--dots .ch-dot { opacity: 1; }

/* columns */
.ch-grid { position: absolute; inset: 0; }
.ch-grid i { position: absolute; left: 0; right: 0; height: 1px; background: var(--chart-grid); }
.ch-grid i:first-child { background: var(--color-neutral-300); }
.ch-cols { position: absolute; inset: 0; display: flex; align-items: flex-end; }
.ch-col-group { flex: 1; min-width: 0; height: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; padding: 0 3px; }
.ch-col { flex: 1; max-width: 28px; min-height: 1px; background: var(--c); border-radius: 4px 4px 0 0; transition: filter 120ms; }
.ch-col:hover { filter: brightness(0.9); }

/* legend */
.ch-legend { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: var(--text-xs); color: var(--text-2); }
.ch-legend li { display: inline-flex; align-items: center; gap: 6px; }
.ch-legend b { font-weight: 600; color: var(--muted); margin-left: 2px; }
.ch-key { width: 10px; height: 10px; border-radius: 3px; background: var(--c); flex-shrink: 0; }
.ch-key--line { height: 3px; width: 14px; border-radius: 2px; }

/* ring / gauge / donut */
.ch-ring, .ch-donut { position: relative; flex-shrink: 0; }
.ch-ring svg, .ch-donut svg { width: 100%; height: 100%; display: block; }
.ch-ring-label, .ch-donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; line-height: 1.1; pointer-events: none; }
.ch-ring-label b { font-size: 15px; font-weight: 700; }
.ch-ring-label small, .ch-donut-center small, .ch-gauge-label small { font-size: 11px; color: var(--muted); margin-top: 2px; }
.ch-donut-center b { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.ch-donut-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.ch-donut-wrap .ch-legend { flex-direction: column; gap: 10px; margin: 0; font-size: var(--text-sm); }
.ch-donut-wrap .ch-legend b { display: block; margin: 0; font-size: var(--text-xs); }
.ch-donut-wrap .ch-legend li { align-items: flex-start; }
.ch-donut-wrap .ch-key { margin-top: 4px; }
.ch-seg { transition: stroke-width 120ms; }
.ch-seg:hover { stroke-width: 17; }
.ch-gauge { position: relative; width: 160px; max-width: 100%; }
.ch-gauge svg { width: 100%; display: block; }
.ch-gauge-label { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.ch-gauge-label b { font-size: 20px; font-weight: 700; }
.ch-spark { width: 100%; height: 100%; display: block; }

/* horizontal bars */
.ch-hbars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.ch-hbars li { display: grid; grid-template-columns: minmax(110px, 34%) 1fr auto; align-items: center; gap: 12px; font-size: var(--text-sm); }
.ch-hbars a { text-decoration: none; color: inherit; min-width: 0; }
.ch-hbars a:hover .ch-hbar-label { color: var(--color-primary-700); }
.ch-hbar-label { display: flex; flex-direction: column; min-width: 0; font-weight: 550; }
.ch-hbar-label, .ch-hbar-label small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-hbar-label small { font-size: var(--text-xs); color: var(--muted); font-weight: 400; }
.ch-hbar-track { height: 10px; background: var(--color-neutral-100); border-radius: 0 4px 4px 0; overflow: hidden; }
.ch-hbar { display: block; height: 100%; background: var(--c); border-radius: 0 4px 4px 0; min-width: 2px; }
.ch-hbar-value { font-weight: 650; font-variant-numeric: tabular-nums; min-width: 48px; text-align: right; }

/* funnel */
.ch-funnel { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.ch-funnel-head { display: flex; justify-content: space-between; gap: 8px; font-size: var(--text-xs); color: var(--muted); font-weight: 550; margin-bottom: 4px; }
.ch-funnel-head span:first-child { color: var(--text-2); font-weight: 600; }
.ch-funnel-conv { font-variant-numeric: tabular-nums; }
.ch-funnel-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 72px; height: 30px; padding: 0 10px; border-radius: 0 6px 6px 0; background: var(--c); color: #fff; font-size: var(--text-sm); }
.ch-funnel-bar small { font-size: var(--text-xs); opacity: 0.9; }

/* stacked bar */
.ch-stack { display: flex; gap: 2px; height: 14px; border-radius: 4px; overflow: hidden; margin-bottom: 12px; }
.ch-stack span { display: block; height: 100%; background: var(--c); min-width: 3px; }

/* data table toggle */
.ch-table { margin-top: 10px; }
.ch-table summary { font-size: var(--text-xs); color: var(--muted); cursor: pointer; width: max-content; }
.ch-table summary:hover { color: var(--color-primary-700); }
.ch-table .data-table th { position: static; }

/* tooltip (js/charts.js) */
.ch-tip {
  position: fixed; z-index: 600; pointer-events: none;
  background: var(--color-neutral-900); color: #fff;
  font-size: var(--text-xs); line-height: 1.5;
  padding: 7px 10px; border-radius: 7px;
  box-shadow: var(--shadow-lg);
  max-width: 280px;
  opacity: 0; transform: translateY(4px); transition: opacity 100ms, transform 100ms;
}
.ch-tip.is-on { opacity: 1; transform: none; }
.ch-tip b { font-weight: 650; }

.chart-empty { height: 180px; display: grid; place-items: center; color: var(--muted); font-size: var(--text-sm); background: repeating-linear-gradient(135deg, transparent 0 10px, var(--color-neutral-50) 10px 20px); border-radius: var(--radius-md); }

@media print {
  .ch-table, .ch-dot { display: none; }
}

/* ==== pages.css ==== */
/* ============================================================
   Page-specific Overrides - Betki Sales Portal (Apple-aligned)
   ============================================================ */

/* Work Order Detail View */
.detail-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: var(--space-1);
  display: block;
}
.detail-block {
  font-size: var(--text-sm);
  color: var(--text);
  background: var(--color-neutral-50);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-top: var(--space-2);
  line-height: 1.6;
}
.signature-box {
  padding: var(--space-2) 0;
  margin: var(--space-2) 0;
  display: inline-block;
}
.signature-box img {
  display: block;
}

/* Quote pricing workspace (quote_view.php) */
.pricing-table { min-width: 940px; }
.pricing-table th:first-child { width: 22%; }
.pricing-table td { vertical-align: top; }
.pricing-table input { min-height: 36px; padding: 6px 9px; font-size: var(--text-sm); }
.pricing-table input.num { text-align: right; font-variant-numeric: tabular-nums; }
.pricing-table input.f-supp { min-width: 110px; }
.pricing-table input.f-cost, .pricing-table input.f-sell { min-width: 96px; }
.pricing-table input.f-margin { min-width: 76px; }
.pricing-table input.f-cost, .pricing-table input.f-supp { background: #fffbf2; }
.pricing-table input.f-margin { background: var(--color-primary-50); }
.pricing-table .f-linetotal, .pricing-table .f-profit { padding-top: 20px; min-width: 104px; white-space: nowrap; }
.svc-toggle { display: flex; align-items: center; gap: 6px; margin: 6px 0 0; font-size: var(--text-xs); font-weight: 500; color: var(--muted); cursor: pointer; white-space: nowrap; }

/* Dashboard */
.dash-grid-wide { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: var(--space-5); align-items: start; }
@media (max-width: 1100px) { .dash-grid-wide { grid-template-columns: 1fr; } }
.dash-big { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 12px; font-variant-numeric: tabular-nums; }
.dash-big small { display: block; font-size: var(--text-xs); font-weight: 500; color: var(--muted); letter-spacing: 0; }
.dash-sub-h { font-size: var(--text-2xs); font-weight: 650; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin: 16px 0 8px; }
.dash-list { list-style: none; margin: 0; padding: 0; }
.dash-list li { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--color-neutral-100); font-size: var(--text-sm); }
.dash-list li:last-child { border-bottom: 0; }
.dash-list .cell-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-list .muted { font-size: var(--text-xs); }
.dash-list b { font-variant-numeric: tabular-nums; }

.attention { list-style: none; margin: 0; padding: 4px 0; }
.attention li { display: flex; align-items: center; gap: 12px; padding: 12px var(--space-5); border-bottom: 1px solid var(--color-neutral-100); }
.attention li:last-child { border-bottom: 0; }
.att-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; }
.att-icon .ic { width: 17px; height: 17px; }
.att-icon--danger { background: var(--tone-danger-bg); color: var(--tone-danger-fg); }
.att-icon--warning { background: var(--tone-warning-bg); color: var(--tone-warning-fg); }
.att-icon--success { background: var(--tone-success-bg); color: var(--tone-success-fg); }
.att-text { flex: 1; min-width: 0; font-size: var(--text-sm); font-weight: 550; }
.att-text a { color: var(--color-primary-700); text-decoration: none; }
.att-text small { display: block; font-size: var(--text-xs); color: var(--muted); font-weight: 400; margin-top: 1px; }

.wo-pipe { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.wo-pipe li { padding: 10px 10px 9px; border-radius: var(--radius-sm); background: var(--st-bg, var(--color-neutral-100)); color: var(--st-fg, var(--text)); min-width: 0; }
.wo-pipe li b { display: block; font-size: 1.25rem; font-weight: 700; line-height: 1.1; }
.wo-pipe li span { display: block; font-size: 11px; font-weight: 550; line-height: 1.25; margin-top: 2px; }
.wo-pipe-info    { --st-bg: var(--tone-info-bg);    --st-fg: var(--tone-info-fg); }
.wo-pipe-warning { --st-bg: var(--tone-warning-bg); --st-fg: var(--tone-warning-fg); }
.wo-pipe-purple  { --st-bg: var(--tone-purple-bg);  --st-fg: var(--tone-purple-fg); }
.wo-pipe-success { --st-bg: var(--tone-success-bg); --st-fg: var(--tone-success-fg); }
.wo-pipe-navy    { --st-bg: var(--tone-navy-bg);    --st-fg: var(--tone-navy-fg); }
@media (max-width: 640px) { .wo-pipe { grid-template-columns: repeat(2, 1fr); } }

/* Invoice view */
.balance-panel { display: flex; align-items: center; gap: 16px; }
.balance-value { font-size: 1.375rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.details-card > summary { list-style: none; cursor: pointer; }
.details-card > summary::-webkit-details-marker { display: none; }
.details-card > summary::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform var(--ease-fast); margin-left: 8px; }
.details-card[open] > summary::after { transform: rotate(45deg); }
.details-card:not([open]) > summary { border-bottom: 0; }

/* Company settings */
.logo-drop { border: 1.5px dashed var(--border2); border-radius: var(--radius-md); padding: 18px; text-align: center; cursor: pointer; transition: border-color var(--ease-fast), background var(--ease-fast); }
.logo-drop:hover, .logo-drop.drag-over { border-color: var(--color-primary-600); background: var(--color-primary-50); }
.logo-drop p { margin: 10px 0 8px; font-size: var(--text-sm); color: var(--muted); }
.logo-drop .field-hint { display: block; margin-top: 8px; }
.logo-preview { width: 96px; height: 96px; margin: 0 auto; border-radius: var(--radius-md); background: #fff; border: 1px solid var(--border); display: grid; place-items: center; overflow: hidden; }
.logo-preview img { max-width: 84px; max-height: 84px; object-fit: contain; }
.logo-preview-fallback { font-size: 36px; font-weight: 700; color: var(--brand-navy); }
.logo-status { margin-top: 8px; font-size: var(--text-xs); }
.logo-status.error { color: var(--color-danger-700); } .logo-status.success { color: var(--color-success-700); }
.lh-preview { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; background: #fff; font-size: 11px; box-shadow: var(--shadow-xs); }
.lh-preview-top { display: flex; align-items: flex-start; gap: 8px; padding-bottom: 8px; border-bottom: 2px solid var(--brand-navy); }
.lh-preview-top img { width: 30px; height: 30px; object-fit: contain; }
.lh-preview-top b { display: block; color: var(--brand-navy); font-size: 12px; }
.lh-preview-top small { display: block; color: var(--muted); }
.lh-preview-doc { margin-left: auto; font-weight: 700; color: var(--brand-navy); letter-spacing: 0.04em; }
.lh-preview-lines { display: flex; flex-direction: column; gap: 2px; padding-top: 8px; color: var(--text-2); white-space: pre-line; }

/* ---------- Shared view-page details (were inline styles) ---------- */
.data-table th.col-idx { width: 40px; }
.card-body--divided { border-top: 1px solid var(--border); }
.totals-box { max-width: 360px; margin-left: auto; }
.field-hint.hint-right { text-align: right; margin: 8px 0 0; }
.field-hint.hint-top { margin: 10px 0 0; }
.field-hint.hint-block { margin: 0 0 16px; }
.m-0 { margin: 0; }
.fw-500 { font-weight: 500; }
.prewrap-text { white-space: pre-wrap; font-size: var(--text-sm); line-height: 1.7; }
.cell-party--head { margin-bottom: 14px; }
.avatar.avatar--md { width: 40px; height: 40px; font-size: 14px; }
.no-underline, a.cell-title.no-underline { text-decoration: none; }
.profit-row { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.profit-value { font-size: 1.375rem; font-weight: 700; }
.alert.alert--after { margin: 12px 0 0; }
.card-foot--block .btn { width: 100%; }
.card-foot.card-foot--end { display: flex; justify-content: flex-end; gap: 8px; }
.tabs.tabs--inset { padding: 0 var(--space-4); }
.check-inline { display: flex; align-items: center; gap: 8px; font-weight: 550; margin: 8px 0 0; }
.chart-empty.chart-empty--sm { height: 150px; }
.text-warning { color: var(--tone-warning-fg); }
.cell-sub.text-danger-strong { color: var(--tone-danger-fg); font-weight: 600; }
.bar.bar--kpi { margin-top: 10px; }
.bar.bar--thin { height: 4px; margin-top: 5px; }

/* ---------- Work order send / sign / invoice pages ---------- */
.link-box { word-break: break-all; font-size: var(--text-sm); background: var(--color-neutral-50); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: var(--space-4); }
.lead-text { font-size: var(--text-sm); color: var(--text); line-height: 1.6; margin: 0 0 var(--space-4); }
.field input[readonly] { background: var(--color-neutral-50); }
.email-preview--frame { display: block; width: 100%; height: 400px; }

/* ---------- Hermes approvals ---------- */
.ha-reason { color: var(--text-2); font-size: var(--text-sm); margin: 0 0 8px; }
.ha-args { font-family: var(--font-mono); font-size: 12px; background: var(--color-neutral-50); border: 1px solid var(--border); padding: 8px 10px; border-radius: var(--radius-md); white-space: pre-wrap; word-break: break-all; margin: 0; }
.ha-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: var(--space-4); align-items: center; }
.ha-actions form { margin: 0; }
.ha-deny { display: flex; gap: 8px; flex: 1; min-width: 260px; }
.ha-deny input { flex: 1; }
.items-edit input[name="description[]"] { min-width: 220px; }
.items-edit .qty-input { min-width: 80px; }
.items-edit .price-input { min-width: 120px; }

/* Delivery-note forms: warranty as number + months/years */
.warranty-input { display: flex; gap: 8px; }
.warranty-input input { flex: 1 1 auto; min-width: 0; }
.warranty-input select { flex: 0 0 auto; width: auto; min-width: 104px; }

/* Warranty per line item (quote forms): small link under the description, opens number + unit */
.wty { margin-top: 6px; display: flex; align-items: center; min-height: 28px; }
.wty-add { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px 2px 4px; margin-left: -4px; border: 0; background: none; border-radius: var(--radius-sm); color: var(--color-primary-600); font-size: var(--text-xs); font-weight: 600; cursor: pointer; }
.wty-add .ic { width: 13px; height: 13px; }
.wty-add:hover { background: var(--color-primary-50); }
.wty-ctl { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border: 1px solid var(--border); border-radius: var(--radius-full); background: var(--color-neutral-50); }
.wty-ctl[hidden], .wty-add[hidden] { display: none; }
.wty-label { font-size: var(--text-xs); font-weight: 600; color: var(--muted); }
.data-table td .wty-ctl input.wty-n { width: 58px; min-width: 0; height: 26px; min-height: 0; padding: 0 6px; font-size: var(--text-xs); text-align: right; }
.data-table td .wty-ctl select.wty-u { width: auto; min-width: 0; height: 26px; min-height: 0; padding: 0 22px 0 8px; font-size: var(--text-xs); background-position: right 6px center; }
.wty-x { display: inline-grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; }
.wty-x:hover { background: var(--tone-danger-bg); color: var(--tone-danger-fg); }
.wty-x .ic { width: 12px; height: 12px; }
.cell-sub--warranty { color: var(--tone-success-fg); font-weight: 600; }

/* ==== projects.css ==== */
/* ============================================================
   Projects + Site Surveys - Betki Sales Portal
   ============================================================ */
/* Accent tones for avatars and stage pills; global so pickers outside .prj (survey, quotes) can use them */
:root {
  --tone-blue:   #0071e3;
  --tone-violet: #7a4ee0;
  --tone-amber:  #e08600;
  --tone-teal:   #0d9488;
  --tone-green:  #248a3d;
  --tone-gray:   #8e8e93;
}
.prj {
  --hero-from:   var(--brand-navy-900);
  --hero-to:     var(--brand-navy);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  min-width: 0;
  /* Our wide rows (chips, rails) must not stretch the portal's flex column */
  contain: inline-size;
}
.prj > * { min-width: 0; }
.prj .prj-ico { flex-shrink: 0; vertical-align: -0.15em; }
/* --- Reveal-on-load animation --- */
.js .reveal { opacity: 0; transform: translateY(14px); }
.js .reveal.is-in {
  opacity: 1; transform: none;
  transition: opacity 600ms var(--d, 0ms) cubic-bezier(0.22, 1, 0.36, 1),
              transform 600ms var(--d, 0ms) cubic-bezier(0.22, 1, 0.36, 1);
}

/* --- Hero --- */
.prj-hero {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-6);
  align-items: end;
  padding: var(--space-6);
  border-radius: var(--radius-xl);
  color: #fff;
  background: linear-gradient(135deg, var(--hero-from) 0%, var(--hero-to) 100%);
  box-shadow: var(--shadow-lg);
}
.prj-hero__grid {
  position: absolute; inset: 0; z-index: -1;
  background-image:
    linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse at 80% 20%, #000 0%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse at 80% 20%, #000 0%, transparent 70%);
}
.prj-hero__glow {
  position: absolute; z-index: -1;
  width: 520px; height: 520px; right: -140px; top: -260px;
  background: radial-gradient(circle, color-mix(in srgb, var(--color-primary-600) 55%, transparent) 0%, color-mix(in srgb, var(--brand-navy) 25%, transparent) 40%, transparent 70%);
  filter: blur(10px);
  animation: prj-float 12s ease-in-out infinite alternate;
}
@keyframes prj-float {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(-60px, 40px) scale(1.12); }
}
.prj-hero__art {
  position: absolute; right: 300px; bottom: 26px; width: 200px; z-index: -1;
  color: rgba(255,255,255,0.2);
}
.prj-hero__beam { animation: prj-pulse 2.6s ease-in-out infinite; }
@keyframes prj-pulse { 0%,100% { opacity: .2; } 50% { opacity: 1; } }

.prj-eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: rgba(255,255,255,0.75);
  padding: 5px 12px; border-radius: var(--radius-full);
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.14);
  backdrop-filter: blur(6px);
}
.prj-hero__title {
  font-size: clamp(1.9rem, 1.4rem + 2vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-top: var(--space-3);
  color: #fff;
}
.prj-hero__lead {
  margin: var(--space-2) 0 0; max-width: 560px;
  color: rgba(255,255,255,0.78); font-size: var(--text-lg); line-height: 1.5;
}
.prj-hero__actions { margin-top: var(--space-5); display: flex; gap: var(--space-3); flex-wrap: wrap; }
.prj-hero .btn { display: inline-flex; align-items: center; gap: 8px; }
.prj-btn-glow {
  position: relative;
  box-shadow: 0 8px 24px -6px color-mix(in srgb, var(--color-primary-600) 70%, transparent);
  transition: transform var(--ease-fast), box-shadow var(--ease-fast);
}
.prj-btn-glow:hover { transform: translateY(-2px); box-shadow: 0 14px 30px -6px color-mix(in srgb, var(--color-primary-600) 85%, transparent); }

.prj-hero__stats {
  display: grid; grid-template-columns: repeat(2, minmax(110px, 1fr)); gap: var(--space-3);
}
.prj-stat {
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  backdrop-filter: blur(10px);
  display: flex; flex-direction: column; gap: 2px;
  transition: background var(--ease-base), transform var(--ease-base);
}
.prj-stat:hover { background: rgba(255,255,255,0.12); transform: translateY(-2px); }
.prj-stat__num { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.prj-stat__label { font-size: var(--text-xs); color: rgba(255,255,255,0.65); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }

/* Detail hero */
.prj-hero--detail { align-items: center; }
.prj-hero__meta { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.prj-hero__facts {
  display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5);
  margin-top: var(--space-4); font-size: var(--text-sm); color: rgba(255,255,255,0.8);
}
.prj-hero__facts span { display: inline-flex; align-items: center; gap: 6px; }
/* headline = client, then the project name (site · type); the project number is a small tag */
.prj-hero--detail .prj-hero__title { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.4rem); line-height: 1.15; overflow-wrap: anywhere; }
.prj-hero__project {
  display: flex; align-items: center; gap: 8px; margin-top: 6px;
  font-size: clamp(1.1rem, 0.95rem + 0.7vw, 1.45rem); font-weight: 700; letter-spacing: -0.01em; color: rgba(255,255,255,0.86);
}
.prj-hero__project .prj-ico { flex-shrink: 0; color: rgba(255,255,255,0.65); }
.prj-hero__facts .prj-hero__no {
  padding: 3px 10px; border-radius: var(--radius-full); font-weight: 700; letter-spacing: .02em; font-variant-numeric: tabular-nums;
  color: #fff; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.16);
}
.prj-hero .st { --st-bg: rgba(255,255,255,0.12); --st-fg: #fff; --st-dot: currentColor; }

/* Progress ring */
.prj-ring { position: relative; width: 136px; height: 136px; }
.prj-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.prj-ring circle { fill: none; stroke-width: 9; stroke-linecap: round; }
.prj-ring__bg { stroke: rgba(255,255,255,0.12); }
.prj-ring__fg {
  stroke: var(--color-primary-200);
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--color-primary-200) 70%, transparent));
  transition: stroke-dashoffset 1400ms cubic-bezier(0.22, 1, 0.36, 1);
}
.prj-ring.is-in .prj-ring__fg { stroke-dashoffset: calc(100 - var(--p)); }
.prj-ring__label {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.prj-ring__label strong { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.03em; }
.prj-ring__label span { font-size: var(--text-xs); color: rgba(255,255,255,0.7); }

/* --- Toolbar --- */
.prj-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap;
}
.prj-chips { display: flex; gap: var(--space-2); flex-wrap: wrap; min-width: 0; }
.prj-chip {
  --c: var(--color-neutral-700);
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: var(--radius-full);
  background: var(--panel); border: 1px solid var(--border);
  font-size: var(--text-sm); font-weight: 500; text-decoration: none; color: var(--text);
  transition: all var(--ease-fast);
}
.prj-chip span {
  font-size: 11px; font-weight: 700; min-width: 20px; text-align: center;
  padding: 1px 6px; border-radius: var(--radius-full); background: var(--color-neutral-100); color: var(--muted);
}
.prj-chip:hover { border-color: var(--border2); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.prj-chip--blue   { --c: var(--tone-blue); }
.prj-chip--violet { --c: var(--tone-violet); }
.prj-chip--amber  { --c: var(--tone-amber); }
.prj-chip--teal   { --c: var(--tone-teal); }
.prj-chip--green  { --c: var(--tone-green); }
.prj-chip--gray   { --c: var(--tone-gray); }
.prj-chip.is-on {
  background: var(--c); border-color: var(--c); color: #fff;
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--c) 70%, transparent);
}
.prj-chip.is-on span { background: rgba(255,255,255,0.22); color: #fff; }

.prj-search {
  position: relative; display: flex; align-items: center;
  min-width: 260px; flex: 0 1 340px;
}
.prj-search .prj-ico { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.prj-search input {
  width: 100%; padding: 10px 14px 10px 40px;
  border-radius: var(--radius-full); border: 1px solid var(--border); background: var(--panel);
  font: inherit; font-size: var(--text-sm);
  transition: border-color var(--ease-fast), box-shadow var(--ease-fast);
}
.prj-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }

/* --- Table (desktop) --- */
.prj-table-wrap { padding: var(--space-2) var(--space-4); }
.prj-table td { vertical-align: middle; }
.prj-row { cursor: pointer; transition: background var(--ease-fast); }
.prj-row td:first-child { position: relative; }
.prj-row td:first-child::before {
  content: ""; position: absolute; left: -16px; top: 18%; bottom: 18%; width: 3px; border-radius: 3px;
  background: var(--c, transparent); opacity: 0; transition: opacity var(--ease-fast);
}
.prj-row:hover td:first-child::before { opacity: 1; }
.prj-row--blue { --c: var(--tone-blue); } .prj-row--violet { --c: var(--tone-violet); }
.prj-row--amber { --c: var(--tone-amber); } .prj-row--teal { --c: var(--tone-teal); }
.prj-row--green { --c: var(--tone-green); } .prj-row--gray { --c: var(--tone-gray); }

.prj-cell-main { display: flex; align-items: center; gap: var(--space-3); }
.prj-no { font-weight: 700; text-decoration: none; color: var(--text); letter-spacing: -0.01em; }
.prj-no:hover { color: var(--primary); }
.prj-type, .prj-site { display: flex; align-items: center; gap: 5px; font-size: var(--text-xs); color: var(--muted); margin-top: 2px; }
.prj-client { font-weight: 600; }
.prj-when { color: var(--muted); font-size: var(--text-sm); white-space: nowrap; }
.prj-flag {
  margin-left: 6px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: 2px 6px; border-radius: 6px; background: var(--warning-soft); color: var(--color-warning-700);
}
.prj-go {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  color: var(--muted); background: var(--color-neutral-100);
  transition: all var(--ease-fast);
}
.prj-row:hover .prj-go { background: var(--primary); color: #fff; transform: translateX(3px); }

/* Avatars */
.prj-avatar {
  --c: var(--tone-blue);
  display: inline-grid; place-items: center; flex-shrink: 0;
  width: 38px; height: 38px; border-radius: var(--radius-md);
  font-size: 13px; font-weight: 800; color: #fff; letter-spacing: .02em;
  background: linear-gradient(135deg, color-mix(in srgb, var(--c) 75%, #fff), var(--c));
  box-shadow: 0 6px 14px -6px color-mix(in srgb, var(--c) 80%, transparent);
}
.prj-avatar--lg { width: 48px; height: 48px; border-radius: var(--radius-lg); font-size: 15px; }
.prj-avatar--blue { --c: var(--tone-blue); } .prj-avatar--violet { --c: var(--tone-violet); }
.prj-avatar--amber { --c: var(--tone-amber); } .prj-avatar--teal { --c: var(--tone-teal); }
.prj-avatar--green { --c: var(--tone-green); } .prj-avatar--gray { --c: var(--tone-gray); }

/* Mini progress track */
.prj-mini-track {
  margin-top: 8px; height: 4px; width: 110px; border-radius: 4px; background: var(--color-neutral-200); overflow: hidden;
}
.prj-mini-track span, .prj-bar span {
  display: block; height: 100%; width: var(--p); border-radius: inherit;
  background: linear-gradient(90deg, var(--color-primary-600), var(--brand-navy));
  background-size: 200% 100%;
  animation: prj-sheen 3s linear infinite;
}
@keyframes prj-sheen { from { background-position: 200% 0; } to { background-position: 0 0; } }

/* --- Cards (phone) --- */
.prj-cards { display: none; flex-direction: column; gap: var(--space-3); }
.prj-card {
  --c: var(--tone-blue);
  position: relative; display: block; text-decoration: none; color: var(--text);
  padding: var(--space-4); border-radius: var(--radius-lg); background: var(--panel);
  border: 1px solid var(--border); box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: transform var(--ease-base), box-shadow var(--ease-base);
}
.prj-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c);
}
.prj-card:active { transform: scale(0.98); }
.prj-card--violet { --c: var(--tone-violet); } .prj-card--amber { --c: var(--tone-amber); }
.prj-card--teal { --c: var(--tone-teal); } .prj-card--green { --c: var(--tone-green); }
.prj-card--gray { --c: var(--tone-gray); }
.prj-card__top { display: flex; align-items: center; gap: var(--space-3); }
.prj-card__id { flex: 1; display: flex; flex-direction: column; }
.prj-card__id strong { font-size: var(--text-base); }
.prj-card__id span { font-size: var(--text-xs); color: var(--muted); }
.prj-card__client { margin-top: var(--space-3); font-weight: 700; font-size: var(--text-lg); }
.prj-card__site { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: var(--text-sm); }
.prj-card .prj-mini-track { width: 100%; }
.prj-card__foot {
  display: flex; gap: var(--space-4); margin-top: var(--space-3); padding-top: var(--space-3);
  border-top: 1px dashed var(--border); font-size: var(--text-xs); color: var(--muted);
}
.prj-card__foot span { display: inline-flex; align-items: center; gap: 5px; }

/* --- Empty state --- */
.prj-empty {
  text-align: center; padding: var(--space-8) var(--space-5);
  background: var(--panel); border: 1px dashed var(--border2); border-radius: var(--radius-xl);
}
.prj-empty__art { width: 180px; color: var(--color-primary-600); opacity: .55; animation: prj-bob 4s ease-in-out infinite; }
@keyframes prj-bob { 50% { transform: translateY(-6px); } }
.prj-empty h3 { margin-top: var(--space-3); font-size: var(--text-xl); }
.prj-empty p { color: var(--muted); margin: var(--space-2) 0 var(--space-5); }
.prj-empty .btn { display: inline-flex; align-items: center; gap: 8px; }

/* --- Detail page --- */
.prj-back {
  display: inline-flex; align-items: center; gap: 6px; align-self: flex-start;
  font-size: var(--text-sm); font-weight: 500; color: var(--muted); text-decoration: none;
  transition: color var(--ease-fast), gap var(--ease-fast);
}
.prj-back:hover { color: var(--primary); gap: 10px; }

/* Pipeline */
.prj-pipeline { padding: var(--space-5) var(--space-6); }
.prj-steps {
  position: relative; list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(5, 1fr);
}
.prj-steps::before, .prj-steps::after {
  content: ""; position: absolute; top: 21px; left: 10%; height: 3px; border-radius: 3px;
}
.prj-steps::before { right: 10%; background: var(--color-neutral-200); }
.prj-steps::after {
  width: 0; background: linear-gradient(90deg, var(--color-primary-600), var(--brand-navy), var(--color-success-500));
  transition: width 1400ms cubic-bezier(0.22, 1, 0.36, 1);
}
.prj-pipeline.is-in .prj-steps::after { width: calc(80% * var(--done) / var(--n)); }
.prj-step { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: var(--space-2); text-align: center; }
.prj-step__dot {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: var(--panel); border: 2px solid var(--color-neutral-200); color: var(--color-neutral-400);
  transition: all var(--ease-spring);
}
.prj-step__label { font-size: var(--text-xs); font-weight: 600; color: var(--muted); }
.prj-step.is-done .prj-step__dot { background: var(--color-primary-600); border-color: var(--color-primary-600); color: #fff; }
.prj-step.is-current .prj-step__dot {
  background: linear-gradient(135deg, var(--color-primary-600), var(--brand-navy)); border-color: transparent; color: #fff;
  transform: scale(1.12);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--color-primary-600) 15%, transparent), 0 10px 24px -8px color-mix(in srgb, var(--brand-navy) 70%, transparent);
  animation: prj-halo 2.4s ease-in-out infinite;
}
@keyframes prj-halo {
  50% { box-shadow: 0 0 0 11px color-mix(in srgb, var(--color-primary-600) 6%, transparent), 0 10px 24px -8px color-mix(in srgb, var(--brand-navy) 70%, transparent); }
}
.prj-step.is-current .prj-step__label { color: var(--text); }
.prj-pipeline.is-cancelled .prj-steps { opacity: .45; filter: grayscale(1); }
.prj-pipeline__foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap;
  margin-top: var(--space-5); padding-top: var(--space-4); border-top: 1px solid var(--border);
}
.prj-pipeline__hint { margin: 0; display: inline-flex; align-items: center; gap: 8px; font-size: var(--text-sm); color: var(--muted); }
.prj-pipeline__hint .prj-ico { color: var(--tone-violet); }
.prj-stage-form { display: flex; gap: var(--space-2); align-items: center; }
.prj-stage-form select {
  padding: 7px 12px; border-radius: var(--radius-full); border: 1px solid var(--border);
  font: inherit; font-size: var(--text-sm); background: var(--panel);
}

/* Two-column layout */
.prj-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--space-5); align-items: start; }
.prj-main { display: flex; flex-direction: column; gap: var(--space-5); }
.prj-aside { display: flex; flex-direction: column; gap: var(--space-4); position: sticky; top: calc(var(--header-h) + var(--space-4)); }

.prj-section {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-xl);
  padding: var(--space-5); box-shadow: var(--shadow-card);
  transition: box-shadow var(--ease-base);
}
.prj-section:hover { box-shadow: var(--shadow-card-hover); }
.prj-section__head { display: flex; align-items: center; gap: var(--space-3); }
.prj-section__head > div { flex: 1; min-width: 0; }
.prj-section__head h3 { font-size: var(--text-lg); font-weight: 700; }
.prj-section__head p { margin: 2px 0 0; color: var(--muted); font-size: var(--text-sm); }
.prj-section__head .btn { display: inline-flex; align-items: center; gap: 6px; }
.prj-section__icon {
  --c: var(--tone-blue);
  width: 42px; height: 42px; border-radius: var(--radius-md); display: grid; place-items: center; flex-shrink: 0;
  color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent);
}
.prj-section__icon--teal { --c: var(--tone-teal); }
.prj-section__icon--violet { --c: var(--tone-violet); }
.prj-section__empty {
  margin-top: var(--space-4); padding: var(--space-4); border-radius: var(--radius-md);
  background: var(--color-neutral-50); border: 1px dashed var(--border2);
  color: var(--muted); font-size: var(--text-sm);
}

.prj-list { list-style: none; margin: var(--space-4) 0 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.prj-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3); border-radius: var(--radius-lg); border: 1px solid transparent;
  transition: background var(--ease-fast), border-color var(--ease-fast), transform var(--ease-fast);
}
.prj-item:hover { background: var(--color-neutral-50); border-color: var(--border); transform: translateX(2px); }
.prj-item__badge {
  width: 40px; height: 40px; border-radius: var(--radius-md); display: grid; place-items: center; flex-shrink: 0;
}
.prj-item__badge.is-draft { background: var(--warning-soft); color: var(--color-warning-700); }
.prj-item__badge.is-done  { background: var(--success-soft); color: var(--color-success-700); }
.prj-item__badge.is-wo    { background: color-mix(in srgb, var(--tone-teal) 12%, transparent); color: var(--tone-teal); }
.prj-item__body { flex: 1; min-width: 0; }
.prj-item__title { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.prj-item__title a { font-weight: 700; text-decoration: none; color: var(--text); }
.prj-item__title a:hover { color: var(--primary); }
.prj-item__meta { font-size: var(--text-xs); color: var(--muted); margin-top: 2px; }
.prj-bar { margin-top: 8px; height: 5px; border-radius: 5px; background: var(--color-neutral-200); overflow: hidden; max-width: 260px; }

.prj-soon {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  padding: 5px 10px; border-radius: var(--radius-full);
  color: var(--tone-violet); background: color-mix(in srgb, var(--tone-violet) 10%, transparent);
}
/* Aside cards */
.prj-card-plain {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-xl);
  padding: var(--space-4) var(--space-5); box-shadow: var(--shadow-card);
}
.prj-aside__head { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-3); }
.prj-aside__head strong { display: block; font-size: var(--text-base); }
.prj-aside__head div span { font-size: var(--text-xs); color: var(--muted); }
.prj-aside__title {
  font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); margin-bottom: var(--space-2);
}
.prj-dl { margin: 0; display: flex; flex-direction: column; }
.prj-dl > div { display: flex; justify-content: space-between; gap: var(--space-3); padding: 8px 0; border-bottom: 1px solid var(--color-neutral-100); }
.prj-dl > div:last-child { border-bottom: 0; }
.prj-dl dt { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--text-sm); }
.prj-dl dd { margin: 0; text-align: right; font-size: var(--text-sm); font-weight: 500; word-break: break-word; }
.prj-dl a { color: var(--primary); text-decoration: none; }

/* --- Work order link chip (on work order pages) --- */
.prj-link-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: 600; text-decoration: none;
  color: var(--color-primary-800); background: var(--primary-soft);
  transition: background var(--ease-fast);
}
.prj-link-chip:hover { background: var(--color-primary-200); }
.prj-context {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); margin-bottom: var(--space-4); border-radius: var(--radius-lg);
  background: linear-gradient(90deg, var(--primary-soft), transparent);
  border: 1px solid var(--color-primary-200); font-size: var(--text-sm);
}

/* --- Responsive --- */
@media (max-width: 1100px) {
  .prj-hero__art { display: none; }
  .prj-layout { grid-template-columns: 1fr; }
  .prj-aside { position: static; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
}
@media (max-width: 900px) {
  .prj-hero { grid-template-columns: minmax(0, 1fr); }
  .prj-hero__stats { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 768px) {
  .prj { gap: var(--space-4); }
  .prj-hero { padding: var(--space-5); border-radius: var(--radius-xl); gap: var(--space-5); }
  .prj-hero__art { display: none; }
  .prj-hero__stats { grid-template-columns: repeat(2, 1fr); }
  .prj-hero--detail .prj-hero__side { display: flex; justify-content: center; }
  .prj-ring { width: 116px; height: 116px; }
  .prj-table-wrap { display: none; }
  .prj-cards { display: flex; }
  .prj-search { flex: 1 1 100%; min-width: 0; }
  .prj-chips { flex: 1 1 100%; width: 0; min-width: 100%; box-sizing: content-box; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; margin: 0 calc(-1 * var(--space-4)); padding-left: var(--space-4); padding-right: var(--space-4); }
  .prj-chips::-webkit-scrollbar { display: none; }
  .prj-chip { flex-shrink: 0; }
  .prj-pipeline { padding: var(--space-4); }
  .prj-step__dot { width: 36px; height: 36px; }
  .prj-step__dot .prj-ico { width: 15px; height: 15px; }
  .prj-steps::before, .prj-steps::after { top: 17px; }
  .prj-step__label { font-size: 10px; }
  .prj-stage-form { width: 100%; }
  .prj-stage-form select { flex: 1; }
  .prj-section { padding: var(--space-4); border-radius: var(--radius-lg); }
  .prj-section__head { flex-wrap: wrap; }
  .prj-section__head .btn { width: 100%; justify-content: center; }
  .prj-item { flex-wrap: wrap; }
  .prj-item__actions { width: 100%; }
  .prj-item__actions .btn { width: 100%; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  .prj *, .prj *::before, .prj *::after { animation: none !important; transition: none !important; }
  .js .reveal { opacity: 1; transform: none; }
  .prj-ring__fg { stroke-dashoffset: calc(100 - var(--p)); }
  .prj-steps::after { width: calc(80% * var(--done) / var(--n)); }
}
@media print {
  .prj-hero { box-shadow: none; }
  .js .reveal { opacity: 1 !important; transform: none !important; }
}

/* --- Equipment catalog --- */
.cat-select {
  width: 100%; min-height: 48px; padding: 12px 14px; font: inherit; font-size: 16px; color: var(--text);
  background: var(--panel); border: 1.5px solid var(--border); border-radius: var(--radius-md);
}
.cat-select:focus { outline: none; border-color: var(--color-primary-600); box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-primary-600) 14%, transparent); }
.cat-edit .prj-section[hidden], .cat-edit .svy-f[hidden] { display: none; }
.cat-check { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.cat-check input { width: 20px; height: 20px; min-height: 0; }
.cat-name { font-weight: 700; }
.cat-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 3px; font-size: var(--text-xs); color: var(--muted); }
.cat-badge { display: inline-block; padding: 2px 8px; border-radius: var(--radius-full); font-size: 11px; font-weight: 700; background: var(--color-neutral-100); color: var(--muted); }
.cat-badge--warn { background: var(--tone-warning-bg); color: var(--color-warning-700); }
.cat-badge--ok { background: var(--tone-success-bg); color: var(--color-success-700); }
.cat-badge--off { background: var(--tone-danger-bg); color: var(--color-danger-700); }
.cat-specs { font-size: var(--text-sm); color: var(--muted); }
.cat-none { font-size: var(--text-xs); color: var(--color-warning-700); font-style: italic; }
.cat-table tr.is-off td { opacity: .5; }

/* --- Power design assistant --- */
.pd-layout { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: var(--space-5); align-items: start; margin-top: var(--space-4); }
.pd-inputs { position: sticky; top: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.pd-inputs .prj-section { margin: 0; }
.pd-inputs .svy-grid { margin-top: var(--space-3); }
.pd-actions { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
.pd-status { font-size: var(--text-xs); color: var(--muted); text-align: center; min-height: 1em; }
.pd-result { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
.pd-result--full { margin-top: var(--space-4); }
.pd-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--space-3); }
.pd-card { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--radius-lg); background: var(--panel); border: 1px solid var(--border); box-shadow: var(--shadow-card); }
.pd-card__ic { width: 40px; height: 40px; flex-shrink: 0; display: grid; place-items: center; border-radius: var(--radius-md); color: #fff; background: linear-gradient(135deg, var(--color-primary-600), var(--brand-navy)); }
.pd-card__k { display: block; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.pd-card strong { display: block; font-size: var(--text-base); line-height: 1.3; margin-top: 2px; }
.pd-card small { display: block; color: var(--muted); font-size: var(--text-xs); margin-top: 2px; }
.pd-block { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-4) var(--space-5); }
.pd-block h4 { display: flex; align-items: center; gap: 10px; font-size: var(--text-sm); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--color-primary-800); margin-bottom: var(--space-3); }
.pd-why { margin: 0; padding-left: 1.2em; line-height: 1.6; font-size: var(--text-sm); }
.pd-why li + li { margin-top: 4px; }
.pd-alt { margin-top: var(--space-3); font-size: var(--text-sm); }
.pd-alt summary { cursor: pointer; font-weight: 600; color: var(--color-primary-600); }
.pd-alt ul { margin: 6px 0 0; padding-left: 1.2em; color: var(--muted); }
.pd-pill { font-size: 11px; padding: 2px 9px; border-radius: var(--radius-full); letter-spacing: 0; text-transform: none; }
.pd-pill--red { background: var(--tone-danger-bg); color: var(--color-danger-700); }
.pd-pill--green { background: var(--tone-success-bg); color: var(--color-success-700); }
.pd-checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.pd-check { display: flex; flex-wrap: wrap; gap: 10px; align-items: baseline; padding: 8px 12px; border-radius: var(--radius-sm); font-size: var(--text-sm); border-left: 4px solid var(--border); background: var(--color-neutral-50); }
.pd-check__lv { flex-shrink: 0; min-width: 72px; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.pd-check__txt { flex: 1; min-width: 200px; }
.pd-check__txt small { color: var(--muted); font-weight: 700; }
.pd-check--red { border-left-color: var(--color-danger-500); background: var(--color-danger-50); } .pd-check--red .pd-check__lv { color: var(--color-danger-700); }
.pd-check--amber { border-left-color: var(--color-warning-500); background: var(--color-warning-50); } .pd-check--amber .pd-check__lv { color: var(--color-warning-700); }
.pd-check--signed { border-left-color: var(--brand-navy); } .pd-check--signed .pd-check__lv { color: var(--brand-navy); }
.pd-check--green { border-left-color: var(--color-success-500); } .pd-check--green .pd-check__lv { color: var(--color-success-700); }
.pd-signoff { flex-basis: 100%; display: flex; gap: 8px; }
.pd-signoff input { flex: 1; min-height: 36px; padding: 6px 10px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font: inherit; }
.pd-bom td { vertical-align: top; }
.pd-bom__grp td { background: var(--color-neutral-50); font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding-top: 10px; }
.pd-bom__name { font-weight: 600; }
.pd-bom__why { font-size: var(--text-xs); color: var(--muted); margin-top: 2px; }
.pd-bom tr.is-missing .pd-bom__name { color: var(--color-warning-700); }
.pd-bom tfoot td { font-weight: 700; border-top: 2px solid var(--border); }
.pd-needs { padding: 14px 16px; border-radius: var(--radius-lg); background: var(--tone-warning-bg); border: 1px solid #f6d49a; color: var(--color-warning-700); font-size: var(--text-sm); }
.pd-needs strong { display: flex; align-items: center; gap: 8px; }
.pd-needs ul { margin: 8px 0 0; padding-left: 1.2em; } .pd-needs li + li { margin-top: 4px; }
.pd-needs a { font-weight: 700; margin-left: 6px; }
.pd-start { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-3); padding: 12px 14px; border-radius: var(--radius-md); border: 1.5px dashed color-mix(in srgb, var(--brand-navy) 35%, transparent); background: var(--brand-navy-50); }
.pd-start span { display: flex; align-items: center; gap: 8px; font-weight: 600; }
@media (max-width: 1024px) {
  .pd-layout { grid-template-columns: 1fr; }
  .pd-inputs { position: static; }
}
.cat-missbox { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius-lg); background: var(--color-danger-50); border: 1px solid #f4c3bf; color: var(--color-danger-700); font-size: var(--text-sm); margin-bottom: var(--space-3); }
.cat-edit .svy-f.is-missing input, .cat-edit .svy-f.is-missing select { border-color: var(--color-danger-500); background: var(--color-danger-50); box-shadow: 0 0 0 3px var(--tone-danger-bg); }
.cat-edit .svy-f.is-missing > label { color: var(--color-danger-700); }
.cat-miss { font-size: var(--text-xs); font-weight: 700; color: var(--color-danger-700); }
.cat-sub-sec { margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px dashed var(--border); }
.cat-sub-sec[hidden] { display: none; }
.cat-sub-sec h4 { font-size: var(--text-sm); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--color-primary-800); }
.cat-sub-sec > p { font-size: var(--text-xs); color: var(--muted); margin: 2px 0 0; }
.cat-maker summary { cursor: pointer; font-weight: 700; font-size: var(--text-sm); }
.cat-maker summary span { font-weight: 500; color: var(--muted); font-size: var(--text-xs); margin-left: 6px; }
.cat-edit [data-kind][hidden] { display: none; }
.cat-nospec { grid-column: 1 / -1; margin: var(--space-3) 0 0; }

/* ==== survey.css ==== */
/* ============================================================
   Site Survey (start, form, view) - Betki Sales Portal
   Builds on projects.css (.prj-* tokens, hero, sections).
   ============================================================ */
.svy, .svy-start, .svy-view { --svy-accent: var(--color-primary-600); --svy-accent2: var(--brand-navy); }

/* --- Form layout: titled groups, each a 12-column grid --- */
.svy-form { display: flex; flex-direction: column; gap: var(--space-4); margin-top: var(--space-5); }
.svy-group { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--panel); padding: var(--space-4) var(--space-5) var(--space-5); }
.svy-group[hidden] { display: none; }
.svy-group--plain { border: 0; padding: 0; background: none; }
.svy-group__head { display: flex; align-items: baseline; gap: 10px; margin-bottom: var(--space-4); padding-bottom: var(--space-3); border-bottom: 1px solid var(--border); }
.svy-group__head h4 { font-size: var(--text-sm); font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--color-primary-800); }
.svy-group__head span { font-size: var(--text-xs); color: var(--muted); }
.svy-group__grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--space-4) var(--space-4); align-items: start; }
.svy-group__grid > * { grid-column: 1 / -1; min-width: 0; }
.svy-group__grid > .svy-f--half { grid-column: span 6; }
.svy-group__grid > .svy-f--third { grid-column: span 4; }
.svy-group__grid > .svy-f--quarter { grid-column: span 3; }
/* inside the item popup the groups are flatter: a divider and a title */
.svy-dlg__body > .svy-group { border: 0; border-radius: 0; padding: 0; background: none; }
.svy-dlg__body > .svy-group + .svy-group { border-top: 1px dashed var(--border); padding-top: var(--space-4); }
.svy-dlg__body > .svy-group .svy-group__head { border-bottom: 0; padding-bottom: 0; margin-bottom: var(--space-3); }
.svy-dlg__body > .svy-group .svy-group__head h4 { color: var(--muted); font-size: var(--text-xs); }

/* --- Shared inputs --- */
.svy-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--space-4); margin-top: var(--space-4); }
.svy-grid > * { grid-column: 1 / -1; min-width: 0; }
.svy-grid > .svy-f--half { grid-column: span 3; }
.svy-grid > .svy-f--third { grid-column: span 2; }
.svy-f { display: flex; flex-direction: column; gap: 6px; }
.svy-f[hidden] { display: none; }
.svy-f > label { font-size: var(--text-sm); font-weight: 600; color: var(--text); }
.svy-f.is-req > label::after { content: " *"; color: var(--color-warning-700); }
.svy-f input, .svy-f textarea, .svy-start input:not([type=radio]), .svy-start textarea {
  width: 100%; min-height: 48px; padding: 12px 14px;
  font: inherit; font-size: 16px; /* 16px stops iOS zooming on focus */
  color: var(--text); background: var(--panel);
  border: 1.5px solid var(--border); border-radius: var(--radius-md);
  transition: border-color var(--ease-fast), box-shadow var(--ease-fast), background var(--ease-fast);
}
.svy-f textarea, .svy-start textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
.svy-f input:focus, .svy-f textarea:focus, .svy-start input:not([type=radio]):focus, .svy-start textarea:focus {
  outline: none; border-color: var(--svy-accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-primary-600) 14%, transparent);
}
.svy-start input[type=radio] { position: absolute; width: 1px; height: 1px; margin: 0; padding: 0; opacity: 0; pointer-events: none; }
.svy-start .prj-search input { padding-left: 40px; border-radius: var(--radius-full); }
.svy-hint { font-size: var(--text-xs); color: var(--muted); line-height: 1.45; }
.svy-hint--wide { flex-basis: 100%; }
.svy-unit { position: relative; display: flex; }
.svy-unit input { padding-right: 52px; }
.svy-unit span {
  position: absolute; right: 6px; top: 6px; bottom: 6px; display: grid; place-items: center;
  padding: 0 10px; border-radius: var(--radius-xs); font-size: var(--text-xs); font-weight: 700; color: var(--muted);
  background: var(--color-neutral-100);
}
.svy-computed {
  min-height: 48px; display: flex; align-items: center; padding: 0 14px; border-radius: var(--radius-md);
  font-weight: 800; font-size: var(--text-lg); letter-spacing: -0.01em; font-variant-numeric: tabular-nums;
  color: var(--color-primary-800);
  background: linear-gradient(135deg, color-mix(in srgb, var(--color-primary-600) 8%, transparent), color-mix(in srgb, var(--brand-navy) 8%, transparent));
  border: 1.5px dashed color-mix(in srgb, var(--color-primary-600) 30%, transparent);
}
.svy-computed.is-neg { color: var(--color-danger-700); background: var(--danger-soft); border-color: color-mix(in srgb, var(--color-danger-500) 35%, transparent); }

/* Choice buttons: plain-language, big tap targets */
/* Choice buttons sit on an even grid; up to 3 options become a segmented control */
.svy-opts { display: grid; gap: 8px; }
.svy-opts--many { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.svy-opts--few { grid-template-columns: repeat(var(--n, 2), minmax(0, 1fr)); max-width: 560px; }
.svy-opts .svy-hint--wide { grid-column: 1 / -1; }
.svy-opt {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  min-height: 46px; padding: 10px 16px 10px 12px;
  font: inherit; font-size: var(--text-sm); font-weight: 600; text-align: left; color: var(--text);
  background: var(--panel); border: 1.5px solid var(--border); border-radius: var(--radius-lg); cursor: pointer;
  transition: transform var(--ease-fast), border-color var(--ease-fast), background var(--ease-fast), box-shadow var(--ease-fast);
  -webkit-tap-highlight-color: transparent;
}
.svy-opt:hover { border-color: var(--border2); transform: translateY(-1px); }
.svy-opt:active { transform: scale(0.97); }
.svy-opt:focus-visible { outline: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-primary-600) 20%, transparent); }
.svy-opt__tick {
  width: 22px; height: 22px; flex-shrink: 0; display: grid; place-items: center; border-radius: var(--radius-xs);
  border: 1.5px solid var(--border2); color: transparent; transition: all var(--ease-fast);
}
.svy-opt__txt { display: flex; flex-direction: column; line-height: 1.25; }
.svy-opt__txt small { font-weight: 500; font-size: 11px; color: var(--muted); }
.svy-opt.is-on {
  border-color: var(--svy-accent); color: var(--color-primary-800);
  background: linear-gradient(135deg, color-mix(in srgb, var(--color-primary-600) 8%, transparent), color-mix(in srgb, var(--brand-navy) 6%, transparent));
  box-shadow: 0 6px 16px -10px color-mix(in srgb, var(--color-primary-600) 80%, transparent);
}
.svy-opt.is-on .svy-opt__tick {
  border-color: transparent; color: #fff;
  background: linear-gradient(135deg, var(--svy-accent), var(--svy-accent2));
  animation: svy-pop 260ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes svy-pop { from { transform: scale(0.4); } }
.svy-opt--add { border-style: dashed; color: var(--svy-accent); }
.svy-opt--add .prj-ico { margin-right: -2px; }

/* --- Start screen --- */
.prj-hero--compact { padding: var(--space-5) var(--space-6); }
.prj-hero--compact .prj-hero__title { font-size: clamp(1.6rem, 1.3rem + 1.5vw, 2.2rem); }
.svy-start__form { display: flex; flex-direction: column; gap: var(--space-5); }
.svy-seg {
  display: inline-flex; padding: 4px; margin-top: var(--space-4); gap: 4px;
  background: var(--color-neutral-100); border-radius: var(--radius-full);
}
.svy-seg__opt {
  position: relative; padding: 9px 18px; border-radius: var(--radius-full);
  font-size: var(--text-sm); font-weight: 600; color: var(--muted); cursor: pointer; transition: all var(--ease-fast);
}
.svy-seg__opt input { position: absolute; opacity: 0; pointer-events: none; }
.svy-seg__opt:has(input:checked) { background: var(--panel); color: var(--text); box-shadow: var(--shadow-sm); }
.svy-seg__opt:has(input:focus-visible) { box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary-600) 25%, transparent); }
.svy-pane { margin-top: var(--space-4); }
.svy-pane[hidden] { display: none; }
/* Client dropdown (native <select> underneath; enhanced when JS runs) */
.svy-combo { position: relative; }
.svy-combo__native {
  width: 100%; min-height: 48px; padding: 10px 14px; font: inherit; font-size: 16px;
  border: 1.5px solid var(--border); border-radius: var(--radius-md); background: var(--panel);
}
.js .svy-combo__native { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; border: 0; opacity: 0; pointer-events: none; }
.svy-combo__btn {
  width: 100%; min-height: 58px; display: flex; align-items: center; gap: var(--space-3);
  padding: 8px 14px 8px 10px; font: inherit; text-align: left; color: var(--text); cursor: pointer;
  background: var(--panel); border: 1.5px solid var(--border); border-radius: var(--radius-lg);
  transition: border-color var(--ease-fast), box-shadow var(--ease-fast);
}
.svy-combo__btn:hover { border-color: var(--border2); }
.svy-combo__btn:focus-visible, .svy-combo.is-open .svy-combo__btn { outline: none; border-color: var(--svy-accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-primary-600) 14%, transparent); }
.svy-combo__ph { flex: 1; padding-left: 4px; color: var(--muted); font-size: 16px; }
.svy-combo__txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.svy-combo__txt strong { font-size: var(--text-sm); }
.svy-combo__txt small { font-size: var(--text-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.svy-combo__chev { flex-shrink: 0; color: var(--muted); transition: transform var(--ease-base); }
.svy-combo.is-open .svy-combo__chev { transform: rotate(180deg); }
.svy-combo__panel {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 6px);
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); overflow: hidden;
  animation: svy-drop 180ms cubic-bezier(0.22, 1, 0.36, 1);
}
.svy-combo__panel[hidden] { display: none; }
@keyframes svy-drop { from { opacity: 0; transform: translateY(-6px); } }
.svy-combo__search { position: relative; display: flex; align-items: center; padding: 10px; border-bottom: 1px solid var(--border); }
.svy-combo__search svg { position: absolute; left: 22px; color: var(--muted); pointer-events: none; }
.svy-start .svy-combo__search input { min-height: 42px; padding: 8px 12px 8px 36px; border-radius: var(--radius-sm); }
.svy-combo__list { list-style: none; margin: 0; padding: 6px; max-height: 300px; overflow-y: auto; overscroll-behavior: contain; }
.svy-combo__opt {
  display: flex; align-items: center; gap: var(--space-3); padding: 8px 10px; min-height: 52px;
  border-radius: var(--radius-md); cursor: pointer; transition: background var(--ease-fast);
}
.svy-combo__opt:hover, .svy-combo__opt.is-active { background: var(--color-neutral-100); }
.svy-combo__opt.is-sel { background: color-mix(in srgb, var(--color-primary-600) 8%, transparent); }
.svy-combo__opt .prj-avatar, .svy-combo__btn .prj-avatar { width: 34px; height: 34px; border-radius: var(--radius-sm); font-size: 12px; }
.svy-combo__none { padding: var(--space-4); text-align: center; color: var(--muted); font-size: var(--text-sm); }
.svy-combo__none[hidden] { display: none; }
.svy-linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--svy-accent); font-weight: 600; cursor: pointer; text-decoration: underline; }

.svy-types { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); margin-top: var(--space-4); }
.svy-type {
  position: relative; display: flex; flex-direction: column; gap: 4px; padding: var(--space-4);
  border: 1.5px solid var(--border); border-radius: var(--radius-lg); cursor: pointer; transition: all var(--ease-base);
}
.svy-type input { position: absolute; opacity: 0; pointer-events: none; }
.svy-type__icon {
  width: 44px; height: 44px; border-radius: var(--radius-md); display: grid; place-items: center; margin-bottom: var(--space-2);
  color: var(--svy-accent); background: color-mix(in srgb, var(--color-primary-600) 10%, transparent);
}
.svy-type strong { font-size: var(--text-base); }
.svy-type small { color: var(--muted); font-size: var(--text-xs); }
.svy-type .prj-soon { position: absolute; top: 12px; right: 12px; }
.svy-type:has(input:checked) {
  border-color: transparent;
  background: linear-gradient(var(--panel), var(--panel)) padding-box,
              linear-gradient(135deg, var(--svy-accent), var(--svy-accent2)) border-box;
  box-shadow: 0 12px 28px -16px color-mix(in srgb, var(--brand-navy) 60%, transparent);
}
.svy-type:has(input:checked) .svy-type__icon { color: #fff; background: linear-gradient(135deg, var(--svy-accent), var(--svy-accent2)); }
.svy-type.is-off { cursor: not-allowed; opacity: .55; }
.svy-start__go { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }
.svy-start__go p { margin: 0; }
.svy-big { min-height: 52px; padding: 0 28px; font-size: var(--text-base); display: inline-flex; align-items: center; gap: 10px; }
.btn.is-busy { opacity: .7; pointer-events: none; }
.prj-section__icon--amber { --c: var(--tone-amber); }

/* --- Form shell --- */
.svy { width: 100%; max-width: 1080px; margin-inline: auto; padding-bottom: 110px; contain: inline-size; }
.svy-top { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.svy-top__title { display: flex; flex-direction: column; margin-top: 4px; }
.svy-top__title strong { font-size: var(--text-xl); letter-spacing: -0.02em; }
.svy-top__title span { font-size: var(--text-sm); color: var(--muted); }
.svy-save {
  display: inline-flex; align-items: center; gap: 8px; flex-shrink: 0;
  padding: 6px 12px; border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: 600;
  background: var(--panel); border: 1px solid var(--border); color: var(--muted);
}
.svy-save__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-success-500); }
.svy-save.is-dirty .svy-save__dot { background: var(--color-warning-500); }
.svy-save.is-busy .svy-save__dot { background: var(--svy-accent); animation: prj-blink 0.8s ease-in-out infinite; }
.svy-save.is-err { color: var(--color-danger-700); border-color: color-mix(in srgb, var(--color-danger-500) 30%, transparent); background: var(--danger-soft); }
.svy-save.is-err .svy-save__dot { background: var(--color-danger-500); }

.svy-rail {
  display: flex; gap: 6px; overflow-x: auto; scroll-behavior: smooth; scrollbar-width: none;
  padding: 4px 2px 10px; margin: 0 -2px;
}
.svy-rail::-webkit-scrollbar { display: none; }
.svy-rail__step {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px 6px 6px; border-radius: var(--radius-full);
  font: inherit; font-size: var(--text-xs); font-weight: 600; color: var(--muted);
  background: var(--panel); border: 1px solid var(--border); cursor: pointer; transition: all var(--ease-fast);
}
.svy-rail__dot {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--color-neutral-100); color: var(--color-neutral-500); transition: all var(--ease-base);
}
.svy-rail__step.is-past .svy-rail__dot { background: color-mix(in srgb, var(--color-primary-600) 12%, transparent); color: var(--svy-accent); }
.svy-rail__step.has-gaps .svy-rail__dot { background: var(--warning-soft); color: var(--color-warning-700); }
.svy-rail__step.is-current {
  color: #fff; border-color: transparent;
  background: linear-gradient(135deg, var(--svy-accent), var(--svy-accent2));
  box-shadow: 0 8px 20px -10px color-mix(in srgb, var(--brand-navy) 80%, transparent);
}
.svy-rail__step.is-current .svy-rail__dot { background: rgba(255,255,255,0.2); color: #fff; }
.svy-progress { height: 4px; border-radius: 4px; background: var(--color-neutral-200); overflow: hidden; margin-bottom: var(--space-5); }
.svy-progress span {
  display: block; height: 100%; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, var(--svy-accent), var(--svy-accent2), var(--color-success-500));
  transition: width 600ms cubic-bezier(0.22, 1, 0.36, 1);
}

.svy-stage:focus { outline: none; }
.svy-pane-step {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-xl);
  padding: var(--space-6); box-shadow: var(--shadow-card);
}
.svy-pane-step.in-right { animation: svy-in-right 420ms cubic-bezier(0.22, 1, 0.36, 1); }
.svy-pane-step.in-left  { animation: svy-in-left 420ms cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes svy-in-right { from { opacity: 0; transform: translateX(28px); } }
@keyframes svy-in-left  { from { opacity: 0; transform: translateX(-28px); } }

.svy-head { display: flex; gap: var(--space-4); align-items: flex-start; }
.svy-head__icon {
  width: 52px; height: 52px; border-radius: var(--radius-lg); flex-shrink: 0; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--svy-accent), var(--svy-accent2));
  box-shadow: 0 12px 26px -12px color-mix(in srgb, var(--brand-navy) 90%, transparent);
}
.svy-head__kicker { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--svy-accent2); }
.svy-head h2 { font-size: var(--text-2xl); font-weight: 800; letter-spacing: -0.02em; margin-top: 2px; }
.svy-head p { margin: 4px 0 0; color: var(--muted); font-size: var(--text-sm); line-height: 1.5; }

.svy-h { display: flex; align-items: baseline; gap: 10px; padding-top: var(--space-3); margin-top: var(--space-2); border-top: 1px solid var(--border); }
.svy-h h4 { font-size: var(--text-base); font-weight: 700; }
.svy-h span { font-size: var(--text-xs); color: var(--muted); padding: 2px 8px; border-radius: var(--radius-xs); background: var(--color-neutral-100); }
.svy-grid > .svy-h:first-child { border-top: 0; padding-top: 0; margin-top: 0; }

.svy-info { border-radius: var(--radius-lg); padding: var(--space-4) var(--space-5); font-size: var(--text-sm); line-height: 1.55; }
.svy-info--amber { background: var(--color-warning-50); border: 1px solid #f6d49a; color: var(--color-warning-700); }
.svy-info--blue { background: color-mix(in srgb, var(--color-primary-600) 6%, transparent); border: 1px solid color-mix(in srgb, var(--color-primary-600) 18%, transparent); color: var(--color-primary-800); }
.svy-info__head { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 6px; }
.svy-info ol { margin: 0; padding-left: 1.3em; }
.svy-info li + li { margin-top: 4px; }

/* Warnings: inform, never block */
.svy-step-warn:empty, .svy-card-warn:empty { display: none; }
.svy-step-warn, .svy-card-warn { display: flex; flex-direction: column; gap: 8px; margin-top: var(--space-4); }
.svy-warn {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-lg);
  font-size: var(--text-sm); line-height: 1.45; color: var(--color-warning-700);
  background: linear-gradient(135deg, var(--tone-warning-bg), var(--color-warning-50)); border: 1px solid #f6d49a;
  animation: svy-shake 420ms ease;
}
.svy-warn .prj-ico { color: var(--color-warning-500); margin-top: 1px; }
@keyframes svy-shake { 20% { transform: translateX(-3px); } 40% { transform: translateX(3px); } 60% { transform: translateX(-2px); } 80% { transform: translateX(1px); } }

/* Repeat items: a compact row each; the answers are filled in through the popup */
.svy-repeat { display: flex; flex-direction: column; gap: var(--space-3); }
.svy-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr)); gap: var(--space-2) var(--space-3); }
.svy-items__empty { grid-column: 1 / -1; padding: var(--space-4); text-align: center; font-size: var(--text-sm); color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius-lg); }
.svy-item {
  display: flex; align-items: center; gap: 4px; padding-right: 4px; min-width: 0;
  border: 1.5px solid var(--border); border-radius: var(--radius-lg); background: var(--panel);
  transition: border-color var(--ease-fast), box-shadow var(--ease-fast), transform var(--ease-fast);
}
.svy-item:hover { border-color: color-mix(in srgb, var(--color-primary-600) 40%, transparent); box-shadow: 0 8px 22px -16px color-mix(in srgb, var(--color-primary-600) 70%, transparent); }
.svy-item.has-gaps { border-left: 4px solid var(--color-warning-500); }
.svy-item.is-new { animation: svy-card-in 520ms cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes svy-card-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.svy-item__open {
  flex: 1; min-width: 0; min-height: 60px; display: flex; align-items: center; gap: var(--space-3);
  padding: 8px 6px 8px 12px; font: inherit; text-align: left; color: var(--text);
  background: none; border: 0; border-radius: var(--radius-lg); cursor: pointer;
}
.svy-item__open:focus-visible { outline: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-primary-600) 20%, transparent); }
.svy-item__txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.svy-item__name { font-size: var(--text-sm); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.svy-item__sum { font-size: var(--text-xs); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.svy-item__sum:empty { display: none; }
.svy-item__status { display: flex; gap: 4px; flex-shrink: 0; }
.svy-pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: var(--radius-full);
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.svy-pill--ok { background: var(--success-soft); color: var(--color-success-700); }
.svy-pill--gap { background: var(--warning-soft); color: var(--color-warning-700); }
.svy-pill--warn { background: var(--color-warning-50); color: var(--color-warning-700); border: 1px solid #f6d49a; }
.svy-card__no {
  flex-shrink: 0; min-width: 44px; padding: 5px 8px; border-radius: var(--radius-sm); text-align: center;
  font-size: var(--text-xs); font-weight: 800; letter-spacing: .03em; color: #fff;
  background: linear-gradient(135deg, var(--svy-accent), var(--svy-accent2));
}

/* Item popup: a wide dialog on desktop, a full-screen sheet on phones */
html.svy-dlg-open { overflow: hidden; }
.modal.svy-dlg {
  width: min(820px, calc(100vw - 32px)); max-width: none; max-height: calc(100dvh - 48px);
  background: var(--panel); color: var(--text); overflow: hidden;
}
.svy-dlg[open] { display: flex; flex-direction: column; animation: svy-dlg-in 260ms cubic-bezier(0.22, 1, 0.36, 1); }
.svy-dlg[open]::backdrop { animation: svy-fade 200ms ease; }
@keyframes svy-dlg-in { from { opacity: 0; transform: translateY(16px) scale(0.98); } }
@keyframes svy-fade { from { opacity: 0; } }
.svy-dlg__head {
  display: flex; align-items: center; gap: var(--space-3); padding: 14px 12px 14px var(--space-5);
  border-bottom: 1px solid var(--border); background: linear-gradient(180deg, var(--color-neutral-50), var(--panel));
}
.svy-dlg__title { flex: 1; min-width: 0; font-size: var(--text-lg); font-weight: 800; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.svy-dlg__tabs { display: flex; gap: 4px; padding: 10px var(--space-5) 0; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.svy-dlg:not(.has-tabs) .svy-dlg__tabs { display: none; }
.svy-dlg__tab {
  flex-shrink: 0; padding: 10px 14px; margin-bottom: -1px; font: inherit; font-size: var(--text-sm); font-weight: 600;
  color: var(--muted); background: none; border: 0; border-bottom: 2.5px solid transparent; cursor: pointer;
}
.svy-dlg__tab.is-on { color: var(--color-primary-800); border-bottom-color: var(--svy-accent); }
.svy-dlg__body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-4); }
.svy-dlg__body > .svy-group.is-tab-off { display: none; }
.svy-dlg.has-tabs .svy-dlg__body > .svy-group .svy-group__head { display: none; }
.svy-dlg.has-tabs .svy-dlg__body > .svy-group + .svy-group { border-top: 0; padding-top: 0; }
.svy-dlg__body .svy-card-warn { margin-top: 0; }
.svy-dlg__foot {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap;
  padding: 12px var(--space-5) calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--panel);
}
.svy-dlg__navs, .svy-dlg__acts { display: flex; align-items: center; gap: var(--space-2); }
.svy-dlg__nav { width: 44px; min-height: 44px; padding: 0; display: grid; place-items: center; }
.svy-dlg__nav:disabled { opacity: .35; pointer-events: none; }
.svy-dlg__pos { min-width: 56px; text-align: center; font-size: var(--text-xs); font-weight: 600; color: var(--muted); }
.svy-dlg__add, .svy-dlg__done { min-height: 44px; display: inline-flex; align-items: center; gap: 8px; }

/* Compact density across the survey form (step and popup): smaller inputs, choices as wrapping chips,
   short answers two per row. */
.modal.svy-dlg { width: min(640px, calc(100vw - 32px)); max-height: min(680px, calc(100dvh - 64px)); }
.svy-dlg__head { padding: 10px 8px 10px var(--space-4); gap: 10px; }
.svy-dlg__head .svy-card__no { min-width: 38px; padding: 3px 7px; font-size: 11px; }
.svy-dlg__title { font-size: var(--text-base); font-weight: 700; }
.svy-dlg__head .svy-icbtn { width: 34px; height: 34px; }
.svy-dlg__tabs { padding: 0 var(--space-4); gap: 2px; }
.svy-dlg__tab { padding: 9px 10px; font-size: 13px; }
.svy-dlg__tab[hidden] { display: none; }
.svy-dlg__body { padding: var(--space-4); gap: var(--space-3); }
.svy .svy-group__grid { gap: 12px 14px; }
.svy .svy-group__grid > .svy-f--short { grid-column: span 6; }
.svy .svy-group__grid > .svy-f--quarter { grid-column: span 3; }
.svy .svy-f { gap: 5px; }
.svy .svy-f > label { font-size: 12.5px; font-weight: 600; color: var(--text-2, var(--muted)); }
.svy .svy-f input, .svy .svy-f textarea { min-height: 38px; padding: 7px 11px; font-size: 14px; border-width: 1px; border-radius: var(--radius-sm); }
.svy .svy-f textarea { min-height: 64px; }
.svy .svy-unit input { padding-right: 44px; }
.svy .svy-unit span { top: 4px; bottom: 4px; right: 4px; padding: 0 8px; font-size: 11px; }
.svy .svy-computed { min-height: 38px; padding: 0 11px; font-size: var(--text-sm); border-width: 1px; border-radius: var(--radius-sm); }
.svy .svy-hint { font-size: 11.5px; }
.svy .svy-opts, .svy .svy-opts--few, .svy .svy-opts--many { display: flex; flex-wrap: wrap; gap: 6px; max-width: none; }
.svy .svy-opt {
  min-height: 34px; padding: 5px 12px 5px 8px; gap: 6px; font-size: 13px; font-weight: 500;
  border-width: 1px; border-radius: var(--radius-full);
}
.svy .svy-opt:hover { transform: none; }
.svy .svy-opt.is-on { font-weight: 600; box-shadow: none; }
.svy .svy-opt__tick { width: 16px; height: 16px; border-radius: 50%; border-width: 1px; }
.svy .svy-opt__tick .prj-ico { width: 10px; height: 10px; }
.svy .svy-opt__txt { flex-direction: row; align-items: baseline; gap: 6px; }
.svy .svy-opt__txt small { font-size: 11px; }
.svy .svy-warn { padding: 8px 12px; font-size: 13px; }
.svy-dlg__foot { padding: 10px var(--space-4) calc(10px + env(safe-area-inset-bottom)); }
.svy-dlg__nav { width: 36px; min-height: 36px; }
.svy-dlg__nav .prj-ico { width: 18px; height: 18px; flex-shrink: 0; }
.svy-dlg__add .prj-ico, .svy-dlg__done .prj-ico { width: 16px; height: 16px; flex-shrink: 0; }
.svy-dlg__head, .svy-dlg__tabs, .svy-dlg__foot { flex-shrink: 0; }
.svy-dlg__add, .svy-dlg__done, .svy-dlg__cancel { min-height: 38px; padding: 0 14px; font-size: 13.5px; }
.svy-dlg__cancel { display: inline-flex; align-items: center; }
/* the step page itself: tighter frame around the compact fields */
.svy .svy-form { gap: var(--space-3); margin-top: var(--space-4); }
.svy-form > .svy-group:not(.svy-group--plain) { padding: var(--space-3) var(--space-4) var(--space-4); }
.svy .svy-group__head { margin-bottom: var(--space-3); padding-bottom: var(--space-2); }
.svy .svy-group__head h4 { font-size: var(--text-xs); }
.svy .svy-pane-step { padding: var(--space-5); }
.svy .svy-head__icon { width: 44px; height: 44px; }
.svy .svy-head h2 { font-size: var(--text-xl); }
.svy .svy-info { padding: var(--space-3) var(--space-4); font-size: 13px; }
.svy .svy-addbtn { min-height: 44px; }
.svy .svy-bar { padding-top: 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
.svy .svy-bar .btn { min-height: 42px; font-size: var(--text-sm); }
.svy-icbtn {
  width: 40px; height: 40px; flex-shrink: 0; display: grid; place-items: center; border-radius: var(--radius-md);
  background: none; border: 1px solid transparent; color: var(--muted); cursor: pointer; transition: all var(--ease-fast);
}
.svy-icbtn--danger:hover { color: var(--color-danger-700); background: var(--danger-soft); border-color: color-mix(in srgb, var(--color-danger-500) 20%, transparent); }
.svy-repeat__add { display: flex; gap: var(--space-3); flex-wrap: wrap; }
.svy-addbtn {
  flex: 1 1 200px; min-height: 56px; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  font: inherit; font-weight: 700; font-size: var(--text-sm); color: var(--svy-accent);
  background: color-mix(in srgb, var(--color-primary-600) 4%, transparent); border: 2px dashed color-mix(in srgb, var(--color-primary-600) 35%, transparent); border-radius: var(--radius-lg); cursor: pointer;
  transition: all var(--ease-fast);
}
.svy-addbtn:hover { background: color-mix(in srgb, var(--color-primary-600) 9%, transparent); border-color: var(--svy-accent); transform: translateY(-1px); }
.svy-addbtn:active { transform: scale(0.98); }
.svy-addbtn--ghost { color: var(--svy-accent2); background: color-mix(in srgb, var(--brand-navy) 4%, transparent); border-color: color-mix(in srgb, var(--brand-navy) 30%, transparent); }
.svy-addbtn--ghost:hover { background: color-mix(in srgb, var(--brand-navy) 9%, transparent); border-color: var(--svy-accent2); }

/* Sticky Back / Next bar */
.svy-bar {
  position: fixed; left: var(--sidebar-w); right: 0; bottom: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center; gap: var(--space-4);
  padding: 12px var(--space-5) calc(12px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,0.82); backdrop-filter: saturate(180%) blur(18px); -webkit-backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--border);
}
.svy-bar .btn { min-height: 50px; min-width: 130px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: var(--text-base); }
.svy-bar__next { box-shadow: 0 10px 24px -12px color-mix(in srgb, var(--color-primary-600) 90%, transparent); }
.svy-bar__next[hidden] { display: none; }
.svy-bar .btn:disabled { opacity: .35; pointer-events: none; }
.svy-bar__step { font-size: var(--text-xs); font-weight: 600; color: var(--muted); min-width: 80px; text-align: center; }
/* keep the floating assistant button clear of the bar */
body:has(.svy-bar) .bops-chat { bottom: calc(86px + env(safe-area-inset-bottom)); }

.svy-toast {
  position: fixed; left: 50%; bottom: 100px; z-index: 60; transform: translate(-50%, 20px);
  max-width: min(92vw, 460px); padding: 12px 18px; border-radius: var(--radius-lg);
  font-size: var(--text-sm); font-weight: 600; color: #fff; background: color-mix(in srgb, var(--brand-navy-900) 94%, transparent);
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
  transition: opacity 250ms ease, transform 250ms cubic-bezier(0.22, 1, 0.36, 1);
}
.svy-toast.is-show { opacity: 1; transform: translate(-50%, 0); }
.svy-toast.is-err { background: var(--color-danger-700); }

/* Review */
.svy-review { margin-top: var(--space-5); display: flex; flex-direction: column; gap: var(--space-4); }
.svy-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: var(--space-3); }
.svy-stat {
  display: flex; flex-direction: column; gap: 2px; padding: var(--space-4); border-radius: var(--radius-lg);
  background: linear-gradient(135deg, color-mix(in srgb, var(--color-primary-600) 6%, transparent), color-mix(in srgb, var(--brand-navy) 5%, transparent)); border: 1px solid color-mix(in srgb, var(--color-primary-600) 14%, transparent);
}
.svy-stat__ic { color: var(--svy-accent); }
.svy-stat strong { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.03em; }
.svy-stat > span:last-child { font-size: var(--text-xs); color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.svy-stat.is-warn { background: linear-gradient(135deg, var(--tone-warning-bg), var(--color-warning-50)); border-color: #f6d49a; }
.svy-stat.is-warn .svy-stat__ic { color: var(--color-warning-500); }
.svy-rv-steps { display: flex; flex-direction: column; gap: 8px; }
.svy-rv {
  display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg); border: 1px solid var(--border);
}
.svy-rv__ic { width: 34px; height: 34px; flex-shrink: 0; border-radius: var(--radius-sm); display: grid; place-items: center; }
.svy-rv.is-ok .svy-rv__ic { background: var(--success-soft); color: var(--color-success-700); }
.svy-rv.has-gaps { border-color: #f6d49a; background: var(--color-warning-50); }
.svy-rv.has-gaps .svy-rv__ic { background: var(--warning-soft); color: var(--color-warning-700); }
.svy-rv__body { flex: 1; min-width: 0; }
.svy-rv__body strong { display: block; font-size: var(--text-sm); }
.svy-rv__body ul { margin: 4px 0 0; padding-left: 1.1em; font-size: var(--text-xs); color: var(--color-warning-700); }
.svy-rv__ok { font-size: var(--text-xs); color: var(--color-success-700); font-weight: 600; }
.svy-rv-title { font-size: var(--text-base); margin-top: var(--space-2); }
.svy-rv-warns { display: flex; flex-direction: column; gap: 8px; }
.svy-rv-warns .svy-warn { animation: none; }
.svy-submit {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap;
  padding: var(--space-5); border-radius: var(--radius-xl); color: #fff;
  background: linear-gradient(135deg, var(--brand-navy-900), var(--brand-navy-600));
}
.svy-submit strong { font-size: var(--text-lg); }
.svy-submit p { margin: 4px 0 0; font-size: var(--text-sm); color: rgba(255,255,255,0.72); max-width: 440px; }

/* --- Read-only view --- */
.svy-btn-light { background: rgba(255,255,255,0.1); color: #fff; border-color: rgba(255,255,255,0.22); display: inline-flex; align-items: center; gap: 8px; }
.svy-btn-light:hover { background: rgba(255,255,255,0.18); }
.svy-inline { display: inline; margin: 0; }
.svy-gapring {
  width: 120px; height: 120px; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.08); border: 8px solid rgba(255,255,255,0.14);
}
.svy-gapring strong { font-size: 2.2rem; font-weight: 800; line-height: 1; }
.svy-gapring span { font-size: var(--text-xs); color: rgba(255,255,255,0.7); text-transform: uppercase; letter-spacing: .06em; }
.svy-gapring.is-ok { border-color: rgba(52,199,89,0.65); box-shadow: 0 0 24px -4px rgba(52,199,89,0.6); }
.svy-gapring.is-warn { border-color: rgba(255,159,10,0.7); box-shadow: 0 0 24px -4px rgba(255,159,10,0.6); }
.svy-note {
  display: flex; gap: 12px; align-items: flex-start; padding: var(--space-4) var(--space-5); border-radius: var(--radius-lg);
  font-size: var(--text-sm); line-height: 1.5; color: var(--color-primary-800);
  background: color-mix(in srgb, var(--color-primary-600) 6%, transparent); border: 1px solid color-mix(in srgb, var(--color-primary-600) 18%, transparent);
}
.svy-gaplist { margin: var(--space-4) 0 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
.svy-gaplist li { font-size: var(--text-xs); padding: 6px 10px; border-radius: var(--radius-sm); background: var(--warning-soft); color: var(--color-warning-700); }
.svy-gaplist li span { font-weight: 700; margin-right: 4px; }
.svy-v-num {
  width: 42px; height: 42px; border-radius: var(--radius-md); flex-shrink: 0; display: grid; place-items: center;
  font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--svy-accent), var(--svy-accent2));
}
.svy-dl { margin: var(--space-3) 0 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--space-5); }
.svy-dl > div { display: flex; justify-content: space-between; gap: var(--space-3); padding: 9px 0; border-bottom: 1px solid var(--color-neutral-100); }
.svy-dl dt { color: var(--muted); font-size: var(--text-sm); }
.svy-dl dd { margin: 0; text-align: right; font-size: var(--text-sm); font-weight: 600; overflow-wrap: anywhere; flex: 0 1 auto; min-width: 4.5em; }
.svy-dl dt { flex: 1 1 auto; }
.svy-dl .is-empty dd { color: var(--color-neutral-400); font-weight: 400; }
.svy-dl .is-gap dd { color: var(--color-warning-700); font-weight: 600; font-style: italic; }
.svy-v-h { margin-top: var(--space-4); font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--svy-accent2); }
.svy-v-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); margin-top: var(--space-3); }
.svy-v-card { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-4); background: var(--color-neutral-50); }
.svy-v-card header { display: flex; align-items: center; gap: 10px; }
.svy-v-card .svy-dl { grid-template-columns: 1fr; }
.svy-v-card .svy-dl > div { border-bottom-color: var(--border); }
.svy-v-none { color: var(--muted); font-size: var(--text-sm); margin: var(--space-3) 0 0; }

/* --- Responsive --- */
/* Wide screens: short answers sit two per row so the full width is used well */
@media (min-width: 1100px) {
  .svy-grid > .svy-f--short:not(.svy-f--third):not(.svy-f--full) { grid-column: span 3; }
  .svy-grid > .svy-f--short.svy-f--half { grid-column: span 3; }
}
@media (max-width: 1024px) {
  .svy-bar { left: var(--sidebar-cw); }
}
@media (max-width: 768px) {
  .svy { padding-bottom: 120px; }
  .svy-bar { left: 0; padding-left: var(--space-3); padding-right: var(--space-3); gap: var(--space-2); }
  .svy-bar .btn { flex: 1; min-width: 0; }
  .svy-bar__step { min-width: 64px; }
  .svy-pane-step { padding: var(--space-4); border-radius: var(--radius-xl); margin: 0 calc(-1 * var(--space-1)); }
  .svy-head__icon { width: 44px; height: 44px; border-radius: var(--radius-lg); }
  .svy-head h2 { font-size: var(--text-xl); }
  .svy-grid > .svy-f--half { grid-column: 1 / -1; }
  /* phones: a bottom sheet that leaves the page peeking above it */
  .modal.svy-dlg { width: 100vw; max-width: 100vw; max-height: 90dvh; margin: auto 0 0; border-radius: 18px 18px 0 0; }
  .svy-dlg[open] { animation-name: svy-sheet-in; }
  .svy-dlg__tabs { padding-inline: var(--space-2); }
  .svy-dlg__body { padding: var(--space-3); }
  .svy .svy-f input, .svy .svy-f textarea { font-size: 16px; } /* no iOS zoom on focus */
  .svy .svy-group__grid > .svy-f--short, .svy .svy-group__grid > .svy-f--quarter { grid-column: span 6; }
  .svy .svy-group__grid > .svy-f--short:not(.svy-f--half):not(.svy-f--third):not(.svy-f--quarter) { grid-column: 1 / -1; }
  .svy-dlg__foot { padding-inline: var(--space-3); flex-wrap: nowrap; }
  .svy-dlg__pos { display: none; }
  .svy-dlg__navs { gap: 4px; }
  .svy-dlg__acts { flex: 1; justify-content: flex-end; }
  .svy-dlg__add span, .svy-dlg__nexttab { display: none; }
  .svy .svy-pane-step { padding: var(--space-4) var(--space-3); }
  .svy-form > .svy-group:not(.svy-group--plain) { padding: var(--space-3); }
  .svy-dlg__add { width: 38px; padding: 0; justify-content: center; }
  .svy-item__open { padding-left: 10px; gap: var(--space-2); }
  /* "Done" shrinks to its tick so the name keeps the room */
  .svy-pill--ok { font-size: 0; gap: 0; padding: 4px; }
  .svy-group:not(.svy-group--plain) { padding: var(--space-3) var(--space-4) var(--space-4); }
  .svy-group__grid > .svy-f--half, .svy-group__grid > .svy-f--third { grid-column: 1 / -1; }
  .svy-group__grid > .svy-f--quarter { grid-column: span 6; }
  .svy-opts--many { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .svy-opts--few { max-width: none; }
  .svy-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .svy-rail__lbl { display: none; }
  .svy-rail__step { padding: 6px; }
  .svy-rail__step.is-current { padding-right: 14px; }
  .svy-rail__step.is-current .svy-rail__lbl { display: inline; }
  .svy-types { grid-template-columns: 1fr; }
  .svy-type { flex-direction: row; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
  .svy-type__icon { margin-bottom: 0; }
  .svy-type small { flex-basis: 100%; padding-left: calc(44px + var(--space-3)); margin-top: -10px; }
  .svy-big { width: 100%; justify-content: center; }
  .svy-dl, .svy-v-cards { grid-template-columns: 1fr; }
  .svy-submit .svy-big { width: 100%; }
}
@keyframes svy-sheet-in { from { transform: translateY(40px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .svy *, .svy-start *, .svy-view *, .svy-dlg::backdrop { animation: none !important; transition: none !important; }
}
@media print {
  .svy-bar, .svy-rail, .svy-save, .svy-toast { display: none !important; }
}

/* ==== responsive.css ==== */
/* ============================================================
   Responsive shell — breakpoints: 1280 / 1024 / 768 / 480
   ============================================================ */

@media (max-width: 1280px) {
  .search-trigger { width: 240px; }
  .user-chip-text { display: none; }
  .app-header { padding: 0 var(--space-6); }
  .app-content { padding: var(--space-6) var(--space-6) var(--space-10); }
}

/* Tablet: icon rail */
@media (max-width: 1024px) {
  .sidebar { width: var(--sidebar-cw); }
  .sidebar-brand { justify-content: center; padding: var(--space-4) 0; }
  .sidebar-brand-text, .sidebar-item .label, .sidebar-section { display: none; }
  .sidebar-group + .sidebar-group { margin-top: var(--space-2); padding-top: var(--space-2); border-top: 1px solid rgba(255,255,255,0.08); }
  .sidebar-nav { padding: var(--space-2) var(--space-2); }
  .sidebar-item { justify-content: center; padding: 10px; }
  .sidebar-item.active::before { left: -8px; }
  .sidebar-item:hover::after {
    content: attr(data-tip);
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--color-neutral-900);
    color: #fff;
    font-size: var(--text-xs);
    font-weight: 500;
    white-space: nowrap;
    padding: 5px 9px;
    border-radius: 6px;
    box-shadow: var(--shadow-md);
    pointer-events: none;
    z-index: 200;
  }
  .sidebar-footer { padding: var(--space-2); }
  .app-main { margin-left: var(--sidebar-cw); }
  .search-trigger { width: 40px; padding: 0; justify-content: center; }
  .search-trigger-text, .search-trigger kbd { display: none; }
}

/* Phone: off-canvas drawer */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); width: 280px; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .sidebar.open .sidebar-brand { justify-content: flex-start; padding: var(--space-5) var(--space-5) var(--space-4); }
  .sidebar.open .sidebar-brand-text,
  .sidebar.open .sidebar-section { display: flex; }
  .sidebar.open .sidebar-section { display: block; }
  .sidebar.open .sidebar-item .label { display: inline; }
  .sidebar.open .sidebar-nav { padding: var(--space-2) var(--space-3) var(--space-4); }
  .sidebar.open .sidebar-item { justify-content: flex-start; padding: 9px var(--space-3); }
  .sidebar.open .sidebar-item:hover::after { display: none; }
  .sidebar.open .sidebar-group + .sidebar-group { border-top: 0; margin-top: var(--space-4); padding-top: 0; }

  .sidebar-toggle { display: grid; }
  .app-main { margin-left: 0; }
  .app-header { padding: 0 var(--space-4); gap: var(--space-2); }
  .crumbs-group { display: none !important; }
  .crumbs li:not(:last-child):not(:nth-last-child(2)) { display: none; }
  .btn-new span { display: none; }
  .btn-new { width: 38px; padding: 0; }
  .app-content { padding: var(--space-5) var(--space-4) var(--space-10); }

  .form-grid { grid-template-columns: 1fr; }
  .table-responsive { margin: 0 calc(-1 * var(--space-4)); padding: 0 var(--space-4); }
}

@media (max-width: 480px) {
  .crumbs li:nth-last-child(2) { display: none; }
  .crumbs li + li::before { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
