/* Bradley Contact Manager — v2
   Fresh Professional theme: emerald, sidebar dashboard, light/dark.
   All colors via semantic HSL CSS variables (shadcn convention). */

:root {
  /* Bradley Images brand: olive gold on near-black, editorial luxury */
  --background: 0 0% 100%;
  --foreground: 215 30% 14%;
  --muted: 210 20% 96%;
  --muted-foreground: 215 16% 47%;
  --border: 214 32% 91%;
  --input: 214 32% 91%;
  --ring: 50 43% 42%;
  --primary: 50 43% 42%;
  --primary-foreground: 0 0% 100%;
  --accent: 50 50% 35%;
  --accent-foreground: 0 0% 100%;
  --destructive: 0 84% 60%;
  --destructive-foreground: 0 0% 100%;
  --card: 0 0% 100%;
  --card-foreground: 222 47% 11%;
  --sidebar: 0 0% 98%;
  --sidebar-foreground: 222 47% 11%;
  --sidebar-border: 214 32% 91%;
  --shadow-sm: 0 1px 2px 0 hsl(222 47% 11% / 0.04);
  --shadow: 0 1px 3px 0 hsl(222 47% 11% / 0.08), 0 1px 2px -1px hsl(222 47% 11% / 0.06);
  --shadow-md: 0 4px 6px -1px hsl(222 47% 11% / 0.08), 0 2px 4px -2px hsl(222 47% 11% / 0.04);
  --radius: 0.5rem;
}

/* ────────────────────────────────────────────────────────────
   CLASSIC theme — v1 editorial look (Playfair + Poppins, olive gold)
   Applied to <html> via class "theme-classic". Same layout, new skin.
   ──────────────────────────────────────────────────────────── */
.theme-classic {
  --background: 0 0% 97%;            /* off-white */
  --foreground: 215 30% 14%;          /* near-black ink */
  --muted: 220 14% 95%;
  --muted-foreground: 215 19% 35%;    /* slate */
  --border: 220 14% 90%;
  --input: 220 14% 90%;
  --ring: 49 44% 41%;                 /* olive gold */
  --primary: 49 44% 41%;
  --primary-foreground: 0 0% 100%;
  --accent: 49 44% 36%;
  --accent-foreground: 0 0% 100%;
  --card: 0 0% 100%;
  --card-foreground: 215 30% 14%;
  --sidebar: 0 0% 99%;
  --sidebar-foreground: 215 30% 14%;
  --sidebar-border: 220 14% 90%;
  --radius: 2px;                      /* sharper corners */
}
.theme-classic body { font-family: 'Poppins', system-ui, sans-serif; }
.theme-classic h1,
.theme-classic h2,
.theme-classic h3,
.theme-classic h4 {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.theme-classic .label,
.theme-classic .nav-group-label {
  font-family: 'Outfit', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.theme-classic .sidebar-logo,
.theme-classic .sidebar-name {
  font-family: 'Playfair Display', Georgia, serif;
}

.dark {
  --background: 215 30% 9%;
  --foreground: 40 30% 92%;
  --muted: 215 25% 16%;
  --muted-foreground: 215 16% 65%;
  --border: 215 25% 18%;
  --input: 215 25% 18%;
  --ring: 50 55% 55%;
  --primary: 50 55% 55%;
  --primary-foreground: 215 30% 9%;
  --accent: 50 50% 48%;
  --accent-foreground: 215 30% 9%;
  --destructive: 0 62% 50%;
  --destructive-foreground: 40 30% 92%;
  --card: 215 30% 12%;
  --card-foreground: 40 30% 92%;
  --sidebar: 215 30% 7%;
  --sidebar-foreground: 40 30% 92%;
  --sidebar-border: 215 25% 15%;
}

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

body {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  color: hsl(var(--foreground));
}
h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }

.label {
  font-family: 'Outfit', sans-serif;
  font-weight: 500;
  font-size: 13px;
  color: hsl(var(--muted-foreground));
  letter-spacing: 0;
  text-transform: none;
}

a { color: hsl(var(--primary)); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

input, select, textarea {
  font-family: inherit; font-size: 15px;
  color: hsl(var(--foreground));
}

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 14px;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
.btn-primary:hover { background: hsl(var(--accent)); }

.btn-secondary {
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  border-color: hsl(var(--border));
}
.btn-secondary:hover { background: hsl(var(--muted)); }

.btn-ghost {
  background: transparent;
  color: hsl(var(--muted-foreground));
}
.btn-ghost:hover { background: hsl(var(--muted)); color: hsl(var(--foreground)); }

.btn-danger {
  background: hsl(var(--card));
  color: hsl(var(--destructive));
  border-color: hsl(var(--border));
}
.btn-danger:hover { background: hsl(var(--destructive)); color: hsl(var(--destructive-foreground)); border-color: hsl(var(--destructive)); }

.btn-icon {
  padding: 8px;
  width: 36px;
  height: 36px;
}

/* ----- Card / Input ----- */
.card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  background: hsl(var(--background));
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.15);
}

/* ----- Badges ----- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  border: 1px solid transparent;
  letter-spacing: 0;
  text-transform: none;
}
.badge-primary { background: hsl(var(--primary) / 0.12); color: hsl(var(--primary)); }
.badge-green   { background: hsl(142 76% 36% / 0.12); color: hsl(142 76% 30%); }
.badge-blue    { background: hsl(212 90% 50% / 0.12); color: hsl(212 90% 45%); }
.badge-red     { background: hsl(var(--destructive) / 0.12); color: hsl(var(--destructive)); }
.badge-amber   { background: hsl(38 92% 50% / 0.15); color: hsl(28 80% 35%); }

/* ----- Layout: sidebar dashboard ----- */
.shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}
.shell.collapsed { grid-template-columns: 64px 1fr; }

.sidebar {
  background: hsl(var(--sidebar));
  color: hsl(var(--sidebar-foreground));
  border-right: 1px solid hsl(var(--sidebar-border));
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-header {
  padding: 18px 20px;
  border-bottom: 1px solid hsl(var(--sidebar-border));
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}
.sidebar-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; }
.sidebar-name small { display: block; font-weight: 400; color: hsl(var(--muted-foreground)); font-size: 11px; }

.sidebar-nav { padding: 14px 12px; flex: 1; overflow-y: auto; }
.nav-group-label {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: hsl(var(--muted-foreground));
  padding: 12px 10px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: hsl(var(--sidebar-foreground));
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.12s;
  margin-bottom: 2px;
}
.nav-item:hover { background: hsl(var(--muted)); text-decoration: none; }
.nav-item.active {
  background: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
}
.ico { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item .ico { width: 16px; height: 16px; }

/* Constrain any inline SVG inside buttons */
.btn svg, .sidebar-footer .btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar-footer {
  border-top: 1px solid hsl(var(--sidebar-border));
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-footer .btn {
  justify-content: flex-start;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 500;
  width: 100%;
}

.shell.collapsed .sidebar-name,
.shell.collapsed .nav-group-label,
.shell.collapsed .nav-item span,
.shell.collapsed .sidebar-footer .btn span { display: none; }

/* ----- Main column ----- */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: hsl(var(--background) / 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid hsl(var(--border));
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.topbar-title h1 { line-height: 1.2; }
.topbar-title p { margin: 4px 0 0; color: hsl(var(--muted-foreground)); font-size: 13px; }

.content { padding: 24px 28px; flex: 1; }

@media (max-width: 880px) {
  .shell { grid-template-columns: 64px 1fr; }
  .shell .sidebar-name, .shell .nav-group-label, .shell .nav-item span, .shell .sidebar-footer .btn span { display: none; }
}

/* ───────── MOBILE: off-canvas sidebar + reflow ───────── */
.mobile-menu-btn { display: none; }
.mobile-nav-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 90;
}
.mobile-nav-open .mobile-nav-backdrop { display: block; }

@media (max-width: 768px) {
  /* Sidebar becomes off-canvas drawer */
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.18);
  }
  .mobile-nav-open .sidebar { transform: translateX(0); }
  /* Inside the drawer, restore full labels even when desktop "collapsed" */
  .sidebar .sidebar-name,
  .sidebar .nav-group-label,
  .sidebar .nav-item span,
  .sidebar-footer .btn span { display: inline !important; }

  .mobile-menu-btn { display: inline-flex; }

  /* Desktop-only concept; meaningless inside the phone drawer */
  #collapseBtn { display: none; }

  /* Topbar: scrolls away (vertical space is precious on a phone); the
     hamburger stays reachable as a fixed floating pill. Left padding
     reserves the pill's slot so the title never sits under it. */
  .topbar { position: static; padding: 14px 16px; flex-wrap: wrap; gap: 10px; }
  .topbar-title { padding-left: 52px; }
  .mobile-menu-btn {
    position: fixed;
    top: max(10px, env(safe-area-inset-top));
    left: 12px;
    z-index: 80;
    width: 44px;
    height: 44px;
    border-radius: 999px;
    background: hsl(var(--background) / 0.92);
    backdrop-filter: blur(8px);
    border: 1px solid hsl(var(--border));
    box-shadow: var(--shadow-md);
  }
  .topbar-title h1 { font-size: 20px; }
  .topbar-title p  { font-size: 12px; }
  /* Action row wraps into a tidy 2-up grid instead of running off-screen */
  .topbar > div:last-child { width: 100%; flex-wrap: wrap; }
  .topbar > div:last-child .btn { flex: 1 1 40%; min-height: 44px; }
  .topbar > div:last-child .label { flex: 1 1 100%; margin-right: 0 !important; }

  /* iOS zooms the page on focus when an input's font is under 16px */
  input, textarea, select, .sort-select { font-size: 16px; }

  .content { padding: 16px; }

  /* Tabs scroll horizontally on touch, and ONLY horizontally. overflow-x:auto
     implicitly makes the strip a vertical scroller too, and the tabs' -1px
     underline overlap gives it 1px of vertical overflow; iOS then lets a
     finger drag and rubber-band the whole bar in any direction. */
  .tabs {
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex-shrink: 0; min-height: 44px; }
  /* .tabs .tab outranks the base .tab rule that sets -1px (it sits later
     in this file); that -1px is the strip's only vertical overflow */
  .tabs .tab { margin-bottom: 0; }

  /* Event filter pills: even grid (7 pills → 4+3 here, and 2-per-row with a
     full-width last pill on narrow phones below). !important because the pills
     carry inline flex styles. */
  .event-pills {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px !important;
  }
  .event-pills button {
    justify-content: center;
    min-width: 0;
    min-height: 44px;
    padding: 8px 4px !important;
    font-size: 12px !important;
    white-space: nowrap;
  }

  /* Stat strip: compact 2×2, not four full-width cards */
  .stat-strip { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
  .stat { padding: 12px 14px; }
  .stat .num { font-size: 20px; }
  .stat .lbl { font-size: 11px; }

  /* Toast: full-width strip above the thumb zone */
  .toast {
    left: 16px;
    right: 16px;
    bottom: max(16px, env(safe-area-inset-bottom));
    text-align: center;
  }

  /* Table is replaced by cards below 900px (see TABLE_MIN_WIDTH) — no
     horizontal-scroll table on mobile. Toggle is hidden since it's moot. */

  /* Search row reflows */
  .search-row { flex-wrap: wrap; gap: 10px; }
  .search-row input { flex: 1 1 100%; min-height: 44px; }
  .search-row .toggle-group { width: 100%; justify-content: stretch; }
  .search-row .toggle-group button { flex: 1; min-height: 38px; }

  /* Buttons get bigger touch targets */
  .btn { min-height: 44px; padding: 10px 16px; }
  .nav-item { min-height: 44px; }

  /* Worklist card actions (Inbox, Follow-ups): equal-width buttons in a
     2-up grid so they fill the card instead of wrapping into a loose pile */
  .card-actions { width: 100%; }
  .card-actions .btn { flex: 1 1 40%; min-height: 42px; }

  /* Modals fill the screen */
  #briefingBackdrop,
  #contractPreviewBackdrop,
  #viewMessageBackdrop {
    padding: 0 !important;
    align-items: stretch !important;
  }
  #briefingBackdrop > div,
  #contractPreviewBackdrop > div,
  #viewMessageBackdrop > div {
    max-width: 100% !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    height: 100vh;
  }
  .briefing-sheet { padding: 18px !important; }

  /* Contact detail header reflows */
  .avatar-lg { width: 56px; height: 56px; font-size: 20px; }

  /* Compose toolbar: let it wrap rather than scroll */
  [data-fmt] { flex: 0 0 auto; }
}

@media (max-width: 480px) {
  .topbar-title h1 { font-size: 18px; }
  .content { padding: 14px 12px; }
  /* Narrow phones: 2-per-row; the odd last pill spans the full width so the
     grid never leaves a lone half-row. */
  .event-pills { grid-template-columns: repeat(2, 1fr); }
  .event-pills button:last-child { grid-column: 1 / -1; }
}


/* ----- Tables ----- */
.t { width: 100%; border-collapse: collapse; }
.t th, .t td {
  text-align: left;
  padding: 14px 18px;
  border-bottom: 1px solid hsl(var(--border));
  font-size: 15px;
}
.t th {
  font-weight: 500;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--muted));
  border-bottom: 1px solid hsl(var(--border));
}
.t tbody tr { transition: background 0.1s ease; cursor: pointer; }
.t tbody tr:hover { background: hsl(var(--muted) / 0.5); }

/* Hide the Table/Grid toggle where the table can't render anyway */
@media (max-width: 899px) {
  .search-row .toggle-group { display: none; }
}

/* ----- Grid ----- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
@media (max-width: 480px) {
  .grid { grid-template-columns: 1fr; gap: 12px; }
}
.contact-card {
  padding: 18px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.contact-card:hover { border-color: hsl(var(--primary) / 0.4); box-shadow: var(--shadow); }

/* ----- Drawer ----- */
.drawer-overlay {
  position: fixed; inset: 0;
  background: hsl(var(--foreground) / 0.4);
  z-index: 40;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 480px; max-width: 92vw;
  background: hsl(var(--background));
  border-left: 1px solid hsl(var(--border));
  box-shadow: var(--shadow-md);
  z-index: 50;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-header { padding: 20px 24px; border-bottom: 1px solid hsl(var(--border)); }
.drawer-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.drawer-footer {
  padding: 14px 24px;
  border-top: 1px solid hsl(var(--border));
  display: flex; justify-content: flex-end; gap: 10px;
}

/* ----- Tabs ----- */
.tabs {
  display: flex;
  border-bottom: 1px solid hsl(var(--border));
  gap: 4px;
  margin-bottom: 18px;
}
.tab {
  padding: 10px 16px;
  font-weight: 500;
  font-size: 13px;
  color: hsl(var(--muted-foreground));
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  border-radius: var(--radius) var(--radius) 0 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.tab:hover { color: hsl(var(--foreground)); background: hsl(var(--muted) / 0.5); }
.tab.active { color: hsl(var(--primary)); border-bottom-color: hsl(var(--primary)); }

/* ----- Inline edit fields ----- */
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: background 0.12s ease;
}
.field:hover { background: hsl(var(--muted) / 0.6); }
.field.editing { background: hsl(var(--background)); border-color: hsl(var(--ring)); }
.field .v {
  font-size: 14px;
  color: hsl(var(--foreground));
  min-height: 18px;
  font-weight: 500;
}
.field .v.empty { color: hsl(var(--muted-foreground)); font-weight: 400; font-style: normal; }
.field input, .field textarea, .field select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid hsl(var(--ring));
  border-radius: 6px;
  background: hsl(var(--background));
}

/* ----- Avatar ----- */
.avatar {
  width: 40px; height: 40px;
  border-radius: 999px;
  background: hsl(var(--primary) / 0.12);
  color: hsl(var(--primary));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}
.avatar-lg { width: 64px; height: 64px; font-size: 22px; }

/* ----- Skeleton ----- */
.skel {
  background: linear-gradient(90deg, hsl(var(--muted)) 0%, hsl(var(--muted) / 0.4) 50%, hsl(var(--muted)) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: 4px;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ----- Toast ----- */
.toast {
  position: fixed;
  bottom: 20px; right: 20px;
  background: hsl(var(--foreground));
  color: hsl(var(--background));
  padding: 11px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  z-index: 100;
  opacity: 0; transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
/* A toast carrying a live control (the touch-log Undo) must accept clicks —
   plain message toasts keep pointer-events:none so they never block the UI. */
.toast.actionable { pointer-events: auto; }

/* ----- Sections on detail page ----- */
.section {
  padding: 20px 24px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.section h3 {
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid hsl(var(--border));
}

.two-col   { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.three-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 720px) {
  .two-col, .three-col { grid-template-columns: 1fr; }
  .drawer { width: 100vw; max-width: 100vw; }
}

/* ----- Login ----- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: hsl(var(--muted));
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  padding: 32px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}
.login-card .brand-bar {
  display: flex; align-items: center; gap: 12px; margin-bottom: 24px;
}
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card p { color: hsl(var(--muted-foreground)); margin: 0 0 24px; font-size: 13px; }

.hidden { display: none !important; }

/* ----- Stat strip on contacts page ----- */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat {
  padding: 16px 18px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
}
.stat .num { font-size: 22px; font-weight: 700; margin-top: 4px; }
.stat .lbl { font-size: 12px; color: hsl(var(--muted-foreground)); }
/* Clickable worklist stat tiles — read as links, lift on hover. */
.stat-link {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.stat-link:hover {
  border-color: #998E3C;
  box-shadow: 0 0 0 3px rgba(153, 142, 60, 0.14);
}

/* ----- Search bar ----- */
.search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.search-row input {
  border: none; background: transparent; flex: 1;
  padding: 4px 4px; outline: none;
}

/* ----- Sort select ----- */
.sort-select {
  flex: 0 0 auto;
  padding: 6px 28px 6px 10px;
  font-size: 12px;
  font-weight: 500;
  color: hsl(var(--foreground));
  background: hsl(var(--muted));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234A5568' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 13px;
}

/* ----- Toggle group ----- */
.toggle-group {
  display: inline-flex;
  background: hsl(var(--muted));
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
}
.toggle-group button {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
}
.toggle-group button.active {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  box-shadow: var(--shadow-sm);
}

/* ----- Compose: contenteditable placeholder ----- */
#composeBody:empty::before {
  content: attr(data-placeholder);
  color: hsl(var(--muted-foreground));
  pointer-events: none;
}
#composeBody a { color: hsl(var(--primary)); text-decoration: underline; }
#composeBody ul, #composeBody ol { padding-left: 22px; margin: 6px 0; }

/* ----- Briefing modal: print isolates the sheet only ----- */
@media print {
  body.printing-briefing > *:not(#app) { display: none !important; }
  body.printing-briefing .briefing-backdrop {
    position: static !important;
    background: transparent !important;
    padding: 0 !important;
    display: block !important;
  }
  body.printing-briefing .briefing-modal {
    box-shadow: none !important;
    border-radius: 0 !important;
    max-height: none !important;
    max-width: 100% !important;
  }
  body.printing-briefing .briefing-toolbar { display: none !important; }
  body.printing-briefing .briefing-sheet { padding: 0 !important; max-height: none !important; }
  body.printing-briefing .shell,
  body.printing-briefing .sidebar,
  body.printing-briefing .topbar { display: none !important; }
}

/* Pipeline progress dots — instant CSS tooltip */
.pdot { position: relative; display: inline-block; }
.pdot .pdot-tip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1A202C;
  color: #fff;
  font-family: 'Outfit', system-ui, sans-serif;
  font-size: 11px;
  line-height: 1.4;
  letter-spacing: 0.3px;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 3px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.1s ease;
  z-index: 50;
  pointer-events: none;
}
.pdot .pdot-tip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: #1A202C;
}
.pdot:hover .pdot-tip { opacity: 1; visibility: visible; }

/* ════════════════════════════════════════════════════════════════════
   SIGNATURE  ·  high-end "lux" skin   (class "theme-lux" on <html>)
   Warm ivory gallery canvas · dramatic ink sidebar with gold foil ·
   Playfair display type · layered shadows · refined micro-interactions.
   Shares the exact same layout — zero markup/feature changes.
   ════════════════════════════════════════════════════════════════════ */
.theme-lux {
  --background: 40 36% 96.5%;          /* warm ivory / parchment */
  --foreground: 215 33% 12%;           /* deep ink */
  --muted: 40 24% 92%;
  --muted-foreground: 215 14% 38%;     /* refined slate */
  --border: 40 20% 87%;
  --input: 40 20% 86%;

  --ring: 45 48% 44%;
  --primary: 45 47% 40%;               /* olive gold */
  --primary-foreground: 40 40% 98%;
  --accent: 43 60% 50%;                /* brighter foil gold */
  --accent-foreground: 215 33% 12%;

  --card: 0 0% 100%;
  --card-foreground: 215 33% 12%;

  /* Dramatic dark ink sidebar against the light content */
  --sidebar: 215 36% 10%;
  --sidebar-foreground: 40 30% 90%;
  --sidebar-border: 215 24% 20%;

  --destructive: 0 68% 50%;
  --destructive-foreground: 40 40% 98%;

  --radius: 3px;

  /* Softer, layered, warmer shadows */
  --shadow-sm: 0 1px 2px hsl(40 30% 20% / 0.05);
  --shadow: 0 2px 4px hsl(40 30% 20% / 0.06), 0 1px 2px hsl(40 30% 20% / 0.05);
  --shadow-md: 0 10px 30px -12px hsl(215 40% 18% / 0.20), 0 2px 6px hsl(40 30% 20% / 0.05);

  --gold-grad: linear-gradient(135deg, hsl(45 55% 52%), hsl(42 46% 38%));
  --gold-soft: linear-gradient(135deg, hsl(46 60% 60%), hsl(43 48% 42%));
}

/* Warm ambient canvas + whisper-fine grain */
.theme-lux body {
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(1200px 700px at 82% -8%, hsl(45 55% 70% / 0.12), transparent 60%),
    radial-gradient(900px 600px at -8% 108%, hsl(215 40% 60% / 0.06), transparent 55%),
    hsl(var(--background));
  background-attachment: fixed;
}
.theme-lux body::before {
  content: '';
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
}
.theme-lux .shell { position: relative; z-index: 1; }

/* ── Editorial typography ── */
.theme-lux h1, .theme-lux h2, .theme-lux h3,
.theme-lux .topbar-title h1,
.theme-lux .login-card h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.theme-lux .topbar-title h1 { font-size: 30px; }
.theme-lux .nav-group-label,
.theme-lux .label {
  font-family: 'Outfit', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 10.5px;
  font-weight: 600;
}

/* ── Topbar: frosted ivory with hairline ── */
.theme-lux .topbar {
  background: hsl(40 36% 97% / 0.78);
  backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid hsl(var(--border));
  box-shadow: 0 1px 0 hsl(0 0% 100% / 0.6);
}
.theme-lux .topbar-title p { letter-spacing: 0.01em; }

/* Subtle entrance for page content */
.theme-lux .content > * { animation: luxRise 0.5s cubic-bezier(0.16, 1, 0.3, 1) both; }
@keyframes luxRise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ── Cards: gallery plates ── */
.theme-lux .card {
  background: hsl(var(--card));
  border: 1px solid hsl(40 22% 89%);
  box-shadow: var(--shadow-md);
  position: relative;
  transition: transform 0.28s cubic-bezier(0.16,1,0.3,1), box-shadow 0.28s ease, border-color 0.28s ease;
}
.theme-lux .card::before {
  content: '';
  position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: var(--gold-grad);
  opacity: 0;
  transition: opacity 0.28s ease;
  border-radius: var(--radius) var(--radius) 0 0;
}
.theme-lux .card:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 40px -18px hsl(215 40% 18% / 0.28), 0 3px 8px hsl(40 30% 20% / 0.06);
  border-color: hsl(45 40% 78%);
}
.theme-lux .card:hover::before { opacity: 0.9; }

/* ── Buttons: brushed gold ── */
.theme-lux .btn { letter-spacing: 0.01em; font-weight: 600; }
.theme-lux .btn-primary {
  background: var(--gold-grad);
  color: hsl(40 40% 98%);
  box-shadow: 0 1px 0 hsl(46 60% 70% / 0.6) inset, 0 6px 16px -6px hsl(45 50% 35% / 0.55);
  border: none;
}
.theme-lux .btn-primary:hover { background: var(--gold-soft); filter: saturate(1.08); transform: translateY(-1px); }
.theme-lux .btn-primary:active { transform: translateY(0); }
.theme-lux .btn-secondary {
  background: hsl(0 0% 100% / 0.7);
  border-color: hsl(40 22% 84%);
  backdrop-filter: blur(4px);
}
.theme-lux .btn-secondary:hover { background: hsl(45 40% 96%); border-color: hsl(45 40% 72%); }

/* ── Inputs ── */
.theme-lux .input {
  background: hsl(40 30% 99%);
  border-color: hsl(var(--input));
}
.theme-lux .input:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.16);
}

/* ── Badges ── */
.theme-lux .badge { letter-spacing: 0.02em; font-weight: 600; }
.theme-lux .badge-primary {
  background: linear-gradient(135deg, hsl(45 55% 52% / 0.16), hsl(43 48% 42% / 0.12));
  color: hsl(43 55% 30%);
}

/* ── Sidebar: ink slab with gold foil ── */
.theme-lux .sidebar {
  background:
    linear-gradient(180deg, hsl(215 38% 12%), hsl(215 40% 8%));
  border-right: 1px solid hsl(215 30% 16%);
  box-shadow: inset -1px 0 0 hsl(45 40% 60% / 0.06);
}
.theme-lux .sidebar-header { border-bottom-color: hsl(215 24% 18%); }
.theme-lux .sidebar-logo {
  background: var(--gold-grad);
  color: hsl(215 40% 10%);
  border-radius: 7px;
  box-shadow: 0 4px 14px -4px hsl(45 60% 45% / 0.65), 0 1px 0 hsl(46 70% 75% / 0.7) inset;
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 700;
}
.theme-lux .sidebar-name { font-family: 'Playfair Display', Georgia, serif; letter-spacing: 0.01em; }
.theme-lux .sidebar-name small {
  font-family: 'Outfit', sans-serif;
  color: hsl(45 30% 62%);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 9.5px;
  margin-top: 2px;
}
.theme-lux .nav-group-label { color: hsl(40 16% 52%); }

/* Nav items on the dark slab */
.theme-lux .nav-item {
  color: hsl(40 26% 82%);
  position: relative;
  transition: background 0.18s ease, color 0.18s ease;
}
.theme-lux .nav-item:hover { background: hsl(45 40% 60% / 0.08); color: hsl(45 50% 80%); }
.theme-lux .nav-item.active {
  background: linear-gradient(90deg, hsl(45 50% 55% / 0.18), hsl(45 50% 55% / 0.04));
  color: hsl(45 65% 72%);
}
.theme-lux .nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 6px; bottom: 6px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--gold-grad);
  box-shadow: 0 0 12px hsl(45 60% 55% / 0.7);
}

/* Sidebar footer controls re-tuned for the dark slab */
.theme-lux .sidebar-footer { border-top-color: hsl(215 24% 18%); }
.theme-lux .sidebar-footer .btn-ghost { color: hsl(40 18% 64%); }
.theme-lux .sidebar-footer .btn-ghost:hover { background: hsl(45 40% 60% / 0.10); color: hsl(45 50% 80%); }

/* Custom sidebar scrollbar */
.theme-lux .sidebar-nav::-webkit-scrollbar { width: 6px; }
.theme-lux .sidebar-nav::-webkit-scrollbar-thumb { background: hsl(45 30% 50% / 0.25); border-radius: 99px; }

/* ── Avatars: gold ring ── */
.theme-lux .avatar, .theme-lux .avatar-lg {
  background: linear-gradient(135deg, hsl(215 33% 16%), hsl(215 36% 11%));
  color: hsl(45 55% 70%);
  box-shadow: 0 0 0 1.5px hsl(45 50% 55% / 0.55), var(--shadow-sm);
}

/* ── Toast ── */
.theme-lux .toast {
  background: linear-gradient(180deg, hsl(215 36% 14%), hsl(215 40% 10%));
  color: hsl(40 30% 92%);
  border: 1px solid hsl(45 40% 55% / 0.25);
  box-shadow: 0 14px 40px -12px hsl(215 50% 8% / 0.55);
}

/* ── Login: framed gallery card ── */
.theme-lux .login-wrap {
  background:
    radial-gradient(1000px 600px at 80% -10%, hsl(45 55% 65% / 0.16), transparent 60%),
    hsl(var(--background));
}
.theme-lux .login-card {
  border: 1px solid hsl(40 22% 86%);
  box-shadow: 0 30px 70px -30px hsl(215 40% 18% / 0.35);
}
.theme-lux .login-card::after {
  content: '';
  position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: var(--gold-grad);
}
.theme-lux .login-card { position: relative; overflow: hidden; }

/* Drawer refinement */
.theme-lux .drawer { box-shadow: -24px 0 60px -24px hsl(215 50% 12% / 0.4); }
.theme-lux .drawer-header { border-bottom-color: hsl(var(--border)); }
