:root {
  /* Tell the browser this is a light UI so native controls (inputs, selects
     and their option popups, date pickers, scrollbars) render with a legible
     light palette. Flipped to dark below so their text never disappears. */
  color-scheme: light;

  --accent: #3652DD;
  --accent-hover: #2B44BE;
  --accent-light: #E7EAFB;
  --accent-soft: #C6CEF5;
  --green: #1F8A5B;
  --green-light: #E3F3EA;
  --orange: #B4720A;
  --orange-light: #FBEDD8;
  --red: #C4432E;
  --red-light: #FBE6E1;
  --blue: #2E93B8;
  --blue-hover: #21789A;

  /* ── Action8 redesign tokens (design_handoff_priceassist_redesign) ──
     Mode-adaptive values the "action8" catalog theme points at via var()
     indirection, so the injected theme flips correctly with the light/dark
     toggle instead of freezing on its light palette. */
  --a8-canvas: linear-gradient(180deg, #F3F1EC 0%, #F3F1EC 100%);
  --a8-surface-rgb: 255, 255, 255;
  --a8-accent: #3652DD;
  --a8-accent-hover: #2B44BE;
  --a8-on-accent: #FFFFFF;
  --a8-border: #E2DFD6;
  --a8-sidebar: rgba(28, 30, 52, .88);
  --surface-alt: #EDEBE4;

  --sidebar-bg: #4338CA;
  --sidebar-secondary-bg: #4C46D6;
  --sidebar-grad-top: #5A52E8;
  --sidebar-grad-bottom: #4338CA;
  --sidebar-rail-width: 72px;
  --sidebar-expanded-width: 264px;
  --sidebar-glass-bg: rgba(30, 45, 75, .78);
  --sidebar-glass-border: rgba(255, 255, 255, .08);
  --sidebar-glass-shadow: 0 8px 32px rgba(0, 0, 0, .18);
  --sidebar-glass-blur: 24px;
  --sidebar-item-radius: 16px;
  --sidebar-item-height: 56px;
  --topbar-h: 68px;

  /* Top navbar glassmorphism — dark frosted glass, identical in light &
     dark so the bar reads the same over any theme/background image. */
  --topbar-glass-bg: rgba(20, 24, 32, .45);
  --topbar-glass-border: rgba(255, 255, 255, .08);
  --topbar-glass-blur: 20px;

  --ink: #211F1B;
  --ink-soft: #5B584F;
  --muted: #8C8879;
  --faint: #CFCBBE;

  --surface: #ffffff;
  --bg: #F3F1EC;
  --border: #E2DFD6;
  --border-soft: #EDEBE4;

  /* Semantic text colours for status labels shown directly on a page surface
     (no coloured pill behind them). The light values below stay legible on
     dark surfaces via the dark-theme overrides, so status text never fades. */
  --ink-success: #1F8A5B;
  --ink-danger: #C4432E;
  --ink-warning: #B4720A;
  --ink-neutral: #5B584F;

  --radius-sm: 10px;
  --radius: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(30, 28, 20, .05);
  --shadow: 0 1px 2px rgba(30, 28, 20, .05), 0 6px 16px rgba(30, 28, 20, .05);
  --shadow-md: 0 8px 24px rgba(30, 28, 20, .10);
  --shadow-lg: 0 12px 32px rgba(30, 28, 20, .16);

  /* ── Premium theme system — admin-configurable via Theme Settings, applied
     live by static/theme.js. Everything below can be overridden at runtime
     with document.documentElement.style.setProperty(). ── */
  --theme-primary: var(--accent);
  --theme-primary-hover: var(--accent-hover);
  --theme-primary-active: var(--accent-hover);
  --theme-accent: var(--blue);
  --theme-secondary: var(--blue);
  /* Contrast-safe ink for text/icons sitting on a --theme-primary fill.
     Overridden per-theme by the extraction engine so button labels stay
     readable whether the brand colour is light or dark. */
  --theme-on-primary: #ffffff;
  --theme-success: var(--green);
  --theme-warning: var(--orange);
  --theme-error: var(--red);
  --theme-info: var(--blue);
  --theme-shadow-color: rgba(15, 23, 42, .12);
  --font-family-base: 'Manrope', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-scale: 1;
  --radius-scale: 1;
  --anim-speed: 1;
  --anim-fast: calc(140ms * var(--anim-speed));
  --anim-base: calc(220ms * var(--anim-speed));
  --anim-slow: calc(320ms * var(--anim-speed));
  --anim-ease: cubic-bezier(.16, 1, .3, 1);

  --glass-blur: 18px;
  --glass-tint: 255, 255, 255;
  --glass-opacity: .82;
  --glass-opacity-strong: .93;
  --glass-border: rgba(255, 255, 255, .55);

  --app-bg-image: none;
  --app-bg-gradient: var(--a8-canvas);

  /* ── Background layer controls (Background Manager / image themes) ──
     A dedicated fixed layer (body::before) paints the image + gradient so it
     can be blurred / dimmed / overlaid without ever touching content clarity. */
  --app-bg-size: cover;         /* cover | contain | <length> */
  --app-bg-repeat: no-repeat;   /* no-repeat | repeat (tiled) */
  --app-bg-attachment: fixed;   /* fixed | scroll */
  --app-bg-blur: 0px;           /* frosted background */
  --app-bg-opacity: 1;          /* fade image toward the base --bg colour */
  --app-bg-overlay: none;       /* dark/light/gradient wash for readability */

  /* ── Built-in premium background presets (Background Manager) ── */
  --preset-business: radial-gradient(circle at 10% 10%, #dbe6ff 0%, transparent 45%),
    radial-gradient(circle at 90% 20%, #e4edff 0%, transparent 45%),
    linear-gradient(160deg, #eef2fb 0%, #f6f8fd 60%, #eef1f8 100%);
  --preset-technology: radial-gradient(circle at 15% 15%, #d7f3ff 0%, transparent 45%),
    radial-gradient(circle at 85% 25%, #dbeeff 0%, transparent 45%),
    radial-gradient(circle at 50% 100%, #e3f7f0 0%, transparent 55%),
    linear-gradient(160deg, #eef9ff 0%, #f5fbff 55%, #eefaf6 100%);
  --preset-corporate: radial-gradient(circle at 12% 12%, #e6e9f5 0%, transparent 45%),
    radial-gradient(circle at 88% 18%, #edeef7 0%, transparent 45%),
    linear-gradient(160deg, #f2f3f8 0%, #f7f7fa 55%, #f1f2f6 100%);
  --preset-dark: radial-gradient(circle at 12% 8%, #1b2340 0%, transparent 45%),
    radial-gradient(circle at 88% 16%, #142a29 0%, transparent 42%),
    radial-gradient(circle at 50% 100%, #241b3a 0%, transparent 55%),
    linear-gradient(160deg, #0c0f18 0%, #0b0e16 55%, #0d1310 100%);
  --preset-minimal: linear-gradient(160deg, #fbfbfc 0%, #f6f7f9 55%, #f9fafb 100%);
  --preset-abstract: radial-gradient(circle at 20% 20%, #ffe3f0 0%, transparent 42%),
    radial-gradient(circle at 80% 15%, #e0f0ff 0%, transparent 42%),
    radial-gradient(circle at 50% 90%, #fff3d6 0%, transparent 50%),
    linear-gradient(160deg, #fbf7fd 0%, #f8fafd 55%, #fdf9f4 100%);
  /* Action8 flat warm canvas — the redesign's default page background. */
  --preset-a8: var(--a8-canvas);
  --preset-modern: radial-gradient(circle at 12% 8%, #eef1ff 0%, transparent 45%),
    radial-gradient(circle at 88% 16%, #e7f9f2 0%, transparent 42%),
    radial-gradient(circle at 50% 100%, #f3eefc 0%, transparent 55%),
    linear-gradient(160deg, #f6f8fd 0%, #f8fafc 55%, #f4faf7 100%);
  --preset-blue: radial-gradient(circle at 15% 10%, #cfe3ff 0%, transparent 45%),
    radial-gradient(circle at 85% 25%, #dbeaff 0%, transparent 45%),
    linear-gradient(160deg, #eaf2ff 0%, #f2f7ff 55%, #eaf1fb 100%);
  --preset-purple: radial-gradient(circle at 15% 12%, #ecdcff 0%, transparent 45%),
    radial-gradient(circle at 85% 22%, #f2e2ff 0%, transparent 45%),
    linear-gradient(160deg, #f6efff 0%, #f9f5ff 55%, #f3ecfc 100%);

  --surface: rgba(var(--glass-tint), var(--glass-opacity));
  --surface-strong: rgba(var(--glass-tint), var(--glass-opacity-strong));

  --radius-sm: calc(10px * var(--radius-scale));
  --radius: calc(12px * var(--radius-scale));
  --radius-lg: calc(16px * var(--radius-scale));
  --radius-xl: calc(22px * var(--radius-scale));
}

html[data-theme="dark"] {
  /* Match native controls (inputs, select popups, date pickers, scrollbars)
     to the dark theme so their default text/background flips too. */
  color-scheme: dark;

  --ink: #F2F3F5;
  --ink-soft: #B8BEC7;
  --muted: #7C838D;
  --faint: #3B4149;

  --bg: #14171C;
  --border: #2E333D;
  --border-soft: #232830;

  /* Brighter status inks so green/red/amber/slate labels stay readable on the
     dark canvas instead of sinking into it. */
  --ink-success: #3FBE8B;
  --ink-danger: #E2695A;
  --ink-warning: #E0A73E;
  --ink-neutral: #7C838D;

  /* Accent + status palettes brighten in dark mode (Action8 handoff). */
  --accent: #8FA0FF;
  --accent-hover: #A6B4FF;
  --green: #3FBE8B;
  --green-light: #173327;
  --orange: #E0A73E;
  --orange-light: #3A2C13;
  --red: #E2695A;
  --red-light: #3B211D;
  --blue: #4FA9D1;
  --blue-hover: #6BB9DC;

  /* On-accent ink flips dark so labels stay readable on the brightened
     indigo. Themes that inject their own --theme-on-primary still win. */
  --theme-on-primary: #14171C;

  /* Action8 redesign tokens — dark values */
  --a8-canvas: linear-gradient(180deg, #14171C 0%, #14171C 100%);
  --a8-surface-rgb: 27, 31, 38;
  --a8-accent: #8FA0FF;
  --a8-accent-hover: #A6B4FF;
  --a8-on-accent: #14171C;
  --a8-border: #2E333D;
  --a8-sidebar: rgba(27, 31, 38, .95);
  --surface-alt: #20242C;

  --glass-tint: 27, 31, 38;
  --glass-opacity: .72;
  --glass-opacity-strong: .86;
  --glass-border: rgba(255, 255, 255, .08);

  --accent-light: #262E52;
  --accent-soft: rgba(143, 160, 255, .32);

  --app-bg-gradient: var(--a8-canvas);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 2px 10px rgba(0, 0, 0, .35);
  --shadow-md: 0 8px 28px rgba(0, 0, 0, .4);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, .5);
}

/* Action8 is a solid-surface design — never frosted glass, in either mode.
   The generic dark block above lowers --glass-opacity for glassy themes;
   this pins the redesign's surfaces back to opaque (#1B1F26 in dark). */
html[data-theme="dark"][data-theme-id="action8"],
html[data-theme="dark"][data-theme-id="action8-dark"] {
  --glass-opacity: 1;
  --glass-opacity-strong: 1;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { transition: background-color var(--anim-base, .22s) ease; }

/* ── Global dynamic background — a plain CSS background on body (not a
   separate positioned layer), so it renders on every page that links this
   stylesheet, including ones that don't include _nav.html (e.g. login).
   background-color is an opaque fallback so the browser never falls back to
   an auto-dark canvas before the gradient/image paints. Swapped live by the
   Background Manager without a page reload. ── */
body {
  font-family: var(--font-family-base);
  background-color: var(--bg);          /* opaque base — the image fades toward this */
  color: var(--ink);
  font-size: calc(14px * var(--font-scale));
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  margin-left: var(--sidebar-rail-width);
  transition: margin-left .25s ease-in-out, color .22s ease;
  animation: pageFadeIn .38s var(--anim-ease);
}
body.sidebar-push { margin-left: var(--sidebar-expanded-width); }

/* Form controls don't inherit the document font by default — without this,
   buttons/inputs silently fall back to the system font instead of Manrope. */
button, input, select, textarea { font-family: inherit; }

/* Background image + themed gradient live on a fixed layer behind all content
   so blur/opacity apply to the backdrop only. The negative inset scales with
   the blur radius so frosted edges never reveal a transparent gutter. */
body::before {
  content: "";
  position: fixed;
  inset: calc(-3 * var(--app-bg-blur));
  z-index: -2;
  background-image: var(--app-bg-image), var(--app-bg-gradient);
  background-size: var(--app-bg-size), cover;
  background-position: center, center;
  background-repeat: var(--app-bg-repeat), no-repeat;
  filter: blur(var(--app-bg-blur));
  opacity: var(--app-bg-opacity);
  transition: opacity .4s ease, filter .4s ease, background-image .4s ease;
  pointer-events: none;
}
/* Readability overlay (dark/light/gradient wash) — sharp, above the blurred
   image but below every UI surface. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--app-bg-overlay);
  transition: background .4s ease;
  pointer-events: none;
}
/* Scrolling (non-fixed) background: let the layer scroll with the document. */
html.bg-scroll body::before { position: absolute; inset: 0; min-height: 100%; }
html.bg-scroll body::after  { position: absolute; min-height: 100%; }

@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Premium glass surfaces — retrofits every shared card/table/modal/menu
   across all pages (they all link this one stylesheet) with a frosted-glass
   look, soft shadow, larger radius and smooth hover elevation, without
   needing to touch each template individually. ── */
.card, .data-table, .modal, .pm-modal, .kanban-card, .product-tile,
.notif-dropdown, .pmenu, .search-suggest, .qr-col-menu, .perm-search-results,
.stats-bar, .task-row, .icon-picker-popover {
  background: var(--surface);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  border-color: var(--glass-border);
}
.card {
  transition: transform var(--anim-base) var(--anim-ease), box-shadow var(--anim-base) var(--anim-ease);
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

/* ══════════════════════════════════════════════════════════════════
   Left sidebar — Action8 redesign (design_handoff_priceassist_redesign)
   Fixed 264px surface panel: brand row, uppercase section headers,
   dot-indicator nav rows, bottom user block + light/dark toggle.
   ══════════════════════════════════════════════════════════════════ */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-rail-width);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 16px 16px;
  z-index: 500;
  overflow: hidden;
  transition: width .25s ease-in-out;
}
.sidebar.expanded { width: var(--sidebar-expanded-width); }
/* Any expansion (hover or pinned) pushes content via body.sidebar-push, so
   give the panel a lifted edge whenever it's wider than the collapsed rail. */
@media (min-width: 1025px) {
  .sidebar.expanded { box-shadow: var(--shadow-lg); }
}
/* Server-rendered pinned state — expanded on first paint, before JS runs. */
html.sidebar-pinned-init .sidebar { width: var(--sidebar-expanded-width); }
html.sidebar-pinned-init body { margin-left: var(--sidebar-expanded-width); }

/* Brand row: accent "PA" badge + wordmark + small-caps subtitle */
.sidebar-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 20px;
  flex-shrink: 0;
}
/* Pin toggle (top-right of the brand row): keeps the sidebar expanded so it
   doesn't auto-collapse when the mouse leaves. */
.sidebar-pin-btn {
  margin-left: auto;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s ease, color .15s ease, opacity .18s ease;
}
.sidebar-pin-btn:hover { background: var(--surface-alt, var(--bg)); color: var(--ink); }
.sidebar-pin-btn.pinned { color: var(--accent); }
.sidebar-pin-btn.pinned svg { fill: currentColor; }
.sidebar-pin-btn svg { width: 15px; height: 15px; }

/* Collapsed rail: labels fade out; dots, logo and avatar stay visible. The
   sidebar's overflow:hidden clips whatever the fade doesn't cover. */
.sidebar-brand, .sidebar-user-text, .sidebar-mode-toggle { transition: opacity .18s ease; }
.sidebar-label, .nav-group-label { transition: opacity .18s ease; }
.sidebar:not(.expanded) .sidebar-brand,
.sidebar:not(.expanded) .sidebar-pin-btn,
.sidebar:not(.expanded) .sidebar-label,
.sidebar:not(.expanded) .nav-group-label,
.sidebar:not(.expanded) .sidebar-user-text,
.sidebar:not(.expanded) .sidebar-mode-toggle { opacity: 0; pointer-events: none; }
.sidebar-logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: #FFD400;
  color: #000;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; letter-spacing: -.5px;
  flex-shrink: 0;
}
.sidebar-brand { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.sidebar-brand-name { font-weight: 800; font-size: 15px; color: var(--ink); white-space: nowrap; }
.sidebar-brand-sub { font-size: 11px; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }

/* Only the middle nav section scrolls; brand above and user block below stay put. */
.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--faint) transparent;
}
.sidebar-scroll::-webkit-scrollbar { width: 6px; }
.sidebar-scroll::-webkit-scrollbar-track { background: transparent; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--faint); border-radius: 10px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; width: 100%; }

/* Section headers — 11px uppercase labels; still click-to-collapse */
.nav-group { display: flex; flex-direction: column; width: 100%; }
.nav-group-header {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 16px 12px 6px;
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  cursor: pointer;
  text-align: left;
}
.nav-group-icon { display: none; }
.nav-group-label { flex: 1; text-align: left; white-space: nowrap; color: inherit; }
.nav-group-chevron { font-size: 9px; opacity: 0; transition: transform .22s cubic-bezier(.4,0,.2,1), opacity .15s ease; }
.nav-group-header:hover .nav-group-chevron { opacity: .8; }
.nav-group.collapsed .nav-group-chevron { transform: rotate(-90deg); opacity: .8; }
.nav-group-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 800px;
  opacity: 1;
  overflow: hidden;
  transition: max-height .25s cubic-bezier(.4,0,.2,1), opacity .25s ease;
}
.nav-group.collapsed .nav-group-items { max-height: 0; opacity: 0; }

.nav-subgroup { display: flex; flex-direction: column; }
.nav-subgroup-items { display: flex; flex-direction: column; gap: 1px; }

/* Nav rows — 6px dot indicator + label (handoff replaces icons with dots) */
.sidebar-link {
  display: flex; align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 9px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.25;
  transition: background .15s ease, color .15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}
.sidebar-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--faint);
  flex-shrink: 0;
  transition: background .15s ease;
}
.sidebar-link:hover .sidebar-dot,
.sidebar-customize-btn:hover .sidebar-dot { background: var(--muted); }
.sidebar-icon { display: none; }   /* legacy SVG icons — replaced by dots */
.sidebar-label { line-height: 1.25; overflow: hidden; text-overflow: ellipsis; color: inherit; }
.sidebar-link:hover { background: var(--surface-alt, var(--bg)); color: var(--ink); }
.sidebar-link.active { background: var(--accent-light); color: var(--accent); }
.sidebar-link.active .sidebar-dot { background: var(--accent); }
.nav-group-items [data-dragsort-id] { transition: transform .15s ease; }
.nav-editing .drag-handle { display: inline-flex !important; }
.sidebar-link-top { margin-top: 2px; }

/* Visible keyboard focus */
.sidebar-link:focus-visible,
.nav-group-header:focus-visible,
.sidebar-customize-btn:focus-visible,
.sidebar-mode-toggle:focus-visible,
.topbar-hamburger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sidebar-customize-btn {
  display: flex; align-items: center; gap: 11px;
  width: 100%;
  padding: 9px 12px;
  margin-top: 4px;
  background: none;
  border: none;
  border-radius: 9px;
  color: var(--ink-soft);
  cursor: pointer;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  text-align: left;
  transition: background .15s ease, color .15s ease;
  flex-shrink: 0;
}
.sidebar-customize-btn:hover { background: var(--surface-alt, var(--bg)); color: var(--ink); }
.sidebar.nav-editing .sidebar-customize-btn { background: var(--accent-light); color: var(--accent); }
.sidebar.nav-editing .sidebar-customize-btn .sidebar-dot { background: var(--accent); }

/* ── Bottom block: user row + light/dark mode toggle ─────────────────── */
.sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 14px;
  margin-top: 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sidebar-user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-light); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
  overflow: hidden; flex-shrink: 0;
}
.sidebar-user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-user-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.sidebar-user-name { font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: var(--muted); text-transform: capitalize; }
.sidebar-mode-toggle {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
  transition: background .15s ease;
}
.sidebar-mode-toggle:hover { background: var(--surface-alt, var(--bg)); }
.sidebar-mode-track {
  width: 34px; height: 19px; border-radius: 10px;
  background: var(--faint);
  position: relative; flex-shrink: 0;
  transition: background .15s ease;
}
html[data-theme="dark"] .sidebar-mode-track { background: var(--accent); }
.sidebar-mode-knob {
  width: 15px; height: 15px; border-radius: 50%;
  background: #fff;
  position: absolute; top: 2px; left: 2px;
  transition: left .15s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
html[data-theme="dark"] .sidebar-mode-knob { left: 17px; }

/* ── Pipelines accordion (inline, expands downward under the trigger) ─── */
.pipeline-trigger { width: 100%; background: none; border: none; cursor: pointer; font-family: inherit; text-align: left; }

.pipeline-chevron { margin-left: auto; font-size: 9px; color: var(--muted); transition: transform .22s cubic-bezier(.4,0,.2,1); }
.nav-subgroup:not(.open) .pipeline-chevron { transform: rotate(-90deg); }

.pipeline-flyout {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  transition: max-height .25s cubic-bezier(.4,0,.2,1), opacity .25s ease, margin-top .2s ease;
}
.nav-subgroup.open > .pipeline-flyout {
  max-height: 640px;
  opacity: 1;
  margin-top: 2px;
}

.pipeline-flyout-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 4px 12px 2px 28px;
}
.pipeline-add-btn {
  width: 22px; height: 22px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s, transform .1s ease;
  flex-shrink: 0;
}
.pipeline-add-btn:hover { background: var(--accent-light); color: var(--accent); border-color: var(--accent-light); }
.pipeline-add-btn:active { transform: scale(.93); }

.pipeline-flyout-list { display: flex; flex-direction: column; gap: 2px; }
.pipeline-flyout-item {
  display: flex; align-items: center; gap: 6px;
  margin-left: 16px;
  padding: 8px 12px;
  border-radius: 9px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.25;
  font-weight: 600;
  transition: background .15s, color .15s, transform .15s ease;
}
.pipeline-flyout-item:hover { background: var(--surface-alt, var(--bg)); color: var(--ink); }
.pipeline-flyout-item.active { background: var(--accent-light); color: var(--accent); }
.pipeline-flyout-icon { display: none; }
/* Indented pipeline rows use the same 6px dot language as top-level rows. */
.pipeline-flyout-main::before {
  content: '';
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--faint);
  flex-shrink: 0;
}
.pipeline-flyout-item.active .pipeline-flyout-main::before { background: var(--accent); }

/* ── Sidebar backdrop (tablet/mobile scrim behind the overlay panel) ── */
.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .45);
  z-index: 490;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
}
.sidebar-backdrop.show { opacity: 1; pointer-events: auto; }

/* ══════════════════════════════════════════════════════════════════
   Topbar — Action8 redesign: 68px surface bar. Page title + subtitle
   on the left; search, notification bell and avatar on the right.
   ══════════════════════════════════════════════════════════════════ */
.topbar {
  position: relative;
  z-index: 900;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  color: var(--ink);
  padding: 10px 28px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--topbar-h);
  flex-wrap: wrap;
  row-gap: 6px;
}
.topbar-page { line-height: 1.3; min-width: 0; margin-right: 12px; }
.topbar-page-title { font-size: 17px; font-weight: 800; color: var(--ink); letter-spacing: -.01em; white-space: nowrap; }
.topbar-page-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.topbar .btn { padding: 8px 14px; font-size: 12.5px; }

.topbar-hamburger {
  display: none;
  width: 38px; height: 38px;
  align-items: center; justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--ink-soft);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s ease;
}
.topbar-hamburger:hover { background: var(--surface-alt, var(--bg)); }
.topbar-hamburger svg { width: 20px; height: 20px; }

/* Tablet & below: the sidebar becomes an off-canvas overlay opened by the
   fixed hamburger; content takes the full width. */
@media (max-width: 1024px) {
  body, body.sidebar-push { margin-left: 0 !important; }
  .topbar-hamburger {
    display: flex;
    position: fixed;
    top: 14px; left: 14px;
    /* Above the topbar (z 900) but below the open sidebar overlay + backdrop. */
    z-index: 950;
    box-shadow: var(--shadow-md);
  }
  .topbar { padding-left: 64px; }
  .sidebar { transform: translateX(-100%); transition: transform .25s ease-in-out; width: var(--sidebar-expanded-width); }
  .sidebar.expanded { transform: translateX(0); box-shadow: var(--shadow-lg); }
  /* Off-canvas panel is always full width — labels never fade on touch tiers. */
  .sidebar:not(.expanded) .sidebar-brand,
  .sidebar:not(.expanded) .sidebar-pin-btn,
  .sidebar:not(.expanded) .sidebar-label,
  .sidebar:not(.expanded) .nav-group-label,
  .sidebar:not(.expanded) .sidebar-user-text,
  .sidebar:not(.expanded) .sidebar-mode-toggle { opacity: 1; pointer-events: auto; }
}
@media (max-width: 640px) {
  .sidebar, .sidebar.expanded { width: min(86vw, 300px); }
}

/* "Sync Data" — filled success-green pill per the handoff Quote Builder toolbar. */
.sync-btn {
  background: var(--green);
  border: none;
  color: #fff;
  padding: 9px 16px;
  border-radius: 9px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: filter .15s, box-shadow .15s;
}
.sync-btn:hover { filter: brightness(1.08); box-shadow: var(--shadow-sm); }

/* ── Layout — Action8: open canvas + floating Quotation card on the right ── */
.layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(360px, 440px); gap: 22px; padding: 24px 28px; height: calc(100vh - var(--topbar-h)); overflow: hidden; }
.panel { height: 100%; overflow-y: auto; min-height: 0; }
.panel-left { padding: 2px; }
.panel-right {
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

/* ── Search box ─────────────────────────────────── */
.search-wrap { position: relative; margin-bottom: 20px; }
.search-wrap input {
  width: 100%; padding: 13px 16px 13px 42px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14.5px; outline: none; transition: border-color .15s, box-shadow .15s;
  box-shadow: var(--shadow-sm);
}
.search-wrap input::placeholder { color: var(--muted); }
.search-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search-wrap .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 15px; }
.search-hint { color: var(--muted); font-size: 13px; text-align: center; margin-top: 48px; line-height: 1.6; }

/* ── Search suggestions dropdown ──────────────────── */
.search-suggest {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 150; margin-top: 4px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); max-height: 320px; overflow-y: auto; display: none;
}
.search-suggest.open { display: block; }
.suggest-item {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border-soft); font-size: 13px;
  transition: background .1s;
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item:hover { background: var(--accent-light); }
.suggest-desc { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest-price { font-family: var(--font-mono); font-weight: 600; color: var(--ink-success); font-size: 12px; flex-shrink: 0; display: flex; align-items: baseline; gap: 5px; }
.suggest-price .suggest-when { font-weight: 400; color: var(--ink-soft); font-size: 10.5px; }

/* ── Results grid (Amazon-style tiles) ────────────── */
.results-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }

.product-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm); display: flex; flex-direction: column;
  transition: box-shadow .15s, border-color .15s, transform .15s;
}
.product-tile:hover { box-shadow: var(--shadow-md); border-color: var(--accent-soft); transform: translateY(-2px); }

.tile-img-wrap { position: relative; width: 100%; aspect-ratio: 1 / 1; background: var(--bg); }
.tile-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile-img-ph { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 40px; color: var(--faint); }

.tile-upload-btn {
  position: absolute; bottom: 8px; right: 8px; width: 30px; height: 30px; border-radius: 50%;
  background: rgba(15,23,42,.72); color: #fff; display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 14px; box-shadow: var(--shadow-sm); transition: background .15s, transform .15s;
}
.tile-upload-btn:hover { background: var(--accent); transform: scale(1.08); }
.tile-upload-btn input { display: none; }

.tile-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.tile-title {
  font-size: 12.5px; font-weight: 600; line-height: 1.35; min-height: 2.7em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tile-meta { font-size: 11px; color: var(--muted); }

.tile-price-row { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.tile-price-avg { font-family: var(--font-mono); font-size: 15px; font-weight: 700; color: var(--ink-success); }
.tile-price-range { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-soft); }

.tile-last-sold { display: flex; gap: 5px; font-size: 11px; flex-wrap: wrap; align-items: baseline; }
.tile-last-sold .lbl { color: var(--ink-soft); }
.tile-last-sold .val { font-family: var(--font-mono); font-weight: 700; color: var(--accent); }
.tile-last-sold .when { color: var(--ink-soft); font-size: 10.5px; }

.tile-cost { display: flex; gap: 5px; font-size: 11px; flex-wrap: wrap; }
.tile-cost .lbl { color: var(--ink-soft); }
.tile-cost .val { font-weight: 600; }
.tile-cost .margin { color: var(--green); font-weight: 600; }
.tile-cost .margin.low { color: var(--orange); }

.tile-recent { border-top: 1px solid var(--border-soft); padding-top: 7px; margin-top: 1px; display: flex; flex-direction: column; gap: 3px; }
.tile-recent-row { display: flex; justify-content: space-between; gap: 6px; font-size: 10.5px; color: var(--ink-soft); }
.tile-recent-row .client { font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-recent-row .rate-val { font-weight: 600; color: var(--accent); flex-shrink: 0; }
.tile-recent-row .quo-ref { font-weight: 400; color: var(--ink-soft); }

.tile-add-btn {
  margin-top: auto; padding: 9px; background: var(--green); color: #fff; border: none;
  border-radius: var(--radius-sm); font-size: 12px; font-weight: 700; cursor: pointer; transition: background .15s, filter .15s;
}
.tile-add-btn:hover { filter: brightness(1.08); }

/* ── Quotation panel ───────────────────────────── */
.panel-title { font-size: 17px; font-weight: 800; margin-bottom: 18px; display: flex; align-items: center; gap: 10px; letter-spacing: -.01em; }
.panel-title .count { background: var(--accent-light); color: var(--accent); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 700; }

.quo-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.quo-fields .full { grid-column: 1 / -1; }
.quo-fields label { font-size: 11.5px; font-weight: 500; color: var(--ink-soft); display: block; margin-bottom: 4px; }
.quo-fields input, .quo-fields select, .quo-fields textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; outline: none;
  transition: border-color .15s, box-shadow .15s; background: var(--surface); color: var(--ink);
}
.quo-fields input:focus, .quo-fields select:focus, .quo-fields textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.quo-fields input.invalid { border-color: var(--red); }
.field-error { font-size: 11px; color: var(--red); margin-top: 4px; min-height: 14px; }

/* Line items */
.quo-items { margin-bottom: 18px; }
.quo-item { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 10px; }
.quo-item-top { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 8px; }
.quo-item-img { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; flex-shrink: 0; border: 1px solid var(--border); }
.quo-item-img-ph { width: 36px; height: 36px; border-radius: 6px; background: var(--border-soft); flex-shrink: 0; }
.quo-item-desc { flex: 1; font-size: 13px; font-weight: 500; }
.quo-item-remove { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 17px; padding: 0; line-height: 1; transition: color .15s; }
.quo-item-remove:hover { color: var(--red); }

.quo-item-nums { display: grid; grid-template-columns: 80px 80px 1fr; gap: 8px; font-size: 12px; }
.quo-item-nums label { color: var(--ink-soft); display: block; margin-bottom: 3px; font-size: 10.5px; }
.quo-item-nums input { width: 100%; padding: 5px 8px; border: 1px solid var(--border); border-radius: 5px; font-size: 12px; outline: none; background: var(--surface); color: var(--ink); }
.quo-item-nums input:focus { border-color: var(--accent); }
.quo-item-amount { text-align: right; font-family: var(--font-mono); font-weight: 600; color: var(--accent); padding-top: 15px; }

.quo-item-weight-row { display: grid; grid-template-columns: 80px 80px 1fr; gap: 8px; font-size: 12px; margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border-soft); }
.quo-item-weight-row label { color: var(--ink-soft); display: block; margin-bottom: 3px; font-size: 10.5px; }
.quo-item-weight-row input { width: 100%; padding: 5px 8px; border: 1px solid var(--border); border-radius: 5px; font-size: 12px; outline: none; background: var(--surface); color: var(--ink); }
.quo-item-weight-row input:focus { border-color: var(--accent); }
.quo-item-weight-note { display: flex; align-items: center; font-size: 11px; color: var(--ink-soft); font-style: italic; }

/* Total */
.quo-total { border-top: 2px solid var(--border); padding-top: 12px; text-align: right; font-family: var(--font-mono); font-size: 17px; font-weight: 600; color: var(--accent); margin-bottom: 18px; }
.quo-total span { font-size: 11.5px; font-weight: 400; color: var(--muted); }

/* Actions */
.quo-actions { display: flex; flex-direction: column; gap: 9px; }
.btn { padding: 10px 16px; border: none; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; font-weight: 600; transition: background .15s, box-shadow .15s, border-color .15s, transform .1s ease; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: var(--theme-on-primary); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg); border-color: var(--faint); }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: #047857; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

/* ── Toast ─────────────────────────────────────── */
.toast { position: fixed; bottom: 28px; right: 28px; background: var(--ink); color: var(--bg); padding: 11px 20px; border-radius: var(--radius-sm); font-size: 13px; z-index: 1000; opacity: 0; transform: translateY(6px); transition: opacity .25s, transform .25s; pointer-events: none; box-shadow: var(--shadow-lg); }
.toast.show { opacity: 1; transform: translateY(0); }

/* ── PWA install / offline banners ────────────────
   Self-contained widgets injected by static/pwa.js — kept out of every
   template so install/offline UI stays in one place. */
.pwa-install-btn {
  position: fixed; bottom: 24px; right: 24px; z-index: 980;
  display: flex; align-items: center; gap: 8px;
  background: var(--theme-primary); color: var(--theme-on-primary, #fff);
  border: none; border-radius: 999px; padding: 12px 18px;
  font-size: 13.5px; font-weight: 700; font-family: var(--font-family-base);
  box-shadow: var(--shadow-lg); cursor: pointer;
  animation: pwaSlideUp .3s ease;
}
.pwa-install-btn:hover { background: var(--theme-primary-hover); }
.pwa-banner {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 980; width: min(420px, calc(100vw - 32px));
  background: var(--surface); color: var(--ink); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 14px 16px; font-size: 13px; font-family: var(--font-family-base);
  display: flex; align-items: flex-start; gap: 10px;
  animation: pwaSlideUp .3s ease;
}
.pwa-banner-icon { font-size: 18px; line-height: 1; }
.pwa-banner-body { flex: 1; }
.pwa-banner-title { font-weight: 700; margin-bottom: 2px; }
.pwa-banner-text { color: var(--ink-soft); line-height: 1.4; }
.pwa-banner-close {
  background: none; border: none; color: var(--muted); font-size: 16px;
  line-height: 1; cursor: pointer; padding: 2px; flex-shrink: 0;
}
.pwa-banner-close:hover { color: var(--ink); }
.pwa-offline-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 990;
  background: var(--orange); color: #fff; text-align: center;
  font-size: 12.5px; font-weight: 600; padding: 6px 12px;
  font-family: var(--font-family-base);
  animation: pwaSlideDown .25s ease;
}
@keyframes pwaSlideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pwaSlideDown { from { opacity: 0; transform: translateY(-100%); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 640px) {
  .pwa-install-btn { bottom: 16px; right: 16px; padding: 11px 16px; font-size: 13px; }
  .pwa-banner { bottom: 16px; width: calc(100vw - 24px); }
}

/* ── Stats bar ─────────────────────────────────── */
.stats-bar { background: var(--green-light); border: 1px solid color-mix(in srgb, var(--green) 35%, transparent); border-radius: var(--radius); padding: 10px 16px; margin-bottom: 20px; font-size: 12.5px; color: var(--ink-success); display: flex; gap: 18px; flex-wrap: wrap; }
.stats-bar b { font-weight: 700; }

/* ── Empty state ───────────────────────────────── */
.empty-quo { text-align: center; color: var(--muted); padding: 40px 0; font-size: 13px; }
.empty-quo .icon { font-size: 38px; display: block; margin-bottom: 10px; opacity: .6; }

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; height: auto; overflow: visible; }
  .panel { height: auto; overflow: visible; }
}

/* ── Shared CRM page shell ─────────────────────── */
.crm-wrap { max-width: 1160px; margin: 0 auto; padding: 32px; }
.crm-wrap .page-title { font-size: 22px; font-weight: 700; margin-bottom: 6px; letter-spacing: -.01em; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.crm-wrap .page-sub { color: var(--ink-soft); font-size: 13.5px; margin-bottom: 24px; }

.data-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); }
.data-table th { text-align: left; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 14px; background: var(--surface-alt, var(--bg)); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 2; }
.data-table td { padding: 10px 14px; font-size: 12.5px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg); }
.row-actions { display: flex; gap: 6px; }
.row-actions button { padding: 5px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; cursor: pointer; font-size: 11px; font-weight: 500; color: var(--ink-soft); transition: background .15s; }
.row-actions button:hover { background: var(--bg); color: var(--ink); }
.row-actions button.danger:hover { background: var(--red-light); color: var(--red); border-color: var(--red-light); }

/* Generic add/edit modal (shared across CRM pages) */
@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalPopIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-bg { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.45); backdrop-filter: blur(2px); z-index: 999; align-items: center; justify-content: center; }
.modal-bg.open { display: flex; animation: modalFadeIn .18s ease; }
.modal-bg.open .modal { animation: modalPopIn .2s ease; }
.modal { background: var(--surface); border-radius: var(--radius-lg); padding: 26px; width: 420px; max-width: 92vw; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal h3 { font-size: 15.5px; font-weight: 700; margin-bottom: 18px; letter-spacing: -.01em; }
.modal .form-group { margin-bottom: 12px; }
.modal .form-group label { font-size: 11.5px; font-weight: 500; color: var(--ink-soft); display: block; margin-bottom: 4px; }
.modal .form-group input, .modal .form-group select, .modal .form-group textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px;
  outline: none; font-family: inherit; transition: border-color .15s, box-shadow .15s; background: var(--surface); color: var(--ink);
}
.modal .form-group input:focus, .modal .form-group select:focus, .modal .form-group textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.modal-actions { display: flex; gap: 8px; margin-top: 20px; }

/* ── Quotation revision sync ("Update in Zoho") ──────────────────
   Each kind of change gets its own visually distinct block so the user can
   tell at a glance which sales orders are being rewritten (down), what is
   merely being added (up), and what is refused outright (block). */
.rev-modal { width: 560px; }
.rev-body { font-size: 13px; line-height: 1.55; }
.rev-group { border-left: 3px solid var(--border); padding: 10px 12px; margin-bottom: 12px; border-radius: var(--radius-sm); background: var(--bg); }
.rev-group-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; color: var(--ink-soft); }
.rev-group ul { margin: 0; padding-left: 18px; }
.rev-group li { margin-bottom: 4px; }
.rev-group li:last-child { margin-bottom: 0; }
.rev-down { border-left-color: #d97706; }
.rev-up { border-left-color: #16a34a; }
.rev-warn { border-left-color: #ca8a04; background: rgba(202,138,4,.08); }
.rev-block { border-left-color: #dc2626; background: rgba(220,38,38,.08); }
.rev-note { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

/* ── Kanban (Deals pipeline) ───────────────────── */
.kanban-board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.kanban-col { flex: 0 0 250px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 220px); transition: transform .15s ease; }
.kanban-col.drag-over { background: var(--accent-light); border-color: var(--accent-soft); }
.kanban-col-head { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; font-weight: 700; }
.kanban-col-head-title { display: flex; align-items: center; gap: 6px; min-width: 0; }
.kanban-col-head .stage-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 7px; }
.kanban-col-head .count { color: var(--ink-soft); font-weight: 500; background: var(--surface); border-radius: 999px; padding: 1px 8px; font-size: 11px; }
.kanban-col-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; flex: 1; min-height: 60px; }
.kanban-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 12px; cursor: grab; box-shadow: var(--shadow-sm); transition: box-shadow .15s, transform .1s; }
.kanban-card:hover { box-shadow: var(--shadow-md); }
.kanban-card.dragging { opacity: .4; }
.kanban-card .deal-name { font-size: 12.5px; font-weight: 600; margin-bottom: 5px; }
.kanban-card .deal-meta { font-size: 11px; color: var(--ink-soft); display: flex; flex-direction: column; gap: 2px; }
.kanban-card .deal-amount { font-weight: 700; color: var(--accent); font-size: 12.5px; margin-top: 6px; }
.kanban-add-btn { margin: 4px 10px 10px; padding: 7px; background: none; border: 1px dashed var(--faint); border-radius: 6px; color: var(--ink-soft); font-size: 11.5px; cursor: pointer; transition: background .15s, border-color .15s; }
.kanban-add-btn:hover { background: var(--surface); border-color: var(--accent); color: var(--accent); }

/* ── Tasks list ─────────────────────────────────── */
.task-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; }
.task-row.done { opacity: .55; }
.task-row.done .task-title { text-decoration: line-through; }
.task-check { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 13px; font-weight: 600; }
.task-meta { font-size: 11.5px; color: var(--ink-soft); margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; }
.task-meta .overdue { color: var(--red); font-weight: 600; }

/* ── Zoho Books invoices (Contacts / Deals) ─────── */
.invoice-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.invoice-table th, .invoice-table td { text-align: left; padding: 7px 8px; font-size: 12.5px; border-bottom: 1px solid var(--border-soft); }
.invoice-status { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; }
.invoice-status.paid { background: var(--green-light); color: var(--ink-success); }
.invoice-status.overdue { background: var(--red-light); color: var(--ink-danger); }
.invoice-status.partially_paid { background: var(--orange-light); color: var(--ink-warning); }
.invoice-status.sent, .invoice-status.viewed { background: color-mix(in srgb, var(--blue) 14%, transparent); color: var(--blue); }
.invoice-status.draft, .invoice-status.void { background: var(--bg); color: var(--ink-soft); }
.invoice-outstanding { font-size: 13.5px; font-weight: 700; margin-top: 12px; }
.task-notes { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

/* ── Zoho Books sync status (Quotation / Sales Order / Invoice chain) ── */
.sync-status { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; }
.sync-status.synced { background: var(--green-light); color: var(--ink-success); }
.sync-status.pending { background: var(--orange-light); color: var(--ink-warning); }
.sync-status.failed { background: #fee2e2; color: #991b1b; }
.sync-status.not_synced { background: var(--bg); color: var(--ink-soft); }

/* Zoho Books status badges shown on the Quotation Records page — same visual
   language as .sync-status, but with the fuller display-label vocabulary. */
.quotation-status { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; white-space: nowrap; }
.quotation-status.not_sent { background: var(--orange-light); color: var(--ink-warning); }
.quotation-status.sending { background: var(--orange-light); color: var(--ink-warning); }
.quotation-status.successfully_pushed, .quotation-status.synced, .quotation-status.updated { background: var(--green-light); color: var(--ink-success); }
.quotation-status.failed { background: var(--red-light); color: var(--ink-danger); }

/* ── Zoho status badges: Estimate (quotation) + Sales Order document states.
   Shares the .invoice-status / .sync-status pastel palette for a consistent
   colour language across the whole Quotation → Sales Order → Invoice chain. */
.doc-status { font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; white-space: nowrap; }
.doc-status.est-draft { background: var(--bg); color: var(--ink-soft); }
.doc-status.est-sent, .doc-status.est-viewed { background: #dbeafe; color: #1e40af; }
.doc-status.est-accepted, .doc-status.est-invoiced { background: #dcfce7; color: #166534; }
.doc-status.est-declined { background: #fee2e2; color: #991b1b; }
.doc-status.est-expired { background: #fef3c7; color: #92400e; }
.doc-status.so-draft { background: var(--bg); color: var(--ink-soft); }
.doc-status.so-open, .doc-status.so-confirmed { background: #dbeafe; color: #1e40af; }
.doc-status.so-fulfilled { background: #dcfce7; color: #166534; }
.doc-status.so-closed, .doc-status.so-void { background: var(--bg); color: var(--ink-soft); }

/* ── Deal → Zoho Books document hub (three-card layout) ── */
.zoho-hub-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.zoho-hub-sub { font-size: 11.5px; color: var(--ink-soft); font-weight: 600; }
.zoho-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: start; }
@media (max-width: 900px) { .zoho-cards { grid-template-columns: 1fr; } }
.zoho-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.zoho-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border-soft); }
.zoho-card-head h4 { margin: 0; font-size: 13px; font-weight: 700; }
.zoho-card-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 12px; }
.zoho-doc-pair { display: flex; flex-direction: column; gap: 10px; padding-bottom: 12px; border-bottom: 1px dashed var(--border); }
.zoho-doc-pair:last-child { border-bottom: none; padding-bottom: 0; }
.zoho-doc { background: var(--bg); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 10px 12px; }
.zoho-doc.pending { border-style: dashed; }
.zoho-doc-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 5px; }
.zoho-doc-title { font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.zoho-doc-title a { color: var(--accent); text-decoration: none; }
.zoho-doc-title a:hover { text-decoration: underline; }
.zoho-doc-meta { font-size: 12px; color: var(--ink); margin-top: 3px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.zoho-doc-meta.muted, .muted { color: var(--ink-soft); }
.zoho-err, .zoho-doc-meta.zoho-err { color: #991b1b; font-weight: 600; }
.zoho-doc-actions { margin-top: 9px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.zoho-open { font-size: 12px; font-weight: 600; color: var(--accent); text-decoration: none; }
.zoho-open:hover { text-decoration: underline; }
.source-pill { font-size: 9.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px; text-transform: uppercase; letter-spacing: .02em; }
.source-pill.crm { background: var(--accent-light); color: var(--accent-hover); }
.source-pill.zoho { background: #e0e7ff; color: #3730a3; }
.source-pill.inherited { background: #fef3c7; color: #92400e; text-transform: none; letter-spacing: 0; margin-left: 4px; }
.zoho-cta { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; background: var(--accent-light); border: 1px dashed var(--accent-soft); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 12px; }
.btn-sm { padding: 5px 11px; font-size: 12px; }

.link-so-results { max-height: 360px; overflow-y: auto; margin: 4px 0 14px; display: flex; flex-direction: column; gap: 8px; }
.link-so-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--bg); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 9px 11px; }
.link-so-number { font-size: 13px; font-weight: 700; }
.link-so-meta { font-size: 11.5px; color: var(--ink-soft); margin-top: 2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.link-so-pager { display: flex; justify-content: center; gap: 10px; margin-top: 4px; }

.related-records-tree { margin-top: 10px; padding-left: 8px; border-left: 2px solid var(--border-soft); }
.related-records-node { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: 12.5px; }
.related-records-node + .related-records-node { margin-left: 18px; }
.related-records-node a { font-weight: 600; }
.related-records-empty { font-size: 12px; color: var(--ink-soft); padding: 6px 0; }

/* ── Activities (Contacts / Deals timelines) ────── */
.activity-type-icon { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; font-size: 11px; margin-right: 8px; flex-shrink: 0; }
.activity-type-icon.task { background: var(--accent-light); }
.activity-type-icon.call { background: #dbeafe; }
.activity-type-icon.meeting { background: #fef3c7; }
.activity-type-icon.zoho { background: #e0e7ff; }

/* ── Notification bell (nav) ────────────────────── */
.nav-bell-wrap { position: relative; margin-left: 10px; }
.notif-badge {
  position: absolute; top: -5px; right: -5px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 999px; display: flex; align-items: center; justify-content: center; padding: 0 3px;
}
.notif-badge.badge-pulse { animation: badgePulse .4s ease; }
@keyframes badgePulse { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
.notif-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; width: 360px; max-height: 420px; overflow-y: auto;
  /* Sits inside .topbar, which sets color:#fff for its dark glass bar. Without
     an explicit ink colour the notification text inherits that white and
     disappears on the light --surface panel in day mode. Pin it to --ink like
     the search dropdown does. */
  background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 500;
  visibility: hidden; opacity: 0; transform: translateY(-6px) scale(.98); transform-origin: top right;
  transition: opacity .16s ease, transform .16s ease, visibility 0s linear .16s;
}
.notif-dropdown.open { visibility: visible; opacity: 1; transform: translateY(0) scale(1); transition: opacity .16s ease, transform .16s ease; }
.notif-dropdown-head {
  display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border);
  font-size: 12.5px; font-weight: 700; position: sticky; top: 0; background: var(--surface);
}
.notif-dropdown-head button { background: none; border: none; color: var(--accent); font-size: 11.5px; font-weight: 600; cursor: pointer; }
.notif-item { padding: 10px 12px; border-bottom: 1px solid var(--border-soft); font-size: 12.5px; cursor: pointer; }
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: var(--accent-light); }
.notif-time { font-size: 10.5px; color: var(--ink-soft); margin-top: 2px; }
.notif-empty { padding: 16px 12px; font-size: 12.5px; color: var(--ink-soft); text-align: center; }

/* ── Pipeline row action menu ─────────────────────────────────────
   Three-dot menu on each pipeline in the sidebar flyout, its dropdown,
   and the modals it opens (Edit Basic Info, Permissions, Stages, Fields). */
.pipeline-flyout-item { justify-content: space-between; }
/* The clickable name is an <a>; inherit the row's color/weight and kill the
   UA link styling (blue/purple + underline) so it matches .sidebar-link. */
.pipeline-flyout-main { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; color: inherit; text-decoration: none; }
.pipeline-flyout-main:link,
.pipeline-flyout-main:visited,
.pipeline-flyout-main:hover,
.pipeline-flyout-main:active { color: inherit; text-decoration: none; }
.pipeline-flyout-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pipeline-item-menu-btn {
  flex-shrink: 0; width: 24px; height: 24px; border-radius: 7px; border: none; background: var(--surface-alt, var(--bg));
  color: var(--ink-soft); font-size: 15px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .12s ease, background .12s ease, color .12s ease;
}
.pipeline-flyout-item:hover .pipeline-item-menu-btn,
.pipeline-flyout-item.active .pipeline-item-menu-btn,
.pipeline-item-menu-btn.menu-open { opacity: 1; }
.pipeline-item-menu-btn:hover, .pipeline-item-menu-btn.menu-open { background: var(--accent-light); color: var(--accent); }

/* Dropdown */
.pmenu {
  position: fixed; z-index: 600; width: 232px; background: var(--surface); border-radius: var(--radius); padding: 6px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--border-soft);
  visibility: hidden; opacity: 0; transform: translateY(-6px) scale(.97); transform-origin: top right;
  transition: opacity .14s ease, transform .14s ease, visibility 0s linear .14s;
}
.pmenu.open { visibility: visible; opacity: 1; transform: translateY(0) scale(1); transition: opacity .14s ease, transform .14s ease; }
.pmenu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: none; background: none;
  border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--ink); text-align: left; cursor: pointer;
  transition: background .12s ease;
}
.pmenu-item:hover, .pmenu-item:focus-visible { background: var(--border-soft); outline: none; }
.pmenu-item.danger { color: var(--red); }
.pmenu-item.danger:hover { background: var(--red-light); }
.pmenu-icon { flex-shrink: 0; width: 18px; text-align: center; font-size: 14px; }
.pmenu-label { flex: 1; }
.pmenu-chevron { flex-shrink: 0; color: var(--muted); font-size: 11px; }
.pmenu-divider { height: 1px; background: var(--border-soft); margin: 5px 4px; }

/* Modals (namespaced separately from .modal so other pages are untouched) */
.pm-modal-bg {
  position: fixed; inset: 0; background: rgba(15,23,42,.45); backdrop-filter: blur(2px); z-index: 999;
  display: flex; align-items: center; justify-content: center;
  visibility: hidden; opacity: 0; transition: opacity .16s ease, visibility 0s linear .16s;
}
.pm-modal-bg.open { visibility: visible; opacity: 1; transition: opacity .16s ease; }
.pm-modal {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 460px; max-width: 92vw; max-height: 88vh; display: flex; flex-direction: column; overflow: hidden;
  transform: translateY(10px) scale(.98); transition: transform .16s ease;
}
.pm-modal-bg.open .pm-modal { transform: translateY(0) scale(1); }
.pm-modal.pm-modal-lg { width: 900px; }
.pm-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 0; }
.pm-modal-head h3 { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.pm-modal-close { width: 28px; height: 28px; border-radius: 8px; border: none; background: none; color: var(--ink-soft); font-size: 16px; cursor: pointer; transition: background .12s; }
.pm-modal-close:hover { background: var(--bg); }
.pm-modal-body { padding: 18px 24px; overflow-y: auto; flex: 1; }
.pm-modal-body .form-group { margin-bottom: 14px; }
.pm-modal-body .form-group label { font-size: 11.5px; font-weight: 600; color: var(--ink-soft); display: block; margin-bottom: 5px; }
.pm-modal-body .form-group input[type=text], .pm-modal-body .form-group input[type=email] {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px;
  outline: none; font-family: inherit; transition: border-color .15s, box-shadow .15s; background: var(--surface); color: var(--ink);
}
.pm-modal-body .form-group input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pm-modal-body .form-row { display: flex; gap: 12px; }
.pm-modal-body .form-row .form-group { flex: 1; }
.pm-modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--border-soft); }
.pm-modal-actions .btn[disabled] { opacity: .6; cursor: not-allowed; }

/* Pipeline icon picker */
.icon-picker-btn {
  width: 44px; height: 44px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--bg);
  font-size: 20px; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: border-color .15s, background .15s;
}
.icon-picker-btn:hover { border-color: var(--accent); background: var(--accent-light); }
.icon-picker-popover {
  position: absolute; z-index: 610; width: 264px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-soft); padding: 10px;
  visibility: hidden; opacity: 0; transform: translateY(-6px); transition: opacity .13s ease, transform .13s ease, visibility 0s linear .13s;
}
.icon-picker-popover.open { visibility: visible; opacity: 1; transform: translateY(0); transition: opacity .13s ease, transform .13s ease; }
.icon-picker-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; max-height: 220px; overflow-y: auto; }
.icon-picker-cell {
  width: 38px; height: 38px; border-radius: 8px; border: 1px solid transparent; background: none; font-size: 18px;
  cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .12s, border-color .12s;
}
.icon-picker-cell:hover { background: var(--border-soft); }
.icon-picker-cell.selected { background: var(--accent-light); border-color: var(--accent-soft); }

/* Permission selector */
.perm-hierarchy-row { display: flex; align-items: center; gap: 8px; padding: 4px 0 16px; font-size: 13px; font-weight: 500; }
.perm-hierarchy-row input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.perm-role-row { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.perm-role-label { font-size: 12.5px; font-weight: 700; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.perm-role-count { font-weight: 500; color: var(--ink-soft); font-size: 11px; }
.perm-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.perm-chips:empty { display: none; }
.perm-chip { display: flex; align-items: center; gap: 6px; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 4px 6px 4px 10px; font-size: 12px; font-weight: 500; }
.perm-chip-remove { width: 16px; height: 16px; border-radius: 50%; border: none; background: var(--border); color: var(--ink-soft); font-size: 10px; cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1; }
.perm-chip-remove:hover { background: var(--red-light); color: var(--red); }
.perm-search-wrap { position: relative; }
.perm-search-input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12.5px;
  outline: none; font-family: inherit;
}
.perm-search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.perm-search-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md); max-height: 160px; overflow-y: auto;
}
.perm-search-result-item { padding: 8px 10px; font-size: 12.5px; cursor: pointer; }
.perm-search-result-item:hover { background: var(--border-soft); }
.perm-search-empty { padding: 8px 10px; font-size: 12px; color: var(--muted); }

/* Stage editor */
.stage-editor-section { margin-bottom: 18px; }
.stage-editor-section-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-soft); margin-bottom: 8px; }
.stage-editor-list { display: flex; flex-direction: column; gap: 6px; }
.stage-editor-row {
  display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 8px 8px 6px;
}
/* Only the ⠿ handle starts a drag, so the name input stays clickable to edit. */
.stage-editor-row-handle { color: var(--faint); font-size: 13px; flex-shrink: 0; cursor: default; touch-action: none; }
.stage-editor-row-handle.pm-stage-drag { cursor: grab; }
.stage-editor-row-handle.pm-stage-drag:hover { color: var(--ink-soft); }
.stage-order-status { min-height: 16px; margin-top: 8px; font-size: 11.5px; line-height: 1.4; color: var(--muted); }
.stage-order-status.ok { color: var(--green, #1F8A5B); }
.stage-order-status.error { color: var(--red); }
.stage-editor-row-input {
  flex: 1; border: none; background: none; font-size: 13px; font-weight: 500; color: var(--ink); outline: none;
  padding: 4px 6px; border-radius: 6px; min-width: 0;
}
.stage-editor-row-input:focus { background: var(--surface-strong); box-shadow: 0 0 0 2px var(--accent-soft); }
.stage-editor-row-delete { flex-shrink: 0; width: 24px; height: 24px; border-radius: 6px; border: none; background: none; color: var(--muted); font-size: 13px; cursor: pointer; }
.stage-editor-row-delete:hover { background: var(--red-light); color: var(--red); }
.stage-editor-add-btn {
  margin-top: 8px; padding: 8px; width: 100%; background: none; border: 1px dashed var(--faint); border-radius: var(--radius-sm);
  color: var(--ink-soft); font-size: 12.5px; font-weight: 500; cursor: pointer; transition: border-color .15s, color .15s;
}
.stage-editor-add-btn:hover { border-color: var(--accent); color: var(--accent); }
.stage-editor-closed-row { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 8px 8px 6px; display: flex; align-items: center; gap: 8px; }
.stage-editor-closed-icon { font-size: 15px; flex-shrink: 0; }

/* Customize Fields two-panel editor */
.field-editor-columns { display: flex; gap: 18px; min-height: 320px; }
.field-editor-panel { flex: 1; min-width: 0; }
.field-editor-panel-head { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-soft); margin-bottom: 8px; }
.field-editor-list { display: flex; flex-direction: column; gap: 6px; min-height: 60px; border-radius: var(--radius-sm); padding: 4px; transition: background .12s; }
.field-editor-list.drag-over { background: var(--accent-light); }
.field-editor-item {
  display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 10px; font-size: 13px; font-weight: 500; cursor: grab;
}
.field-editor-item.dragging { opacity: .4; }
.field-editor-item-handle { color: var(--faint); font-size: 13px; }
.field-editor-item-label { flex: 1; }
.field-editor-item-action { flex-shrink: 0; width: 24px; height: 24px; border-radius: 6px; border: none; background: none; color: var(--muted); font-size: 13px; cursor: pointer; }
.field-editor-item-action:hover { background: var(--surface); color: var(--accent); }
.field-editor-empty { font-size: 12px; color: var(--muted); padding: 10px; text-align: center; }

/* ── Stage Requirements editor (mandatory fields per stage) ── */
.stagereq-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border-soft); }
.stagereq-row:last-child { border-bottom: none; }
.stagereq-stage { flex: 0 0 108px; font-size: 13px; font-weight: 600; color: var(--ink); padding-top: 5px; word-break: break-word; }
.stagereq-chips { flex: 1; display: flex; flex-wrap: wrap; gap: 6px; }
.stagereq-chip {
  font-size: 12px; font-weight: 500; padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--border-soft); background: var(--surface); color: var(--ink-soft);
  cursor: pointer; transition: background .12s, color .12s, border-color .12s;
}
.stagereq-chip:hover { border-color: var(--brand, #2563eb); color: var(--ink); }
.stagereq-chip.on { background: var(--brand, #2563eb); border-color: transparent; color: #fff; }
.stagereq-hint { font-size: 12px; color: var(--ink-soft); margin: 0 0 4px; line-height: 1.5; }

/* ── Shared drag-to-reorder (dragsort.js): sidebar, pipeline flyout, kanban columns ── */
.drag-handle {
  display: none;
  align-items: center; justify-content: center;
  flex-shrink: 0;
  cursor: grab;
  color: var(--faint);
  font-size: 13px;
  touch-action: none;
  user-select: none;
}
.drag-handle:hover { color: var(--ink-soft); }
.pipeline-flyout-item .drag-handle,
.kanban-col-head .drag-handle { display: inline-flex; opacity: 0; transition: opacity .12s ease; }
.pipeline-flyout-item:hover .drag-handle,
.kanban-col-head:hover .drag-handle { opacity: 1; }
.kanban-col-head .drag-handle { color: var(--muted); }
.kanban-col-head:hover .drag-handle:hover { color: var(--ink); }

.dragsort-hidden-source { opacity: 0; pointer-events: none; }
.dragsort-placeholder {
  border: 2px dashed var(--accent-soft);
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  box-sizing: border-box;
}
.dragsort-ghost {
  position: fixed;
  top: 0; left: 0;
  z-index: 2000;
  pointer-events: none;
  opacity: .95;
  box-shadow: var(--shadow-lg);
  cursor: grabbing;
}
body.dragsort-active { cursor: grabbing; }
body.dragsort-active * { cursor: grabbing !important; }

/* ── Quotation Records page ──────────────────────── */
.qr-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.qr-search { flex: 1; min-width: 200px; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; outline: none; font-family: inherit; background: var(--surface); color: var(--ink); }
.qr-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.qr-filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.qr-filter-chip { padding: 8px 15px; border: 1px solid transparent; border-radius: 20px; background: var(--surface-alt, var(--bg)); font-size: 12.5px; font-weight: 600; color: var(--ink-soft); cursor: pointer; white-space: nowrap; transition: all .12s; }
.qr-filter-chip:hover { color: var(--accent); }
.qr-filter-chip.active { background: var(--accent); border-color: var(--accent); color: var(--theme-on-primary, #fff); }

.qr-table-wrap { overflow-x: auto; border-radius: var(--radius-lg); max-height: 68vh; overflow-y: auto; }
.qr-table-wrap .data-table td { white-space: nowrap; }
.qr-table-wrap .data-table th input[type=checkbox], .qr-table-wrap .data-table td input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.qr-th-sort { cursor: pointer; user-select: none; }
.qr-th-sort:hover { color: var(--accent); }
.qr-th-sort .qr-sort-arrow { margin-left: 4px; opacity: .5; }
.qr-th-sort.active .qr-sort-arrow { opacity: 1; }
.qr-link { font-weight: 600; cursor: pointer; }
.qr-link:hover { text-decoration: underline; }
.qr-sub { font-size: 11px; color: var(--ink-soft); }
.qr-not-linked { color: var(--muted); font-size: 11.5px; font-style: italic; }

/* Row action menu (three dots), reusing .pmenu's dropdown look */
.qr-row-menu-wrap { position: relative; display: inline-block; }
.qr-row-menu-btn { width: 26px; height: 26px; border-radius: 6px; border: none; background: none; color: var(--ink-soft); font-size: 16px; cursor: pointer; line-height: 1; }
.qr-row-menu-btn:hover { background: var(--bg); color: var(--ink); }
.qr-row-menu { right: 0; left: auto; top: calc(100% + 4px); }

/* Bulk actions bar */
.qr-bulk-bar { display: none; align-items: center; gap: 12px; background: var(--accent-light); border: 1px solid var(--accent-soft); border-radius: var(--radius-sm); padding: 9px 14px; margin-bottom: 12px; font-size: 12.5px; font-weight: 600; color: var(--accent); }
.qr-bulk-bar.open { display: flex; }
.qr-bulk-bar .btn { padding: 6px 12px; font-size: 12px; }

/* Column show/hide */
.qr-col-toggle-wrap { position: relative; }
.qr-col-menu { display: none; position: absolute; right: 0; top: calc(100% + 4px); z-index: 50; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); padding: 8px; width: 200px; max-height: 280px; overflow-y: auto; }
.qr-col-menu.open { display: block; }
.qr-col-menu label { display: flex; align-items: center; gap: 8px; padding: 6px 6px; font-size: 12.5px; cursor: pointer; border-radius: 6px; }
.qr-col-menu label:hover { background: var(--bg); }
.qr-col-menu input { accent-color: var(--accent); }

/* Pagination */
.qr-pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; font-size: 12.5px; color: var(--ink-soft); flex-wrap: wrap; }
.qr-pagination-pages { display: flex; gap: 4px; }
.qr-pagination-pages button { min-width: 30px; padding: 6px 8px; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius-sm); font-size: 12px; font-weight: 600; cursor: pointer; color: var(--ink-soft); }
.qr-pagination-pages button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.qr-pagination-pages button:disabled { opacity: .4; cursor: not-allowed; }

/* Activity timeline (detail drawer) */
.qr-timeline { display: flex; flex-direction: column; gap: 2px; }
.qr-timeline-item { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border-soft); font-size: 12.5px; }
.qr-timeline-item:last-child { border-bottom: none; }
.qr-timeline-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 5px; flex-shrink: 0; }
.qr-timeline-body { flex: 1; min-width: 0; }
.qr-timeline-action { font-weight: 600; }
.qr-timeline-meta { color: var(--ink-soft); font-size: 11px; margin-top: 1px; }
.qr-timeline-empty { color: var(--muted); font-size: 12px; padding: 8px 0; }

.qr-detail-section { margin-bottom: 18px; }
.qr-detail-section-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-soft); margin-bottom: 8px; }
.qr-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; font-size: 13px; }
.qr-detail-grid .label { color: var(--ink-soft); font-size: 11px; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 2px; }
.qr-detail-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-soft); margin-bottom: 16px; }
.qr-detail-tab { padding: 8px 4px; margin-right: 16px; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); cursor: pointer; border-bottom: 2px solid transparent; }
.qr-detail-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ══════════════════════════════════════════════════════════════════════
   PREMIUM REDESIGN — global card system, welcome hero, header widgets
   (clock, search, profile, theme toggle). Shared across every page since
   they all link this stylesheet and all include _nav.html. ══════════════ */

/* ── Base card (was only defined inline in admin.html; now shared) ── */
.card {
  background: var(--surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.card-header-grad {
  margin: -24px -24px 20px; padding: 18px 24px; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: linear-gradient(120deg, var(--theme-primary), var(--theme-accent));
  color: #fff; display: flex; align-items: center; gap: 10px;
}
.card-header-grad h2, .card-header-grad h3 { color: #fff; margin: 0; }

/* ── Welcome hero (dashboard) ───────────────────────────────────────── */
.welcome-hero {
  border-radius: var(--radius-xl);
  padding: 28px 30px;
  margin-bottom: 24px;
  background: var(--surface-strong);
  border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(var(--glass-blur));
  backdrop-filter: blur(var(--glass-blur));
  box-shadow: var(--shadow-md);
  display: flex; flex-direction: column; gap: 20px;
  animation: pageFadeIn .45s var(--anim-ease);
}
.welcome-hero-top { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.welcome-greeting { font-size: 24px; font-weight: 800; letter-spacing: -.02em; }
.welcome-greeting span { background: linear-gradient(90deg, var(--theme-primary), var(--theme-accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.welcome-date { font-size: 13px; color: var(--ink-soft); font-weight: 500; }
.welcome-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.welcome-stat {
  background: var(--surface); border: 1px solid var(--glass-border); border-radius: var(--radius);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 6px;
  transition: transform var(--anim-base) var(--anim-ease), box-shadow var(--anim-base) var(--anim-ease);
}
.welcome-stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.welcome-stat-icon { width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 15px; background: var(--accent-light); color: var(--theme-primary); }
.welcome-stat-value { font-size: 21px; font-weight: 800; letter-spacing: -.01em; }
.welcome-stat-label { font-size: 11.5px; color: var(--ink-soft); font-weight: 500; }

/* ── Topbar widgets: search, notification bell, profile — Action8 light
   surface (was dark-glass). All controls are 38px, 10px radius, bordered. ── */
.topbar-widgets { display: flex; align-items: center; gap: 12px; margin-left: 2px; }

.topbar-icon-btn {
  width: 38px; height: 38px; flex-shrink: 0; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--ink-soft); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
  transition: background var(--anim-fast) ease, transform var(--anim-fast) ease;
}
.topbar-icon-btn:hover { background: var(--surface-alt, var(--bg)); }
.topbar-icon-btn:active { transform: scale(.92); }
.topbar-icon-btn svg { width: 18px; height: 18px; }

.topbar-search-wrap { position: relative; width: 280px; }
.topbar-search-wrap input {
  width: 100%; padding: 9px 14px 9px 34px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-alt, var(--bg)); color: var(--ink); font-size: 13px; outline: none;
  transition: border-color var(--anim-fast) ease, box-shadow var(--anim-fast) ease;
}
.topbar-search-wrap input::placeholder { color: var(--muted); }
.topbar-search-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
.topbar-search-wrap .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; pointer-events: none; }
.topbar-search-results {
  position: absolute; top: calc(100% + 8px); left: 0; width: 320px; max-height: 360px; overflow-y: auto;
  background: var(--surface-strong, var(--surface)); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-lg); z-index: 700; color: var(--ink);
  visibility: hidden; opacity: 0; transform: translateY(-6px) scale(.98);
  transition: opacity var(--anim-fast) ease, transform var(--anim-fast) ease, visibility 0s linear var(--anim-fast);
}
.topbar-search-results.open { visibility: visible; opacity: 1; transform: translateY(0) scale(1); transition: opacity var(--anim-fast) ease, transform var(--anim-fast) ease; }
.topbar-search-results .topbar-search-item { display: block; padding: 10px 12px; font-size: 12.5px; border-bottom: 1px solid var(--border-soft); cursor: pointer; text-decoration: none; color: var(--ink); }
.topbar-search-item:hover { background: var(--accent-light); }
.topbar-search-item .kind { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-left: 6px; }
.topbar-search-empty { padding: 14px 12px; font-size: 12px; color: var(--muted); text-align: center; }

/* ── Employee profile widget — 38px accent-soft avatar box ─────────── */
.profile-wrap { position: relative; }
.profile-trigger {
  display: flex; align-items: center; padding: 0; border: none; cursor: pointer;
  background: none; border-radius: 10px; color: var(--ink); font-family: inherit;
}
.profile-avatar {
  width: 38px; height: 38px; border-radius: 10px; object-fit: cover; flex-shrink: 0;
  background: var(--accent-light); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
  position: relative; overflow: hidden;
}
.profile-avatar img { border-radius: inherit !important; }
.profile-online-dot {
  position: absolute; bottom: 3px; right: 3px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--green); border: 1px solid var(--surface);
}
/* Handoff topbar shows the avatar box only — name/role live in the dropdown. */
.profile-trigger-text { display: none; }
.profile-trigger-name { font-size: 12.5px; font-weight: 600; }
.profile-trigger-role { font-size: 10.5px; color: var(--muted); text-transform: capitalize; }

.profile-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0; width: 240px;
  background: var(--surface-strong, var(--surface)); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-lg); z-index: 700; color: var(--ink); overflow: hidden;
  visibility: hidden; opacity: 0; transform: translateY(-6px) scale(.98); transform-origin: top right;
  transition: opacity var(--anim-fast) ease, transform var(--anim-fast) ease, visibility 0s linear var(--anim-fast);
}
.profile-dropdown.open { visibility: visible; opacity: 1; transform: translateY(0) scale(1); transition: opacity var(--anim-fast) ease, transform var(--anim-fast) ease; }
.profile-dropdown-head { display: flex; align-items: center; gap: 10px; padding: 14px; border-bottom: 1px solid var(--border-soft); }
.profile-dropdown-head .profile-avatar { width: 38px; height: 38px; font-size: 14px; }
.profile-dropdown-name { font-size: 13px; font-weight: 700; }
.profile-dropdown-role { font-size: 11px; color: var(--ink-soft); text-transform: capitalize; }
.profile-dropdown-items { padding: 6px; }
.profile-dropdown .profile-dropdown-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: none; background: none;
  border-radius: 8px; font-size: 13px; font-weight: 500; color: var(--ink); text-align: left; cursor: pointer;
  text-decoration: none; transition: background var(--anim-fast) ease;
}
.profile-dropdown-item:hover { background: var(--border-soft); }
.profile-dropdown-item.danger { color: var(--red); }
.profile-dropdown-item.danger:hover { background: var(--red-light); }
.profile-dropdown-divider { height: 1px; background: var(--border-soft); margin: 5px 4px; }

/* ── Profile page (avatar upload + crop) ───────────────────────────── */
.avatar-editor { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.avatar-editor-preview {
  width: 96px; height: 96px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
  background: linear-gradient(135deg, var(--theme-primary), var(--theme-accent));
  display: flex; align-items: center; justify-content: center; font-size: 32px; font-weight: 700; color: #fff;
  border: 3px solid var(--surface); box-shadow: var(--shadow-md);
}
.crop-modal-canvas-wrap { display: flex; justify-content: center; padding: 10px 0; }
.crop-modal-canvas-wrap canvas { border-radius: 8px; cursor: grab; touch-action: none; background: var(--bg); }
.crop-modal-canvas-wrap canvas:active { cursor: grabbing; }
.crop-modal-zoom { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.crop-modal-zoom input[type=range] { flex: 1; accent-color: var(--accent); }

/* ── Appearance / Theme Settings admin panel ───────────────────────── */
.appearance-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.bg-preset {
  position: relative; height: 84px; border-radius: var(--radius); cursor: pointer; overflow: hidden;
  border: 2px solid var(--border); transition: border-color var(--anim-fast) ease, transform var(--anim-fast) ease;
}
.bg-preset:hover { transform: translateY(-2px); }
.bg-preset.selected { border-color: var(--theme-primary); box-shadow: 0 0 0 3px var(--accent-soft); }
.bg-preset-label {
  position: absolute; bottom: 0; left: 0; right: 0; padding: 5px 8px; font-size: 10.5px; font-weight: 600;
  color: #fff; background: linear-gradient(0deg, rgba(0,0,0,.55), transparent);
}
.bg-preset-check {
  position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--theme-primary); color: #fff; display: none; align-items: center; justify-content: center; font-size: 11px;
}
.bg-preset.selected .bg-preset-check { display: flex; }
.bg-upload-tile {
  height: 84px; border-radius: var(--radius); border: 2px dashed var(--faint); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 4px; cursor: pointer; color: var(--ink-soft); font-size: 11px;
  transition: border-color var(--anim-fast) ease, color var(--anim-fast) ease;
}
.bg-upload-tile:hover { border-color: var(--theme-primary); color: var(--theme-primary); }
.bg-upload-tile input { display: none; }

.theme-control-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--border-soft); }
.theme-control-row:last-child { border-bottom: none; }
.theme-control-label { font-size: 13px; font-weight: 600; }
.theme-control-hint { font-size: 11px; color: var(--ink-soft); font-weight: 400; margin-top: 1px; }
.theme-control-row input[type=color] { width: 42px; height: 32px; border: 1px solid var(--border); border-radius: 8px; padding: 2px; background: var(--surface); cursor: pointer; }
.theme-control-row input[type=range] { width: 160px; accent-color: var(--accent); }
.theme-swatch-row { display: flex; gap: 8px; }
.theme-swatch {
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer; border: 2px solid transparent;
  transition: transform var(--anim-fast) ease, border-color var(--anim-fast) ease;
}
.theme-swatch:hover { transform: scale(1.1); }
.theme-swatch.selected { border-color: var(--ink); }

/* ── Toggle switch (used across Appearance panel) ───────────────────── */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute; inset: 0; background: var(--faint); border-radius: 999px; cursor: pointer;
  transition: background var(--anim-fast) ease;
}
.switch-track::before {
  content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%;
  box-shadow: var(--shadow-sm); transition: transform var(--anim-fast) ease;
}
.switch input:checked + .switch-track { background: var(--theme-primary); }
.switch input:checked + .switch-track::before { transform: translateX(18px); }

/* ── Responsive: hide non-essential header widgets on small screens ── */
@media (max-width: 900px) {
  .topbar-search-wrap { display: none; }
}
@media (max-width: 640px) {
  .topbar-widgets .topbar-icon-btn:not(.profile-keep) { display: none; }
}

/* ── Action8 handoff: monospace numerics (IBM Plex Mono) ─────────── */
.mono, .qr-money, .qr-date { font-family: var(--font-mono); }
.qr-money { font-weight: 600; }

/* ── Deals List View — view toggle, warnings, import wizard, export column picker ── */
.pl-view-toggle { display: flex; gap: 2px; background: var(--surface-alt, var(--bg)); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 2px; }
.pl-view-btn { border: none; background: none; padding: 6px 12px; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); border-radius: 6px; cursor: pointer; }
.pl-view-btn.active { background: var(--accent); color: var(--theme-on-primary, #fff); }
.dl-wrap { padding-top: 4px; }

.dl-select-all-link { font-weight: 400; }
.dl-select-all-link .qr-link { font-weight: 600; }
.dl-bulk-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* WhatsApp click-to-chat in the Actions column — same secondary button as
   Open/Clone, with the brand-green mark. Disabled when no phone is on file. */
.dl-wa { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.dl-wa svg { width: 14px; height: 14px; color: #25D366; flex-shrink: 0; }
.dl-wa[disabled] { opacity: .5; cursor: not-allowed; }
.dl-wa[disabled] svg { color: var(--ink-soft); }

.dl-warning { background: var(--red-light, #FEF2F2); color: var(--red); border: 1px solid var(--red); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 12.5px; margin-bottom: 12px; }
.dl-confirm-list { max-height: 220px; overflow-y: auto; margin: 8px 0 0; padding-left: 20px; font-size: 13px; }
.dl-confirm-list li { margin-bottom: 4px; }

.dl-col-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.dl-col-picker label { display: flex; align-items: center; gap: 8px; padding: 6px 4px; font-size: 12.5px; cursor: pointer; }
.dl-col-picker input { accent-color: var(--accent); }

.dl-import-steps { display: flex; align-items: center; gap: 6px; margin-bottom: 18px; }
.dl-import-step { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; background: var(--surface-alt, var(--bg)); color: var(--ink-soft); border: 1px solid var(--border); }
.dl-import-step.active { background: var(--accent); border-color: var(--accent); color: var(--theme-on-primary, #fff); }
.dl-import-step.done { background: var(--green); border-color: var(--green); color: #fff; }
.dl-import-step-sep { flex: 1; height: 1px; background: var(--border); max-width: 40px; }
.dl-import-table-wrap { max-height: 260px; overflow-y: auto; margin-top: 10px; border-radius: var(--radius-sm); }

/* ── Custom fields (rendered by static/custom-fields.js into record forms,
   plus the /settings/custom-fields builder) ────────────────────── */
.cf-group.cf-invalid input, .cf-group.cf-invalid select, .cf-group.cf-invalid textarea, .cf-group.cf-invalid .cf-multi {
  border-color: var(--red); box-shadow: 0 0 0 3px var(--red-light, rgba(220,38,38,.12));
}
.cf-req { color: var(--red); }
.cf-hint { font-size: 11px; color: var(--ink-soft); margin-top: 4px; }
.cf-error { font-size: 11.5px; color: var(--red); margin-top: 4px; font-weight: 500; }
.cf-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; color: var(--ink); }
.cf-check input { width: auto !important; accent-color: var(--accent); }
.cf-multi {
  display: flex; flex-wrap: wrap; gap: 6px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 11px; background: var(--surface);
}
.cf-section-title {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft);
  margin: 18px 0 8px; padding-top: 12px; border-top: 1px solid var(--border-soft, var(--border));
}

/* Builder page */
.cfb-layout { display: grid; grid-template-columns: 232px 1fr; gap: 20px; align-items: start; }
.cfb-rail { background: var(--surface); border: 1px solid var(--border-soft, var(--border)); border-radius: var(--radius); padding: 8px; }
.cfb-rail-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; text-align: left;
  padding: 9px 11px; border: none; background: none; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 13px; font-weight: 500; color: var(--ink); font-family: inherit;
}
.cfb-rail-item:hover { background: var(--bg); }
.cfb-rail-item.active { background: var(--accent-light, var(--accent-soft)); color: var(--accent); font-weight: 600; }
.cfb-rail-count { font-size: 11px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.cfb-rail-item.active .cfb-rail-count { color: var(--accent); }
.cfb-soon { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
.cfb-panel { background: var(--surface); border: 1px solid var(--border-soft, var(--border)); border-radius: var(--radius); padding: 20px; }
.cfb-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 4px; }
.cfb-banner {
  background: var(--bg); border: 1px dashed var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 12.5px; color: var(--ink-soft); margin: 14px 0;
}
.cfb-list { list-style: none; margin: 0; padding: 0; }
.cfb-row {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border: 1px solid var(--border-soft, var(--border));
  border-radius: var(--radius-sm); margin-bottom: 8px; background: var(--surface);
}
.cfb-row.inactive { opacity: .55; }
.cfb-row.default-field { background: var(--bg); border-style: dashed; }
.cfb-row-main { flex: 1; min-width: 0; }
.cfb-move { display: flex; flex-direction: column; gap: 2px; flex: none; }
.cfb-move button {
  width: 22px; height: 16px; padding: 0; line-height: 1; font-size: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 4px;
  color: var(--ink-soft); cursor: pointer; transition: background .15s;
}
.cfb-move button:hover:not([disabled]) { background: var(--bg); color: var(--ink); }
.cfb-move button[disabled] { opacity: .3; cursor: not-allowed; }
.cfb-row-label { font-size: 13px; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.cfb-row-meta { font-size: 11.5px; color: var(--ink-soft); margin-top: 3px; }
.cfb-key { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--ink-soft); }
.cfb-tag { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 2px 6px; border-radius: 999px; background: var(--bg); color: var(--ink-soft); border: 1px solid var(--border); }
.cfb-tag.req { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.cfb-tag.off { background: #f3f4f6; color: #6b7280; border-color: #e5e7eb; }
.cfb-tag.lock { background: #e0e7ff; color: #3730a3; border-color: #c7d2fe; }
.cfb-tag.warn { background: #fef3c7; color: #92400e; border-color: #fde68a; cursor: help; }
.cfb-tag.cust { background: var(--accent-light, var(--accent-soft)); color: var(--accent); border-color: transparent; }

/* Form Layout Editor */
.cfb-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-soft, var(--border)); margin: 14px 0 4px; }
.cfb-tab {
  padding: 8px 14px; border: none; background: none; cursor: pointer; font-family: inherit;
  font-size: 13px; font-weight: 600; color: var(--ink-soft); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.cfb-tab:hover { color: var(--ink); }
.cfb-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.cfb-hint { font-size: 11.5px; color: var(--ink-soft); line-height: 1.5; margin-bottom: 10px; }
.cfb-layout-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin: 14px 0 6px; }
.cfb-layout-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.cfb-dirty { font-size: 11px; font-weight: 700; color: #92400e; background: #fef3c7; border-radius: 999px; padding: 3px 9px; }
.cfb-cols { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr) 260px; gap: 18px; align-items: start; }
.cfb-drop { min-height: 90px; border-radius: var(--radius-sm); padding: 4px; transition: background .15s; }
.cfb-drop-hidden { border: 1px dashed var(--border); background: var(--bg); }
.cfb-layout-row { touch-action: none; }
.cfb-layout-row .drag-handle {
  cursor: grab; color: var(--faint, var(--ink-soft)); font-size: 15px; line-height: 1; padding: 2px 2px 2px 0; flex-shrink: 0;
}
.cfb-layout-row .drag-handle:active { cursor: grabbing; }
.cfb-layout-row .row-actions button[disabled] { opacity: .4; cursor: not-allowed; }
.cfb-preview {
  border: 1px solid var(--border-soft, var(--border)); border-radius: var(--radius-sm); padding: 14px;
  background: var(--bg); max-height: 520px; overflow-y: auto;
}
.cfb-preview .form-group { margin-bottom: 12px; }
.cfb-preview .form-group label { font-size: 11.5px; font-weight: 500; color: var(--ink-soft); display: block; margin-bottom: 4px; }
.cfb-preview input, .cfb-preview select, .cfb-preview textarea {
  width: 100%; padding: 7px 9px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 12px;
  font-family: inherit; background: var(--surface); color: var(--ink);
}
.cfb-preview .cf-multi { padding: 7px 9px; }
@media (max-width: 1100px) {
  .cfb-cols { grid-template-columns: 1fr; }
}
.cfb-opts { display: flex; flex-direction: column; gap: 6px; }
.cfb-opt-row { display: flex; gap: 6px; align-items: center; }
.cfb-opt-row input { flex: 1; }
.cfb-opt-row button { flex-shrink: 0; }
.cfb-modal { width: 560px; max-height: 88vh; overflow-y: auto; }
.cfb-rules { border: 1px solid var(--border-soft, var(--border)); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 12px; background: var(--bg); }
.cfb-rules-title { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); margin-bottom: 10px; }
.cfb-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cf-col-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.cf-col-picker label { display: flex; align-items: center; gap: 8px; padding: 6px 4px; font-size: 12.5px; cursor: pointer; }
.cf-col-picker input { accent-color: var(--accent); }
@media (max-width: 760px) {
  .cfb-layout { grid-template-columns: 1fr; }
  .cfb-modal { width: auto; }
}

/* ── Email Accounts settings (Inbox feature, Phase 1) ─────────────── */
.ea-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 18px 0 12px; }

.ea-banner { border-radius: var(--radius-sm); padding: 12px 14px; font-size: 12.5px; line-height: 1.6; margin: 16px 0; }
.ea-banner-warn { background: var(--orange-light); color: var(--orange); border: 1px solid var(--orange); }
.ea-banner code { font-family: 'IBM Plex Mono', monospace; font-size: 11.5px; background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 3px; }

.ea-card { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); margin-bottom: 10px; }
.ea-card-main { min-width: 0; flex: 1; }
.ea-card-title { font-size: 13.5px; font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ea-card-sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.ea-card-meta { font-size: 11.5px; color: var(--ink-soft); margin-top: 6px; }
.ea-card-err { font-size: 11.5px; color: var(--red); margin-top: 6px; word-break: break-word; }
.ea-card-actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }

.ea-pill { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .3px; }
.ea-pill-ok  { background: var(--green-light);  color: var(--green); }
.ea-pill-err { background: var(--red-light);    color: var(--red); }
.ea-pill-off { background: var(--line);         color: var(--ink-soft); }
.ea-pill-new { background: var(--accent-light); color: var(--accent); }

.ea-modal { width: 620px; max-width: 94vw; }
.ea-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ea-toggles { display: flex; gap: 20px; margin: 14px 0 4px; }
.ea-check { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--ink); cursor: pointer; }
.ea-check input { accent-color: var(--accent); }

.ea-test { margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 12.5px; line-height: 1.5; }
.ea-test-pending { background: var(--line); color: var(--ink-soft); }
.ea-test-ok  { background: var(--green-light); color: var(--green); }
.ea-test-err { background: var(--red-light);   color: var(--red); }

@media (max-width: 760px) {
  .ea-grid2 { grid-template-columns: 1fr; }
  .ea-card { flex-direction: column; }
}
