/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --color-bg:         #fdf4f8;
  --color-surface:    #ffffff;
  --color-primary:    #cc5b8e;
  --color-primary-dk: #b0487a;
  --color-accent:     #5ab8b9;
  --color-text:       #2a1a22;
  --color-muted:      #8a6878;
  --color-border:     #f0d6e6;
  --color-error:      #c0392b;
  --color-error-bg:   #fdf0ef;

  --radius-sm:   6px;
  --radius-md:   12px;
  --radius-lg:   20px;
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.09);
  --transition:  0.2s ease;

  --font-sans: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;

  /* Layout */
  --topbar-height: 56px;
  --safe-top:    env(safe-area-inset-top,    0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left,   0px);
  --safe-right:  env(safe-area-inset-right,  0px);
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 16px; /* Prevents iOS auto-zoom on inputs */
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
}

/* ───── iOS Safari: prevent auto-zoom on input focus ─────
   Mobile Safari zooms the page when a focused input has font-size < 16px,
   regardless of the body default. Force every form field on touch devices
   to 16px so the zoom never triggers, while keeping our designed sizes on
   desktop. */
@media (hover: none) and (pointer: coarse) {
  input,
  textarea,
  select,
  button {
    font-size: 16px !important;
  }
}

/* Touch optimisation for all interactive elements */
a, button, [role="button"] {
  touch-action: manipulation;
  cursor: pointer;
}

/* ===== LOGIN / INDEX BODY ===== */
body:not(.page-full) {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  padding-top:    max(1.5rem, env(safe-area-inset-top));
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  padding-left:   max(1.5rem, env(safe-area-inset-left));
  padding-right:  max(1.5rem, env(safe-area-inset-right));
}

/* ===== STATE CONTAINERS ===== */
.state-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 480px;
  animation: fadeIn 0.3s ease;
}

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

/* ===== LOADING SPINNER ===== */
.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  margin-bottom: 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.state-message {
  color: var(--color-muted);
  font-size: 0.95rem;
  letter-spacing: 0.01em;
  text-align: center;
}

/* ===== BRAND LOGO ===== */
.profile-logo {
  text-align: center;
  padding: 0.5rem 0 1rem;
}

.brand-logo {
  max-width: 220px;
  width: 100%;
  height: auto;
}

/* ===== PROFILE CARD ===== */
.profile-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1.5rem;
  width: 100%;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
}

.profile-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.profile-headline h1 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.3;
}

.spoke-badge {
  display: inline-block;
  margin-top: 0.25rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-accent);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ===== USER DETAILS ===== */
.user-details {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}

.detail-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0.5rem;
  align-items: start;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.875rem;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  color: var(--color-muted);
  font-weight: 500;
  text-transform: capitalize;
  white-space: nowrap;
}

.detail-value {
  color: var(--color-text);
  word-break: break-word;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 48px; /* Touch-friendly */
  padding: 0.6rem 1.4rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.btn-primary:hover { background: var(--color-primary-dk); }

.btn-secondary {
  background: transparent;
  color: var(--color-muted);
  border: 1.5px solid var(--color-border);
}
.btn-secondary:hover { background: var(--color-bg); color: var(--color-text); }

/* ===== PROFILE ACTIONS ===== */
.profile-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding-top: 0.75rem;
  border-top: 1px solid var(--color-border);
}

.profile-actions .btn {
  flex: 1;
  min-width: 120px;
}

/* ===== ERROR CARD ===== */
.error-card {
  background: var(--color-error-bg);
  border: 1.5px solid #f0c0bc;
  border-radius: var(--radius-md);
  padding: 2rem 1.5rem;
  width: 100%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.error-icon {
  font-size: 2rem;
  color: var(--color-error);
}

.error-message {
  color: var(--color-error);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ===== PAGE LAYOUT (clientlist + future pages) ===== */
/* The base `html { overflow:hidden }` and `body { overflow:hidden }` rules
   near the top of this file lock scrolling for the LOGIN page. For full-
   page views (clientlist, chat) we MUST explicitly re-enable vertical
   scrolling on the document, otherwise the global lock wins on iOS/Android
   and the user can't scroll the client list at all.

   Strategy: let the document itself scroll (single scroll container).
   - html → overflow-y: auto (un-lock vertical scroll, keep horizontal hidden)
   - body → overflow: visible (do NOT make body its own scroll container,
            otherwise iOS gets two competing scroll contexts and neither
            actually scrolls). */
html:has(body.page-full) {
  overflow-y: auto;
  overflow-x: hidden;
}
body.page-full {
  overflow: visible;
}
/* Chat is a fixed-height flex column — neither the html nor the body
   should ever scroll. Only the inner .chat-thread does. Without this,
   a long message history makes the document itself scroll and drags
   the sticky topbar off the screen. */
html:has(body.page-chat),
body.page-chat {
  overflow: hidden !important;
  overscroll-behavior: none;
  /* iOS: stop the document itself from rubber-banding when the inner
     chat thread reaches its edge. Without this, the bounce chains to
     the document and visually drags the topbar. */
  overscroll-behavior-y: none;
  touch-action: pan-y;
}

/* ───── Parent SPA scroll lock when the chat iframe is open ─────
   `clientlist.js` toggles `chat-panel-open` on <html> and <body> while
   the chat overlay is mounted. We apply the same iOS-proof lock the
   chat page uses on itself (position:fixed + overscroll-behavior:none),
   plus touch-action:none on the parent #main-topbar so any swipe that
   begins on the pink header is fully ignored — the data-loading spinner,
   the "Booking Discussed" popup inside the iframe, and the message
   thread can no longer drag the parent topbar. */
html.chat-panel-open,
body.chat-panel-open {
  overflow: hidden !important;
  overscroll-behavior: none;
}
body.chat-panel-open {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}
body.chat-panel-open #main-topbar,
body.chat-panel-open #chat-panel-overlay {
  touch-action: none;
}
body.page-full {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--color-bg);
  /* Do NOT set `overscroll-behavior` or `-webkit-overflow-scrolling` here:
     body is not the scroll container on the list page (the document is),
     and adding either turns body into one on iOS, which then prevents the
     document from scrolling at all. The chat-page lock above is scoped to
     `body.page-chat` and `body.chat-panel-open` so it doesn't leak here. */
}

/* ── Top navigation bar ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  /* Pad top for iOS status bar / notch */
  padding-top: env(safe-area-inset-top, 0px);
  height: calc(var(--topbar-height) + env(safe-area-inset-top, 0px));
  padding-left:  max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  flex-shrink: 0;
}

/* Topbar states (list vs chat) — each fills the full bar */
.topbar-state {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  min-width: 0;
}

/* Topbar subtitle (phone number in chat state) */
.topbar-subtitle {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.72);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Embedded mode — hide own topbar and assume bar when inside the SPA iframe */
[data-embedded] .topbar,
[data-embedded] #rmt-assume-bar {
  display: none !important;
}
[data-embedded] .page-chat {
  padding-top: 0;
}

.topbar-back {
  background: none;
  border: none;
  color: rgba(255,255,255,0.9);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0 0.25rem;
  transition: color var(--transition);
}
.topbar-back:hover { color: #fff; }

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-user {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.75);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
  flex-shrink: 0;
}

.topbar-title-select {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 1.2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='rgba(255,255,255,0.7)' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.1rem center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-title-select option {
  background: #cc5b8e;
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
}


/* ── Page main area ── */
/* Let the document scroll instead of the inner container so touch/wheel
   events behave naturally inside iframes and on mobile. */
.page-main {
  flex: 1 0 auto;
  padding: 1.25rem 1rem;
  padding-left:  max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

/* List page: reduce horizontal padding so cards feel full-width */
.page-main--list {
  padding-left:  0;
  padding-right: 0;
}
.page-main--list .tbl-toolbar,
.page-main--list .tbl-search-wrap {
  padding-left:  max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
}

/* ── Conversation list (WhatsApp-style) ── */
.convo-list {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.convo-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.8rem max(1rem, env(safe-area-inset-right)) 0.8rem max(1rem, env(safe-area-inset-left));
  border-bottom: 1px solid var(--color-border);
  min-height: 72px;
  background: var(--color-surface);
  transition: background var(--transition);
}
.convo-card:last-child { border-bottom: none; }

.convo-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: 0.02em;
}

.convo-avatar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.18rem;
  flex-shrink: 0;
}

.convo-avatar-id {
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text-muted, #888);
  letter-spacing: 0.03em;
  line-height: 1;
  font-family: 'SF Mono', 'Fira Mono', monospace;
  user-select: none;
}

.convo-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
}

.convo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.convo-name {
  font-size: 0.96rem;
  font-weight: 500;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
  min-width: 0;
}
.convo-name--unread { font-weight: 700; color: var(--color-primary); }

/* Unread card — subtle pink tint + accent left border */
.row-unread {
  background: rgba(204, 91, 142, 0.07);
  border-left: 3px solid var(--color-primary);
  padding-left: calc(max(1rem, env(safe-area-inset-left)) - 3px);
}

/* Fresh card — bold flash animation when a new message just arrived */
@keyframes row-flash-in {
  0%   { background-color: rgba(204, 91, 142, 0.30); }
  100% { background-color: transparent; }
}
.row-fresh {
  animation: row-flash-in 1.8s ease-out forwards;
}
.row-fresh.row-unread {
  animation: row-flash-in 1.8s ease-out forwards;
  background-color: rgba(204, 91, 142, 0.07); /* fallback after animation */
}

/* "New" badge next to name */
.new-msg-icon {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.68rem;
  font-weight: 700;
  color: #fff;
  background: var(--color-primary);
  padding: 2px 7px 2px 5px;
  border-radius: 20px;
  white-space: nowrap;
  vertical-align: middle;
  letter-spacing: 0.02em;
}
.msg-count-badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.1rem 0.45rem;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 600;
  background: #e8edf5;
  color: #556;
  vertical-align: middle;
  line-height: 1.5;
  white-space: nowrap;
}

/* ── Client star rating ── */
.client-stars {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
  margin-left: 5px;
  line-height: 1;
  cursor: default;
  border-radius: 4px;
  padding: 1px 2px;
}

/* Booking popup overlay */
.booking-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 12000;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.booking-popup-card {
  background: var(--color-surface, #fff);
  border-radius: 18px;
  padding: 1.75rem 1.5rem 1.5rem;
  max-width: 340px;
  width: 100%;
  box-shadow: 0 12px 48px rgba(0,0,0,0.28);
  text-align: center;
}
.booking-popup-icon { font-size: 2.2rem; margin-bottom: 0.5rem; }
.booking-popup-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text, #1a1a2e);
  margin: 0 0 0.5rem;
}
.booking-popup-msg {
  font-size: 0.88rem;
  color: var(--text-muted, #666);
  margin: 0 0 1.1rem;
  line-height: 1.45;
}
.booking-popup-btns {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.booking-date-label {
  display: block;
  text-align: left;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted, #555);
  margin: 0 0 0.25rem;
}
.booking-date-input {
  display: block;
  width: 100%;
  border: 1px solid var(--color-border, #ddd);
  border-radius: 8px;
  padding: 0.55rem 0.75rem;
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  box-sizing: border-box;
  background: var(--color-surface, #fff);
  color: var(--color-text, #1a1a2e);
}
.booking-save-err {
  font-size: 0.8rem;
  color: #e74c3c;
  margin: 0.25rem 0 0.5rem;
  text-align: left;
}
.client-star {
  font-size: 1.17rem;
  line-height: 1;
  display: inline-block;
}

/* ── Score breakdown popover ── */
.score-popover {
  position: fixed;
  z-index: 13000;
  background: #1e1030;
  border: 1px solid #3d2a55;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.65);
  padding: 0.75rem 0.9rem 0.7rem;
  pointer-events: auto;
  animation: popover-in 0.15s ease;
}
@keyframes popover-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.score-popover-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.55rem;
  gap: 0.5rem;
}
.score-popover-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: #b89ec8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.score-popover-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1;
}
.score-popover-value small {
  font-size: 0.68rem;
  font-weight: 400;
  color: #b89ec8;
  margin-left: 1px;
}
.score-popover-clean {
  font-size: 0.78rem;
  color: #4ade80;
  margin: 0;
  padding: 0.35rem 0;
}
.score-popover-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  border-top: 1px solid #3d2a55;
  padding-top: 0.45rem;
}
.score-popover-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
}
.score-popover-label {
  color: #f0e6ff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.score-popover-count {
  font-style: normal;
  color: #b89ec8;
  font-size: 0.7rem;
}
.score-popover-sev {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.score-popover-ded {
  font-size: 0.72rem;
  color: #ff6b6b;
  font-weight: 700;
  white-space: nowrap;
  text-align: right;
}
.score-popover-footer {
  font-size: 0.68rem;
  color: #b89ec8;
  margin: 0.55rem 0 0;
  padding-top: 0.45rem;
  border-top: 1px solid #3d2a55;
}

.convo-meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

/* Pin button — appears on every convo card */
.convo-pin-btn {
  background: transparent;
  border: 0;
  padding: 0.18rem 0.32rem;
  margin-left: 0.15rem;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 6px;
  opacity: 0.35;
  filter: grayscale(1);
  transition: opacity 0.15s ease, background 0.15s ease, filter 0.15s ease;
  flex-shrink: 0;
}
.convo-pin-btn:hover { opacity: 0.85; background: rgba(0,0,0,0.05); }
.convo-pin-btn.is-pinned {
  opacity: 1;
  filter: none;
}
.convo-pin-btn.is-pinned:hover { background: rgba(204,91,142,0.12); }
.convo-pin-btn:disabled { cursor: wait; }

/* Subtle left accent on pinned cards (only when not unread, since unread
   already gets its own highlight) */
.convo-card.row-pinned:not(.row-unread) {
  background: linear-gradient(90deg, rgba(204,91,142,0.06) 0%, transparent 60%);
  box-shadow: inset 3px 0 0 rgba(204,91,142,0.55);
}

.convo-time {
  font-size: 0.72rem;
  color: var(--color-muted);
  white-space: nowrap;
}

.convo-preview {
  font-size: 0.81rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0.18rem 0.6rem;
  border-radius: 10px;
  display: inline-block;
  max-width: 100%;
  box-sizing: border-box;
  cursor: default;
}
.convo-preview--rmt    { background: #cc5b8e; color: #fff; }
.convo-preview--client { background: #189dad; color: #fff; }
.convo-preview--empty  { color: var(--color-muted); font-style: italic; background: none; padding: 0; }

.convo-preview-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.convo-last-seen {
  font-size: 0.65rem;
  color: var(--color-muted);
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: auto;
  opacity: 0.75;
}

/* ── Message hover tooltip ── */
.convo-msg-tip {
  position: fixed;
  z-index: 5000;
  background: #fff;
  border: 1px solid #e8d8ec;
  border-radius: 10px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.14);
  padding: 0.55rem 0.75rem;
  min-width: 200px;
  max-width: 280px;
  pointer-events: none;
  animation: popover-in 0.12s ease;
}
.msg-tip-row {
  display: flex;
  gap: 0.4rem;
  align-items: baseline;
  font-size: 0.78rem;
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
  margin-bottom: 0.2rem;
}
.msg-tip-row:last-child { margin-bottom: 0; }
.msg-tip-row--rmt    { background: #fce8f3; }
.msg-tip-row--client { background: #e5f7f9; }
.msg-tip-sender {
  font-weight: 700;
  font-size: 0.72rem;
  flex-shrink: 0;
  white-space: nowrap;
}
.msg-tip-row--rmt    .msg-tip-sender { color: #cc5b8e; }
.msg-tip-row--client .msg-tip-sender { color: #189dad; }
.msg-tip-text {
  color: #333;
  line-height: 1.35;
  word-break: break-word;
  white-space: normal;
}

/* Unread pulse on cards */
.convo-card.row-unread {
  animation: row-pulse 2s ease-in-out infinite;
}

.convo-card.row-fresh {
  animation: row-fresh-pulse 1.4s ease-in-out infinite;
}

@keyframes row-fresh-pulse {
  0%   { background: #fff; }
  50%  { background: #fde8f3; }
  100% { background: #fff; }
}

/* ── Table states ── */
.tbl-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  gap: 1rem;
  text-align: center;
}

.empty-icon {
  font-size: 3rem;
  opacity: 0.4;
}

/* ── Toolbar ── */
.tbl-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.tbl-heading {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text);
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tbl-count {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--color-muted);
  background: var(--color-border);
  padding: 0.1rem 0.5rem;
  border-radius: 99px;
}

/* ── Search bar ── */
.tbl-search-wrap {
  margin-bottom: 0.75rem;
}

.tbl-search {
  width: 100%;
  padding: 0.65rem 1rem 0.65rem 2.5rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--color-text);
  background: var(--color-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7c93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") 0.75rem center / 1rem no-repeat;
  min-height: 48px;
  box-sizing: border-box;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

.tbl-search:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(45, 106, 159, 0.15);
}

.tbl-search::placeholder {
  color: var(--color-muted);
}

/* ── Scrollable table wrapper ── */
.tbl-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  background: var(--color-surface);
}

/* ── Data table ── */
.data-table {
  border-collapse: collapse;
  font-size: 0.875rem;
  white-space: nowrap;
  min-width: 100%;
}

/* First 2 columns: # and ID — fixed 70px */
.col-fixed {
  width: 70px;
  min-width: 70px;
  max-width: 70px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-sizing: border-box;
}

.col-num {
  color: var(--color-muted);
  font-size: 0.78rem;
  text-align: center;
}

.data-table thead {
  background: var(--color-primary);
  color: #fff;
}

.data-table th {
  padding: 0.7rem 0.9rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.data-table th.col-fixed {
  padding: 0.7rem 0.4rem;
  text-align: center;
}

.data-table td {
  padding: 0.75rem 0.9rem;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
  min-height: 48px; /* Touch-friendly row height */
}

.data-table td.col-fixed {
  padding: 0.75rem 0.4rem;
  text-align: center;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:nth-child(odd) {
  background: #ffffff;
}

.data-table tbody tr:nth-child(even) {
  background: #f2f7fb;
}

@media (hover: hover) {
  .data-table tbody tr:hover {
    background: #e8f1f8;
  }
}

/* ===== TAPPABLE ROWS ===== */
.row-tappable {
  cursor: pointer;
  transition: background var(--transition);
}
@media (hover: hover) {
  .row-tappable:hover { background: #ddeef8 !important; }
}
.row-tappable:active { background: #c8e2f4 !important; }

/* ── Unread / new-message indicator ── */
@keyframes row-pulse {
  0%, 100% { background-color: rgba(125, 200, 209, 0.10); }
  50%       { background-color: rgba(125, 200, 209, 0.28); }
}

@keyframes badge-pulse {
  0%, 100% { transform: scale(1);    box-shadow: 0 1px 4px rgba(125, 200, 209, 0.45); }
  50%       { transform: scale(1.12); box-shadow: 0 2px 10px rgba(125, 200, 209, 0.80); }
}

.row-unread {
  animation: row-pulse 2s ease-in-out infinite;
}

.row-unread td {
  font-weight: 600;
}

.new-flag-cell {
  width: 72px;
  text-align: center;
  white-space: nowrap;
}

.new-msg-icon {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #7DC8D1;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 2px 7px 2px 5px;
  border-radius: 10px;
  vertical-align: middle;
  letter-spacing: 0.03em;
  white-space: nowrap;
  animation: badge-pulse 1.6s ease-in-out infinite;
}

/* ===== CHAT PAGE ===== */
/* `position: fixed; inset: 0` is the iOS-Safari-proof way to lock the
   document. Plain `overflow:hidden` on body doesn't always prevent the
   page itself from scrolling on iOS — touches near the edges still
   rubber-band the document and drag the topbar with them. Pinning the
   body in place forces every swipe to land on the inner .chat-thread. */
body.page-chat {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #fdf0f6;
}

/* Block iOS from interpreting swipes that *start* in the chat header bars
   as document scrolls. Without this, dragging a finger that begins on the
   topbar / stats / appointment bar still triggers browser-level pan and
   moves the header up, even though the body itself is locked. `touch-action:
   none` disables pan/zoom on these elements but leaves tap/click intact, so
   the back button, AI button, stats handle, etc. still work normally. */
body.page-chat .topbar,
body.page-chat #stats-panel,
body.page-chat .appt-bar,
body.page-chat .chat-input-bar,
body.page-chat #rmt-assume-bar {
  touch-action: none;
}

/* Client sub-title in topbar */
.chat-topbar-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  min-width: 0;
}

.chat-topbar-info .topbar-title {
  flex: unset;
  font-size: 0.98rem;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-subtitle {
  font-size: 1.08rem;
  color: #fff;
  font-weight: 400;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Message thread ── */
/* ── Manager stats panel ── */
#stats-panel {
  width: 100%;
  background: #1a0d14;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  z-index: 90;
}

.stats-grab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  height: 26px;
  background: rgba(255,255,255,0.06);
  border: none;
  border-top: 1px solid rgba(255,255,255,0.1);
  cursor: pointer;
  padding: 0;
  transition: background 0.15s;
}

.stats-grab:hover {
  background: rgba(255,255,255,0.1);
}

.stats-grab::before {
  content: "▾ Stats";
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.45);
}

.stats-grab[aria-expanded="true"]::before {
  content: "▴ Stats";
}

.stats-grab-pill {
  display: block;
  width: 28px;
  height: 3px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
}

.stats-grab:hover .stats-grab-pill {
  background: rgba(255,255,255,0.4);
}

.stats-drawer {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.28s ease;
}

.stats-drawer--open {
  max-height: 240px;
}

/* Client avatar in topbar */
.topbar-avatar-wrap {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: 1.5px solid rgba(255,255,255,0.4);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  margin-right: 0.4rem;
}

/* Live clock wrap in topbar */
.topbar-clock-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.1rem;
  flex-shrink: 0;
  margin-right: 0.5rem;
}

/* Hamburger menu: section header + toggle rows */
.hmenu-section {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6b7c8c;
  padding: 0.6rem 0.85rem 0.3rem;
  border-top: 1px solid #e3e8ee;
  background: #fafbfd;
}
.hmenu-toggle { cursor: pointer; }
.hmenu-toggle-input {
  margin-left: auto;
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #014a64;
}

/* Live clock in topbar */
.topbar-clock {
  font-size: 1.2rem;
  color: rgba(255,255,255,0.7);
  text-align: right;
  flex-shrink: 0;
  white-space: nowrap;
  line-height: 1.3;
  margin-right: 0.5rem;
}

/* AI Report button inside stats grid */
.stat-ai-btn {
  margin-top: 0.15rem;
  padding: 0.2rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 700;
  color: #fff;
  background: rgba(204,91,142,0.55);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.stat-ai-btn:hover { background: rgba(204,91,142,0.85); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  padding: 0.6rem 1rem 0.8rem;
}

.stat-item {
  padding: 0.35rem 0.5rem;
  border-right: 1px solid rgba(255,255,255,0.07);
}

.stat-item:nth-child(3n) {
  border-right: none;
}

.stat-label {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.45);
  margin-bottom: 0.2rem;
}

.stat-value {
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.stat-sub {
  font-size: 0.62rem;
  color: rgba(255,255,255,0.4);
  margin-top: 0.1rem;
}

.chat-thread {
  flex: 1 1 0;
  /* min-height:0 is required: without it, a flex item defaults to
     min-height:auto and refuses to shrink below its content size,
     which lets a long thread overflow the body and force the whole
     page to scroll instead of just the message list. */
  min-height: 0;
  overflow-y: auto;
  /* `none` (not `contain`) is required on iOS: `contain` still allows
     the bounce animation to render before being clipped, which the
     user perceives as the header sliding. `none` kills the bounce
     entirely so the topbar is rock-solid. */
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  padding: 1rem;
  padding-left:  max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
}

/* Push messages to the bottom when there are few of them */
#chat-messages {
  margin-top: auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.chat-loading {
  display: flex;
  justify-content: center;
  padding: 2rem 0;
}

.chat-empty {
  text-align: center;
  color: var(--color-muted);
  font-size: 0.9rem;
  padding: 3rem 1rem;
}

/* ── Message bubbles ── */
.msg-wrap {
  display: flex;
  flex-direction: column;
  max-width: 78%;
  gap: 0.2rem;
}

.msg-wrap--rmt {
  align-self: flex-end;
  align-items: flex-end;
}

.msg-wrap--client {
  align-self: flex-start;
  align-items: flex-start;
}

.msg-bubble {
  padding: 0.6rem 0.9rem;
  border-radius: 18px;
  font-size: 0.95rem;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
}

.msg-bubble--rmt {
  background: var(--color-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 6px rgba(204, 91, 142, 0.25);
}

.msg-bubble--client {
  background: #189dad;
  color: #ffffff;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 6px rgba(125, 200, 209, 0.3);
}

.msg-time {
  font-size: 0.68rem;
  color: var(--color-muted);
  padding: 0 0.35rem;
}

/* ── Input bar ── */
.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  padding-left:  max(0.75rem, env(safe-area-inset-left));
  padding-right: max(0.75rem, env(safe-area-inset-right));
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 0.6rem 0.9rem;
  border: 1.5px solid var(--color-border);
  border-radius: 22px;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--color-text);
  background: #f4f7fb;
  resize: none;
  outline: none;
  transition: border-color var(--transition);
}

.chat-input:focus {
  border-color: var(--color-primary);
  background: #fff;
}

.chat-attach-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: none;
  color: var(--color-muted);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: color var(--transition), transform var(--transition);
  touch-action: manipulation;
}
.chat-attach-btn:hover  { color: var(--color-primary); }
.chat-attach-btn:active { transform: scale(0.93); }
.chat-attach-btn:disabled { opacity: 0.4; }

.chat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}

.chat-send-btn:hover  { background: var(--color-primary-dk); }
.chat-send-btn:active { transform: scale(0.93); }
.chat-send-btn:disabled { opacity: 0.45; }

/* Image bubbles */
.msg-bubble--image {
  padding: 6px 6px 8px;
}
.msg-image-caption {
  font-size: 0.88rem;
  line-height: 1.35;
  margin: 6px 2px 0;
  padding: 0;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-bubble--rmt .msg-image-caption  { color: #fff; }
.msg-bubble--client .msg-image-caption { color: #fff; }

.msg-image {
  max-width: 220px;
  max-height: 220px;
  border-radius: 12px;
  display: block;
  cursor: pointer;
  object-fit: cover;
}

/* ── Image staging bar ── */
.img-stage {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--color-surface, #fff);
  border-top: 1px solid var(--color-border, #e8e8e8);
  box-shadow: 0 -2px 12px rgba(0,0,0,0.07);
}
.img-stage-thumb {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--color-border, #e0e0e0);
}
.img-stage-cancel {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--color-muted, #aaa);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: background 0.15s;
}
.img-stage-cancel:hover { background: #e74c3c; }
.msg-bubble--uploading {
  background: rgba(204,91,142,0.15);
  color: var(--color-muted);
  font-size: 0.85rem;
  font-style: italic;
}

/* ===== AI REVIEW ===== */

.ai-review-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.18);
  border: 1.5px solid rgba(255,255,255,0.5);
  color: #fff;
  border-radius: 20px;
  padding: 5px 11px 5px 8px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), transform var(--transition);
  touch-action: manipulation;
}
.ai-review-btn:hover  { background: rgba(255,255,255,0.28); }
.ai-review-btn:active { transform: scale(0.94); }

.ai-panel {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
}
.ai-panel-card {
  background: var(--color-surface);
  border-radius: 0 0 20px 20px;
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 4px 32px rgba(0,0,0,0.18);
}
.ai-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
}
.ai-panel-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
}
.ai-panel-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  color: var(--color-muted);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}
.ai-panel-body {
  padding: 1.1rem 1.25rem 1.5rem;
  overflow-y: auto;
  flex: 1;
}
.ai-panel-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 2rem 0;
  color: var(--color-muted);
  font-size: 0.9rem;
}
.ai-intent-box {
  background: #fff8f0;
  border-left: 4px solid #e8844a;
  border-radius: 0 8px 8px 0;
  padding: 0.75rem 1rem;
  margin-bottom: 1.1rem;
  font-size: 0.9rem;
  color: var(--color-text);
  line-height: 1.5;
}
.ai-intent-box.safe    { border-color: #27ae60; background: #f0faf3; }
.ai-intent-box.caution { border-color: #e8844a; background: #fff8f0; }
.ai-intent-box.warning { border-color: #e74c3c; background: #fff3f3; }
.ai-intent-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.35rem;
  opacity: 0.7;
}
.ai-suggestions-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-muted);
  margin-bottom: 0.6rem;
}
.ai-suggestion {
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.55rem;
  font-size: 0.88rem;
  color: var(--color-text);
  line-height: 1.45;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: border-color var(--transition), background var(--transition);
}
.ai-suggestion:hover  { border-color: var(--color-primary); background: #fdf0f6; }
.ai-suggestion:active { background: #f8e0ee; }
.ai-error {
  color: #e74c3c;
  font-size: 0.88rem;
  text-align: center;
  padding: 1.5rem 0;
}

/* ── Sentiment Report ── */
.ai-score-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.ai-score-ring {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
}

.ai-score-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.ai-score-num {
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1;
}

.ai-score-sub {
  font-size: 0.62rem;
  color: var(--color-muted);
  font-weight: 500;
}

.ai-score-meta {
  flex: 1;
  min-width: 0;
}

.ai-level-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  margin-bottom: 0.45rem;
}

.ai-level-badge.safe    { background: #f0faf3; color: #27ae60; }
.ai-level-badge.caution { background: #fff8f0; color: #e8844a; }
.ai-level-badge.warning { background: #fff3f3; color: #e74c3c; }

.ai-sentiment-text {
  font-size: 0.85rem;
  color: var(--color-text);
  line-height: 1.5;
  margin: 0;
}

.ai-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
  margin-bottom: 0.55rem;
}

.ai-obs-list {
  margin: 0 0 1rem;
  padding: 0 0 0 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.ai-obs-item {
  font-size: 0.85rem;
  color: var(--color-text);
  line-height: 1.5;
}

.ai-advice-box {
  background: #f0f7ff;
  border-left: 4px solid #3d8bcd;
  border-radius: 0 10px 10px 0;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
}

.ai-advice-text {
  font-size: 0.87rem;
  color: var(--color-text);
  line-height: 1.55;
  margin: 0;
}

/* ===== RESPONSIVE BREAKPOINTS ===== */

/* Small phones (< 360px) */
@media (max-width: 360px) {
  .topbar-user { display: none; }
  .profile-card { padding: 1.1rem; }
  .data-table { font-size: 0.8rem; }
}

/* All mobile (< 640px) */
@media (max-width: 640px) {
  .detail-row {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }
  .detail-label {
    font-size: 0.72rem;
    color: var(--color-primary);
  }
  .profile-card {
    padding: 1.25rem;
    border-radius: var(--radius-md);
  }
  body:not(.page-full) {
    padding: 1rem;
    padding-top:    max(1rem, env(safe-area-inset-top));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    padding-left:   max(1rem, env(safe-area-inset-left));
    padding-right:  max(1rem, env(safe-area-inset-right));
  }
}

/* ── Voicemail topbar button ── */
.voicemail-topbar-btn {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 8px;
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  padding: 0.28rem 0.55rem;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.voicemail-topbar-btn:hover { background: rgba(255,255,255,0.28); }

/* ── Voicemail modal overlay ── */
.vm-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.vm-modal {
  background: #fff;
  border-radius: 18px;
  padding: 1.75rem 1.5rem 1.25rem;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}

.vm-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: #1a0d14;
  text-align: center;
}

.vm-info {
  margin: 0;
  font-size: 0.75rem;
  color: #cc5b8e;
  text-align: center;
  font-weight: 600;
  letter-spacing: 0.02em;
  min-height: 1em;
}

.vm-status {
  margin: 0;
  font-size: 0.85rem;
  color: #666;
  text-align: center;
  min-height: 1.2em;
}

.vm-timer {
  font-size: 1.6rem;
  font-weight: 700;
  color: #cc5b8e;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
  min-height: 2rem;
  line-height: 1;
}

/* Big mic button */
.vm-record-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #cc5b8e;
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 4px 16px rgba(204,91,142,0.4);
  flex-shrink: 0;
}
.vm-record-btn:hover { background: #b84d7e; }
.vm-record-btn:active { transform: scale(0.94); }

/* Pulsing red when recording */
.vm-record-btn--active {
  background: #e03030;
  box-shadow: 0 4px 16px rgba(224,48,48,0.45);
  animation: vm-pulse 1.2s ease-in-out infinite;
}
@keyframes vm-pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(224,48,48,0.45); }
  50%       { box-shadow: 0 4px 28px rgba(224,48,48,0.75), 0 0 0 10px rgba(224,48,48,0.12); }
}

.vm-controls {
  display: flex;
  gap: 0.75rem;
  width: 100%;
  margin-top: 0.25rem;
}
.vm-controls .btn { flex: 1; }

.vm-cancel-btn {
  background: none;
  border: none;
  color: #999;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  margin-top: 0.1rem;
}
.vm-cancel-btn:hover { color: #555; }

/* ── Brand footer (logo) ── */
.brand-footer {
  text-align: center;
  padding: 1.5rem 1rem calc(1.5rem + var(--safe-bottom));
  background: transparent;
}
.brand-footer-logo {
  display: block;
  margin: 0 auto;
  width: clamp(120px, 40vw, 260px);
  height: auto;
  max-height: 20vw;
  object-fit: contain;
  opacity: 0.85;
}

/* Tablet and up (≥ 768px) */
@media (min-width: 768px) {
  .page-main {
    padding: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
  }
  .topbar-user { max-width: 240px; }
  .data-table { font-size: 0.9rem; }
  body:not(.page-full) {
    padding: 2rem;
  }
}

/* Large screens (≥ 1024px) */
@media (min-width: 1024px) {
  .page-main {
    padding: 2rem 2.5rem;
  }
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0,0,0,0.22);
  padding: 1.5rem;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: -0.25rem;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}

.btn-delete-chat {
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  background: #c0392b;
  border: none;
  border-radius: 6px;
  padding: 0.3rem 0.65rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-delete-chat:hover { background: #a93226; }
.btn-delete-chat:disabled { opacity: 0.6; cursor: not-allowed; }

.modal-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: -0.5rem;
}

.modal-input {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  color: var(--color-text);
  background: #f4f7fb;
  box-sizing: border-box;
  min-height: 48px;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
}

.modal-textarea {
  min-height: 72px;
  resize: vertical;
  line-height: 1.5;
}

.notes-history {
  max-height: 140px;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  font-size: 0.78rem;
  color: #111;
}
.notes-entry {
  display: flex;
  flex-direction: column;
  padding: 0.3rem 0;
  border-bottom: 1px solid #e8e8e8;
}
.notes-entry:last-child { border-bottom: none; }
.notes-ts {
  font-size: 0.67rem;
  color: #888;
  margin-bottom: 1px;
}
.notes-text {
  color: #111;
  line-height: 1.4;
  white-space: pre-wrap;
}
.notes-empty {
  color: #aaa;
  font-style: italic;
}
.modal-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(204, 91, 142, 0.15);
  background: #fff;
}

.modal-error {
  font-size: 0.82rem;
  color: #c0392b;
  margin: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.65rem;
}

/* convo-avatar cursor hint */
.convo-avatar {
  cursor: pointer;
}
.convo-avatar:hover {
  filter: brightness(1.12);
}

/* ===== BEHAVIOUR SCORE ===== */

.page-chat {
  --topbar-height: 80px;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.score-track {
  flex: 1;
  height: 5px;
  background: rgba(255,255,255,0.25);
  border-radius: 3px;
  overflow: hidden;
  max-width: 130px;
}

.score-fill {
  height: 100%;
  width: 100%;
  border-radius: 3px;
  background: rgba(255,255,255,0.92);
  transition: width 0.6s ease, background 0.6s ease;
}

.score-num {
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  min-width: 20px;
  text-align: right;
}

/* ===== CAUTION FLAG ===== */

.msg-bubble--client {
  position: relative;
}

.caution-flag {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 22px;
  height: 22px;
  background: #f5c518;
  border: 2px solid #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  z-index: 10;
  padding: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.22);
  transition: transform 0.15s;
  touch-action: manipulation;
}

.caution-flag:hover,
.caution-flag:active { transform: scale(1.25); }

@keyframes bubblePulse {
  0%   { box-shadow: 0 2px 6px rgba(125,200,209,0.3); }
  20%  { box-shadow: 0 0 0 6px rgba(245,197,24,0.35); }
  40%  { box-shadow: 0 2px 6px rgba(125,200,209,0.3); }
  60%  { box-shadow: 0 0 0 6px rgba(245,197,24,0.35); }
  80%  { box-shadow: 0 2px 6px rgba(125,200,209,0.3); }
  100% { box-shadow: 0 2px 6px rgba(125,200,209,0.3); }
}

.msg-bubble--pulse {
  animation: bubblePulse 1.4s ease forwards;
}

/* ===== FLAG TOOLTIP ===== */

.flag-tooltip {
  position: fixed;
  z-index: 900;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 6px 28px rgba(0,0,0,0.18);
  padding: 14px 16px 12px;
  max-width: min(320px, calc(100vw - 32px));
  display: none;
}

.flag-tooltip.is-visible { display: block; }

.flag-tooltip-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 9px;
}

.flag-tooltip-badge--mild     { background: #fff8e1; color: #f9a825; }
.flag-tooltip-badge--moderate { background: #fff3e0; color: #ef6c00; }
.flag-tooltip-badge--severe   { background: #fce4ec; color: #c62828; }
.flag-tooltip-badge--critical { background: #b71c1c; color: #fff; }

.flag-tooltip-explanation {
  font-size: 0.83rem;
  color: #333;
  line-height: 1.5;
  margin: 0 0 10px;
}

.flag-tooltip-reply-btn {
  display: block;
  width: 100%;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 0.82rem;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  line-height: 1.4;
  transition: opacity 0.15s;
  touch-action: manipulation;
}

.flag-tooltip-reply-btn:hover { opacity: 0.88; }

.flag-tooltip-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1rem;
  color: #999;
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
}

/* ── Tolerance field in Edit Client modal ── */
.tolerance-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.tolerance-value-badge {
  background: var(--color-primary, #cc5b8e);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tolerance-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* Range slider track */
.tolerance-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(
    to right,
    var(--color-primary, #cc5b8e) 0%,
    var(--color-primary, #cc5b8e) calc((var(--val, 5) - 1) / 9 * 100%),
    #e0e0e0 calc((var(--val, 5) - 1) / 9 * 100%),
    #e0e0e0 100%
  );
  outline: none;
  cursor: pointer;
  margin: 4px 0;
}
.tolerance-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-primary, #cc5b8e);
  border: 3px solid #fff;
  box-shadow: 0 1px 5px rgba(0,0,0,0.25);
  cursor: grab;
  transition: transform 0.1s;
}
.tolerance-slider::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.15); }
.tolerance-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-primary, #cc5b8e);
  border: 3px solid #fff;
  box-shadow: 0 1px 5px rgba(0,0,0,0.25);
  cursor: grab;
}

.tolerance-hints {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--color-muted);
  line-height: 1.3;
}

/* ── Tolerance note in flag tooltip ── */
.flag-tolerance-note {
  font-size: 0.72rem;
  color: var(--color-muted);
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--color-border);
  line-height: 1.4;
}

/* ===== CLIENT AVATAR PHOTO ===== */
.convo-avatar .avatar-photo {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

/* ===== IMAGE CONTEXT MENU ===== */
/* Reply bar */
.reply-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 10px;
  background: #ffffff;
  border-top: 2px solid var(--color-primary, #cc5b8e);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
  flex-shrink: 0;
}
.reply-bar-content {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
  min-width: 0;
  border-left: 3px solid var(--color-primary, #cc5b8e);
  padding-left: 10px;
  border-radius: 2px;
  gap: 1px;
}
.reply-bar-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--color-primary, #cc5b8e);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.reply-bar-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #333;
  font-size: 0.84rem;
  line-height: 1.3;
}
.reply-bar-close {
  background: none;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
  color: #888;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.reply-bar-close:hover { background: rgba(204,91,142,0.1); color: var(--color-primary, #cc5b8e); }

/* Reply quote inside bubble */
.msg-reply-quote {
  font-size: 0.81rem;
  font-style: italic;
  padding: 6px 8px;
  margin-bottom: 6px;
  border-left: 3px solid rgba(255,255,255,0.55);
  background: rgba(0,0,0,0.15);
  border-radius: 6px;
  color: rgba(255,255,255,0.88);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.35;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.msg-reply-quote:hover { background: rgba(0,0,0,0.22); }
.msg-reply-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}
.reply-bar-thumb {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}
@keyframes highlight-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(204,91,142,0); }
  40%       { box-shadow: 0 0 0 6px rgba(204,91,142,0.55); }
}
.msg-wrap--highlight { animation: highlight-pulse 0.6s ease-out 2; }
.msg-reply-body {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}

/* Context menu separator */
.ctx-sep {
  margin: 0;
  border: none;
  border-top: 1px solid var(--color-border, #e8e8e8);
}

.img-ctx-menu {
  position: fixed;
  z-index: 9999;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border, #e0e0e0);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.18);
  overflow: hidden;
  min-width: 190px;
}

.img-ctx-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  background: none;
  border: none;
  font-size: 0.93rem;
  color: var(--color-text, #1a1a1a);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}

.img-ctx-menu button:hover {
  background: var(--color-hover, rgba(0,0,0,0.06));
}

/* ===== AUDIO PLAYER BUBBLE ===== */
.msg-bubble--audio {
  background: transparent;
  padding: 4px 0;
  box-shadow: none;
}
.msg-bubble--rmt.msg-bubble--audio .audio-player-wrap {
  background: var(--bubble-rmt, #4a90d9);
}
.msg-bubble--client.msg-bubble--audio .audio-player-wrap,
.msg-bubble--left.msg-bubble--audio  .audio-player-wrap {
  background: var(--bubble-client, #fff);
  border: 1px solid rgba(0,0,0,0.1);
}
.audio-player-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 18px;
  min-width: 220px;
  max-width: 300px;
}
.audio-player-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  line-height: 1;
}
.audio-player-ctrl {
  flex: 1;
  height: 32px;
  min-width: 0;
  accent-color: #fff;
}
.msg-bubble--client .audio-player-ctrl,
.msg-bubble--left  .audio-player-ctrl {
  accent-color: var(--color-primary, #4a90d9);
}
.audio-dl-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  color: inherit;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  transition: background 0.15s;
}
.audio-dl-btn:hover {
  background: rgba(255,255,255,0.45);
}
.audio-dl-fallback {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,0.2);
  color: inherit;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}
.audio-dl-fallback:hover {
  background: rgba(255,255,255,0.35);
  text-decoration: underline;
}

/* ===== AVATAR SAVE TOAST ===== */
.avatar-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: #1a1a2e;
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 24px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  white-space: nowrap;
  z-index: 10000;
}

.avatar-toast--show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== TRAINING BUTTON & PLAYER ===== */
.topbar-logout-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 1.15rem;
  line-height: 1;
  padding: 0.25rem 0.4rem;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.topbar-logout-btn svg { display: block; }
.topbar-logout-btn:hover { color: #fff; background: rgba(255,255,255,0.15); }

.training-topbar-btn {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 8px;
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  padding: 0.28rem 0.55rem;
  cursor: pointer;
  flex-shrink: 0;
}
.training-topbar-btn:hover  { background: rgba(255,255,255,0.28); }
.training-topbar-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* filter-topbar-btn is now inside the hamburger menu — reset its topbar styles */
.filter-topbar-btn {
  background: transparent;
  border: none;
  border-radius: 0;
  color: inherit;
  line-height: inherit;
  padding: 0;
  font-size: inherit;
  font-weight: inherit;
}
.filter-topbar-btn:hover { background: transparent; }
.filter-topbar-btn.active { background: transparent; border-color: transparent; box-shadow: none; }

/* ── Hamburger button ── */
.hamburger-topbar-btn {
  position: relative;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 8px;
  color: #fff;
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 36px;
  height: 34px;
  transition: background 0.15s;
}
.hamburger-topbar-btn span {
  display: block;
  width: 16px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: opacity 0.15s;
}
.hamburger-topbar-btn:hover { background: rgba(255,255,255,0.28); }
.hamburger-topbar-btn.open { background: rgba(255,255,255,0.28); }
/* Dot indicator when filter is active */
.hamburger-topbar-btn.filter-on::after {
  content: '';
  position: absolute;
  top: 5px; right: 5px;
  width: 7px; height: 7px;
  background: #f5c542;
  border-radius: 50%;
  border: 1.5px solid rgba(1,74,100,0.7);
}

/* ── Hamburger dropdown menu ── */
.hamburger-menu {
  position: fixed;
  top: calc(var(--topbar-height, 56px) + env(safe-area-inset-top, 0px) + 6px);
  left: 10px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 6px 28px rgba(0,0,0,0.18);
  z-index: 400;
  min-width: 220px;
  overflow: hidden;
  transform-origin: top left;
  transform: scale(0.92);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.18s cubic-bezier(0.34,1.56,0.64,1), opacity 0.15s ease;
}
.hamburger-menu.open {
  transform: scale(1);
  opacity: 1;
  pointer-events: auto;
}
.hmenu-item {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  width: 100%;
  padding: 0.85rem 1.1rem;
  border: none;
  border-bottom: 1px solid #f0f3f7;
  background: transparent;
  text-align: left;
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  color: #1a1a2e;
  text-decoration: none;
  transition: background 0.1s;
}
.hmenu-item:last-child { border-bottom: none; }
.hmenu-item:hover, .hmenu-item:focus { background: #f5f8ff; outline: none; }
.hmenu-item .hmenu-icon { font-size: 1.05rem; flex-shrink: 0; width: 20px; text-align: center; }
.hmenu-item svg.hmenu-icon { color: #014a64; }
.hmenu-filter-badge {
  margin-left: auto;
  background: #014a64;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 20px;
  letter-spacing: 0.05em;
}

.date-filter-panel {
  position: fixed;
  top: calc(var(--topbar-height, 56px) + env(safe-area-inset-top, 0px) + 6px);
  left: 12px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.16);
  padding: 1rem 1.1rem 0.85rem;
  z-index: 300;
  min-width: 210px;
  display: none;
}
.date-filter-panel.open { display: block; }

.date-filter-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: #cc5b8e;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.8rem;
}
.date-filter-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}
.date-filter-row label {
  font-size: 0.8rem;
  color: #555;
  white-space: nowrap;
  flex: 1;
}
.date-filter-row input[type=number] {
  width: 52px;
  padding: 0.28rem 0.4rem;
  border: 1.5px solid #e0c8d8;
  border-radius: 6px;
  font-size: 0.85rem;
  text-align: center;
  outline: none;
  flex-shrink: 0;
}
.date-filter-row input[type=number]:focus { border-color: #cc5b8e; }
.date-filter-unit {
  font-size: 0.78rem;
  color: #aaa;
  flex-shrink: 0;
}
.date-filter-clear {
  margin-top: 0.65rem;
  width: 100%;
  padding: 0.38rem;
  background: #f8edf4;
  color: #cc5b8e;
  border: 1px solid #e8c8d8;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}
.date-filter-clear:hover { background: #f0d8e8; }

.training-player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 1rem;
  padding-bottom: max(0.55rem, env(safe-area-inset-bottom));
  background: #1a1a2e;
  color: #fff;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.3);
}
.training-label {
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  color: rgba(255,255,255,0.85);
}
.training-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 0.9rem;
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.training-btn:hover { background: rgba(255,255,255,0.28); }
/* ── Custom pointer-capture scrubber (works in nested iframes) ── */
.training-scrubber-track {
  flex: 1;
  height: 18px;
  position: relative;
  display: flex;
  align-items: center;
  cursor: pointer;
  touch-action: none;   /* prevents scroll hijack on touch */
  user-select: none;
  -webkit-user-select: none;
}
.training-scrubber-track::before {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  height: 6px;
  background: rgba(255,255,255,0.22);
  border-radius: 3px;
}
.training-scrubber-fill {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 6px;
  width: 0%;
  background: #cc5b8e;
  border-radius: 3px;
  pointer-events: none;
}
.training-scrubber-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 5px rgba(0,0,0,0.4);
  pointer-events: none;
  transition: transform 0.1s;
}
.training-scrubber-track:active .training-scrubber-thumb,
.training-scrubber-track.dragging .training-scrubber-thumb {
  transform: translate(-50%, -50%) scale(1.25);
  cursor: grabbing;
}
.training-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  background: rgba(20,20,40,0.92);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  padding: 0.3rem 0.65rem;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}
.training-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(20,20,40,0.92);
}
.training-progress-wrap:hover .training-tooltip,
.training-progress-wrap.dragging .training-tooltip { opacity: 1; }
.training-time {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.65);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 2.8rem;
  text-align: right;
}
.training-stop {
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0 0.2rem;
}
.training-stop:hover { color: #fff; }

/* ===== TOLERANCE HELP BUTTON & POPUP ===== */
.tol-help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  margin-left: 6px;
  border-radius: 50%;
  border: 1.5px solid var(--color-pink, #e91e8c);
  background: transparent;
  color: var(--color-pink, #e91e8c);
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
  transition: background 0.15s, color 0.15s;
  padding: 0;
}
.tol-help-btn:hover {
  background: var(--color-pink, #e91e8c);
  color: #fff;
}

.tol-help-overlay {
  position: fixed;
  inset: 0;
  z-index: 12000;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.tol-help-card {
  background: #1e1030;
  border: 1px solid #3d2a55;
  border-radius: 16px;
  padding: 1.25rem 1.25rem 1rem;
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 12px 48px rgba(0,0,0,0.65);
}
.tol-help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.tol-help-title {
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
}
.tol-help-close {
  background: none;
  border: none;
  color: #b89ec8;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  transition: color 0.15s;
}
.tol-help-close:hover { color: #ffffff; }

.tol-help-intro {
  font-size: 0.8rem;
  color: #b89ec8;
  margin: 0 0 0.85rem;
}
.tol-help-levels {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}
.tol-help-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 10px;
  border-left: 3px solid transparent;
}
.tol-help-row--off      { background: rgba(180,180,180,0.12); border-left-color: #888; }
.tol-help-row--critical { background: rgba(220,38,38,0.18);   border-left-color: #dc2626; }
.tol-help-row--severe   { background: rgba(234,88,12,0.18);   border-left-color: #ea580c; }
.tol-help-row--moderate { background: rgba(217,119,6,0.18);   border-left-color: #d97706; }
.tol-help-row--mild     { background: rgba(22,163,74,0.15);   border-left-color: #16a34a; }

.tol-help-badge {
  flex-shrink: 0;
  min-width: 38px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #ffffff;
  background: rgba(255,255,255,0.15);
  border-radius: 6px;
  padding: 2px 5px;
  margin-top: 1px;
}
.tol-help-detail {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tol-help-detail strong {
  font-size: 0.82rem;
  color: #f0e6ff;
}
.tol-help-detail span {
  font-size: 0.76rem;
  color: #c8b4d8;
  line-height: 1.4;
}
.tol-help-detail em {
  font-size: 0.72rem;
  color: #b89ec8;
  font-style: normal;
  opacity: 0.9;
}
.tol-help-note {
  font-size: 0.74rem;
  color: #b89ec8;
  margin: 0.85rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid #3d2a55;
  line-height: 1.5;
}

/* ── Attach popup menu ── */
.attach-menu {
  position: fixed;
  bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 6px);
  left: 0.75rem;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 6px 28px rgba(0,0,0,0.18), 0 1px 4px rgba(0,0,0,0.1);
  z-index: 450;
  padding: 0.35rem 0;
  min-width: 190px;
  overflow: hidden;
  animation: attachMenuIn 0.15s ease;
}
@keyframes attachMenuIn {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.attach-menu-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.72rem 1.1rem;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: #222;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.attach-menu-item svg { flex-shrink: 0; color: #cc5b8e; }
.attach-menu-item:hover,
.attach-menu-item:active { background: #f5f0f8; }
.attach-menu-item + .attach-menu-item { border-top: 1px solid #f3f3f3; }

/* ── Shared modal close button ── */
.modal-x-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  line-height: 1;
  color: #aaa;
  cursor: pointer;
  padding: 0.2rem 0.3rem;
  border-radius: 6px;
  transition: color 0.1s, background 0.1s;
}
.modal-x-btn:hover { color: #555; background: #f0f0f0; }

/* ── Delete Confirmation modal ── */
.modal-confirm-card {
  max-width: 320px;
  text-align: center;
  gap: 0.75rem;
}
.modal-confirm-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #fdecea;
  margin: 0 auto 0.25rem;
}
.modal-confirm-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text);
}
.modal-confirm-body {
  margin: 0;
  font-size: 0.875rem;
  color: var(--color-muted);
  line-height: 1.5;
}
.modal-confirm-actions {
  display: flex;
  gap: 0.625rem;
  margin-top: 0.25rem;
}
.modal-confirm-actions .btn {
  flex: 1;
  justify-content: center;
}
.modal-confirm-danger-btn {
  background: #c0392b;
  border: none;
  color: #fff;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  cursor: pointer;
  transition: background 0.15s;
}
.modal-confirm-danger-btn:hover:not(:disabled) { background: #a93226; }
.modal-confirm-danger-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Canned Responses modal ── */
.canned-card {
  max-width: 360px;
  width: 94vw;
  gap: 0;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 88vh;
}
.canned-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.25rem 0.85rem;
  border-bottom: 1px solid #eef0f3;
  flex-shrink: 0;
}
.canned-search-row {
  padding: 0.55rem 1rem;
  border-bottom: 1px solid #eef0f3;
  flex-shrink: 0;
}
.canned-search {
  width: 100%;
  box-sizing: border-box;
  border: 1.5px solid #dde0e5;
  border-radius: 8px;
  padding: 0.4rem 0.7rem;
  font-size: 0.83rem;
  font-family: inherit;
  outline: none;
  background: #fafbfd;
  color: #333;
  transition: border-color 0.15s;
}
.canned-search:focus { border-color: #cc5b8e; background: #fff; }
.canned-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  min-height: 0;
}
.canned-row {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid #f0f0f0;
}
.canned-row:last-child { border-bottom: none; }
.canned-option {
  flex: 1;
  text-align: left;
  background: none;
  border: none;
  padding: 0.65rem 1rem;
  font-family: inherit;
  font-size: 0.83rem;
  color: #333;
  cursor: pointer;
  line-height: 1.45;
  transition: background 0.12s, color 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.canned-option:hover,
.canned-option:active { background: #fdf4f9; color: #cc5b8e; }
.canned-del-btn {
  background: none;
  border: none;
  border-left: 1px solid #f0f0f0;
  padding: 0 0.75rem;
  color: #ccc;
  cursor: pointer;
  font-size: 0.8rem;
  flex-shrink: 0;
  transition: color 0.12s, background 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.canned-del-btn:hover { color: #e74c3c; background: #fff5f5; }
.canned-del-btn:disabled { opacity: 0.4; cursor: default; }
.canned-empty {
  padding: 1.2rem 1rem;
  color: #bbb;
  font-size: 0.82rem;
  font-style: italic;
  text-align: center;
  margin: 0;
}
.canned-add-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.7rem 1rem;
  border-top: 1.5px solid #eef0f3;
  background: #fafbfd;
  flex-shrink: 0;
}
.canned-new-text {
  flex: 1;
  border: 1.5px solid #dde0e5;
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
  font-size: 0.82rem;
  font-family: inherit;
  resize: none;
  outline: none;
  line-height: 1.4;
  transition: border-color 0.15s;
  background: #fff;
  color: #333;
}
.canned-new-text:focus { border-color: #cc5b8e; }
.canned-add-btn {
  background: #cc5b8e;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.canned-add-btn:hover { background: #b8487a; }
.canned-add-btn:disabled { opacity: 0.55; cursor: default; }

/* ── Rates modal rows ── */
.rates-category {
  padding: 0.6rem 1.25rem;
  border-bottom: 1px solid #f3f3f3;
}
.rates-category:last-child { border-bottom: none; }
.rates-cat-name {
  font-size: 0.72rem;
  font-weight: 700;
  color: #014a64;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.35rem;
}
.rates-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0;
  font-size: 0.87rem;
  gap: 0.5rem;
}
.rates-item-name  { color: #444; flex: 1; }
.rates-item-price { font-weight: 700; color: #222; white-space: nowrap; }

/* ── Manager assume bar ── */
.rmt-assume-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.38rem max(1rem, env(safe-area-inset-left, 1rem));
  background: #0a3a50;
  color: rgba(255,255,255,0.9);
  font-size: 0.74rem;
  font-weight: 600;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.rmt-assume-label {
  opacity: 0.65;
  white-space: nowrap;
  flex-shrink: 0;
}
.rmt-assume-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
}
.rmt-assume-exit {
  margin-left: auto;
  flex-shrink: 0;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.18rem 0.55rem;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,0.18);
  white-space: nowrap;
  transition: background 0.12s, color 0.12s;
}
.rmt-assume-exit:hover { background: rgba(255,255,255,0.12); color: #fff; }

/* ── House-icon info tooltip ── */
.topbar-back--tip {
  position: relative;
}
.topbar-back--tip::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: rgba(20, 20, 30, 0.88);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.15s, transform 0.15s;
  z-index: 600;
  font-family: 'SF Mono', 'Fira Mono', monospace;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
.topbar-back--tip:hover::after,
.topbar-back--tip:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

/* ── Topbar info hover tooltip ── */
.chat-topbar-info {
  position: relative;
  cursor: default;
}
.chat-topbar-info::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: rgba(20, 20, 30, 0.88);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 500;
  white-space: pre;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.15s, transform 0.15s;
  z-index: 600;
  font-family: 'SF Mono', 'Fira Mono', monospace;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}
.chat-topbar-info:hover::after {
  opacity: 1;
  transform: translateY(0);
}

/* ── Book Now — Calendar ── */
/* ── Availability calendar ─────────────────────────────────────────────── */
.avail-cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 1rem 0.25rem;
}
.avail-cal-month {
  font-size: 1rem;
  font-weight: 700;
  color: #1a1a2e;
}
.avail-nav-btn {
  background: none;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  color: #555;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}
.avail-nav-btn:hover { background: #f3f4f6; }
.avail-dow-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 0 0.75rem;
  margin-bottom: 0.15rem;
}
.avail-dow-row span {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #aaa;
  text-transform: uppercase;
  padding: 0.2rem 0;
}
.avail-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  padding: 0 0.75rem 0.75rem;
}
.avail-day-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: background 0.1s, color 0.1s;
  color: #222;
}
.avail-day-cell.avail-empty { cursor: default; }
.avail-day-cell.is-past     { color: #ccc; cursor: default; }
.avail-day-cell.is-today    { font-weight: 800; color: #014a64; }
.avail-day-cell:not(.is-past):not(.avail-empty):not(.is-blocked):hover { background: #fee2e2; }
/* Newly selected (pending save) */
.avail-day-cell.is-sel {
  background: #ef4444;
  color: #fff;
  font-weight: 700;
}
.avail-day-cell.is-sel:hover { background: #dc2626; }
/* Already saved — full day blocked */
.avail-day-cell.is-blocked {
  background: #b91c1c;
  color: #fff;
  font-weight: 700;
  cursor: default;
}
.avail-day-cell.is-blocked:hover { background: #991b1b; cursor: pointer; }
/* Already saved — specific time slots blocked */
.avail-day-cell.is-partial {
  background: #fef08a;
  color: #713f12;
  font-weight: 600;
}
.avail-day-cell.is-partial:hover { background: #fde047; }
.avail-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem 0.9rem;
  border-top: 1px solid #eef0f3;
}
.avail-sel-count {
  font-size: 0.8rem;
  font-weight: 600;
  color: #666;
}

/* ── Book calendar ─────────────────────────────────────────────────────── */
.book-cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}
.book-cal-month-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1a1a2e;
}
.book-cal-nav-btn {
  background: none;
  border: none;
  font-size: 1.35rem;
  color: #cc5b8e;
  cursor: pointer;
  padding: 0.15rem 0.45rem;
  border-radius: 8px;
  line-height: 1;
  transition: background 0.12s;
}
.book-cal-nav-btn:hover { background: #fdf4f9; }

.book-cal-dow-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.3rem;
}
.book-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.book-cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: none;
  font-family: inherit;
  font-size: 0.82rem;
  color: #222;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  -webkit-tap-highlight-color: transparent;
  min-width: 0;
  padding: 0;
}
.book-cal-day:hover:not(:disabled) { background: #fdf4f9; color: #cc5b8e; }
.book-cal-day.today {
  background: #f3d8ea;
  font-weight: 700;
  color: #cc5b8e;
}
.book-cal-day.past {
  color: #ccc;
  cursor: default;
}
.book-cal-day.book-cal-empty {
  pointer-events: none;
}
.book-cal-day.day-full-blocked {
  background: #ef4444;
  color: #fff;
  cursor: not-allowed;
  opacity: 0.85;
  flex-direction: column;
  gap: 1px;
}
.book-cal-day.day-full-blocked:hover { background: #ef4444; color: #fff; }
.book-cal-day.day-partial-blocked {
  background: #fef08a;
  color: #713f12;
  flex-direction: column;
  gap: 1px;
}
.book-cal-day.day-partial-blocked:hover { background: #fde047; color: #713f12; }
.cal-block-x {
  font-size: 0.5rem;
  line-height: 1;
  font-weight: 900;
  opacity: 0.9;
}
.cal-block-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #a16207;
  flex-shrink: 0;
}

.book-back-btn {
  background: none;
  border: none;
  font-size: 0.82rem;
  color: #cc5b8e;
  cursor: pointer;
  padding: 0;
  font-weight: 600;
  margin-bottom: 0.1rem;
}
.book-back-btn:hover { text-decoration: underline; }

/* ── Book Now: service picker ── */
.book-svc-prompt {
  font-size: 0.78rem;
  font-weight: 700;
  color: #014a64;
  padding: 0.7rem 1.1rem 0.35rem;
  margin: 0;
}
.book-svc-list {
  display: flex;
  flex-direction: column;
  max-height: 60vh;
  overflow-y: auto;
  padding: 0 0 0.5rem;
}
.book-svc-btn {
  background: none;
  border: none;
  border-bottom: 1px solid #f2f2f2;
  text-align: left;
  font-family: inherit;
  font-size: 0.84rem;
  color: #222;
  padding: 0.7rem 1.1rem;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.book-svc-btn:last-child { border-bottom: none; }
.book-svc-btn:hover { background: #f5fafd; color: #014a64; }
.book-svc-btn.is-block { color: #b91c1c; }
.book-svc-btn.is-block:hover { background: #fef2f2; color: #991b1b; }
.book-svc-chip {
  font-size: 0.72rem;
  font-weight: 700;
  color: #cc5b8e;
  background: #fdf4f9;
  border-radius: 20px;
  padding: 0.2rem 0.65rem;
  margin: 0 0 0.5rem;
  display: inline-block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Day planner ── */
.book-planner-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 1rem 0.5rem;
  border-bottom: 1px solid #eef0f3;
}
.book-selected-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #014a64;
  flex: 1;
}
.book-planner {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  max-height: 52vh;
  padding: 4px 6px 12px 10px;
}
.book-planner-loading {
  padding: 1.2rem;
  text-align: center;
  color: #aaa;
  font-size: 0.82rem;
  font-style: italic;
}
.book-cal-col {
  position: relative;
  margin-left: 52px;
  margin-right: 6px;
}
.book-hour-row {
  position: absolute;
  left: -52px;
  right: 0;
  display: flex;
  align-items: flex-start;
  pointer-events: none;
}
.book-hour-label {
  width: 46px;
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 600;
  color: #555;
  text-align: right;
  padding-right: 8px;
  transform: translateY(-50%);
  line-height: 1;
  white-space: nowrap;
}
.book-hour-row::after {
  content: "";
  flex: 1;
  border-top: 1px solid #e8e8e8;
}
.book-half-row {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px dashed #f0f0f0;
  pointer-events: none;
}
.book-appt-card {
  position: absolute;
  left: 2px;
  right: 2px;
  background: #fde68a;
  border-left: 4px solid #d97706;
  border-radius: 5px;
  padding: 3px 7px;
  overflow: hidden;
  z-index: 2;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}
.book-appt-range {
  font-size: 0.62rem;
  color: #92400e;
  line-height: 1.3;
  font-weight: 600;
}
.book-appt-svc {
  font-size: 0.72rem;
  font-weight: 700;
  color: #78350f;
  line-height: 1.3;
  margin-top: 1px;
}
.book-appt-card.is-blocked {
  background: #fee2e2;
  border-left-color: #ef4444;
}
.book-appt-card.is-blocked .book-appt-range { color: #991b1b; }
.book-appt-card.is-blocked .book-appt-svc   { color: #7f1d1d; }
/* ── Booking: preset clickable free slots ─────────────────────────────────── */
.book-free-slot {
  position: absolute;
  left: 2px;
  right: 2px;
  cursor: pointer;
  z-index: 1;
  border-radius: 5px;
  background: rgba(26, 158, 92, 0.15);
  border: none;
  box-sizing: border-box;
  transition: background 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: #14692e;
}
.book-free-slot::after {
  content: attr(data-label);
  pointer-events: none;
}
.book-free-slot:hover { background: rgba(26, 158, 92, 0.26); }
.book-free-slot.is-saving { background: rgba(26, 158, 92, 0.07); color: #888; }
.book-free-slot.is-saving::after { content: "Saving…"; }
.book-free-slot.is-booked-ok { background: rgba(26, 158, 92, 0.25); color: #1a9e5c; }
.book-free-slot.is-booked-ok::after { content: "✓ Booked!"; }
.book-free-slot.is-error { background: rgba(231, 76, 60, 0.09); color: #c0392b; }
.book-free-slot.is-error::after { content: attr(data-label); }

/* ── Drag-to-select planner interaction ──────────────────────────────────── */
.book-drag-hitzone {
  position: absolute;
  inset: 0;
  z-index: 3;
  cursor: crosshair;
}
.book-drag-preview {
  position: absolute;
  left: 2px;
  right: 2px;
  background: rgba(26, 158, 92, 0.28);
  border: 2px solid #16a34a;
  border-radius: 5px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #14532d;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 4;
  min-height: 15px;
  padding: 0 4px;
  text-align: center;
  line-height: 1.2;
}
.book-drag-preview.is-block {
  background: rgba(239, 68, 68, 0.25);
  border-color: #ef4444;
  color: #7f1d1d;
}
.book-drag-preview.is-error {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
  color: #991b1b;
}

/* ── Appointment bar ──────────────────────────────────────────────────────── */
.appt-bar {
  background: #1a9e5c;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.appt-bar-main {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0 0.85rem;
  height: 40px;
}
.appt-bar-label {
  color: rgba(255,255,255,0.75);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
  flex-shrink: 0;
}
.appt-bar-inner {
  flex: 1;
  display: flex;
  align-items: center;
  overflow: hidden;
}
.appt-bar-empty {
  color: rgba(255,255,255,0.6);
  font-size: 0.75rem;
  font-style: italic;
  white-space: nowrap;
}
.appt-chip {
  background: none;
  border: none;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  padding: 0;
  letter-spacing: 0.01em;
  -webkit-tap-highlight-color: transparent;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: rgba(255,255,255,0.4);
}
.appt-chip:hover { text-decoration-color: rgba(255,255,255,0.9); }
/* handle pull-down */
.appt-bar-handle {
  background: none;
  border: none;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  padding: 0 0 4px;
}
.appt-bar-handle-pill {
  display: block;
  width: 36px;
  height: 4px;
  border-radius: 3px;
  background: rgba(255,255,255,0.45);
  transition: background 0.15s, transform 0.25s;
}
.appt-bar-handle:hover .appt-bar-handle-pill { background: rgba(255,255,255,0.75); }
.appt-bar-handle[aria-expanded="true"] .appt-bar-handle-pill { transform: scaleX(0.7); }

/* ── Appointment drawer ───────────────────────────────────────────────────── */
.appt-drawer {
  background: #fff;
  border-bottom: 1px solid #e5e5e5;
  flex-shrink: 0;
  overflow: hidden;
  max-height: 220px;
  overflow-y: auto;
}
.appt-drawer-list {
  display: flex;
  flex-direction: column;
}
.appt-drawer-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  color: #222;
  background: none;
  border-left: none;
  border-right: none;
  border-top: none;
  text-align: left;
  transition: background 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.appt-drawer-row:last-child { border-bottom: none; }
.appt-drawer-row:hover { background: #f7f7f7; }
.appt-drawer-row.is-next {
  background: #f0faf5;
  font-weight: 700;
  color: #1a9e5c;
}
.appt-drawer-row.is-past { color: #bbb; }
.appt-drawer-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #1a9e5c;
}
.appt-drawer-row.is-past .appt-drawer-dot { background: #ddd; }
.appt-drawer-row.is-next .appt-drawer-dot { background: #1a9e5c; box-shadow: 0 0 0 2px rgba(26,158,92,0.25); }
.appt-drawer-history-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #888;
  border-bottom: 1px solid #ececec;
  cursor: pointer;
  user-select: none;
}
.appt-drawer-history-toggle input { accent-color: #1a9e5c; cursor: pointer; }
.appt-drawer-section-label {
  padding: 0.25rem 1rem;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #bbb;
  background: #fafafa;
  border-bottom: 1px solid #f0f0f0;
}

/* ── Appointment detail overlay ───────────────────────────────────────────── */
.appt-detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
}
.appt-detail-card {
  background: #fff;
  border-radius: 16px;
  padding: 1.5rem 1.75rem 1.75rem;
  min-width: 280px;
  max-width: 340px;
  width: 90%;
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,0.22);
}
.appt-detail-close {
  position: absolute;
  top: 0.75rem;
  right: 0.9rem;
  background: none;
  border: none;
  font-size: 1.1rem;
  color: #888;
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem;
}
.appt-detail-close:hover { color: #333; }
.appt-detail-title {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 700;
  color: #1a9e5c;
}
.appt-detail-list {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.55rem 1rem;
  align-items: baseline;
}
.appt-detail-list dt {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #999;
}
.appt-detail-list dd {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 500;
  color: #222;
}
