
/* ═══════════════════════════════════════════
   CUSTOM PROPERTIES
   ═══════════════════════════════════════════ */
:root {
  color-scheme: light;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Space Grotesk', 'Helvetica Neue', sans-serif;
  --font-mono: 'Space Mono', monospace;

  --color-bg: #F1F2F7;
  --color-surface: #FFFFFF;
  --color-surface-alt: #F7F8FC;
  --color-surface-hover: #ECEEF8;
  --color-text: #110E1A;
  --color-text-secondary: #373A52;
  --color-text-muted: #62688F;
  --color-border: #E4E8FF;
  --color-border-strong: #C9CEEB;

  --color-accent: #2A44DF;
  --color-accent-light: #E4E8FF;
  --color-accent-dark: #142287;
  --color-accent-glow: rgba(42, 68, 223, 0.15);
  /* Solid fill behind white text (primary buttons, active toggles). */
  --color-accent-fill: #2A44DF;
  --color-accent-fill-hover: #142287;

  --logo-icon: #2A44DF;
  --logo-word: #110E1A;

  --color-success: #059669;
  --color-success-light: #ECFDF5;
  --color-warning: #D97706;
  --color-warning-light: #FFFBEB;
  --color-error: #DC2626;
  --color-error-light: #FEF2F2;
  --color-success-solid: #047857;
  --color-violet: #7C3AED;
  --color-violet-light: #F3EEFF;

  --color-navy: #110E1A;
  --color-navy-light: #1E182B;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.06), 0 12px 40px rgba(0,0,0,0.08);
  --shadow-glow: 0 0 0 3px var(--color-accent-glow);

  --transition-fast: 150ms ease;
  --transition-med: 250ms ease;
  --transition-slow: 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Dark theme (app-wide) ──
   Applied by setting `data-theme="dark"` on <html> (theme.js, persisted in
   localStorage; "System" resolves via prefers-color-scheme). Every surface
   keys off these variables, so chrome, panels, forms, dashboard and modals
   follow automatically. Light is the :root default above. */
html[data-theme="dark"] {
  color-scheme: dark;
  /* Coil brand darks: background #110E1A, surface #1E182B; the steps between
     them stay in the same purple-tinted family. Blue fills only the main
     action; highlights use the softer #8F9CFF (#556DFF is 4.6:1 on bg but
     4.1:1 on surface). */
  --color-bg: #110E1A;
  --color-surface: #1E182B;
  --color-surface-alt: #17121F;
  --color-surface-hover: #282236;
  --color-surface-raised: #2E2840;
  --color-text: #F1F2F7;
  --color-text-secondary: #A9AECB;
  --color-text-muted: #8B91BC;
  --color-border: #2A2438;
  --color-border-strong: #373A52;
  --color-accent: #8F9CFF;
  --color-accent-light: #20232F;
  --color-accent-dark: #B4BDFF;
  --color-accent-glow: rgba(143, 156, 255, 0.25);
  --color-accent-fill: #2A44DF;
  --color-accent-fill-hover: #556DFF;
  /* #2A44DF reaches only 2.7:1 on the dark top bar. */
  --logo-icon: #2A44DF;
  --logo-word: #F1F2F7;
  /* Brighter emerald for success text/borders on dark (the base #059669 reads
     muddy), with a soft translucent wash replacing the old murky solid fill.
     The solid-green button keeps its own readable green below so its white
     text stays legible. */
  --color-success: #34D399;
  --color-success-light: rgba(52, 211, 153, 0.12);
  --color-warning-light: #392D12;
  --color-error: #F87171;
  --color-error-light: #3A1B1B;
  --color-violet: #C4A8FF;
  --color-violet-light: rgba(167, 139, 250, 0.14);
}

/* ═══════════════════════════════════════════
   RESET & BASE
   ═══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { font-family: var(--font-body); color: var(--color-text); background: var(--color-bg); overflow: hidden; height: 100vh; }
a { color: var(--color-accent); text-decoration: none; }
a:hover { color: var(--color-accent-dark); }
button { font-family: var(--font-body); cursor: pointer; border: none; outline: none; }
input { font-family: var(--font-body); outline: none; }
::selection { background: var(--color-accent-fill); color: white; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-muted); }

/* ═══════════════════════════════════════════
   SCREEN MANAGEMENT
   ═══════════════════════════════════════════ */
.screen {
  position: fixed; inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-slow), transform var(--transition-slow);
  transform: translateX(20px);
  z-index: 1;
}
.screen.active {
  opacity: 1;
  pointer-events: all;
  transform: translateX(0);
}

/* ═══════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  transition: all var(--transition-fast);
  letter-spacing: -0.01em;
}
/* `.btn` (inline-flex) beats the UA `[hidden]{display:none}` rule. */
.btn[hidden] { display: none; }
.btn-primary {
  background: var(--color-accent-fill);
  color: white;
  box-shadow: 0 1px 2px rgba(42,68,223,0.3);
}
.btn-primary:hover {
  background: var(--color-accent-fill-hover);
  box-shadow: 0 2px 8px rgba(42,68,223,0.35);
  transform: translateY(-1px);
}
.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover {
  background: var(--color-surface-alt);
  border-color: var(--color-border-strong);
}
.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  padding: 8px 12px;
}
.btn-ghost:hover { background: var(--color-surface-alt); color: var(--color-text); }

.btn-sm { padding: 6px 14px; font-size: 0.82rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
/* Fixed red in both themes: white on the dark theme's lighter error red is under 4.5:1. */
.btn-primary.btn-destructive { background: #DC2626; box-shadow: none; }
.btn-primary.btn-destructive:hover { background: #B91C1C; box-shadow: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; box-shadow: none !important; }
.btn:disabled:hover { transform: none; }
/* Paid actions: a filled text-colour button that never looks like a free action. */
.pr-paid { background: var(--color-accent-fill); color: #FFFFFF; border: 1px solid var(--color-accent-fill); }
.pr-paid:hover:not(:disabled) { background: var(--color-accent-fill-hover); border-color: var(--color-accent-fill-hover); }
.pr-paid:disabled { opacity: 0.5; cursor: not-allowed; }
.pr-paid svg { width: 15px; height: 15px; flex: none; }
.pr-paid[hidden] { display: none; }

/* ═══════════════════════════════════════════
   INPUTS
   ═══════════════════════════════════════════ */
.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-group[hidden] { display: none; }
.input-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.01em;
}
.input-field {
  width: 100%;
  min-width: 0;
  padding: 11px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  background: var(--color-surface);
  color: var(--color-text);
  transition: all var(--transition-fast);
}
.input-field:focus {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-glow);
}
.input-field::placeholder { color: var(--color-text-muted); }

/* ═══════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.badge-success { background: var(--color-success-light); color: var(--color-success); }
.badge-warning { background: var(--color-warning-light); color: var(--color-warning); }
.badge-info { background: var(--color-accent-light); color: var(--color-accent); }
.badge-muted { background: var(--color-surface-alt); color: var(--color-text-muted); }

/* On dark, the solid light-theme tints read as muddy blobs. Dark badges use a
   translucent colour wash, brighter text, and a hairline inset border (no
   layout shift) so each status stays crisp and legible against the slate. */
html[data-theme="dark"] .badge-success {
  background: rgba(52, 211, 153, 0.13);
  color: #4ADE80;
  box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.30);
}
html[data-theme="dark"] .badge-warning {
  background: rgba(251, 191, 36, 0.13);
  color: #FBBF24;
  box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.30);
}
html[data-theme="dark"] .badge-error {
  background: rgba(248, 113, 113, 0.13);
  color: #F87171;
  box-shadow: inset 0 0 0 1px rgba(248, 113, 113, 0.30);
}
html[data-theme="dark"] .badge-info {
  background: rgba(143, 156, 255, 0.13);
  color: var(--color-accent);
  box-shadow: inset 0 0 0 1px rgba(143, 156, 255, 0.30);
}
html[data-theme="dark"] .badge-muted {
  background: rgba(148, 163, 184, 0.12);
  color: var(--color-text-secondary);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.22);
}

/* ═══════════════════════════════════════════
   APP SHELL (projects list, price lists, library)
   ═══════════════════════════════════════════ */
.app-shell { display: flex; flex-direction: column; height: 100vh; }
.app-shell > .main-content { flex: 1 1 auto; min-height: 0; }

/* Left navigation (app-nav.js): fixed beside every signed-in page, full or the icon rail. */
body.has-app-nav { --app-nav-w: 280px; padding-left: var(--app-nav-w); box-sizing: border-box; }
body.has-app-nav.app-nav-rail { --app-nav-w: 60px; }
body.has-app-nav .screen { left: var(--app-nav-w); }
.app-nav {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 30;
  width: var(--app-nav-w); box-sizing: border-box;
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 10px;
  background: var(--color-bg);
  border-right: 1px solid var(--color-border);
}
.app-nav-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 40px; padding: 0 4px 0 8px; margin-bottom: 12px; }
.app-nav-logo { display: inline-flex; align-items: center; color: inherit; }
.app-nav-logo .coil-logo { height: 22px; }
.app-nav-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--color-text-muted); cursor: pointer;
}
.app-nav-toggle:hover { background: var(--color-surface); color: var(--color-text); }
.app-nav-toggle svg { width: 16px; height: 16px; }
.app-nav-items { display: flex; flex-direction: column; gap: 2px; }
.app-nav-item {
  display: flex; align-items: center; gap: 10px;
  min-height: 36px; padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem; font-weight: 500; color: var(--color-text-secondary); text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.app-nav-item:hover { background: var(--color-surface); color: var(--color-text); }
.app-nav-item.is-current { background: var(--color-accent-light); color: var(--color-accent-dark); font-weight: 600; }
html[data-theme="dark"] .app-nav-item.is-current { background: rgba(143, 156, 255, 0.13); color: var(--color-accent); box-shadow: inset 0 0 0 1px rgba(143, 156, 255, 0.22); }
.app-nav-icon { display: inline-flex; flex: 0 0 auto; }
.app-nav-icon svg { width: 18px; height: 18px; }
.app-nav-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-nav-soon, .app-nav-badge {
  flex: 0 0 auto; padding: 0 7px; border-radius: 999px;
  font-size: 0.68rem; font-weight: 600; line-height: 18px;
  background: var(--color-surface-alt); color: var(--color-text-muted);
}
.app-nav-badge { margin-left: auto; background: var(--color-accent-light); color: var(--color-accent); }
.app-nav-spacer { flex: 1 1 auto; }
.app-nav-account { border-top: 1px solid var(--color-border); padding-top: 8px; }
.app-nav-me {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 6px; border: 0; border-radius: var(--radius-md);
  background: none; color: var(--color-text); font: inherit; text-align: left; cursor: pointer;
}
.app-nav-me:hover, .app-nav-me[aria-expanded="true"] { background: var(--color-surface); }
.app-nav-me.is-current .app-nav-name { color: var(--color-accent); }
.app-nav-me:focus-visible, .app-nav-item:focus-visible, .app-nav-toggle:focus-visible, .app-nav-logo:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 1px; }
.app-nav-avatar { width: 30px; height: 30px; font-size: 0.85rem; }
.app-nav-who { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; line-height: 1.25; }
.app-nav-name { font-size: 0.85rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-nav-company { font-size: 0.74rem; color: var(--color-text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-nav-dots { display: inline-flex; color: var(--color-text-muted); }
.app-nav-dots svg { width: 16px; height: 16px; }
/* Opens in place above the account block, inside the sidebar; beats the shared `.user-menu-panel` placement under a trigger. */
.app-nav-account .app-nav-menu { position: static; min-width: 0; max-width: none; margin-bottom: 6px; padding: 6px; border-radius: var(--radius-md); box-shadow: none; }
html[data-theme="dark"] .app-nav-account .app-nav-menu { box-shadow: none; }
.app-nav-menu a.user-menu-item { box-sizing: border-box; text-decoration: none; }
.app-nav-menu-section { padding: 6px 8px 2px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-text-muted); }
/* The rail: icons only, the label in each item's title. */
.app-nav-rail .app-nav { align-items: center; padding: 12px 8px; }
.app-nav-rail .app-nav-head { flex-direction: column; height: auto; gap: 8px; padding: 0; }
.app-nav-rail .app-nav-items { align-items: center; }
.app-nav-rail .app-nav-item { justify-content: center; width: 40px; padding: 0; }
.app-nav-rail .app-nav-label, .app-nav-rail .app-nav-soon, .app-nav-rail .app-nav-who, .app-nav-rail .app-nav-dots { display: none; }
.app-nav-rail .app-nav-account { align-self: stretch; display: flex; justify-content: center; }
.app-nav-rail .app-nav-me { width: auto; padding: 4px; }
/* The rail is too narrow to hold the menu, so there it opens beside the rail. */
.app-nav-rail .app-nav-account .app-nav-menu { position: fixed; top: auto; right: auto; left: 66px; bottom: 8px; width: 260px; margin: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
html[data-theme="dark"] .app-nav-rail .app-nav-account .app-nav-menu { box-shadow: 0 4px 16px rgba(0,0,0,.45); }
.app-nav-narrow .app-nav-toggle { display: none; }

/* The top bar (app-nav.js) above the navigation outside a project workspace. Its
   middle column lines up with the page content (.main-content padding, .projects-page width). */
/* Every page's top bar has this height and the 26px logo. */
:root { --topbar-h: 61px; }
body.has-app-topbar { --app-topbar-h: var(--topbar-h); padding-top: var(--app-topbar-h); }
body.has-app-topbar .app-nav { top: var(--app-topbar-h); padding-top: 14px; }
body.has-app-topbar .screen { top: var(--app-topbar-h); }
body.has-app-topbar .app-shell { height: calc(100vh - var(--app-topbar-h)); }
body.has-app-topbar .settings-shell, body.has-app-topbar .admin-shell, body.has-app-topbar .np-shell { min-height: calc(100vh - var(--app-topbar-h)); }
.app-topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 31;
  height: var(--app-topbar-h); box-sizing: border-box;
  display: flex; align-items: center;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}
.app-topbar[hidden] { display: none; }
.app-topbar-brand {
  width: var(--app-nav-w); flex: none; box-sizing: border-box; height: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 14px 0 18px;
  border-right: 1px solid var(--color-border);
}
.app-topbar-brand .app-nav-logo .coil-logo { height: 26px; }
.app-topbar-main { flex: 1 1 auto; min-width: 0; padding: 0 32px; }
.app-topbar-search { display: flex; max-width: 1160px; margin: 0 auto; }
.app-topbar-search .table-search { max-width: 420px; }
.app-topbar-search .table-search input { padding-top: 6px; padding-bottom: 6px; font-size: 0.85rem; }
.app-topbar-notices { position: relative; }
/* The top-right corner (app-nav.js buildCorner): notifications, then the account avatar
   whose menu drops down under it, right-aligned. */
.app-user-corner { display: flex; align-items: center; gap: 6px; }
.app-corner-account { position: relative; }
.app-corner-me {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%;
  background: none; cursor: pointer;
}
.app-corner-me:hover .app-corner-avatar, .app-corner-me[aria-expanded="true"] .app-corner-avatar { box-shadow: 0 0 0 3px var(--color-surface-alt); }
.app-corner-me.is-current .app-corner-avatar { box-shadow: 0 0 0 2px var(--color-accent); }
.app-corner-me:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 1px; }
.app-corner-avatar { width: 28px; height: 28px; font-size: 0.8rem; }
.app-corner-account .app-nav-menu { width: 260px; padding: 6px; }
.app-topbar .app-user-corner { position: absolute; top: 50%; right: 16px; transform: translateY(-50%); }

.app-topbar-bell {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--color-text-secondary); cursor: pointer;
}
.app-topbar-bell:hover, .app-topbar-bell[aria-expanded="true"] { background: var(--color-surface); color: var(--color-text); }
.app-topbar-bell:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 1px; }
.app-topbar-bell svg { width: 18px; height: 18px; }
.app-user-corner .app-topbar-notices-panel { width: 300px; max-width: calc(100vw - 32px); padding: 6px; }
.app-topbar-notices-empty { margin: 4px 8px 10px; font-size: 0.85rem; color: var(--color-text-muted); }
.app-topbar-bell { position: relative; }
.app-topbar-badge {
  position: absolute; top: 2px; right: 1px;
  min-width: 16px; height: 16px; padding: 0 4px; box-sizing: border-box;
  border-radius: 999px; background: #C4320A; color: #FFFFFF;
  font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}
.app-topbar-badge[hidden] { display: none; }
.app-topbar-notices-list { max-height: min(420px, 70vh); overflow-y: auto; }
.app-notice {
  display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; align-items: start; gap: 8px;
  padding: 8px; border-radius: var(--radius-sm);
  color: var(--color-text); text-decoration: none;
}
a.app-notice:hover { background: var(--color-surface-hover); }
.app-notice-dot { width: 8px; height: 8px; margin-top: 5px; border-radius: 50%; background: transparent; }
.app-notice.is-unread .app-notice-dot { background: var(--color-accent); }
.app-notice-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.app-notice-title { font-size: 0.85rem; font-weight: 600; }
.app-notice.is-failed .app-notice-title { color: var(--color-error); }
.app-notice-subject, .app-notice-detail { font-size: 0.78rem; color: var(--color-text-muted); overflow-wrap: anywhere; }
.app-notice-when { font-size: 0.72rem; color: var(--color-text-muted); white-space: nowrap; }
.app-nav-rail .app-topbar-brand { justify-content: center; padding: 0; }

/* Settings pages: a section list beside the cards. */
.settings-shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100vh; }
.settings-nav { border-right: 1px solid var(--color-border); padding: 28px 12px; }
.settings-nav-list { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 28px; }
.settings-nav-group { padding: 14px 10px 6px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-text-muted); }
.settings-nav-group:first-child { padding-top: 0; }
.settings-nav-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px; border-radius: var(--radius-sm); font-size: 0.88rem; color: var(--color-text-secondary); text-decoration: none; }
a.settings-nav-item:hover { background: var(--color-surface); color: var(--color-text); }
.settings-nav-item.is-current { background: var(--color-surface); color: var(--color-text); font-weight: 600; }
.settings-nav-item.is-soon { color: var(--color-text-muted); cursor: default; }
.settings-nav-item:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 1px; }
.settings-main { width: 100%; max-width: 900px; box-sizing: border-box; display: flex; flex-direction: column; gap: 20px; }
.settings-title { margin: 0; font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.settings-card { padding: 20px 24px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); scroll-margin-top: 24px; }
.settings-card-title { margin: 0 0 4px; font-size: 1.05rem; font-weight: 700; color: var(--color-text); }
.settings-note { margin: 0; font-size: 0.85rem; color: var(--color-text-secondary); }
.settings-fields { margin: 12px 0; }
.settings-field { display: grid; grid-template-columns: 140px minmax(0, 1fr); align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--color-border); }
.settings-field dt { font-size: 0.85rem; color: var(--color-text-secondary); }
.settings-field dd { margin: 0; font-size: 0.9rem; color: var(--color-text); overflow-wrap: anywhere; }
.settings-avatar-row { display: flex; align-items: center; gap: 12px; }
.settings-avatar { width: 40px; height: 40px; font-size: 1rem; }
.settings-theme { display: inline-flex; gap: 2px; margin-top: 12px; padding: 3px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-alt); }
.settings-theme-option { min-width: 84px; padding: 6px 14px; border: 0; border-radius: var(--radius-sm); background: none; font: inherit; font-size: 0.85rem; color: var(--color-text-secondary); cursor: pointer; }
.settings-theme-option.on { background: var(--color-surface); color: var(--color-text); font-weight: 600; box-shadow: var(--shadow-sm); }
.settings-theme-option:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 1px; }
@media (max-width: 720px) {
  .settings-shell { grid-template-columns: minmax(0, 1fr); }
  .settings-nav { border-right: 0; border-bottom: 1px solid var(--color-border); padding: 16px 12px; }
  .settings-field { grid-template-columns: minmax(0, 1fr); gap: 4px; }
}

/* Library: not built yet. */

/* Top bar */
.top-bar {
  grid-column: 1 / -1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  z-index: 10;
}
.top-bar-left { display: flex; align-items: center; gap: 20px; min-width: 0; overflow: hidden; }
.top-bar-right { flex-shrink: 0; }
.coil-logo { display: block; height: 22px; width: auto; }
.coil-logo-icon { fill: var(--logo-icon); }
.coil-logo-word { fill: var(--logo-word); }
.top-bar-sep {
  width: 1px; height: 24px;
  background: var(--color-border);
}
.top-bar-context {
  font-size: 0.9rem;
  color: var(--color-text-secondary);
  display: flex; align-items: center; gap: 8px;
}
.top-bar-right { display: flex; align-items: center; gap: 16px; }

/* Main content area */
.main-content {
  padding: 32px;
  overflow-y: auto;
  background: var(--color-bg);
}

/* ═══════════════════════════════════════════
   SCREEN 1: DASHBOARD
   ═══════════════════════════════════════════ */
/* The Projects page (#1531): content centred at most 1160px wide. */
.projects-page { max-width: 1160px; margin: 0 auto; }
.dashboard-header {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px 16px;
  margin-bottom: 18px;
}
.dashboard-header-actions { display: flex; align-items: center; gap: 12px; flex: 1; justify-content: flex-end; min-width: 0; }
.dashboard-header-actions .table-search { max-width: 320px; }
.dashboard-header-actions .btn { flex: none; }
.spend-line { color: var(--color-text-muted); }
.spend-line.spend-warn { color: var(--color-warning); }
.spend-line.spend-over { color: var(--color-error); }
.dashboard-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

/* Status filter chips above the table; the selected chip is filled. */
/* Needs your attention: four cards over the project list. */
.attention { margin-bottom: 24px; }
.attention-heading {
  margin: 0 0 12px;
  font-family: var(--font-mono);
  font-size: 12px; font-weight: 400;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--color-text-secondary);
}
.attention-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1200px) { .attention-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) { .attention-cards { grid-template-columns: 1fr; } }
.attention-card {
  display: flex; flex-direction: column; gap: 6px;
  min-width: 0; padding: 20px;
  border: 1px solid #E4E8FF; border-radius: var(--radius-md);
  background: #FFFFFF; color: #110E1A;
  text-decoration: none;
}
button.attention-card { font: inherit; text-align: left; cursor: pointer; }
button.attention-card:hover { border-color: #2A44DF; color: #110E1A; }
button.attention-card:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(42, 68, 223, 0.25); }
.attention-card.is-active { border-color: #2A44DF; box-shadow: inset 0 0 0 1px #2A44DF; }
.attention-value { font-family: var(--font-mono); font-size: 32px; line-height: 1.1; color: #2A44DF; }
.attention-title { font-weight: 600; }
.attention-detail { font-size: 13px; line-height: 1.4; color: #373A52; overflow-wrap: anywhere; }
.attention-card.attention-usage { border-color: var(--color-accent-fill); background: var(--color-accent-fill); color: #FFFFFF; }
.dashboard-stats { display: flex; flex-wrap: wrap; gap: 8px 28px; margin-top: 14px; font-size: 14px; color: var(--color-text-secondary); }
.dashboard-stats[hidden] { display: none; }
.dashboard-stat { display: inline-flex; align-items: baseline; gap: 6px; }
.dashboard-stat-value { font-family: var(--font-mono); font-weight: 700; color: var(--color-text); }
.attention-usage .attention-value { color: #FFFFFF; }
.attention-usage .attention-detail { color: #E4E8FF; }
html[data-theme="dark"] .attention-card { border-color: #373A52; background: #110E1A; color: #F1F2F7; }
html[data-theme="dark"] button.attention-card:hover { border-color: #556DFF; color: #F1F2F7; }
html[data-theme="dark"] .attention-card.is-active { border-color: #8F9CFF; box-shadow: inset 0 0 0 1px #8F9CFF; }
html[data-theme="dark"] .attention-value { color: #8F9CFF; }
html[data-theme="dark"] .attention-detail { color: #E4E8FF; }
html[data-theme="dark"] .attention-card.attention-usage { border-color: var(--color-accent-fill); background: var(--color-accent-fill); }
html[data-theme="dark"] .attention-usage .attention-value { color: #FFFFFF; }

.status-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.status-chip {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--color-border-strong);
  border-radius: 999px;
  background: var(--color-surface);
  color: var(--color-text-secondary);
  font-size: 13px;
  font-weight: 600;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}
.status-chip:hover { border-color: var(--color-accent); color: var(--color-text); }
.status-chip:focus-visible { box-shadow: var(--shadow-glow); }
.status-chip.is-selected { background: var(--color-accent-fill); border-color: var(--color-accent-fill); color: #FFFFFF; }
.status-chips-sep { align-self: stretch; width: 1px; margin: 4px 4px; background: var(--color-border); }

/* Project table */
.project-table {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.project-table table {
  width: 100%;
  border-collapse: collapse;
}
/* On a screen tall enough, the page stays put and only the table scrolls,
   its header row kept in view. */
@media (min-height: 600px) {
  .main-content:has(> .projects-page) { display: flex; flex-direction: column; overflow: hidden; }
  .main-content > .projects-page { flex: 1 1 auto; min-height: 0; width: 100%; display: flex; flex-direction: column; }
  .projects-page > * { flex-shrink: 0; }
  .projects-page > .project-table { flex: 0 1 auto; min-height: 160px; overflow: auto; }
  .project-table thead th { position: sticky; top: 0; z-index: 1; box-shadow: inset 0 -1px 0 var(--color-border); }
}
.project-table th {
  text-align: left;
  padding: 14px 20px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  background: var(--color-surface-alt);
  border-bottom: 1px solid var(--color-border);
}
.project-table td {
  padding: 16px 20px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}
.project-table tr:last-child td { border-bottom: none; }
.project-table tbody tr.project-row {
  position: relative;
  cursor: pointer;
  transition: background var(--transition-fast);
}
.project-table tbody tr.project-row:hover,
.project-table tbody tr.project-row:focus-within { background: var(--color-surface-hover); }
/* The row's link is stretched over the whole row, so a click, Cmd/Ctrl-click
   or middle-click anywhere on it opens the project; the ⋯ button sits above. */
.project-table .project-row-link {
  font-weight: 600;
  color: var(--color-text);
  outline: none;
}
.project-table .project-row-link::after { content: ''; position: absolute; inset: 0; }
.project-table .project-row-link:focus-visible::after { box-shadow: inset 0 0 0 2px var(--color-accent); }
.project-table .project-row-link:hover { color: var(--color-text); }
.project-table .col-number { width: 72px; }
.project-table .col-actions { width: 56px; }
.project-table .project-cell-none { color: var(--color-text-muted); }
.project-table .project-estimator { color: var(--color-text-secondary); }
.project-table .project-client { color: var(--color-text-secondary); }
.project-table .col-estimator { width: 96px; }
.project-table .col-progress { width: 190px; }
.project-table .col-tender { width: 120px; }
.project-table .col-quote { width: 130px; }
.project-table .project-tender { color: var(--color-text-secondary); white-space: nowrap; }
.project-table .project-tender.is-soon { color: var(--color-text); font-weight: 700; }
.project-table .project-tender.is-past { color: var(--color-error); }
.project-table .project-quote { font-family: var(--font-mono); font-size: 0.85rem; white-space: nowrap; }
.estimator-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #FFFFFF;
  font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
}
.project-progress { display: flex; flex-direction: column; gap: 5px; min-width: 120px; }
.project-progress-text { font-size: 0.85rem; color: var(--color-text-secondary); }
.project-progress-bar { display: block; height: 4px; border-radius: 100px; background: var(--color-border); overflow: hidden; }
.project-progress-fill { display: block; height: 100%; border-radius: inherit; background: var(--color-accent); }
.status-pill {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.status-pill.status-draft { background: var(--color-surface-alt); color: var(--color-text-muted); box-shadow: inset 0 0 0 1px var(--color-border); }
.status-pill.status-processing { background: var(--color-accent-light); color: var(--color-accent); }
.status-pill.status-in_review { background: transparent; color: var(--color-accent); box-shadow: inset 0 0 0 1px var(--color-accent); }
.status-pill.status-quoted { background: var(--color-violet-light); color: var(--color-violet); }
/* The pulsing dot: work is running (a sort, an assembly, an estimate). */
.status-pill.is-running { gap: 6px; }
.sort-row .status-pill.status-processing::before,
.status-pill.is-running::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  animation: sort-row-pulse 1.4s ease-in-out infinite;
}
.sort-row .status-pill.status-processing { gap: 6px; }
.status-pill.status-failed { background: var(--color-error-light); color: var(--color-error); }
/* Placeholder rows of drawing packages being sorted (sort-rows.js). */
.project-table tbody tr.sort-row { opacity: 1; animation: none; cursor: default; background: color-mix(in srgb, var(--color-accent-light) 35%, transparent); }
.project-table tbody tr.sort-row:hover { background: color-mix(in srgb, var(--color-accent-light) 35%, transparent); }
.project-table tbody tr.sort-row.is-failed,
.project-table tbody tr.sort-row.is-failed:hover { background: color-mix(in srgb, var(--color-error-light) 45%, transparent); }
.sort-row-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--color-accent-light);
  color: var(--color-accent);
}
.sort-row-icon svg { width: 16px; height: 16px; }
.sort-row-spin { animation: sort-row-spin 0.9s linear infinite; transform-origin: 50% 50%; }
.sort-row.is-failed .sort-row-icon { background: var(--color-error-light); color: var(--color-error); }
.sort-row-name { font-weight: 600; color: var(--color-text); }
.sort-row .project-main .sort-row-error { margin-top: 6px; max-width: 260px; }
.sort-row-error { display: block; max-width: 340px; font-size: 0.82rem; color: var(--color-error); }
.sort-row .project-progress-bar.is-moving .project-progress-fill {
  width: 35%;
  animation: sort-row-moving 1.3s ease-in-out infinite;
}
.sort-row-actions { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.sort-row-dismiss {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--color-text-muted);
}
.sort-row-dismiss:hover { background: var(--color-surface-alt); color: var(--color-text); }
@keyframes sort-row-spin { to { transform: rotate(360deg); } }
@keyframes sort-row-pulse { 50% { opacity: 0.25; } }
@keyframes sort-row-moving { 0% { transform: translateX(-100%); } 100% { transform: translateX(290%); } }
@media (prefers-reduced-motion: reduce) {
  .sort-row-spin, .sort-row .status-pill.status-processing::before, .status-pill.is-running::before,
  .sort-row .project-progress-bar.is-moving .project-progress-fill { animation: none; }
}
.project-actions-cell { text-align: right; }
.project-actions {
  position: relative; z-index: 1;
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--color-text-muted);
}
.project-actions:hover, .project-actions[aria-expanded="true"] { background: var(--color-surface-alt); color: var(--color-text); }
.project-actions:focus-visible { box-shadow: var(--shadow-glow); }
/* The row ⋯ menu: a popover on <body>, so the table card does not clip it. */
.project-menu {
  position: fixed; z-index: 1000;
  min-width: 180px;
  padding: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}
.project-menu-item {
  display: block; width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--color-text);
  font-size: 0.88rem;
  text-align: left;
}
.project-menu-item:hover:not(:disabled), .project-menu-item:focus-visible { background: var(--color-surface-hover); }
.project-menu-item:disabled { color: var(--color-text-muted); cursor: not-allowed; }
.project-menu-item.is-danger { color: var(--color-error); }
.project-menu-item svg { width: 15px; height: 15px; vertical-align: -2px; margin-right: 6px; }
.project-menu-divider { height: 1px; margin: 6px 4px; background: var(--color-border); }
.project-table .project-customer {
  color: var(--color-text-secondary);
  font-size: 0.82rem;
  margin-top: 1px;
}
.project-table .project-number {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.table-search {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 360px;
}
.table-search svg {
  position: absolute;
  left: 12px;
  color: var(--color-text-muted);
  pointer-events: none;
}
.table-search input {
  width: 100%;
  min-width: 0;
  padding: 10px 14px 10px 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background: var(--color-surface);
  color: var(--color-text);
  transition: all var(--transition-fast);
}
.table-search input:focus {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-glow);
}
.table-search input::placeholder { color: var(--color-text-muted); }

/* Sortable column headers */
.project-table th.sortable { padding: 0; }
.project-table th.sortable .th-sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 14px 20px;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  transition: color var(--transition-fast);
}
.project-table th.sortable .th-sort:hover { color: var(--color-text); }
.project-table th.sortable.sorted .th-sort { color: var(--color-accent); }
.project-table th.sortable .sort-caret {
  font-size: 0.6rem;
  line-height: 1;
  min-width: 8px;
}

/* Pagination footer under every data table (table-pagination.js). */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--color-border);
}
.pagination[hidden] { display: none; }
/* The pagers' shared live region: read by screen readers, never shown. */
.pagination-announcer {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.pagination-summary {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  letter-spacing: -0.01em;
}
.pagination-summary strong {
  color: var(--color-text-secondary);
  font-weight: 600;
}
.pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.page-numbers {
  display: flex;
  align-items: center;
  gap: 2px;
}
.pagination .page-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: all var(--transition-fast);
}
.pagination .page-btn:hover:not(:disabled):not(.on) {
  background: var(--color-surface-hover);
  color: var(--color-text);
}
.pagination .page-btn.on {
  background: var(--color-accent-fill);
  color: #fff;
  box-shadow: 0 2px 10px var(--color-accent-glow);
  cursor: default;
}
/* Prev / Next read as outlined anchor buttons at the ends of the control. */
.pagination .page-nav {
  gap: 5px;
  padding: 0 14px;
  font-family: var(--font-body);
  border-color: var(--color-border-strong);
  color: var(--color-text);
}
.pagination .page-nav:hover:not(:disabled) {
  background: var(--color-surface-hover);
  border-color: var(--color-text-muted);
}
.pagination .page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.pagination .page-gap {
  min-width: 24px;
  height: 36px;
  display: inline-flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
  color: var(--color-text-muted);
  user-select: none;
}

/* Row stagger animation */
.project-table tbody tr {
  opacity: 0;
  animation: fadeSlideUp 0.4s ease forwards;
}
.project-table tbody tr:nth-child(1) { animation-delay: 0.05s; }
.project-table tbody tr:nth-child(2) { animation-delay: 0.1s; }
.project-table tbody tr:nth-child(3) { animation-delay: 0.15s; }
.project-table tbody tr:nth-child(4) { animation-delay: 0.2s; }
.project-table tbody tr:nth-child(5) { animation-delay: 0.25s; }

/* Projects, admin and company admin pages in Coil brand colours only: page,
   top bar and sidebar share one colour and the content is the only card.
   Scoped here so other screens and electrical.html keep the global tokens.
   Light mid-grey #8B91BC is 2.7:1 on #F1F2F7, so in light it is a border
   colour only. */
#screen-dashboard,
.admin-body {
  --color-surface-alt: #F1F2F7;
  --color-surface-hover: #F1F2F7;
  --color-text-muted: #373A52;
  --color-border: #E4E8FF;
  --color-border-strong: #8B91BC;
  --color-accent-light: #E4E8FF;
}
html[data-theme="dark"] #screen-dashboard,
html[data-theme="dark"] .admin-body {
  --color-surface-alt: #110E1A;
  --color-surface-hover: #110E1A;
  --color-text-secondary: #E4E8FF;
  --color-text-muted: #8B91BC;
  --color-border: #373A52;
  --color-border-strong: #373A52;
  --color-accent: #556DFF;
  --color-accent-light: #142287;
  --color-accent-glow: rgba(85, 109, 255, 0.35);
  --shadow-glow: 0 0 0 3px var(--color-accent-glow);
}
#screen-dashboard .status-chip:not(.is-selected) { background: transparent; }
/* One table: Projects, the admin page and the company admin page. */
#screen-dashboard .project-table,
.admin-body .project-table { border: none; border-radius: 12px; box-shadow: none; }
#screen-dashboard .project-table th,
.admin-body .project-table th,
#screen-dashboard .project-table th.sortable .th-sort {
  height: 44px;
  padding: 0 20px;
  background: var(--color-surface);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}
#screen-dashboard .project-table th.sortable { padding: 0; }
#screen-dashboard .project-table th.sortable .th-sort:hover { color: var(--color-text); }
#screen-dashboard .project-table td,
.admin-body .project-table td { height: 60px; padding: 10px 20px; font-size: 14px; }
#screen-dashboard .status-pill,
.admin-body .status-pill { font-size: 12px; font-weight: 700; border-radius: 999px; }
#screen-dashboard .project-actions,
.admin-body .project-actions { border-radius: 8px; color: var(--color-text-secondary); }
#screen-dashboard .project-actions:hover,
#screen-dashboard .project-actions[aria-expanded="true"],
.admin-body .project-actions:hover,
.admin-body .project-actions[aria-expanded="true"] { color: var(--color-text); }
#screen-dashboard .project-table th.sortable.sorted .th-sort { color: var(--color-text); }
/* A window with no room for the table at its full cell padding: tighter cells, so the table does not scroll sideways. */
@media (max-width: 1400px) {
  #screen-dashboard .project-table th:not(.sortable),
  #screen-dashboard .project-table th.sortable .th-sort,
  #screen-dashboard .project-table td { padding-left: 12px; padding-right: 12px; }
}
#screen-dashboard .pagination .page-btn:hover:not(:disabled):not(.on),
.admin-body .pagination .page-btn:hover:not(:disabled):not(.on) { background: var(--color-surface); }
html[data-theme="dark"] #screen-dashboard .project-actions:hover,
html[data-theme="dark"] #screen-dashboard .project-actions[aria-expanded="true"],
html[data-theme="dark"] .admin-body .project-actions:hover,
html[data-theme="dark"] .admin-body .project-actions[aria-expanded="true"] { background: #373A52; }
html[data-theme="dark"] #screen-dashboard .sort-row-icon { color: #E4E8FF; }
#screen-dashboard .project-progress-fill { background: #2A44DF; }
#screen-dashboard .status-pill.status-ready { background: #2A44DF; color: #FFFFFF; }
#screen-dashboard .status-pill.status-processing { background: #E4E8FF; color: #142287; }
html[data-theme="dark"] #screen-dashboard .status-pill.status-processing { background: #142287; color: #E4E8FF; }
#screen-dashboard .status-pill.status-draft {
  background: transparent;
  color: var(--color-text-muted);
  box-shadow: inset 0 0 0 1px var(--color-border-strong);
}
#screen-dashboard .status-pill.status-quoted { background: var(--color-text); color: var(--color-bg); }
#screen-dashboard .status-pill.status-in_review { background: transparent; color: #2A44DF; box-shadow: inset 0 0 0 1px #2A44DF; }
html[data-theme="dark"] #screen-dashboard .status-pill.status-in_review { color: #E4E8FF; box-shadow: inset 0 0 0 1px #556DFF; }

/* ═══════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-med);
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 36px;
  max-width: 640px;
  width: 90%;
  transform: translateY(12px) scale(0.98);
  transition: transform var(--transition-slow);
}
.modal-overlay.active .modal-card {
  transform: translateY(0) scale(1);
}
/* The light backdrop tint and shadow vanish on dark pages: darken the page
   behind and give the card an edge. */
html[data-theme="dark"] .modal-overlay {
  background: rgba(4, 5, 8, 0.72);
  backdrop-filter: blur(2px);
}
html[data-theme="dark"] .modal-card {
  border: 1px solid var(--color-border-strong);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), 0 24px 64px rgba(0, 0, 0, 0.55);
}
.modal-title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.modal-subtitle {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  margin-bottom: 28px;
}
.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: none; border: none;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  cursor: pointer;
}
.modal-close:hover { background: var(--color-surface-alt); color: var(--color-text); }


/* Dialog-variant modals (confirm/alert/prompt via ui-modal.js).
   A compact card with a title, optional subtitle/message, and a right-aligned
   footer row of buttons. Reuses .modal-overlay + .modal-card for transitions
   and backdrop. */
.modal-dialog-card { padding: 28px 28px 24px; max-width: 480px; }
.modal-dialog-body { /* reserved for promptModal's input group */ }
.modal-dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

/* The tender pack and progress pages' shell under a plain top bar. */
.np-shell { min-height: 100vh; display: flex; flex-direction: column; background: var(--color-bg); }
/* The tender pack page: drop, details and services in three columns. */
.tp-topbar {
  position: sticky; top: 0; z-index: 31; flex: none;
  height: var(--topbar-h); box-sizing: border-box;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 16px 0 18px; border-bottom: 1px solid var(--color-border); background: var(--color-bg);
}
.tp-home { display: inline-flex; align-items: center; }
.tp-home .coil-logo { height: 26px; }
.tp-home .is-mark { display: none; }
/* Below 900px the home pages show the mark alone in the navigation rail. */
@media (max-width: 900px) { .tp-home .is-word { display: none; } .tp-home .is-mark { display: inline-flex; } }
.tp-user-corner { display: flex; }
.tp-main { flex: 1; width: 100%; padding: 28px 32px 64px; box-sizing: border-box; }
@media (max-width: 760px) { .tp-main { padding: 20px 16px 48px; } }
.tp-page { display: flex; flex-direction: column; gap: 24px; }
.ep-page { max-width: 1040px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.np-shell:has(.ep-main) { height: 100vh; min-height: 0; }
body.has-app-topbar .np-shell:has(.ep-main) { height: calc(100vh - var(--app-topbar-h)); }
.ep-main { flex: 1; min-height: 0; overflow-y: auto; }
#ep-root { display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.ep-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 8px 24px; }
.ep-eyebrow { margin: 0 0 6px; font-family: 'Space Mono', monospace; font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-text-muted); }
.ep-close-note { margin: 0; font-size: 0.875rem; color: var(--color-text-muted); }
.ep-problem { margin: 0; font-size: 0.85rem; color: var(--color-warning); }
.ep-empty, .ep-sorting-note { margin: 0; padding: 14px 20px; font-size: 0.85rem; color: var(--color-text-muted); }

/* The step cards: done, the one running, then the ones still to come. */
.ep-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; }
.ep-step { display: flex; align-items: flex-start; gap: 12px; padding: 13px 15px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); }
.ep-step.is-active { border-color: var(--color-accent); box-shadow: inset 0 0 0 1px var(--color-accent); }
.ep-step.is-failed { border-color: var(--color-error); }
.ep-step.is-waiting { background: var(--color-surface-alt); border-style: dashed; border-color: var(--color-border-strong); }
.ep-step-mark { flex: none; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: 700; background: var(--color-accent-light); color: var(--color-accent); }
.ep-step.is-done .ep-step-mark { background: var(--color-success-light); color: var(--color-success); }
.ep-step.is-failed .ep-step-mark { background: var(--color-error-light); color: var(--color-error); }
.ep-step.is-waiting .ep-step-mark { background: var(--color-surface); box-shadow: inset 0 0 0 1px var(--color-border-strong); color: var(--color-text-muted); }
.ep-step-mark.is-spinning { box-sizing: border-box; background: transparent; border: 3px solid var(--color-accent-light); border-top-color: var(--color-accent); animation: sort-row-spin 0.9s linear infinite; }
.ep-step-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ep-step-title { font-size: 0.9rem; color: var(--color-text); }
.ep-step-detail { font-size: 0.8rem; color: var(--color-text-secondary); overflow-wrap: anywhere; }
.ep-step.is-waiting .ep-step-title { color: var(--color-text-secondary); }
.ep-step.is-waiting .ep-step-detail { color: var(--color-text-muted); }
.ep-step.is-failed .ep-step-detail { color: var(--color-error); }
.ep-step-bar { margin-top: 6px; height: 4px; }
.ep-step-action { align-self: flex-start; margin-top: 8px; }

/* The number tiles. */
.ep-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.ep-tile { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); }
.ep-tile-label { font-size: 0.8rem; color: var(--color-text-muted); }
.ep-tile-value { font-family: 'Space Mono', monospace; font-size: 1.6rem; line-height: 1.2; color: var(--color-text); }
.ep-tile.is-done .ep-tile-value { color: var(--color-success); }
.ep-tile-note { font-size: 0.75rem; color: var(--color-text-muted); }
@media (max-width: 760px) { .ep-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* The drawings card: a head with the filter chips over the rows. */
.ep-drawings { border: 1px solid var(--color-border); border-radius: var(--radius-lg); background: var(--color-surface); overflow: hidden; display: flex; flex-direction: column; }
.ep-drawings-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; padding: 12px 20px; background: var(--color-surface-alt); border-bottom: 1px solid var(--color-border); }
.ep-drawings-title { margin: 0; font-size: 0.95rem; color: var(--color-text); }
.ep-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.ep-filter { height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--color-border-strong); background: var(--color-surface); color: var(--color-text-secondary); font: inherit; font-size: 0.8rem; font-weight: 500; cursor: pointer; }
.ep-filter:hover { background: var(--color-surface-hover); }
.ep-filter:focus-visible { outline: none; box-shadow: var(--shadow-glow); }
.ep-filter.is-failed { color: var(--color-error); }
.ep-filter.is-on { border-color: var(--color-accent); background: var(--color-accent-light); color: var(--color-accent-dark); font-weight: 600; }
.ep-drawings-body { min-height: 0; overflow-y: auto; }
/* On a screen tall enough, the page stays put and only the drawings scroll. */
@media (min-height: 640px) and (min-width: 761px) {
  .ep-main { display: flex; flex-direction: column; overflow: hidden; }
  .ep-page { flex: 1 1 auto; min-height: 0; width: 100%; }
  .ep-page > * { flex-shrink: 0; }
  .ep-page > #ep-root { flex: 1 1 auto; min-height: 0; }
  #ep-root > * { flex-shrink: 0; }
  #ep-root > .ep-drawings { flex: 0 1 auto; min-height: 180px; }
}

.ep-list { list-style: none; margin: 0; padding: 0; }
.ep-row { display: grid; grid-template-columns: 160px minmax(0, 1fr) 170px auto; align-items: center; gap: 20px; padding: 14px 20px; border-top: 1px solid var(--color-border); }
.ep-row:first-child { border-top: 0; }
.ep-row-name { font-family: 'Space Mono', monospace; font-size: 0.8rem; color: var(--color-text-secondary); overflow-wrap: anywhere; }
.ep-row-progress { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.ep-row-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ep-row-service { flex: none; padding: 2px 8px; border-radius: 999px; font-size: 0.7rem; font-weight: 600; background: var(--color-surface-alt); box-shadow: inset 0 0 0 1px var(--color-border); color: var(--color-text-secondary); }
.ep-row-revised { flex: none; padding: 2px 8px; border-radius: 999px; font-size: 0.7rem; font-weight: 600; background: var(--color-accent-light); color: var(--color-accent-dark); }
.ep-row-file { min-width: 0; font-size: 0.9rem; font-weight: 500; color: var(--color-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ep-row-detail { font-size: 0.8rem; color: var(--color-text-muted); }
.ep-row.is-failed .ep-row-detail { color: var(--color-error); }
.ep-row-side { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-shrink: 0; min-width: 96px; }
.ep-bar { display: block; height: 6px; border-radius: 999px; background: var(--color-border); overflow: hidden; }
.ep-bar-fill { display: block; height: 100%; border-radius: inherit; transition: width 0.4s ease; }
.ep-bar.is-running .ep-bar-fill { background: var(--color-accent); }
.ep-bar.is-done .ep-bar-fill { background: var(--color-success); }
.ep-bar.is-failed .ep-bar-fill { background: var(--color-error); }
.ep-bar.is-partial .ep-bar-fill { background: var(--color-text-muted); }
.ep-bar.is-sliding .ep-bar-fill { width: 35% !important; animation: sort-row-moving 1.4s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
  .ep-bar-fill { transition: none; }
  .ep-step-mark.is-spinning, .ep-bar.is-sliding .ep-bar-fill, .ep-spinner { animation: none; }
}
@media (max-width: 760px) {
  .ep-row { grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; }
  .ep-row-progress { grid-column: 1 / -1; grid-row: 2; }
  .ep-row-detail { grid-column: 1; grid-row: 3; }
  .ep-row-side { grid-column: 2; grid-row: 1; }
}
.ep-status { min-width: 86px; text-align: center; padding: 3px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; background: var(--color-surface-alt); color: var(--color-text-muted); }
.ep-status.is-running, .ep-status.is-starting { background: var(--color-accent-light); color: var(--color-accent); }
.ep-status.is-queued { background: var(--color-warning-light); color: var(--color-warning); }
.ep-status.is-failed { background: var(--color-error-light); color: var(--color-error); }
.ep-status { display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.ep-status.is-reading, .ep-status.is-sorted { background: var(--color-accent-light); color: var(--color-accent); }
.ep-status.is-waiting { background: transparent; box-shadow: inset 0 0 0 1px var(--color-border); }
.ep-status.is-reference { color: var(--color-text-secondary); }
.ep-status.is-unread { color: var(--color-warning); }
.ep-spinner { flex: none; box-sizing: border-box; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--color-accent-light); border-top-color: var(--color-accent); animation: sort-row-spin 0.9s linear infinite; }
.tp-title { margin: 0; font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; color: var(--color-text); }
.tp-sub { margin: 0; font-size: 0.95rem; line-height: 1.5; color: var(--color-text-secondary); }
/* The New project page's three steps: the stepper, the step's title, then one screen at a time. */
.tp-stepper { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 14px; margin: 0; padding: 0; list-style: none; }
.tp-stepper-step { display: flex; align-items: center; gap: 10px; font-size: 0.95rem; font-weight: 500; color: var(--color-text-secondary); }
.tp-stepper-step + .tp-stepper-step::before { content: ''; width: 56px; height: 2px; margin-right: 4px; background: #C9CEEB; }
.tp-stepper-step.is-done + .tp-stepper-step::before { background: #2A44DF; }
.tp-stepper-number { flex: none; box-sizing: border-box; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; border: 1.5px solid #8B91BC; border-radius: 50%; font-size: 0.85rem; font-weight: 700; }
.tp-stepper-step.is-current { font-weight: 700; color: var(--color-text); }
.tp-stepper-step.is-current .tp-stepper-number { border-color: #2A44DF; background: #2A44DF; color: #FFFFFF; }
.tp-stepper-step.is-done .tp-stepper-number { border-color: #E4E8FF; background: #E4E8FF; color: #2A44DF; }
@media (max-width: 760px) { .tp-stepper-step + .tp-stepper-step::before { width: 16px; } }
.tp-head { display: flex; flex-direction: column; gap: 6px; text-align: center; }
.tp-screen { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
/* `.tp-screen` (flex) beats the UA `[hidden]{display:none}` rule. */
.tp-screen[hidden] { display: none; }
.tp-screen-upload { width: 100%; max-width: 960px; margin: 0 auto; }
.tp-screen-disciplines { width: 100%; max-width: 1120px; margin: 0 auto; }
.tp-screen-upload .tp-actions, .tp-screen-disciplines .tp-actions { justify-content: space-between; }
.tp-screen-upload .tp-estimate, .tp-screen-disciplines .tp-estimate { flex: 0 1 320px; }
/* The body never scrolls, so the page scrolls its own main area; dvh keeps a phone's browser bar off the bottom. */
.np-shell:has(.tp-main) { height: 100vh; height: 100dvh; min-height: 0; }
body.has-app-topbar .np-shell:has(.tp-main) { height: calc(100vh - var(--app-topbar-h)); height: calc(100dvh - var(--app-topbar-h)); }
.tp-main { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
/* The page is at least as high as the window, so the upload step fills it: its drop zone takes the free height and its buttons stand at the bottom. On a very high window the step stops growing, so the zone is never an empty wall. */
.tp-page { flex: 1 0 auto; }
.tp-screen-upload { flex: 1 1 auto; max-height: 680px; }
.tp-screen-upload .tp-drop-large { flex: 1 1 auto; min-height: 240px; }
/* With a pack dropped, its card shows whole: the step is as high as it needs and the drop zone is smaller. */
.tp-screen-upload:has(.tp-facts:not([hidden])) { max-height: none; }
.tp-screen-upload:has(.tp-facts:not([hidden])) .tp-drop-large { min-height: 170px; max-height: 300px; gap: 10px; padding-top: 20px; padding-bottom: 20px; }
.tp-screen-upload:has(.tp-facts:not([hidden])) .tp-drop-large > .tp-icon { width: 48px; height: 48px; border-radius: 12px; }
/* The first two steps have the room for a title that stands lower. */
.tp-page.is-step-1 .tp-head, .tp-page.is-step-2 .tp-head { margin-top: 20px; margin-bottom: 6px; }
/* On a wide, tall enough window the drawings step fits the window: the pack tree and the list scroll inside their panes. */
@media (min-width: 1181px) and (min-height: 640px) {
  .tp-main { padding-top: 20px; padding-bottom: 20px; }
  .tp-page { flex: 1; min-height: 0; gap: 18px; }
  .tp-screen-drawings { flex: 1; min-height: 0; }
  .tp-panes { flex: 1; min-height: 280px; }
  .tp-pane { min-height: 0; }
  .tp-tree-card { flex: 1; min-height: 0; }
  .tp-tree-card > .ft-wrap { flex: 1; }
  .tp-tree { flex: 1; min-height: 0; max-height: none; }
  .ft-scroll.tp-list-body { max-height: none; }
  .tp-actions, .tp-estimate-note { flex: none; }
}
.tp-step-head { display: flex; align-items: center; gap: 10px; min-height: 32px; }
.tp-step-number {
  flex: none; width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; background: #2A44DF; color: #FFFFFF; font-size: 0.85rem; font-weight: 700;
}
.tp-step-title { margin: 0; font-size: 1.25rem; font-weight: 700; color: var(--color-text); }
.tp-from-names { margin-left: auto; font-family: var(--font-mono); font-size: 0.78rem; color: var(--color-success-solid); }
.tp-from-names::before { content: ''; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: currentColor; vertical-align: middle; }
.tp-card {
  display: flex; flex-direction: column; gap: 14px; padding: 20px;
  border: 1px solid #E4E8FF; border-radius: var(--radius-md); background: #FFFFFF; box-sizing: border-box;
}
html[data-theme="dark"] .tp-card { border-color: #373A52; background: #110E1A; }
.tp-icon { flex: none; display: inline-flex; color: inherit; }
.tp-drop {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 16px 18px;
  border: 2px dashed #8B91BC; border-radius: var(--radius-md); background: #F7F8FC;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.tp-drop > .tp-icon { width: 44px; height: 44px; align-items: center; justify-content: center; border-radius: var(--radius-md); background: #E4E8FF; color: #2A44DF; }
.tp-drop.is-dragover { border-style: solid; border-color: #2A44DF; background: #E4E8FF; }
html[data-theme="dark"] .tp-drop { background: #110E1A; border-color: #373A52; }
html[data-theme="dark"] .tp-drop > .tp-icon { background: #142287; color: #E4E8FF; }
html[data-theme="dark"] .tp-drop.is-dragover { border-color: #556DFF; }
.tp-drop-text { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tp-drop-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1rem; font-weight: 600; color: var(--color-text); }
.tp-drop-note { font-size: 0.85rem; color: var(--color-text-secondary); }
.tp-drop-note:empty { display: none; }
.tp-drop-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tp-import-link { padding: 0 2px; border: 0; background: none; font: inherit; font-weight: 500; color: var(--color-accent); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.tp-import-link:hover:not(:disabled) { color: var(--color-accent-dark); }
.tp-import-link:focus-visible { outline: none; box-shadow: var(--shadow-glow); border-radius: 6px; }
.tp-import-link:disabled { opacity: 0.5; cursor: progress; }
.tp-import-status { flex-basis: 100%; margin: 0; font-size: 0.85rem; color: var(--color-text-secondary); }
.tp-import-status.is-error { color: var(--color-error); }
.tp-small-btn { min-height: 36px; padding: 0 12px; font-size: 0.85rem; }
/* A link button with nowhere to go yet, such as Open project before a drawing is counted. */
a.btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.tp-tree-card { padding: 14px 0 0; gap: 8px; }
.tp-tree-tools { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 14px; }
.tp-search { flex: 1 1 120px; min-width: 0; }
.tp-tree-summary { margin: 0; padding: 0 14px; font-size: 0.85rem; color: var(--color-text-secondary); }
.tp-tree-summary:empty { display: none; }
.tp-tree { max-height: 62vh; overflow: auto; border-top: 1px solid #E4E8FF; padding: 4px 0; }
html[data-theme="dark"] .tp-tree { border-color: #373A52; }
.tp-empty { margin: 0; padding: 28px 18px; text-align: center; font-size: 0.9rem; line-height: 1.5; color: var(--color-text-secondary); }
.tp-row {
  display: flex; align-items: flex-start; gap: 6px; min-height: 34px; box-sizing: border-box;
  padding: 5px 12px 5px calc(6px + var(--tp-depth, 0) * 6px);
  font-size: 0.9rem; color: var(--color-text);
}
.tp-row:hover { background: #F7F8FC; }
html[data-theme="dark"] .tp-row:hover { background: #1C1A2A; }
.tp-folder-row .tp-name { font-weight: 600; }
.tp-row > .tp-icon { padding-top: 3px; }
.tp-folder-row > .tp-icon { color: #62688F; }
.tp-file-row > .tp-icon { color: #8B91BC; }
.tp-row.is-off .tp-name, .tp-row.is-empty .tp-name { color: var(--color-text-secondary); }
.tp-name { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding-top: 2px; line-height: 1.3; overflow-wrap: anywhere; }
.tp-chevron, .tp-chevron-space { flex: none; width: 20px; height: 24px; }
.tp-chevron { display: inline-flex; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: var(--radius-sm); background: none; color: var(--color-text-secondary); cursor: pointer; }
.tp-chevron:hover { background: #ECEEF8; }
html[data-theme="dark"] .tp-chevron:hover { background: #282236; }
.tp-chevron .tp-icon { transition: transform var(--transition-fast); }
.tp-chevron.is-open .tp-icon { transform: rotate(90deg); }
.tp-check { flex: none; width: 18px; height: 18px; margin: 3px 0 0; accent-color: #2A44DF; cursor: pointer; }
.tp-check:disabled { cursor: default; opacity: 0.4; }
.tp-count { flex: none; min-width: 56px; padding-top: 3px; text-align: right; font-family: var(--font-mono); font-size: 0.78rem; color: var(--color-text-secondary); }
.tp-tag { padding: 1px 8px; border-radius: 999px; background: #E4E8FF; color: #142287; font-size: 0.72rem; }
html[data-theme="dark"] .tp-tag { background: #20232F; color: #B4BDFF; }
.tp-badge { flex: none; padding: 2px 8px; border-radius: 999px; background: #E4E8FF; color: #142287; font-size: 0.72rem; }
.tp-badge.is-error { background: var(--color-error-light); color: #B91C1C; }
html[data-theme="dark"] .tp-badge { background: #20232F; color: #B4BDFF; }
/* The drawings to count are the files the sort reads first. */
/* Step 1 and 2: what the file names say, as counts. */
.tp-drop.tp-drop-large { flex-direction: column; justify-content: center; gap: 20px; padding: 44px 32px; border-radius: 14px; text-align: center; }
.tp-drop-large > .tp-icon { width: 64px; height: 64px; border-radius: 16px; transition: width 320ms, height 320ms, border-radius 320ms; }
.tp-drop-large > .tp-icon svg { width: 28px; height: 28px; }
.tp-drop-large .tp-drop-text { flex: none; align-items: center; gap: 6px; max-width: 100%; }
.tp-drop-large .tp-drop-title { font-size: 1.375rem; font-weight: 700; white-space: normal; overflow-wrap: anywhere; }
.tp-drop-large .tp-drop-note { font-size: 1rem; }
.tp-drop-large .tp-drop-actions { justify-content: center; gap: 12px; }
.tp-drop-large .tp-drop-actions .btn { justify-content: center; min-width: 170px; min-height: 44px; padding: 0 22px; font-size: 0.95rem; font-weight: 700; }
.tp-import-row { margin: 0; font-size: 1rem; color: var(--color-text-secondary); }
.tp-card.tp-found { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; padding: 18px 20px; }
@media (max-width: 760px) { .tp-card.tp-found { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* The pack card of the upload step: one row for each fact of the dropped pack. */
.tp-card.tp-facts { flex: none; display: flex; flex-direction: column; gap: 0; padding: 14px 20px 6px; }
/* After the display rules of the two cards: they beat the UA `[hidden]{display:none}` rule. */
.tp-card.tp-facts[hidden], .tp-card.tp-found[hidden] { display: none; }
.tp-facts-title { margin: 0; padding-bottom: 8px; font-size: 1rem; font-weight: 700; color: var(--color-text); }
.tp-facts-list { margin: 0; padding: 0; list-style: none; }
.tp-fact { display: flex; align-items: center; gap: 14px; padding: 9px 2px; border-top: 1px solid #E4E8FF; }
/* A row of the pack card comes in once, after the row above it. */
@keyframes tp-fact-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.tp-fact.is-entering { animation: tp-fact-in 320ms ease both; }
@media (prefers-reduced-motion: reduce) {
  .tp-fact.is-entering { animation: none; }
  .tp-drop-large > .tp-icon { transition: none; }
}
html[data-theme="dark"] .tp-fact { border-top-color: #373A52; }
.tp-fact-icon { flex: none; width: 30px; height: 30px; align-items: center; justify-content: center; border-radius: 50%; background: var(--color-bg); color: var(--color-text-secondary); }
.tp-fact.is-ok .tp-fact-icon { background: #ECFDF5; color: #047857; }
.tp-fact.is-info .tp-fact-icon { background: var(--color-accent-light); color: var(--color-accent); }
.tp-fact.is-warning .tp-fact-icon { background: #FEF3C7; color: #92400E; }
html[data-theme="dark"] .tp-fact.is-ok .tp-fact-icon { background: #0D2A20; color: #6EE7B7; }
html[data-theme="dark"] .tp-fact.is-warning .tp-fact-icon { background: #3A2A0B; color: #FCD34D; }
.tp-fact-count { flex: none; min-width: 56px; font-family: var(--font-mono); font-size: 1.3rem; font-weight: 700; text-align: right; color: var(--color-text); }
.tp-fact-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.tp-fact-label { font-size: 0.92rem; font-weight: 600; color: var(--color-text); }
.tp-fact-hint { font-size: 0.8rem; line-height: 1.4; color: var(--color-text-secondary); }
.tp-fact-files { margin: 0 0 8px 100px; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 4px; max-height: 132px; overflow-y: auto; font-size: 0.8rem; line-height: 1.4; color: var(--color-text-secondary); overflow-wrap: anywhere; }
.tp-fact-files[hidden] { display: none; }
@media (max-width: 760px) { .tp-fact-files { margin-left: 0; } }
/* The disciplines the user chose, named beside what Coil found for them. */
.tp-found-head { grid-column: 1 / -1; display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding-bottom: 12px; border-bottom: 1px solid #E4E8FF; }
html[data-theme="dark"] .tp-found-head { border-bottom-color: #373A52; }
.tp-found-label { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: var(--color-text-secondary); }
.tp-chosen { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.tp-chip { padding: 3px 11px; border: 1px solid #C9CEEB; border-radius: 999px; background: #F3F4FD; font-size: 0.82rem; font-weight: 600; white-space: nowrap; color: var(--color-text); }
html[data-theme="dark"] .tp-chip { border-color: #556DFF; background: #1E182B; }
.tp-list-chosen { min-width: 0; }
.tp-stat { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tp-stat-count { font-family: var(--font-mono); font-size: 1.6rem; font-weight: 700; color: var(--color-text); }
.tp-stat-label { font-size: 0.9rem; font-weight: 600; color: var(--color-text); }
.tp-stat-hint { font-size: 0.8rem; line-height: 1.35; color: var(--color-text-secondary); }
/* Step 2: the disciplines as cards. */
.tp-services.tp-service-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; padding: 0; border: 0; background: none; overflow: visible; }
@media (max-width: 1180px) { .tp-services.tp-service-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .tp-services.tp-service-cards { grid-template-columns: minmax(0, 1fr); } }
.tp-service-cards .tp-service { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "text check" "count count"; gap: 10px; min-height: 132px; padding: 16px; border: 1px solid #C9CEEB; border-radius: 12px; background: #FFFFFF; }
.tp-service-cards .tp-service.is-on { padding: 15px; border: 2px solid #2A44DF; background: #F3F4FD; }
html[data-theme="dark"] .tp-service-cards .tp-service { background: #110E1A; }
html[data-theme="dark"] .tp-service-cards .tp-service.is-on { background: #1E182B; }
.tp-service-cards .tp-check { grid-area: check; width: 20px; height: 20px; }
.tp-service-cards .tp-service-text { grid-area: text; gap: 6px; }
.tp-service-cards .tp-service-label { font-size: 1.05rem; font-weight: 700; }
.tp-service-cards .tp-service-count { grid-area: count; align-self: end; }
/* Step 3: the files of the pack on the left, the drawings to count on the right. */
.tp-panes { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 20px; min-height: 320px; }
@media (max-width: 1000px) { .tp-panes { grid-template-columns: minmax(0, 1fr); } }
.tp-pane { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.tp-pane-title { margin: 0; font-size: 1.05rem; font-weight: 700; color: var(--color-text); }
.tp-row[draggable="true"] { cursor: grab; }
/* A `file-tree.js` tree: rows of one height placed by index, with the open folders above the view as sticky headers. */
.ft-wrap { position: relative; display: flex; flex-direction: column; min-height: 0; }
.ft-wrap[hidden] { display: none; }
.ft-scroll { position: relative; flex: 1; min-height: 0; overflow: auto; }
.ft-scroll.tp-tree { padding: 0; }
.ft-scroll.tp-list-body { max-height: 62vh; }
.ft-sizer { position: relative; min-width: 100%; }
.ft-view { position: absolute; top: 0; left: 0; right: 0; }
.ft-row { box-sizing: border-box; height: 36px; min-height: 0; align-items: center; gap: 8px; padding: 0 12px 0 calc(8px + var(--tp-depth, 0) * 14px); white-space: nowrap; }
.ft-row > .tp-icon { padding-top: 0; }
.ft-row > .tp-name { flex-direction: row; align-items: center; gap: 8px; padding-top: 0; overflow: hidden; white-space: nowrap; }
.ft-row .tp-name-text, .ft-row > .tp-list-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ft-row > .tp-count { padding-top: 0; }
.ft-row:focus-visible { outline: none; box-shadow: inset 0 0 0 2px #2A44DF; }
.ft-row.tp-others { padding-left: calc(36px + var(--tp-depth, 0) * 14px); }
.tp-folder-count { flex: none; font-family: var(--font-mono); font-size: 0.78rem; font-weight: 400; color: var(--color-text-secondary); }
/* The sticky folders stay at the top of the scrolling tree and take no height of their own: their rows lie over the rows under them. */
.ft-sticky { position: sticky; top: 0; left: 0; z-index: 2; height: 0; }
.ft-sticky[hidden] { display: none; }
.ft-sticky-row { background-color: #FFFFFF; cursor: pointer; }
.ft-sticky-row:last-of-type { box-shadow: 0 1px 0 #C9CEEB, 0 4px 8px rgba(17, 14, 26, 0.06); }
html[data-theme="dark"] .ft-sticky-row { background-color: #110E1A; }
html[data-theme="dark"] .ft-sticky-row:last-of-type { box-shadow: 0 1px 0 #373A52; }
.ft-more { flex: none; width: 24px; height: 24px; padding: 0; border: 1px solid #C9CEEB; border-radius: 6px; background: #FFFFFF; color: var(--color-text); font: inherit; font-weight: 700; line-height: 1; cursor: pointer; }
.ft-more:focus-visible, .ft-menu-item:focus-visible { outline: none; box-shadow: var(--shadow-glow); }
.ft-menu { position: absolute; top: 34px; left: 8px; z-index: 3; display: flex; flex-direction: column; min-width: 200px; max-width: calc(100% - 16px); padding: 4px; border: 1px solid #C9CEEB; border-radius: 8px; background: #FFFFFF; box-shadow: 0 8px 24px rgba(17, 14, 26, 0.16); }
html[data-theme="dark"] .ft-more, html[data-theme="dark"] .ft-menu { border-color: #373A52; background: #1C1A2A; }
.ft-menu-item { min-height: 32px; padding: 0 10px; border: 0; border-radius: 6px; background: none; color: var(--color-text); font: inherit; font-size: 0.88rem; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.ft-menu-item:hover { background: #F3F4FD; }
html[data-theme="dark"] .ft-menu-item:hover { background: #282236; }
.tp-icon-btn { flex: none; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: 8px; background: none; color: var(--color-text-secondary); cursor: pointer; }
.tp-icon-btn:hover { background: #ECEEF8; color: var(--color-text); }
.tp-icon-btn:focus-visible, .tp-add:focus-visible { outline: none; box-shadow: var(--shadow-glow); }
html[data-theme="dark"] .tp-icon-btn:hover { background: #20232F; }
/* A file name that opens the file's preview. */
.tp-name-link { cursor: pointer; }
.tp-name-link:hover { color: var(--color-accent); text-decoration: underline; text-underline-offset: 3px; }
.tp-add { flex: none; box-sizing: border-box; width: 96px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 30px; padding: 0 10px; border: 1px solid #2A44DF; border-radius: 8px; background: #FFFFFF; color: #2A44DF; font: inherit; font-size: 0.78rem; font-weight: 700; cursor: pointer; }
.tp-add:hover { background: #F3F4FD; }
html[data-theme="dark"] .tp-add { border-color: #556DFF; background: transparent; color: #B4BDFF; }
.tp-in-list { flex: none; box-sizing: border-box; width: 96px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 30px; font-size: 0.78rem; font-weight: 600; color: var(--color-success-solid); }
.tp-pack-pane, .tp-list-pane { gap: 0; padding-top: 14px; border: 2px solid #2A44DF; border-radius: var(--radius-md); background: #FFFFFF; }
html[data-theme="dark"] .tp-pack-pane, html[data-theme="dark"] .tp-list-pane { background: #110E1A; }
/* The pack's card has no box of its own: the pane is the box, as for the list. */
.tp-pack-pane > .tp-tree-card { gap: 0; padding: 0; border: 0; border-radius: 0; }
.tp-pack-pane .tp-tree-tools { align-items: center; gap: 10px; padding: 0 16px 12px; }
/* The height of the list's buttons, so the two trees start on one line. */
.tp-pack-pane .tp-search { min-height: 36px; height: 36px; }
.tp-list-pane.is-dragover { background: #F3F4FD; }
html[data-theme="dark"] .tp-list-pane.is-dragover { background: #1E182B; }
.tp-list-head { display: flex; align-items: center; gap: 10px; padding: 0 16px 12px; border-bottom: 1px solid #E4E8FF; }
.tp-list-head .tp-count { margin-left: auto; min-width: 0; }
.tp-list-head .tp-small-btn { flex: none; }
.tp-list-pane > .tp-empty { flex: 1; }
.tp-list-pane > .ft-wrap { flex: 1; min-height: 160px; }
.tp-list-section { background: #F7F8FC; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-text-secondary); }
.tp-list-section:hover { background: #F7F8FC; }
html[data-theme="dark"] .tp-list-section, html[data-theme="dark"] .tp-list-section:hover { background: #1E182B; }
.tp-list-section .tp-folder-count { text-transform: none; letter-spacing: 0; }
/* A listed file's name takes the row's free width; when it is too long, its start is cut and its end stays whole. */
.ft-row > .tp-list-name { flex: 1 1 0; gap: 0; }
.tp-name-start { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: pre; }
.tp-name-end { flex: none; white-space: pre; }
/* A discipline under Drawings, and the folder of a listed file whose name another listed file has. */
.tp-list-subsection .tp-name { font-weight: 600; }
.tp-list-folder { flex: 0 4 auto; min-width: 0; max-width: 24%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.74rem; color: var(--color-text-secondary); }
/* The level and the revision of a listed file stand in two columns of one width, under their names on the group's row. */
.tp-list-level { flex: none; box-sizing: border-box; width: 44px; text-align: center; font-family: var(--font-mono); font-size: 0.78rem; color: var(--color-text-secondary); }
.tp-list-revision { flex: none; box-sizing: border-box; width: 52px; text-align: center; font-family: var(--font-mono); font-size: 0.78rem; color: var(--color-text-secondary); }
.tp-list-heading { font-family: inherit; font-size: inherit; }
.tp-icon-space { flex: none; width: 32px; }
.tp-revision { flex: none; padding: 2px 8px; border-radius: 999px; background: #E4E8FF; color: #142287; font-family: var(--font-mono); font-size: 0.74rem; font-weight: 700; white-space: nowrap; }
.tp-list-hint { margin: 12px 16px 14px; padding: 10px 14px; border: 1.5px dashed #8B91BC; border-radius: 10px; background: #F7F8FC; text-align: center; font-size: 0.82rem; line-height: 1.4; color: var(--color-text-secondary); }
html[data-theme="dark"] .tp-list-hint { border-color: #373A52; background: transparent; }
/* The project beside Start: its name, the other details behind a link. */
.tp-card.tp-start-bar { flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: 14px; padding: 14px 16px; }
.tp-start-project { flex: 0 1 340px; }
.tp-start-project .tp-from-names { margin-left: 10px; }
.tp-start-bar .tp-estimate-note { flex: 1 1 220px; align-self: center; text-align: right; }
.tp-start-bar .tp-cancel { min-width: 100px; }
.tp-start-bar .tp-estimate { flex: 0 1 280px; }
.tp-card.tp-more-details { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 16px; }
.tp-more-details[hidden] { display: none; }
.tp-more-details > .tp-note { grid-column: 1 / -1; }
@media (max-width: 760px) { .tp-card.tp-more-details { grid-template-columns: minmax(0, 1fr); } }
/* A dropped file in the browser's own viewer, in a window over the page. */
.modal-content-card:has(.tp-preview) { display: flex; flex-direction: column; width: min(1200px, calc(100vw - 48px)); height: calc(100vh - 64px); max-width: none; padding: 20px; }
.tp-preview { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 12px; }
.tp-preview-frame { flex: 1; min-height: 0; width: 100%; box-sizing: border-box; border: 1px solid var(--color-border); border-radius: 8px; background: #FFFFFF; }
.tp-preview-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tp-preview-note { min-width: 0; font-size: 0.82rem; line-height: 1.4; color: var(--color-text-secondary); }
/* An .xlsx workbook in the preview: a tab per sheet over a table of its values. */
.tp-sheet-tabs { flex: none; display: flex; flex-wrap: wrap; gap: 6px; }
.tp-sheet-tabs[hidden] { display: none; }
.tp-sheet-tab { padding: 6px 12px; border: 1px solid var(--color-border); border-radius: 8px; background: none; color: var(--color-text-secondary); font: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer; }
.tp-sheet-tab:hover { color: var(--color-text); }
.tp-sheet-tab.is-current { border-color: #2A44DF; background: #E4E8FF; color: #142287; }
html[data-theme="dark"] .tp-sheet-tab.is-current { background: #142287; color: #E4E8FF; }
.tp-sheet-tab:focus-visible, .tp-sheet-wrap:focus-visible { outline: none; box-shadow: var(--shadow-glow); }
.tp-sheet-wrap { flex: 1; min-height: 0; overflow: auto; border: 1px solid var(--color-border); border-radius: 8px; background: var(--color-surface, #FFFFFF); }
/* The table is as wide as its values need, a column 360px at most, and the box scrolls: a column is never squeezed until its words break. */
.tp-sheet { width: max-content; border-collapse: separate; border-spacing: 0; font-size: 0.82rem; line-height: 1.35; }
.tp-sheet th, .tp-sheet td { padding: 5px 9px; border-right: 1px solid var(--color-border); border-bottom: 1px solid var(--color-border); text-align: left; vertical-align: top; }
.tp-sheet td { min-width: 48px; max-width: 360px; white-space: pre-wrap; overflow-wrap: break-word; }
.tp-sheet th { position: sticky; background: #F1F2F7; color: var(--color-text-secondary); font-family: var(--font-mono); font-size: 0.72rem; font-weight: 400; white-space: nowrap; }
html[data-theme="dark"] .tp-sheet th { background: #1E182B; }
.tp-sheet thead th { top: 0; z-index: 2; text-align: center; }
.tp-sheet .tp-sheet-row { left: 0; z-index: 1; text-align: right; }
.tp-sheet .tp-sheet-corner { left: 0; z-index: 3; }
.tp-preview-link { font-size: 0.9rem; font-weight: 600; color: var(--color-accent); text-decoration: underline; text-underline-offset: 3px; }
.tp-others { font-size: 0.8rem; color: var(--color-text-secondary); padding-left: calc(32px + var(--tp-depth, 0) * 6px); }
.tp-details { gap: 16px; }
.tp-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tp-field-label { font-size: 0.85rem; font-weight: 600; color: var(--color-text); }
.tp-field-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tp-input {
  width: 100%; min-height: 40px; padding: 6px 12px; box-sizing: border-box;
  font: inherit; font-size: 0.95rem;
  border: 1px solid #8B91BC; border-radius: var(--radius-sm); background: #FFFFFF; color: #110E1A;
}
.tp-input:focus { outline: none; border-color: #2A44DF; box-shadow: 0 0 0 3px rgba(42, 68, 223, 0.18); }
.tp-input.is-readonly { background: #F1F2F7; color: #373A52; }
html[data-theme="dark"] .tp-input { background: #110E1A; border-color: #373A52; color: #F1F2F7; }
html[data-theme="dark"] .tp-input.is-readonly { background: #1E182B; color: #A9AECB; }
.tp-input.is-invalid,
html[data-theme="dark"] .tp-input.is-invalid { border-color: var(--color-error, #dc2626); }
.tp-input.is-invalid:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18); }
.tp-field-error { margin: 0; font-size: 0.82rem; line-height: 1.5; color: var(--color-error, #dc2626); }
.tp-details .el-client-picker .cs-trigger { min-height: 40px; padding: 6px 12px; font-size: 0.95rem; border-color: #8B91BC; background: #FFFFFF; color: #110E1A; }
.tp-details .el-client-picker .cs-trigger[aria-expanded="true"],
.tp-details .el-client-picker .cs-trigger:focus-visible { outline: none; border-color: #2A44DF; box-shadow: 0 0 0 3px rgba(42, 68, 223, 0.18); }
html[data-theme="dark"] .tp-details .el-client-picker .cs-trigger { background: #110E1A; border-color: #373A52; color: #F1F2F7; }
.tp-note { margin: 0; font-size: 0.82rem; line-height: 1.5; color: var(--color-text-secondary); }
.tp-services { gap: 10px; padding: 14px; }
.tp-service {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px;
  border: 1px solid #E4E8FF; border-radius: var(--radius-md); cursor: pointer;
}
.tp-service.is-on { border-color: #C9CEEB; background: #F3F4FD; }
html[data-theme="dark"] .tp-service { border-color: #373A52; }
html[data-theme="dark"] .tp-service.is-on { border-color: #556DFF; background: #1E182B; }
.tp-service .tp-check { margin-top: 2px; }
.tp-service-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tp-service-label { font-size: 0.98rem; font-weight: 600; color: var(--color-text); }
.tp-service-tag { margin-left: 8px; padding: 1px 7px; border-radius: 999px; font-size: 0.68rem; font-weight: 600; vertical-align: 1px; background: var(--color-accent-light); color: var(--color-accent-dark); }
.tp-service-hint { font-size: 0.85rem; color: var(--color-text-secondary); }
.tp-service-count { flex: none; font-family: var(--font-mono); font-size: 0.78rem; color: var(--color-text-secondary); }
.tp-actions { display: flex; gap: 10px; }
.tp-cancel { flex: none; min-height: 52px; min-width: 110px; justify-content: center; }
.tp-cancel:disabled { cursor: not-allowed; opacity: 0.55; }
.tp-estimate { flex: 1; min-height: 52px; font-size: 1rem; font-weight: 700; justify-content: center; }
@media (max-width: 760px) {
  .tp-actions { flex-direction: column-reverse; align-items: center; gap: 6px; }
  .tp-estimate { align-self: stretch; }
  .tp-cancel { min-height: 36px; min-width: 0; border: 0; background: none; text-decoration: underline; }
}
.tp-estimate:disabled { cursor: not-allowed; opacity: 0.55; }
.tp-estimate-note { text-align: center; }
/* A step's note with nothing to say takes no room under the buttons. */
.tp-screen > .tp-estimate-note:empty { display: none; }
.tp-estimate-note.is-error { color: #B91C1C; }
html[data-theme="dark"] .tp-estimate-note.is-error { color: #F87171; }
.tp-page.is-busy .tp-drop, .tp-page.is-busy .tp-pack-pane, .tp-page.is-busy .tp-details, .tp-page.is-busy .tp-services, .tp-page.is-busy .tp-list-pane, .tp-page.is-busy .tp-start-project,
.tp-page.is-continuing .tp-details, .tp-page.is-continuing .tp-services { pointer-events: none; opacity: 0.6; }

/* ═══════════════════════════════════════════
   SCREEN 2: DESIGN WORKSPACE
   ═══════════════════════════════════════════ */
.workspace-shell {
  --ws-left-w: 320px;
  --ws-right-w: 320px;
  display: grid;
  grid-template-columns: var(--ws-left-w) 1fr var(--ws-right-w);
  /* No dedicated row for the findings tray — it floats over the canvas (below)
     so it never resizes it. */
  grid-template-rows: 56px 1fr;
  height: 100vh;
  background: var(--color-bg);
}
.workspace-shell .top-bar { grid-column: 1 / -1; grid-row: 1; }

/* Pin the panes to their grid tracks — collapsing a sidebar removes it from
   the grid, and auto-placement would otherwise slide the canvas into the
   zero-width track. */
.workspace-shell .ws-sidebar { grid-column: 1; grid-row: 2; }
.workspace-shell .ws-canvas { grid-column: 2; grid-row: 2; }
.workspace-shell .ws-right { grid-column: 3; grid-row: 2; }

/* Collapsible side panels — panel-collapse.js toggles these classes. */
.workspace-shell.ws-left-collapsed { --ws-left-w: 0px; }
.workspace-shell.ws-left-collapsed .ws-sidebar { display: none; }
.workspace-shell.ws-right-collapsed { --ws-right-w: 0px; }
.workspace-shell.ws-right-collapsed .ws-right { display: none; }

/* Collapse handles — slim tabs hugging the canvas edges. */
.ws-panel-toggle {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 22px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  z-index: 6;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.ws-panel-toggle:hover { background: var(--color-surface-alt); color: var(--color-text); }
.ws-panel-toggle svg {
  width: 14px; height: 14px;
  stroke: currentColor; fill: none; stroke-width: 2;
  transition: transform var(--transition-fast);
}
.ws-panel-toggle-left { left: 0; border-left: none; border-radius: 0 var(--radius-md) var(--radius-md) 0; }
.ws-panel-toggle-right { right: 0; border-right: none; border-radius: var(--radius-md) 0 0 var(--radius-md); }
.ws-left-collapsed .ws-panel-toggle-left svg { transform: rotate(180deg); }
.ws-right-collapsed .ws-panel-toggle-right svg { transform: rotate(180deg); }

/* Workspace sidebar */
.ws-sidebar {
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  padding: 0;
}

.ws-sidebar-section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition-fast);
}
.ws-sidebar-section-header:hover { background: var(--color-surface-alt); }

/* Canvas */
.ws-canvas {
  /* Light theme default = white issue-ready sheet surround. The dark theme
     (below) switches to a neutral charcoal close to AutoCAD's model space. */
  background: #F0F4F8;
  --canvas-select: #0891B2;     /* selection accent on the white sheet */
  position: relative;
  overflow: hidden;
  cursor: grab;
  transition: background var(--transition-base);
}
html[data-theme="dark"] .ws-canvas {
  background: #262A30;
  --canvas-select: #22D3EE;     /* brighter cyan so #116 selection reads on dark */
}

.ws-canvas:active { cursor: grabbing; }

/* ── Layers panel (E2 binding, #253) ──
   Left-docked, collapsible card floating over the canvas (a chrome sibling of
   the SVG mount, positioned against .ws-canvas). Mirrors the drawing's real
   container hierarchy — floor → discipline layer → element-kind category
   rows — using the existing surface/border/shadow tokens so it themes for
   light & dark automatically and reads as a sibling of the canvas toolbar and
   side panels. */
.layers-panel {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 6;
  width: 232px;
  max-height: calc(100% - 24px);
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-family: var(--font-body);
  overflow: hidden;
}

.layers-panel.collapsed .layers-panel-body { display: none; }
.layers-panel-body {
  overflow-y: auto;
  padding: 4px 0 6px;
}

/* Collapsible floor / discipline-layer groups. */
.lp-group-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition-fast);
}
.lp-group-header:hover { background: var(--color-surface-alt); }
#layers-panel .lp-chevron {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  color: var(--color-text-muted);
  transition: transform var(--transition-fast);
}
.lp-collapsed > .lp-group-header .lp-chevron { transform: rotate(-90deg); }
.lp-collapsed > .lp-group-body { display: none; }
#layers-panel .lp-group-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--color-text-muted);
}
.lp-group-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lp-floor > .lp-group-header .lp-group-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
}
.lp-layer > .lp-group-header .lp-group-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--color-text);
}
/* Indent the discipline layer under the floor. */
.lp-floor > .lp-group-body { padding-left: 10px; }

/* Sublayer rows: swatch + name + eye toggle. */
.lp-sublayer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 22px;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  transition: background var(--transition-fast);
}
.lp-sublayer:hover { background: var(--color-surface-alt); }
.lp-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
  border: 1px solid rgba(15, 23, 42, 0.18);
}
html[data-theme="dark"] .lp-swatch { border-color: rgba(255, 255, 255, 0.22); }

.lp-sublayer-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lp-eye {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  flex-shrink: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.lp-eye:hover { background: var(--color-surface-hover); color: var(--color-text); }
#layers-panel .lp-eye svg { width: 15px; height: 15px; }
/* Show the open eye when visible, the struck-through eye when hidden. All rules
   are #layers-panel-scoped so they outrank the `#layers-panel .lp-eye svg`
   sizing rule above (equal-ID specificity, so the more specific class chain
   below wins) and the drawing's `.ws-canvas svg` rule. */
#layers-panel .lp-eye .lp-eye-on { display: block; }
#layers-panel .lp-eye .lp-eye-off { display: none; }
/* aria-pressed=false ⇒ the group is hidden: swap to the struck-through eye and
   dim the whole row so the off state reads at a glance. */
.lp-eye[aria-pressed="false"] { opacity: 0.6; }
#layers-panel .lp-eye[aria-pressed="false"] .lp-eye-on { display: none; }
#layers-panel .lp-eye[aria-pressed="false"] .lp-eye-off { display: block; }
.lp-sublayer.lp-hidden .lp-swatch { opacity: 0.4; }
.lp-sublayer.lp-hidden .lp-sublayer-name { color: var(--color-text-muted); }

/* Light / Dark / System theme toggle on the login and setup pages, which have no account menu. */
.theme-toggle {
  display: inline-flex;
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 2px;
  gap: 2px;
}
.theme-toggle button {
  font: inherit;
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 24px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.theme-toggle button:hover { color: var(--color-text-secondary); }
.theme-toggle button.on {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-sm);
}
.theme-toggle button svg { width: 14px; height: 14px; }
.ws-canvas svg {
  width: 100%; height: 100%;
}

/* Right panel */
.ws-right {
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  overflow-y: auto;
  display: flex; flex-direction: column;
}
.ws-right[hidden] { display: none; }

.ws-right-pane { display: flex; flex-direction: column; gap: 20px; }
.ws-right-pane[hidden] { display: none; }

/* Details section */
.ws-details-section {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

/* ═══════════════════════════════════════════
   FORMS AND PROJECT DIALOGS
   ═══════════════════════════════════════════ */

/* Form fields of the electrical forms and of the Project settings dialog,
 * which the Projects page opens too (#1531). */
.el-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 0 10px;
  font-size: 0.8rem;
}
.el-field-label {
  color: var(--color-text-secondary);
  font-weight: 600;
}
.el-field input,
.el-field select {
  font: inherit;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
}
/* The card of the Add files dialog, and the base of Project settings (left-panel.js). */
.modal-content-card:has(.el-project-dialog) { position: relative; width: min(480px, calc(100vw - 32px)); height: auto; max-height: 92vh; padding: 24px 26px; overflow-y: auto; }
.el-project-dialog-head { display: flex; flex-direction: column; gap: 4px; margin: 0 0 16px; padding-right: 32px; }
.el-project-dialog-eyebrow { font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: #373A52; }
html[data-theme="dark"] .el-project-dialog-eyebrow { color: #8B91BC; }
.el-project-dialog .modal-close { color: #373A52; }
.el-project-dialog .modal-close:hover { background: #F1F2F7; color: #110E1A; }
html[data-theme="dark"] .el-project-dialog .modal-close { color: #8B91BC; }
html[data-theme="dark"] .el-project-dialog .modal-close:hover { background: #373A52; color: #F1F2F7; }
.el-project-dialog-title { margin: 0; font-size: 22px; font-weight: 700; line-height: 1.2; color: var(--color-text); }
.el-project-form { display: flex; flex-direction: column; }
.el-project-dialog .el-field { margin-bottom: 8px; }
.el-client-picker { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.el-client-new[hidden] { display: none; }
.el-field-error { margin: -4px 0 10px; font-size: 0.8rem; color: #B91C1C; }
html[data-theme="dark"] .el-field-error { color: #F87171; }
.el-field-error[hidden] { display: none; }
/* A field the drawings say otherwise: their value, Use and Keep mine. */
.el-field-check {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  margin: -4px 0 12px; padding: 8px 10px;
  border: 1px dashed #2A44DF; border-radius: var(--radius-sm);
  background: #F1F2F7;
}
html[data-theme="dark"] .el-field-check { border-color: #556DFF; background: #20232F; }
.el-field-check-text { margin: 0; font-size: 0.8rem; font-weight: 600; color: #142287; }
html[data-theme="dark"] .el-field-check-text { color: #E4E8FF; }
.el-field-check-actions { display: flex; gap: 6px; }
.el-field-check[hidden] { display: none; }
.el-project-dialog .el-field input { min-height: 32px; padding: 4px 10px; font-size: 0.85rem; background: #FFFFFF; border-color: #8B91BC; color: #110E1A; }
.el-project-dialog .el-field input:focus { border-color: #2A44DF; box-shadow: 0 0 0 3px rgba(42, 68, 223, 0.18); }
html[data-theme="dark"] .el-project-dialog .el-field input { background: #110E1A; border-color: #373A52; color: #F1F2F7; }
html[data-theme="dark"] .el-project-dialog .el-field input:focus { border-color: #556DFF; box-shadow: 0 0 0 3px rgba(85, 109, 255, 0.25); }
.el-project-dialog .el-field-label { color: #373A52; }
html[data-theme="dark"] .el-project-dialog .el-field-label { color: #E4E8FF; }
.el-project-dialog .btn-secondary { border-color: #8B91BC; }
.el-project-dialog .btn-secondary:hover { background: #F1F2F7; border-color: #8B91BC; }
html[data-theme="dark"] .el-project-dialog .btn-secondary { background: #1E182B; border-color: #373A52; color: #F1F2F7; }
html[data-theme="dark"] .el-project-dialog .btn-secondary:hover { background: #373A52; border-color: #8B91BC; }
.el-project-dialog .btn-primary:disabled { opacity: 1; background: #E4E8FF; color: #8B91BC; }
html[data-theme="dark"] .el-project-dialog .btn-primary:disabled { background: #373A52; }
.el-project-form-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.el-project-form-buttons .btn { width: 100%; justify-content: center; min-height: 36px; }
/* Project settings tabs: Details and Drawing package (imported projects). */
/* Project settings: a fixed head, a body that alone scrolls, and a footer pinned to the bottom. */
.modal-content-card:has(.el-project-dialog.is-settings) { display: flex; flex-direction: column; width: min(560px, calc(100vw - 32px)); height: auto; max-height: calc(100vh - 80px); padding: 0; overflow: hidden; }
.modal-content-card:has(.el-project-dialog.is-tabbed) { height: min(720px, calc(100vh - 80px)); }
.el-project-dialog.is-settings { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.el-project-dialog.is-settings .el-project-dialog-head { flex: none; margin: 0; padding: 24px 60px 14px 28px; }
.el-project-dialog.is-settings .el-project-dialog-title { font-size: 24px; }
.el-project-dialog.is-settings .el-project-tabs { flex: none; margin: 0; padding: 0 28px; }
.el-project-dialog.is-settings > .el-project-form,
.el-project-dialog.is-settings > .el-project-panel { flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; padding: 22px 28px 24px; }
.el-project-dialog.is-settings > .el-project-package { margin: 0; padding: 20px 28px 24px; }
.el-project-dialog-foot { flex: none; display: flex; align-items: center; gap: 12px; padding: 16px 28px; border-top: 1px solid #E4E8FF; background: var(--color-surface); }
html[data-theme="dark"] .el-project-dialog-foot { border-top-color: #373A52; }
.el-project-dialog-foot[hidden] { display: none; }
.el-project-dialog-foot .el-project-form-buttons { display: flex; gap: 12px; margin: 0 0 0 auto; }
.el-project-dialog-foot .el-project-form-buttons .btn { width: auto; min-width: 120px; min-height: 44px; padding: 0 22px; font-size: 15px; border-radius: 6px; }
.el-project-export { display: flex; min-width: 0; }
.el-project-export-button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 8px;
  border: 0; border-radius: 6px; background: none; font: inherit; font-size: 14px; font-weight: 500;
  color: #2A44DF; cursor: pointer;
}
.el-project-export-button:hover:not(:disabled) { text-decoration: underline; }
.el-project-export-button:focus-visible { outline: 2px solid #2A44DF; outline-offset: 2px; }
.el-project-export-button:disabled { color: #8B91BC; cursor: not-allowed; }
html[data-theme="dark"] .el-project-export-button { color: #8F9CFF; }
html[data-theme="dark"] .el-project-export-button:disabled { color: #4F5063; }
.el-field-group-title { margin: 22px 0 12px; font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.06em; text-transform: uppercase; color: #373A52; }
.el-field-group-title:first-child { margin-top: 0; }
html[data-theme="dark"] .el-field-group-title { color: #8B91BC; }
.el-field-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px 14px; }
.el-field-grid > .el-field { margin: 0; gap: 6px; min-width: 0; }
.el-field-grid > .span-6 { grid-column: span 6; }
.el-field-grid > .span-4 { grid-column: span 4; }
.el-field-grid > .span-3 { grid-column: span 3; }
.el-field-grid > .span-2 { grid-column: span 2; }
.el-field-grid > .el-field-check { grid-column: 1 / -1; margin: -8px 0 0; }
.el-field-grid .el-field > .el-field-error { margin: 0; }
@media (max-width: 480px) {
  .el-field-grid { grid-template-columns: minmax(0, 1fr); }
  .el-field-grid > [class*="span-"] { grid-column: 1 / -1; }
}
.el-project-dialog.is-settings .el-field-label { font-size: 14px; }
.el-project-dialog.is-settings .el-field input { box-sizing: border-box; width: 100%; height: 40px; min-height: 40px; padding: 0 12px; font-size: 15px; border-radius: 6px; }
.el-project-dialog.is-settings .el-field input.is-mono { font-family: var(--font-mono); font-size: 14px; }
/* As wide as Chrome's date picker, so the calendar lines up under the field. */
.el-project-dialog.is-settings .el-field input[type="date"] { width: 220px; max-width: 100%; }
.el-project-dialog.is-settings .el-field .cs-wrap { display: block; width: 100%; }
.el-project-dialog.is-settings .el-field .cs-trigger { box-sizing: border-box; height: 40px; padding: 0 12px; font-size: 15px; border-color: #8B91BC; border-radius: 6px; }
html[data-theme="dark"] .el-project-dialog.is-settings .el-field .cs-trigger { border-color: #373A52; }
.el-project-dialog.is-tabbed .el-pkg-table { flex: 1; min-height: 0; }
.el-project-dialog.is-tabbed .el-pkg-tree { flex: 1; min-height: 0; max-height: none; }
.el-project-tabs { display: flex; gap: 22px; margin: 0 -26px 18px; padding: 0 26px; border-bottom: 1px solid #E4E8FF; }
.el-project-tab { padding: 10px 0 12px; border: 0; background: none; font: inherit; font-size: 14px; font-weight: 600; color: #373A52; cursor: pointer; }
.el-project-tab:hover { color: #110E1A; }
.el-project-tab.is-selected { color: #110E1A; box-shadow: inset 0 -3px 0 #2A44DF; }
.el-project-tab:focus-visible { outline: 2px solid #2A44DF; outline-offset: 2px; border-radius: 4px; }
.el-project-panel[hidden] { display: none; }
html[data-theme="dark"] .el-project-tabs { border-bottom-color: #373A52; }
html[data-theme="dark"] .el-project-tab { color: #E4E8FF; }
html[data-theme="dark"] .el-project-tab:hover, html[data-theme="dark"] .el-project-tab.is-selected { color: #F1F2F7; }
html[data-theme="dark"] .el-project-tab.is-selected { box-shadow: inset 0 -3px 0 #556DFF; }
html[data-theme="dark"] .el-project-tab:focus-visible { outline-color: #556DFF; }
/* The Drawing package tab: summary, search, then the folder tree, which scrolls. */
.el-project-package { display: flex; flex-direction: column; gap: 14px; margin: -18px -26px -24px; padding: 20px 26px 24px; background: #F1F2F7; }
.el-project-package[hidden] { display: none; }
html[data-theme="dark"] .el-project-package { background: #110E1A; }
.el-pkg-summary { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid #E4E8FF; border-radius: 12px; background: #FFFFFF; }
.el-pkg-summary-text { flex: 1; min-width: 0; }
.el-pkg-name { margin: 0; font-size: 14px; font-weight: 700; color: #110E1A; overflow-wrap: anywhere; }
.el-pkg-line { margin: 3px 0 0; font-size: 12px; color: #373A52; }
.el-pkg-kept { font-weight: 700; color: #110E1A; }
.el-pkg-details { flex: none; }
.el-pkg-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.el-pkg-search-wrap { flex: 0 1 320px; min-width: 200px; height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border: 1px solid #E4E8FF; border-radius: 8px; background: #FFFFFF; }
.el-pkg-search-wrap:focus-within { border-color: #2A44DF; box-shadow: 0 0 0 3px rgba(42, 68, 223, 0.18); }
.el-pkg-search-icon { flex: none; display: inline-flex; width: 15px; height: 15px; color: #8B91BC; }
.el-pkg-search-icon svg { width: 15px; height: 15px; }
.el-project-dialog .el-pkg-search { flex: 1; min-width: 0; min-height: 0; height: 100%; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; outline: none; font: inherit; font-size: 13px; color: #110E1A; }
.el-project-dialog .el-pkg-search::placeholder { color: #373A52; opacity: 1; }
.el-pkg-table { display: flex; flex-direction: column; min-height: 0; padding: 0 4px 6px; border: 1px solid #E4E8FF; border-radius: 12px; background: #FFFFFF; }
.el-pkg-head { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px 0 12px; border-bottom: 1px solid #E4E8FF; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: #373A52; }
.el-pkg-col-file { flex: 1; min-width: 0; }
.el-pkg-tree { max-height: min(46vh, 440px); margin: 0; padding: 0; overflow-y: auto; list-style: none; }
.el-pkg-folder, .el-pkg-folder-list { margin: 0; padding: 0; list-style: none; }
.el-pkg-folder-row { width: 100%; height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 10px 0 calc(12px + var(--el-depth, 0) * 18px); border: 0; border-radius: 6px; background: none; font: inherit; font-size: 13px; font-weight: 600; color: #110E1A; text-align: left; cursor: pointer; }
.el-pkg-folder-row.is-root { font-weight: 700; }
.el-pkg-folder-row:hover { background: #F1F2F7; }
.el-pkg-folder-row:focus-visible { outline: 2px solid #2A44DF; outline-offset: -2px; }
.el-pkg-folder-row .el-level-chevron { color: #373A52; }
.el-pkg-folder-row[aria-expanded="true"] .el-level-chevron { transform: rotate(90deg); }
.el-pkg-folder-icon { flex: none; display: inline-flex; width: 15px; height: 15px; color: #373A52; }
.el-pkg-folder-icon svg { width: 15px; height: 15px; }
.el-pkg-folder-name { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.el-pkg-folder-count { flex: none; font-size: 12px; font-weight: 400; color: #373A52; font-variant-numeric: tabular-nums; }
.el-pkg-file { min-height: 36px; display: flex; align-items: center; gap: 8px; padding: 0 10px 0 calc(22px + var(--el-depth, 0) * 18px); border-radius: 6px; font-size: 12px; color: #110E1A; }
.el-pkg-file-name { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.el-pkg-empty { margin: 0; padding: 14px 12px; font-size: 13px; color: #373A52; }
.el-pkg-empty[hidden] { display: none; }
html[data-theme="dark"] .el-pkg-summary, html[data-theme="dark"] .el-pkg-table, html[data-theme="dark"] .el-pkg-search-wrap { border-color: #373A52; background: #1E182B; }
html[data-theme="dark"] .el-pkg-search-wrap:focus-within { border-color: #556DFF; box-shadow: 0 0 0 3px rgba(85, 109, 255, 0.25); }
html[data-theme="dark"] .el-pkg-name, html[data-theme="dark"] .el-pkg-kept, html[data-theme="dark"] .el-pkg-folder-row, html[data-theme="dark"] .el-pkg-file,
html[data-theme="dark"] .el-project-dialog .el-pkg-search { color: #F1F2F7; }
html[data-theme="dark"] .el-pkg-line, html[data-theme="dark"] .el-pkg-head, html[data-theme="dark"] .el-pkg-folder-count,
html[data-theme="dark"] .el-pkg-empty,
html[data-theme="dark"] .el-project-dialog .el-pkg-search::placeholder, html[data-theme="dark"] .el-pkg-folder-icon, html[data-theme="dark"] .el-pkg-folder-row .el-level-chevron { color: #E4E8FF; }
html[data-theme="dark"] .el-pkg-head { border-bottom-color: #373A52; }
html[data-theme="dark"] .el-pkg-folder-row:hover { background: #2A2340; }
html[data-theme="dark"] .el-pkg-folder-row:focus-visible { outline-color: #556DFF; }

/* ═══════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════ */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Checkbox row */
.check-row { display: flex; align-items: center; gap: 10px; }
.check-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--color-accent); }
.check-row label { font-size: 0.9rem; color: var(--color-text); cursor: pointer; }

input.is-invalid,
select.is-invalid {
    border-color: var(--color-error, #dc2626);
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.13);
}
.check-row.is-invalid {
    color: var(--color-error, #dc2626);
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.13);
    border-radius: var(--radius-sm, 4px);
}

/* ═════════════════════════════════════════════════════════════════════
   CANVAS TOOLBAR
   ═════════════════════════════════════════════════════════════════════ */

.canvas-toolbar {
    position: absolute;
    top: 56px; left: 50%;
    transform: translateX(-50%);
    display: flex; align-items: center; gap: 1px;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: 4px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--color-border);
    z-index: 5;
    font-family: var(--font-body);
    /* On narrow windows: wrap onto additional rows (groups stay intact) and
       keep the strip centred, rather than scrolling a single overflowing row. */
    max-width: calc(100% - 56px);
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 4px;
}
/* Docked: the bar merges into the workspace top bar as a normal flex child,
   centred between the breadcrumb and the right-hand controls. It sheds the
   floating pill's chrome (shadow/border/background) to blend into the header,
   and never wraps — it shares the fixed-height top-bar row. */
.canvas-toolbar.canvas-toolbar--docked {
    position: static;
    transform: none;
    margin: 0;
    max-width: none;
    flex-wrap: nowrap;
    flex-shrink: 0;
    min-width: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.canvas-toolbar .ct-group { display: flex; align-items: center; gap: 1px; padding: 0 1px; flex-shrink: 0; }
.canvas-toolbar .ct-sep { width: 1px; height: 20px; background: var(--color-border); margin: 0 2px; flex-shrink: 0; }
.canvas-toolbar .ct-btn {
    padding: 6px 7px;
    border-radius: 4px;
    border: none;
    background: transparent;
    color: var(--color-text-secondary, #475569);
    cursor: pointer;
    font-size: 0.82rem;
    font-family: inherit;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}
/* Icon buttons: square, centred glyph. */
.canvas-toolbar .ct-icon { display: inline-flex; align-items: center; justify-content: center; padding: 7px; }
.canvas-toolbar .ct-icon svg { width: 18px; height: 18px; display: block; }

.canvas-toolbar .ct-btn:not(:disabled):hover { background: var(--color-surface-alt, #f1f5f9); color: var(--color-text); }
.canvas-toolbar .ct-btn.is-active { background: var(--color-accent-fill); color: #fff; }
/* Add-tools tinted in the accent so "create" reads at a glance (but not when active). */
.canvas-toolbar .ct-btn--add:not(.is-active) { color: var(--color-accent); }
/* Keep disabled tools hoverable so their tooltip still shows. */
.canvas-toolbar .ct-btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: auto; }

/* Hover tooltip for any toolbar control carrying `data-tip`. */
.canvas-toolbar [data-tip] { position: relative; }
.canvas-toolbar [data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
    background: var(--color-text, #0F172A); color: var(--color-surface, #fff);
    font-family: var(--font-body); font-size: 0.72rem; font-weight: 500;
    white-space: nowrap; padding: 5px 9px; border-radius: 6px;
    box-shadow: var(--shadow-md); z-index: 20; pointer-events: none;
}
.canvas-toolbar [data-tip]:hover::before {
    content: ""; position: absolute; top: calc(100% + 3px); left: 50%; transform: translateX(-50%);
    border: 5px solid transparent; border-bottom-color: var(--color-text, #0F172A); z-index: 20; pointer-events: none;
}

@keyframes ki-spinner { to { transform: rotate(360deg); } }

/* Toast stack (global, bottom-right). */
.toast-host {
    position: fixed;
    bottom: 24px; right: 24px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 1000;
    pointer-events: none;
}
.toast {
    min-width: 220px; max-width: 360px;
    padding: 10px 14px;
    background: #1e293b;
    color: #fff;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    font-size: 0.85rem;
    pointer-events: auto;
    animation: toast-in 180ms ease-out;
}
.toast--error { background: #b91c1c; }
.toast--dismissing { animation: toast-out 240ms ease-in forwards; }
@keyframes toast-in {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
    to { opacity: 0; transform: translateX(20px); }
}

/* Selected mark on the drawing canvas; electrical.css refines its halos. */
.is-selected { stroke: var(--canvas-select, #0891b2) !important; stroke-width: 3 !important; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.82rem;
  color: var(--color-text);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.chip:hover { background: var(--color-surface-alt); }
.chip.warn { border-color: var(--color-warning); color: #92400E; background: var(--color-warning-light); }
/* ═══════════════════════════════════════════════════════════════════════
   CUSTOM SELECT — replaces native <select> so it matches light theme and
   app aesthetic regardless of OS dark-mode. (see custom-select.js)
   ═══════════════════════════════════════════════════════════════════════ */
.cs-wrap { position: relative; display: inline-block; }
.cs-wrap select.cs-native { position: absolute; inset: 0; opacity: 0; pointer-events: none; width: 100%; height: 100%; }
.cs-trigger {
  font: inherit; font-size: 0.82rem;
  display: inline-flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 4px 8px 4px 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  cursor: pointer;
  min-width: 100px; width: 100%;
  text-align: left;
}
.cs-trigger:hover { border-color: var(--color-border-strong); }
.cs-trigger:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 1px; }
.cs-trigger[aria-expanded="true"] { border-color: var(--color-accent); }
.cs-trigger .cs-caret { width: 10px; height: 10px; flex: 0 0 10px; opacity: 0.6; }
.cs-trigger:disabled { opacity: 0.55; cursor: not-allowed; }
.cs-trigger:disabled:hover { border-color: var(--color-border); }
.cs-menu, .user-menu-panel {
  position: absolute; top: calc(100% + 4px);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 4px;
  z-index: 90;
}
.cs-menu {
  left: 0; right: 0;
  max-height: 240px; overflow-y: auto;
  list-style: none; margin: 0;
}
.cs-menu[hidden] { display: none; }
.cs-menu:focus { outline: none; }
.cs-opt {
  padding: 6px 10px; border-radius: var(--radius-sm); cursor: pointer; font-size: 0.82rem;
  color: var(--color-text);
}
.cs-opt:hover, .cs-opt.is-active { background: var(--color-surface-alt); }
.cs-opt.is-selected { font-weight: 600; color: var(--color-accent); }
.cs-opt.is-disabled { opacity: 0.4; cursor: not-allowed; }
.cs-opt.is-disabled:hover { background: transparent; }
.cs-group {
  padding: 6px 10px 2px; font-size: 0.72rem; font-weight: 600;
  color: var(--color-text-muted); cursor: default; user-select: none;
}
.cs-opt + .cs-group { margin-top: 4px; border-top: 1px solid var(--color-border); }
.cs-search {
  position: sticky; top: -4px; z-index: 1;
  margin: -4px -4px 4px; padding: 6px;
  background: var(--color-surface); border-bottom: 1px solid var(--color-border);
}
.cs-search-input {
  box-sizing: border-box; width: 100%;
  font: inherit; font-size: 0.82rem; padding: 5px 8px;
  background: var(--color-surface); color: var(--color-text);
  border: 1px solid var(--color-border); border-radius: var(--radius-sm);
}
.cs-search-input:focus { outline: 2px solid var(--color-accent); outline-offset: -1px; }
.cs-header { padding: 4px 10px; font-size: 0.72rem; color: var(--color-text-muted); }
.cs-opt:has(.cs-opt-label) { display: flex; align-items: center; gap: 8px; }
.cs-opt-label { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.cs-opt-label mark { background: var(--color-warning-light); color: inherit; border-radius: 2px; }
.cs-detail { flex: 0 0 auto; margin-left: auto; font-size: 0.75rem; font-weight: 400; color: var(--color-text-muted); }
.cs-swatch { flex: 0 0 10px; width: 10px; height: 10px; border-radius: 50%; }
.cs-count, .cs-hint { padding: 4px 10px 0; font-size: 0.72rem; color: var(--color-text-muted); cursor: default; }
.cs-count { margin-top: 4px; border-top: 1px solid var(--color-border); }
/* --shadow-md barely shows on the dark surface; the open menu needs a stronger edge. */
html[data-theme="dark"] .cs-menu,
html[data-theme="dark"] .user-menu-panel { border-color: var(--color-border-strong); box-shadow: 0 4px 16px rgba(0,0,0,.45); }
.user-menu-avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--color-accent-fill); color: #fff;
  font-size: 0.78rem; font-weight: 600; line-height: 1;
}
.user-menu-avatar-large { width: 38px; height: 38px; font-size: 1rem; }
.user-menu-panel { right: 0; min-width: 200px; max-width: min(280px, calc(100vw - 32px)); }
.user-menu-panel[hidden] { display: none; }
.user-menu-who { display: flex; align-items: center; gap: 12px; padding: 8px 8px 10px; font-size: 0.82rem; }
.user-menu-details { min-width: 0; flex: 1 1 auto; }
.user-menu-name { color: var(--color-text); font-weight: 700; overflow-wrap: anywhere; }
.user-menu-email { margin-top: 2px; color: var(--color-text-muted); overflow-wrap: anywhere; }
.user-menu-divider { height: 1px; margin: 4px 0; background: var(--color-border); }
.user-menu-item {
  display: block; width: 100%;
  padding: 6px 10px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--color-text);
  font: inherit; font-size: 0.82rem; text-align: left; cursor: pointer;
}
.user-menu-item:hover, .user-menu-item:focus-visible { background: var(--color-surface-alt); outline: none; }
.user-menu-action { display: flex; align-items: center; gap: 10px; padding: 8px; }
.user-menu-icon { display: inline-flex; flex: 0 0 auto; color: var(--color-text-secondary); }
.user-menu-icon svg { width: 16px; height: 16px; }

/* ═══════════════════════════════════════════════════════════════════════
   BREADCRUMB
   ═══════════════════════════════════════════════════════════════════════ */
.bc-crumbs { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; flex-wrap: nowrap; min-width: 0; overflow: hidden; }
.bc-crumbs > * { flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════════════════
   LEFT RAIL
   ═══════════════════════════════════════════════════════════════════════ */
#workspace-left-rail { overflow-y: auto; background: var(--color-surface); border-right: 1px solid var(--color-border); }
#workspace-left-rail > section { border-bottom: 1px solid var(--color-border); padding: 12px 14px; }

/* Run dialogs and the package Details dialog, shown on the project page and
 * from the Projects list. The Re-estimate/Add dialog reuses the content modal
 * at dialog size, not the original-sheet viewer's full-screen frame. */
.el-run-kept { margin: 0 0 16px; color: var(--color-text-secondary); font-size: 0.85rem; overflow-wrap: anywhere; }
.modal-content-card:has(.el-run-dialog) {
  width: min(480px, calc(100vw - 32px));
  height: auto;
  max-height: 92vh;
  overflow-y: auto;
}
.modal-content-card:has(.el-package-dialog) { width: min(760px, calc(100vw - 32px)); }
.el-package-heading { margin: 0 0 8px; font-size: 0.85rem; font-weight: 600; color: var(--color-text); }
.el-package-scroll { max-height: 40vh; overflow: auto; margin: 0 0 12px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); }
.el-package-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; color: var(--color-text); }
.el-package-table th { position: sticky; top: 0; background: var(--color-surface-alt); color: var(--color-text-secondary); font-weight: 600; text-align: left; }
.el-package-table th, .el-package-table td { padding: 5px 8px; border-bottom: 1px solid var(--color-border); overflow-wrap: anywhere; }
.el-package-skipped { margin: 0 0 12px; }
.el-package-skipped > summary { margin-bottom: 8px; color: var(--color-text); font-size: 0.85rem; font-weight: 600; cursor: pointer; }
