/* ==========================================================================
   AC Transfer / КондиционерОборот — Design System v2
   Warm ivory base · role-driven accents · Inter Tight + Inter + JetBrains Mono
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Inter+Tight:wght@500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  color-scheme: light;

  /* Typography */
  --font-sans: "Inter", "Segoe UI Variable", "Segoe UI", -apple-system,
    BlinkMacSystemFont, "SF Pro Text", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Inter Tight", "Inter", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Mono",
    "Fira Code", Consolas, monospace;

  /* Font scale */
  --fs-eyebrow: 0.72rem;    --ls-eyebrow: 0.14em;
  --fs-caption: 0.78rem;
  --fs-body-sm: 0.86rem;
  --fs-body:    0.94rem;
  --fs-body-lg: 1.02rem;
  --fs-h4: 1.02rem;
  --fs-h3: 1.25rem;
  --fs-h2: 1.6rem;
  --fs-h1: clamp(2rem, 3vw, 2.6rem);

  /* Surfaces — warm ivory */
  --bg:             #fbf5ec;
  --bg-alt:         #f5ecdf;
  --surface:        #fffcf7;
  --surface-strong: #ffffff;
  --surface-muted:  #f5ede0;
  --surface-sunken: #efe5d5;
  --surface-bright: #efe7dd;
  --surface-tint:   rgba(255, 252, 246, 0.72);

  /* Ink */
  --fg:           #1b1812;
  --fg-strong:    #0f0d09;
  --fg-muted:     #6b6250;
  --fg-subtle:    #8f8672;
  --fg-inverse:   #fffcf7;

  /* Lines */
  --line:         rgba(27, 24, 18, 0.08);
  --line-strong:  rgba(27, 24, 18, 0.14);
  --line-heavy:   rgba(27, 24, 18, 0.22);

  /* Shadows — warm-tinted */
  --shadow-xs: 0 1px 0 rgba(27, 24, 18, 0.04);
  --shadow-sm: 0 1px 2px rgba(27, 24, 18, 0.04), 0 1px 3px rgba(27, 24, 18, 0.06);
  --shadow-md: 0 4px 12px rgba(27, 24, 18, 0.06), 0 2px 4px rgba(27, 24, 18, 0.04);
  --shadow-lg: 0 12px 32px rgba(27, 24, 18, 0.10), 0 4px 8px rgba(27, 24, 18, 0.04);
  --shadow-xl: 0 24px 48px rgba(27, 24, 18, 0.14), 0 8px 16px rgba(27, 24, 18, 0.06);
  --shadow-inset: inset 0 0 0 1px var(--line);

  /* Radii */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-2xl: 22px;
  --r-pill: 999px;

  /* Spacing */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-7: 32px; --s-8: 40px; --s-9: 56px;

  /* Role — default admin teal */
  --role:         #0e7f76;
  --role-ink:     #0a5b54;
  --role-soft:    rgba(14, 127, 118, 0.12);
  --role-soft-2:  rgba(14, 127, 118, 0.22);
  --role-bg:      #e6f4f2;

  --role-admin:      #0e7f76;
  --role-customer:   #2f5bea;
  --role-contractor: #e45a11;
  --role-warehouse:  #178a44;
  --role-technical_supervisor:    #a0401c;

  /* Semantic */
  --success:      #157a3d;
  --success-soft: #d9f2e3;
  --success-ink:  #0b5126;
  --warning:      #a85a05;
  --warning-soft: #fbecc8;
  --warning-ink:  #6e3c03;
  --danger:       #b41f15;
  --danger-soft:  #fcdedb;
  --danger-ink:   #7c140d;
  --info:         #1e49c9;
  --info-soft:    #dbe3fb;
  --info-ink:     #152f86;

  /* Status palette — 12+ states */
  --st-draft-bg:     #efebe2; --st-draft-fg:     #5d5545;  --st-draft-dot:     #8f8672;
  --st-pending-bg:   #fbecc8; --st-pending-fg:   #7a4a06;  --st-pending-dot:   #c97f09;
  --st-otp-bg:       #ffe5c2; --st-otp-fg:       #8a3e03;  --st-otp-dot:       #ea7b10;
  --st-signed-bg:    #d9f2e3; --st-signed-fg:    #0b5126;  --st-signed-dot:    #15803d;
  --st-declined-bg:  #fcdedb; --st-declined-fg:  #7c140d;  --st-declined-dot:  #d62f22;
  --st-annulled-bg:  #eadcda; --st-annulled-fg:  #6a3f3a;  --st-annulled-dot:  #8c5a54;
  --st-installed-bg: #dbe7fb; --st-installed-fg: #1a3a93;  --st-installed-dot: #2f5bea;
  --st-removed-bg:   #e8dcfa; --st-removed-fg:   #3d2289;  --st-removed-dot:   #6b3fd8;
  --st-storage-bg:   #dde2fb; --st-storage-fg:   #26318a;  --st-storage-dot:   #3f4fd4;
  --st-transit-bg:   #e7f0d9; --st-transit-fg:   #3d5718;  --st-transit-dot:   #6a8a2d;
  --st-disputed-bg:  #fbe0c9; --st-disputed-fg:  #793606;  --st-disputed-dot:  #d67319;
  --st-expired-bg:   #e4dcd6; --st-expired-fg:   #4d4238;  --st-expired-dot:   #7a6b5e;
  --st-returned-bg:  #d3ecee; --st-returned-fg:  #1a4e54;  --st-returned-dot:  #2a8b94;

  /* Motion */
  --ease: cubic-bezier(.2, .7, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --t-fast: 120ms;
  --t-med: 200ms;
  --t-slow: 320ms;

  /* Density */
  --d-row-py: 12px;
  --d-cell-fs: 0.9rem;
  --d-input-h: 38px;
  --d-btn-h: 36px;

  /* ---- Backward-compatible aliases ---- */
  --role-accent: var(--role);
  --role-soft-strong: var(--role-soft-2);
  --role-contrast: var(--role-bg);
  --text: var(--fg);
  --muted: var(--fg-muted);
  --muted-strong: var(--fg-muted);
  --text-muted: var(--fg-muted);
  --text-primary: var(--fg-strong);
  --accent: var(--role);
  --border: var(--line);
  --radius-xl: var(--r-xl);
  --radius-lg: var(--r-lg);
  --radius-md: var(--r-md);
  --radius-sm: var(--r-sm);
  --radius-pill: var(--r-pill);
}

/* Role swap — body.role-* (legacy) + [data-role] (new) */
body.role-admin, [data-role="admin"] {
  --role: #0e7f76; --role-ink: #0a5b54;
  --role-soft: rgba(14,127,118,.12); --role-soft-2: rgba(14,127,118,.22);
  --role-bg: #e6f4f2;
  --role-accent: var(--role); --role-soft-strong: var(--role-soft-2); --role-contrast: var(--role-bg);
}

body.role-technical_supervisor,
body.role-technical_supervisor,
[data-role="customer"] {
  --role: #2f5bea; --role-ink: #1e3fa8;
  --role-soft: rgba(47,91,234,.10); --role-soft-2: rgba(47,91,234,.20);
  --role-bg: #e4ebfc;
  --role-accent: var(--role); --role-soft-strong: var(--role-soft-2); --role-contrast: var(--role-bg);
}

body.role-contractor_employee,
body.role-contractor_employee,
[data-role="contractor"] {
  --role: #e45a11; --role-ink: #a73d04;
  --role-soft: rgba(228,90,17,.10); --role-soft-2: rgba(228,90,17,.22);
  --role-bg: #fde6d8;
  --role-accent: var(--role); --role-soft-strong: var(--role-soft-2); --role-contrast: var(--role-bg);
}

body.role-warehouse_employee,
[data-role="warehouse"] {
  --role: #178a44; --role-ink: #0d5a2a;
  --role-soft: rgba(23,138,68,.10); --role-soft-2: rgba(23,138,68,.22);
  --role-bg: #dcf0e3;
  --role-accent: var(--role); --role-soft-strong: var(--role-soft-2); --role-contrast: var(--role-bg);
}

body.role-technical_supervisor,
[data-role="technical_supervisor"] {
  --role: #a0401c; --role-ink: #6e2b0f;
  --role-soft: rgba(160,64,28,.10); --role-soft-2: rgba(160,64,28,.22);
  --role-bg: #f2e1d8;
  --role-accent: var(--role); --role-soft-strong: var(--role-soft-2); --role-contrast: var(--role-bg);
}

body.role-public {
  --role: #0e7f76; --role-ink: #0a5b54;
  --role-soft: rgba(14,127,118,.12); --role-soft-2: rgba(14,127,118,.22);
  --role-bg: #e6f4f2;
  --role-accent: var(--role); --role-soft-strong: var(--role-soft-2); --role-contrast: var(--role-bg);
}

/* Density toggle */
[data-density="compact"] {
  --d-row-py: 7px; --d-cell-fs: 0.84rem; --d-input-h: 32px; --d-btn-h: 30px;
}
[data-density="comfortable"] {
  --d-row-py: 16px; --d-cell-fs: 0.95rem; --d-input-h: 44px; --d-btn-h: 42px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  font-feature-settings: "cv11", "ss01", "ss03";
  font-size: var(--fs-body);
  line-height: 1.5;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-alt) 120%);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

img { display: block; max-width: 100%; }
svg.icon { display: inline-block; vertical-align: middle; flex-shrink: 0; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }

a {
  color: inherit;
  text-decoration: none;
}

code,
kbd,
pre,
samp {
  font-family: var(--font-mono);
  font-size: 0.94em;
}

input, textarea, select { font: inherit; color: inherit; }

textarea {
  min-height: 110px;
  resize: vertical;
}

[hidden],
.is-hidden {
  display: none !important;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  background: var(--surface-tint);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 20px;
  min-height: 56px;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  margin: 0 16px;
  overflow-x: auto;
  scrollbar-width: none;
}

.topnav::-webkit-scrollbar {
  display: none;
}

.topnav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--r-md);
  font-size: var(--fs-body-sm);
  font-weight: 500;
  color: var(--fg-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--t-fast), background var(--t-fast);
}

.topnav-link:hover {
  color: var(--fg-strong);
  background: var(--surface-muted);
}

.topnav-link.active {
  color: var(--fg-strong);
  background: var(--surface-strong);
  box-shadow: var(--shadow-xs), inset 0 0 0 1px var(--line-strong);
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  border-radius: var(--radius-pill);
  background: var(--role-accent);
  color: #fff;
  vertical-align: middle;
}

.subnav {
  display: flex;
  gap: 2px;
  padding: 0 22px 10px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--line);
}

.subnav::-webkit-scrollbar { display: none; }

.subnav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: var(--fs-body-sm);
  font-weight: 500;
  color: var(--fg-muted);
  border-radius: var(--r-sm);
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--t-fast);
}

.subnav-link:hover { color: var(--fg-strong); }
.subnav-link.active {
  color: var(--role-ink, var(--role));
  background: var(--role-soft);
}
[data-theme="dark"] .subnav-link.active { color: var(--fg-strong); }

.primary-cta {
  font-weight: 600;
  padding: 8px 14px !important;
  min-height: 36px !important;
  white-space: nowrap;
}

.btn-icon-only {
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0 !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-type {
  display: grid;
  gap: 4px;
}

.logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--role-accent);
  color: white;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  box-shadow: var(--shadow-md);
}

.title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--muted);
  font-size: 0.88rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: auto;
  max-width: 260px;
  padding: 6px 10px 6px 6px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  color: inherit;
  text-decoration: none;
}

.user-chip > div {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.user-chip strong {
  font-size: 0.88rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 170px;
  display: block;
}

.user-chip > div > span {
  color: var(--muted);
  font-size: 0.74rem;
}

.app-shell {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 22px;
  display: grid;
  grid-template-columns: 296px minmax(0, 1fr);
  gap: 22px;
  box-sizing: border-box;
}

.app-shell--no-sidebar {
  grid-template-columns: minmax(0, 1fr);
}

[id$="-create-form"],
#create-form {
  scroll-margin-top: 80px;
}

.content--full {
  max-width: 100%;
}

.sidebar {
  position: sticky;
  top: 60px;
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 18px;
  height: fit-content;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface-strong);
  box-shadow: var(--shadow-md);
}

.sidebar-head {
  display: grid;
  gap: 8px;
}

.sidebar-head strong {
  font-size: 1.1rem;
}

.sidebar-nav {
  display: grid;
  gap: 16px;
}

.sidebar-section {
  display: grid;
  gap: 8px;
}

.sidebar-label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sidebar-foot {
  display: grid;
  gap: 12px;
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 12px 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-weight: 500;
  color: var(--muted-strong);
  transition:
    background-color 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease,
    padding-left 0.16s ease;
}

.nav-link:hover {
  background: var(--surface-muted);
  border-color: var(--line);
  color: var(--text);
}

.nav-link:focus-visible {
  outline: none;
  border-color: var(--role-accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--role-accent) 22%, transparent);
}

.nav-link.active {
  background: color-mix(in srgb, var(--role-accent) 12%, var(--surface-strong));
  border-color: color-mix(in srgb, var(--role-accent) 22%, transparent);
  color: var(--text);
  font-weight: 600;
  padding-left: 18px;
}

.nav-link.active::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  border-radius: 2px;
  background: var(--role-accent);
}

.content {
  display: grid;
  gap: 18px;
  min-width: 0;
  animation: page-in 0.15s ease;
}

@keyframes page-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.content-shell {
  display: grid;
  gap: 20px;
  min-width: 0;
}

.panel,
.surface-card,
.hero-card,
.auth-card,
.signer-shell {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface-strong);
  box-shadow: var(--shadow-lg);
  min-width: 0;
}

.panel,
.surface-card,
.hero-card,
.auth-card,
.signer-shell {
  padding: 24px;
}

.light-panel {
  background: var(--surface-muted);
}

.settings-group {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 20px;
}

.settings-group legend {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--role-accent);
  padding: 0 8px;
}

.quick-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--role-accent);
  color: var(--role-accent);
  font-weight: 600;
}

.btn-outline:hover {
  background: var(--role-soft);
}

.page-hero,
.workspace-hero,
.signer-hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 18px 22px;
  border-radius: var(--radius-lg, 14px);
  border: 1px solid var(--line);
  background: var(--surface-strong);
  box-shadow: none;
}

.workspace-copy {
  display: grid;
  gap: 10px;
  max-width: 100%;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sans);
  font-size: var(--fs-eyebrow);
  font-weight: 600;
  letter-spacing: var(--ls-eyebrow);
  text-transform: uppercase;
  color: var(--role);
}

.eyebrow::before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 1px;
  background: currentColor;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  margin: 0;
  color: var(--fg-strong);
  letter-spacing: -0.02em;
  line-height: 1.15;
}

h1 {
  font-size: var(--fs-h1);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.05;
}

h2 {
  margin-bottom: 8px;
  font-size: var(--fs-h2);
  font-weight: 700;
  letter-spacing: -0.025em;
}

h3 {
  margin-bottom: 6px;
  font-size: var(--fs-h3);
  font-weight: 700;
  letter-spacing: -0.02em;
}

h4 {
  font-size: var(--fs-h4);
  font-weight: 600;
  letter-spacing: -0.01em;
}

p {
  margin: 0;
  color: var(--fg-muted);
  line-height: 1.55;
}

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

.hero-actions,
.inline-buttons,
.toolbar,
.grid-inline,
.pill-row,
.copy-wrap {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.hero-actions {
  justify-content: flex-end;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.section-head.wrap,
.inline-buttons.wrap,
.pill-row.wrap {
  flex-wrap: wrap;
}

.divider {
  height: 1px;
  margin: 18px 0;
  background: var(--line-strong);
}

.note {
  padding: 16px 18px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
  line-height: 1.55;
}

.link {
  color: var(--role-accent);
}

.linkish {
  color: var(--role-accent);
  cursor: pointer;
}

.workspace-stats,
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.compact-stats {
  margin-bottom: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-card,
.stat-card {
  display: grid;
  gap: 10px;
  min-height: 110px;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
}

.metric-card span,
.stat-card span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.metric-card strong,
.stat-card strong {
  font-size: clamp(1.2rem, 1.7vw, 2rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.workspace-board,
.secondary-board,
.workspace-grid,
.grid-2,
.checklist-grid,
.action-grid {
  display: grid;
  gap: 20px;
}

.workspace-board,
.secondary-board,
.workspace-grid,
.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}

.action-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.contractor-onboarding-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(420px, 1.1fr);
  gap: 18px;
  align-items: start;
}

.contractor-onboarding-panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: var(--surface-muted);
}

.contractor-onboarding-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.contractor-onboarding-head h3 {
  margin: 0 0 4px;
}

.contractor-onboarding-head p {
  margin: 0;
  font-size: 0.9rem;
}

.contractor-onboarding-head .step-dot {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--role-accent);
  color: #fff;
  font-weight: 800;
  flex: 0 0 auto;
}

@media (max-width: 980px) {
  .contractor-onboarding-grid {
    grid-template-columns: 1fr;
  }
}

.queue-panel {
  padding: 22px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(254, 252, 247, 0.96), rgba(247, 242, 234, 0.96));
  box-shadow: var(--shadow-md);
}

.queue-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

.queue-list,
.stack-list,
.timeline,
.stack {
  display: grid;
  gap: 12px;
}

.stack.gap,
.timeline.compact {
  gap: 14px;
}

.queue-card,
.stack-row,
.action-card {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface-muted);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.action-card {
  flex-direction: column;
  justify-content: flex-start;
  min-height: 160px;
}

.queue-card:hover,
.stack-row:hover,
.action-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: 0 12px 28px rgba(28, 37, 51, 0.08);
}

.queue-card-wide {
  align-items: stretch;
}

.queue-main,
.queue-side,
.queue-side-stretch {
  display: grid;
  gap: 6px;
}

.queue-main strong,
.stack-row strong,
.action-card strong {
  font-size: 1rem;
}

.queue-side {
  align-content: start;
  justify-items: end;
}

.queue-side-stretch {
  width: min(320px, 100%);
  align-content: start;
}

.queue-empty {
  padding: 20px;
  border-radius: 18px;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
  background: var(--surface-muted);
}

.badge,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-muted);
  color: var(--muted-strong);
  font-size: 0.82rem;
  font-weight: 700;
}

.badge-soft {
  background: var(--role-soft);
  border-color: var(--role-soft-strong);
  color: var(--text);
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted-strong);
}

.filter-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  align-items: end;
}

.filter-form label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted-strong);
  font-size: 0.9rem;
  font-weight: 700;
}

.filter-form input,
.filter-form select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  color: var(--text);
}

.checkbox-row label {
  display: flex;
  gap: 10px;
  align-items: center;
}

.input {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line-strong);
  background: var(--surface-strong);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background-color 0.18s ease;
}

.input::placeholder {
  color: var(--muted);
  opacity: 0.72;
}

.input:hover:not(:focus):not([disabled]) {
  border-color: color-mix(in srgb, var(--role-accent) 30%, var(--line-strong));
}

.input.compact {
  min-width: 180px;
}

.input:focus,
.input:focus-visible {
  border-color: var(--role-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--role-accent) 22%, transparent);
}

.input[disabled],
.input:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  background: var(--surface-muted);
}

.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  color: white;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1.25;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition:
    background-color 0.16s ease,
    border-color 0.16s ease,
    color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.1s ease;
}

.btn:hover {
  filter: brightness(1.06);
}

.btn:active {
  transform: translateY(0);
  filter: brightness(0.96);
}

.btn:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px var(--bg),
    0 0 0 4px color-mix(in srgb, var(--role-accent) 55%, transparent);
}

.btn[disabled],
.btn.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  filter: none;
  pointer-events: none;
}

.btn-primary {
  background: var(--role-accent);
  box-shadow: 0 1px 2px rgba(15, 118, 110, 0.16), 0 0 0 1px color-mix(in srgb, var(--role-accent) 40%, transparent) inset;
}

.btn-primary:hover {
  box-shadow: 0 6px 16px rgba(15, 118, 110, 0.22), 0 0 0 1px color-mix(in srgb, var(--role-accent) 50%, transparent) inset;
  transform: translateY(-1px);
}

.btn-success {
  background: var(--success);
  box-shadow: 0 1px 2px rgba(21, 128, 61, 0.18);
}

.btn-success:hover {
  box-shadow: 0 6px 16px rgba(21, 128, 61, 0.22);
  transform: translateY(-1px);
}

/* Warning — softened: muted amber surface with darker text, not solid fill */
.btn-warning {
  background: color-mix(in srgb, var(--warning) 18%, var(--surface-strong));
  color: color-mix(in srgb, var(--warning) 90%, var(--text));
  border-color: color-mix(in srgb, var(--warning) 42%, transparent);
  box-shadow: none;
}

.btn-warning:hover {
  background: color-mix(in srgb, var(--warning) 28%, var(--surface-strong));
  border-color: color-mix(in srgb, var(--warning) 58%, transparent);
  filter: none;
}

[data-theme="dark"] .btn-warning {
  background: color-mix(in srgb, var(--warning) 22%, transparent);
  color: color-mix(in srgb, var(--warning) 75%, #ffffff);
  border-color: color-mix(in srgb, var(--warning) 44%, transparent);
}

[data-theme="dark"] .btn-warning:hover {
  background: color-mix(in srgb, var(--warning) 32%, transparent);
}

.btn-danger {
  background: var(--danger);
  box-shadow: 0 1px 2px rgba(185, 28, 28, 0.18);
}

.btn-danger:hover {
  box-shadow: 0 6px 16px rgba(185, 28, 28, 0.24);
  transform: translateY(-1px);
}

.btn-ghost {
  color: var(--text);
  background: var(--surface-strong);
  border-color: var(--line);
  box-shadow: none;
}

.btn-ghost:hover {
  background: var(--surface-muted);
  border-color: var(--line-strong);
  filter: none;
  transform: none;
}

/* Soft — low-weight action for crowded table cells */
.btn-soft {
  color: var(--muted-strong);
  background: transparent;
  border-color: transparent;
  font-weight: 600;
}

.btn-soft:hover {
  color: var(--text);
  background: var(--surface-muted);
  border-color: var(--line);
  filter: none;
  transform: none;
}

.btn-soft.btn-danger {
  color: var(--danger);
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.btn-soft.btn-danger:hover {
  color: #ffffff;
  background: var(--danger);
  border-color: var(--danger);
  transform: none;
}

/* Icon-only — square, consistent size */
.btn-icon {
  width: 40px;
  padding: 0;
  flex-shrink: 0;
}

.btn-icon.btn-sm {
  width: 32px;
  min-height: 32px;
}

/* Size variants */
.btn-sm {
  min-height: 32px;
  padding: 6px 12px;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

.btn-map {
  min-height: 24px;
  padding: 2px 8px;
  font-size: 0.75rem;
  vertical-align: middle;
  white-space: nowrap;
}

.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.photo-card {
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  overflow: hidden;
  background: var(--surface-strong);
}

.photo-card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
  cursor: pointer;
  transition: opacity 0.15s;
}

.photo-card img:hover {
  opacity: 0.85;
}

.photo-card-file {
  height: 160px;
  display: grid;
  place-items: center;
  background: var(--bg-alt);
  color: var(--muted);
}

.photo-card-meta {
  padding: 8px 10px;
  display: grid;
  gap: 2px;
}

.photo-card-name {
  font-size: 0.85rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-card-meta .muted {
  font-size: 0.78rem;
}

.btn-block {
  width: 100%;
}

.flash {
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  box-shadow: var(--shadow-md);
}

.flash.info {
  background: var(--info-soft);
  border-color: rgba(29, 78, 216, 0.2);
}

.flash.success {
  background: var(--success-soft);
  border-color: rgba(21, 128, 61, 0.2);
}

.flash.error {
  background: var(--danger-soft);
  border-color: rgba(180, 35, 24, 0.2);
}

.flash.standalone {
  margin: 18px 24px 0;
}

.table-wrap {
  overflow: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
}

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

.conditioners-table {
  min-width: 1180px;
  table-layout: fixed;
}

.conditioners-table th,
.conditioners-table td {
  overflow-wrap: anywhere;
}

.conditioners-table th:nth-child(9),
.conditioners-table td:nth-child(9) {
  width: 160px;
}

.conditioners-table td:nth-child(9) .inline-buttons {
  align-items: stretch;
  flex-direction: column;
  gap: 6px;
}

.conditioners-table td:nth-child(9) .btn {
  width: 100%;
  white-space: normal;
}

.object-mobile-list {
  display: none;
}

table {
  width: 100%;
  min-width: 700px;
  border-collapse: collapse;
  background: var(--surface-muted);
}

.stage-progress-table {
  min-width: 0;
  table-layout: fixed;
}

.stage-progress-table th:first-child,
.stage-progress-table td:first-child {
  width: 45%;
}

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

thead th {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
  border-bottom: 2px solid var(--line-strong);
}

tbody tr {
  transition: background 0.12s, border-color 0.12s;
  border-left: 3px solid transparent;
}

tbody tr:hover {
  background: var(--role-soft);
  border-left-color: var(--role-accent);
}

tbody tr[data-row-href] {
  cursor: pointer;
}

tbody tr[data-row-href]:focus-visible {
  outline: 2px solid var(--role-accent);
  outline-offset: -2px;
}

.btn.compact {
  padding: 6px 14px;
  font-size: 0.85rem;
  border-radius: 10px;
}

.obj-edit-form,
.equip-add-form {
  margin-top: 16px;
}

.section-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.section-head-actions > .toolbar {
  flex-wrap: nowrap;
}

.form-block-title {
  margin: 0 0 12px;
  font-size: 0.95rem;
  font-weight: 600;
}

.passport-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px 32px;
}
@media (max-width: 900px) {
  .passport-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
}

dl.meta-grid {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 12px 16px;
}

dl.meta-grid dt {
  color: var(--muted);
  font-weight: 700;
}

dl.meta-grid dd {
  margin: 0;
}

.timeline-item {
  padding: 0 0 0 16px;
  border-left: 3px solid var(--role-soft-strong);
}

.timeline-title {
  margin-bottom: 4px;
  font-weight: 800;
}

.timeline-meta {
  color: var(--muted);
  font-size: 0.84rem;
}

.auth-page,
.sign-page {
  min-height: 100vh;
  padding: 28px;
  display: grid;
  place-items: center;
}

.auth-card.wide,
.signer-shell {
  width: min(1240px, 100%);
}

.hero-block {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.auth-grid {
  align-items: start;
}

/* ============================================
   AUTH SPLIT LAYOUT
   ============================================ */
.auth-split {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  min-height: 100vh;
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background: var(--role-accent);
  color: white;
}

.auth-brand-inner {
  max-width: 440px;
}

.auth-brand-inner .logo {
  background: rgba(255, 255, 255, 0.2);
  margin-bottom: 24px;
}

.auth-brand-inner h1 {
  font-size: 1.8rem;
  font-weight: 800;
  margin: 0 0 12px;
  line-height: 1.3;
}

.auth-brand-inner p {
  opacity: 1;
  color: rgba(255, 255, 255, 0.95);
  line-height: 1.6;
  margin: 0 0 24px;
}

.auth-features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 12px;
}

.auth-features li {
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0.9;
  font-weight: 500;
}

.auth-form-side {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px;
}

.auth-form-side form {
  max-width: 400px;
  width: 100%;
  margin: 0 auto;
}

.auth-form-side h2 {
  margin: 0 0 24px;
}

.demo-panel {
  max-width: 600px;
  margin: 28px auto 0;
  width: 100%;
}

.demo-panel h3 {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--muted-strong);
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.demo-table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  font-size: 0.84rem;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--line);
}

.demo-table thead th {
  padding: 8px 10px;
  text-align: left;
  font-weight: 700;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: var(--surface-muted);
  border-bottom: 1px solid var(--line-strong);
}

.demo-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.demo-table code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: var(--surface-muted);
  padding: 2px 6px;
  border-radius: 4px;
}

.demo-row {
  cursor: pointer;
  transition: background 0.12s ease;
}

.demo-row:hover {
  background: var(--role-soft);
}

.demo-row.is-active {
  background: var(--role-soft-strong);
}

.demo-name {
  font-weight: 500;
  white-space: nowrap;
}

.demo-role-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}

.demo-role--admin { background: rgba(15,118,110,0.14); color: #0f766e; }
.demo-role--technical_supervisor { background: rgba(37,99,235,0.12); color: #2563eb; }
.demo-role--technical_supervisor { background: rgba(37,99,235,0.12); color: #1d4ed8; }
.demo-role--contractor_employee { background: rgba(234,88,12,0.12); color: #ea580c; }
.demo-role--contractor_employee { background: rgba(234,88,12,0.12); color: #c2410c; }
.demo-role--warehouse_employee { background: rgba(21,128,61,0.12); color: #15803d; }
.demo-role--technical_supervisor { background: rgba(154,52,18,0.12); color: #9a3412; }
.demo-role--owner { background: rgba(107,99,86,0.12); color: #6b6356; }

.demo-hint {
  margin: 10px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 768px) {
  .auth-split {
    grid-template-columns: 1fr;
  }
  .auth-brand {
    padding: 32px 24px;
    min-height: auto;
  }
  .auth-brand-inner h1 {
    font-size: 1.3rem;
  }
  .auth-form-side {
    padding: 32px 24px;
  }
}

.mini-list,
.file-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
  color: var(--muted-strong);
}

.signer-shell {
  display: grid;
  gap: 20px;
}

.hero-badges,
.summary-grid,
.signer-steps {
  display: grid;
  gap: 16px;
}

.signer-steps {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.signer-summary {
  display: grid;
  gap: 18px;
}

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

.summary-grid p {
  margin-top: 4px;
}

.flow-builder,
.flow-section {
  display: grid;
  gap: 16px;
}

.flow-section {
  padding: 18px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--surface-muted);
}

.flow-heading {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.step-badge {
  display: inline-grid;
  place-items: center;
  min-width: 76px;
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--role-soft);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 800;
}

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

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

.check-card,
.picker-card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface-muted);
}

.check-card input,
.picker-card input,
.checkbox-row input {
  margin-top: 3px;
  accent-color: var(--role-accent);
}

.equipment-picker {
  display: grid;
  gap: 12px;
}

.form-footer {
  display: flex;
  justify-content: flex-start;
}

.action-card p,
.queue-main p,
.stack-row p {
  color: var(--muted);
}

.compact-object-switch {
  display: flex;
  justify-content: flex-end;
}

.filter-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) repeat(2, minmax(0, 1fr)) auto;
  gap: 12px;
}

.signature-box {
  overflow: hidden;
  border-radius: 18px;
  border: 1px dashed var(--line-strong);
  background: #ffffff;
  touch-action: none;
}

.signature-box canvas {
  display: block;
  width: 100%;
  min-height: 220px;
}

.standalone-form {
  margin-top: 10px;
}

.final-state-card {
  display: grid;
  gap: 14px;
}

.state-banner {
  display: grid;
  gap: 6px;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid transparent;
}

.state-banner-success {
  background: var(--success-soft);
  border-color: rgba(21, 128, 61, 0.18);
}

.state-banner-danger {
  background: var(--danger-soft);
  border-color: rgba(180, 35, 24, 0.18);
}

.state-banner-info {
  background: var(--info-soft);
  border-color: rgba(29, 78, 216, 0.18);
}

.stack-actions {
  display: grid;
  gap: 8px;
}

.inline-details {
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface-muted);
}

.inline-details summary {
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}

.inline-details[open] summary {
  border-bottom: 1px solid var(--line);
}

.mini-form {
  padding: 12px 14px 14px;
}

.equal > .panel,
.equal > section {
  height: 100%;
}

/* --- Hamburger nav toggle --- */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 10px;
  border: none;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 29;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
}

.nav-overlay.is-active {
  display: block;
}

/* --- QR Scanner --- */
.qr-scanner-wrap {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
}

.qr-scanner-wrap .surface-card {
  max-width: 460px;
  width: 100%;
}

/* --- Camera Capture --- */
.camera-capture {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
}

.camera-capture .surface-card {
  max-width: 500px;
  width: 100%;
}

.camera-viewfinder video {
  display: block;
  width: 100%;
  border-radius: 12px;
  background: #000;
}

.camera-preview img {
  display: block;
  width: 100%;
  border-radius: 12px;
}

/* --- Geo Status --- */
.geo-status {
  padding: 8px 14px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
}

.geo-status-loading {
  background: var(--info-soft);
  color: var(--info);
}

.geo-status-success {
  background: var(--success-soft);
  color: var(--success);
}

.geo-status-error {
  background: var(--danger-soft);
  color: var(--danger);
}

/* --- Empty States --- */
.empty-state {
  display: grid;
  place-items: center;
  gap: 12px;
  padding: 40px 20px;
  text-align: center;
}

.empty-state-text {
  color: var(--muted);
  font-size: 0.95rem;
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 1.6rem;
}

/* --- Offline Banner --- */
.offline-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 12px 20px;
  background: var(--danger);
  color: white;
  text-align: center;
  font-weight: 700;
  font-size: 0.9rem;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.offline-banner.is-visible {
  transform: translateY(0);
}

/* --- Toast / Flash improvements --- */
.flash-toast {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 60;
  max-width: 400px;
  padding: 14px 20px;
  border-radius: 16px;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.3s ease;
}

.flash-toast-success {
  background: var(--success-soft);
  border: 1px solid rgba(21, 128, 61, 0.2);
  color: var(--success);
}

.flash-toast-error {
  background: var(--danger-soft);
  border: 1px solid rgba(180, 35, 24, 0.2);
  color: var(--danger);
}

.flash-toast-info {
  background: var(--info-soft);
  border: 1px solid rgba(29, 78, 216, 0.2);
  color: var(--info);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@media (max-width: 1240px) {
  .signer-steps,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .filter-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 1024px) {
  .nav-toggle {
    display: flex;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 30;
    width: 300px;
    max-width: 85vw;
    border-radius: 0;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }
}

@media (max-width: 820px) {
  .page-hero,
  .workspace-hero,
  .signer-hero,
  .hero-block {
    flex-direction: column;
  }

  .topbar-main {
    flex-wrap: wrap;
    gap: 10px;
  }

  .topnav {
    order: 3;
    width: 100%;
    margin: 0;
    padding: 6px 0;
    border-top: 1px solid var(--line);
  }

  .hero-actions {
    width: 100%;
  }

  .user-chip {
    min-width: 0;
    width: 100%;
  }

  .workspace-stats,
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .compact-stats,
  .checklist-grid {
    grid-template-columns: 1fr;
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }

  dl.meta-grid {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .signer-shell,
  .auth-card,
  .surface-card,
  .panel,
  .hero-card {
    padding: 18px;
  }

  .page-hero,
  .workspace-hero,
  .signer-hero {
    padding: 22px 18px;
  }
}

@media (max-width: 640px) {
  .auth-page,
  .sign-page,
  .app-shell {
    padding: 14px;
  }

  .topbar {
    padding: 12px 14px;
    gap: 10px;
  }

  .brand-wrap {
    gap: 10px;
  }

  .logo {
    width: 32px;
    height: 32px;
    font-size: 0.78rem;
  }

  .title {
    font-size: 1rem;
  }

  .topbar-actions {
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
  }

  .user-chip {
    padding: 6px;
    border-radius: 999px;
    width: auto;
    min-width: 0;
    gap: 0;
  }

  .user-chip > div {
    display: none;
  }

  .avatar {
    width: 34px;
    height: 34px;
    font-size: 0.95rem;
  }

  .btn,
  .input {
    min-height: 48px;
  }

  .table-wrap:not(.responsive-cards) table {
    min-width: 620px;
  }
}

/* ============================================
   RESPONSIVE TABLE → CARD VIEW (mobile)
   ============================================ */
@media (max-width: 768px) {
  .table-wrap.responsive-cards table {
    min-width: 0;
    border: none;
    background: none;
  }

  .table-wrap.responsive-cards thead {
    display: none;
  }

  .table-wrap.responsive-cards tbody tr {
    display: grid;
    gap: 6px;
    padding: 16px;
    margin-bottom: 12px;
    border-radius: 16px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    box-shadow: 0 4px 12px rgba(28, 37, 51, 0.06);
  }

  .table-wrap.responsive-cards tbody tr:hover {
    background: var(--surface);
  }

  .table-wrap.responsive-cards td {
    display: grid;
    grid-template-columns: 115px 1fr;
    gap: 6px 8px;
    padding: 6px 0;
    border: none;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .table-wrap.responsive-cards td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    padding-top: 2px;
  }

  .table-wrap.responsive-cards td:last-child {
    padding: 6px 0;
    border-top: none;
    display: grid;
    grid-template-columns: 115px 1fr;
    justify-content: initial;
  }

  .table-wrap.responsive-cards td:last-child::before {
    display: block;
  }

  .table-wrap.responsive-cards td > * {
    grid-column: 2;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .table-wrap.responsive-cards td > :first-child {
    grid-column: 2;
  }

  .table-wrap.responsive-cards tbody tr {
    overflow: hidden;
  }

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

  .object-mobile-list {
    display: block;
    border-radius: 0;
    overflow: hidden;
    min-width: 0;
  }

  .object-desktop-table {
    display: none;
  }

  .object-mobile-row {
    border-bottom: 1px solid var(--line-strong);
  }

  .object-mobile-row:first-child .object-mobile-summary {
    padding-top: 4px;
  }

  .object-mobile-row:last-child {
    border-bottom: 0;
  }

  .object-mobile-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 34px;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 15px 0;
    list-style: none;
    cursor: pointer;
  }

  .object-mobile-summary::-webkit-details-marker {
    display: none;
  }

  .object-mobile-address-link {
    min-width: 0;
    color: var(--role-accent);
    text-decoration: none;
    font-size: 1.02rem;
    font-weight: 650;
    line-height: 1.25;
  }

  .object-mobile-address-link:hover,
  .object-mobile-address-link:focus-visible {
    color: var(--role-accent-strong, var(--role-accent));
  }

  .object-mobile-spoiler {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: var(--role-accent);
    background: color-mix(in srgb, var(--role-accent) 8%, var(--surface-muted));
    transition: transform 0.16s ease, background-color 0.16s ease, color 0.16s ease;
  }

  .object-mobile-spoiler::before {
    content: "";
    width: 9px;
    height: 9px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
  }

  .object-mobile-summary:hover .object-mobile-spoiler {
    background: color-mix(in srgb, var(--role-accent) 14%, var(--surface-muted));
    color: var(--role-accent-strong, var(--role-accent));
  }

  .object-mobile-row[open] .object-mobile-spoiler {
    transform: rotate(180deg);
  }

  .object-mobile-address {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .object-mobile-card {
    margin: 0 0 12px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-muted);
  }

  .object-mobile-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 0.84rem;
    font-weight: 700;
  }

  .object-mobile-card-head span {
    color: var(--muted);
    font-weight: 600;
  }

  .object-mobile-card-title {
    margin-bottom: 10px;
    color: var(--text);
    font-weight: 700;
    line-height: 1.3;
  }

  .object-mobile-meta {
    display: grid;
    grid-template-columns: 116px minmax(0, 1fr);
    gap: 6px 10px;
    margin: 0;
    font-size: 0.86rem;
  }

  .object-mobile-meta dt {
    color: var(--muted);
    font-weight: 700;
  }

  .object-mobile-meta dd {
    margin: 0;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .object-mobile-apartments {
    margin-top: 10px;
    color: var(--muted);
    font-size: 0.84rem;
  }

  .object-mobile-empty {
    padding: 20px 0;
  }
}

/* ============================================
   COLLAPSIBLE CREATE FORMS
   ============================================ */
.collapsible-form {
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  background:
    var(--surface-strong),
    var(--surface-strong);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.collapsible-form > summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  cursor: pointer;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  list-style: none;
  user-select: none;
  transition: background-color 0.2s ease;
}

.collapsible-form > summary::-webkit-details-marker {
  display: none;
}

.collapsible-form > summary::after {
  content: '+';
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--role-soft);
  color: var(--role-accent);
  font-size: 1.4rem;
  font-weight: 800;
  transition: transform 0.25s ease;
}

.collapsible-form[open] > summary::after {
  content: '\2212';
  transform: rotate(180deg);
}

.collapsible-form > summary:hover {
  background: var(--surface-muted);
}

.collapsible-form > .form-body {
  padding: 0 24px 24px;
}

@media (max-width: 640px) {
  .collapsible-form > summary {
    padding: 16px 18px;
    font-size: 1.05rem;
  }

  .collapsible-form > .form-body {
    padding: 0 18px 18px;
  }
}

/* ============================================
   IMPROVED OFFLINE BANNER (visible only offline)
   ============================================ */
.offline-banner.is-visible {
  background: #fbbf24;
  color: #78350f;
  font-size: 0.85rem;
  border-top: 2px solid #f59e0b;
}

/* ============================================
   TABLE SCROLL HINTS
   ============================================ */
.table-wrap {
  position: relative;
}

.table-wrap::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 30px;
  background: linear-gradient(to left, var(--bg-alt), transparent);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.table-wrap.has-scroll::after {
  opacity: 1;
}

/* ============================================
   BETTER STAT CARDS ON MOBILE
   ============================================ */
@media (max-width: 480px) {
  .metric-card,
  .stat-card {
    min-height: 80px;
    padding: 14px;
    border-radius: 16px;
    flex-direction: row;
    align-items: center;
  }

  .metric-card strong,
  .stat-card strong {
    font-size: 1.3rem;
  }

  .workspace-stats,
  .compact-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ============================================
   SETTINGS KEY-VALUE IMPROVEMENTS
   ============================================ */
.settings-group {
  margin-bottom: 24px;
}

.settings-group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  margin-bottom: 12px;
  border-bottom: 2px solid var(--role-soft-strong);
  color: var(--role-accent);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.settings-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-label {
  font-weight: 700;
  font-size: 0.92rem;
}

.settings-hint {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 2px;
}

@media (max-width: 640px) {
  .settings-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

/* ============================================
   REPORT GROUPS
   ============================================ */
.report-group {
  margin-bottom: 16px;
}

.report-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-radius: 16px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  cursor: pointer;
  font-weight: 700;
  transition: background-color 0.2s ease;
}

.report-group-header:hover {
  background: var(--surface-muted);
}

.report-group-body {
  padding: 12px 0;
}

.report-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-radius: 12px;
  transition: background-color 0.15s ease;
}

.report-item:hover {
  background: var(--surface-muted);
}

.report-item-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.report-formats {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.report-formats .btn {
  min-height: 32px;
  padding: 6px 12px;
  font-size: 0.78rem;
  border-radius: 10px;
}

@media (max-width: 640px) {
  .report-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .report-formats {
    width: 100%;
  }

  .report-formats .btn {
    flex: 1;
  }
}

/* ============================================
   DASHBOARD AUDIT LOG IMPROVEMENTS
   ============================================ */
.audit-mini-list {
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
}

.audit-mini-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-muted);
  font-size: 0.88rem;
}

.audit-mini-action {
  font-weight: 700;
  color: var(--text);
}

.audit-mini-time {
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

/* ============================================
   SIDEBAR POLISH
   ============================================ */
.sidebar-foot .btn-danger {
  background: rgba(180, 35, 24, 0.12);
  color: var(--danger);
  border: 1px solid rgba(180, 35, 24, 0.18);
  font-size: 0.82rem;
  box-shadow: none;
}

.sidebar-foot .btn-danger:hover {
  background: rgba(180, 35, 24, 0.2);
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 0 4px;
  flex-wrap: wrap;
}

.pagination-info {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pagination-btn {
  display: grid;
  place-items: center;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  cursor: pointer;
}

.pagination-btn:hover:not(.disabled):not(.active) {
  background: var(--surface-muted);
  border-color: var(--line-strong);
}

.pagination-btn.active {
  background: var(--role-accent);
  color: #fff;
  border-color: var(--role-accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.pagination-btn.disabled {
  opacity: 0.35;
  cursor: default;
}

.pagination-ellipsis {
  padding: 0 4px;
  color: var(--muted);
  font-size: 0.88rem;
}

@media (max-width: 480px) {
  .pagination {
    justify-content: center;
    gap: 8px;
  }

  .pagination-info {
    width: 100%;
    text-align: center;
  }

  .pagination-btn {
    min-width: 32px;
    height: 32px;
    font-size: 0.82rem;
  }
}

/* ============================================
   GENERAL POLISH
   ============================================ */
.page-hero h1,
.workspace-hero h1 {
  font-size: clamp(1.25rem, 1.6vw, 1.55rem);
  margin: 0;
}

.page-hero p,
.workspace-hero p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

@media (max-width: 480px) {
  .page-hero,
  .workspace-hero {
    padding: 18px 16px;
    border-radius: 20px;
  }

  .page-hero h1 {
    font-size: 1.5rem;
  }

  .eyebrow {
    font-size: 0.7rem;
  }

  .panel,
  .surface-card {
    padding: 16px;
    border-radius: 20px;
  }

  .section-head {
    flex-direction: column;
  }

  .toolbar {
    width: 100%;
  }

  .toolbar .input.compact {
    min-width: 0;
    flex: 1;
  }
}

/* ============================================
   MODAL DIALOG
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.modal-overlay.is-active {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  background: var(--surface);
  border-radius: 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  max-width: 440px;
  width: calc(100% - 32px);
  padding: 28px 24px 20px;
  transform: translateY(12px) scale(0.97);
  transition: transform 0.2s;
}

.modal-overlay.is-active .modal-box {
  transform: translateY(0) scale(1);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

.modal-body {
  font-size: 0.95rem;
  color: var(--muted);
  margin-bottom: 20px;
  line-height: 1.5;
}

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

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border-left: 4px solid var(--role-accent);
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
  padding: 14px 18px;
  font-size: 0.92rem;
  max-width: 380px;
  pointer-events: auto;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.25s, transform 0.25s;
  cursor: pointer;
}

.toast.is-visible {
  opacity: 1;
  transform: translateX(0);
}

.toast.toast-success {
  border-left-color: var(--success, #16a34a);
}

.toast.toast-error {
  border-left-color: var(--danger, #dc2626);
}

.toast.toast-warning {
  border-left-color: var(--warning, #d97706);
}

@media (max-width: 480px) {
  .toast-container {
    left: 16px;
    right: 16px;
  }

  .toast {
    max-width: 100%;
  }

  .modal-box {
    padding: 22px 18px 16px;
  }
}

/* ============================================
   LOADING / SPINNER
   ============================================ */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--line);
  border-top-color: var(--role-accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.btn.is-loading {
  pointer-events: none;
  opacity: 0.7;
  position: relative;
}

.btn.is-loading::after {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}

.htmx-request .spinner-target::after {
  content: '';
  display: block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--line);
  border-top-color: var(--role-accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin: 24px auto;
}

.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator {
  display: inline-block;
}

.skeleton {
  background: linear-gradient(90deg, var(--line) 25%, #f3f4f6 50%, var(--line) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: 8px;
  min-height: 1em;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================
   SORTABLE TABLE HEADERS
   ============================================ */
th[data-sort] {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

th[data-sort]:hover {
  color: var(--role-accent);
}

th[data-sort]::after {
  content: '\2195';
  margin-left: 4px;
  opacity: 0.3;
  font-size: 0.8em;
}

th[data-sort].sort-asc::after {
  content: '\2191';
  opacity: 0.8;
}

th[data-sort].sort-desc::after {
  content: '\2193';
  opacity: 0.8;
}

/* ============================================
   FORM VALIDATION
   ============================================ */
.field-error {
  color: var(--danger, #dc2626);
  font-size: 0.82rem;
  margin-top: 4px;
  display: none;
}

.field.has-error .input {
  border-color: var(--danger, #dc2626);
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.12);
}

.field.has-error .field-error {
  display: block;
}

.field.is-valid .input {
  border-color: var(--success, #16a34a);
}

/* ============================================
   BREADCRUMBS
   ============================================ */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.breadcrumbs a {
  color: var(--muted);
  text-decoration: none;
}

.breadcrumbs a:hover {
  color: var(--role-accent);
}

.breadcrumbs .sep {
  opacity: 0.4;
  color: var(--line-strong);
}

.breadcrumbs .current {
  color: var(--text);
  font-weight: 600;
}

/* ============================================
   EMPTY STATES
   ============================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 8px;
  opacity: 0.3;
  color: var(--muted);
}

.empty-state-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.empty-state-hint {
  font-size: 0.9rem;
  max-width: 360px;
  margin: 0 auto 12px;
  line-height: 1.5;
  color: var(--muted);
}

/* ============================================
   COMMAND PALETTE (Ctrl+K)
   ============================================ */
.cmd-palette-overlay {
  position: fixed;
  inset: 0;
  z-index: 9800;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s, visibility 0.15s;
}

.cmd-palette-overlay.is-active {
  opacity: 1;
  visibility: visible;
}

.cmd-palette {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25);
  max-width: 520px;
  width: calc(100% - 32px);
  overflow: hidden;
}

.cmd-palette-input {
  width: 100%;
  padding: 16px 20px;
  border: none;
  border-bottom: 1px solid var(--line);
  font-size: 1rem;
  background: transparent;
  color: var(--text);
  outline: none;
}

.cmd-palette-results {
  max-height: 320px;
  overflow-y: auto;
}

.cmd-palette-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: background 0.1s;
}

.cmd-palette-item:hover,
.cmd-palette-item.is-active {
  background: var(--surface-muted);
}

.cmd-palette-item .cmd-label {
  flex: 1;
}

.cmd-palette-item .cmd-hint {
  font-size: 0.8rem;
  color: var(--muted);
}

.cmd-palette-footer {
  padding: 8px 20px;
  border-top: 1px solid var(--line);
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  gap: 16px;
}

.cmd-palette-footer kbd {
  background: var(--line);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.75rem;
}

/* ============================================
   STICKY TABLE HEADERS
   ============================================ */
.table-wrap table thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 2;
  box-shadow: 0 1px 0 var(--line);
}

/* ============================================
   RELATIVE TIME
   ============================================ */
time[data-relative] {
  cursor: help;
}

/* ============================================
   BATCH SELECT
   ============================================ */
.batch-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--role-accent);
}

.batch-bar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--role-accent);
  color: #fff;
  border-radius: 12px;
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.batch-bar.is-visible {
  display: flex;
}

.batch-bar .batch-count {
  font-weight: 700;
}

.batch-bar .btn {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border: none;
}

.batch-bar .btn:hover {
  background: rgba(255, 255, 255, 0.35);
}

/* ============================================
   SKIP TO CONTENT (A11Y)
   ============================================ */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10000;
  padding: 8px 16px;
  background: var(--role-accent);
  color: #fff;
  border-radius: 0 0 8px 0;
  font-size: 0.9rem;
  text-decoration: none;
}

.skip-link:focus {
  left: 0;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  .sidebar,
  .nav-toggle,
  .nav-overlay,
  .hero-actions,
  .collapsible-form,
  .filter-grid,
  .toolbar,
  .pagination,
  .toast-container,
  .modal-overlay,
  .cmd-palette-overlay,
  .batch-bar,
  .offline-banner,
  .breadcrumbs,
  .skip-link,
  .btn {
    display: none !important;
  }

  .layout {
    display: block !important;
  }

  .content {
    margin: 0 !important;
    padding: 0 !important;
  }

  .surface-card,
  .panel {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
    break-inside: avoid;
  }

  .page-hero {
    background: none !important;
    color: #000 !important;
    padding: 8px 0 !important;
    border-radius: 0 !important;
  }

  .page-hero h1 {
    font-size: 1.4rem !important;
    color: #000 !important;
  }

  .page-hero .eyebrow,
  .page-hero p {
    color: #333 !important;
  }

  table {
    font-size: 0.85rem !important;
  }

  th, td {
    padding: 4px 8px !important;
  }

  a {
    color: #000 !important;
    text-decoration: none !important;
  }

  body {
    font-size: 12pt;
    color: #000;
    background: #fff;
  }
}

/* ============================================
   STATUS BADGES (color-coded)
   ============================================ */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Transfer statuses */
.status-badge.st-draft { background: #f3f4f6; color: #6b7280; }
.status-badge.st-draft::before { background: #9ca3af; }

.status-badge.st-awaiting_otp_send,
.status-badge.st-code_sent,
.status-badge.st-code_verified,
.status-badge.st-partially_signed { background: #fef3c7; color: #92400e; }
.status-badge.st-awaiting_otp_send::before,
.status-badge.st-code_sent::before,
.status-badge.st-code_verified::before,
.status-badge.st-partially_signed::before { background: #f59e0b; }

.status-badge.st-signed { background: #d1fae5; color: #065f46; }
.status-badge.st-signed::before { background: #10b981; }

.status-badge.st-declined,
.status-badge.st-annulled { background: #fee2e2; color: #991b1b; }
.status-badge.st-declined::before,
.status-badge.st-annulled::before { background: #ef4444; }

.status-badge.st-expired,
.status-badge.st-replaced { background: #f3f4f6; color: #6b7280; }
.status-badge.st-expired::before,
.status-badge.st-replaced::before { background: #6b7280; }

/* Conditioner statuses */
.status-badge.st-installed { background: #dbeafe; color: #1e40af; }
.status-badge.st-installed::before { background: #3b82f6; }

.status-badge.st-removed { background: #fef3c7; color: #92400e; }
.status-badge.st-removed::before { background: #f59e0b; }

.status-badge.st-accepted_at_warehouse,
.status-badge.st-responsible_storage { background: #e0e7ff; color: #3730a3; }
.status-badge.st-accepted_at_warehouse::before,
.status-badge.st-responsible_storage::before { background: #6366f1; }

.status-badge.st-transferred_to_owner,
.status-badge.st-transferred_to_customer { background: #d1fae5; color: #065f46; }
.status-badge.st-transferred_to_owner::before,
.status-badge.st-transferred_to_customer::before { background: #10b981; }

.status-badge.st-written_off { background: #f3f4f6; color: #6b7280; }
.status-badge.st-written_off::before { background: #6b7280; }

/* Return request statuses */
.status-badge.st-requested { background: #dbeafe; color: #1e40af; }
.status-badge.st-requested::before { background: #3b82f6; }

.status-badge.st-agreed,
.status-badge.st-issued { background: #fef3c7; color: #92400e; }
.status-badge.st-agreed::before,
.status-badge.st-issued::before { background: #f59e0b; }

.status-badge.st-completed { background: #d1fae5; color: #065f46; }
.status-badge.st-completed::before { background: #10b981; }

.status-badge.st-no_response,
.status-badge.st-cancelled { background: #f3f4f6; color: #6b7280; }
.status-badge.st-no_response::before,
.status-badge.st-cancelled::before { background: #6b7280; }

/* Escalation */
.status-badge.st-open { background: #fee2e2; color: #991b1b; }
.status-badge.st-open::before { background: #ef4444; }

.status-badge.st-resolved { background: #d1fae5; color: #065f46; }
.status-badge.st-resolved::before { background: #10b981; }

/* ============================================
   USER AVATAR / INITIALS
   ============================================ */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
}

.avatar.avatar-sm { width: 26px; height: 26px; font-size: 0.65rem; }
.avatar.avatar-lg { width: 40px; height: 40px; font-size: 0.9rem; }

.avatar.role-admin { background: #7c3aed; }
.avatar.role-technical_supervisor { background: #2563eb; }
.avatar.role-technical_supervisor { background: #0891b2; }
.avatar.role-contractor_employee { background: #059669; }
.avatar.role-contractor_employee { background: #65a30d; }
.avatar.role-warehouse_employee { background: #d97706; }
.avatar.role-technical_supervisor { background: #dc2626; }

/* ============================================
   ROW HOVER ACTIONS
   ============================================ */
.row-actions {
  opacity: 0;
  transition: opacity 0.15s;
  display: flex;
  gap: 4px;
}

tr:hover .row-actions {
  opacity: 1;
}

.row-actions .btn {
  padding: 2px 8px;
  font-size: 0.78rem;
}

@media (max-width: 768px) {
  .row-actions {
    opacity: 1;
  }
}

/* ============================================
   EXPANDABLE ROLE ROWS
   ============================================ */
.roles-table tbody tr.role-expand-row > td {
  background: var(--surface-muted, rgba(0, 0, 0, 0.02));
  padding: 16px 20px;
  border-top: none;
}

.role-perm-form .grid-2 {
  margin-bottom: 12px;
}

/* ============================================
   INLINE ROW ACTIONS (always visible, compact)
   ============================================ */
.row-actions-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.row-actions-inline .btn {
  padding: 4px 10px;
  font-size: 0.82rem;
}

.row-actions-inline form {
  margin: 0;
}

/* ============================================
   CLICKABLE USER ROW
   ============================================ */
.user-row-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.user-row-link:hover strong {
  color: var(--accent);
}

.user-row-text {
  display: inline-flex;
  flex-direction: column;
  line-height: 1.3;
}

.user-row-text .muted {
  font-size: 0.82rem;
}

/* ============================================
   COLLAPSIBLE SIDEBAR
   ============================================ */
.sidebar-collapse-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--muted);
  margin: 8px auto;
  transition: transform 0.2s;
}

@media (min-width: 769px) {
  .sidebar-collapse-btn {
    display: flex;
  }

  .sidebar.is-collapsed {
    width: 64px;
    overflow: hidden;
  }

  .sidebar.is-collapsed .sidebar-label,
  .sidebar.is-collapsed .sidebar-head,
  .sidebar.is-collapsed .sidebar-foot .note,
  .sidebar.is-collapsed .sidebar-foot form {
    display: none;
  }

  .sidebar.is-collapsed .nav-link {
    justify-content: center;
    padding: 10px;
    overflow: hidden;
    text-overflow: clip;
    white-space: nowrap;
    width: 44px;
    text-align: center;
  }

  .sidebar.is-collapsed .sidebar-collapse-btn {
    transform: rotate(180deg);
  }

  .sidebar.is-collapsed ~ .nav-overlay ~ .content {
    margin-left: 64px;
  }
}

/* ============================================
   TABLE CSV EXPORT BUTTON
   ============================================ */
.table-export-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 0.78rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.table-export-btn:hover {
  background: var(--surface-muted);
  color: var(--text);
}

/* ============================================
   SVG ICONS
   ============================================ */
.icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

/* ============================================
   DARK MODE
   ============================================ */
[data-theme="dark"] {
  color-scheme: dark;

  --bg:             #131210;
  --bg-alt:         #0d0c0a;
  --surface:        #1c1a16;
  --surface-strong: #252219;
  --surface-muted:  #272420;
  --surface-sunken: #141311;
  --surface-bright: #3a3933;
  --surface-tint:   rgba(28, 26, 22, 0.72);

  --fg:          #ece5d4;
  --fg-strong:   #fffaee;
  --fg-muted:    #a59d89;
  --fg-subtle:   #7c7563;
  --fg-inverse:  #141311;

  --line:        rgba(236, 229, 212, 0.08);
  --line-strong: rgba(236, 229, 212, 0.14);
  --line-heavy:  rgba(236, 229, 212, 0.24);

  --shadow-xs: 0 1px 0 rgba(0,0,0,.4);
  --shadow-sm: 0 2px 4px rgba(0,0,0,.35);
  --shadow-md: 0 8px 20px rgba(0,0,0,.45), 0 2px 4px rgba(0,0,0,.3);
  --shadow-lg: 0 20px 40px rgba(0,0,0,.55), 0 6px 12px rgba(0,0,0,.35);
  --shadow-xl: 0 32px 60px rgba(0,0,0,.6);

  --success: #3dd084;     --success-soft: rgba(61,208,132,.14);  --success-ink: #8aeab0;
  --warning: #f2b344;     --warning-soft: rgba(242,179,68,.14);  --warning-ink: #fbd89a;
  --danger:  #f16a5f;     --danger-soft:  rgba(241,106,95,.14);  --danger-ink:  #ffa59c;
  --info:    #6b8efb;     --info-soft:    rgba(107,142,251,.14); --info-ink:    #b7c6fd;

  /* Status palette (dark) */
  --st-draft-bg:     rgba(143,134,114,.16);  --st-draft-fg:     #c5bda9;  --st-draft-dot:     #8f8672;
  --st-pending-bg:   rgba(201,127,9,.18);    --st-pending-fg:   #f4c97a;  --st-pending-dot:   #eab94c;
  --st-otp-bg:       rgba(234,123,16,.2);    --st-otp-fg:       #ffa569;  --st-otp-dot:       #ea7b10;
  --st-signed-bg:    rgba(21,128,61,.22);    --st-signed-fg:    #7fd9a4;  --st-signed-dot:    #3dd084;
  --st-declined-bg:  rgba(214,47,34,.2);     --st-declined-fg:  #fba195;  --st-declined-dot:  #ef5947;
  --st-annulled-bg:  rgba(140,90,84,.22);    --st-annulled-fg:  #caa19a;  --st-annulled-dot:  #b4857c;
  --st-installed-bg: rgba(47,91,234,.22);    --st-installed-fg: #a6bcfb;  --st-installed-dot: #6b8efb;
  --st-removed-bg:   rgba(107,63,216,.22);   --st-removed-fg:   #c3a5f7;  --st-removed-dot:   #a683f2;
  --st-storage-bg:   rgba(63,79,212,.22);    --st-storage-fg:   #a8b3f3;  --st-storage-dot:   #7a86e8;
  --st-transit-bg:   rgba(106,138,45,.22);   --st-transit-fg:   #bbdc7d;  --st-transit-dot:   #9ac055;
  --st-disputed-bg:  rgba(214,115,25,.22);   --st-disputed-fg:  #f1b072;  --st-disputed-dot:  #e69449;
  --st-expired-bg:   rgba(122,107,94,.25);   --st-expired-fg:   #c6b6a5;  --st-expired-dot:   #9a8875;
  --st-returned-bg:  rgba(42,139,148,.22);   --st-returned-fg:  #7ecdd4;  --st-returned-dot:  #3fb0b9;

  /* Backward aliases */
  --text: var(--fg); --muted: var(--fg-muted); --muted-strong: var(--fg-muted);
}

[data-theme="dark"] .topbar {
  background: var(--surface);
  border-color: var(--line);
}

[data-theme="dark"] .sidebar {
  background: var(--bg-alt);
  border-color: var(--line);
}

[data-theme="dark"] .surface-card {
  background: var(--surface);
  border-color: var(--line);
}

[data-theme="dark"] table th {
  background: var(--bg-alt);
}

[data-theme="dark"] table td {
  border-color: var(--line);
}

[data-theme="dark"] .input {
  background: var(--bg-alt);
  border-color: var(--line-strong);
  color: var(--text);
}

[data-theme="dark"] .btn-ghost {
  color: var(--muted-strong);
  border-color: var(--line-strong);
}

[data-theme="dark"] .btn-ghost:hover {
  background: var(--surface-muted);
}

[data-theme="dark"] .modal-box,
[data-theme="dark"] .cmd-palette {
  background: var(--surface-strong);
  border-color: var(--line);
}

[data-theme="dark"] .flash {
  border-color: var(--line);
}

[data-theme="dark"] .metric-card {
  background: var(--surface);
  border-color: var(--line);
}

[data-theme="dark"] .page-hero {
  background: linear-gradient(135deg, var(--bg-alt) 0%, var(--bg) 100%);
}

[data-theme="dark"] .workspace-hero {
  background: linear-gradient(135deg, var(--bg-alt) 0%, var(--bg) 100%);
}

[data-theme="dark"] .queue-card,
[data-theme="dark"] .queue-panel {
  background: var(--surface);
  border-color: var(--line);
}

[data-theme="dark"] .queue-head {
  border-color: var(--line);
}

[data-theme="dark"] .picker-card,
[data-theme="dark"] .check-card {
  background: var(--surface);
  border-color: var(--line);
}

[data-theme="dark"] .badge,
[data-theme="dark"] .badge-soft {
  background: var(--surface-muted);
  color: var(--muted-strong);
}

[data-theme="dark"] .collapsible-form {
  border-color: var(--line);
}

[data-theme="dark"] .collapsible-form summary {
  background: var(--bg-alt);
}

[data-theme="dark"] .onboarding-banner {
  background: linear-gradient(135deg, var(--surface-muted) 0%, var(--bg-alt) 100%);
  border-color: var(--line);
}

[data-theme="dark"] .onboarding-step {
  background: var(--surface);
  border-color: var(--line);
}

[data-theme="dark"] .notif-dropdown {
  background: var(--surface-strong);
  border-color: var(--line);
}

[data-theme="dark"] .notif-item:hover {
  background: var(--surface-muted);
}

[data-theme="dark"] .drop-zone {
  border-color: var(--line-strong);
}

[data-theme="dark"] .shortcuts-panel {
  background: var(--surface-strong);
  border-color: var(--line);
}

[data-theme="dark"] .shortcut-key kbd {
  background: var(--surface-muted);
  border-color: var(--line);
}

[data-theme="dark"] .col-toggle-menu {
  background: var(--surface-strong);
  border-color: var(--line);
}

[data-theme="dark"] .col-toggle-menu label:hover {
  background: var(--surface-muted);
}

[data-theme="dark"] .scroll-top-btn {
  background: var(--surface-strong);
  border-color: var(--line);
}

[data-theme="dark"] .density-toggle {
  border-color: var(--line);
}

[data-theme="dark"] .density-toggle button:not(:last-child) {
  border-color: var(--line);
}

[data-theme="dark"] .form-footer {
  border-color: var(--line);
}

[data-theme="dark"] .inline-buttons .btn {
  border-color: var(--line);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  cursor: pointer;
  font-size: 1rem;
  color: var(--muted-strong);
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}

.theme-toggle:hover {
  background: var(--surface-muted);
  border-color: var(--line-strong);
  color: var(--text);
}

.theme-toggle:focus-visible {
  outline: none;
  border-color: var(--role-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--role-accent) 22%, transparent);
}

.theme-toggle .theme-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.theme-toggle .theme-icon-light {
  display: none;
}

[data-theme="dark"] .theme-toggle .theme-icon-dark {
  display: none;
}

[data-theme="dark"] .theme-toggle .theme-icon-light {
  display: inline-flex;
}

/* ============================================
   KEYBOARD SHORTCUTS PANEL
   ============================================ */
.shortcuts-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

.shortcuts-overlay.is-active {
  opacity: 1;
  pointer-events: auto;
}

.shortcuts-panel {
  background: var(--surface-strong, #fff);
  border: 1px solid var(--line);
  border-radius: var(--radius-md, 16px);
  padding: 24px 28px;
  width: 420px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.shortcuts-panel h3 {
  margin: 0 0 16px;
  font-size: 1.1rem;
  font-weight: 700;
}

.shortcut-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.shortcut-row:last-child {
  border-bottom: none;
}

.shortcut-key {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.shortcut-key kbd {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--bg-alt, #f3f4f6);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.6;
}

/* ============================================
   TABLE DENSITY TOGGLE
   ============================================ */
.density-toggle {
  display: inline-flex;
  border: 1px solid var(--line-strong, #e5e7eb);
  border-radius: 8px;
  overflow: hidden;
}

.density-toggle button {
  padding: 4px 10px;
  font-size: 0.75rem;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.15s, color 0.15s;
}

.density-toggle button.is-active {
  background: var(--role-soft);
  color: var(--role-accent);
  font-weight: 600;
}

.density-toggle button:not(:last-child) {
  border-right: 1px solid var(--line-strong, #e5e7eb);
}

body.density-compact table td,
body.density-compact table th {
  padding: 4px 8px;
  font-size: 0.82rem;
}

body.density-comfortable table td,
body.density-comfortable table th {
  padding: 14px 16px;
}

/* ============================================
   FORM STEPPER
   ============================================ */
.form-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 24px;
  padding: 0 8px;
}

.stepper-step {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.stepper-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--surface-muted);
  color: var(--muted);
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
}

.stepper-step.is-active .stepper-dot {
  background: var(--role-accent);
  color: #fff;
}

.stepper-step.is-done .stepper-dot {
  background: var(--success);
  color: #fff;
}

.stepper-label {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}

.stepper-step.is-active .stepper-label {
  color: var(--text);
  font-weight: 600;
}

.stepper-step.is-done .stepper-label {
  color: var(--success);
}

.stepper-line {
  flex: 1;
  height: 2px;
  background: var(--line);
  margin: 0 8px;
  min-width: 16px;
}

.stepper-step.is-done + .stepper-line {
  background: var(--success);
}

@media (max-width: 768px) {
  .form-stepper {
    overflow-x: auto;
    padding-bottom: 8px;
  }
  .stepper-label {
    display: none;
  }
}

/* ============================================
   DRAG AND DROP FILE UPLOAD
   ============================================ */
.drop-zone {
  border: 2px dashed var(--line-strong, #d1d5db);
  border-radius: var(--radius-md, 16px);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  color: var(--muted);
  font-size: 0.9rem;
}

.drop-zone:hover,
.drop-zone.is-dragover {
  border-color: var(--role-accent);
  background: var(--role-soft);
  color: var(--text);
}

.drop-zone-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.drop-zone-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 4px;
}

.drop-zone-preview {
  margin-top: 12px;
}

.drop-zone-preview img {
  max-width: 200px;
  max-height: 150px;
  border-radius: 8px;
  border: 1px solid var(--line);
}

/* ============================================
   TOP PROGRESS BAR
   ============================================ */
.top-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 3px;
  background: var(--role-accent, #0f766e);
  z-index: 9999;
  transition: width 0.3s ease;
  pointer-events: none;
}

.top-progress.is-active {
  animation: top-progress-indeterminate 1.8s ease-in-out infinite;
}

.top-progress.is-done {
  width: 100%;
  transition: width 0.15s ease;
}

@keyframes top-progress-indeterminate {
  0% { width: 0; left: 0; }
  50% { width: 60%; left: 20%; }
  100% { width: 0; left: 100%; }
}

/* ============================================
   SEARCH HIGHLIGHT
   ============================================ */
mark.search-hl {
  background: #fef08a;
  color: inherit;
  padding: 1px 2px;
  border-radius: 3px;
}

[data-theme="dark"] mark.search-hl {
  background: rgba(250, 204, 21, 0.3);
}

/* ============================================
   SCROLL TO TOP
   ============================================ */
.scroll-top-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line-strong, #e5e7eb);
  background: var(--surface-strong, #fff);
  color: var(--muted);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 900;
}

.scroll-top-btn.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.scroll-top-btn:hover {
  transform: translateY(-2px);
  color: var(--text);
}

@media print {
  .scroll-top-btn { display: none; }
}

/* ============================================
   DRAFT AUTO-SAVE INDICATOR
   ============================================ */
.draft-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.3s;
}

.draft-indicator.is-visible {
  opacity: 1;
}

.draft-indicator-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

/* ============================================
   COLUMN VISIBILITY TOGGLE
   ============================================ */
.col-toggle-wrap {
  position: relative;
  display: inline-block;
}

.col-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 0.78rem;
  border: 1px solid var(--line-strong, #e5e7eb);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.col-toggle-btn:hover {
  background: var(--bg-alt, #f3f4f6);
  color: var(--text);
}

.col-toggle-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--surface-strong, #fff);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 0;
  min-width: 180px;
  box-shadow: var(--shadow-md);
  z-index: 200;
  display: none;
}

.col-toggle-menu.is-open {
  display: block;
}

.col-toggle-menu label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  font-size: 0.84rem;
  cursor: pointer;
  transition: background 0.1s;
}

.col-toggle-menu label:hover {
  background: var(--bg-alt, #f3f4f6);
}

/* ============================================
   ONBOARDING WELCOME BANNER
   ============================================ */
.onboarding-banner {
  background: linear-gradient(135deg, var(--role-soft) 0%, var(--bg-alt, #fbf8f2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg, 22px);
  padding: 24px 28px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  position: relative;
}

.onboarding-banner-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.onboarding-banner h3 {
  margin: 0 0 6px;
  font-size: 1.1rem;
  font-weight: 700;
}

.onboarding-banner p {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.9rem;
}

.onboarding-steps {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.onboarding-step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 10px;
  background: var(--surface-strong, #fff);
  border: 1px solid var(--line);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.onboarding-step:hover {
  border-color: var(--role-accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.onboarding-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--role-accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}

.onboarding-dismiss {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--muted);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.onboarding-dismiss:hover {
  background: var(--surface-muted);
}

/* ============================================
   SKELETON LOADING
   ============================================ */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface-muted, #f0e7da);
  border-radius: 6px;
  min-height: 16px;
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 25%, rgba(255,255,255,0.4) 50%, transparent 75%);
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

[data-theme="dark"] .skeleton::after {
  background: linear-gradient(90deg, transparent 25%, rgba(255,255,255,0.08) 50%, transparent 75%);
}

@keyframes skeleton-shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.htmx-indicator.skeleton-table {
  display: none;
}

.htmx-request .htmx-indicator.skeleton-table {
  display: block;
}

.htmx-request #transfer-results {
  opacity: 0.4;
  pointer-events: none;
  transition: opacity 0.15s;
}

.skeleton-row {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.skeleton-cell {
  flex: 1;
  height: 16px;
}

.skeleton-cell.w-sm { max-width: 80px; }
.skeleton-cell.w-md { max-width: 160px; }
.skeleton-cell.w-lg { max-width: 280px; }

.skeleton-table {
  padding: 12px 16px;
}

/* ============================================
   NOTIFICATION BELL
   ============================================ */
.notif-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  cursor: pointer;
  font-size: 1rem;
  color: var(--muted-strong);
  transition: background 0.15s, color 0.15s;
}

.notif-bell:hover {
  background: var(--surface-muted);
  border-color: var(--line-strong);
  color: var(--text);
}

.notif-bell:focus-visible {
  outline: none;
  border-color: var(--role-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--role-accent) 22%, transparent);
}

.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 10px;
  background: var(--danger, #b42318);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.notif-badge:empty {
  display: none;
}

.notif-badge:not(:empty) {
  animation: badge-pulse 2s ease-in-out infinite;
}

@keyframes badge-pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.15); }
}

.notif-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  width: 340px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--surface-strong, #fff);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 500;
  display: none;
}

.notif-dropdown.is-open {
  display: block;
}

.notif-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 0.9rem;
}

.notif-item {
  display: flex;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 0.84rem;
  line-height: 1.5;
  transition: background 0.1s;
}

.notif-item:last-child {
  border-bottom: none;
}

.notif-item:hover {
  background: var(--bg-alt, #f3f4f6);
}

.notif-item.is-unread {
  background: var(--info-soft, rgba(29, 78, 216, 0.08));
}

.notif-icon {
  flex-shrink: 0;
  font-size: 1.1rem;
  margin-top: 2px;
}

.notif-text strong {
  display: block;
  font-size: 0.84rem;
}

.notif-text span {
  color: var(--muted);
  font-size: 0.78rem;
}

.notif-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ============================================
   KPI BARS & DISTRIBUTION
   ============================================ */
.kpi-bars {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.kpi-bar-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-bar-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.88rem;
}

.kpi-bar-head span {
  color: var(--muted);
}

.kpi-bar-head strong {
  font-weight: 700;
}

.kpi-bar-track {
  height: 10px;
  background: var(--surface-muted, #f0e7da);
  border-radius: 6px;
  overflow: hidden;
}

.kpi-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.5s ease;
  min-width: 2px;
}

.kpi-bar-success { background: var(--success, #16a34a); }
.kpi-bar-danger  { background: var(--danger, #b42318); }
.kpi-bar-warning { background: var(--warning, #d97706); }

.text-danger {
  color: var(--danger, #b42318);
}

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

.kpi-dist-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.kpi-dist-row .status-badge {
  min-width: 100px;
  text-align: center;
  flex-shrink: 0;
}

.kpi-dist-bar {
  flex: 1;
  height: 8px;
  background: var(--surface-muted, #f0e7da);
  border-radius: 4px;
  overflow: hidden;
}

.kpi-dist-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
  min-width: 2px;
}

.kpi-dist-row strong {
  min-width: 40px;
  text-align: right;
  font-size: 0.9rem;
  flex-shrink: 0;
}

/* Dark mode for KPI */
[data-theme="dark"] .kpi-bar-track,
[data-theme="dark"] .kpi-dist-bar {
  background: var(--surface-muted, #2a2a2a);
}

/* ============================================
   LEGAL PAGES
   ============================================ */
.legal-page {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  background: var(--bg, #faf8f5);
}

.legal-shell {
  max-width: 800px;
  width: 100%;
}

.legal-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.legal-nav a {
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--muted);
  border: 1px solid var(--line);
  transition: all 0.15s;
}

.legal-nav a:hover {
  color: var(--text);
  border-color: var(--role-accent);
}

.legal-nav a.active {
  background: var(--role-accent);
  color: #fff;
  border-color: var(--role-accent);
}

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

.legal-header h1 {
  margin: 0;
  font-size: 1.4rem;
}

.legal-text {
  line-height: 1.8;
  font-size: 0.95rem;
  color: var(--text);
  white-space: pre-line;
}

.legal-meta {
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
}

.legal-back {
  margin-top: 20px;
  text-align: center;
}

.legal-nav-inline {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-active {
  background: var(--role-accent) !important;
  color: #fff !important;
  border-color: var(--role-accent) !important;
}

/* ============================================
   CONSENT WITHDRAW
   ============================================ */
.consent-warning {
  background: var(--danger-soft, rgba(180, 35, 24, 0.08));
  border: 1px solid var(--danger, #b42318);
  border-radius: var(--radius-lg, 22px);
  padding: 20px 24px;
  margin-bottom: 16px;
}

.consent-warning strong {
  display: block;
  margin-bottom: 8px;
  color: var(--danger, #b42318);
}

.consent-warning ul {
  margin: 8px 0 0;
  padding-left: 20px;
  line-height: 1.8;
  font-size: 0.9rem;
}

/* ============================================
   LEGAL FOOTER
   ============================================ */
.legal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.legal-footer a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}

.legal-footer a:hover {
  color: var(--text);
}

.auth-legal-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.auth-legal-footer a {
  color: var(--muted);
  text-decoration: none;
}

.auth-legal-footer a:hover {
  color: var(--text);
}

/* ============================================
   SIGNER WIZARD — простой пошаговый интерфейс
   ============================================ */
.signer-compact-hero {
  text-align: center;
  padding: 24px 16px 16px;
}

.signer-act-label {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 20px;
  background: var(--role-accent, #0f766e);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.signer-compact-hero h1 {
  font-size: 1.4rem;
  margin: 0 0 6px;
}

.signer-compact-hero p {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0;
}

/* Progress dots */
.wizard-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 16px 0 8px;
}

.wizard-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  border: 2px solid var(--line);
  color: var(--muted);
  background: var(--surface-strong, #fff);
  flex-shrink: 0;
  transition: all 0.2s;
}

.wizard-dot.is-active {
  border-color: var(--role-accent, #0f766e);
  background: var(--role-accent, #0f766e);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.15);
}

.wizard-dot.is-done {
  border-color: var(--success, #16a34a);
  background: var(--success, #16a34a);
  color: #fff;
}

.wizard-line {
  height: 3px;
  width: 60px;
  background: var(--line);
  border-radius: 2px;
  transition: background 0.3s;
}

.wizard-line.is-done {
  background: var(--success, #16a34a);
}

/* Wizard card */
.wizard-card {
  background: var(--surface-strong, #fff);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px 24px;
  margin: 12px 0;
}

.wizard-card h2 {
  font-size: 1.3rem;
  margin: 0 0 8px;
  text-align: center;
}

.wizard-card > p {
  color: var(--muted);
  text-align: center;
  font-size: 0.9rem;
  margin: 0 0 20px;
}

.wizard-done, .wizard-refused {
  text-align: center;
  padding: 40px 24px;
}

.wizard-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

/* Wizard form */
.wizard-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.wizard-form .field label {
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.input-lg {
  min-height: 52px;
  font-size: 1.05rem;
  padding: 12px 16px;
}

.btn-lg {
  min-height: 54px;
  font-size: 1.05rem;
  font-weight: 700;
}

/* Signature actions */
.wizard-sig-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.wizard-sig-actions .btn {
  flex: 1;
  font-size: 0.82rem;
}

/* Consent checkboxes */
.wizard-consents {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 0;
}

.wizard-consent-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.88rem;
  line-height: 1.5;
  cursor: pointer;
}

.wizard-consent-row input[type="checkbox"] {
  margin-top: 3px;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.wizard-consent-row a {
  color: var(--role-accent, #0f766e);
  text-decoration: underline;
}

/* Refuse toggle */
.wizard-refuse-toggle {
  margin-top: 12px;
}

.wizard-refuse-panel {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.wizard-refuse-panel h3 {
  font-size: 1rem;
  margin: 0 0 4px;
  color: var(--danger, #b42318);
}

/* Details for act info */
.wizard-details {
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.wizard-details summary {
  padding: 12px 16px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg-alt, #f3f4f6);
  list-style: none;
}

.wizard-details summary::-webkit-details-marker { display: none; }

.wizard-details summary::before {
  content: '+ ';
  font-weight: 700;
}

.wizard-details[open] summary::before {
  content: '- ';
}

.wizard-details-body {
  padding: 14px 16px;
}

.wizard-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.wizard-info-grid div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wizard-info-grid strong {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.wizard-info-grid span {
  font-size: 0.9rem;
}

.wizard-equip-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 8px;
}

.wizard-equip-card strong {
  font-size: 0.92rem;
}

.wizard-equip-card span {
  font-size: 0.84rem;
}

.wizard-consent-note {
  text-align: center;
  padding: 12px 16px;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.6;
}

/* Dark mode wizard */
[data-theme="dark"] .wizard-card {
  background: var(--surface-strong, #1e1e1e);
}

[data-theme="dark"] .wizard-details summary {
  background: var(--surface-muted, #2a2a2a);
}

[data-theme="dark"] .wizard-equip-card {
  border-color: var(--line);
}

/* ============================================
   FLOW WIZARD — acts.html пошаговый режим
   ============================================ */
.flow-section.wizard-hidden {
  display: none;
}

.flow-wizard-nav {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.flow-wizard-nav .btn {
  min-width: 120px;
}

/* ============================================
   QUICK ACTION TILES — крупные кнопки для полевых
   ============================================ */
.quick-actions-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  padding: 0 0 8px;
}

.quick-action-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 12px;
  border-radius: 14px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  text-align: center;
  transition: transform 0.12s, box-shadow 0.15s, border-color 0.15s, background 0.15s;
  min-height: 88px;
  justify-content: center;
}

.quick-action-tile .quick-action-icon {
  color: var(--role-accent);
}

.quick-action-tile:active {
  transform: scale(0.98);
}

.quick-action-tile:hover {
  background: var(--role-soft);
  border-color: var(--role-accent);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
}

.quick-action-icon {
  font-size: 1.6rem;
  line-height: 1;
}

@media (max-width: 480px) {
  .quick-actions-strip {
    grid-template-columns: repeat(2, 1fr);
  }
  .quick-action-tile {
    padding: 14px 8px;
    min-height: 76px;
    font-size: 0.85rem;
  }
}

/* ============================================
   EQUIPMENT CARDS — карточки оборудования
   ============================================ */
.equip-card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.equip-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  background: var(--surface-strong, #fff);
  transition: border-color 0.15s;
}

.equip-card:hover {
  border-color: var(--role-accent, #0f766e);
}

.equip-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.equip-card-head strong {
  font-size: 1rem;
  display: block;
}

.equip-card-title {
  display: block;
  font-size: 0.88rem;
  color: var(--muted);
  margin-top: 2px;
}

.equip-card-info {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 0.84rem;
  color: var(--muted);
  margin-bottom: 10px;
}


/* Clickable equip-card as <a> */
a.equip-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
a.equip-card-link:hover {
  border-color: var(--role-accent, #0f766e);
  box-shadow: 0 2px 8px rgba(0,0,0,.06);
}
.equip-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.equip-card-actions .btn {
  flex: 1;
  min-width: 80px;
  text-align: center;
}

.equip-demolish-details {
  flex: 1;
  min-width: 80px;
}

.equip-demolish-details summary {
  list-style: none;
  cursor: pointer;
  text-align: center;
  width: 100%;
}

.equip-demolish-details summary::-webkit-details-marker { display: none; }

.equip-demolish-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

[data-theme="dark"] .equip-card {
  background: var(--surface-strong, #1e1e1e);
}

/* ============================================
   INLINE FORM ROW (desktop flex → mobile stack)
   ============================================ */
.inline-form-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.inline-form-row .field {
  flex: 1;
  min-width: 180px;
}

/* ============================================
   MOBILE TOUCH IMPROVEMENTS (≤640px)
   Larger touch-targets, wider gaps, thumb-friendly
   ============================================ */
@media (max-width: 640px) {
  .field {
    gap: 10px;
    margin-bottom: 18px;
  }

  .field label {
    font-size: 0.95rem;
  }

  .grid-2 {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .grid-3 {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .btn {
    min-height: 50px;
    font-size: 1rem;
    padding: 12px 18px;
    border-radius: 14px;
    max-width: 100%;
    white-space: normal;
    text-align: center;
  }

  .btn-icon,
  .btn-icon-only {
    white-space: nowrap;
  }

  .input {
    min-height: 50px;
    font-size: 1rem;
    padding: 14px 16px;
  }

  select.input {
    font-size: 1rem;
  }

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

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

  .stage-progress-table th,
  .stage-progress-table td {
    padding: 10px 8px;
  }

  .stage-progress-table th:first-child,
  .stage-progress-table td:first-child {
    width: 44%;
    white-space: normal !important;
    overflow-wrap: break-word;
  }

  .checkbox-row label {
    gap: 12px;
    font-size: 0.95rem;
    min-height: 44px;
    align-items: center;
  }

  .checkbox-row input[type="checkbox"] {
    width: 22px;
    height: 22px;
    min-width: 22px;
  }

  .section-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .page-hero,
  .workspace-hero {
    padding: 20px 16px;
  }

  .page-hero h1,
  .workspace-hero h1 {
    font-size: 1.4rem;
  }

  .hero-actions {
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }

  .hero-actions .btn {
    width: 100%;
  }

  .surface-card {
    padding: 18px 14px;
    border-radius: 16px;
  }

  .filter-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .filter-grid .btn {
    width: 100%;
  }

  .collapsible-form > summary {
    font-size: 1.05rem;
    padding: 14px 18px;
    min-height: 50px;
  }

  .status-badge {
    font-size: 0.82rem;
    padding: 5px 12px;
  }

  .breadcrumbs {
    font-size: 0.9rem;
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 4px;
  }

  .equip-card-actions {
    flex-direction: column;
    gap: 8px;
  }

  .equip-card-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .timeline-item {
    padding: 14px;
  }

  .topbar .user-chip {
    font-size: 0.85rem;
    padding: 6px 12px;
  }

  .inline-form-row {
    flex-direction: column;
    gap: 12px;
  }

  .inline-form-row .field {
    min-width: 0;
    width: 100%;
  }

  .inline-form-row .btn {
    width: 100%;
  }
}

/* ============================================
   EXTRA-SMALL SCREENS (≤400px)
   ============================================ */
@media (max-width: 400px) {
  .btn {
    min-height: 52px;
    font-size: 1.05rem;
  }

  .input {
    min-height: 52px;
    font-size: 1.05rem;
  }

  .quick-action-tile {
    min-height: 76px;
    font-size: 0.95rem;
  }

  .workspace-stats {
    grid-template-columns: 1fr;
  }

  .equip-card-info {
    font-size: 0.88rem;
  }

  .page-hero h1,
  .workspace-hero h1 {
    font-size: 1.2rem;
  }
}

/* ==========================================================================
   Error screen — standalone 4xx/5xx pages
   ========================================================================== */
.error-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background:
    radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb, var(--role-accent) 10%, transparent) 0%, transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-alt) 100%);
}

.error-card {
  width: 100%;
  max-width: 480px;
  padding: 40px 36px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.error-eyebrow {
  display: inline-block;
  padding: 4px 12px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--role-accent);
  background: color-mix(in srgb, var(--role-accent) 10%, transparent);
  border-radius: var(--radius-pill);
  margin-bottom: 20px;
}

.error-title {
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.2;
  margin: 0 0 12px;
  color: var(--text);
  letter-spacing: -0.01em;
}

.error-message {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--muted);
  margin: 0 0 28px;
}

.error-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

@media (max-width: 480px) {
  .error-card {
    padding: 32px 24px;
  }
  .error-title {
    font-size: 1.4rem;
  }
}

/* ==========================================================================
   Theme toggle — floating variant (unauth pages)
   ========================================================================== */
.theme-toggle-floating {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 40;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: var(--surface-strong);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.theme-toggle-floating:hover {
  transform: translateY(-1px);
  background: var(--surface-muted);
  border-color: var(--line-strong);
}

.theme-toggle-floating:focus-visible {
  outline: 2px solid var(--role-accent);
  outline-offset: 2px;
}

.route-steps {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.route-step {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.route-step-link {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 16px;
  padding: 14px 16px;
  align-items: start;
  color: inherit;
  text-decoration: none;
}
a.route-step-link { cursor: pointer; }
a.route-step-link:hover,
a.route-step-link:focus-visible {
  text-decoration: none;
}
.route-step:has(> a.route-step-link:hover),
.route-step:has(> a.route-step-link:focus-visible) {
  border-color: rgba(37,99,235,0.55);
  box-shadow: 0 2px 10px rgba(37,99,235,0.12);
  transform: translateY(-1px);
}
.route-step-link.is-disabled { cursor: default; opacity: 0.85; }
.route-step.is-done { border-color: rgba(22,163,74,0.35); background: rgba(22,163,74,0.06); }
.route-step.is-current { border-color: rgba(37,99,235,0.45); background: rgba(37,99,235,0.06); box-shadow: 0 0 0 1px rgba(37,99,235,0.18); }
.route-step-bullet {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.95rem;
  background: var(--surface-muted); color: var(--text-muted);
}
.route-step.is-done .route-step-bullet { background: #16a34a; color: #fff; }
.route-step.is-current .route-step-bullet { background: #2563eb; color: #fff; }
.route-step-body { min-width: 0; }
.route-step-head {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 4px;
}
.route-step-title { margin: 0; font-size: 1rem; font-weight: 600; }
.route-step-code {
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em;
  padding: 2px 8px; border-radius: 999px;
  background: var(--surface-muted); color: var(--text-muted);
  border: 1px solid var(--line);
}
.route-step-meta {
  display: flex; flex-wrap: wrap; gap: 8px 14px;
  align-items: center; font-size: 0.88rem;
}
.route-step .muted-details { margin-top: 8px; }
.route-legend {
  margin-top: 18px; padding: 12px 14px;
  border: 1px dashed var(--line); border-radius: 10px;
  background: var(--surface-muted);
}
.route-legend > summary {
  cursor: pointer; font-weight: 600; color: var(--text-muted);
}
.route-legend ul { margin: 10px 0 0; padding-left: 20px; }
.route-step-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid transparent;
}
.route-step-pill.pill-done { background: #d1fae5; color: #065f46; border-color: rgba(6,95,70,0.18); }
.route-step-pill.pill-current { background: #dbeafe; color: #1e40af; border-color: rgba(30,64,175,0.22); }
.route-step-pill.pill-pending { background: var(--surface-muted); color: var(--text-muted); border-color: var(--line); }

.role-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}
.role-chip {
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.2;
}
.role-chip.is-active {
  background: var(--role-accent, #2563eb);
  color: #fff;
  border-color: transparent;
}

/* --- Tab Bar (simple navigation) --- */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border, #e5e7eb);
  margin-bottom: 1.5rem;
  padding: 0 1rem;
}
.tab-item {
  padding: 0.75rem 1.25rem;
  font-weight: 500;
  color: var(--muted, #6b7280);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.tab-item:hover {
  color: var(--text, #1f2937);
}
.tab-item.is-active {
  color: var(--teal, #0d9488);
  border-bottom-color: var(--teal, #0d9488);
}

/* --- Status Change Card --- */
.status-change-card {
  border-left: 4px solid var(--teal, #0d9488);
}
.status-change-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  flex-wrap: wrap;
}
.status-change-row select {
  min-width: 240px;
  flex: 0 1 auto;
}
.status-change-row input[type="text"] {
  flex: 1 1 200px;
  min-width: 160px;
}
.status-change-row .btn {
  flex-shrink: 0;
  white-space: nowrap;
}

/* --- Form Section (structured document forms) --- */
.form-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border, #e5e7eb);
}
.form-section:last-of-type { border-bottom: none; }
.form-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text, #1f2937);
  margin-bottom: 0.75rem;
}
.required-mark {
  color: #dc2626;
  font-weight: 700;
}

/* --- Checklist Grid (completeness, test modes) --- */
.checklist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.5rem;
}
.checklist-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.checklist-item:hover {
  background: var(--bg-card-hover, #f9fafb);
  border-color: var(--teal, #0d9488);
}
.checklist-item input[type="checkbox"] {
  accent-color: var(--teal, #0d9488);
  width: 1.1rem;
  height: 1.1rem;
}
.checklist-item input[type="checkbox"]:checked + span {
  color: var(--teal, #0d9488);
  font-weight: 500;
}

/* --- Signing Form (ACT-09 / documents) --- */
.signing-form { margin-top: 1rem; }
.signing-row {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}
.signing-row .field {
  flex: 1 1 200px;
  min-width: 160px;
}
.signing-row .field:last-child {
  flex: 0 0 auto;
}

/* --- Badge (for signer roles) --- */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
}
.badge-success {
  background: #d1fae5;
  color: #065f46;
}
.badge-warning {
  background: #fef3c7;
  color: #92400e;
}
.badge-pending {
  background: #e0e7ff;
  color: #3730a3;
}
.badge-priority-low {
  background: #e2e8f0;
  color: #475569;
}
.badge-priority-medium {
  background: #dbeafe;
  color: #1e40af;
}
.badge-priority-high {
  background: #fed7aa;
  color: #9a3412;
}
.badge-priority-urgent {
  background: #fecaca;
  color: #991b1b;
}
.st-new {
  background: #e0e7ff;
  color: #3730a3;
}
.st-in_progress {
  background: #dbeafe;
  color: #1e40af;
}
.st-review {
  background: #fef3c7;
  color: #92400e;
}
.st-done {
  background: #d1fae5;
  color: #065f46;
}
.st-cancelled {
  background: #e2e8f0;
  color: #64748b;
}

/* ============================================
   TRACKER — Overdue, Kanban, Quick Actions, Attachments
   ============================================ */

/* --- Overdue highlights --- */
.metric-card-overdue {
  border: 2px solid #ef4444;
  background: #fef2f2;
}
.metric-card-overdue strong {
  color: #dc2626;
}
.row-overdue {
  background: #fef2f2 !important;
  border-left: 3px solid #ef4444;
}
.row-overdue:hover {
  background: #fee2e2 !important;
}
.overdue-text {
  color: #dc2626;
  font-weight: 600;
}
.overdue-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-radius: var(--radius-pill);
  background: #fecaca;
  color: #991b1b;
}

/* --- View toggle --- */
.view-toggle {
  display: flex;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 2px;
}
.view-toggle .btn-active {
  background: var(--role-soft);
  color: var(--role-accent);
}

/* --- Filter grid 5-col --- */
.filter-grid-5 {
  display: grid;
  grid-template-columns: minmax(0, 2fr) repeat(3, minmax(0, 1fr)) minmax(0, 1fr) auto;
  gap: 12px;
}

/* --- Kanban board (Trello-style) --- */
.kanban-board {
  display: flex;
  gap: 12px;
  padding: 16px 0;
  min-height: 420px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  align-items: flex-start;
}
.kanban-column {
  flex: 1 1 0;
  min-width: 260px;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  background: var(--bg-alt);
  border-radius: var(--radius-lg);
  padding: 0;
  max-height: 75vh;
}
.kanban-column.drag-over {
  outline: 2px dashed var(--role-accent);
  outline-offset: -2px;
  background: var(--role-soft);
}
.kanban-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.kanban-column-header.kh-new { background: #e0e7ff; color: #3730a3; }
.kanban-column-header.kh-in_progress { background: #dbeafe; color: #1e40af; }
.kanban-column-header.kh-review { background: #fef3c7; color: #92400e; }
.kanban-column-header.kh-done { background: #d1fae5; color: #065f46; }
.kanban-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  background: rgba(0, 0, 0, 0.12);
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
}
.kanban-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  flex: 1;
  overflow-y: auto;
  min-height: 60px;
}
.kanban-card {
  position: relative;
  display: block;
  background: var(--surface-strong);
  border-radius: var(--radius-md);
  padding: 0;
  text-decoration: none;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  transition: box-shadow 0.15s, transform 0.12s;
  cursor: grab;
  overflow: hidden;
}
.kanban-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  transform: translateY(-1px);
}
.kanban-card:active {
  cursor: grabbing;
}
.kanban-card.dragging {
  opacity: 0.45;
  transform: rotate(3deg);
}
.kanban-card-color {
  height: 4px;
  width: 100%;
}
.kc-low { background: #94a3b8; }
.kc-medium { background: #3b82f6; }
.kc-high { background: #f97316; }
.kc-urgent { background: #ef4444; }
.kanban-card-body {
  padding: 8px 10px 10px;
}
.kanban-card-overdue {
  border-left: 3px solid #ef4444;
}
.kanban-card-labels {
  display: flex;
  gap: 4px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.kanban-label {
  display: inline-block;
  height: 8px;
  min-width: 36px;
  border-radius: 4px;
}
.kl-low { background: #cbd5e1; }
.kl-medium { background: #93c5fd; }
.kl-high { background: #fdba74; }
.kl-urgent { background: #fca5a5; }
.kanban-card-title {
  font-weight: 600;
  font-size: 0.84rem;
  line-height: 1.35;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.kanban-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.kanban-card-icons {
  display: flex;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--muted);
  align-items: center;
}
.kanban-card-icons span {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.kanban-card-due {
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--surface-muted);
  color: var(--muted);
}
.kanban-card-due.due-overdue {
  background: #fecaca;
  color: #991b1b;
}
.kanban-card-due.due-soon {
  background: #fef3c7;
  color: #92400e;
}
.kanban-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
  background: var(--role-accent);
  flex-shrink: 0;
  text-transform: uppercase;
}
.kanban-add-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 0.82rem;
  cursor: pointer;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  transition: background 0.12s, color 0.12s;
}
.kanban-add-btn:hover {
  background: var(--surface-muted);
  color: var(--text);
}
.kanban-quick-form {
  padding: 8px;
  display: none;
}
.kanban-quick-form.is-open {
  display: block;
}
.kanban-quick-form textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 8px;
  font-size: 0.84rem;
  resize: none;
  font-family: inherit;
  min-height: 54px;
}
.kanban-quick-form textarea:focus {
  outline: 2px solid var(--role-accent);
  outline-offset: -1px;
}
.kanban-quick-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  align-items: center;
}
.kanban-drop-placeholder {
  border: 2px dashed var(--role-accent);
  border-radius: var(--radius-md);
  min-height: 40px;
  background: var(--role-soft);
  opacity: 0.6;
  transition: min-height 0.15s;
}
.badge-sm {
  font-size: 0.65rem;
  padding: 1px 6px;
}

/* --- Quick actions in table --- */
.quick-actions-cell {
  white-space: nowrap;
}
.quick-actions {
  display: flex;
  gap: 4px;
}
.inline-form {
  display: inline;
}
.btn-quick {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-strong);
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.15s, border-color 0.15s;
  padding: 0;
}
.btn-quick:hover {
  border-color: var(--line-strong);
}
.btn-quick-in_progress:hover {
  background: #dbeafe;
  color: #1e40af;
}
.btn-quick-review:hover {
  background: #fef3c7;
  color: #92400e;
}
.btn-quick-done:hover {
  background: #d1fae5;
  color: #065f46;
}

/* --- Attachment grid --- */
.attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  padding: 8px 0;
}
.attachment-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.attachment-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg-alt);
}
.attachment-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.attachment-file {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.attachment-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.attachment-name {
  font-size: 0.8rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-upload-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

/* --- Bulk planner --- */
.bulk-object-select {
  max-width: 600px;
}
.bulk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 6px;
  padding: 8px 0;
}
.bulk-group-header {
  grid-column: 1 / -1;
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 8px 0 2px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2px;
}
.bulk-group-header:first-child {
  padding-top: 0;
}
.bulk-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
  font-size: 0.85rem;
  font-weight: 600;
  user-select: none;
}
.bulk-item:hover {
  background: var(--surface-muted);
  border-color: var(--line-strong);
}
.bulk-item:has(input:checked) {
  background: var(--role-soft);
  border-color: var(--role-accent);
  color: var(--role-accent);
}
.bulk-item input[type="checkbox"] {
  accent-color: var(--role-accent);
}
.bulk-item-label {
  white-space: nowrap;
}
.bulk-select-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}
.bulk-counter {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--role-accent);
  min-width: 90px;
}
.bulk-table-wrap {
  overflow-x: auto;
}
.bulk-table {
  width: 100%;
  border-collapse: collapse;
}
.bulk-table th,
.bulk-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 0.84rem;
}
.bulk-table thead th {
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  background: var(--bg-alt);
}
.bulk-table tbody tr:hover {
  background: var(--surface-muted);
}
.bulk-table input[type="checkbox"] {
  accent-color: var(--role-accent);
  width: 16px;
  height: 16px;
}
.bulk-submit-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.bulk-summary {
  font-size: 0.9rem;
  color: var(--text);
}
.bulk-summary strong {
  font-size: 1.1rem;
  color: var(--role-accent);
}
@media (max-width: 600px) {
  .bulk-grid {
    grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  }
  .bulk-select-controls {
    flex-wrap: wrap;
  }
  .bulk-submit-bar {
    flex-direction: column;
    gap: 8px;
  }
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .kanban-board {
    flex-direction: column;
  }
  .kanban-column {
    min-width: 100%;
    max-width: 100%;
    max-height: none;
  }
  .filter-grid-5 {
    grid-template-columns: 1fr;
  }
  .view-toggle {
    margin-top: 8px;
  }
}
@media (min-width: 901px) and (max-width: 1200px) {
  .filter-grid-5 {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* --- Grid helpers --- */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}
@media (max-width: 768px) {
  .grid-3 { grid-template-columns: 1fr; }
  .signing-row { flex-direction: column; }
  .signing-row .field { width: 100%; }
}

/* --- Button block variant --- */
.btn-block {
  display: block;
  width: 100%;
  text-align: center;
}

/* --- Geo autofill --- */
.geo-autofill {
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

/* --- Status bar chart (house registry) --- */
.status-bar-chart {
  display: grid;
  gap: 10px;
}
.status-bar-item {
  display: flex;
  align-items: center;
  gap: 12px;
}
.status-bar-item .status {
  min-width: 140px;
  text-align: right;
  flex-shrink: 0;
}
.status-bar-fill {
  background: var(--role-soft);
  border: 1px solid var(--role-soft-strong);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  min-width: 32px;
  text-align: center;
  transition: width 0.3s ease;
}

/* --- Signature table --- */
.sig-table {
  width: 100%;
  border-collapse: collapse;
}
.sig-table th,
.sig-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.sig-table th {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}
.sig-pending {
  color: var(--muted);
  font-style: italic;
}
.sig-done {
  color: var(--role-accent);
  font-weight: 600;
}

/* ============================================
   INLINE SIGNATURE FORM (document_detail)
   ============================================ */
.sign-inline-form {
  display: grid;
  gap: 16px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin-top: 16px;
  padding: 20px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  background: var(--surface-strong);
}

.sign-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  min-width: 0;
  max-width: 100%;
}

.sign-fields label {
  display: grid;
  gap: 6px;
  min-width: 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
}

.sign-fields select,
.sign-fields input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  font-size: 0.95rem;
}

.sign-canvas-wrap {
  display: grid;
  gap: 10px;
  min-width: 0;
  max-width: 100%;
}

.sign-canvas-wrap > label {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-primary);
}

.sign-canvas-wrap .signature-box {
  min-width: 0;
  max-width: 100%;
  touch-action: none;
}

.sign-canvas-wrap .signature-box canvas {
  display: block;
  width: 100%;
  min-height: 180px;
}

.sign-canvas-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}

.stacked-form,
.stacked-form .field,
.stacked-form label,
.stacked-form select,
.stacked-form textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.sign-geo-status {
  padding: 10px 16px;
  border-radius: 8px;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  font-size: 14px;
  margin-bottom: 12px;
}

.geo-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid #94a3b8;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

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

@media (max-width: 640px) {
  .sign-fields {
    grid-template-columns: 1fr;
  }

  .sign-inline-form {
    padding: 16px;
  }

  .sign-canvas-wrap .signature-box canvas {
    min-height: 160px;
  }
}

/* ============================================
   MOBILE: DETAILS-GRID STACKED
   ============================================ */
@media (max-width: 640px) {
  dl.details-grid {
    grid-template-columns: 1fr;
    gap: 4px 0;
  }

  dl.details-grid dt {
    padding-top: 10px;
    border-top: 1px solid var(--line);
    font-weight: 700;
  }

  dl.details-grid dt:first-child {
    border-top: none;
    padding-top: 0;
  }

  dl.details-grid dd {
    padding-bottom: 6px;
  }

  .page-hero h1 {
    font-size: 1.25rem;
    word-break: break-all;
  }

  .breadcrumbs {
    font-size: 0.82rem;
    flex-wrap: wrap;
  }

  .inline-form {
    flex-direction: column;
    gap: 10px;
  }

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

  .data-table {
    font-size: 0.85rem;
  }

  .data-table th,
  .data-table td {
    padding: 8px 10px;
  }

  code {
    font-size: 0.78rem;
    word-break: break-all;
  }

  .surface-card {
    border-radius: 16px;
  }

  .form-section h3 {
    font-size: 1rem;
  }

  .drop-zone {
    min-height: 120px;
    padding: 20px;
  }

  .wizard-card {
    padding: 1rem;
    margin: 0.5rem 0;
  }

  .wizard-info-grid {
    grid-template-columns: 1fr;
  }

  .checklist-item {
    padding: 12px 8px;
  }

  .signature-box canvas {
    width: 100%;
    height: 160px;
  }

  .wizard-consents label {
    font-size: 0.9rem;
    gap: 10px;
    min-height: 44px;
  }

  .wizard-sig-actions {
    flex-direction: row;
    gap: 8px;
  }

  .wizard-sig-actions .btn {
    flex: 1;
  }
}

/* ============================================
   ACTS PAGE — wizard top, registry bottom
   ============================================ */
.acts-top-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

@media (min-width: 900px) {
  .acts-top-row {
    grid-template-columns: minmax(0, 1fr);
  }
  .acts-top-row > .wizard {
    max-width: 100%;
  }
}

/* ==================== TRACKER — Labels ==================== */
.label-toggle-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0;
}
.label-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}
.label-chip:hover {
  border-color: var(--lbl-color, var(--accent));
  background: color-mix(in srgb, var(--lbl-color, var(--accent)) 8%, transparent);
}
.label-chip.label-active {
  border-color: var(--lbl-color, var(--accent));
  background: color-mix(in srgb, var(--lbl-color, var(--accent)) 14%, transparent);
  font-weight: 600;
}
.label-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.label-check {
  font-size: 0.75rem;
  margin-left: 2px;
}
.label-chip-input {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}
.label-chip-input:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  font-weight: 600;
}
.label-chip-input input[type="checkbox"] {
  display: none;
}

/* Kanban label tags */
.kanban-label-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0.01em;
}

/* ==================== TRACKER — Checklist ==================== */
.checklist {
  list-style: none;
  padding: 0;
  margin: 0;
}
.checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-light, #f0f0f0);
}
.checklist-item:last-child {
  border-bottom: none;
}
.checklist-done .checklist-text {
  text-decoration: line-through;
  opacity: 0.55;
}
.checklist-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.15rem;
  padding: 0;
  line-height: 1;
}
.checklist-text {
  flex: 1;
  font-size: 0.95rem;
}
.checklist-delete {
  margin-left: auto;
}
.btn-icon-sm {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s;
}
.btn-icon-sm:hover {
  color: var(--danger, #ef4444);
  background: rgba(239, 68, 68, 0.08);
}
.checklist-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border-light, #e5e7eb);
  border-radius: 3px;
  overflow: hidden;
}
.checklist-progress-fill {
  height: 100%;
  background: var(--accent, #3b82f6);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* ==================== TRACKER — Activity log ==================== */
.activity-log {
  list-style: none;
  padding: 0;
  margin: 0;
}
.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light, #f0f0f0);
  font-size: 0.9rem;
}
.activity-item:last-child {
  border-bottom: none;
}
.activity-icon {
  flex-shrink: 0;
  font-size: 1rem;
  width: 24px;
  text-align: center;
}
.activity-text {
  flex: 1;
}
.activity-time {
  flex-shrink: 0;
  font-size: 0.8rem;
  white-space: nowrap;
}

/* ==================== TRACKER — Analytics ==================== */
.analytics-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.analytics-bar-label {
  min-width: 100px;
  flex-shrink: 0;
}
.analytics-bar-track {
  flex: 1;
  height: 22px;
  background: var(--border-light, #e5e7eb);
  border-radius: 6px;
  overflow: hidden;
}
.analytics-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.4s ease;
  min-width: 2px;
}
.analytics-bar-count {
  min-width: 32px;
  text-align: right;
  font-weight: 600;
  font-size: 0.9rem;
}
.st-bg-new { background: #6366f1; }
.st-bg-in_progress { background: #f59e0b; }
.st-bg-review { background: #8b5cf6; }
.st-bg-done { background: #22c55e; }
.st-bg-cancelled { background: #9ca3af; }
.pr-bg-low { background: #6b7280; }
.pr-bg-medium { background: #3b82f6; }
.pr-bg-high { background: #f59e0b; }
.pr-bg-urgent { background: #ef4444; }

/* ==================== TRACKER — Template cards ==================== */
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.template-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  background: var(--surface);
  transition: box-shadow 0.15s;
}
.template-card:hover {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}
.template-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.template-card-header h4 {
  margin: 0;
  font-size: 1rem;
}

/* ==========================================================================
   NEW DESIGN SYSTEM v2 COMPONENTS
   ========================================================================== */

/* ---- STATUS PILLS (v2 with dot indicators) ----------------------------- */
.pill-v2,
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 7px;
  border-radius: var(--r-pill);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1.4;
  background: var(--st-draft-bg);
  color: var(--st-draft-fg);
  white-space: nowrap;
}
.pill-v2::before,
.status-dot::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--st-draft-dot);
  flex-shrink: 0;
}
.pill-v2.st-draft,     .status-dot.st-draft     { background: var(--st-draft-bg);     color: var(--st-draft-fg); }
.pill-v2.st-draft::before, .status-dot.st-draft::before { background: var(--st-draft-dot); }
.pill-v2.st-pending,   .status-dot.st-pending   { background: var(--st-pending-bg);   color: var(--st-pending-fg); }
.pill-v2.st-pending::before, .status-dot.st-pending::before { background: var(--st-pending-dot); }
.pill-v2.st-otp,       .status-dot.st-otp       { background: var(--st-otp-bg);       color: var(--st-otp-fg); }
.pill-v2.st-otp::before, .status-dot.st-otp::before { background: var(--st-otp-dot); animation: dot-pulse 1.6s ease-in-out infinite; }
.pill-v2.st-signed,    .status-dot.st-signed    { background: var(--st-signed-bg);    color: var(--st-signed-fg); }
.pill-v2.st-signed::before, .status-dot.st-signed::before { background: var(--st-signed-dot); }
.pill-v2.st-declined,  .status-dot.st-declined  { background: var(--st-declined-bg);  color: var(--st-declined-fg); }
.pill-v2.st-declined::before, .status-dot.st-declined::before { background: var(--st-declined-dot); }
.pill-v2.st-annulled,  .status-dot.st-annulled  { background: var(--st-annulled-bg);  color: var(--st-annulled-fg); }
.pill-v2.st-annulled::before, .status-dot.st-annulled::before { background: var(--st-annulled-dot); }
.pill-v2.st-installed, .status-dot.st-installed { background: var(--st-installed-bg); color: var(--st-installed-fg); }
.pill-v2.st-installed::before, .status-dot.st-installed::before { background: var(--st-installed-dot); }
.pill-v2.st-removed,   .status-dot.st-removed   { background: var(--st-removed-bg);   color: var(--st-removed-fg); }
.pill-v2.st-removed::before, .status-dot.st-removed::before { background: var(--st-removed-dot); }
.pill-v2.st-storage,   .status-dot.st-storage   { background: var(--st-storage-bg);   color: var(--st-storage-fg); }
.pill-v2.st-storage::before, .status-dot.st-storage::before { background: var(--st-storage-dot); }
.pill-v2.st-transit,   .status-dot.st-transit   { background: var(--st-transit-bg);   color: var(--st-transit-fg); }
.pill-v2.st-transit::before, .status-dot.st-transit::before { background: var(--st-transit-dot); }
.pill-v2.st-disputed,  .status-dot.st-disputed  { background: var(--st-disputed-bg);  color: var(--st-disputed-fg); }
.pill-v2.st-disputed::before, .status-dot.st-disputed::before { background: var(--st-disputed-dot); }
.pill-v2.st-expired,   .status-dot.st-expired   { background: var(--st-expired-bg);   color: var(--st-expired-fg); }
.pill-v2.st-expired::before, .status-dot.st-expired::before { background: var(--st-expired-dot); }
.pill-v2.st-returned,  .status-dot.st-returned  { background: var(--st-returned-bg);  color: var(--st-returned-fg); }
.pill-v2.st-returned::before, .status-dot.st-returned::before { background: var(--st-returned-dot); }

@keyframes dot-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

/* ---- SWITCH ------------------------------------------------------------ */
.switch {
  position: relative;
  width: 34px; height: 20px;
  background: var(--line-heavy);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background var(--t-fast);
  appearance: none;
  flex-shrink: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--t-med) var(--ease);
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch:checked { background: var(--role); }
.switch:checked::after { transform: translateX(14px); }

/* ---- SEGMENTED CONTROL ------------------------------------------------- */
.segmented {
  display: inline-flex;
  background: var(--surface-muted);
  border-radius: var(--r-md);
  padding: 3px;
  gap: 2px;
}
.segmented button {
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--fg-muted);
  border-radius: 5px;
  transition: color var(--t-fast), background var(--t-fast);
}
.segmented button:hover { color: var(--fg-strong); }
.segmented button.active {
  background: var(--surface-strong);
  color: var(--fg-strong);
  box-shadow: var(--shadow-xs);
}

/* ---- CHECKBOX / RADIO (v2) --------------------------------------------- */
.check-v2, .radio-v2 {
  appearance: none;
  width: 17px; height: 17px;
  margin: 0;
  border: 1.5px solid var(--line-heavy);
  background: var(--surface-strong);
  border-radius: var(--r-xs);
  display: inline-grid; place-items: center;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
  flex-shrink: 0;
}
.radio-v2 { border-radius: 50%; }
.check-v2:hover, .radio-v2:hover { border-color: var(--role); }
.check-v2:checked, .radio-v2:checked {
  background: var(--role);
  border-color: var(--role);
}
.check-v2:checked::after {
  content: "";
  width: 9px; height: 9px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='4 12 10 18 20 6'/></svg>") center/contain no-repeat;
}
.radio-v2:checked::after {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #fff;
}
.check-v2:focus-visible, .radio-v2:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px var(--role-soft);
}

/* ---- FILE DROPZONE ----------------------------------------------------- */
.dropzone {
  border: 1.5px dashed var(--line-heavy);
  border-radius: var(--r-lg);
  padding: 20px;
  text-align: center;
  color: var(--fg-muted);
  background: var(--surface-muted);
  transition: border-color var(--t-fast), background var(--t-fast);
  cursor: pointer;
}
.dropzone:hover { border-color: var(--role); background: var(--role-soft); }
.dropzone .drop-icon { width: 28px; height: 28px; margin: 0 auto 6px; color: var(--fg-muted); }

/* ---- ICON BUTTONS (topbar v2) ------------------------------------------ */
.icon-btn {
  width: 34px; height: 34px;
  display: inline-grid; place-items: center;
  border-radius: var(--r-md);
  color: var(--fg-muted);
  position: relative;
  transition: color var(--t-fast), background var(--t-fast);
}
.icon-btn:hover { color: var(--fg-strong); background: var(--surface-muted); }
.icon-btn .dot-badge {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--surface);
}

/* ---- BANNER (inline feedback) ------------------------------------------ */
.banner {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 14px;
  background: var(--info-soft);
  color: var(--info-ink, var(--info));
  border-radius: var(--r-lg);
  font-size: var(--fs-body-sm);
  border: 1px solid transparent;
}
.banner .banner-icon { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; color: var(--info); }
.banner.success { background: var(--success-soft); color: var(--success-ink, var(--success)); }
.banner.success .banner-icon { color: var(--success); }
.banner.warning { background: var(--warning-soft); color: var(--warning-ink, var(--warning)); }
.banner.warning .banner-icon { color: var(--warning); }
.banner.danger  { background: var(--danger-soft); color: var(--danger-ink, var(--danger)); }
.banner.danger  .banner-icon { color: var(--danger); }
[data-theme="dark"] .banner { color: var(--fg-strong); }

/* ---- BREADCRUMBS ------------------------------------------------------- */
.breadcrumbs {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
  font-size: var(--fs-body-sm); color: var(--fg-muted);
}
.breadcrumbs a { color: var(--fg-muted); text-decoration: none; padding: 2px 6px; border-radius: var(--r-xs); }
.breadcrumbs a:hover { color: var(--fg-strong); background: var(--surface-muted); }
.breadcrumbs .sep { color: var(--fg-subtle, var(--fg-muted)); opacity: .7; }
.breadcrumbs .current { color: var(--fg-strong); font-weight: 500; padding: 2px 6px; }

/* ---- HELPER CLASSES ---------------------------------------------------- */
.mono { font-family: var(--font-mono); font-size: 0.92em; font-feature-settings: "zero", "ss01"; letter-spacing: -0.01em; }
.num  { font-variant-numeric: tabular-nums; }
.subtle { color: var(--fg-subtle, var(--fg-muted)); }

/* ---- CUSTOM SCROLLBAR -------------------------------------------------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: var(--r-pill);
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--line-heavy);
  background-clip: padding-box;
  border: 2px solid transparent;
}

/* ---- FOCUS-VISIBLE RING ------------------------------------------------ */
:focus-visible {
  outline: 2px solid var(--role);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ---- PAGE TRANSITION --------------------------------------------------- */
.page-v2 { animation: page-in-v2 0.26s var(--ease-out); }
@keyframes page-in-v2 {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ---- BOTTOM NAV (mobile) ----------------------------------------------- */
.bottom-nav {
  display: none;
  position: sticky; bottom: 0;
  background: var(--surface-tint);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding: 4px 8px 6px;
  gap: 2px;
  justify-content: space-around;
  z-index: 30;
}
.bottom-nav .bn-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px 4px;
  font-size: 0.68rem;
  color: var(--fg-muted);
  text-decoration: none;
  border-radius: var(--r-md);
}
.bottom-nav .bn-item.active { color: var(--role-ink, var(--role)); }
[data-theme="dark"] .bottom-nav .bn-item.active { color: var(--fg-strong); }

@media (max-width: 768px) {
  .bottom-nav { display: flex; }

  .topnav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    flex-direction: column;
    background: var(--surface);
    border-bottom: 2px solid var(--line-strong);
    box-shadow: 0 12px 32px rgba(0,0,0,.15);
    padding: 6px 0;
    max-height: 75vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .topnav.is-open {
    display: flex;
    animation: mobileNavSlide 0.2s ease-out;
  }

  @keyframes mobileNavSlide {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  .topnav {
    align-items: stretch;
    gap: 0;
    margin: 0;
  }

  .topnav-link {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 15px 24px;
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    border-radius: 0;
    border-bottom: 1px solid var(--line);
    white-space: normal;
    color: var(--fg);
    min-height: 48px;
    box-shadow: none;
    background: transparent;
  }

  .topnav-link:last-child {
    border-bottom: none;
  }

  .topnav-link.active {
    background: var(--role-tint, rgba(15, 118, 110, 0.07));
    font-weight: 700;
    color: var(--role, #0f766e);
    border-left: 3px solid var(--role, #0f766e);
    border-radius: 0;
    box-shadow: none;
    padding-left: 21px;
  }

  .topnav-link:active {
    background: var(--role-tint, rgba(15, 118, 110, 0.12));
  }

  .topbar {
    position: relative;
  }

  .topnav.is-open ~ .subnav,
  .topbar:has(.topnav.is-open) + .subnav {
    display: none;
  }

  .subnav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
    white-space: nowrap;
    padding: 0 14px;
  }

  .subnav::-webkit-scrollbar { display: none; }

  .subnav-link {
    flex-shrink: 0;
    font-size: 0.82rem;
    padding: 8px 12px;
  }
}

/* ---- LAUNCH GATE ENHANCED ---------------------------------------------- */
.launch-readiness .readiness-checks { list-style: none; padding: 0; margin: 0; }
.launch-readiness .check-row {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border-radius: var(--r-md);
  transition: background var(--t-fast) var(--ease);
}
.launch-readiness .check-row:hover { background: var(--surface-muted); }
.launch-readiness .check-row.check-ok .check-icon { color: var(--st-signed-fg, #16a34a); }
.launch-readiness .check-row.check-fail .check-icon { color: var(--st-rejected-fg, #dc2626); font-weight: 700; }
.launch-readiness .check-icon {
  width: 22px; height: 22px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 600;
  border-radius: var(--r-full);
}
.launch-readiness .check-row.check-ok .check-icon {
  background: rgba(22, 163, 74, 0.12);
}
.launch-readiness .check-row.check-fail .check-icon {
  background: rgba(220, 38, 38, 0.12);
}
.launch-readiness .check-body { flex: 1; min-width: 0; }
.launch-readiness .check-name { font-weight: 600; font-size: 0.88rem; display: block; }
.launch-readiness .check-message { font-size: 0.82rem; color: var(--fg-muted); display: block; margin-top: 2px; }
.launch-readiness .check-hint {
  display: block; margin-top: 4px; padding: 6px 10px;
  font-size: 0.8rem; color: var(--fg-muted);
  background: var(--surface-accent, rgba(14, 127, 118, 0.06));
  border-left: 3px solid var(--role);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

/* ---- ROUTE STEPPER ----------------------------------------------------- */
.route-stepper {
  display: flex; align-items: flex-start;
  gap: 0; padding: 16px 0; overflow-x: auto;
  scrollbar-width: thin;
}
.route-step {
  display: flex; flex-direction: column; align-items: center;
  min-width: 80px; flex: 1; position: relative;
  text-align: center;
}
.route-step-dot {
  width: 28px; height: 28px;
  border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.72rem; font-weight: 700;
  transition: all var(--t-med) var(--ease);
  position: relative; z-index: 2;
}
.route-step.is-done .route-step-dot {
  background: var(--role); color: #fff;
}
.route-step.is-current .route-step-dot {
  background: var(--role); color: #fff;
  box-shadow: 0 0 0 4px var(--role-soft-2);
  animation: stepper-pulse 2s ease-in-out infinite;
}
.route-step.is-future .route-step-dot {
  background: var(--surface-muted); color: var(--fg-muted);
  border: 2px solid var(--line);
}
.route-step.is-blocked .route-step-dot {
  background: var(--st-rejected-bg, #fef2f2); color: var(--st-rejected-fg, #dc2626);
  border: 2px solid var(--st-rejected-fg, #dc2626);
}
@keyframes stepper-pulse {
  0%, 100% { box-shadow: 0 0 0 4px var(--role-soft-2); }
  50% { box-shadow: 0 0 0 8px rgba(14, 127, 118, 0.08); }
}
.route-step-label {
  margin-top: 6px; font-size: 0.7rem; line-height: 1.2;
  color: var(--fg-muted); max-width: 90px;
  word-wrap: break-word;
}
.route-step.is-current .route-step-label { color: var(--fg-strong); font-weight: 600; }
.route-step.is-done .route-step-label { color: var(--fg); }
.route-step-connector {
  position: absolute; top: 14px; left: calc(50% + 16px);
  width: calc(100% - 32px); height: 2px;
  background: var(--line);
  z-index: 1;
}
.route-step.is-done .route-step-connector { background: var(--role); }
.route-step:last-child .route-step-connector { display: none; }

/* Compact stepper for mobile */
@media (max-width: 640px) {
  .route-stepper { flex-wrap: nowrap; justify-content: flex-start; }
  .route-step { min-width: 60px; }
  .route-step-label { font-size: 0.62rem; max-width: 70px; }
  .route-step-dot { width: 22px; height: 22px; font-size: 0.62rem; }
  .route-step-connector { top: 11px; left: calc(50% + 13px); width: calc(100% - 26px); }
}

/* ---- CONTEXTUAL HELP --------------------------------------------------- */
.ctx-help {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 14px; margin-bottom: 12px;
  background: var(--surface-accent, rgba(14, 127, 118, 0.06));
  border: 1px solid var(--role-soft-2);
  border-radius: var(--r-md);
  font-size: 0.82rem; color: var(--fg-muted); line-height: 1.4;
}
.ctx-help-icon { flex-shrink: 0; color: var(--role); opacity: 0.7; margin-top: 1px; }
.ctx-help strong { color: var(--fg); }
.ctx-help a { color: var(--role-ink, var(--role)); text-decoration: underline; }
.ctx-help[hidden] { display: none; }
[data-theme="dark"] .ctx-help {
  background: rgba(14, 127, 118, 0.08);
  border-color: rgba(14, 127, 118, 0.2);
}

/* ---- REQ-08 STATUS STEPPER --------------------------------------------- */
.req08-stepper {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 0; flex-wrap: wrap;
}
.req08-step {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: var(--r-pill);
  font-size: 0.78rem; font-weight: 500;
  background: var(--surface-muted); color: var(--fg-muted);
}
.req08-step.is-done { background: var(--role-bg, #e6f4f2); color: var(--role-ink, #0a5b54); }
.req08-step.is-current {
  background: var(--role); color: #fff;
  box-shadow: 0 0 0 3px var(--role-soft-2);
}
.req08-step-arrow { color: var(--fg-subtle); font-size: 0.7rem; }

/* ---- GUIDED ACTION CARDS ----------------------------------------------- */
.guided-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.guided-action {
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px 16px; border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  transition: all var(--t-fast) var(--ease);
  text-decoration: none; color: inherit;
  cursor: pointer;
}
.guided-action:hover {
  border-color: var(--role);
  box-shadow: 0 2px 8px rgba(14, 127, 118, 0.1);
  transform: translateY(-1px);
}
.guided-action-title { font-weight: 600; font-size: 0.9rem; color: var(--fg-strong); }
.guided-action-desc { font-size: 0.78rem; color: var(--fg-muted); line-height: 1.35; }
.guided-action-meta {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.72rem; color: var(--fg-subtle);
  margin-top: auto;
}

/* ---- EMPTY STATE ILLUSTRATION ------------------------------------------ */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; padding: 40px 20px; text-align: center;
}
.empty-state-icon {
  width: 56px; height: 56px; border-radius: var(--r-full);
  background: var(--surface-muted);
  display: flex; align-items: center; justify-content: center;
  color: var(--fg-subtle);
}
.empty-state-title { font-weight: 600; font-size: 1rem; color: var(--fg-strong); }
.empty-state-desc { font-size: 0.85rem; color: var(--fg-muted); max-width: 360px; }

/* ---- APPROVAL BANNER --------------------------------------------------- */
.approval-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; border-radius: var(--r-md);
  background: var(--st-otp-bg, #fef3c7);
  border: 1px solid var(--st-otp-dot, #f59e0b);
}
.approval-banner-text { flex: 1; min-width: 200px; font-size: 0.88rem; }
.approval-banner-text strong { display: block; margin-bottom: 2px; }
.approval-banner-text span { color: var(--fg-muted); font-size: 0.82rem; }
.approval-banner .btn { flex-shrink: 0; }

/* ---- MOBILE FORM & NAVIGATION IMPROVEMENTS ----------------------------- */
@media (max-width: 480px) {
  .section-head.wrap {
    flex-direction: column;
    gap: 10px;
  }
  .section-head-actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .section-head-actions .btn {
    flex: 1;
    min-width: 120px;
    text-align: center;
  }
  .wizard-progress {
    overflow-x: auto;
    justify-content: flex-start;
    padding-bottom: 12px;
  }
  .wizard-dot { width: 30px; height: 30px; font-size: 0.75rem; }
  .wizard-line { width: 32px; }
  .wizard-header { padding: 14px; }
  .wizard-title h1 { font-size: 1.15rem; }
  .wizard-title .muted { font-size: 0.78rem; }
  .equip-card-actions {
    flex-direction: column;
    gap: 8px;
  }
  .equip-card-actions .btn {
    width: 100%;
    justify-content: center;
  }
  .meta-grid { gap: 6px; }
  .meta-grid dt { font-size: 0.78rem; }
  .meta-grid dd { font-size: 0.88rem; }
  .breadcrumbs { font-size: 0.78rem; overflow-x: auto; white-space: nowrap; }
  .eyebrow { font-size: 0.68rem; }
  h1 { font-size: 1.25rem; }
  .content-shell { padding: 0; }
  .legal-footer { flex-wrap: wrap; gap: 8px; padding: 12px; font-size: 0.72rem; }
}

@media (max-width: 768px) {
  .content--full { padding-bottom: 72px; }
  .topbar-actions .primary-cta { display: none; }
  .equip-demolish-form { padding: 12px; }
  .equip-demolish-form .field { margin-bottom: 10px; }
  .drop-zone { padding: 20px 12px; }
  .form-grid { gap: 10px; }
  .inline-form-row {
    flex-direction: column;
    align-items: stretch;
  }
  .inline-form-row .field { min-width: 0; }
}

/* ---- PRINT ------------------------------------------------------------- */
@media print {
  .topbar, .bottom-nav { display: none; }
}


/* === Collapsible sections === */
.collapsible-section { padding: 0; }
.collapsible-section > .section-toggle {
  display: flex; align-items: center; gap: 8px;
  padding: 16px 20px; cursor: pointer; list-style: none;
  border-bottom: 1px solid transparent; transition: border-color .2s;
}
.collapsible-section > .section-toggle::-webkit-details-marker { display: none; }
.collapsible-section > .section-toggle::before {
  content: '\25B6'; font-size: .7em; transition: transform .2s; flex-shrink: 0;
}
.collapsible-section[open] > .section-toggle::before { transform: rotate(90deg); }
.collapsible-section[open] > .section-toggle { border-bottom-color: var(--border); }
.collapsible-section > .collapsible-body { padding: 16px 20px; }
.collapsible-section > .section-toggle h2 { margin: 0; font-size: 1rem; }

/* === Compact meta-grid === */
.meta-grid.compact { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px 16px; font-size: 0.88rem; }
.meta-grid.compact dt { font-size: 0.78rem; margin-bottom: 0; }
.meta-grid.compact dd { margin-bottom: 4px; }

/* === Apartment grid === */
.apt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px; padding: 0 0 8px;
}
.apt-card {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 12px 8px; border-radius: 8px;
  background: var(--surface-2, rgba(255,255,255,.04));
  border: 1px solid var(--border, rgba(255,255,255,.08));
  text-decoration: none; color: inherit;
  transition: border-color .15s, background .15s;
  cursor: pointer; text-align: center;
}
.apt-card:hover {
  border-color: var(--accent, #C9A84C);
  background: rgba(201,168,76,.06);
}
.apt-num {
  font-size: 1.4rem; font-weight: 700; line-height: 1;
  color: var(--accent, #C9A84C);
}
.apt-owner {
  font-size: 0.78rem; color: var(--text-muted); margin-top: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.apt-conds {
  font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; opacity: .7;
}

@media (max-width: 480px) {
  .apt-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 6px; }
  .apt-card { padding: 10px 6px; }
  .apt-num { font-size: 1.2rem; }
}


/* === Object assignment list === */
.obj-assign-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.obj-assign-search {
  flex: 1 1 360px;
  min-width: 240px;
  max-width: 620px;
}
.obj-assign-list {
  max-height: 66vh;
  overflow: auto;
  border: 1px solid var(--border, rgba(255,255,255,.08));
  border-radius: 8px;
  background: var(--surface-2, rgba(255,255,255,.03));
}
.obj-assign-head,
.obj-assign-item {
  display: grid;
  grid-template-columns: 34px minmax(116px, 150px) minmax(360px, 1fr) minmax(150px, 220px);
  column-gap: 12px;
  align-items: center;
}
.obj-assign-head {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 9px 14px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface-card, #fff);
  border-bottom: 1px solid var(--border, rgba(0,0,0,.08));
}
.obj-assign-item {
  min-height: 48px;
  padding: 8px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border, rgba(255,255,255,.06));
  transition: background .12s, border-color .12s;
  font-size: .9rem;
}
.obj-assign-item:last-child { border-bottom: 0; }
.obj-assign-item:hover { background: rgba(14,127,118,.06); }
.obj-assign-item.is-assigned {
  background: rgba(14,127,118,.08);
  box-shadow: inset 3px 0 0 var(--accent, #0e7f76);
}
.obj-assign-check {
  display: flex;
  justify-content: center;
}
.obj-assign-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.obj-assign-code {
  font-weight: 700;
  font-size: .86rem;
  white-space: nowrap;
  color: var(--text);
}
.obj-assign-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.obj-assign-title {
  color: var(--text);
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.32;
}
.obj-assign-subtitle,
.obj-assign-district {
  color: var(--text-muted);
  font-size: .82rem;
  line-height: 1.25;
}
.obj-assign-subtitle {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.obj-assign-district {
  text-align: left;
}

@media (max-width: 760px) {
  .obj-assign-head { display: none; }
  .obj-assign-list {
    max-height: none;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
  .obj-assign-item {
    grid-template-columns: 28px 1fr;
    gap: 6px 10px;
    padding: 10px 4px;
  }
  .obj-assign-code {
    grid-column: 2;
  }
  .obj-assign-main,
  .obj-assign-district {
    grid-column: 2;
  }
  .obj-assign-district {
    font-size: .78rem;
  }
}

/* === Inline details dropdown === */
.inline-details { position: relative; display: inline-block; }
.inline-details .dropdown-form {
  position: absolute; right: 0; top: 100%; z-index: 10;
  background: var(--surface-card, #1a1a1a); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px; min-width: 260px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.inline-details .dropdown-form .field { margin-bottom: 8px; }
.inline-details .dropdown-form label { font-size: 0.78rem; }

/* === Team page === */
.team-member-section {
  overflow: visible;
}
.team-table-wrap {
  overflow: visible;
}
.team-table-wrap::after {
  display: none;
}
.team-table {
  min-width: 0;
}
.team-table th:last-child,
.team-table td:last-child {
  width: 440px;
}
.team-table .action-row {
  justify-content: flex-start;
}
.team-table .inline-details {
  position: relative;
  display: inline-block;
  background: transparent;
  border: 0;
  border-radius: 0;
}
.team-table .inline-details summary {
  padding: 6px 14px;
}
.team-table .inline-details[open] summary {
  border-bottom: 0;
}
.team-table .inline-details .dropdown-form {
  min-width: 320px;
}

@media (max-width: 900px) {
  .team-table th:last-child,
  .team-table td:last-child {
    width: auto;
  }
  .team-table-wrap {
    overflow: visible;
  }
  .team-table .inline-details .dropdown-form {
    position: static;
    margin-top: 8px;
    min-width: min(320px, 100%);
  }
}


/* === Act form === */
.act-form { display: flex; flex-direction: column; gap: 16px; }
.act-section .section-head { margin-bottom: 16px; }
.act-section .section-head h2 { font-size: 1.05rem; margin: 0; }
.act-section .section-head p { margin: 4px 0 0; }

.act-grid-2 {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px;
}
.act-grid-3 {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px 16px;
}
.act-grid-2 .span-2, .act-grid-3 .span-2 { grid-column: span 2; }
.act-grid-3 .span-3 { grid-column: span 3; }

.radio-row {
  display: flex; flex-wrap: wrap; gap: 16px; padding: 8px 0;
}
.radio-label {
  display: flex; align-items: center; gap: 6px;
  cursor: pointer; font-size: 0.9rem;
}
.radio-label input[type="radio"] { margin: 0; }
.checkbox-label {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; font-size: 0.9rem; padding: 8px 0;
}
.checkbox-label input[type="checkbox"] { margin: 0; }

.act-legal-note {
  margin-top: 12px; padding: 10px 14px;
  font-size: 0.78rem; color: var(--text-muted);
  background: var(--surface-2, rgba(255,255,255,.02));
  border-radius: 6px; border-left: 3px solid var(--border);
  line-height: 1.5;
}
.act-actions {
  display: flex; gap: 12px; padding: 8px 0 24px;
}

.btn-accent {
  background: var(--accent, #C9A84C); color: #fff;
  border: none; border-radius: 6px; padding: 6px 14px;
  font-weight: 600; font-size: 0.82rem; cursor: pointer;
  transition: opacity .15s;
}
.btn-accent:hover { opacity: .85; }

@media (max-width: 768px) {
  .act-grid-2 { grid-template-columns: 1fr; }
  .act-grid-3 { grid-template-columns: 1fr; }
  .act-grid-2 .span-2, .act-grid-3 .span-2, .act-grid-3 .span-3 { grid-column: span 1; }
}

/* === Apartment phone in card === */
.apt-phone { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }

/* ── Pipeline Progress Bar ── */
.pipeline-bar{display:flex;align-items:center;gap:0;margin:0 0 24px;padding:16px 20px;background:var(--surface,#fff);border-radius:12px;overflow-x:auto}
.pipeline-step{display:flex;flex-direction:column;align-items:center;gap:4px;min-width:80px;flex-shrink:0}
.pipeline-dot{width:36px;height:36px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-weight:700;font-size:0.85rem;border:2px solid var(--border,#e2e8f0);background:var(--bg,#f8fafc);color:var(--fg-subtle,#94a3b8);transition:all .2s}
.pipeline-step.done .pipeline-dot{background:var(--success,#16a34a);border-color:var(--success,#16a34a);color:#fff}
.pipeline-step.active .pipeline-dot{background:var(--role,#2563eb);border-color:var(--role,#2563eb);color:#fff;box-shadow:0 0 0 4px rgba(37,99,235,.18)}
.pipeline-label{font-size:0.72rem;color:var(--fg-subtle,#94a3b8);text-align:center;white-space:nowrap}
.pipeline-step.done .pipeline-label{color:var(--success,#16a34a);font-weight:600}
.pipeline-step.active .pipeline-label{color:var(--role,#2563eb);font-weight:600}
.pipeline-connector{flex:1;height:3px;min-width:20px;background:var(--border,#e2e8f0);margin:0 -2px;align-self:center;margin-bottom:20px;border-radius:2px}
.pipeline-connector.done{background:var(--success,#16a34a)}
.st-done{background:var(--success-bg,#dcfce7)!important;color:var(--success,#16a34a)!important}
.status-badge.st-registered{background:#dbeafe;color:#2563eb}
.status-badge.st-inspected{background:#fef3c7;color:#d97706}
.status-badge.st-dismantled{background:#fce7f3;color:#be185d}
.status-badge.st-stored{background:#e0e7ff;color:#4338ca}
.status-badge.st-installed{background:#d1fae5;color:#059669}
.status-badge.st-completed{background:#dcfce7;color:#16a34a}
@media(max-width:640px){.pipeline-bar{padding:12px 8px;gap:0}.pipeline-step{min-width:56px}.pipeline-dot{width:28px;height:28px;font-size:0.72rem}.pipeline-label{font-size:0.62rem}.pipeline-connector{min-width:10px}}

/* ── Stage Photos (inline in pipeline stages) ── */
.stage-photos{display:flex;gap:8px;flex-wrap:wrap;margin-top:12px;padding-top:12px;border-top:1px solid var(--border,#e2e8f0)}
.stage-photo-thumb{display:block;width:80px;height:80px;border-radius:8px;overflow:hidden;border:2px solid var(--border,#e2e8f0);transition:border-color .15s,transform .15s}
.stage-photo-thumb:hover{border-color:var(--role,#2563eb);transform:scale(1.05)}
.stage-photo-thumb img{width:100%;height:100%;object-fit:cover}
@media(max-width:640px){.stage-photo-thumb{width:60px;height:60px}}

/* ── Phone Verification ── */
.pv-wrap{position:relative}
.pv-send-btn{margin-top:4px;font-size:0.78rem}
.pv-code-row{display:flex;gap:6px;align-items:center;margin-top:6px}
.pv-code-row input{width:80px;text-align:center;letter-spacing:4px;font-size:1.1rem}
.pv-status{display:block;font-size:0.75rem;margin-top:4px;min-height:1.1em}
.pv-status.pv-info{color:var(--role,#2563eb)}
.pv-status.pv-ok{color:var(--success,#16a34a);font-weight:600}
.pv-status.pv-error{color:var(--danger,#dc2626)}
.pv-verified-badge{display:inline-flex;align-items:center;gap:4px;padding:2px 8px;border-radius:6px;background:var(--success-bg,#dcfce7);color:var(--success,#16a34a);font-size:0.75rem;font-weight:600}
/* ── PD Consent ── */
.pd-consent{margin:12px 0 8px;font-size:0.82rem;line-height:1.4}
.pd-consent input[type="checkbox"]{margin-right:6px;vertical-align:middle}
.pd-consent a{color:var(--role,#2563eb);text-decoration:underline}
.pd-consent a:hover{text-decoration:none}

/* QR scan floating button */
.scan-fab{position:fixed;bottom:24px;right:24px;z-index:1000;width:52px;height:52px;border-radius:50%;background:var(--accent,#0d9488);color:#fff;display:flex;align-items:center;justify-content:center;box-shadow:0 4px 12px rgba(0,0,0,.25);text-decoration:none;transition:transform .15s,box-shadow .15s}
.scan-fab:hover{transform:scale(1.08);box-shadow:0 6px 20px rgba(0,0,0,.3)}
@media(min-width:1200px){.scan-fab{bottom:32px;right:32px}}

/* Act download dropdown */
.dropdown-wrap .dropdown-menu{display:none;position:absolute;right:0;top:100%;min-width:220px;background:var(--bg-card,#fff);border:1px solid var(--border,#e2e8f0);border-radius:8px;box-shadow:0 8px 24px rgba(0,0,0,.12);z-index:100;padding:4px 0;margin-top:4px}
.dropdown-wrap.open .dropdown-menu{display:block}
.dropdown-item{display:block;padding:8px 16px;color:var(--fg,#1e293b);text-decoration:none;font-size:.875rem;white-space:nowrap;transition:background .1s}
.dropdown-item:hover{background:var(--bg-hover,#f1f5f9)}

/* Act registry */
.inline-filters{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
.act-links{display:flex;flex-direction:column;gap:4px}
.act-link-row{display:flex;align-items:center;gap:6px}
.act-link{font-size:.85rem;font-weight:600;color:var(--accent,#0d9488);text-decoration:none}
.act-link:hover{text-decoration:underline}
.btn-icon{background:none;border:none;cursor:pointer;padding:4px;border-radius:4px;color:var(--muted,#94a3b8);transition:color .15s,background .15s}
.btn-icon:hover{color:var(--fg,#1e293b);background:var(--bg-hover,#f1f5f9)}
/* QR modal */
.modal-overlay{position:fixed;inset:0;background:rgba(0,0,0,.5);z-index:2000;display:flex;align-items:center;justify-content:center}
.modal-overlay[hidden]{display:none}
.modal-card{background:var(--bg-card,#fff);border-radius:12px;padding:24px;box-shadow:0 20px 60px rgba(0,0,0,.2)}

/* === Stage forms — fixed 2-col grid === */
.stage-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 24px;
  margin-bottom: 20px;
}
.stage-form-grid .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 0;
}
.stage-form-grid .field.full {
  grid-column: 1 / -1;
}
.stage-form-grid .field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted-strong);
}
.stage-form-grid .field .input {
  width: 100%;
  box-sizing: border-box;
}
.stage-form-grid .field .hint {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0;
}
.stage-form-grid [data-phone-verify] .phone-verify-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
.stage-form-grid [data-phone-verify] .phone-verify-row .input {
  flex: 1;
}
.stage-form-grid [data-phone-verify] .phone-verify-row .btn {
  white-space: nowrap;
  flex-shrink: 0;
}
@media (max-width: 640px) {
  .stage-form-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}
@media (min-width: 641px) and (max-width: 900px) {
  .stage-form-grid {
    grid-template-columns: 1fr 1fr;
    gap: 14px 18px;
  }
}

/* === Photo preview grid === */
.photo-preview-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.photo-preview-grid .photo-thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  border: 2px solid var(--line);
}

/* === Tech supervisor kanban === */
.tech-kanban {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.tech-kanban .page-header {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}
.kanban-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  min-height: 400px;
}
@media (max-width: 768px) {
  .kanban-columns { grid-template-columns: 1fr; }
}
.kanban-alert {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  padding: 12px 16px;
  font-weight: 500;
}
.kanban-col {
  background: var(--bg-alt, #f8f7f4);
  border-radius: 12px;
  overflow: hidden;
}
.kanban-col-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  font-weight: 600;
  font-size: 1.05rem;
}
.kanban-pending { background: #fef3c7; color: #92400e; }
.kanban-signed { background: #d1fae5; color: #065f46; }
.kanban-col-pending .kanban-col-header { background: #fef3c7; color: #92400e; }
.kanban-col-signed .kanban-col-header { background: #d1fae5; color: #065f46; }
.kanban-col-title { flex: 1; }
.kanban-badge {
  background: rgba(0,0,0,.12);
  color: inherit;
  border-radius: 20px;
  padding: 2px 10px;
  font-size: .85rem;
  font-weight: 700;
}
.kanban-cards, .kanban-col-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.kanban-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--line, #e5e2da);
  border-radius: 10px;
  padding: 14px 16px;
}
.kanban-card-signed { opacity: .75; }
.kanban-card-title { font-weight: 600; font-size: 1rem; margin-bottom: 4px; }
.kanban-card-meta { font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.kanban-card-info { font-size: .88rem; line-height: 1.5; margin-bottom: 10px; }
.kanban-label { color: var(--muted); }
.kanban-card-actions { display: flex; gap: 8px; }
.kanban-empty { text-align: center; color: var(--muted); padding: 32px 16px; font-size: .95rem; }
.btn-sm { padding: 6px 14px; font-size: .85rem; }
/* === Apartment add form === */
.apt-add-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.apt-add-row1 {
  display: grid;
  grid-template-columns: 100px 1fr 1fr;
  gap: 16px;
  align-items: start;
}
.apt-add-row2 {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.apt-add-row2 .checkbox-label {
  white-space: nowrap;
}
.apt-add-row2 .pd-consent {
  flex: 1;
  font-size: .85rem;
  color: var(--muted);
  min-width: 200px;
}
.apt-add-row2 .btn {
  white-space: nowrap;
}
@media (max-width: 768px) {
  .apt-add-row1 {
    grid-template-columns: 80px 1fr;
  }
  .apt-add-row1 .field:nth-child(3) {
    grid-column: 1 / -1;
  }
  .apt-add-row2 {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .apt-add-row2 .btn {
    width: 100%;
  }
}
@media (max-width: 480px) {
  .apt-add-row1 {
    grid-template-columns: 1fr;
  }
}

/* === Kanban timer + overdue === */
.kanban-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.kanban-timer {
  font-size: .8rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  background: #dbeafe;
  color: #1e40af;
  white-space: nowrap;
  flex-shrink: 0;
}
.kanban-timer.warning {
  background: #fef3c7;
  color: #92400e;
}
.kanban-timer.overdue {
  background: #fee2e2;
  color: #991b1b;
  animation: pulse-overdue 2s infinite;
}
@keyframes pulse-overdue {
  0%, 100% { opacity: 1; }
  50% { opacity: .6; }
}
.kanban-card-overdue {
  border-color: #f87171 !important;
  background: #fef2f2 !important;
}

/* === Tech kanban dark theme === */
[data-theme="dark"] .kanban-col {
  background: var(--surface);
}
[data-theme="dark"] .kanban-col-pending .kanban-col-header {
  background: #3d2e0a;
  color: #fbd89a;
}
[data-theme="dark"] .kanban-col-signed .kanban-col-header {
  background: #0a3d24;
  color: #8aeab0;
}
[data-theme="dark"] .kanban-card {
  background: var(--surface-strong);
  border-color: var(--line-strong);
  color: var(--fg);
}
[data-theme="dark"] .kanban-card-title {
  color: var(--fg-strong);
}
[data-theme="dark"] .kanban-card-meta {
  color: var(--fg-muted);
}
[data-theme="dark"] .kanban-card-info {
  color: var(--fg);
}
[data-theme="dark"] .kanban-card-info small {
  color: var(--fg-muted);
}
[data-theme="dark"] .kanban-empty {
  color: var(--fg-subtle);
}
[data-theme="dark"] .kanban-timer {
  background: #1a3a4d;
  color: #7dd3fc;
}
[data-theme="dark"] .kanban-timer-overdue {
  background: #4d1a1a;
  color: #fca5a5;
}
[data-theme="dark"] .kanban-card-overdue {
  border-color: #f87171;
  background: #2d1515;
}
[data-theme="dark"] .kanban-signed-badge {
  color: #8aeab0;
}
[data-theme="dark"] .kanban-alert {
  background: #3d2e0a;
  color: #fbd89a;
  border-color: #92400e;
}
[data-theme="dark"] .kanban-badge {
  background: rgba(255,255,255,.15);
}

/* Overdue signatures severity */
.row-critical { background: rgba(220, 53, 69, 0.06); }
.text-danger { color: var(--danger, #dc3545); }
.text-warning { color: var(--warning-text, #b58105); }
.pill-ack { background: var(--success-bg, #d4edda); color: var(--success-text, #155724); }
.pill-open { background: var(--warning-bg, #fff3cd); color: var(--warning-text, #856404); }
