/* Preline redesign — design tokens mapped to Tailwind/Preline's neutral
   palette (gray-50 surfaces, gray-200 rules, blue-600 primary) and softer
   radii (rounded-lg inputs/buttons, rounded-xl cards). Component blocks
   below consume these vars, so the whole UI re-skins from here. */
:root {
  /* ─── PALETTE SCALES — single source of truth ─────────────────────────
     The numbered Tailwind/Preline scales (blue/gray/neutral) live here as
     space-separated RGB channels so BOTH styling layers read one definition:
       • tailwind.config.js maps each step to rgb(var(--blue-600)/<alpha-value>)
         so utility classes (bg-blue-600, dark:bg-neutral-800, the /50 opacity
         modifier) resolve from these vars;
       • the bespoke semantic tokens below alias the same vars.
     Channels (not hex) are required for Tailwind's <alpha-value> to slot in.
     This is a FIXED palette — do NOT redefine it under .dark: dark mode flips
     via `dark:` utility variants + html.dark overrides, not by mutating the
     scale. Values = Chatwoot v4 brand #2781F6 on Radix slate. */
  --blue-50: 237 244 254;  --blue-100: 218 236 255; --blue-200: 186 213 251;
  --blue-300: 143 186 249; --blue-400: 93 156 248;  --blue-500: 61 143 247;
  --blue-600: 39 129 246;  --blue-700: 29 111 224;  --blue-800: 26 92 192;
  --blue-900: 23 74 153;   --blue-950: 15 57 102;
  --gray-50: 249 249 251;  --gray-100: 240 240 243; --gray-200: 232 232 236;
  --gray-300: 217 217 224; --gray-400: 185 187 198; --gray-500: 139 141 152;
  --gray-600: 96 100 108;  --gray-700: 73 77 85;    --gray-800: 28 32 36;
  --gray-900: 21 23 26;    --gray-950: 16 17 19;
  --neutral-50: 250 250 251;  --neutral-100: 244 245 246; --neutral-200: 237 238 240;
  --neutral-300: 213 216 221; --neutral-400: 176 180 186; --neutral-500: 105 110 119;
  --neutral-600: 67 72 78;    --neutral-700: 54 58 63;    --neutral-800: 33 34 37;
  --neutral-900: 24 25 27;    --neutral-950: 17 17 19;

  /* Chatwoot v4 semantic tokens (dashboard/assets/scss/_next-colors.scss +
     theme/colors.js `n:` map): n-background page, n-card panels, n-weak
     borders, slate-11/12 text, fixed brand #2781F6. Tokens whose value equals
     a scale step above alias it (rgb(var(--…))) so there's one definition. */
  --bg:        #f7f7f7;   /* n-background */
  --bg-soft:   rgb(var(--gray-100));   /* slate-3 */
  --panel:     #ffffff;   /* n-card / n-solid-1 */
  --side-bg:   #ffffff;
  --ink:       rgb(var(--gray-800));   /* slate-12 */
  --ink-soft:  rgb(var(--gray-600));   /* slate-11 */
  --muted:     #80838d;   /* slate-10 */
  --rule:      #eaeaea;   /* n-weak */
  --rule-soft: rgb(var(--gray-100));   /* slate-3 */
  --accent:    rgb(var(--blue-600));   /* n-brand (fixed across themes) */
  --accent-hover: rgb(var(--blue-700));
  --accent-soft: rgb(var(--blue-50));
  --accent-ink:  #ffffff;
  --ok:        #16a34a;   /* green-600 */
  --ok-soft:   #dcfce7;   /* green-100 */
  --warn:      #d97706;   /* amber-600 */
  --warn-soft: #fef3c7;   /* amber-100 */
  --bad:       #dc2626;   /* red-600  */
  --bad-soft:  #fee2e2;   /* red-100  */
  --info:      #2f81f6;
  --info-soft: #dceafd;   /* blue-100 */
  --side-w:    208px;     /* Chatwoot v4 labeled sidebar (Sidebar.vue w-[200px]) */
  --settings-rail-w: 230px; /* settings sub-nav rail, sits right of the sidebar */
  --radius:    12px;      /* rounded-xl — cards/tables/panels */
  --radius-sm: 8px;       /* rounded-lg — buttons/inputs/chips */

  /* Form-control base tokens (consumed by the vendored element base below;
     dark values live in html.dark). */
  --field-bg:          #ffffff;
  --field-border:      rgb(var(--gray-500));
  --field-placeholder: rgb(var(--gray-500));
  --check-border:      rgb(var(--gray-500));

  /* Aliases for bespoke inline styles (tasks board/editor) that reference
     these names; point them at the themable tokens so they flip in dark. */
  --border:    var(--rule);
  --surface-2: var(--bg-soft);

  /* Preline-style elevation */
  --shadow-xs: 0 1px 2px 0 rgba(0,0,0,0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0,0,0,0.07), 0 1px 2px -1px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
  --ring:      0 0 0 4px var(--accent-soft);

  --sans:  'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --mono:  'Geist Mono', ui-monospace, Menlo, monospace;
}

/* ─── Form-control element base — vendored from @tailwindcss/forms 0.5.9 (MIT)
   output, which is no longer in the Tailwind build. Colors are lifted to the
   --field-* and --check-border tokens so dark mode flips here, replacing the old
   high-specificity `html.dark input` override. Selectors are element-anchored
   with :where() — (0,0,1), one focus/checked pseudo-class at most — so any
   utility or component class beats this base without specificity games.
   Later rules in this file win equal-specificity ties, same as when this base
   lived in tw.css (loaded before app.css). ─── */
input:where([type=date],[type=datetime-local],[type=email],[type=month],[type=number],[type=password],[type=search],[type=tel],[type=text],[type=time],[type=url],[type=week],:not([type])),
select,
textarea {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-color: var(--field-bg);
  border-color: var(--field-border);
  border-width: 1px;
  border-radius: 0;
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  line-height: 1.5rem;
  color: var(--ink);
  --tw-shadow: 0 0 #0000;
}
input:where([type=date],[type=datetime-local],[type=email],[type=month],[type=number],[type=password],[type=search],[type=tel],[type=text],[type=time],[type=url],[type=week],:not([type])):focus,
select:focus,
textarea:focus {
  outline: 2px solid transparent;
  outline-offset: 2px;
  --tw-ring-inset: var(--tw-empty,/*!*/ /*!*/);
  --tw-ring-offset-width: 0px;
  --tw-ring-offset-color: #fff;
  --tw-ring-color: var(--accent);
  --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
  --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);
  box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
  border-color: var(--accent);
}
input::placeholder,
textarea::placeholder {
  color: var(--field-placeholder);
  opacity: 1;
}
::-webkit-datetime-edit-fields-wrapper { padding: 0; }
::-webkit-date-and-time-value { min-height: 1.5em; text-align: inherit; }
::-webkit-datetime-edit { display: inline-flex; }
::-webkit-datetime-edit,
::-webkit-datetime-edit-year-field,
::-webkit-datetime-edit-month-field,
::-webkit-datetime-edit-day-field,
::-webkit-datetime-edit-hour-field,
::-webkit-datetime-edit-minute-field,
::-webkit-datetime-edit-second-field,
::-webkit-datetime-edit-millisecond-field,
::-webkit-datetime-edit-meridiem-field { padding-top: 0; padding-bottom: 0; }
select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%238B8D98' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
[multiple],
[size]:where(select:not([size="1"])) {
  background-image: none;
  background-position: 0 0;
  background-repeat: unset;
  background-size: initial;
  padding-right: 0.75rem;
  -webkit-print-color-adjust: unset;
  print-color-adjust: unset;
}
input:where([type=checkbox]),
input:where([type=radio]) {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding: 0;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  display: inline-block;
  vertical-align: middle;
  background-origin: border-box;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  flex-shrink: 0;
  height: 1rem;
  width: 1rem;
  color: var(--accent);
  background-color: var(--field-bg);
  border-color: var(--check-border);
  border-width: 1px;
  --tw-shadow: 0 0 #0000;
}
input:where([type=checkbox]) { border-radius: 0; }
input:where([type=radio]) { border-radius: 100%; }
input:where([type=checkbox]):focus,
input:where([type=radio]):focus {
  outline: 2px solid transparent;
  outline-offset: 2px;
  --tw-ring-inset: var(--tw-empty,/*!*/ /*!*/);
  --tw-ring-offset-width: 2px;
  --tw-ring-offset-color: #fff;
  --tw-ring-color: var(--accent);
  --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
  --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);
  box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
}
input:where([type=checkbox]):checked,
input:where([type=radio]):checked {
  border-color: transparent;
  background-color: currentColor;
  background-size: 100% 100%;
  background-position: 50%;
  background-repeat: no-repeat;
}
input:where([type=checkbox]):checked {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 16 16'%3E%3Cpath d='M12.207 4.793a1 1 0 0 1 0 1.414l-5 5a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L6.5 9.086l4.293-4.293a1 1 0 0 1 1.414 0'/%3E%3C/svg%3E");
}
@media (forced-colors: active) {
  [type=checkbox]:checked { -webkit-appearance: auto; -moz-appearance: auto; appearance: auto; }
}
input:where([type=radio]):checked {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='3'/%3E%3C/svg%3E");
}
@media (forced-colors: active) {
  [type=radio]:checked { -webkit-appearance: auto; -moz-appearance: auto; appearance: auto; }
}
input:where([type=checkbox]):checked:focus,
input:where([type=checkbox]):checked:hover,
input:where([type=radio]):checked:focus,
input:where([type=radio]):checked:hover {
  border-color: transparent;
  background-color: currentColor;
}
input:where([type=checkbox]):indeterminate {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 16 16'%3E%3Cpath stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 8h8'/%3E%3C/svg%3E");
  border-color: transparent;
  background-color: currentColor;
  background-size: 100% 100%;
  background-position: 50%;
  background-repeat: no-repeat;
}
@media (forced-colors: active) {
  [type=checkbox]:indeterminate { -webkit-appearance: auto; -moz-appearance: auto; appearance: auto; }
}
input:where([type=checkbox]):indeterminate:focus,
input:where([type=checkbox]):indeterminate:hover {
  border-color: transparent;
  background-color: currentColor;
}
input:where([type=file]) {
  background: unset;
  border-color: inherit;
  border-width: 0;
  border-radius: 0;
  padding: 0;
  font-size: unset;
  line-height: inherit;
}
input:where([type=file]):focus {
  outline: 1px solid ButtonText;
  outline: 1px auto -webkit-focus-ring-color;
}
/* ─── end vendored form base ─── */

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss03';
}

/* Boosted-nav progress: the glue script in layout.html adds .nav-loading to
   <html> while a boosted request has been in flight >150ms. */
html.nav-loading::before {
  content: ""; position: fixed; top: 0; left: 0; width: 40vw; height: 2px; z-index: 200;
  background: linear-gradient(90deg, transparent, var(--accent) 40%, var(--accent) 60%, transparent);
  animation: nav-loading-slide 1.1s ease-in-out infinite;
}
@keyframes nav-loading-slide {
  from { transform: translateX(-40vw); }
  to   { transform: translateX(100vw); }
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }

main { max-width: 1100px; margin: 2rem auto; padding: 0 1.5rem; }
main.with-sidebar { max-width: none; margin: 0 0 0 var(--side-w); padding: 1.5rem 1.25rem 3rem; }

/* The fixed notification bell occupies the top-right corner; give admin pages
   a right gutter so their own header buttons (e.g. "New booking") never sit
   under it. Scoped via :has so portal pages (no bell) keep full width. */
@media (min-width: 901px) {
  body:has(> #notif-bell) main.with-sidebar { padding-right: 4.5rem; }
}

/* Settings rail: a second fixed column right of the app sidebar. Pages opt in
   by rendering the settings_rail partial as the first child of <main>; the
   :has() selector widens the content margin without touching layout.html.
   Visual styling (colors, spacing of links) lives in the partial's utility
   classes; only the column layout is bespoke because it mirrors .sidebar. */
.settings-rail {
  position: fixed; inset: 0 auto 0 var(--side-w);
  width: var(--settings-rail-w);
  background: var(--panel);
  border-right: 1px solid var(--rule);
  overflow-y: auto; z-index: 30;
}
main.with-sidebar:has(> .settings-rail) {
  margin-left: calc(var(--side-w) + var(--settings-rail-w));
  /* A too-wide child must clip rather than h-scroll the document: scrolling
     right slides the content under the fixed rail, leaving controls covered
     and unclickable. */
  overflow-x: clip;
}
/* Narrow screens: the rail folds into an in-flow card above the page content.
   These use the same :has() specificity as the wide rule above, so they win
   over it by order — and over the plain drawer margin rules at 900px, which
   they must repeat (the :has() selector out-specifies them). */
@media (max-width: 1100px) {
  .settings-rail {
    position: static; width: auto;
    border: 1px solid var(--rule); border-radius: var(--radius);
    margin-bottom: 1.25rem;
  }
  main.with-sidebar:has(> .settings-rail) { margin-left: var(--side-w); }
}
@media (max-width: 900px) {
  main.with-sidebar:has(> .settings-rail) { margin-left: 0; }
}
@media (min-width: 1400px) {
  main.with-sidebar { padding: 1.75rem 2rem 3rem; }
}

/* ─── SIDEBAR (Chatwoot v4 labeled sidebar) ───────────────────────────
   ~208px column of icon+label rows (Sidebar.vue: bg-n-background,
   border-n-weak; leaf rows h-8 gap-2 px-2 rounded-lg). Active page still
   lights via body[data-nav]; the Inbox row expands a nested inbox list. */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w);
  background: var(--bg);
  border-right: 1px solid var(--rule);
  display: flex; flex-direction: column;
  padding: 0.5rem 0.45rem;
}

.sidebar .brand {
  display: flex; align-items: center; gap: 0.5rem;
  color: var(--ink); text-decoration: none;
  padding: 0.25rem 0.5rem 0.6rem;
  margin-bottom: 0.25rem;
  border-bottom: 1px solid var(--rule);
}
.sidebar .brand::after { content: none; }
.sidebar .brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; flex-shrink: 0;
  background: var(--accent); color: #fff;
  border-radius: 8px; font-weight: 700; font-size: 0.9rem;
  box-shadow: var(--shadow-sm);
}
.brand-text { font-size: 0.9rem; font-weight: 600; letter-spacing: -0.01em; }

/* Scrollable middle band — brand and foot stay pinned. */
.rail-scroll {
  flex: 1; width: 100%; min-height: 0;
  display: flex; flex-direction: column;
  overflow-y: auto; scrollbar-width: none;
}
.rail-scroll::-webkit-scrollbar { display: none; }

.side-cta {
  display: flex; align-items: center; justify-content: center; gap: 0.45rem;
  margin: 0.3rem 0 0.45rem; padding: 0.4rem 0.6rem;
  background: var(--accent); color: var(--accent-ink);
  text-decoration: none;
  font-size: 0.82rem; font-weight: 600;
  border: 1px solid transparent; border-radius: 8px;
  box-shadow: var(--shadow-sm);
  transition: background 0.15s;
}
.side-cta:hover { background: var(--accent-hover); color: var(--accent-ink); text-decoration: none; }
.side-cta .nav-label { flex: none; }

.side-sep { height: 1px; flex-shrink: 0; background: var(--rule); margin: 0.45rem 0.5rem; }

.side-nav { display: flex; flex-direction: column; gap: 1px; padding: 0; }
.side-nav .nav-item {
  display: flex; align-items: center; gap: 0.5rem;
  width: 100%; height: 32px; padding: 0 0.5rem; flex-shrink: 0;
  color: var(--ink-soft); text-decoration: none;
  font-size: 0.84rem; font-weight: 500;
  border-radius: 8px;
  transition: background 0.12s, color 0.12s;
  text-align: left;
}
.side-nav .nav-item::before { content: none; }
.nav-ic {
  width: 16px; height: 16px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
  color: var(--muted); transition: color 0.12s;
}
.side-nav .nav-item:hover { background: var(--bg-soft); color: var(--ink); text-decoration: none; }
.side-nav .nav-item:hover .nav-ic { color: var(--ink-soft); }

/* Inline row label (truncates; badges/chevrons ride at the row end) */
.nav-label {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Inbox group: the row toggles a nested inbox list (Chatwoot SidebarGroup) */
button.nav-item { background: none; border: none; cursor: pointer; font: inherit; }
.nav-group { display: flex; flex-direction: column; }
.nav-disclose {
  width: 13px; height: 13px; flex-shrink: 0;
  color: var(--muted);
  transition: transform 0.15s ease;
  transform: rotate(-90deg);
}
[data-rail-inbox-toggle][aria-expanded="true"] .nav-disclose { transform: rotate(0deg); }
.nav-sublist {
  margin: 1px 0 2px 0.95rem;
  padding-left: 0.35rem;
  border-left: 1px solid var(--rule);
}
.nav-sublist.hidden { display: none; }
.nav-sublist__loading { font-size: 0.76rem; margin: 0.2rem 0 0.2rem 0.5rem; }
.nav-sublist .inbox-folders { padding: 0; border: none; }
.nav-sublist .inbox-folders__item { padding: 0.28rem 0.45rem; font-size: 0.8rem; }
.nav-sublist .inbox-folders__sep { margin-left: 0.45rem; }

/* Unread badges sit inline at the row end (Chatwoot leaf counts). The inbox
   badge endpoint swaps in a bare `.badge` span; chat's swaps `.chat-badge`. */
.side-nav .nav-item .badge,
.side-nav .nav-item .inbox-badge,
.side-nav .nav-item .chat-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 17px; height: 17px; padding: 0 4px;
  margin-left: auto; flex-shrink: 0;
  border-radius: 999px;
  font-size: 0.64rem; font-weight: 600; line-height: 1;
  background: transparent; color: transparent;
  border: none;
}
/* rows whose label already flexes push badges right via the label */
.side-nav .nav-item .nav-label + .badge,
.side-nav .nav-item .nav-label ~ .inbox-badge,
.side-nav .nav-item .nav-label ~ .chat-badge { margin-left: 0; }
.side-nav .nav-item .badge,
.side-nav .nav-item .chat-badge.badge-on {
  background: var(--accent); color: #fff;
}

/* Active nav highlight: the page sets <body data-nav="KEY"> (the page's
   {{block "nav"}}) and the matching `.nav-KEY` sidebar item lights up. Every
   sidebar nav item needs a row here — admin (operations + configuration) and
   portal — or its page renders with nothing highlighted. */
body[data-nav="leads"]            .nav-leads,
body[data-nav="calendar"]         .nav-calendar,
body[data-nav="bookings"]         .nav-bookings,
body[data-nav="inbox"]            .nav-inbox,
body[data-nav="customers"]        .nav-customers,
body[data-nav="teams"]            .nav-teams,
body[data-nav="services"]         .nav-services,
body[data-nav="extras"]           .nav-extras,
body[data-nav="locations"]        .nav-locations,
body[data-nav="chat"]             .nav-chat,
body[data-nav="calls"]            .nav-calls,
body[data-nav="charges"]          .nav-charges,
body[data-nav="payouts"]          .nav-payouts,
body[data-nav="reports"]          .nav-reports,
body[data-nav="settings"]         .nav-settings,
body[data-nav="agents"]           .nav-agents,
body[data-nav="automations"]      .nav-automations,
body[data-nav="cron"]             .nav-cron,
body[data-nav="help"]             .nav-help,
body[data-nav="portal"]           .nav-portal,
body[data-nav="portal-bookings"]  .nav-portal-bookings,
body[data-nav="portal-tasks"]     .nav-portal-tasks,
body[data-nav="portal-requests"]  .nav-portal-requests,
body[data-nav="portal-claims"]    .nav-portal-claims,
body[data-nav="portal-profile"]   .nav-portal-profile {
  /* Chatwoot v4 active leaf: neutral pill, ink text (not a blue tint) */
  background: rgba(196, 197, 198, 0.28);
  color: var(--ink);
  font-weight: 600;
}
body[data-nav="leads"]            .nav-leads           .nav-ic,
body[data-nav="calendar"]         .nav-calendar        .nav-ic,
body[data-nav="bookings"]         .nav-bookings        .nav-ic,
body[data-nav="inbox"]            .nav-inbox           .nav-ic,
body[data-nav="customers"]        .nav-customers       .nav-ic,
body[data-nav="teams"]            .nav-teams           .nav-ic,
body[data-nav="services"]         .nav-services        .nav-ic,
body[data-nav="extras"]           .nav-extras          .nav-ic,
body[data-nav="locations"]        .nav-locations       .nav-ic,
body[data-nav="chat"]             .nav-chat            .nav-ic,
body[data-nav="charges"]          .nav-charges         .nav-ic,
body[data-nav="payouts"]          .nav-payouts         .nav-ic,
body[data-nav="reports"]          .nav-reports         .nav-ic,
body[data-nav="settings"]         .nav-settings        .nav-ic,
body[data-nav="agents"]           .nav-agents          .nav-ic,
body[data-nav="automations"]      .nav-automations     .nav-ic,
body[data-nav="cron"]             .nav-cron            .nav-ic,
body[data-nav="help"]             .nav-help            .nav-ic,
body[data-nav="portal"]           .nav-portal          .nav-ic,
body[data-nav="portal-bookings"]  .nav-portal-bookings .nav-ic,
body[data-nav="portal-requests"]  .nav-portal-requests .nav-ic,
body[data-nav="portal-claims"]    .nav-portal-claims   .nav-ic,
body[data-nav="portal-profile"]   .nav-portal-profile  .nav-ic { color: var(--ink); }

/* Help wiki — typography for the rendered markdown guide body. Uses the design
   tokens so it adapts to dark mode (html.dark redefines them). */
.help-prose { color: var(--ink-soft); line-height: 1.7; font-size: 0.95rem; }
.help-prose > :first-child { margin-top: 0; }
.help-prose h2 { font-size: 1.15rem; font-weight: 700; color: var(--ink); margin: 1.8rem 0 0.6rem; padding-bottom: 0.3rem; border-bottom: 1px solid var(--rule); }
.help-prose h3 { font-size: 1rem; font-weight: 600; color: var(--ink); margin: 1.4rem 0 0.4rem; }
.help-prose p { margin: 0.7rem 0; }
.help-prose ul, .help-prose ol { margin: 0.7rem 0; padding-left: 1.4rem; }
.help-prose li { margin: 0.3rem 0; }
.help-prose ul { list-style: disc; }
.help-prose ol { list-style: decimal; }
.help-prose a { color: var(--accent); font-weight: 500; }
.help-prose a:hover { color: var(--accent-hover); }
.help-prose img { max-width: 100%; height: auto; margin: 1.1rem 0; border: 1px solid var(--rule); border-radius: 10px; box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,0.08)); }
.help-prose code { font-family: 'Geist Mono', ui-monospace, monospace; font-size: 0.85em; background: var(--bg-soft); padding: 0.1rem 0.35rem; border-radius: 5px; color: var(--ink); }
.help-prose pre { background: var(--bg-soft); padding: 0.8rem 1rem; border-radius: 8px; overflow-x: auto; margin: 0.9rem 0; }
.help-prose pre code { background: none; padding: 0; }
.help-prose blockquote { margin: 1rem 0; padding: 0.6rem 1rem; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 8px 8px 0; }
.help-prose blockquote p { margin: 0.3rem 0; }
.help-prose table { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 0.9rem; }
.help-prose th, .help-prose td { text-align: left; padding: 0.5rem 0.7rem; border: 1px solid var(--rule); vertical-align: top; }
.help-prose th { background: var(--bg-soft); font-weight: 600; color: var(--ink); }
.help-prose hr { border: 0; border-top: 1px solid var(--rule); margin: 1.6rem 0; }

/* ─── SIDEBAR FOOT + ACCOUNT DROPDOWN (Chatwoot v4 foot row) ──────── */
.side-foot {
  margin-top: auto; padding: 0.4rem 0 0;
  width: 100%;
  border-top: 1px solid var(--rule);
  display: flex; flex-direction: row; align-items: center; gap: 2px;
}
.hs-dropdown.account { position: relative; display: flex; flex: 1; min-width: 0; order: -1; }
.account-btn {
  display: flex; align-items: center; gap: 0.45rem;
  flex: 1; min-width: 0;
  padding: 0.25rem 0.35rem; cursor: pointer;
  background: transparent; border: 1px solid transparent;
  border-radius: 8px; text-align: left;
  transition: background 0.12s, border-color 0.12s;
}
.account-btn:hover { background: var(--bg-soft); }
.hs-dropdown.open .account-btn { background: var(--bg-soft); border-color: var(--rule); }
.account-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent);
  border-radius: 50%; font-weight: 600; font-size: 0.74rem;
  text-transform: uppercase;
}
.account-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.15; }
.account-name { font-size: 0.74rem; font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-role { font-size: 0.64rem; color: var(--muted); text-transform: capitalize; }
.account-chevron { display: none; }

.account-menu {
  position: absolute; bottom: calc(100% + 6px); left: 0; right: auto;
  width: 230px;
  z-index: 80;
  background: var(--panel); border: 1px solid var(--rule);
  border-radius: var(--radius-sm); padding: 0.35rem;
  box-shadow: var(--shadow-lg);
}
.account-menu.hidden { display: none; }
.account-menu-head { padding: 0.45rem 0.6rem 0.5rem; border-bottom: 1px solid var(--rule-soft); margin-bottom: 0.3rem; display: flex; flex-direction: column; gap: 0.1rem; }
.account-menu-label { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }
.account-menu-email { font-size: 0.78rem; color: var(--ink); word-break: break-all; }
.account-menu-form { margin: 0; }
.account-menu-item {
  display: flex; align-items: center; gap: 0.55rem; width: 100%;
  padding: 0.5rem 0.6rem; cursor: pointer;
  background: transparent; border: 0; border-radius: 6px;
  font: inherit; font-size: 0.82rem; font-weight: 500; color: var(--ink-soft);
  text-decoration: none; text-align: left;
  transition: background 0.12s, color 0.12s;
}
.account-menu-item svg { color: var(--muted); flex-shrink: 0; }
.account-menu-item:hover { background: var(--bg-soft); color: var(--ink); text-decoration: none; }
.account-menu-item:hover svg { color: var(--ink-soft); }
.account-menu-item.danger { color: var(--bad); }
.account-menu-item.danger svg { color: var(--bad); }
.account-menu-item.danger:hover { background: var(--bad-soft); color: #991b1b; }
.account-menu-item.danger:hover svg { color: #991b1b; }
.side-foot .logout button:hover { background: var(--bg-soft); border-color: var(--ink-soft); color: var(--ink); }

/* ─── HEADINGS ────────────────────────────────────────────────────── */
h1, h2, h3 { font-family: var(--sans); font-weight: 600; letter-spacing: -0.018em; line-height: 1.2; color: var(--ink); }
h1 { font-size: 1.65rem; margin: 0 0 0.5rem; font-weight: 700; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 0.6rem; }
h3 { font-size: 0.95rem; margin: 1.1rem 0 0.5rem; }

.page-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.5rem; padding-bottom: 1rem;
  border-bottom: 1px solid var(--rule);
  gap: 1rem; flex-wrap: wrap;
}
.page-head h1 {
  font-size: 1.75rem; line-height: 1.15; letter-spacing: -0.025em;
  font-weight: 700;
}
.page-head h1::before { content: none; }
.head-actions { display: flex; gap: 0.5rem; align-items: center; }
.head-actions form { margin: 0; }

/* ─── BUTTONS ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.45em; padding: 0.55rem 0.95rem;
  border: 1px solid var(--rule); background: var(--panel);
  color: var(--ink-soft); cursor: pointer;
  font-family: var(--sans); font-size: 0.82rem; font-weight: 500;
  letter-spacing: -0.005em;
  text-decoration: none; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs);
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.btn:hover { background: var(--bg-soft); border-color: var(--rule); color: var(--ink); text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); box-shadow: var(--shadow-sm); }
.btn.primary:hover { background: var(--accent-hover); border-color: transparent; color: var(--accent-ink); }
.btn.saved,
.btn.saved:hover {
  background: var(--ok); border-color: var(--ok); color: #fff;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  pointer-events: none;
}
.btn.saved::before { content: "✓ "; }
.btn.danger { background: var(--panel); color: var(--bad); border-color: var(--rule); }
.btn.danger:hover { background: var(--bad); color: var(--panel); border-color: var(--bad); }

/* ─── SEARCH ──────────────────────────────────────────────────────── */
.search { display: flex; gap: 0.5rem; margin-bottom: 1.25rem; max-width: 600px; }
.search input {
  flex: 1; padding: 0.5rem 0.75rem;
  border: 1px solid var(--rule);
  background: var(--panel); font: inherit; font-family: var(--sans);
  border-radius: var(--radius-sm);
  color: var(--ink);
}
.search input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.search button {
  padding: 0.5rem 1.1rem; background: var(--accent); color: var(--accent-ink);
  border: 1px solid transparent;
  font-family: var(--sans); font-size: 0.82rem; font-weight: 600;
  cursor: pointer; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: background 0.15s;
}
.search button:hover { background: var(--accent-hover); border-color: transparent; }
.search button:focus-visible { outline: none; box-shadow: var(--ring); }

/* ─── TABLES ──────────────────────────────────────────────────────── */
table.data {
  width: 100%; border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--rule); border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  font-variant-numeric: tabular-nums;
}
table.data th {
  text-align: left; padding: 0.7rem 0.95rem;
  font-family: var(--sans); font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); background: var(--bg-soft);
  border-bottom: 1px solid var(--rule);
}
table.data td {
  padding: 0.75rem 0.95rem; border-bottom: 1px solid var(--rule-soft);
  vertical-align: middle;
}
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr { transition: background 0.1s; }
table.data tbody tr:hover { background: var(--bg-soft); }
table.data td.empty {
  text-align: center; color: var(--muted); padding: 3rem 1rem;
  font-style: normal; font-size: 0.9rem;
}
table.data td a { color: var(--accent); border-bottom: none; }
table.data td a:hover { color: var(--accent-hover); text-decoration: underline; }

/* ─── FORMS ───────────────────────────────────────────────────────── */
.form { max-width: 720px; }
.form label {
  display: block; margin: 1rem 0 0.35rem;
  font-family: var(--sans); font-size: 0.78rem; font-weight: 500;
  color: var(--ink-soft);
  letter-spacing: -0.005em;
}
.form input:not([type="checkbox"]):not([type="radio"]), .form textarea, .form select {
  width: 100%; padding: 0.5rem 0.7rem;
  border: 1px solid var(--rule);
  /* background-color, not the shorthand: the shorthand wiped the vendored
     select base's background-image chevron on every .form select. */
  background-color: var(--panel); font: inherit; font-family: var(--sans);
  border-radius: var(--radius-sm);
  color: var(--ink);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.form input:not([type="checkbox"]):not([type="radio"]):focus, .form textarea:focus, .form select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form textarea { min-height: 90px; resize: vertical; }
.form .grid.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.25rem; }
.form label.check {
  display: flex; align-items: center; gap: 0.5rem; margin-top: 0.9rem;
  font-size: 0.88rem; color: var(--ink); font-weight: 400;
}
/* No input override here: the vendored appearance-none base sizes checkboxes/radios
   at 1rem; a `width: auto` on top collapses them to a 2px sliver. */
.form .actions {
  display: flex; gap: 0.6rem; margin-top: 1.75rem;
  padding-top: 1.1rem; border-top: 1px solid var(--rule);
}
small.error { color: var(--bad); display: block; margin-top: 0.3rem; font-size: 0.78rem; font-weight: 500; }

/* ─── TABS ────────────────────────────────────────────────────────── */
.tabs {
  display: flex; flex-wrap: wrap; gap: 0;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--rule);
}
.tab {
  padding: 0.55rem 0.95rem; text-decoration: none; color: var(--muted);
  font-family: var(--sans); font-size: 0.85rem; font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  border-radius: 0;
}
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ─── BADGES ──────────────────────────────────────────────────────── */
/* Preline soft badges: tinted background + matching ink, no border, small
   leading dot in the same hue. Default is neutral gray; status modifiers
   recolor both the pill and the dot. */
.badge {
  display: inline-flex; align-items: center; gap: 0.4em;
  padding: 0.2rem 0.6rem; border: 0;
  background: var(--bg-soft);
  font-family: var(--sans); font-size: 0.72rem; font-weight: 500;
  color: var(--ink-soft); border-radius: 999px;
  white-space: nowrap;
}
.badge::before {
  content: ''; width: 6px; height: 6px;
  background: currentColor; border-radius: 50%;
  flex-shrink: 0; opacity: 0.85;
}
.badge.st-unassigned, .badge.st-pending { background: var(--warn-soft); color: #92400e; }
.badge.st-upcoming, .badge.st-authorized, .badge.st-payment_authorized, .badge.st-assigned, .badge.st-pushed, .badge.st-sent { background: var(--info-soft); color: #1e40af; }
.badge.st-completed, .badge.st-charged, .badge.st-captured, .badge.st-payment_captured, .badge.st-payment_succeeded, .badge.st-created, .badge.st-settled, .badge.st-paid { background: var(--ok-soft); color: #166534; }
.badge.st-declined, .badge.st-failed, .badge.st-payment_failed, .badge.st-deleted { background: var(--bad-soft); color: #991b1b; }
.badge.st-cancelled, .badge.st-voided { background: var(--bg-soft); color: var(--muted); }
.badge.st-updated { background: #e0e7ff; color: #3730a3; }

/* ─── CARDS ───────────────────────────────────────────────────────── */
.card {
  background: var(--panel); border: 1px solid var(--rule);
  padding: 1.25rem 1.5rem; margin: 1rem 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card h2 { margin-top: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(245px, 1fr)); gap: 1rem; }
.card.link {
  text-decoration: none; color: inherit; display: block;
  position: relative; transition: 0.12s;
  padding-right: 2.75rem;
}
.card.link::after {
  content: '→'; position: absolute; right: 1.25rem; top: 1.4rem;
  color: var(--muted); font-size: 1rem;
  transition: transform 0.15s, color 0.15s;
}
.card.link:hover { border-color: var(--ink-soft); }
.card.link:hover::after { color: var(--accent); transform: translateX(2px); }
.card.error-banner { border-color: var(--bad); color: var(--bad); background: #fef3f2; }
.card.success-banner { border-color: var(--ok); color: #054f31; background: #f0faf5; }
.card.notice { border-color: var(--ok); color: #054f31; background: #f0faf5; }

/* ─── KEY/VALUE LIST ──────────────────────────────────────────────── */
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 0.6rem 1.25rem; margin: 0; }
.kv dt {
  font-size: 0.78rem; font-weight: 500;
  color: var(--muted); align-self: center;
}
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
/* `.kv-flow` wraps each <dt><dd> pair in a `.kv-row` div so we can flow
   them into newspaper-style columns without forcing rows in the two
   columns to share the tallest cell's height. Avoids the "lone short
   value next to a long label" look on cards like custom fields. */
.kv-flow { margin: 0; }
.kv-row { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 0.4rem 1rem; padding: 0.45rem 0; break-inside: avoid; }
.kv-row + .kv-row { border-top: 1px solid var(--rule-soft); }
.kv-row dt {
  font-size: 0.78rem; font-weight: 500;
  color: var(--muted); align-self: start; padding-top: 0.1rem;
}
.kv-row dd { margin: 0; font-variant-numeric: tabular-nums; }
.kv-row .cf-multi-list { margin: 0; padding-left: 1.1rem; }
@media (min-width: 1100px) {
  .kv-flow { column-count: 2; column-gap: 2rem; column-rule: 1px solid var(--rule-soft); }
  .kv-row + .kv-row { border-top: 1px solid var(--rule-soft); }
  .kv-row:first-child { padding-top: 0; }
}
@media (min-width: 1600px) {
  .kv-flow { column-count: 3; }
}

/* ─── BOOKINGS LIST: filter sidebar + calendar ────────────────────────
   Mobile-first: filter stacks above table at narrow widths.
   ──────────────────────────────────────────────────────────────────── */
.bookings-grid { display: flex; flex-direction: column; gap: 1rem; }
.bookings-main { min-width: 0; width: 100%; order: 2; }
.bookings-main table.data { font-size: 0.86rem; }
.bookings-main table.data td,
.bookings-main table.data th { padding: 0.55rem 0.7rem; }
.bookings-main td.bk-date { white-space: nowrap; }

.bookings-filter {
  order: 1;
  background: var(--panel); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 0.75rem 0.85rem 0.85rem;
  width: 100%; max-width: 360px; align-self: center;
}
.bookings-filter select {
  width: 100%; padding: 0.45rem 0.55rem;
  border: 1px solid var(--rule); border-radius: var(--radius-sm);
  background: var(--panel); font: inherit; font-family: var(--sans); color: var(--ink);
}
.bookings-filter > form > label {
  display: block; margin: 0 0 0.6rem;
  font-size: 0.78rem; font-weight: 500; color: var(--ink-soft);
}

.cal { margin-top: 0.75rem; border-top: 1px solid var(--rule); padding-top: 0.85rem; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.55rem; }
.cal-label { font-weight: 600; font-size: 0.92rem; color: var(--ink); }
.cal-nav {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--rule); border-radius: var(--radius-sm);
  color: var(--ink-soft); text-decoration: none; font-size: 1rem; line-height: 1;
}
.cal-nav:hover { background: var(--bg-soft); border-color: var(--ink-soft); color: var(--ink); text-decoration: none; }

.cal-grid { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 0.78rem; }
.cal-grid th {
  font-weight: 600; color: var(--muted);
  padding: 0.25rem 0; text-align: center; font-size: 0.7rem;
}
.cal-grid td { padding: 1px; text-align: center; vertical-align: middle; }
.cal-day a {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  height: 32px; border-radius: var(--radius-sm);
  color: var(--ink); text-decoration: none; font-variant-numeric: tabular-nums;
}
.cal-day a:hover { background: var(--bg-soft); text-decoration: none; }
.cal-day.out a { color: #c2c8d2; }
.cal-day.in-range a { background: var(--accent-soft); }
.cal-day.range-start a, .cal-day.range-end a {
  background: var(--accent); color: var(--bg); font-weight: 600;
}
.cal-day.today a { background: #fef3c7; color: var(--ink); font-weight: 600; }
.cal-day.today.in-range a { background: #fef3c7; }
.cal-day.selected a { outline: 1.5px solid var(--ink); outline-offset: -1px; }
.cal-day.today.selected a { background: #fde68a; }
.cal-day .c {
  position: absolute; top: 1px; right: 2px;
  min-width: 12px; height: 12px; padding: 0 3px;
  border-radius: 6px;
  background: var(--accent); color: var(--bg);
  font-size: 0.58rem; font-weight: 700; line-height: 12px;
}

.cal-views {
  display: flex; flex-wrap: wrap; gap: 1px; margin-top: 0.85rem;
  background: var(--rule); border: 1px solid var(--rule);
  border-radius: var(--radius-sm); overflow: hidden;
}
.cal-view-btn {
  flex: 1 1 calc(33.333% - 1px); min-width: 0;
  padding: 0.5rem 0.2rem;
  background: var(--panel); color: var(--ink-soft);
  text-decoration: none; text-align: center;
  font-size: 0.74rem; font-weight: 500;
}
.cal-view-btn:hover { background: var(--bg-soft); text-decoration: none; }
.cal-view-btn.active { background: var(--ink); color: var(--bg); }

/* desktop: 2-column grid w/ filter pinned right */
@media (min-width: 900px) {
  .bookings-grid {
    display: grid; grid-template-columns: minmax(0, 1fr) 230px;
    gap: 1.25rem; align-items: start;
  }
  .bookings-main { order: 0; }
  .bookings-filter {
    order: 0; width: auto; max-width: none; align-self: stretch;
  }
  .cal-day a { height: 28px; }
}

/* ─── LOCATION CHECKLIST (teams form) ─────────────────────────────── */
.loc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.4rem 1rem; margin: 0.5rem 0; }
.loc-check { margin: 0; padding: 0.3rem 0; font-size: 0.88rem; font-weight: 400; }

/* ─── EXTRAS LIST (booking form) ──────────────────────────────────── */
.extras-list { list-style: none; padding: 0; margin: 0.5rem 0 0; }
.extra-row { padding: 0.5rem 0; border-top: 1px solid var(--rule-soft); }
.extra-row:first-child { border-top: none; }
/* Scoped under .extras-list so these beat the broad `.form label`/forms-plugin
   rules (display:block, [type=checkbox] sizing) that otherwise stack and collapse the row. */
.extras-list .extra-toggle { display: flex; align-items: center; gap: 0.55rem; cursor: pointer; margin: 0; font-size: 0.9rem; color: var(--ink); font-weight: 500; }
.extras-list .extra-toggle input[type="checkbox"] { flex: none; }
.extra-toggle .extra-name { flex: 0 1 auto; }
.extra-toggle .extra-summary { font-size: 0.78rem; color: var(--muted); font-weight: 400; }
.extra-params { display: none; padding: 0.5rem 0 0.25rem 1.55rem; }
.extra-params.open { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.65rem; }

/* ─── PARAM VALUE ROWS (booking form) ─────────────────────────────── */
.pv-grid { display: flex; flex-direction: column; gap: 0.85rem; }
/* Cap the stepper row width: it's a full-width flex block with justify-between, so
   without a cap the +/- controls get flung to the far edge of the fieldset, miles
   from the label. Capping keeps the controls a short, consistent hop from the label
   and column-aligned across stacked rows. (Extras steppers already sit in a 220px
   grid cell, so this only tightens the naked service-param rows in #svcParamsRows.) */
.pv-stepper { max-width: 18rem; }
/* Quantity steppers (Preline HSInputNumber) on the booking form: neutralise the
   generic ".form input" box so the value sits naked between the +/- buttons. */
/* Selector must out-specify the vendored form-control base
   (".form input:not([type=checkbox]):not([type=radio])" = 0,3,1 — and its
   html.dark twin at 0,3,2) or the value renders as a full bordered box
   instead of sitting naked between the +/- buttons. .form .pv-stepper input
   :not()… = 0,4,1, which beats both. */
.form .pv-stepper input:not([type="checkbox"]):not([type="radio"]) {
  width: 3rem; padding: 0; border: 0; background: transparent; text-align: center;
}
.form .pv-stepper input:not([type="checkbox"]):not([type="radio"]):focus { box-shadow: none; outline: none; }

/* ─── PARAMS TABLE (services form) ────────────────────────────────── */
fieldset.params { border: 1px solid var(--rule); padding: 0.5rem 1.25rem 1.1rem; margin: 1.5rem 0; border-radius: var(--radius); background: var(--panel); }
fieldset.params legend { padding: 0 0.5rem; font-size: 0.74rem; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; }
fieldset.params.hidden .params-table, fieldset.params.hidden #paramActions, fieldset.params.hidden .param-cards { display: none; }
.params-hint { font-size: 0.85rem; color: var(--muted); margin: 0.5rem 0 1rem; }
.param-cards { display: flex; flex-direction: column; gap: 0.75rem; margin: 0.5rem 0 1rem; }
.param-card { border: 1px solid var(--rule); border-radius: var(--radius-sm); padding: 0.75rem; background: var(--panel-muted, var(--panel)); }
.param-card .param-row.top { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: end; }
.param-card .param-row.top label { flex: 1 1 8rem; display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.78rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.03em; }
.param-card .param-row.top input, .param-card .param-row.top select { padding: 0.35rem 0.5rem; border: 1px solid var(--rule); border-radius: var(--radius-sm); font: inherit; background: var(--panel); color: var(--ink); }
.param-card .param-numeric { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.6rem; }
/* The kind-specific sections toggle via the [hidden] attribute (set server-side
   and by applyKind JS). The class rules above set an explicit display, which
   would otherwise outrank the UA `[hidden]{display:none}`, so re-assert it with
   higher specificity. */
.param-card .param-numeric[hidden], .param-card .param-tiered[hidden], .param-card .param-options[hidden] { display: none; }
.param-card .param-numeric label { flex: 1 1 6rem; display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.78rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.03em; }
.param-card .param-numeric input { padding: 0.35rem 0.5rem; border: 1px solid var(--rule); border-radius: var(--radius-sm); font: inherit; background: var(--panel); color: var(--ink); }
.param-card .param-options { margin-top: 0.6rem; }
.param-card .option-rows { width: 100%; font-size: 0.86rem; }
.param-card .option-rows td input:not([type="checkbox"]):not([type="radio"]), .param-card .option-rows td textarea { width: 100%; padding: 0.35rem 0.5rem; border: 1px solid var(--rule); border-radius: var(--radius-sm); font: inherit; background: var(--panel); resize: vertical; }
.param-card .option-rows td textarea { font-family: var(--mono, monospace); font-size: 0.78rem; min-height: 1.8rem; }
.param-card .add-option { margin-top: 0.4rem; padding: 0.3rem 0.6rem; font-size: 0.74rem; }
fieldset.pv-radio-group { border: 1px solid var(--rule); border-radius: var(--radius-sm); padding: 0.4rem 0.75rem 0.6rem; margin: 0.3rem 0 0; }
fieldset.pv-radio-group legend.pv-label { padding: 0 0.3rem; font-size: 0.78rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.03em; font-weight: 600; }
.pv-radio-group .pv-radio { display: flex; align-items: center; gap: 0.5rem; margin: 0; padding: 0.25rem 0; cursor: pointer; }
.pv-radio-group .pv-radio input { appearance: auto; -webkit-appearance: radio; width: 1rem; height: 1rem; margin: 0; padding: 0; border: 0; background: none; accent-color: var(--accent); flex: 0 0 auto; }
.pv-radio-group .pv-radio span { flex: 1; }
table.params-table { margin: 0.5rem 0 1rem; font-size: 0.86rem; box-shadow: none; border-radius: var(--radius-sm); }
table.params-table th { padding: 0.5rem 0.6rem; }
table.params-table td { padding: 0.4rem 0.5rem; }
table.params-table tbody tr:hover { background: transparent; }
table.params-table input:not([type="checkbox"]):not([type="radio"]) { width: 100%; padding: 0.35rem 0.5rem; border: 1px solid var(--rule); background: var(--panel); font: inherit; font-family: var(--sans); border-radius: var(--radius-sm); color: var(--ink); }
table.params-table input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
table.params-table .btn { padding: 0.3rem 0.6rem; font-size: 0.74rem; }
#paramActions { margin: 0.5rem 0 0; padding: 0; border: none; }

/* ─── FIELDSET ────────────────────────────────────────────────────── */
fieldset.customfields {
  border: 1px solid var(--rule); padding: 0.4rem 1.25rem 1.2rem;
  margin: 1.5rem 0; border-radius: var(--radius); background: var(--panel);
}
fieldset.customfields legend {
  padding: 0 0.5rem; font-size: 0.74rem; font-weight: 600;
  color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em;
}

/* ─── MISC ────────────────────────────────────────────────────────── */
.muted { color: var(--muted); }
.error { color: var(--bad); }
.swatch { display: inline-block; width: 0.85rem; height: 0.85rem; vertical-align: middle; margin-right: 0.4rem; border: 1px solid rgba(0,0,0,0.1); border-radius: 2px; }
.actions.wrap { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.mt { margin-top: 1rem; }

pre.copy {
  background: var(--ink-soft); color: #d4dae4;
  padding: 0.85rem 1rem; font-family: var(--mono); font-size: 0.82rem;
  white-space: pre-wrap; word-break: break-all;
  border: 1px solid var(--ink-soft); border-radius: var(--radius-sm);
}
pre.copy::before { content: none; }

form.inline { display: inline-flex; gap: 0.4rem; align-items: center; margin: 0; }
form.inline select, form.inline input {
  padding: 0.4rem 0.55rem; border: 1px solid var(--rule);
  background: var(--panel); font: inherit; font-family: var(--sans);
  border-radius: var(--radius-sm); color: var(--ink);
}
form.inline select:focus, form.inline input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* ─── HISTORY ─────────────────────────────────────────────────────── */
ol.history { list-style: none; padding: 0; margin: 0; }
ol.history > li { padding: 0.85rem 0; border-bottom: 1px solid var(--rule-soft); position: relative; padding-left: 1rem; }
ol.history > li::before {
  content: ''; position: absolute; left: 0; top: 1.2rem;
  width: 5px; height: 5px; background: var(--accent); border-radius: 50%;
}
ol.history > li:last-child { border-bottom: none; }
.history-meta {
  display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--muted); margin-bottom: 0.35rem;
}
.history-meta .actor { color: var(--ink); font-weight: 500; }
ul.changes { margin: 0.4rem 0 0; padding-left: 1.2rem; font-size: 0.88rem; }
ul.changes code { font-family: var(--mono); background: var(--bg-soft); border: 1px solid var(--rule); padding: 0 0.3rem; font-size: 0.82em; border-radius: 3px; }

/* ─── REL LIST ────────────────────────────────────────────────────── */
ul.rel-list { list-style: none; padding: 0; margin: 0 0 1rem; }
ul.rel-list > li {
  padding: 0.55rem 0; border-bottom: 1px solid var(--rule-soft);
  display: flex; align-items: center; gap: 0.55rem; flex-wrap: wrap;
}
ul.rel-list > li:last-child { border-bottom: none; }

ul.inline-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.3rem; }

/* ─── AUTH ────────────────────────────────────────────────────────── */
.auth-card {
  max-width: 380px; margin: 5rem auto;
  padding: 2rem 2rem 1.75rem;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 12px rgba(16, 24, 40, 0.04);
}
.auth-card::before, .auth-card::after { content: none; }
.auth-card h1 {
  font-family: var(--sans); font-style: normal; font-weight: 700;
  font-size: 1.5rem; margin: 0 0 0.25rem; letter-spacing: -0.02em;
}
.auth-card h1::after { content: none; }
.auth-card p.muted { font-size: 0.85rem; margin: 0 0 1.5rem; }
.auth-card label {
  display: block; margin: 1rem 0 0.35rem;
  font-size: 0.78rem; font-weight: 500;
  color: var(--ink-soft); letter-spacing: -0.005em;
}
.auth-card input {
  display: block; width: 100%; padding: 0.5rem 0.7rem;
  border: 1px solid var(--rule);
  background: var(--panel); font: inherit; font-size: 0.92rem;
  font-family: var(--sans); border-radius: var(--radius-sm); color: var(--ink);
}
.auth-card input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.auth-card button {
  width: 100%; padding: 0.6rem;
  background: var(--accent); color: var(--accent-ink);
  border: 1px solid var(--accent); border-radius: var(--radius-sm);
  font-family: var(--sans); font-size: 0.88rem; font-weight: 500;
  cursor: pointer; margin-top: 1.25rem; transition: 0.12s;
}
.auth-card button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.auth-card .error { color: var(--bad); margin: 0 0 0.5rem; font-size: 0.82rem; font-weight: 500; }

/* ─── MOBILE TOP BAR & DRAWER ─────────────────────────────────────── */
.mobile-bar { display: none; }
.nav-backdrop { display: none; }
.nav-toggle {
  width: 40px; height: 40px; padding: 0;
  background: transparent; border: 1px solid var(--rule);
  border-radius: var(--radius-sm); cursor: pointer;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
}
.nav-toggle span { display: block; width: 18px; height: 2px; background: var(--ink); }
.mobile-brand { font-weight: 700; font-size: 1rem; color: var(--ink); text-decoration: none; letter-spacing: -0.015em; }

/* ─── RESPONSIVE ─────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .mobile-bar {
    display: flex; align-items: center; gap: 0.75rem;
    position: fixed; top: 0; left: 0; right: 0; z-index: 40;
    height: 56px; padding: 0 1rem;
    background: var(--panel); border-bottom: 1px solid var(--rule);
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 50;
    box-shadow: 2px 0 24px rgba(11, 20, 36, 0.08);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .nav-backdrop {
    display: block;
    position: fixed; inset: 0; z-index: 45;
    background: rgba(11, 20, 36, 0.4);
  }

  main.with-sidebar {
    margin-left: 0;
    padding: 5rem 1rem 3rem;
  }
  main { padding: 1rem; margin: 0; }

  .page-head {
    flex-direction: column; align-items: flex-start;
    margin-bottom: 1.25rem; padding-bottom: 0.85rem;
  }
  .page-head h1 { font-size: 1.4rem; }
  .head-actions { width: 100%; flex-wrap: wrap; }

  h1 { font-size: 1.4rem; }
  h2 { font-size: 1.05rem; }

  .form .grid.two { grid-template-columns: 1fr; gap: 0.5rem 0; }
  .kv { grid-template-columns: 1fr; gap: 0.1rem 0; }
  .kv dt { margin-top: 0.6rem; }

  table.data {
    display: block; overflow-x: auto; white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  table.data th, table.data td { padding: 0.6rem 0.75rem; }

  .pv-grid { grid-template-columns: 1fr; }
  .extra-params.open { grid-template-columns: 1fr; }

  .search { flex-direction: column; max-width: none; }
  .search button { width: 100%; }

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

  .tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .tab { white-space: nowrap; }

  .auth-card {
    margin: 2rem 1rem;
    padding: 1.5rem 1.25rem 1.25rem;
  }

  fieldset.params, fieldset.customfields { padding: 0.4rem 0.85rem 1rem; }
  table.params-table { font-size: 0.78rem; }
  table.params-table input { padding: 0.3rem 0.4rem; font-size: 0.82rem; }

  pre.copy { font-size: 0.74rem; padding: 0.7rem 0.85rem; }

  .actions { flex-wrap: wrap; }
  .actions .btn { flex: 1 1 auto; }
}

@media (max-width: 480px) {
  main.with-sidebar { padding: 4.5rem 0.85rem 2.5rem; }
  .page-head h1 { font-size: 1.25rem; }
  .btn { font-size: 0.78rem; padding: 0.45rem 0.7rem; }
}

/* ---- Picker (typeahead, MUI Autocomplete style) ----
   Mirrors MUI: outlined 1px border, 4px radius, focus = 2px primary,
   listbox = paper with shadow, options padded 6/16, selected highlight.
*/
.picker {
  position: relative;
  display: block;
}
.picker-input-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  border: 1px solid rgba(0, 0, 0, 0.23);
  border-radius: 4px;
  padding: 6px 36px 6px 10px;            /* right room for end adornment */
  background: #fff;
  min-height: 40px;
  cursor: text;
  transition: border-color 120ms, box-shadow 120ms;
}
.picker-input-row:hover { border-color: var(--ink-soft); }
.picker-input-row:focus-within {
  border-color: var(--accent);
  box-shadow: var(--ring);                /* Preline focus ring */
}
/* Override .form input styling — picker search is naked inside the box */
.form .picker .picker-search,
.picker .picker-search {
  flex: 1 1 6rem;
  min-width: 4rem;
  border: 0 !important;
  outline: none;
  padding: 4px 0 !important;
  margin: 0;
  width: auto;
  font: inherit;
  color: rgba(0, 0, 0, 0.87);
  background: transparent !important;
  border-radius: 0;
  box-shadow: none !important;
}
.form .picker .picker-search:focus,
.picker .picker-search:focus { border: 0 !important; box-shadow: none !important; }
.picker-search::placeholder { color: rgba(0, 0, 0, 0.6); }

/* End adornment: clear and popup-arrow buttons, absolute right */
.picker-end {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
}
.picker-end button {
  background: transparent;
  border: 0;
  color: rgba(0, 0, 0, 0.54);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 14px;
  line-height: 1;
}
.picker-end button:hover { background: rgba(0, 0, 0, 0.04); color: rgba(0, 0, 0, 0.87); }
.picker-clear { visibility: hidden; }
.picker-input-row:hover .picker-clear,
.picker-input-row:focus-within .picker-clear { visibility: visible; }
.picker-single .picker-input-row:not(:has(input.picker-search:not([value=""]))) .picker-clear {
  visibility: hidden !important;
}
.picker-arrow svg {
  transition: transform 200ms;
  width: 18px;
  height: 18px;
  fill: currentColor;
}
.picker:has(.picker-results:not(:empty)) .picker-arrow svg { transform: rotate(180deg); }

/* Chips inline within input row (multi-select only) */
.picker .chips-list { display: contents; }
.picker .chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.08);
  color: rgba(0, 0, 0, 0.87);
  border-radius: 16px;
  padding: 0 4px 0 10px;
  font-size: 13px;
  line-height: 1;
  height: 24px;
  white-space: nowrap;
  max-width: calc(100% - 6px);
}
.picker .chip-label { overflow: hidden; text-overflow: ellipsis; }
.picker .chip-adhoc { background: rgba(245, 158, 11, 0.18); }
.picker .chip-x {
  background: transparent;
  border: 0;
  color: rgba(0, 0, 0, 0.4);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* Hidden until the chip is hovered, so casual clicks on the chip body
     don't accidentally hit the × button. pointer-events also turned off
     so coordinate-based clicks pass through to the row. */
  visibility: hidden;
  pointer-events: none;
}
.picker .chip:hover .chip-x,
.picker .chip:focus-within .chip-x {
  visibility: visible;
  pointer-events: auto;
}
.picker .chip-x:hover { background: rgba(0, 0, 0, 0.16); color: rgba(0, 0, 0, 0.87); }

/* Tag chip: tiny color dot before the label. Background dot only —
   the chip body itself stays neutral so contrast with the × button stays
   readable regardless of which colors ops pick. */
.chip-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}
.color-row { display: inline-flex; align-items: center; gap: 8px; }
.color-row input[type="color"] { width: 36px; height: 28px; padding: 0; border: 1px solid rgba(0,0,0,0.16); border-radius: 4px; }
.color-row input[type="text"] { flex: 1; max-width: 220px; }

/* Dropdown (Paper + Listbox) */
.picker-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 30;
  background: #fff;
  border-radius: 4px;
  max-height: 40vh;
  overflow-y: auto;
  box-shadow:
    0 5px 5px -3px rgba(0, 0, 0, 0.2),
    0 8px 10px 1px rgba(0, 0, 0, 0.14),
    0 3px 14px 2px rgba(0, 0, 0, 0.12);
}
.picker-results:empty { display: none; }
.picker-results-list {
  list-style: none;
  margin: 0;
  padding: 8px 0;
}
.picker-results-list li button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 6px 16px;
  min-height: 36px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  color: rgba(0, 0, 0, 0.87);
}
.picker-results-list li button small { color: rgba(0, 0, 0, 0.6); margin-left: 4px; }
.picker-results-list li button:hover,
.picker-results-list li button:focus {
  background: rgba(0, 0, 0, 0.04);
  outline: none;
}
.picker-results-list li button[aria-selected="true"] {
  background: var(--accent-soft);
}

/* No-match / inline-add panel */
.picker-empty {
  padding: 12px 16px;
  font-size: 14px;
}
.picker-empty .muted { color: rgba(0, 0, 0, 0.6); margin-bottom: 8px; }
.picker-empty .error { color: #d32f2f; margin-bottom: 8px; font-size: 13px; }
.picker-add-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.picker-add-form input {
  padding: 8px 10px;
  font-size: 14px;
  border: 1px solid rgba(0, 0, 0, 0.23);
  border-radius: 4px;
  background: #fff;
}
.picker-add-form input:focus { border-color: var(--accent); outline: none; box-shadow: var(--ring); }
.picker-add-form input[name=_add_in_name] { grid-column: 1 / -1; }
.picker-add-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
}
.picker-add-actions .btn { font-size: 13px; padding: 6px 12px; }

/* ─── CUSTOMER PROFILE: profile + bookings sidebar ─────────────────── */
.profile-grid { display: block; }
.profile-side { margin-top: 0; }
.cust-bookings { list-style: none; padding: 0; margin: 0; max-height: 60vh; overflow-y: auto; border: 1px solid var(--rule-soft); border-radius: 6px; }
.cust-bookings li { border-top: 1px solid var(--rule-soft); }
.cust-bookings li:first-child { border-top: none; }
.cb-link { display: block; padding: 0.55rem 0.75rem; text-decoration: none; color: inherit; }
.cb-link:hover { background: var(--accent-soft, #f0f4ff); }
.cb-row { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; }
.cb-row + .cb-row { margin-top: 0.15rem; }
.cb-date { font-size: 0.85rem; color: var(--ink); }
.cb-date small { color: var(--muted); }
.cb-svc { font-size: 0.92rem; font-weight: 500; }
.cb-price { font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.cb-team { font-size: 0.78rem; margin-top: 0.1rem; }

@media (min-width: 1100px) {
  .profile-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 1.25rem;
    align-items: start;
  }
  .profile-side { position: sticky; top: 1rem; }
  .cust-bookings { max-height: calc(100vh - 8rem); }
}

/* ─── BOOKING HISTORY: tighter event labels, comment styling ─────────── */
.hist-event { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.hist-body { margin-top: 0.15rem; }
.hist-comment {
  margin-top: 0.25rem; padding: 0.55rem 0.75rem;
  background: var(--accent-soft, #f0f4ff);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  white-space: pre-wrap;
}
.hist-comment::before { content: "💬 "; color: var(--accent); }

/* ─── BOOKING HISTORY: comment form ─────────────────────────────────── */
.comment-form { display: flex; gap: 0.5rem; align-items: flex-start; margin: 0 0 1rem; }
.comment-form textarea {
  flex: 1; padding: 0.5rem 0.7rem;
  border: 1px solid var(--rule); border-radius: var(--radius-sm);
  font: inherit; font-family: var(--sans); resize: vertical;
}
.comment-form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.comment-form button { white-space: nowrap; }

/* ─── BOOKING HISTORY: comment edit/delete ──────────────────────────── */
.comment-actions { margin-left: auto; display: inline-flex; gap: 0.4rem; align-items: center; }
.comment-actions form.inline { display: inline; margin: 0; }
.btn-link {
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; color: var(--accent); font-size: 0.78rem;
  text-decoration: underline; text-underline-offset: 2px;
}
.btn-link:hover { color: var(--accent-hover); }
.btn-link.danger { color: var(--bad); }
.btn-link.danger:hover { color: #8a1c12; }
.history-meta { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.comment-edit-form { margin-top: 0.4rem; }
.comment-edit-form textarea {
  width: 100%; padding: 0.5rem 0.7rem;
  border: 1px solid var(--rule); border-radius: var(--radius-sm);
  font: inherit; font-family: var(--sans); resize: vertical;
}
.comment-edit-form .actions { display: flex; justify-content: flex-end; gap: 0.4rem; margin-top: 0.4rem; }

.hist-edited { font-size: 0.72rem; color: var(--muted); margin-left: 0.4rem; }

/* ─── SCHEDULER ────────────────────────────────────────────────────── */
.sched-toolbar {
  display: flex; align-items: center; gap: 0.5rem;
  margin: 0.75rem 0 1rem;
}
.sched-week-label { margin-left: 0.75rem; color: var(--muted); }

.sched-scroller {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.sched-grid {
  display: grid;
  grid-template-columns: 200px repeat(7, minmax(140px, 1fr));
  grid-auto-rows: min-content;
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 1180px;
}
.sched-corner, .sched-day-head, .sched-row-head, .sched-cell {
  background: var(--panel);
  padding: 0.5rem 0.6rem;
}
.sched-day-head {
  font-weight: 600;
  font-size: 0.85rem;
  text-align: center;
  color: var(--ink-soft);
  position: sticky; top: 0; z-index: 2;
}
.sched-day-head.today, .sched-cell.today { background: var(--accent-soft); }
.sched-row-head {
  display: flex; align-items: center; gap: 0.45rem;
  flex-wrap: wrap;
  border-left: 3px solid var(--team-color, var(--rule));
  font-weight: 500;
}
.sched-row-head.foreign { background: #fff7ed; }
.sched-row-head .sched-row-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--team-color, var(--muted));
  display: inline-block;
}
.sched-row-head small { width: 100%; font-size: 0.7rem; }

.sched-cell {
  min-height: 70px;
  display: flex; flex-direction: column; gap: 0.3rem;
}
.sched-cell.drag-over { outline: 2px dashed var(--accent); outline-offset: -3px; }

.sched-chip {
  display: flex; flex-direction: column; gap: 1px;
  position: relative;
  padding: 0.35rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--team-color, var(--rule));
  background: color-mix(in srgb, var(--team-color, #94a3b8) 14%, var(--panel));
  color: var(--ink);
  font-size: 0.78rem;
  line-height: 1.2;
  cursor: grab;
  text-decoration: none;
}
.sched-chip:hover { text-decoration: none; filter: brightness(0.97); }
.sched-chip.dragging { opacity: 0.5; }
.sched-chip.unassigned {
  border-color: var(--warn);
  background: color-mix(in srgb, var(--warn) 10%, var(--panel));
}
.sched-chip.pending-preview {
  background: transparent;
  border-style: dashed;
  border-color: var(--team-color, var(--muted));
  cursor: pointer;
}
.sched-chip.pending-preview .sched-chip-time,
.sched-chip.pending-preview .sched-chip-customer { color: var(--ink-soft); }
/* A team has accepted this offer (request-mode hold) — solid green outline so
   ops can spot "ready to assign" at a glance vs a still-pending dashed ghost. */
.sched-chip.accepted-preview {
  background: color-mix(in srgb, var(--ok) 10%, var(--panel));
  border-style: solid;
  border-color: var(--ok);
  cursor: pointer;
}
.sched-chip.accepted-preview .sched-chip-time,
.sched-chip.accepted-preview .sched-chip-customer { color: var(--ink-soft); }
.sched-chip-time { font-family: var(--mono); font-weight: 500; color: var(--ink-soft); font-size: 0.74rem; }
.sched-chip-service { font-weight: 600; }
.sched-chip-customer { color: var(--muted); font-size: 0.72rem; }
/* Marks a chip whose booking is assigned to more than one team (mig 0211):
   the same booking appears on each team's lane, so this tag distinguishes it
   from a genuine double-booking. */
.sched-chip-shared {
  display: inline-block; margin-top: 2px; padding: 0 5px;
  border-radius: 999px; background: var(--accent-soft, #e0e7ff); color: var(--accent, #4338ca);
  font-size: 0.62rem; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase;
}
.sched-chip-urgent {
  display: inline-block; margin-top: 2px; padding: 0 5px;
  border-radius: 999px; background: #fef3c7; color: #92400e;
  font-size: 0.62rem; font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase;
}

.sched-chip-badge {
  position: absolute; top: 2px; right: 2px;
  min-width: 18px; height: 18px; padding: 0 5px;
  border: 0; border-radius: 999px;
  background: var(--warn); color: white;
  font-size: 0.7rem; font-weight: 600;
  cursor: pointer; line-height: 18px;
}
.sched-chip-broadcast {
  position: absolute; bottom: 2px; right: 2px;
  width: 18px; height: 18px;
  border: 1px solid var(--rule); border-radius: 50%;
  background: white; color: var(--accent);
  font-size: 0.85rem; line-height: 14px;
  cursor: pointer;
}
/* Compact assign/decline actions on an accepted ghost chip — ✓ assigns the
   offer in place (behind hx-confirm), ✕ declines it (reason via prompt). */
.sched-chip-actions { display: flex; gap: 4px; margin-top: 3px; }
.sched-chip-assign, .sched-chip-decline {
  width: 20px; height: 20px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%;
  color: white; cursor: pointer;
}
.sched-chip-assign { background: var(--ok); }
.sched-chip-decline { background: var(--muted); }
.sched-chip-assign:hover, .sched-chip-decline:hover { filter: brightness(1.1); }
.sched-chip-assign svg, .sched-chip-decline svg { width: 11px; height: 11px; }
/* An accepted offer exists, so the unassigned source chip goes ghost (dashed,
   faded) — the emphasis moves to the accepted chip on the team's row. */
.sched-chip.unassigned.held {
  border-style: dashed;
  background: transparent;
  opacity: 0.65;
}

.sched-unavail {
  display: block;
  padding: 0.25rem 0.4rem;
  margin-bottom: 0.25rem;
  font-size: 0.72rem;
  border: 1px dashed var(--muted);
  border-radius: var(--radius);
  background: repeating-linear-gradient(
    -45deg,
    rgba(148, 163, 184, 0.10) 0px,
    rgba(148, 163, 184, 0.10) 4px,
    rgba(148, 163, 184, 0.20) 4px,
    rgba(148, 163, 184, 0.20) 8px
  );
  color: var(--ink-soft);
}
.sched-unavail .sched-chip-time { font-size: 0.7rem; }
.sched-unavail-label { display: block; font-style: italic; }

.sched-chip.has-conflict {
  outline: 2px solid #f97316;
  outline-offset: -2px;
}
.sched-chip.has-conflict::after {
  content: "!";
  position: absolute; top: 2px; right: 2px;
  width: 14px; height: 14px;
  background: #f97316; color: white;
  border-radius: 50%;
  font-size: 0.7rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* Portal week view: single-team grid — no row-head column, compact day-row. */
.sched-grid-portal {
  grid-template-columns: repeat(7, minmax(140px, 1fr));
  grid-auto-rows: min-content;
  min-width: 980px;
  min-height: 0;
}
.sched-grid-portal .sched-day-head {
  padding: 0.2rem 0.4rem;
  font-size: 0.72rem;
  line-height: 1.2;
  position: static;
}
.sched-grid-portal .sched-cell { min-height: 90px; }

.portal-week-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 1rem;
  align-items: start;
}
@media (max-width: 900px) {
  .portal-week-layout { grid-template-columns: 1fr; }
}

.portal-cal {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.6rem 0.7rem;
  font-size: 0.8rem;
}
.portal-cal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.5rem;
}
.portal-cal-nav {
  padding: 0.1rem 0.5rem;
  text-decoration: none;
  color: var(--ink-soft);
  border-radius: var(--radius);
}
.portal-cal-nav:hover { background: var(--accent-soft); }
.portal-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.portal-cal-dow {
  text-align: center;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--muted);
  padding: 0.15rem 0;
}
.portal-cal-day {
  text-align: center;
  padding: 0.3rem 0;
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
  font-variant-numeric: tabular-nums;
}
.portal-cal-day:hover { background: var(--accent-soft); }
.portal-cal-day.oom { color: var(--muted); opacity: 0.55; }
.portal-cal-day.today { font-weight: 700; outline: 1px solid var(--accent); }
.portal-cal-day.in-week { background: var(--accent-soft); }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 500;
}
.badge-warn { background: #fef0c7; color: var(--warn); }
.page-head-meta { display: flex; align-items: center; gap: 0.6rem; }

.icon-field {
  margin: 0.25rem 0 0.5rem;
}
.icon-preview {
  position: relative;
  display: inline-block;
  padding: 4px;
  border: 1px solid var(--rule-soft);
  border-radius: 6px;
  background: #fff;
}
.icon-preview img { display: block; }
.icon-remove-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
.icon-remove-btn:hover { background: var(--bg-soft); }

/* ---- Chat -------------------------------------------------------------- */
.chat-page { display: grid; grid-template-columns: 260px 1fr; gap: 1rem; align-items: start; }
@media (max-width: 720px) { .chat-page { grid-template-columns: 1fr; } }
.chat-rail { background: var(--panel); border: 1px solid var(--rule); border-radius: 8px; padding: 0.5rem; }
.chat-rail-head { padding: 0.25rem 0.5rem 0.4rem; }
.chat-rail-head h2 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; margin: 0; color: var(--muted); }
.chat-conv-list { list-style: none; margin: 0 0 0.5rem; padding: 0; }
.chat-conv a { display: flex; flex-direction: column; padding: 0.4rem 0.55rem; border-radius: 6px; text-decoration: none; color: var(--ink); }
.chat-conv a:hover { background: var(--bg-soft); }
.chat-conv.active a { background: var(--bg-soft); }
.chat-conv.unread .chat-conv-name { font-weight: 600; }
.chat-conv-name { font-size: 0.95rem; }
.chat-conv-preview { color: var(--muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-conv-role { font-size: 0.72rem; }
.chat-conv-badge {
  align-self: flex-end;
  background: #2f81f6; color: #fff; font-size: 0.72rem;
  border-radius: 999px; padding: 0 0.45rem; min-width: 1.1rem; text-align: center;
}
.chat-thread { background: var(--panel); border: 1px solid var(--rule); border-radius: 8px; display: flex; flex-direction: column; min-height: 60vh; }
.chat-empty { padding: 2rem; }
.chat-thread-head { padding: 0.75rem 1rem; border-bottom: 1px solid var(--rule-soft); display: flex; gap: 0.5rem; align-items: baseline; }
.chat-thread-head h1 { margin: 0; font-size: 1.05rem; }
.chat-bubbles { list-style: none; margin: 0; padding: 1rem; flex: 1; overflow-y: auto; max-height: 60vh; }
.chat-bubble { margin: 0.35rem 0; max-width: 75%; padding: 0.5rem 0.7rem; border-radius: 12px; }
.chat-bubble.me   { margin-left: auto; }
.chat-bubble.them { margin-right: auto; }
.chat-bubble.kind-booking_forward { background: #fff7ed; border: 1px dashed #f59e0b; }
.chat-bubble .chat-body { white-space: pre-wrap; word-break: break-word; }
.chat-time { display: block; font-size: 0.7rem; color: var(--muted); margin-top: 0.25rem; }
.chat-system { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.chat-system-label { font-weight: 600; color: #92400e; }
.chat-attachments { list-style: none; margin: 0.25rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chat-att-img { display: block; max-width: 240px; max-height: 240px; border-radius: 6px; object-fit: cover; }
.chat-att-file { display: flex; align-items: center; gap: 0.3rem; padding: 0.25rem 0.5rem; background: var(--bg-soft); border-radius: 6px; font-size: 0.82rem; text-decoration: none; color: var(--ink); }
.chat-att-file:hover { background: var(--rule); }
.chat-att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.chat-attach-btn { cursor: pointer; font-size: 1.1rem; padding: 0.25rem; line-height: 1; color: var(--muted); }
.chat-attach-btn:hover { color: var(--ink); }
.chat-typing { min-height: 1.2rem; padding: 0 0.75rem 0.25rem; font-size: 0.78rem; color: var(--muted); font-style: italic; margin: 0; }
.chat-conv.muted { opacity: 0.65; }
.chat-conv.muted .chat-conv-name { font-weight: 400; }
.chat-mute-glyph { font-size: 0.75em; vertical-align: middle; }
.chat-mute-btn { font-size: 0.8rem; padding: 0.15rem 0.5rem; margin-left: auto; }
.chat-mute-btn.active { background: var(--bg-soft); border-color: var(--rule); color: var(--muted); }
.chat-send { display: flex; gap: 0.5rem; padding: 0.75rem; border-top: 1px solid var(--rule-soft); }
.chat-send textarea { flex: 1; resize: vertical; min-height: 2.2rem; }
.chat-send { position: relative; }
.chat-editor-wrap { flex: 1; position: relative; min-width: 0; }
.chat-editor { min-height: 2.4rem; max-height: 10rem; overflow-y: auto; }

/* ---- mention editor (tasks description + chat composer) ------------------ */
.md-field { position: relative; display: block; }
.md-toolbar { display: flex; align-items: center; gap: 0.35rem; margin: 0.25rem 0; }
.md-btn { border: 1px solid var(--border, #e2e4e8); background: var(--panel); border-radius: 4px; padding: 0.1rem 0.5rem; cursor: pointer; font-size: 0.85rem; }
.md-btn:hover { background: var(--surface-2, #f4f5f7); }
.md-hint { color: var(--muted, #6b7280); font-size: 0.78rem; margin-left: 0.4rem; }
.md-hint kbd { background: var(--surface-2, #eef2fb); border-radius: 3px; padding: 0 0.3rem; font-family: inherit; }
.md-editor { min-height: 6rem; border: 1px solid var(--border, #e2e4e8); border-radius: 6px; padding: 0.5rem 0.6rem; background: var(--panel); line-height: 1.5; outline: none; }
.md-editor:focus { border-color: var(--accent, #3a5bbf); }
.md-editor.is-empty:before { content: attr(data-placeholder); color: var(--muted, #9aa0ab); pointer-events: none; }
.md-editor ul { margin: 0.25rem 0 0.25rem 1.25rem; }
.md-editor.chat-editor { min-height: 2.4rem; }
.crm-pill { display: inline-block; background: var(--surface-2, #eef2fb); color: #3a5bbf; border-radius: 999px; padding: 0.02rem 0.5rem; font-size: 0.85em; line-height: 1.5; white-space: nowrap; text-decoration: none; cursor: pointer; }
.crm-pill[data-href]:hover, a.crm-pill:hover { filter: brightness(0.95); text-decoration: underline; }
.crm-pill--booking { background: #eef6ee; color: #3a7d44; }
.crm-pill--lead { background: #fef6e8; color: #9a6a1a; }
.crm-pill--charge { background: #fdecea; color: #b3261e; }
.crm-pill--team, .crm-pill--user { background: #f0eefb; color: #5b3abf; }
.chat-body .crm-pill { margin: 0 0.05rem; }
.mention-pop { position: absolute; z-index: 50; min-width: 240px; max-width: 360px; background: var(--panel); border: 1px solid var(--border, #e2e4e8); border-radius: 6px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); max-height: 260px; overflow-y: auto; }
.mention-item { padding: 0.4rem 0.6rem; cursor: pointer; display: flex; gap: 0.45rem; align-items: baseline; }
.mention-item.is-sel, .mention-item:hover { background: var(--surface-2, #eef2fb); }
.mention-kind { color: var(--muted, #6b7280); font-size: 0.72rem; text-transform: uppercase; flex: 0 0 auto; }
.mention-empty { padding: 0.45rem 0.6rem; color: var(--muted, #6b7280); }
.btn.small { padding: 0.15rem 0.5rem; font-size: 0.8rem; }
.chat-badge {
  display: inline-block; min-width: 1.1rem; padding: 0 0.4rem;
  border-radius: 999px; font-size: 0.7rem; line-height: 1.3;
  background: transparent; color: transparent;
}
.chat-badge.badge-on { background: var(--accent); color: #fff; }

.booking-show-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: start;
}
.booking-show-main { min-width: 0; }
.booking-summary {
  position: sticky;
  top: 24px;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 20px 22px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(20, 58, 134, 0.18);
}
.booking-summary h2 {
  margin: 0 0 12px;
  font-size: 1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
}
.booking-summary dl {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  row-gap: 6px;
  column-gap: 12px;
}
.booking-summary dt { font-weight: 400; opacity: 0.92; }
.booking-summary dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.booking-summary dt.sub-line {
  padding-left: 14px;
  font-size: 0.85em;
  opacity: 0.75;
}
.booking-summary dd.sub-line {
  font-size: 0.85em;
  opacity: 0.75;
}
.booking-summary dt.sub-line .muted { color: rgba(255, 255, 255, 0.6); font-size: 0.92em; }
.booking-summary dt.bt-line,
.booking-summary dd.bt-line {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.25);
  font-weight: 600;
}
.booking-summary .muted { color: rgba(255, 255, 255, 0.7); }
.booking-summary .total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.35);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 900px) {
  .booking-show-layout { grid-template-columns: 1fr; }
  .booking-summary { position: static; }
}

.tier-list { font-variant-numeric: tabular-nums; }

/* ─── INBOX (Chatwoot-style three-pane conversation view) ───────────
   sidebar (conversation list) | conversation | details panel.
   The conversation column is a flex stack: fixed header, scrolling
   message pane, bottom-docked composer. */
.inbox-shell {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 0;
  height: 100vh;
  margin: -1.5rem -1.25rem -3rem;
  background: var(--panel);
  border-left: 1px solid var(--rule);
  overflow: hidden;
}
.inbox-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  grid-template-rows: minmax(0, 1fr);
  min-width: 0; min-height: 0;
}

.inbox-sidebar {
  display: flex; flex-direction: column;
  border-right: 1px solid var(--rule);
  background: var(--panel);
  min-width: 0;
  min-height: 0;
}
.inbox-sidebar__head {
  display: flex; align-items: center; gap: 0.45rem;
  padding: 0.7rem 0.75rem;
}
.inbox-sidebar__head h1 {
  margin: 0; font-size: 0.98rem; font-weight: 600;
}
.inbox-sidebar__spacer { flex: 1; }

/* Chatwoot's status chip next to the title (their "All" pill dropdown) */
.inbox-status-chip {
  display: inline-flex; align-items: center; gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  font: inherit; font-size: 0.72rem; font-weight: 500;
  color: var(--ink-soft); cursor: pointer;
  background: rgba(196, 197, 198, 0.22);                             /* n-alpha-2 */
  border: none; border-radius: 6px;
}
html.dark .inbox-status-chip { background: rgba(147, 153, 176, 0.12); }
.inbox-status-chip:hover { color: var(--ink); }
.inbox-status-menu {
  z-index: 60; min-width: 9rem; padding: 0.3rem;
  background: var(--panel); border: 1px solid var(--rule);
  border-radius: 10px; box-shadow: var(--shadow-lg);
}
.inbox-status-menu__item {
  display: block; padding: 0.35rem 0.6rem;
  font-size: 0.8rem; color: var(--ink-soft);
  border-radius: 6px; text-decoration: none;
}
.inbox-status-menu__item:hover { background: var(--bg-soft); color: var(--ink); text-decoration: none; }
.inbox-status-menu__item.active { color: var(--accent); font-weight: 600; }

/* Funnel dropdown: assignee / sort / unread controls */
.inbox-filter-menu {
  z-index: 60; width: 14rem; padding: 0.65rem 0.7rem;
  background: var(--panel); border: 1px solid var(--rule);
  border-radius: 10px; box-shadow: var(--shadow-lg);
}
.inbox-filter-menu__label {
  display: block; margin-bottom: 0.55rem;
  font-size: 0.72rem; color: var(--ink-soft);
}
.inbox-filter-menu__label select {
  display: block; width: 100%; margin-top: 0.2rem;
  font-size: 0.8rem; padding: 0.3rem 0.4rem;
  border: 1px solid var(--rule); border-radius: 8px;
  background: var(--panel); color: var(--ink);
}
.inbox-filter-menu__check {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.78rem; color: var(--ink-soft); cursor: pointer;
}

.inbox-sidebar__toolbar { padding: 0 0.75rem; }
.inbox-search-row { display: flex; gap: 0.4rem; padding: 0.25rem 0 0.55rem; }
.inbox-search-row.hidden { display: none; }

/* Chatwoot underline tabs */
.inbox-sidebar__tabs {
  display: flex; gap: 0;
  padding: 0 0.75rem;
  border-bottom: 1px solid var(--rule-soft);
}
.inbox-sidebar__tabs .tab {
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem; color: var(--muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.inbox-sidebar__tabs .tab:hover { color: var(--ink); text-decoration: none; }
.inbox-sidebar__tabs .tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-count {
  display: inline-block; min-width: 1.05rem; padding: 0 0.28rem;
  border-radius: 999px; text-align: center;
  background: var(--bg-soft); color: var(--muted);
  font-size: 0.66rem; font-weight: 600; line-height: 1.5;
}
.inbox-sidebar__tabs .tab.active .tab-count { background: var(--accent-soft); color: var(--accent); }

/* Collapsible folder list (Chatwoot's Folders/Inboxes sidebar sections) */
.inbox-folders {
  padding: 0.15rem 0.5rem 0.4rem;
  border-bottom: 1px solid var(--rule-soft);
}
.inbox-folders__head {
  display: flex; align-items: center; gap: 0.45rem;
  width: 100%; padding: 0.35rem 0.4rem;
  font: inherit; font-size: 0.78rem; font-weight: 500;
  color: var(--ink-soft); cursor: pointer;
  background: none; border: none; border-radius: 6px;
  text-align: left;
}
.inbox-folders__head:hover { color: var(--ink); }
.inbox-folders__head > svg:first-child { color: var(--muted); flex-shrink: 0; }
.inbox-folders__chev {
  margin-left: auto; color: var(--muted);
  transition: transform 0.2s ease;
}
/* Preline toggles `hidden` on the content — key the chevron off that */
.inbox-folders:has(.inbox-folders__list.hidden) .inbox-folders__chev { transform: rotate(-90deg); }
.inbox-folders__item {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.32rem 0.4rem 0.32rem 1.5rem;
  font-size: 0.8rem; color: var(--ink-soft);
  border-radius: 6px; text-decoration: none;
}
.inbox-folders__item svg { width: 14px; height: 14px; flex-shrink: 0; color: var(--muted); }
.inbox-folders__item:hover { background: var(--bg-soft); color: var(--ink); text-decoration: none; }
.inbox-folders__item.active { background: rgba(196, 197, 198, 0.22); color: var(--ink); font-weight: 500; }
html.dark .inbox-folders__item.active { background: rgba(147, 153, 176, 0.12); }
.inbox-folders__item.active svg { color: var(--accent); }
.inbox-folders__sep { height: 1px; margin: 0.3rem 0.4rem 0.3rem 1.5rem; background: var(--rule-soft); }
.inbox-folders__count {
  margin-left: auto;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.1rem; height: 1.05rem; padding: 0 0.32rem;
  border-radius: 999px;
  background: var(--accent); color: #fff;
  font-size: 0.64rem; font-weight: 600; line-height: 1;
}

.inbox-sidebar__scroll { flex: 1; overflow-y: auto; }
.inbox-sidebar__empty { padding: 1rem; }

.inbox-mailbox-banner {
  display: block;
  padding: 0.55rem 0.85rem;
  margin: 0;
  background: #fff7e6;
  border-bottom: 1px solid #f2c98b;
  color: var(--warn);
  font-size: 0.78rem;
  text-decoration: none;
}
.inbox-mailbox-banner:hover { background: #ffefcc; text-decoration: none; }
.inbox-mailbox-banner strong { display: block; color: var(--warn); }
.inbox-mailbox-banner .muted { font-size: 0.72rem; }

.inbox-date-head {
  margin: 0; padding: 0.7rem 1rem 0.25rem;
  font-size: 0.68rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted);
  background: var(--bg);
  position: sticky; top: 0; z-index: 1;
}

.inbox-list {
  list-style: none; margin: 0; padding: 0;
}

/* Identity avatars — Chatwoot Avatar.vue palette (6 light/dark pairs,
   picked by name length % 6; see view.avClass). */
.av-0 { background: #FBDCEF; color: #C2298A; }
.av-1 { background: #FFE0BB; color: #99543A; }
.av-2 { background: #E8E8E8; color: #60646C; }
.av-3 { background: #CCF3EA; color: #008573; }
.av-4 { background: #EBEBFE; color: #4747C2; }
.av-5 { background: #E1E9FF; color: #3A5BC7; }
html.dark .av-0 { background: #4B143D; color: #FF8DCC; }
html.dark .av-1 { background: #3F220D; color: #FFA366; }
html.dark .av-2 { background: #2A2A2A; color: #ADB1B8; }
html.dark .av-3 { background: #023B37; color: #0BD8B6; }
html.dark .av-4 { background: #27264D; color: #A19EFF; }
html.dark .av-5 { background: #1D2E62; color: #9EB1FF; }

/* Conversation card (Chatwoot ConversationCard.vue anatomy):
   avatar | name + [channel-chip · time] / preview / meta+unread */
.inbox-row {
  position: relative;
  border-bottom: 1px solid var(--rule-soft);
  transition: background 0.1s;
}
.inbox-row > a {
  display: flex; gap: 0.75rem; align-items: flex-start;
  padding: 0.8rem 0.85rem;
  color: inherit; text-decoration: none;
}
.inbox-row > a:hover { text-decoration: none; }
.inbox-row:hover { background: rgba(215, 215, 215, 0.22); }       /* n-alpha-1 */
html.dark .inbox-row:hover { background: rgba(35, 36, 42, 0.8); }
.inbox-row.active { background: rgba(215, 215, 215, 0.22); }
html.dark .inbox-row.active { background: rgba(35, 36, 42, 0.8); }
.inbox-row.active::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--accent);
}
.inbox-row.unread .inbox-row__subject { font-weight: 600; color: var(--ink); }
.inbox-row.unread .inbox-row__from { font-weight: 700; }

.inbox-row__avatar {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  margin-top: 1px;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 500; font-size: 0.68rem; text-transform: uppercase;
  outline: 1px solid rgba(0, 0, 0, 0.03); outline-offset: -1px;
}
html.dark .inbox-row__avatar { outline-color: rgba(255, 255, 255, 0.04); }
.inbox-row__main { flex: 1; min-width: 0; }

.inbox-row__head {
  display: flex; justify-content: space-between; align-items: center; gap: 0.5rem;
  margin-bottom: 0.1rem;
}
.inbox-row__from {
  font-size: 0.86rem; font-weight: 500; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; min-width: 0;
}
.inbox-row__right { display: inline-flex; align-items: center; gap: 0.4rem; flex-shrink: 0; }
.inbox-row__chan {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 999px;
  background: rgba(196, 197, 198, 0.22);                            /* n-alpha-2 */
  color: var(--ink-soft);
}
html.dark .inbox-row__chan { background: rgba(147, 153, 176, 0.12); }
.inbox-row__chan svg { width: 11px; height: 11px; }
.inbox-row__when {
  font-size: 0.72rem; color: var(--muted); flex-shrink: 0;
}
.inbox-row__subject {
  font-size: 0.8rem; color: var(--ink-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.inbox-row__snippet {
  font-size: 0.78rem; color: var(--muted);
  margin-top: 0.1rem; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.inbox-row__meta {
  display: flex; gap: 0.4rem; align-items: center;
  margin-top: 0.3rem;
}
.inbox-row__mailbox {
  font-size: 0.68rem; color: var(--muted);
}
.inbox-row__chip {
  font-size: 0.66rem; padding: 0.05rem 0.35rem;
  background: var(--bg-soft); color: var(--muted);
  border-radius: 3px;
}
.inbox-row__snoozed {
  display: inline-flex; align-items: center; gap: 0.2rem;
  font-size: 0.68rem; font-weight: 500; color: #ab6400;             /* amber-11 */
}
html.dark .inbox-row__snoozed { color: #ffca16; }
/* Missive-style red Draft marker ahead of the recipient name */
.inbox-row__draftmark {
  margin-right: 0.35rem;
  font-size: 0.66rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.02em;
  color: #ce2c31;                                                    /* red-11 */
}
html.dark .inbox-row__draftmark { color: #ff9592; }
.inbox-row__count {
  margin-left: auto;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.1rem; height: 1.1rem; padding: 0 0.3rem;
  border-radius: 999px;
  background: var(--accent); color: #fff;                            /* n-brand */
  font-size: 0.66rem; font-weight: 600; line-height: 1;
}
/* customer/booking-page embeds keep the old stacked row markup */
.inbox-list--embed .inbox-row > a { display: block; }
.chan-pill {
  display: inline-block;
  font-size: 0.62rem; font-weight: 600; letter-spacing: 0.04em;
  padding: 0.08rem 0.4rem;
  border-radius: 3px;
  text-transform: uppercase;
  vertical-align: middle;
  flex-shrink: 0;
}
.chan-pill.chan-email { background: #edf4fe; color: #174a99; }
.chan-pill.chan-sms   { background: #e6f6ec; color: #2c7a3e; }
.inbox-timeline__actions {
  display: flex; gap: 0.4rem; flex-wrap: wrap;
}

/* ─── INBOX (conversation column) ───────────────────────────────────── */
.inbox-detail {
  display: flex; flex-direction: column;
  background: #fefefe;                                               /* n-surface-1 */
  min-height: 0; min-width: 0;
}
html.dark .inbox-detail { background: #141517; }
.inbox-detail--empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.inbox-empty {
  display: flex; flex-direction: column; align-items: center; gap: 0.6rem;
  color: var(--muted);
}
.inbox-main .inbox-detail { border-right: 1px solid var(--rule); }

.inbox-detail__head {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 0.65rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}
.inbox-detail__title { min-width: 0; }
.inbox-detail__title h1 {
  margin: 0; font-size: 0.95rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.inbox-detail__title p { margin: 0.15rem 0 0; font-size: 0.74rem; }

.inbox-detail__actions {
  display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap;
  justify-content: flex-end; flex-shrink: 0;
}
.inbox-detail__actions form.inline { display: flex; gap: 0.3rem; align-items: center; }
.inbox-detail__actions input[type="datetime-local"] {
  font-size: 0.76rem; padding: 0.2rem 0.4rem;
  border: 1px solid var(--rule); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--ink);
}
.inbox-jump-latest { white-space: nowrap; }
.inbox-detail__avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 500; font-size: 0.8rem; text-transform: uppercase;
}
.inbox-snoozed-until { font-weight: 500; color: #ffba18; }          /* amber-10 */
html:not(.dark) .inbox-snoozed-until { color: #ab6400; }            /* amber-11 (light) */

/* Resolve button group — v4 uses SLATE (ResolveAction.vue), not green:
   white/dark-slate joined pair with a caret dropdown for Snooze. */
.inbox-resolve-group { display: inline-flex; align-items: stretch; }
.inbox-resolve-main {
  border-top-right-radius: 0; border-bottom-right-radius: 0;
}
.inbox-resolve-caret {
  border-top-left-radius: 0; border-bottom-left-radius: 0;
  margin-left: -1px; padding-left: 0.4rem; padding-right: 0.4rem;
}
html.dark .inbox-resolve-main, html.dark .inbox-resolve-caret {
  background: #2a2b33; border-color: transparent;                    /* n-button-color dark */
}
.inbox-resolve-menu {
  z-index: 60; margin-top: 4px; padding: 0.6rem 0.7rem;
  background: var(--panel); border: 1px solid var(--rule);
  border-radius: 10px; box-shadow: var(--shadow-lg);
}
.inbox-snooze-form { display: flex; flex-direction: column; gap: 0.4rem; }
.inbox-snooze-form label { font-size: 0.72rem; }
.inbox-snooze-form input[type="datetime-local"] {
  font-size: 0.78rem; padding: 0.25rem 0.4rem;
  border: 1px solid var(--rule); border-radius: 8px;
  background: var(--panel); color: var(--ink);
}

/* scrolling message pane between the header and the composer */
.inbox-scroll {
  flex: 1; min-height: 0;
  overflow-y: auto;
}

.status-pill {
  display: inline-block; padding: 0.05rem 0.45rem;
  font-size: 0.7rem; font-weight: 500;
  border-radius: 999px; background: var(--bg-soft); color: var(--ink-soft);
}
.status-pill.st-open { background: rgba(18, 165, 148, 0.12); color: #008573; }   /* teal-11 */
html.dark .status-pill.st-open { color: #0bd8b6; }
.status-pill.st-closed { background: var(--bg-soft); color: var(--muted); }
.status-pill.st-snoozed { background: rgba(255, 197, 61, 0.16); color: #ab6400; } /* amber-11 */
html.dark .status-pill.st-snoozed { color: #ffca16; }

/* messages — hybrid rendering (Chatwoot-informed): emails stay full-width
   cards, SMS renders as chat bubbles (outgoing blue, right), private notes
   as yellow blocks, events as centred pills. */
.inbox-messages {
  list-style: none; margin: 0; padding: 1rem 1.25rem;
}
.inbox-msg {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 0.85rem;
  scroll-margin-top: 1rem;
}

/* email card */
.inbox-msg--in,
.inbox-msg--out {
  padding: 1rem 1.1rem;
  margin: 0 0 0.85rem;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(11, 20, 36, 0.03);
}
.inbox-msg--out {
  background: hsl(212 100% 99%);
}

/* SSE-delivered bubble — brief highlight so ops sees a new message landed
   even when the thread was already open + auto-marked-read. */
.inbox-msg.is-fresh {
  animation: inboxMsgFlash 2.5s ease-out;
}
@keyframes inboxMsgFlash {
  0%   { background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-soft); }
  60%  { background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-soft); }
  100% { background: var(--panel); box-shadow: 0 1px 2px rgba(11, 20, 36, 0.03); }
}
.inbox-msg--out.is-fresh {
  animation-name: inboxMsgFlashOut;
}
@keyframes inboxMsgFlashOut {
  0%, 60% { background: #cfe0ff; }
  100%    { background: hsl(212 100% 99%); }
}

/* avatar */
.inbox-msg__avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-soft); color: var(--ink-soft);
  font-weight: 600; font-size: 0.85rem;
  text-transform: uppercase;
  flex-shrink: 0;
}
.inbox-msg--out .inbox-msg__avatar { background: var(--accent); color: var(--accent-ink); }

.inbox-msg__head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.inbox-msg__from { font-weight: 600; font-size: 0.88rem; }
.inbox-msg__time { font-size: 0.72rem; flex-shrink: 0; }
.inbox-msg__body { min-width: 0; }
.inbox-msg__text {
  font-family: var(--sans); white-space: pre-wrap;
  margin: 0; font-size: 0.9rem; line-height: 1.55; color: var(--ink-soft);
}
/* HTML bodies render inside a sandboxed iframe (CSS isolation — app styles
   can't reach in, the email's styles can't leak out). JS sizes height to
   content; see sizeInboxFrames in inbox_thread.html. */
.inbox-msg__frame {
  width: 100%; border: 0; display: block;
  min-height: 1.5rem; background: #fff; color-scheme: light;
}
.inbox-msg--out .inbox-msg__text { color: var(--ink); }

/* Gmail-style trimmed-content toggle for plain-text quoted replies. The
   HTML-body equivalent lives inside the iframe srcdoc (emailQuoteStyle in
   thread_handler.go) because app styles can't reach into the sandbox. */
.inbox-msg__quote-toggle {
  display: inline-block; cursor: pointer;
  margin: 0.5rem 0 0.15rem; padding: 1px 8px;
  font-size: 15px; line-height: 11px; letter-spacing: 2px;
  color: var(--ink-soft); background: var(--bg-soft);
  border: 1px solid var(--rule); border-radius: 8px;
  user-select: none;
}
.inbox-msg__quote-toggle:hover { background: var(--rule); }
.inbox-msg__quote { color: var(--muted); }

/* downloadable (non-inline) attachment chips below a message body */
.inbox-msg__atts {
  list-style: none; margin: 0.6rem 0 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 0.4rem;
}
.inbox-msg__att {
  display: inline-flex; align-items: center; gap: 0.4rem;
  max-width: 18rem;
  padding: 0.3rem 0.6rem;
  background: var(--bg-soft); border: 1px solid var(--rule);
  border-radius: 8px; font-size: 0.82rem; color: var(--ink);
  text-decoration: none;
}
.inbox-msg__att:hover { border-color: var(--accent); text-decoration: none; }
.inbox-msg__att-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.inbox-msg__att-size { flex-shrink: 0; font-size: 0.74rem; }

/* internal note — Chatwoot yellow block */
.inbox-msg--internal_note {
  display: block;
  margin: 0 0 0.85rem;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}
.inbox-msg__note {
  padding: 0.65rem 1rem;
  background: #ffe4b5;                                              /* n-solid-amber */
  border-radius: 12px;
}
html.dark .inbox-msg__note { background: #383229; }
.inbox-msg--internal_note .inbox-msg__head {
  margin-bottom: 0.25rem;
  font-size: 0.78rem;
}
.inbox-msg--internal_note .inbox-msg__label {
  font-weight: 600; color: #4f3422;                                  /* amber-12 */
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em;
}
.inbox-msg__from--note {
  font-size: 0.76rem; font-weight: 500; color: rgba(79, 52, 34, 0.7);
  margin-left: 0.25rem; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.inbox-msg--internal_note .inbox-msg__time { color: rgba(79, 52, 34, 0.5); }
.inbox-msg--internal_note .inbox-msg__text {
  font-size: 0.85rem; color: #4f3422;                                /* amber-12 */
}
html.dark .inbox-msg--internal_note .inbox-msg__label,
html.dark .inbox-msg--internal_note .inbox-msg__text { color: #ffe7b3; }
html.dark .inbox-msg__from--note { color: rgba(255, 231, 179, 0.7); }
html.dark .inbox-msg--internal_note .inbox-msg__time { color: rgba(255, 231, 179, 0.5); }

/* SMS — chat bubbles per v4 Base.vue: incoming = slate-4 fill, outgoing =
   n-solid-blue (light-blue fill, slate-12 text in light; deep blue in dark).
   Timestamp sits INSIDE the bubble (MessageMeta.vue). */
.inbox-msg--sms {
  display: block;
  max-width: min(32rem, 78%);
  margin: 0 0 0.7rem;
}
.inbox-msg--sms-out { margin-left: auto; text-align: right; }
.inbox-msg__bubble {
  display: inline-block; text-align: left;
  padding: 0.65rem 1rem;
  background: #e8e8ec;                                              /* slate-4 */
  border-radius: 12px;
  border-bottom-left-radius: 2px;
  color: var(--ink);
}
html.dark .inbox-msg__bubble { background: #272a2d; }
.inbox-msg--sms-out .inbox-msg__bubble {
  background: #daecff;                                              /* n-solid-blue */
  border-radius: 12px;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 2px;
}
html.dark .inbox-msg--sms-out .inbox-msg__bubble { background: #0f3966; }
.inbox-msg--sms .inbox-msg__text { font-size: 0.88rem; color: var(--ink); }
.inbox-msg__bubble-meta {
  display: block; margin-top: 0.4rem; font-size: 0.7rem; color: var(--ink-soft);
}
.inbox-msg--sms.is-fresh { animation: none; }
.inbox-msg--sms-in.is-fresh .inbox-msg__bubble { animation: none; box-shadow: 0 0 0 2px var(--accent-soft); }

/* thread activity event — centred pill, no avatar, no card chrome */
.inbox-msg--event {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  grid-template-columns: unset;
  margin: 0.5rem 0;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}
.inbox-msg__event-text {
  font-size: 0.75rem;
  color: var(--ink-soft);
}
.inbox-msg--event .inbox-msg__time {
  font-size: 0.7rem;
}

/* ─── INBOX intent chip (agent-proposed actions above the composer) ── */
.inbox-intent {
  flex-shrink: 0;
  margin: 0 0.6rem 0.35rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid #fcd34d;
  background: #fffbeb;
  border-radius: 10px;
  font-size: 0.82rem;
}
html.dark .inbox-intent {
  border-color: rgba(252, 211, 77, 0.35);
  background: rgba(252, 211, 77, 0.08);
}
.inbox-intent--applied {
  border-color: #86efac;
  background: #f0fdf4;
}
html.dark .inbox-intent--applied {
  border-color: rgba(134, 239, 172, 0.35);
  background: rgba(134, 239, 172, 0.08);
}
.inbox-intent__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}
.inbox-intent__badge {
  font-weight: 600;
  color: #92400e;
}
html.dark .inbox-intent__badge {
  color: #fcd34d;
}
.inbox-intent--applied .inbox-intent__badge {
  color: #166534;
}
html.dark .inbox-intent--applied .inbox-intent__badge {
  color: #86efac;
}
.inbox-intent__run {
  font-size: 0.72rem;
  color: var(--ink-soft);
}
.inbox-intent__muted {
  color: var(--ink-soft);
}
.inbox-intent__actions {
  list-style: none;
  margin: 0 0 0.4rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.inbox-intent__detail {
  display: block;
  color: var(--ink-soft);
  white-space: pre-wrap;
}
.inbox-intent__buttons {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.inbox-intent__adjust-form {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.35rem;
}
.inbox-intent__adjust-form[hidden] {
  display: none;
}
.inbox-intent__adjust-form input[type="text"] {
  flex: 1;
  font-size: 0.78rem;
  padding: 0.35rem 0.5rem;
}

/* ─── INBOX composer (Chatwoot ReplyBox: floating rounded card with a
   pill mode-toggle; whole card turns amber in Private Note mode) ───── */
.inbox-composer {
  flex-shrink: 0;
  margin: 0 0.6rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--panel);                                          /* n-solid-1 */
  overflow: visible;
}
.inbox-composer:has(#composer-note:not(.hidden)) {
  background: #ffe4b5;                                               /* n-solid-amber */
  border-color: rgba(79, 52, 34, 0.05);
}
html.dark .inbox-composer:has(#composer-note:not(.hidden)) {
  background: #383229;
  border-color: rgba(255, 197, 61, 0.1);
}
.inbox-composer__tabs {
  display: inline-flex; align-items: center; gap: 0;
  height: 32px; padding: 3px;
  margin: 0.6rem 0 0 0.75rem;
  border-radius: 999px;
  background: rgba(196, 197, 198, 0.22);                             /* n-alpha-2 */
  border: 1px solid var(--rule-soft);
}
html.dark .inbox-composer__tabs { background: rgba(147, 153, 176, 0.12); border-color: transparent; }
.inbox-composer__tab {
  display: inline-flex; align-items: center;
  height: 24px; padding: 0 0.65rem;
  font: inherit; font-size: 0.76rem; font-weight: 500;
  color: var(--ink-soft);
  background: none; border: none; cursor: pointer;
  border-radius: 999px;
}
.inbox-composer__tab.active {
  background: var(--panel); color: var(--ink);                       /* sliding white chip */
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
html.dark .inbox-composer__tab.active { background: #17171a; }       /* n-solid-1 dark */
#composer-note { background: transparent; }

.inbox-reply, .inbox-note { padding: 0.5rem 0.75rem 0.75rem; }
/* Email addressing — Chatwoot ReplyEmailHead: borderless underline rows */
.inbox-reply__meta {
  display: block;
  margin-bottom: 0.35rem;
}
.inbox-reply__meta label {
  display: flex; align-items: center; gap: 0.5rem;
  height: 2.4rem;
  font-size: 0.72rem; font-weight: 600; color: var(--ink-soft);
  border-bottom: 1px solid var(--rule);
}
.inbox-reply__meta input {
  flex: 1; min-width: 0; height: 100%;
  padding: 0; margin: 0;
  font-family: var(--sans); font-size: 0.84rem; font-weight: 400;
  border: none; background: transparent; color: var(--ink);
}
.inbox-reply__meta input:focus { outline: none; box-shadow: none; }
.inbox-reply textarea,
.inbox-note textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
  font-family: var(--sans); font-size: 0.88rem;
  border: none; border-radius: 8px;
  background: transparent; color: var(--ink);
  resize: vertical;
}
.inbox-reply textarea:focus, .inbox-note textarea:focus { outline: none; box-shadow: none; }
.inbox-note textarea { color: #4f3422; }
.inbox-note textarea::placeholder { color: rgba(79, 52, 34, 0.55); }
html.dark .inbox-note textarea { color: #ffe7b3; }
html.dark .inbox-note textarea::placeholder { color: rgba(255, 231, 179, 0.55); }
.inbox-reply__foot {
  display: flex; align-items: center; gap: 0.5rem;
  margin-top: 0.4rem;
}
.inbox-reply__foot > p { flex: 1; margin: 0; font-size: 0.74rem; }
.inbox-note .inbox-reply__foot > p { color: rgba(79, 52, 34, 0.7); }
html.dark .inbox-note .inbox-reply__foot > p { color: rgba(255, 231, 179, 0.7); }
.inbox-send { margin-left: auto; }
.inbox-discard { margin-left: auto; color: var(--muted); }
.inbox-discard + .inbox-send { margin-left: 0; }
.inbox-attach { cursor: pointer; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; flex-shrink: 0;
  border: 1px solid transparent; border-radius: 8px;
  color: var(--muted); background: none;
  transition: background 0.12s, color 0.12s;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--ink); }
/* Note send — v4 amber solid ("Add Note (⌘↵)") */
.inbox-note__send { background: #ffc53d; border-color: #ffc53d; color: #4f3422; font-weight: 600; }
.inbox-note__send:hover { background: #ffba18; border-color: #ffba18; color: #4f3422; }

/* Quill (snow) — borderless inside the composer card */
.inbox-reply .ql-toolbar.ql-snow,
.quill-card .ql-toolbar.ql-snow {
  border: none;
  border-bottom: 1px solid var(--rule-soft);
  font-family: var(--sans);
  padding: 0.25rem 0.3rem;
}
html.dark .inbox-reply .ql-toolbar.ql-snow,
html.dark .quill-card .ql-toolbar.ql-snow { border-bottom-color: var(--rule); }
.inbox-reply .ql-container.ql-snow,
.quill-card .ql-container.ql-snow {
  border: none;
  font-family: var(--sans); font-size: 0.9rem;
  background: transparent; color: var(--ink);
}
/* pre-init visibility: an unwired [data-editor] div must still hold space */
.inbox-editor { min-height: 6rem; }
.inbox-reply .ql-editor { min-height: 6rem; max-height: 14rem; }
.inbox-reply .ql-editor.ql-blank::before,
.quill-card .ql-editor.ql-blank::before { color: var(--muted); font-style: normal; }
html.dark .inbox-reply .ql-snow .ql-stroke,
html.dark .quill-card .ql-snow .ql-stroke { stroke: var(--muted); }
html.dark .inbox-reply .ql-snow .ql-fill,
html.dark .quill-card .ql-snow .ql-fill { fill: var(--muted); }
html.dark .inbox-reply .ql-snow .ql-picker,
html.dark .quill-card .ql-snow .ql-picker { color: var(--muted); }
html.dark .inbox-reply .ql-snow.ql-toolbar button:hover .ql-stroke,
html.dark .inbox-reply .ql-snow.ql-toolbar button.ql-active .ql-stroke,
html.dark .quill-card .ql-snow.ql-toolbar button:hover .ql-stroke,
html.dark .quill-card .ql-snow.ql-toolbar button.ql-active .ql-stroke { stroke: var(--accent); }
html.dark .inbox-reply .ql-snow.ql-toolbar button:hover .ql-fill,
html.dark .inbox-reply .ql-snow.ql-toolbar button.ql-active .ql-fill,
html.dark .quill-card .ql-snow.ql-toolbar button:hover .ql-fill,
html.dark .quill-card .ql-snow.ql-toolbar button.ql-active .ql-fill { fill: var(--accent); }

/* ─── INBOX inline compose pane (Missive-style new conversation) ────── */
.inbox-detail__avatar--compose { background: var(--bg-soft); color: var(--muted); }
.inbox-compose-card { margin: 0.6rem; }
.inbox-compose__none { padding: 1rem; }
.inbox-compose__meta select {
  flex: 1; min-width: 0; height: 100%;
  /* background-color (not the shorthand) so the vendored base's chevron
     background-image survives; right padding clears that chevron. */
  padding: 0.3rem 1.75rem 0.3rem 0; margin: 0;
  font-family: var(--sans); font-size: 0.84rem; font-weight: 400;
  border: none; background-color: transparent; color: var(--ink);
}
.inbox-compose__meta select:focus { outline: none; box-shadow: none; }
.inbox-compose__ccbcc { display: inline-flex; gap: 0.2rem; flex-shrink: 0; }
.inbox-compose__ccbcc button {
  padding: 0.1rem 0.4rem;
  font: inherit; font-size: 0.72rem; font-weight: 500;
  color: var(--muted); background: none;
  border: none; border-radius: 6px; cursor: pointer;
}
.inbox-compose__ccbcc button:hover { background: var(--bg-soft); color: var(--ink); }
.inbox-compose__ctx { margin: 0.35rem 0 0; font-size: 0.76rem; }
.inbox-compose__smscount { margin: 0.25rem 0 0; font-size: 0.74rem; }
/* the compose body gets room to breathe — it's the pane, not a reply strip */
.inbox-compose-card .ql-editor { min-height: 12rem; max-height: none; }
/* chip rows wrap, so the fixed underline-row height becomes a minimum */
.inbox-compose__meta label { height: auto; min-height: 2.4rem; }
/* display:flex on meta labels would beat the [hidden] UA rule */
.inbox-compose__meta label[hidden] { display: none; }

/* Recipient chips (compose To/Cc/Bcc) — Missive-style tokens + suggestions */
.inbox-chips {
  position: relative; flex: 1; min-width: 0;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem;
  padding: 0.3rem 0;
}
.inbox-chips__input {
  flex: 1; min-width: 8rem; height: 1.6rem;
  padding: 0; margin: 0;
  font-family: var(--sans); font-size: 0.84rem; font-weight: 400;
  border: none; background: transparent; color: var(--ink);
}
.inbox-chips__input:focus { outline: none; box-shadow: none; }
.inbox-chip {
  display: inline-flex; align-items: center; gap: 0.25rem; max-width: 100%;
  padding: 0.1rem 0.3rem 0.1rem 0.55rem;
  font-size: 0.78rem; font-weight: 500; color: var(--ink);
  background: var(--bg-soft); border: 1px solid var(--rule); border-radius: 999px;
}
.inbox-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-chip__x {
  padding: 0 0.15rem; font-size: 0.9rem; line-height: 1;
  border: none; background: none; color: var(--muted); cursor: pointer;
}
.inbox-chip__x:hover { color: var(--ink); }
.inbox-chips__menu {
  position: absolute; top: 100%; left: 0; z-index: 70;
  min-width: 16rem; max-width: 100%; margin-top: 2px;
  background: var(--panel); border: 1px solid var(--rule);
  border-radius: 10px; box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.inbox-chips__menu ul { list-style: none; margin: 0; padding: 0.25rem; }
.inbox-chips__suggestion {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.05rem;
  width: 100%; padding: 0.35rem 0.5rem;
  font: inherit; font-size: 0.8rem; text-align: left;
  color: var(--ink); background: none; border: none; border-radius: 8px; cursor: pointer;
}
.inbox-chips__suggestion:hover { background: var(--bg-soft); }
.inbox-chips__suggestion small { font-size: 0.72rem; }

/* ─── INBOX details panel (right column — Chatwoot ContactPanel) ────── */
.inbox-panel {
  border-left: 1px solid var(--rule);
  background: var(--panel);
  overflow-y: auto;
  min-height: 0;
}
.inbox-panel__head {
  display: flex; align-items: center; justify-content: space-between;
  height: 48px; padding: 0 1rem;
  border-bottom: 1px solid var(--rule);
}
.inbox-panel__head h2 { margin: 0; font-size: 0.86rem; font-weight: 500; color: var(--ink); }

/* Contact block (ContactInfo.vue): avatar 48 + name, info rows, actions */
.inbox-contact-block { padding: 1rem; border-bottom: 1px solid var(--rule); }
.inbox-contact { display: flex; gap: 0.7rem; align-items: center; margin-bottom: 0.6rem; }
.inbox-contact__avatar {
  width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 500; font-size: 1.1rem; text-transform: uppercase;
  outline: 1px solid rgba(0, 0, 0, 0.03); outline-offset: -1px;
}
html.dark .inbox-contact__avatar { outline-color: rgba(255, 255, 255, 0.04); }
.inbox-contact__meta { min-width: 0; }
.inbox-contact__name {
  display: block; font-size: 0.95rem; font-weight: 500; color: var(--ink);
  text-transform: capitalize;
}
.inbox-contact__name:hover { color: var(--ink); }
.inbox-contact__rows { display: flex; flex-direction: column; gap: 0.45rem; margin-bottom: 0.7rem; }
.inbox-contact__line {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.8rem; color: var(--ink-soft);
  min-width: 0;
}
.inbox-contact__line svg { width: 14px; height: 14px; flex-shrink: 0; color: var(--muted); }
.inbox-contact__actions { display: flex; gap: 0.5rem; margin-bottom: 0.7rem; }
.icon-btn--faded {
  width: 32px; height: 32px;
  background: rgba(128, 131, 141, 0.1);                              /* slate-9/10 */
  color: var(--ink-soft);
}
.icon-btn--faded:hover { background: rgba(128, 131, 141, 0.18); color: var(--ink); }

/* Accordion-look sections (AccordionItem.vue): slate-2 outlined header bar */
.inbox-panel__sec { padding: 0.6rem 0.75rem 0; }
.inbox-panel__sec:last-child { padding-bottom: 0.75rem; }
.inbox-panel__sec-head {
  display: flex; align-items: center;
  margin: 0; padding: 0.5rem 0.9rem;
  font-size: 0.8rem; font-weight: 500; color: var(--ink);
  background: #f9f9fb;                                               /* slate-2 */
  border: 1px solid var(--rule);
  border-radius: 10px 10px 0 0;
}
/* Dark: --rule (#1f1f25) on --panel (#1c1e22) is a near-invisible delta, so
   the section cards blend into the panel. Border with n-strong (#2e2d32, the
   dark field border) like the panel's inputs so the cards read again. */
html.dark .inbox-panel__sec-head { background: #18191b; border-color: #2e2d32; }
html.dark .inbox-panel__sec-body { border-color: #2e2d32; }
.inbox-panel__sec-body {
  padding: 0.7rem 0.9rem 0.8rem;
  border: 1px solid var(--rule); border-top: none;
  border-radius: 0 0 10px 10px;
}
.inbox-panel__label {
  display: block; margin: 0.55rem 0 0.25rem;
  font-size: 0.72rem; color: var(--ink-soft);
}
.inbox-panel__label:first-child { margin-top: 0; }
.inbox-panel__row {
  display: flex; gap: 0.4rem; align-items: center;
}
.inbox-panel__row .picker { flex: 1; min-width: 0; }
.inbox-panel__row select {
  flex: 1; min-width: 0;
  font-size: 0.8rem; padding: 0.35rem 0.45rem;
  border: 1px solid var(--rule); border-radius: 8px;
  background: var(--panel); color: var(--ink);
}
.inbox-panel__empty { font-size: 0.78rem; margin: 0 0 0.4rem; }
.inbox-panel__booking { margin: 0 0 0.4rem; font-size: 0.82rem; }

.inbox-panel__prev { list-style: none; margin: 0; padding: 0; }
.inbox-panel__prev a {
  display: block; padding: 0.4rem 0.5rem; margin: 0 -0.5rem;
  border-radius: 8px; text-decoration: none;
}
.inbox-panel__prev a:hover { background: var(--bg-soft); text-decoration: none; }
.inbox-panel__prev-subject {
  display: block; font-size: 0.8rem; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.inbox-panel__prev-meta { font-size: 0.7rem; }

@media (max-width: 1200px) {
  /* details panel stacks under the conversation on narrow screens */
  .inbox-main { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .inbox-main .inbox-detail { border-right: none; }
  .inbox-panel { border-left: none; border-top: 1px solid var(--rule); max-height: 40vh; }
}
@media (max-width: 900px) {
  .inbox-shell { grid-template-columns: 1fr; grid-template-rows: none; height: auto; }
  .inbox-sidebar { border-right: none; border-bottom: 1px solid var(--rule); max-height: 50vh; }
  .inbox-detail { min-height: 70vh; }
}

/* ─── Inbox embed (customer/booking sidebar card) ──────────────────── */
.inbox-timeline__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 0.6rem; margin-bottom: 0.5rem;
}
.inbox-timeline__head h2 { margin: 0; font-size: 0.95rem; }
.inbox-timeline__empty { margin: 0; padding: 0.4rem 0; font-size: 0.85rem; }

.inbox-list--embed {
  list-style: none; margin: 0; padding: 0;
  border: 1px solid var(--rule); border-radius: var(--radius);
  overflow: hidden;
}
.inbox-list--embed .inbox-row { border-bottom: 1px solid var(--rule-soft); }
.inbox-list--embed .inbox-row:last-child { border-bottom: none; }
.inbox-list--embed .inbox-row > a { padding: 0.55rem 0.75rem 0.6rem 1.15rem; }
.inbox-list--embed .inbox-row.unread::after { left: 0.45rem; top: 0.75rem; }

/* ─── INBOX MAILBOX SETTINGS ────────────────────────────────────────── */
.page-head__title { display: flex; flex-direction: column; gap: 0.15rem; }
.page-head__title p { margin: 0; font-size: 0.85rem; }

.empty-state { text-align: center; padding: 2.5rem 1.5rem; }
.empty-state h2 { margin: 0 0 0.4rem; font-size: 1.05rem; }
.empty-state p { margin: 0 0 1rem; }

.mailbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 0.85rem;
  margin-top: 1rem;
}

.mailbox-card {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  display: flex; flex-direction: column; gap: 0.85rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.mailbox-card:hover { border-color: var(--ink-soft); box-shadow: 0 4px 12px rgba(11, 20, 36, 0.06); }
.mailbox-card.is-paused { opacity: 0.85; border-style: dashed; }

.mailbox-card__head {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 0.85rem;
  align-items: start;
}
.mailbox-card__title h3 {
  margin: 0; font-size: 0.95rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mailbox-card__title p { margin: 0.1rem 0 0; font-size: 0.8rem; }

.mailbox-provider {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.78rem;
  color: var(--accent-ink);
}
.mailbox-provider--google { background: #ea4335; }
.mailbox-provider--microsoft { background: #0078d4; }
.mailbox-provider--imap { background: var(--ink-soft); font-size: 0.7rem; }

.mailbox-card__status { display: flex; flex-direction: column; gap: 0.2rem; align-items: flex-end; }

.mailbox-card__meta {
  margin: 0; padding-top: 0.5rem;
  border-top: 1px solid var(--rule-soft);
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 0.85rem;
  font-size: 0.78rem;
}
.mailbox-card__meta > div { display: flex; flex-direction: column; gap: 0.1rem; }
.mailbox-card__meta dt {
  font-size: 0.66rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted);
}
.mailbox-card__meta dd { margin: 0; color: var(--ink-soft); font-family: var(--mono); font-size: 0.75rem; }

.mailbox-card__actions {
  display: flex; flex-wrap: wrap; gap: 0.35rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--rule-soft);
}
.mailbox-card__actions .inline { display: inline; margin: 0; }
.mailbox-card__actions form { margin: 0; }

.pill {
  display: inline-block; padding: 0.1rem 0.5rem;
  font-size: 0.7rem; font-weight: 500;
  border-radius: 999px; background: var(--bg-soft); color: var(--ink-soft);
}
.pill.ok { background: #e8f5ed; color: var(--ok); }
.pill.warn { background: #fff7e6; color: var(--warn); }

/* ─── Generic modal (HTML5 <dialog>) ────────────────────────────────── */
dialog.modal {
  border: none; padding: 0; background: transparent;
  max-width: none; max-height: none;
}
dialog.modal::backdrop { background: rgba(11, 20, 36, 0.45); }
dialog.modal[open] {
  display: flex; align-items: center; justify-content: center;
  width: 100vw; height: 100vh;
  position: fixed; inset: 0; margin: 0;
}
.modal-card {
  background: var(--panel);
  border-radius: var(--radius);
  max-width: 560px; width: calc(100% - 2rem);
  max-height: 85vh; overflow: auto;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.25);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.75rem;
}
.modal-head h2 { margin: 0; font-size: 1.05rem; }
.modal-close {
  background: none; border: 0; cursor: pointer;
  font-size: 1.6rem; line-height: 1; color: var(--muted);
  padding: 0 0.3rem;
}
.modal-close:hover { color: var(--ink); }

/* --- Inbox automation rules ------------------------------------------- */
.badge.muted { background: var(--bg-soft); color: var(--muted); }
.badge.muted::before { display: none; }

/* Draft/Live status shares the rule-name row (P7). One grid cell holding a
   compact badge above its hint; align-items keeps the inline-flex badge at its
   natural size instead of stretching to fill the cell. */
.rule-status { display: flex; flex-direction: column; align-items: flex-start; gap: 0.35rem; }

.rule-list { list-style: none; margin: 1rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.rule-card {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 0.9rem; background: var(--panel);
  border: 1px solid var(--rule); border-radius: 8px;
}
.rule-card--off { opacity: 0.6; }
.rule-card__body { flex: 1 1 auto; min-width: 0; }
.rule-card__head { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.rule-card__summary { display: flex; gap: 0.4rem; flex-wrap: wrap; font-size: 0.82rem; margin-top: 0.2rem; }
.rule-card__actions { display: flex; align-items: center; gap: 0.4rem; flex-shrink: 0; }
.rule-card__actions form { margin: 0; }

.rule-grip { cursor: grab; color: var(--muted); user-select: none; font-size: 1.05rem; line-height: 1; }

/* Zapier-style canvas: centred node cards connected by downward arrows. */
.rule-flow {
  counter-reset: step;
  max-width: 560px; margin: 1.25rem auto 0; padding: 1.5rem 1.25rem;
  border-radius: 14px; border: 1px solid var(--rule);
  background-color: var(--bg);
  background-image: radial-gradient(var(--rule) 1px, transparent 1px);
  background-size: 16px 16px;
}
.flow-node {
  counter-increment: step;
  position: relative; background: var(--panel);
  border: 1px solid var(--rule); border-radius: 12px;
  padding: 0.85rem 1rem; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.flow-node--trigger { border-top: 3px solid var(--accent); }
.flow-node.dragging, .rule-card.dragging { opacity: 0.4; }

/* Connector: a short vertical line centred above every node except the
   trigger. Works for dynamically-added action cards too. */
.flow-node--filter, .flow-node--action { margin-top: 2.6rem; }
.flow-node--filter::before, .flow-node--action::before {
  content: ""; position: absolute; left: 50%; top: -2.4rem;
  transform: translateX(-50%); width: 2px; height: 2rem; background: var(--rule);
}
/* The filter connector (from the fixed trigger) is a plain arrowhead — nothing
   can be inserted there. Action connectors carry a "+" insert button instead. */
.flow-node--filter::after {
  content: ""; position: absolute; left: 50%; top: -1.05rem;
  transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: var(--rule);
}

/* "+" insert button sitting on an action's connector — inserts a new action
   at that gap (Zapier-style insert-between). */
.flow-add-here {
  position: absolute; left: 50%; top: -2.05rem; transform: translateX(-50%); z-index: 2;
  width: 1.5rem; height: 1.5rem; border-radius: 50%; cursor: pointer; padding: 0;
  border: 1px dashed var(--ink-soft); background: var(--panel); color: var(--muted);
  font-size: 1rem; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.flow-add-here:hover { border-color: var(--accent); color: var(--accent); }

.flow-node__head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.55rem; }
.flow-icon {
  width: 1.6rem; height: 1.6rem; border-radius: 7px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; background: var(--accent); color: var(--accent-ink);
}
.flow-icon--filter { background: #6366f1; color: #fff; }
.flow-icon--action { background: var(--bg-soft); color: var(--muted); border: 1px solid var(--rule); cursor: grab; }
.flow-node__type { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }
.flow-step-num { margin-left: auto; font-size: 0.72rem; color: var(--muted); }
.flow-step-num::before { content: counter(step); }
.flow-node__head .rm-action { margin-left: 0.5rem; }

.flow-node__title { font-weight: 600; margin: 0 0 0.55rem; display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.flow-node__title select { font-weight: 600; width: auto; }
.flow-field { display: flex; flex-direction: column; gap: 0.25rem; max-width: 22rem; margin: 0; }
.flow-field[hidden] { display: none; } /* beat .flow-field{display:flex} when JS hides */
.flow-fields { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
/* min-width:0 lets the field shrink to the panel instead of being held open at
   its content's min-content width — the trigger picker inside the "When" field
   otherwise forces the flex item (and a horizontal scrollbar) past the panel. */
.flow-fields .flow-field { flex: 1 1 11rem; max-width: none; min-width: 0; }
.flow-fields select { width: 100%; }
.flow-hint { font-size: 0.78rem; margin: 0.1rem 0 0; }
.input-suffix { display: flex; align-items: center; gap: 0.4rem; }
.input-suffix input { flex: 1 1 auto; min-width: 0; }
.input-suffix > span { font-size: 0.8rem; color: var(--muted); }
.flow-node > .action-type { width: 100%; }

/* "+" insert button sits on the connector below the last action. */
.flow-insert { position: relative; margin-top: 2.6rem; display: flex; flex-direction: column; align-items: center; gap: 0.3rem; }
.flow-insert::before {
  content: ""; position: absolute; left: 50%; top: -2.4rem;
  transform: translateX(-50%); width: 2px; height: 2rem; background: var(--rule);
}
.flow-insert__btn {
  width: 2rem; height: 2rem; border-radius: 50%; cursor: pointer;
  border: 1px dashed var(--ink-soft); background: var(--panel); color: var(--muted);
  font-size: 1.1rem; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.flow-insert__btn:hover { border-color: var(--accent); color: var(--accent); }
.flow-insert__label { font-size: 0.74rem; color: var(--muted); }

.flow-actions { display: block; }
.rule-stop { display: flex; align-items: center; gap: 0.4rem; margin-top: 1.25rem; }

.action-params { margin-top: 0.5rem; }
.action-params [data-for][hidden] { display: none; }
.action-params .action-note, .action-params .action-assign { width: 100%; }

/* Variable palette: draggable token pills inserted into templatable fields. */
.var-palette { margin-top: 0.75rem; padding-top: 0.6rem; border-top: 1px dashed var(--rule); }
.var-palette[hidden] { display: none; }
.var-palette__caption { display: block; font-size: 0.72rem; color: var(--muted); margin-bottom: 0.35rem; }
.var-palette__pills { display: flex; flex-wrap: wrap; gap: 6px; }
.var-pill {
  display: inline-flex; align-items: center; cursor: grab;
  background: rgba(0, 0, 0, 0.06); color: var(--ink-soft, inherit);
  border: 1px solid var(--rule); border-radius: 14px;
  padding: 2px 10px; font-size: 12px; line-height: 1.4; white-space: nowrap;
}
.var-pill:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.var-pill:active { cursor: grabbing; }
.var-pill.dragging { opacity: 0.5; }
.var-pill { gap: 6px; max-width: 100%; }
.var-pill__label { white-space: nowrap; }
.var-pill__example {
  color: var(--muted); font-size: 11px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; max-width: 150px;
}
.var-pill:hover .var-pill__example { color: rgba(255, 255, 255, 0.8); }
.var-palette__group {
  flex-basis: 100%; font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted); margin-top: 0.35rem;
}
.var-palette__group:first-child { margin-top: 0; }
.var-palette__search {
  display: block; width: 100%; margin-bottom: 0.4rem;
  padding: 4px 10px; font-size: 12px;
  border: 1px solid var(--rule); border-radius: 8px;
  background: transparent; color: inherit;
}

/* Rich HTML email editor (send_email body): toolbar + contenteditable WYSIWYG
   with a raw-HTML source toggle. */
.email-body-field { display: block; margin-top: 0.5rem; }
.email-body-field__label { display: block; font-size: 0.78rem; color: var(--muted); margin-bottom: 0.25rem; }
/* Visual email builder (GrapesJS). The card shows a compact preview + an "Edit
   email" button; the full-screen modal hosts the GrapesJS canvas. */
.email-builder { border: 1px solid var(--rule); border-radius: 6px; background: var(--panel); padding: 8px; }
.email-builder__preview-wrap {
  position: relative; height: 9rem; overflow: hidden; border-radius: 4px;
  border: 1px solid var(--rule); background: #fff;
}
.email-builder__preview { border: 0; width: 100%; height: 100%; background: #fff; display: none; }
.email-builder__empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 0.85rem;
}
.email-builder__edit { margin-top: 8px; }

/* Full-screen GrapesJS builder modal. */
.email-builder-overlay {
  position: fixed; inset: 0; z-index: 70; display: flex; padding: 24px;
  background: rgba(0, 0, 0, 0.55);
}
.email-builder-overlay[hidden] { display: none; }
.email-builder-modal {
  background: var(--panel); border: 1px solid var(--rule); border-radius: 8px;
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}
.email-builder-modal__head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; border-bottom: 1px solid var(--rule); color: var(--ink);
}
.email-builder-modal__hint { font-size: 0.78rem; }
.email-builder-modal__tools { display: inline-flex; align-items: center; gap: 8px; }
.email-builder-modal__actions { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; }
.email-builder-var {
  padding: 4px 8px; border: 1px solid var(--rule); border-radius: 4px;
  background: var(--panel); color: var(--ink); font-size: 0.8rem;
}
.email-builder-canvas { flex: 1; min-height: 0; }
/* GrapesJS panels already ship a dark theme that suits the admin UI; just let the
   canvas fill the modal. */
.email-builder-canvas .gjs-editor, .email-builder-canvas .gjs-cv-canvas { height: 100%; }

/* Step test runner: ▶ button, mock editor, result panel. */
.action-test-btn {
  margin-left: auto; margin-right: 0.4rem; cursor: pointer;
  border: 1px solid var(--rule); background: var(--panel); color: var(--ink-soft, inherit);
  border-radius: 6px; padding: 2px 8px; font-size: 0.75rem; line-height: 1.4; white-space: nowrap;
}
.action-test-btn:hover:not(:disabled) { border-color: var(--ok, var(--accent)); color: var(--ok, var(--accent)); }
.action-test-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.flow-node__head .rm-action { margin-left: 0; }
.action-card.tested { border-color: var(--ok, var(--accent)); }
.action-mock-wrap { margin-top: 0.6rem; }
.action-mock-wrap summary { font-size: 0.78rem; cursor: pointer; color: var(--ink-soft, inherit); }
.action-mock { width: 100%; margin-top: 0.4rem; font-family: var(--mono, monospace); font-size: 0.78rem; }
.action-mock-fill { margin-top: 0.3rem; }
.action-test-result {
  margin-top: 0.6rem; padding: 0.5rem 0.65rem; border-radius: 6px; white-space: pre-wrap;
  font-size: 0.78rem; line-height: 1.45; border: 1px solid var(--ok, #16a34a);
  background: color-mix(in srgb, var(--ok, #16a34a) 8%, var(--panel, #fff)); color: var(--ink, inherit);
}
.action-test-result.is-error {
  border-color: var(--bad, #dc2626);
  background: color-mix(in srgb, var(--bad, #dc2626) 8%, var(--panel, #fff));
}
.test-warning { font-size: 0.78rem; color: var(--warn, #b45309); margin: 0 0 0.6rem; }

/* Field highlighted while a pill hovers it — the token drops at the caret. */
.var-drop-target {
  outline: 2px solid var(--accent); outline-offset: 1px;
  background: color-mix(in srgb, var(--accent) 8%, var(--panel, #fff));
  caret-color: var(--accent);
}

/* fetch_* window builder: each bound is one compact inline row reading
   "From [3] [days] [in the future]" with the lead word column-aligned. */
.action-fetch { display: flex; flex-direction: column; gap: 0.5rem; }
.action-fetch > .muted { margin: 0 0 0.15rem; font-size: 0.78rem; line-height: 1.4; }
.fetch-bound { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.fetch-bound__lead {
  flex: 0 0 2.4rem; font-weight: 600; font-size: 0.82rem;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em;
}
.fetch-bound .input-suffix { flex: 0 0 auto; }
.fetch-bound input[type="number"] { width: 4rem; flex: 0 0 auto; text-align: center; }
.fetch-bound select { width: auto; flex: 0 0 auto; }
.fetch-once-row { margin-top: 0.35rem; }

.cond-rows, .filter-conds { display: flex; flex-direction: column; gap: 0.5rem; }
.cond-row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.cond-row select { width: auto; flex: 0 0 auto; }
.cond-row .cond-value { flex: 1 1 9rem; min-width: 7rem; }

/* Filter step: Zapier "Only continue if" — OR rule groups, each ANDed inside. */
.action-filter { display: flex; flex-direction: column; gap: 0.5rem; }
.filter-head { font-size: 0.9rem; font-weight: 600; }
.filter-groups { display: flex; flex-direction: column; gap: 0.7rem; }
.filter-group {
  position: relative; border: 1px solid var(--rule); border-radius: 10px;
  padding: 0.75rem; background: var(--bg);
}
.filter-group:not(:first-child) { margin-top: 0.4rem; }
.filter-group:not(:first-child)::before {
  content: "Or"; position: absolute; top: -0.65rem; left: 0.75rem;
  background: var(--accent); color: #fff; font-size: 0.64rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em; padding: 0.08rem 0.45rem; border-radius: 6px;
}
/* Inside a filter group conditions stack full-width (Zapier field/rule/value). */
.action-filter .cond-row { flex-direction: column; align-items: stretch; gap: 0.4rem; }
.action-filter .cond-row select,
.action-filter .cond-row .cond-value { width: 100%; flex: 1 1 auto; }
.action-filter .cond-row .rm-cond { align-self: flex-end; margin-top: -0.2rem; }
.action-filter .cond-row:not(:first-child) {
  border-top: 1px dashed var(--rule); padding-top: 0.6rem; margin-top: 0.1rem;
}
.action-filter .cond-row:not(:first-child)::before {
  content: "And"; font-size: 0.66rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted);
}
.filter-group__foot { display: flex; gap: 0.5rem; margin-top: 0.6rem; flex-wrap: wrap; }
.filter-group__foot .filter-rm-group { margin-left: auto; color: var(--muted); }

/* Paths (branching) builder. */
.action-paths { display: flex; flex-direction: column; gap: 0.6rem; }
.paths-list { display: flex; flex-direction: column; gap: 0.9rem; }
.path-card { border: 1px solid var(--rule); border-radius: 12px; padding: 0.85rem; background: var(--bg); }
.path-card__head { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.6rem; }
.path-card__badge {
  font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: #fff; background: #6d28d9; border-radius: 6px; padding: 0.12rem 0.45rem; flex: 0 0 auto;
}
.path-label { flex: 1 1 auto; font-weight: 600; }
.path-card__head .path-rm { flex: 0 0 auto; color: var(--muted); }
.path-filter, .path-then { margin-top: 0.5rem; }
.path-filter .filter-head, .path-then .filter-head { font-size: 0.82rem; }
.path-steps { display: flex; flex-direction: column; gap: 0.6rem; margin: 0.45rem 0 0.5rem; }

/* Nested branch step cards: show the raw type select, hide rail/test chrome. */
.nested-card { border: 1px solid var(--rule); border-radius: 10px; padding: 0.7rem; background: var(--panel); }
.nested-card .node-test { display: none; }
.nested-card .node-setup > .action-type { display: block; margin-bottom: 0.5rem; }
.nested-card .var-palette { display: none; }
.nested-card .node-actions { margin-top: 0.6rem; padding-top: 0.5rem; }

/* Delay + approval setup. */
.action-delay { display: flex; flex-direction: column; gap: 0.5rem; }
.delay-row { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.delay-row__lead { font-weight: 600; font-size: 0.82rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.delay-row input[type="number"] { width: 4rem; text-align: center; }
.delay-row select { width: auto; }
.action-approval { display: flex; flex-direction: column; gap: 0.4rem; }
.action-approval textarea { width: 100%; }

/* Pending approvals panel on the automations index. */
.approvals { margin-bottom: 1.25rem; }
.approval-row {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.7rem 0.85rem;
  border: 1px solid var(--rule); border-radius: 10px; background: var(--panel); margin-bottom: 0.5rem;
}
.approval-row__icon {
  width: 1.9rem; height: 1.9rem; border-radius: 8px; flex: 0 0 auto; background: #6d28d9; color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 1rem;
}
.approval-row__body { flex: 1 1 auto; min-width: 0; }
.approval-row__prompt { font-weight: 600; }
.approval-row__meta { font-size: 0.78rem; color: var(--muted); }
.approval-row__actions { display: flex; gap: 0.4rem; flex: 0 0 auto; }

/* ---- Zapier-style 2-pane builder: rail of node chips + setup/test panel ---- */
.form.builder-split { max-width: none; }   /* fill the page; override .form 720px cap */
.builder-split__cols {
  display: grid; grid-template-columns: minmax(0, 1fr) 380px;
  gap: 1.25rem; align-items: start; margin-top: 1rem;
}

/* Center: compact node chips floated in the middle of the dotted canvas
   (the canvas fills the column; the chips sit centered at a fixed width). */
.node-rail {
  display: flex; flex-direction: column; align-items: center;
  padding: 1.75rem 1rem; border-radius: 14px; border: 1px solid var(--rule);
  background-color: var(--bg);
  background-image: radial-gradient(var(--rule) 1px, transparent 1px);
  background-size: 16px 16px;
}
.rail-node, .rail-link { width: 100%; max-width: 420px; }
.rail-node {
  display: flex; align-items: center; gap: 0.6rem; cursor: pointer; box-sizing: border-box;
  background: var(--panel); border: 1px solid var(--rule); border-radius: 12px;
  padding: 0.6rem 0.75rem; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.rail-node--trigger { border-top: 3px solid var(--accent); }
.rail-node.is-active { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.rail-node.dragging { opacity: 0.4; }
.rail-icon {
  width: 1.7rem; height: 1.7rem; border-radius: 7px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; background: var(--accent); color: var(--accent-ink, #fff);
}
.rail-icon--action { background: var(--bg-soft); color: var(--muted); border: 1px solid var(--rule); }
.rail-icon--filter { background: #6366f1; color: #fff; }
.rail-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 0.1rem; }
.rail-num { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }
.rail-text { font-size: 0.9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-sub { font-size: 0.75rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; flex: 0 0 auto; background: transparent; }

/* Live plain-language rule sentence under the page heading. */
.rule-sentence { margin: 0.35rem 0 0; font-size: 0.9rem; color: var(--ink); font-style: italic; max-width: 60rem; }

/* Trigger picker (reuses .step-picker__* internals) + current-trigger blurb. */
.trigger-current { display: flex; flex-direction: column; gap: 0.3rem; margin-top: 0.4rem; }
.trigger-desc { margin: 0; font-size: 0.82rem; }
.trigger-picker { margin-top: 0.5rem; border: 1px solid var(--rule); border-radius: 10px; padding: 0.5rem; }
.trigger-picker .step-pick.is-current { outline: 2px solid var(--accent); border-radius: 8px; }

/* Cross-rule context: where this rule sits among rules on the same trigger. */
.trigger-context { margin-top: 0.6rem; padding-top: 0.5rem; border-top: 1px dashed var(--rule); }
.trigger-context__order { margin: 0; font-size: 0.8rem; }
.trigger-context__warn { margin: 0.25rem 0 0; font-size: 0.8rem; color: var(--warn-ink, #b45309); }
.rail-dot--ok { background: var(--ok, #16a34a); }
.rail-dot--err { background: var(--bad, #dc2626); }

/* Connector + insert "+" sitting between two chips. */
.rail-link { position: relative; height: 2rem; display: flex; align-items: center; justify-content: center; }
.rail-link::before {
  content: ""; position: absolute; left: 50%; top: 0; bottom: 0;
  width: 2px; transform: translateX(-50%); background: var(--rule);
}
.rail-add {
  position: relative; z-index: 2; width: 1.4rem; height: 1.4rem; border-radius: 50%; padding: 0;
  cursor: pointer; border: 1px dashed var(--ink-soft); background: var(--panel); color: var(--muted);
  font-size: 1rem; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.rail-add:hover { border-color: var(--accent); color: var(--accent); }

/* Right: the setup / test panel for the selected node. */
.builder-panel {
  position: sticky; top: 1rem; align-self: start;
  border: 1px solid var(--rule); border-radius: 14px; background: var(--panel);
  padding: 1rem 1.1rem; max-height: calc(100vh - 2rem); overflow: auto;
}
.builder-panel:not(.has-selection) .panel-top,
.builder-panel:not(.has-selection) .panel-host,
.builder-panel:not(.has-selection) #step-picker { display: none; }
.builder-panel.has-selection .panel-empty { display: none; }
.panel-tab.is-active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.panel-tab:disabled { opacity: 0.4; cursor: not-allowed; }
.node-detail[hidden], .node-setup[hidden], .node-test[hidden] { display: none; }
/* The step type is chosen via the picker + shown in the panel header, so the
   raw <select> is hidden (kept in the DOM for serialization). */
.node-setup > .action-type { display: none; }
.node-actions { margin-top: 0.85rem; padding-top: 0.6rem; border-top: 1px dashed var(--rule); }
.node-test .action-test-btn { margin: 0.6rem 0 0; }
.node-test .action-test-result { margin-top: 0.6rem; }

/* Panel empty-state (no node selected). */
.panel-empty { color: var(--muted); font-size: 0.88rem; text-align: center; padding: 2.5rem 1rem; }
.panel-empty__icon {
  width: 2.6rem; height: 2.6rem; margin: 0 auto 0.6rem; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 1.3rem;
  background: var(--accent-soft); color: var(--accent);
}
.panel-empty p { margin: 0; }

/* Tinted header band wrapping the icon/title + tabs (Zapier panel header). */
.panel-top {
  margin: -1rem -1.1rem 0.85rem; padding: 0.85rem 1.1rem 0;
  background: color-mix(in srgb, var(--accent) 5%, var(--panel));
  border-bottom: 1px solid var(--rule); border-radius: 14px 14px 0 0;
}
.panel-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.7rem; }
.panel-head__icon {
  width: 1.9rem; height: 1.9rem; border-radius: 8px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; background: var(--accent); color: #fff;
}
.panel-head__meta { display: flex; flex-direction: column; gap: 0.05rem; min-width: 0; flex: 1 1 auto; }
.panel-head__num { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.panel-head__title { font-weight: 600; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-expand, .panel-close {
  border: none; background: none; cursor: pointer; line-height: 1; color: var(--muted);
  padding: 0.1rem 0.3rem; flex: 0 0 auto;
}
.panel-expand { font-size: 0.95rem; }
.panel-close { font-size: 1.3rem; }
.panel-expand:hover, .panel-close:hover { color: var(--ink); }

/* Tabs with status dots + chevron separator. */
.panel-tabs { display: flex; align-items: center; gap: 0.15rem; border-bottom: none; margin-bottom: 0; }
.panel-tabs__sep { color: var(--muted); font-size: 0.95rem; margin: 0 0.1rem; }
.panel-tab {
  display: inline-flex; align-items: center; gap: 0.35rem;
  border: none; background: none; cursor: pointer; padding: 0.4rem 0.3rem 0.55rem;
  font-size: 0.85rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab-status {
  width: 0.7rem; height: 0.7rem; border-radius: 50%; flex: 0 0 auto;
  border: 1.5px solid var(--rule); box-sizing: border-box;
}
.tab-status.is-ok  { background: var(--ok, #16a34a); border-color: var(--ok, #16a34a); }
.tab-status.is-ok::after { content: "✓"; color: #fff; font-size: 0.5rem; display: flex; align-items: center; justify-content: center; height: 100%; }
.tab-status.is-err { background: var(--bad, #dc2626); border-color: var(--bad, #dc2626); }

/* Step-type picker (Zapier "add action" searchable list). */
.builder-panel.is-picking .panel-tabs { visibility: hidden; }
.builder-panel.is-picking .panel-host { display: none; }
.builder-panel:not(.is-picking) #step-picker { display: none; }
.step-picker { display: flex; flex-direction: column; }
/* The real <input> is the box: it keeps the base .form input border + single
   focus ring. The wrapper is just a positioning context so the search icon can
   sit inside the input's padding — no wrapper border/ring (that doubled up). */
.step-picker__search { position: relative; margin-bottom: 0.75rem; }
.step-picker__search-icon {
  position: absolute; left: 0.7rem; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 0.95rem; pointer-events: none;
}
/* #rule-form prefix so padding-left beats the base `.form input` rule and the
   text clears the absolutely-positioned search icon. */
#rule-form .step-picker__search input { padding-left: 2rem; font-size: 0.9rem; }
.step-picker__list { display: flex; flex-direction: column; gap: 0.15rem; }
.step-picker__group {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700;
  color: var(--muted); padding: 0.7rem 0.2rem 0.3rem;
}
.step-picker__empty { color: var(--muted); font-size: 0.85rem; padding: 0.5rem 0.2rem; }
.step-pick {
  display: flex; align-items: center; gap: 0.7rem; width: 100%; text-align: left; cursor: pointer;
  border: 1px solid transparent; border-radius: 10px; padding: 0.55rem 0.6rem; background: none;
}
.step-pick:hover { background: var(--bg); border-color: var(--rule); }
.step-pick__icon {
  width: 2rem; height: 2rem; border-radius: 8px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; font-size: 1rem; color: #fff;
}
.step-pick__body { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.step-pick__name { font-weight: 600; font-size: 0.9rem; }
.step-pick__desc { font-size: 0.78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Expanded panel = centered modal overlay. */
body.builder-modal-open { overflow: hidden; }
.builder-panel.is-expanded {
  position: fixed; inset: 50% auto auto 50%; transform: translate(-50%, -50%);
  width: min(720px, 92vw); max-height: 88vh; z-index: 60;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}
.builder-panel.is-expanded::backdrop, body.builder-modal-open::before {
  content: ""; position: fixed; inset: 0; background: rgba(11, 20, 36, 0.45); z-index: 59;
}

@media (max-width: 900px) {
  .builder-split__cols { grid-template-columns: 1fr; }
  .builder-panel { position: static; max-height: none; }
}
/* ─── REPORTS DASHBOARD ───────────────────────────────────────────────
   Two-column layout: stat cards on the left (1/3), charts on the right.
   Stacks to single column on narrow viewports.
   ──────────────────────────────────────────────────────────────────── */
.report-grid {
  display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem;
}
@media (min-width: 900px) {
  .report-grid { flex-direction: row; align-items: flex-start; }
  .report-cards { width: 300px; flex-shrink: 0; }
  .report-charts { flex: 1; min-width: 0; }
}

/* Stat tile — extends .card */
.stat-tile { padding: 1.1rem 1.25rem; }
.stat-tile h4 { margin: 0 0 0.35rem; font-size: 0.88rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-tile .stat-total {
  font-size: 1.75rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink); line-height: 1.1; margin: 0 0 0.85rem;
}
.stat-tile table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
.stat-tile table td { padding: 0.28rem 0; color: var(--ink-soft); }
.stat-tile table td.stat-val {
  text-align: right; font-variant-numeric: tabular-nums;
  font-weight: 500; color: var(--ink); padding-left: 0.5rem;
}
.stat-tile .stat-sep { border-top: 1px solid var(--rule); margin: 0.65rem 0 0.55rem; }
.stat-tile .stat-sub { font-size: 0.78rem; font-weight: 600; color: var(--ink-soft); margin: 0.5rem 0 0.35rem; }
.stat-tile small { font-size: 0.73rem; color: var(--muted); display: block; margin-top: 0.65rem; }

/* Chart card */
.chart-card { padding: 1.1rem 1.25rem; }
.chart-card h4 {
  margin: 0 0 0.75rem; font-size: 0.92rem; font-weight: 600;
  display: flex; justify-content: space-between; align-items: baseline;
}
.chart-card h4 .chart-total {
  font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--ink);
}

/* Report period filter bar */
.report-filter { margin-bottom: 0; padding: 0.85rem 1.25rem; display: flex; flex-direction: column; gap: 0.6rem; }
.report-filter-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.6rem; }
.report-filter .tabs { border: 0; padding: 0; gap: 0.25rem; display: flex; flex-wrap: wrap; }
.report-filter .tab { padding: 0.3rem 0.7rem; border: 1px solid var(--rule); border-radius: var(--radius-sm); border-bottom: 1px solid var(--rule); font-size: 0.82rem; line-height: 1.4; }
.report-filter .tab.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.report-filter-custom { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; padding-top: 0.4rem; border-top: 1px solid var(--rule); }
.report-filter-custom input[type=date] {
  padding: 0.3rem 0.55rem; border: 1px solid var(--rule); border-radius: var(--radius-sm);
  font: inherit; font-size: 0.83rem; background: var(--panel); color: var(--ink);
}

/* Two-panel charts: pie left, line right */
.chart-split { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-start; }
.chart-split .chart-pie { flex: 0 0 220px; }
.chart-split .chart-line { flex: 1; min-width: 200px; }
.chart-split h5 { margin: 0 0 0.5rem; font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); text-align: center; }

/* Extras pie+table layout */
.chart-extras { display: flex; flex-wrap: wrap; gap: 1.25rem; align-items: flex-start; }
.chart-extras .chart-pie { flex: 0 0 220px; }
.chart-extras .extras-table { flex: 1; min-width: 200px; }
.chart-extras .extras-table table.data td { padding: 0.4rem 0.6rem; }

/* Trends comparison table */
.trends-table td, .trends-table th { padding: 0.45rem 0.7rem; }
.trends-time { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.75rem; }
.trends-time .btn { font-size: 0.8rem; padding: 0.25rem 0.6rem; }
.trends-time .btn.active { background: var(--ink); color: #fff; border-color: var(--ink); }
/* Dark mode: --ink is near-white, so the inverted chip flips — light pill,
   dark text — instead of white-on-white. */
html.dark .trends-time .btn.active { color: var(--bg); }

/* ─── THEME + NOTIFY TOGGLES (foot row icon buttons) ──────────────────── */
.side-foot .nav-label { display: none; }
.theme-toggle {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; flex-shrink: 0; cursor: pointer;
  border: 1px solid transparent; border-radius: 8px;
  color: var(--ink-soft);
  transition: background 0.12s, color 0.12s;
}
.theme-toggle:hover { background: var(--bg-soft); color: var(--ink); }
.theme-switch-input { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.theme-ic { width: 19px; height: 19px; flex-shrink: 0; color: var(--muted); }
.theme-toggle:hover .theme-ic { color: var(--ink-soft); }
/* Labels ride as rail flyouts (.nav-label wraps them in layout.html). */
.notify-toggle { background: none; font: inherit; }
.notify-dot {
  position: absolute; top: 6px; right: 6px;
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  background: var(--muted);
  box-shadow: 0 0 0 2px var(--side-bg);
}
.notify-toggle[data-notify-state="on"] .notify-dot { background: #16a34a; }
.notify-toggle[data-notify-state="blocked"] .notify-dot { background: #dc2626; }
/* Show the icon + label for the theme you'd switch TO. */
html:not(.dark) .theme-ic-sun,   html.dark .theme-ic-moon   { display: none; }
html:not(.dark) .theme-text-light, html.dark .theme-text-dark { display: none; }

/* ─── DARK THEME (bespoke layer) ──────────────────────────────────────
   The converted templates carry their own `dark:` utility variants. This
   block only re-themes app.css's hand-written components by flipping the
   design tokens they consume (shell, picker, scheduler, chat, calendars,
   cards, history, kv…) — it does NOT override Tailwind utility classes. */
html.dark {
  /* Chatwoot v4 dark tokens (_next-colors.scss .dark): page #1C1D20,
     cards #1C1E22, borders #1F1F25, slate-11/12 text, brand unchanged. */
  --bg:        #1c1d20;  /* n-background */
  --bg-soft:   #26282c;
  --panel:     #1c1e22;  /* n-card */
  --side-bg:   #111113;  /* slate-1 */
  --ink:       #edeef0;  /* slate-12 */
  --ink-soft:  #b0b4ba;  /* slate-11 */
  --muted:     #777b84;  /* slate-10 */
  --rule:      #1f1f25;  /* n-weak */
  --rule-soft: #232428;
  --accent:    #2781f6;  /* n-brand (fixed) */
  --accent-hover: #3d8ff7;
  --accent-soft: rgba(39,129,246,0.16);
  --accent-ink:  #ffffff;
  --ok: #22c55e;   --ok-soft:   rgba(34,197,94,0.18);
  --warn: #f59e0b; --warn-soft: rgba(245,158,11,0.18);
  --bad: #ef4444;  --bad-soft:  rgba(239,68,68,0.18);
  --info: #4c90f7; --info-soft: rgba(47,129,246,0.20);
  --shadow-xs: 0 1px 2px 0 rgba(0,0,0,0.4);
  --shadow-sm: 0 1px 3px 0 rgba(0,0,0,0.5), 0 1px 2px -1px rgba(0,0,0,0.5);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.5), 0 2px 4px -2px rgba(0,0,0,0.5);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.55), 0 4px 6px -4px rgba(0,0,0,0.5);
  --ring: 0 0 0 4px rgba(59,130,246,0.35);
  --field-bg:          #18191b;
  --field-border:      #2e2d32;  /* n-strong */
  --field-placeholder: #696e77;
  --check-border:      #43484e;
  color-scheme: dark;
}
/* Status pills in the bespoke layer: bg flips via --*-soft tokens; recolour
   the ink so it reads on the dark tint. */
html.dark .badge { color: #d1d5db; }
html.dark .badge.st-upcoming, html.dark .badge.st-authorized, html.dark .badge.st-payment_authorized, html.dark .badge.st-assigned, html.dark .badge.st-pushed, html.dark .badge.st-sent { color: #93c5fd; }
html.dark .badge.st-completed, html.dark .badge.st-charged, html.dark .badge.st-captured, html.dark .badge.st-payment_captured, html.dark .badge.st-payment_succeeded, html.dark .badge.st-created, html.dark .badge.st-settled, html.dark .badge.st-paid { color: #86efac; }
html.dark .badge.st-unassigned, html.dark .badge.st-pending { color: #fcd34d; }
html.dark .badge.st-declined, html.dark .badge.st-failed, html.dark .badge.st-payment_failed, html.dark .badge.st-deleted { color: #fca5a5; }
html.dark .badge.st-updated { background: rgba(99,102,241,0.20); color: #c7d2fe; }
/* Form controls: the vendored element base at the top of this file is
   token-driven, so dark mode flips via the --field-* and --check-border values
   in html.dark above — no element-level dark override needed here. The legacy
   `.form` field box is the exception: its specificity beats both the base and
   utility classes, and its light pairing (--rule on --panel) is near-invisible
   in dark (#1f1f25 on #1c1e22), so its fields need the field tokens re-applied. */
html.dark .form input:not([type="checkbox"]):not([type="radio"]),
html.dark .form textarea,
html.dark .form select {
  background-color: var(--field-bg);
  border-color: var(--field-border);
}

/* Bespoke components that hardcode light fills (not token-driven) — re-tint
   for dark so large coloured blocks don't stay bright. */
html.dark .card.error-banner   { background: rgba(239,68,68,0.12); color: #fca5a5; }
html.dark .card.success-banner,
html.dark .card.notice         { background: rgba(34,197,94,0.12); color: #86efac; }
html.dark .inbox-mailbox-banner { background: rgba(245,158,11,0.14); }
html.dark .inbox-mailbox-banner:hover { background: rgba(245,158,11,0.22); }
/* Outbound email cards hardcode a near-white blue tint (hsl(212 100% 99%)) for
   light mode; in dark that left --ink text on a white fill — unreadable. Re-tint
   to a translucent accent wash that reads against the dark page. */
html.dark .inbox-msg--out { background: rgba(47,129,246,0.10); }
html.dark .inbox-msg--out.is-fresh { animation-name: inboxMsgFlashOutDark; }
@keyframes inboxMsgFlashOutDark {
  0%, 60% { background: rgba(47,129,246,0.24); }
  100%    { background: rgba(47,129,246,0.10); }
}
/* Yellow note surfaces: exact n-solid-amber values live with the component
   rules above (inbox-msg__note / composer note mode). */
html.dark .sched-row-head.foreign { background: rgba(245,158,11,0.10); }
html.dark .chat-bubble.kind-booking_forward { background: rgba(245,158,11,0.12); }
html.dark .chat-system-label { color: #fcd34d; }
/* Material-style picker (customer/tag/inbox/search) hardcodes rgba(0,0,0,*) and
   #fff throughout, so without these it renders as a light island in dark mode.
   The picker's own class-level colors beat the zero-specificity vendored form
   base, so its inputs need explicit dark re-tints here too. */
html.dark .picker-input-row { background: var(--bg-soft); border-color: var(--rule); }
html.dark .form .picker .picker-search,
html.dark .picker .picker-search { color: var(--ink); }
html.dark .picker-search::placeholder { color: var(--muted); }
html.dark .picker-end button { color: var(--muted); }
html.dark .picker-end button:hover { background: rgba(255,255,255,0.08); color: var(--ink); }
html.dark .picker .chip { background: rgba(255,255,255,0.12); color: var(--ink); }
html.dark .picker .chip-adhoc { background: rgba(245,158,11,0.22); }
html.dark .picker .chip-x { color: var(--muted); }
html.dark .picker .chip-x:hover { background: rgba(255,255,255,0.2); color: var(--ink); }
html.dark .chip-swatch { background: rgba(255,255,255,0.28); }
html.dark .picker-results { background: var(--panel); box-shadow: var(--shadow-lg); }
html.dark .picker-results-list li button { color: var(--ink); }
html.dark .picker-results-list li button small { color: var(--muted); }
html.dark .picker-results-list li button:hover,
html.dark .picker-results-list li button:focus { background: rgba(255,255,255,0.06); }
html.dark .picker-empty .muted { color: var(--muted); }
html.dark .picker-empty .error { color: #fca5a5; }
html.dark .picker-add-form input {
  background: var(--field-bg); border-color: var(--field-border); color: var(--ink);
}
html.dark .color-row input[type="color"] { border-color: var(--rule); }
/* Misc bespoke surfaces that hardcode a light fill with no dark variant, so
   the --ink text (light in dark mode) sat on a light island. Re-tint to the
   neutral dark surfaces / translucent accent washes used elsewhere. */
html.dark .icon-preview { background: var(--bg-soft); border-color: var(--rule); }
html.dark .icon-remove-btn { background: var(--bg-soft); border-color: var(--rule); }
html.dark .icon-remove-btn:hover { background: var(--rule); }
html.dark .sched-chip-broadcast { background: var(--panel); border-color: var(--rule); }
html.dark .swatch { border-color: rgba(255,255,255,0.2); }
html.dark .cal-day.today a     { background: rgba(245,158,11,0.22); color: var(--ink); }
html.dark .cal-day.today.in-range a { background: rgba(245,158,11,0.16); }
html.dark .cal-day.today.selected a { background: rgba(245,158,11,0.34); }
html.dark .chan-pill.chan-email { background: rgba(59,130,246,0.18); color: #93c5fd; }
html.dark .chan-pill.chan-sms   { background: rgba(34,197,94,0.18); color: #86efac; }
html.dark .status-pill.st-open  { background: rgba(34,197,94,0.18); }
html.dark .status-pill.st-snoozed { background: rgba(245,158,11,0.18); }
html.dark .pill.ok   { background: rgba(34,197,94,0.18); }
html.dark .pill.warn { background: rgba(245,158,11,0.18); }
html.dark .badge-warn { background: rgba(245,158,11,0.18); }
html.dark pre.copy { background: #0a0a0a; border-color: #0a0a0a; }
html.dark .kanban-card-meta .badge.prio-high   { background: rgba(239,68,68,0.18); color: #fca5a5; }
html.dark .kanban-card-meta .badge.prio-medium { background: rgba(59,130,246,0.18); color: #93c5fd; }
html.dark .kanban-card-meta .badge.prio-low    { background: rgba(34,197,94,0.18); color: #86efac; }
/* Task editor @-mention pills hardcode light bg + dark ink; re-tint for dark. */
html.dark .crm-pill            { color: #93c5fd; }
html.dark .crm-pill--booking   { background: rgba(34,197,94,0.18);  color: #86efac; }
html.dark .crm-pill--lead      { background: rgba(245,158,11,0.18); color: #fcd34d; }
html.dark .crm-pill--charge    { background: rgba(239,68,68,0.18);  color: #fca5a5; }
html.dark .crm-pill--team,
html.dark .crm-pill--user      { background: rgba(99,102,241,0.22); color: #c7d2fe; }

/* ---- AI Assistant chat ---------------------------------------------------- */
.assistant-page { display: flex; gap: 1rem; height: calc(100vh - 7rem); min-height: 28rem; }
.assistant-sidebar {
  width: 16rem; flex: none; display: flex; flex-direction: column; gap: 0.5rem;
  border: 1px solid var(--rule); border-radius: var(--radius); background: var(--panel);
  padding: 0.75rem; overflow-y: auto;
}
.assistant-new {
  display: block; text-align: center; padding: 0.55rem 0.75rem; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--accent-ink, #fff); font-size: 0.875rem; font-weight: 600;
}
.assistant-new:hover { background: var(--accent-hover, #1d6fe4); text-decoration: none; color: #fff; }
.assistant-thread-link {
  display: block; padding: 0.5rem 0.625rem; border-radius: var(--radius-sm); font-size: 0.875rem;
  color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.assistant-thread-link:hover { background: var(--bg-soft); color: var(--ink); text-decoration: none; }
.assistant-thread-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.assistant-main {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  border: 1px solid var(--rule); border-radius: var(--radius); background: var(--panel); overflow: hidden;
}
#assistant-conversation { display: contents; }
.assistant-scroll { flex: 1; overflow-y: auto; padding: 1.25rem; }
.assistant-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.75rem; color: var(--muted); padding: 2rem; text-align: center; }
.assistant-row { display: flex; margin-bottom: 0.75rem; }
.assistant-row.user { justify-content: flex-end; }
.assistant-bubble {
  max-width: 80%; padding: 0.625rem 0.875rem; border-radius: var(--radius);
  font-size: 0.9rem; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word;
}
.assistant-row.user .assistant-bubble { background: var(--accent); color: var(--accent-ink, #fff); border-bottom-right-radius: 4px; }
.assistant-row.assistant .assistant-bubble { background: var(--bg-soft); color: var(--ink); border: 1px solid var(--rule); border-bottom-left-radius: 4px; animation: asst-rise 0.24s ease both; }
.assistant-status { font-size: 0.8rem; color: var(--muted); font-style: italic; padding: 0.15rem 0.25rem; }

/* Typing indicator — three bouncing dots (Open WebUI-style). */
.assistant-typing { display: inline-flex; align-items: center; gap: 0.28rem; padding: 0.55rem 0.7rem; background: var(--bg-soft); border: 1px solid var(--rule); border-radius: var(--radius); border-bottom-left-radius: 4px; }
.assistant-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: asst-bounce 1.2s infinite ease-in-out both; }
.assistant-typing span:nth-child(1) { animation-delay: -0.24s; }
.assistant-typing span:nth-child(2) { animation-delay: -0.12s; }

.assistant-approval {
  margin: 0.5rem 0 0.75rem; border: 1px solid var(--warn, #f59e0b); border-radius: var(--radius);
  background: var(--warn-soft, rgba(245,158,11,0.12)); padding: 0.75rem 0.875rem;
  animation: asst-pop 0.2s ease both;
}
.assistant-approval-head { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--warn, #b45309); }
.assistant-approval h4 { margin: 0.25rem 0 0.5rem; font-size: 0.95rem; font-weight: 600; color: var(--ink); }
.assistant-approval-args { margin: 0 0 0.25rem; display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 0.75rem; font-size: 0.8rem; }
.assistant-approval-args dt { color: var(--muted); font-weight: 600; }
.assistant-approval-args dd { margin: 0; color: var(--ink); white-space: pre-wrap; word-break: break-word; }
.assistant-recovery-args { display: block; margin: 0.25rem 0 0.5rem; padding: 0.45rem 0.55rem; border-radius: 0.4rem; background: rgba(220, 38, 38, 0.08); color: var(--ink); font-size: 0.75rem; white-space: pre-wrap; word-break: break-word; }
.assistant-approval-actions { display: flex; gap: 0.5rem; margin-top: 0.6rem; flex-wrap: wrap; }

/* Persistent "auto-approving" bar with one-click revoke. */
.assistant-autobar { display: flex; align-items: center; gap: 0.5rem; margin: 0.5rem 0 0.25rem; padding: 0.4rem 0.7rem; font-size: 0.78rem; color: var(--ink-soft); background: var(--bg-soft); border: 1px solid var(--rule); border-radius: 999px; width: fit-content; }
.assistant-autobar-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok, #16a34a); animation: asst-glow 1.6s infinite ease-in-out; }
.assistant-autobar-off { border: 0; background: transparent; color: var(--accent); cursor: pointer; font: inherit; font-size: 0.78rem; font-weight: 600; padding: 0; }
.assistant-autobar-off:hover { text-decoration: underline; }

.assistant-error { margin: 0 0 0.75rem; padding: 0.5rem 0.75rem; border-radius: var(--radius-sm); background: var(--err-soft, rgba(239,68,68,0.12)); color: var(--err, #dc2626); font-size: 0.85rem; }

@keyframes asst-rise { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
@keyframes asst-pop { from { opacity: 0; transform: scale(0.97) translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes asst-bounce { 0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; } 40% { transform: scale(1); opacity: 1; } }
@keyframes asst-glow { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .assistant-row.assistant .assistant-bubble, .assistant-approval { animation: none; }
  .assistant-typing span, .assistant-autobar-dot { animation: none; }
}

.assistant-composer { display: flex; gap: 0.5rem; border-top: 1px solid var(--rule); padding: 0.75rem; }
.assistant-composer textarea {
  flex: 1; resize: none; border: 1px solid var(--rule); border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem; font: inherit; font-size: 0.9rem; background: var(--bg); color: var(--ink);
}
.assistant-composer textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
@media (max-width: 720px) {
  .assistant-sidebar { display: none; }
}

/* ---- automations: test-data sample chooser (P3) ---- */
.sample-section { display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; }
.sample-section__title { margin: 0; font-size: 0.85rem; }
.sample-section__hint { margin: 0; font-size: 0.78rem; }
.sample-current__label { margin: 0; font-weight: 600; font-size: 0.85rem; }
.sample-current__meta { margin: 0; font-size: 0.78rem; }
.sample-warn { margin: 0.25rem 0 0; font-size: 0.78rem; color: var(--warn, #b45309); }
.sample-list { display: flex; flex-direction: column; gap: 4px; width: 100%; max-height: 260px; overflow-y: auto; }
.sample-pick {
  text-align: left; font-size: 0.8rem; padding: 6px 10px; cursor: pointer;
  background: rgba(0, 0, 0, 0.04); border: 1px solid var(--rule); border-radius: 8px;
  color: var(--ink-soft, inherit);
}
.sample-pick:hover { border-color: var(--accent); }
.sample-pick--synthetic { font-style: italic; }

/* ---- automations: typed conditions + live verdicts + branch modes (P4) ---- */
.cond-value--warn { border-color: var(--warn, #b45309); background: color-mix(in srgb, var(--warn, #b45309) 8%, var(--bg)); }
.cond-verdict {
  display: flex; flex-direction: column; gap: 0.15rem;
  margin-top: 0.5rem; padding: 0.45rem 0.65rem; border-radius: var(--radius-sm);
  font-size: 0.8rem; border: 1px solid var(--rule);
}
.cond-verdict strong { font-size: 0.82rem; }
.cond-verdict--pass { border-color: color-mix(in srgb, #16a34a 45%, var(--rule)); color: #16a34a; }
.cond-verdict--stop { border-color: color-mix(in srgb, #dc2626 45%, var(--rule)); color: #dc2626; }
.cond-verdict--uncertain { border-color: color-mix(in srgb, #d97706 45%, var(--rule)); color: #d97706; }
.cond-verdict--pass span, .cond-verdict--stop span, .cond-verdict--uncertain span { color: var(--muted); }
.path-verdict { font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
.path-verdict--taken { color: #16a34a; font-weight: 600; }
.path-verdict--uncertain { color: #d97706; }
.paths-mode-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; font-size: 0.85rem; }
.paths-legacy-badge {
  font-size: 0.72rem; padding: 0.1rem 0.45rem; border-radius: 999px;
  border: 1px solid var(--warn, #b45309); color: var(--warn, #b45309);
}
.path-card--inactive { opacity: 0.55; }
.path-card--inactive::after {
  content: "Not used in \201Crun every matching branch\201D mode";
  display: block; font-size: 0.72rem; color: var(--warn, #b45309); padding: 0 0.65rem 0.5rem;
}

/* ---- automations: whole-rule rehearsal (P5) ---- */
.sim-ai-toggle { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.82rem; color: var(--muted); margin-right: 0.5rem; }
.sim-results { margin: 0.75rem 0; padding: 0.75rem 0.9rem; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--panel, var(--bg)); }
.sim-results__head { display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.sim-results__close { margin-left: auto; }
.sim-results__warn { font-size: 0.8rem; color: var(--warn, #b45309); border: 1px solid color-mix(in srgb, var(--warn, #b45309) 45%, var(--rule)); border-radius: var(--radius-sm); padding: 0.35rem 0.55rem; margin: 0.3rem 0; }
.sim-steps { display: flex; flex-direction: column; gap: 0.45rem; }
.sim-step { border: 1px solid var(--rule); border-radius: var(--radius-sm); padding: 0.5rem 0.65rem; }
.sim-step__head { display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }
.sim-step__summary { font-size: 0.8rem; }
.sim-pill { font-size: 0.7rem; font-weight: 600; padding: 0.1rem 0.5rem; border-radius: 999px; border: 1px solid var(--rule); white-space: nowrap; }
.sim-pill--would_run { color: #16a34a; border-color: color-mix(in srgb, #16a34a 45%, var(--rule)); }
.sim-pill--would_stop, .sim-pill--would_error { color: #dc2626; border-color: color-mix(in srgb, #dc2626 45%, var(--rule)); }
.sim-pill--would_skip, .sim-pill--cannot_simulate { color: var(--muted); }
.sim-pill--would_suspend { color: #2563eb; border-color: color-mix(in srgb, #2563eb 45%, var(--rule)); }
.sim-pill--uncertain, .sim-pill--needs_data { color: #d97706; border-color: color-mix(in srgb, #d97706 45%, var(--rule)); }
.sim-detail { margin-top: 0.4rem; }
.sim-detail pre { font-size: 0.75rem; white-space: pre-wrap; word-break: break-word; margin: 0.25rem 0 0; padding: 0.4rem 0.55rem; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--ink) 5%, var(--bg)); overflow-x: auto; }
.sim-email-preview { width: 100%; min-height: 180px; max-height: 320px; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: #fff; margin-top: 0.35rem; }
.sim-branch { margin-top: 0.4rem; border-left: 3px solid var(--rule); padding: 0.3rem 0 0.3rem 0.65rem; }
.sim-branch--taken { border-left-color: #16a34a; }
.sim-branch--uncertain { border-left-color: #d97706; }
.sim-branch__head { font-size: 0.8rem; color: var(--muted); margin-bottom: 0.3rem; }
.sim-branch--taken .sim-branch__head { color: #16a34a; }
.sim-children { margin-top: 0.4rem; padding-left: 0.65rem; border-left: 3px dashed var(--rule); }
.sim-children__label { font-size: 0.75rem; margin-bottom: 0.3rem; }
.rail-node.sim-would_run { box-shadow: 0 0 0 2px color-mix(in srgb, #16a34a 55%, transparent); }
.rail-node.sim-would_stop, .rail-node.sim-would_error { box-shadow: 0 0 0 2px color-mix(in srgb, #dc2626 55%, transparent); }
.rail-node.sim-uncertain, .rail-node.sim-needs_data { box-shadow: 0 0 0 2px color-mix(in srgb, #d97706 55%, transparent); }
.rail-node.sim-would_suspend { box-shadow: 0 0 0 2px color-mix(in srgb, #2563eb 55%, transparent); }

/* P6: enrichment provenance warnings */
.rule-warnings {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--warn-text, #b45309);
}
.card-ref-warnings {
  margin: 0 0 10px;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 0.85rem;
  background: rgba(217, 119, 6, 0.12);
  color: var(--warn-text, #b45309);
}
.rail-node--broken .rail-icon {
  box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.75);
}
.rail-node--broken .rail-text::after {
  content: " ⚠";
  color: #d97706;
}

/* ---- P9: recipe banner, schedule builder, chip tokens ---- */
.recipe-banner {
  border-left: 3px solid #2563eb;
  font-size: 0.9rem;
}
.recipe-banner__list {
  margin: 6px 0 0;
  padding-left: 1.2rem;
}
.recipe-banner__list li { margin: 2px 0; }

.sched-builder {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.sched-builder select, .sched-builder input { width: auto; }
.sched-dom { max-width: 5rem; }
.sched-next { margin: 4px 0 0; font-size: 0.85rem; }
.sched-next--bad { color: #dc2626; }

.chip-input {
  min-height: 2.1rem;
  padding: 6px 9px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--field-bg, transparent);
  font-size: 0.9rem;
  line-height: 1.5;
  cursor: text;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.chip-input:focus {
  outline: 2px solid rgba(37, 99, 235, 0.55);
  outline-offset: 1px;
}
.chip-input--multi { min-height: 3.4rem; }
.chip-input:empty::before {
  content: attr(data-placeholder);
  color: color-mix(in srgb, currentColor 45%, transparent);
}
.chip-token {
  display: inline-block;
  margin: 0 1px;
  padding: 0 7px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.16);
  color: #2563eb;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  user-select: none;
}
.chip-input.var-drop-target {
  outline: 2px dashed rgba(37, 99, 235, 0.65);
  outline-offset: 1px;
}
