/* Custom styles that complement Tailwind CDN */

/* ── Brand tokens ────────────────────────────────────────────────────────── */
:root {
  --sidebar-w: 220px;
  --sidebar-collapsed-w: 56px;
  /* blue-light defaults (overridden per data-theme below) */
  --brand-bg:          #e8f2f8;
  --brand-nav:         #7b9fb8;
  --brand-nav-dark:    #6a8ea6;
  --brand-accent:      #B93834;
  --brand-accent-dark: #9a2d2a;
  --brand-text:        #22577A;
  --card-bg:           #ffffff;
  --card-bg-alt:       #f0f8fc;
  --card-border:       #c5dce9;
  --text-primary:      #1e3a4f;
  --text-secondary:    #374151;
  --text-muted:        #4b6a7e;
  --border-color:      #d1e4ef;
  --input-bg:          #ffffff;
}

/* ── Themes ──────────────────────────────────────────────────────────────── */
[data-theme="blue-light"] {
  --brand-bg:          #e8f2f8;
  --brand-nav:         #7b9fb8;
  --brand-nav-dark:    #6a8ea6;
  --brand-accent:      #B93834;
  --brand-accent-dark: #9a2d2a;
  --brand-text:        #22577A;
  --card-bg:           #ffffff;
  --card-bg-alt:       #f0f8fc;
  --card-border:       #c5dce9;
  --text-primary:      #1e3a4f;
  --text-secondary:    #374151;
  --text-muted:        #4b6a7e;
  --border-color:      #d1e4ef;
  --input-bg:          #ffffff;
}

[data-theme="blue-dark"] {
  --brand-bg:          #0d1b2a;
  --brand-nav:         #1a3a5c;
  --brand-nav-dark:    #142e48;
  --brand-accent:      #4a9ece;
  --brand-accent-dark: #3a8db8;
  --brand-text:        #93c5fd;
  --card-bg:           #1e2d3d;
  --card-bg-alt:       #243447;
  --card-border:       rgba(255,255,255,0.1);
  --text-primary:      #e2e8f0;
  --text-secondary:    #cbd5e1;
  --text-muted:        #94a3b8;
  --border-color:      rgba(255,255,255,0.12);
  --input-bg:          #243447;
}

[data-theme="red-light"] {
  --brand-bg:          #fff5f5;
  --brand-nav:         #c0392b;
  --brand-nav-dark:    #a93226;
  --brand-accent:      #c0392b;
  --brand-accent-dark: #a93226;
  --brand-text:        #7f1d1d;
  --card-bg:           #ffffff;
  --card-bg-alt:       #fef2f2;
  --card-border:       #fca5a5;
  --text-primary:      #1c1917;
  --text-secondary:    #44403c;
  --text-muted:        #78716c;
  --border-color:      #fde0e0;
  --input-bg:          #ffffff;
}

[data-theme="red-dark"] {
  --brand-bg:          #1a0a0a;
  --brand-nav:         #7f1d1d;
  --brand-nav-dark:    #6b1212;
  --brand-accent:      #ef4444;
  --brand-accent-dark: #dc2626;
  --brand-text:        #fca5a5;
  --card-bg:           #2d1515;
  --card-bg-alt:       #3a1c1c;
  --card-border:       rgba(239,68,68,0.2);
  --text-primary:      #fef2f2;
  --text-secondary:    #fde8e8;
  --text-muted:        #f87171;
  --border-color:      rgba(239,68,68,0.15);
  --input-bg:          #3a1c1c;
}

/* ── Contrast fix: upgrade near-invisible gray text in light themes ───────── */
html:not([data-theme]) .text-gray-300,
html:not([data-theme]) .text-gray-400,
[data-theme="blue-light"] .text-gray-300,
[data-theme="blue-light"] .text-gray-400,
[data-theme="red-light"] .text-gray-300,
[data-theme="red-light"] .text-gray-400 {
  color: #6b7280 !important;
}

/* ── Dark mode: override common Tailwind light-mode classes ──────────────── */
[data-theme="blue-dark"],
[data-theme="red-dark"] {
  color-scheme: dark;
}
[data-theme="blue-dark"] body,
[data-theme="red-dark"] body { color: var(--text-primary); }

[data-theme="blue-dark"] .bg-white,
[data-theme="red-dark"] .bg-white { background-color: var(--card-bg) !important; }
[data-theme="blue-dark"] .bg-gray-50,
[data-theme="red-dark"] .bg-gray-50 { background-color: var(--card-bg-alt) !important; }
[data-theme="blue-dark"] .bg-gray-100,
[data-theme="red-dark"] .bg-gray-100 { background-color: var(--card-bg-alt) !important; }

[data-theme="blue-dark"] .text-gray-900,
[data-theme="red-dark"] .text-gray-900 { color: var(--text-primary) !important; }
[data-theme="blue-dark"] .text-gray-800,
[data-theme="red-dark"] .text-gray-800 { color: var(--text-primary) !important; }
[data-theme="blue-dark"] .text-gray-700,
[data-theme="red-dark"] .text-gray-700 { color: var(--text-secondary) !important; }
[data-theme="blue-dark"] .text-gray-600,
[data-theme="red-dark"] .text-gray-600 { color: var(--text-secondary) !important; }
[data-theme="blue-dark"] .text-gray-500,
[data-theme="red-dark"] .text-gray-500 { color: var(--text-muted) !important; }
[data-theme="blue-dark"] .text-gray-400,
[data-theme="red-dark"] .text-gray-400 { color: var(--text-muted) !important; }
[data-theme="blue-dark"] .text-gray-300,
[data-theme="red-dark"] .text-gray-300 { color: var(--text-muted) !important; }

[data-theme="blue-dark"] .border-gray-100,
[data-theme="red-dark"] .border-gray-100 { border-color: var(--border-color) !important; }
[data-theme="blue-dark"] .border-gray-200,
[data-theme="red-dark"] .border-gray-200 { border-color: var(--border-color) !important; }
[data-theme="blue-dark"] .border-gray-300,
[data-theme="red-dark"] .border-gray-300 { border-color: var(--border-color) !important; }

[data-theme="blue-dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
[data-theme="red-dark"]  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
[data-theme="blue-dark"] textarea,
[data-theme="red-dark"]  textarea,
[data-theme="blue-dark"] select,
[data-theme="red-dark"]  select {
  background-color: var(--input-bg) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-color) !important;
}
[data-theme="blue-dark"] input::placeholder,
[data-theme="red-dark"]  input::placeholder,
[data-theme="blue-dark"] textarea::placeholder,
[data-theme="red-dark"]  textarea::placeholder { color: var(--text-muted); }

[data-theme="blue-dark"] .data-row:hover,
[data-theme="red-dark"] .data-row:hover { background: rgba(255,255,255,0.06) !important; }
[data-theme="blue-dark"] .detail-panel,
[data-theme="red-dark"] .detail-panel { background: var(--card-bg-alt) !important; border-color: var(--border-color) !important; }

/* bg-blue-50 / bg-blue-100 (used for unread message cards) */
[data-theme="blue-dark"] .bg-blue-50,
[data-theme="red-dark"] .bg-blue-50 { background-color: rgba(59,130,246,0.12) !important; }
[data-theme="blue-dark"] .bg-blue-100,
[data-theme="red-dark"] .bg-blue-100 { background-color: rgba(59,130,246,0.18) !important; }
[data-theme="blue-dark"] .hover\:bg-blue-100:hover,
[data-theme="red-dark"] .hover\:bg-blue-100:hover { background-color: rgba(59,130,246,0.22) !important; }
[data-theme="blue-dark"] .border-blue-200,
[data-theme="red-dark"] .border-blue-200 { border-color: rgba(59,130,246,0.35) !important; }

/* SW dashboard: selected card inline style uses hardcoded light bg — override with higher specificity */
[data-theme="blue-dark"] .sw-msg-card.sw-selected,
[data-theme="red-dark"] .sw-msg-card.sw-selected { background: rgba(255,255,255,0.08) !important; border-color: var(--brand-accent) !important; }
[data-theme="blue-dark"] .sw-job-card.sw-selected,
[data-theme="red-dark"] .sw-job-card.sw-selected { background: rgba(255,255,255,0.08) !important; }

/* ── Base ────────────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #b0c8d8; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #7b9fb8; }
#header-bookmarks::-webkit-scrollbar { display: none; }

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--brand-nav) 0%, var(--brand-nav-dark) 100%);
  box-shadow: 2px 0 20px rgba(0,0,0,.18);
  border-right: 1px solid rgba(255,255,255,0.15);
  transition: width 0.2s ease, transform 0.2s ease;
  overflow-x: hidden;  /* clips nav labels during collapse animation */
  overflow-y: auto;    /* allows scrolling if content exceeds viewport */
  flex-shrink: 0;
  /* Use dynamic viewport height on mobile so browser toolbar is excluded */
  height: 100vh;
  height: 100dvh;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-w);
}
.sidebar.collapsed .nav-label { display: none; }

/* ── Nav items ───────────────────────────────────────────────────────────── */
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  width: 100%;
  text-align: left;
  color: rgba(255,255,255,0.80);
  font-size: 0.8125rem;
  letter-spacing: 0.01em;
  border-left: 2px solid transparent;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  white-space: nowrap;
  cursor: pointer;
}
.nav-item:hover {
  color: #fff;
  background: rgba(0,0,0,0.12);
}
.nav-item.active {
  color: #fff;
  background: rgba(0,0,0,0.18);
  border-left-color: var(--brand-accent);
}
.nav-item svg {
  width: 15px;
  height: 15px;
  stroke-width: 2;
  flex-shrink: 0;
  opacity: 0.80;
}
.nav-item.active svg { opacity: 1; }

/* ── Favorite star ────────────────────────────────────────────────────────── */
.nav-star {
  margin-left: auto;
  font-size: 13px;
  line-height: 1;
  padding: 2px 0 2px 2px;
  color: transparent;
  flex-shrink: 0;
  transition: color 0.12s;
}
.nav-item:hover .nav-star { color: rgba(255,255,255,0.40); }
.nav-star.starred { color: #fbbf24 !important; }
.sidebar.collapsed .nav-star { display: none; }

/* ── Collapsible nav sections ─────────────────────────────────────────────── */
.sidebar nav p.nav-section {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}
.sidebar nav p.nav-section:hover { color: rgba(255,255,255,0.6) !important; }
.sidebar nav p.nav-section::after {
  content: '';
  width: 5px;
  height: 5px;
  margin-left: auto;
  border-right: 1.5px solid rgba(255,255,255,0.4);
  border-bottom: 1.5px solid rgba(255,255,255,0.4);
  transform: rotate(45deg);           /* caret points down when expanded */
  transition: transform 0.15s ease;
}
.sidebar nav p.nav-section.sec-collapsed-hdr::after {
  transform: rotate(-45deg);          /* caret points right when collapsed */
}
/* Hide a section's members when collapsed — but never in the icon-only rail,
   where headers aren't visible to toggle. Independent of the permission-driven
   `hidden` class, so hidden items stay hidden when a section is re-expanded. */
.sidebar:not(.collapsed) nav .sec-collapsed { display: none !important; }

/* ── Status badges ───────────────────────────────────────────────────────── */
.badge {
  letter-spacing: 0.03em;
  font-weight: 500;
  border-width: 1px;
  border-style: solid;
}
.badge-open          { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.badge-closed        { background: #f1f5f9; color: #64748b; border-color: #e2e8f0; }
.badge-estimate      { background: #fef9c3; color: #854d0e; border-color: #fef08a; }
.badge-POSTED        { background: #f8fafc; color: #94a3b8; border-color: #e2e8f0; }
.badge-open_status   { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.badge-pending       { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.badge-resolved      { background: #f1f5f9; color: #64748b; border-color: #e2e8f0; }
.badge-closed_status { background: #f1f5f9; color: #64748b; border-color: #e2e8f0; }

/* ── Table ───────────────────────────────────────────────────────────────── */
.data-row { transition: background 0.1s; }
.data-row:hover { background: #ddeef7; cursor: pointer; }

/* ── Detail panel ────────────────────────────────────────────────────────── */
.detail-panel {
  border-top: 1px solid #c5dce9;
  background: #f0f8fc;
}

/* ── Calendar ────────────────────────────────────────────────────────────── */
.cal-day { min-height: 3rem; }
@media (min-width: 640px) { .cal-day { min-height: 4.5rem; } }
.cal-day.other-month { opacity: 0.35; }

.cal-event {
  font-size: 0.65rem;
  line-height: 1.25;
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--brand-text);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.1s, filter 0.1s;
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
}
.cal-event:hover { opacity: 0.88; filter: brightness(1.12); }

/* Day-view events: flex row so action buttons sit at the end */
.cal-event-day {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow: visible;
}
.cal-event-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-event-actions {
  display: none;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}
.cal-event-day:hover .cal-event-actions { display: flex; }
.cal-action-btn {
  background: rgba(255,255,255,0.28);
  color: #fff;
  border: none;
  border-radius: 3px;
  font-size: 0.6rem;
  padding: 1px 5px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s;
  line-height: 1.5;
}
.cal-action-btn:hover { background: rgba(255,255,255,0.5); }

/* ── Dashboard week appointment cards ───────────────────────────────────── */
.dash-appt-card {
  background: var(--brand-text);
  color: #fff;
  border-radius: 5px;
  padding: 5px 7px;
  font-size: 0.72rem;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
  transition: opacity 0.1s, filter 0.1s;
  line-height: 1.35;
}
.dash-appt-card:hover { opacity: 0.92; filter: brightness(1.08); }
.dash-appt-time { color: rgba(255,255,255,0.7); font-size: 0.62rem; }
.dash-appt-name { font-weight: 600; }
.dash-appt-vehicle {
  color: rgba(255,255,255,0.78);
  font-size: 0.62rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 1px;
}
.dash-appt-actions { margin-top: 4px; display: flex; gap: 3px; flex-wrap: wrap; }

/* Action buttons for mobile list rows (light background) */
.dash-list-action-btn {
  font-size: 0.62rem;
  border: 1px solid #d1d5db;
  border-radius: 3px;
  padding: 1px 6px;
  color: #4b5563;
  background: white;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.dash-list-action-btn:hover { background: var(--brand-text); color: #fff; border-color: var(--brand-text); }

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.spinner {
  border: 2px solid rgba(0,0,0,0.08);
  border-top-color: var(--brand-accent);
  border-radius: 50%;
  width: 1.5rem;
  height: 1.5rem;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Brand buttons ───────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--brand-accent);
  color: #fff;
  transition: background 0.12s;
}
.btn-primary:hover { background: var(--brand-accent-dark); }

/* ── Garage Loader Overlay ───────────────────────────────────────────────── */
#garage-loader {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.garage-scene {
  width: 540px;
  max-width: 92vw;
  height: 320px;
  background: linear-gradient(180deg, #1b3a5c 0%, #243f6e 100%);
  border: 12px solid #34495e;
  border-radius: 14px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0,0,0,0.7);
}
.garage-door {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 150px;
  background: repeating-linear-gradient(45deg, #243f6e, #243f6e 25px, #162b4d 25px, #162b4d 50px);
  border-top: 10px solid var(--brand-accent);
  box-shadow: inset 0 0 30px rgba(0,0,0,0.5);
}
.garage-conveyor {
  position: absolute;
  bottom: 55px;
  left: 0; right: 0;
  height: 38px;
  background: #162b4d;
  box-shadow: 0 4px 0 #0f1e38;
}
.garage-conveyor::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent, transparent 28px, rgba(255,255,255,0.12) 28px, rgba(255,255,255,0.12) 56px);
  animation: loaderConveyorMove 1s linear infinite;
}
@keyframes loaderConveyorMove {
  from { background-position: 0 0; }
  to   { background-position: -112px 0; }
}
#loader-items {
  position: absolute;
  bottom: 104px;
  left: 0; right: 0;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 10px;
  height: 68px;
}
.loader-item {
  width: 52px; height: 52px;
  font-size: 30px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.95);
  border: 3px solid rgba(255,255,255,0.25);
  border-radius: 10px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.45);
  animation: loaderFlyIn 0.8s ease forwards, loaderBob 1.4s ease-in-out infinite alternate;
  flex-shrink: 0;
}
@keyframes loaderFlyIn {
  from { transform: translateY(-240px) rotate(-28deg) scale(0.5); opacity: 0; }
  to   { transform: translateY(0) rotate(0deg) scale(1); opacity: 1; }
}
@keyframes loaderBob {
  from { transform: translateY(0) rotate(-3deg); }
  to   { transform: translateY(-10px) rotate(3deg); }
}
.loader-text {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  color: #f1c40f;
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  text-shadow: 0 2px 6px rgba(0,0,0,0.6);
}

/* ── Scrollable table wrapper ────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Service Writer Workbench (Direction D) ──────────────────────────────────
   Self-contained palette + layout so the workbench reads as its own surface
   without fighting the global console theme. Steel background, teal-blue accent. */
.wb-root {
  --wb-bg:        #EEF3F8;
  --wb-surface:   #ffffff;
  --wb-border:    #d8e2ec;
  --wb-ink:       #0B1F33;
  --wb-muted:     #5b7186;
  --wb-accent:    #0E7C86;
  --wb-accent-dk: #0a5b62;
  --wb-soft:      #f2f7fb;
  display: flex;
  height: 100%;
  background: var(--wb-bg);
  color: var(--wb-ink);
  overflow: hidden;
  font-feature-settings: "tnum";
}
[data-theme="blue-dark"] .wb-root,
[data-theme="red-dark"] .wb-root {
  --wb-bg: #0d1b2a; --wb-surface: #1e2d3d; --wb-border: rgba(255,255,255,.10);
  --wb-ink: #e2e8f0; --wb-muted: #94a3b8; --wb-soft: #243447; --wb-accent: #2dd4bf; --wb-accent-dk: #14b8a6;
}

.wb-muted { color: var(--wb-muted); }
.wb-ink   { color: var(--wb-ink); }
.wb-border { border-color: var(--wb-border) !important; }
.wb-link  { color: var(--wb-accent); }
.wb-link:hover { text-decoration: underline; }

/* Panes */
.wb-pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; border-right: 1px solid var(--wb-border); }
.wb-queue   { width: 270px; flex: 0 0 270px; background: var(--wb-surface); }
.wb-context { width: 290px; flex: 0 0 290px; }
.wb-convo   { flex: 1 1 auto; background: var(--wb-soft); }
.wb-assist  { width: 300px; flex: 0 0 300px; border-right: 0; }
.wb-scroll  { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; min-height: 0; }

.wb-pane-head { padding: 10px 12px; border-bottom: 1px solid var(--wb-border); background: var(--wb-surface); }
.wb-pane-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--wb-muted); }

/* Cards */
.wb-card { background: var(--wb-surface); border: 1px solid var(--wb-border); border-radius: 14px; }
.wb-card-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--wb-muted); }

/* Inputs */
.wb-input { width: 100%; background: var(--wb-surface); border: 1px solid var(--wb-border); border-radius: 9px; padding: 6px 10px; font-size: 13px; color: var(--wb-ink); }
.wb-input:focus { outline: none; border-color: var(--wb-accent); }
.wb-input-sm { background: var(--wb-surface); border: 1px solid var(--wb-border); border-radius: 7px; padding: 3px 7px; font-size: 11px; max-width: 110px; color: var(--wb-ink); }
.wb-input-sm:focus { outline: none; border-color: var(--wb-accent); }
.wb-textarea { width: 100%; background: var(--wb-surface); border: 1px solid var(--wb-border); border-radius: 10px; padding: 8px 10px; font-size: 13px; resize: none; color: var(--wb-ink); }
.wb-textarea:focus { outline: none; border-color: var(--wb-accent); }

/* Buttons */
.wb-pill { font-size: 10px; font-weight: 700; background: var(--wb-soft); color: var(--wb-muted); border-radius: 999px; padding: 1px 7px; }
.wb-icon-btn { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--wb-border); border-radius: 8px; background: var(--wb-surface); font-size: 14px; transition: .15s; }
.wb-icon-btn:hover { border-color: var(--wb-accent); color: var(--wb-accent); }
.wb-btn-primary { font-size: 12px; font-weight: 600; color: #fff; background: var(--wb-accent); border-radius: 9px; padding: 6px 14px; transition: .15s; }
.wb-btn-primary:hover { background: var(--wb-accent-dk); }
.wb-btn-primary:disabled { opacity: .55; }
.wb-btn-ghost { font-size: 12px; font-weight: 500; color: var(--wb-muted); background: var(--wb-surface); border: 1px solid var(--wb-border); border-radius: 9px; padding: 5px 11px; transition: .15s; }
.wb-btn-ghost:hover { border-color: var(--wb-accent); color: var(--wb-accent); }
.wb-chip { font-size: 11px; font-weight: 600; color: var(--wb-muted); background: var(--wb-surface); border: 1px solid var(--wb-border); border-radius: 999px; padding: 3px 10px; transition: .15s; }
.wb-chip:hover { border-color: var(--wb-accent); }
.wb-chip-on { background: var(--wb-accent); color: #fff; border-color: var(--wb-accent); }
.wb-act-btn { font-size: 11px; font-weight: 600; color: var(--wb-ink); background: var(--wb-soft); border: 1px solid var(--wb-border); border-radius: 8px; padding: 5px 10px; transition: .15s; }
.wb-act-btn:hover { border-color: var(--wb-accent); color: var(--wb-accent); }

/* Queue rows */
.wb-qrow { display: block; width: 100%; text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--wb-border); transition: background .12s; }
.wb-qrow:hover { background: var(--wb-soft); }
.wb-qrow-on { background: var(--wb-soft); box-shadow: inset 3px 0 0 var(--wb-accent); }
.wb-qchan { font-size: 12px; }
.wb-unread-dot { width: 7px; height: 7px; border-radius: 999px; background: var(--wb-accent); display: inline-block; }

/* Conversation */
.wb-convo-head { display: flex; align-items: center; gap: 10px; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--wb-border); background: var(--wb-surface); }
.wb-bubble { max-width: 78%; min-width: 0; border-radius: 14px; padding: 8px 11px; font-size: 13px; box-shadow: 0 1px 2px rgba(11,31,51,.06); }
.wb-bubble-in  { background: var(--wb-surface); border: 1px solid var(--wb-border); color: var(--wb-ink); border-bottom-left-radius: 4px; }
.wb-bubble-out { background: var(--wb-accent); color: #fff; border-bottom-right-radius: 4px; }
.wb-composer { border-top: 1px solid var(--wb-border); background: var(--wb-surface); padding: 10px 12px; }

/* Context / assist rows */
.wb-pastrow { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 5px 7px; border-radius: 8px; transition: background .12s; }
.wb-pastrow:hover { background: var(--wb-soft); }
.wb-canned { display: block; width: 100%; text-align: left; font-size: 12px; padding: 6px 9px; border: 1px solid var(--wb-border); border-radius: 8px; transition: .15s; color: var(--wb-ink); }
.wb-canned:hover { border-color: var(--wb-accent); background: var(--wb-soft); }
.wb-note { background: var(--wb-soft); border: 1px solid var(--wb-border); border-radius: 9px; padding: 6px 9px; }

/* Mobile tab bar — hidden on laptop, panes shown side by side */
.wb-tabbar { display: none; }
@media (max-width: 1023px) {
  .wb-root { position: relative; }
  .wb-pane { display: none; width: 100% !important; flex: 1 1 auto !important; border-right: 0; padding-bottom: 56px; }
  .wb-pane.wb-active { display: flex; }
  .wb-tabbar { display: flex; position: absolute; bottom: 0; left: 0; right: 0; height: 56px; background: var(--wb-surface); border-top: 1px solid var(--wb-border); z-index: 20; }
  .wb-tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--wb-muted); font-size: 16px; }
  .wb-tab-on { color: var(--wb-accent); box-shadow: inset 0 2px 0 var(--wb-accent); }
}

/* ── Service Writer Timeline (Direction C) ───────────────────────────────────
   One unified story per customer. White surfaces, indigo accent — distinct
   from the Workbench's steel/teal so the two directions read differently. */
.tl-root {
  --tl-bg:      #ffffff;
  --tl-rail:    #FAFAFB;
  --tl-feed:    #F6F7FB;
  --tl-border:  #e6e8f0;
  --tl-ink:     #0F172A;
  --tl-muted:   #64708a;
  --tl-accent:  #5B5BD6;
  --tl-accent-dk: #4a4ac0;
  display: flex;
  position: relative;
  height: 100%;
  background: var(--tl-bg);
  color: var(--tl-ink);
  overflow: hidden;
}
[data-theme="blue-dark"] .tl-root,
[data-theme="red-dark"] .tl-root {
  --tl-bg: #1e2d3d; --tl-rail: #18242f; --tl-feed: #0d1b2a; --tl-border: rgba(255,255,255,.10);
  --tl-ink: #e2e8f0; --tl-muted: #94a3b8; --tl-accent: #8b8bf0; --tl-accent-dk: #7676e6;
}

.tl-ink { color: var(--tl-ink); }
.tl-muted { color: var(--tl-muted); }
.tl-accent-text { color: var(--tl-accent); }
.tl-link { color: var(--tl-accent); }
.tl-link:hover { text-decoration: underline; }

/* Left rail */
.tl-rail { width: 264px; flex: 0 0 264px; background: var(--tl-rail); border-right: 1px solid var(--tl-border); display: flex; flex-direction: column; min-height: 0; }
.tl-rail-head { padding: 12px; border-bottom: 1px solid var(--tl-border); }
.tl-rail-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--tl-muted); }
.tl-queue { overflow-y: auto; min-height: 0; max-height: 45%; border-bottom: 1px solid var(--tl-border); }
.tl-facts { overflow-y: auto; min-height: 0; flex: 1; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.tl-qrow { display: block; width: 100%; text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--tl-border); transition: background .12s; }
.tl-qrow:hover { background: var(--tl-feed); }
.tl-qrow-on { background: var(--tl-feed); box-shadow: inset 3px 0 0 var(--tl-accent); }
.tl-fact { background: var(--tl-bg); border: 1px solid var(--tl-border); border-radius: 12px; padding: 10px; }
.tl-fact-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--tl-muted); }

/* Center column */
.tl-main { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--tl-feed); }
.tl-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--tl-border); background: var(--tl-bg); }
.tl-feed { flex: 1 1 auto; overflow-y: auto; min-height: 0; padding: 18px 16px; display: flex; flex-direction: column; }
.tl-feed > * { width: 100%; }

/* Message bubbles */
.tl-bubble { max-width: 72%; min-width: 0; border-radius: 16px; padding: 8px 12px; font-size: 13px; line-height: 1.45; box-shadow: 0 1px 2px rgba(15,23,42,.06); }
.tl-bubble-in  { background: var(--tl-bg); border: 1px solid var(--tl-border); border-bottom-left-radius: 5px; }
.tl-bubble-out { background: var(--tl-accent); color: #fff; border-bottom-right-radius: 5px; }

/* Centered system/event chips */
.tl-event { align-self: center; max-width: 80%; text-align: center; font-size: 11.5px; color: var(--tl-muted); background: var(--tl-bg); border: 1px solid var(--tl-border); border-radius: 999px; padding: 5px 14px; margin: 6px 0; }
.tl-event-body { text-align: left; color: var(--tl-ink); font-size: 12.5px; margin-top: 4px; white-space: pre-wrap; }
.tl-event-note   { border-color: #f1d9a8; background: #fffaf0; color: #92710f; border-radius: 12px; }
.tl-event-ro     { border-color: #cbd5f5; background: #f3f5fe; color: var(--tl-accent-dk); }
.tl-event-appt   { border-color: #bfe3f7; background: #f0f9ff; color: #0c6e9e; }
.tl-event-review { border-color: #f9d8c0; background: #fff7ed; color: #b45309; border-radius: 12px; }
.tl-event-jobchat { border-color: #b9e0d8; background: #f0fbf8; color: #0f766e; border-radius: 12px; }
.tl-event-roevent { border-color: #cbd5f5; background: #f3f5fe; color: var(--tl-accent-dk); border-radius: 12px; }
.tl-stars { letter-spacing: 1px; }
.tl-divider { align-self: center; display: flex; align-items: center; gap: 8px; margin: 14px 0 8px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--tl-muted); }
.tl-divider::before, .tl-divider::after { content: ''; width: 36px; height: 1px; background: var(--tl-border); }

/* Composer (pinned) */
.tl-compose { border-top: 1px solid var(--tl-border); background: var(--tl-bg); padding: 10px 14px; }
.tl-textarea { width: 100%; background: var(--tl-bg); border: 1px solid var(--tl-border); border-radius: 14px; padding: 9px 12px; font-size: 13px; resize: none; color: var(--tl-ink); min-height: 40px; }
.tl-textarea:focus { outline: none; border-color: var(--tl-accent); }
.tl-suggest { background: #f3f5fe; border: 1px solid #cbd5f5; border-radius: 12px; padding: 9px 11px; margin-bottom: 8px; }
[data-theme="blue-dark"] .tl-suggest, [data-theme="red-dark"] .tl-suggest { background: rgba(139,139,240,.12); border-color: rgba(139,139,240,.35); }
.tl-input { width: 100%; background: var(--tl-bg); border: 1px solid var(--tl-border); border-radius: 9px; padding: 6px 10px; font-size: 13px; color: var(--tl-ink); }
.tl-input:focus { outline: none; border-color: var(--tl-accent); }

/* Buttons */
.tl-icon-btn { width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--tl-border); border-radius: 9px; background: var(--tl-bg); font-size: 14px; transition: .15s; }
.tl-icon-btn:hover { border-color: var(--tl-accent); color: var(--tl-accent); }
.tl-btn-primary { font-size: 12px; font-weight: 600; color: #fff; background: var(--tl-accent); border-radius: 10px; padding: 7px 15px; transition: .15s; }
.tl-btn-primary:hover { background: var(--tl-accent-dk); }
.tl-btn-primary:disabled { opacity: .55; }
.tl-btn-ghost { font-size: 12px; font-weight: 500; color: var(--tl-muted); background: var(--tl-bg); border: 1px solid var(--tl-border); border-radius: 10px; padding: 6px 12px; transition: .15s; }
.tl-btn-ghost:hover { border-color: var(--tl-accent); color: var(--tl-accent); }
.tl-chip { font-size: 11px; background: var(--tl-feed); border: 1px solid var(--tl-border); border-radius: 999px; padding: 2px 9px; color: var(--tl-muted); }
.tl-snip-pop { position: absolute; bottom: calc(100% + 6px); left: 0; width: 240px; max-height: 260px; overflow-y: auto; background: var(--tl-bg); border: 1px solid var(--tl-border); border-radius: 12px; box-shadow: 0 10px 30px rgba(15,23,42,.15); padding: 6px; z-index: 40; }
.tl-snip-item { display: block; width: 100%; text-align: left; font-size: 12px; padding: 6px 9px; border-radius: 8px; color: var(--tl-ink); }
.tl-snip-item:hover { background: var(--tl-feed); }
.tl-rail-toggle { display: none; width: 32px; height: 32px; align-items: center; justify-content: center; border: 1px solid var(--tl-border); border-radius: 9px; background: var(--tl-bg); font-size: 15px; }
.tl-backdrop { display: none; }

/* Mobile: rail becomes a slide-over; feed is the base layer */
@media (max-width: 1023px) {
  .tl-rail { position: absolute; inset: 0 auto 0 0; z-index: 30; transform: translateX(-110%); transition: transform .25s ease; }
  .tl-rail.tl-rail-open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,.25); }
  .tl-rail-toggle { display: inline-flex; }
  .tl-backdrop { display: none; position: absolute; inset: 0; background: rgba(0,0,0,.35); z-index: 25; }
  .tl-backdrop.tl-backdrop-on { display: block; }
  .tl-bubble { max-width: 84%; }
}
