/* Shared visual language for the operator, manager, widget and media viewer. */
:root {
  --brand: #2f9eae;
  --brand-deep: #176f7d;
  --brand-soft: #e8f5f7;
  --soft: #e8f5f7;
  --ink: #20343b;
  --muted: #71858d;
  --line: #e2eaed;
  --canvas: #f3f6f8;
  --ui-radius: 14px;
  --ui-shadow: 0 12px 36px rgb(26 53 65 / 8%);
  --ui-focus: 0 0 0 3px rgb(47 158 174 / 16%);
}
body { -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button, a { touch-action: manipulation; }
button { transition: background-color .15s, border-color .15s, box-shadow .15s; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 3px;
}
button:disabled { cursor: not-allowed; }
input, textarea, select { accent-color: var(--brand); }
::selection { background: #bde6ec; color: #143b43; }
* { scrollbar-width: thin; scrollbar-color: #c8d6db transparent; }
.sova-tooltips-ready [data-tooltip]::after { display: none; }
.sova-tooltip {
  position: fixed; inset: auto; z-index: 10000; width: max-content;
  max-width: min(240px, calc(100vw - 16px)); margin: 0; padding: 6px 9px;
  border: 0; border-radius: 6px;
  background: #263d45; color: #fff; box-shadow: 0 6px 20px rgb(20 39 47 / 18%);
  font: 400 11px/1.4 "Segoe UI", Arial, sans-serif; overflow-wrap: anywhere;
  pointer-events: none;
}
.sova-tooltip::backdrop { background: transparent; pointer-events: none; }

/* Operator workspace */
.operator-shell { grid-template-columns: 4.25rem minmax(17rem, 19.5rem) minmax(0, 1fr) minmax(18rem, 20.5rem); }
.rail { padding: 1rem .6rem; background: #f9fbfc; }
.sova-mark { width: 2.75rem; height: 2.75rem; border-radius: 14px; box-shadow: 0 5px 14px rgb(47 158 174 / 18%); }
.rail nav { margin-top: 1.5rem; gap: .5rem; }
.rail-button { border-radius: 12px; }
.rail-button.active { box-shadow: inset 0 0 0 1px rgb(47 158 174 / 8%); }
.staff-avatar {
  display: grid; place-items: center; flex: 0 0 42px; width: 42px; height: 42px;
  min-width: 42px; min-height: 42px; padding: 0; aspect-ratio: 1; line-height: 1;
  border: 0; border-radius: 50%; box-shadow: 0 0 0 3px #fff, 0 0 0 4px #dce7eb;
}
.staff-avatar img { width: 100%; height: 100%; min-width: 0; display: block; object-fit: cover; object-position: center; border-radius: 50%; }
.staff-avatar > span { width: 11px; height: 11px; right: -1px; bottom: -1px; }
.inbox { background: #fff; }
.inbox-heading { min-height: 5.1rem; padding: 1.15rem 1.1rem .9rem; }
.inbox-heading h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: -.035em; }
.inbox-heading span { font-size: .65rem; letter-spacing: .14em; }
.inbox-heading .icon-button { background: #f3f7f9; border: 1px solid #e8eef1; }
.work-status-control, .queue-tabs { margin-inline: .85rem; border-radius: 12px; background: #f1f5f7; padding: 4px; }
.work-status-control button { min-height: 32px; border-radius: 9px; font-size: .7rem; }
.work-status-control button.active, .queue-tabs button.active { box-shadow: 0 2px 5px rgb(31 62 74 / 7%); }
.queue-tabs button { min-height: 39px; border-radius: 9px; font-size: .83rem; }
.queue-tabs span { display: inline-block; min-width: 18px; padding: 1px 4px; border-radius: 5px; font-size: .72rem; }
.queue-tabs button.active span { background: var(--brand-soft); }
.take-next-button {
  width: calc(100% - 1.7rem); margin: 0 .85rem .85rem; padding: .8rem .9rem;
  border-radius: 12px; background: var(--brand); box-shadow: 0 4px 12px rgb(47 158 174 / 14%);
}
.take-next-button:disabled { background: #eff4f6; color: #82959d; opacity: 1; box-shadow: none; }
.take-next-button:disabled small { color: #82959d; }
.take-next-button:disabled i { background: #e3ebee; }
.source-tabs { gap: .22rem; padding: 0 .85rem .8rem; }
.source-tabs button { flex: 0 0 auto; min-height: 31px; padding: .32rem .52rem; border-radius: 8px; font-size: .7rem; }
.conversation-list { padding: .15rem .55rem 1rem; }
.conversation { margin-bottom: 3px; padding: .85rem .65rem; border-radius: 12px; gap: .65rem; }
.conversation.active { background: #f1f5f6; box-shadow: none; }
.conversation:hover:not(.active) { background: #f4f7f9; }
.conversation-copy strong { font-size: .85rem; }
.conversation-copy small { font-size: .73rem; line-height: 1.4; }
.conversation-meta time { font-size: .66rem; }
.dialog { height: 100dvh; grid-template-rows: 4.6rem minmax(0, 1fr) auto; background: #f3f6f8; }
.operator-shell.settings-mode .dialog > :not(.operator-settings-panel) { display: none; }
.dialog-heading { min-width: 0; padding-inline: 1.1rem; gap: .65rem; }
.dialog-person strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .91rem; }
.dialog-person > span { font-size: .72rem; }
.dialog-actions { gap: 4px; }
.action-icon, .icon-button { flex-shrink: 0; width: 36px; height: 36px; padding: 0; border-radius: 10px; }
.action-icon svg, .icon-button svg { width: 18px; height: 18px; }
.action-icon.danger { background: #fff1f3; color: #cc5365; }
.action-icon.danger:hover { background: #ffe4e9; }
.client-info-toggle, .client-info-close { display: none; }
.thread { padding: 1.5rem clamp(1rem, 3vw, 3.5rem) 1.5rem; }
.day { margin-bottom: 1.25rem; font-size: .69rem; color: #8a9ca4; }
.message { max-width: min(38rem, 85%); padding: .8rem .95rem .55rem; border: 1px solid #e8eef1; border-radius: 4px 16px 16px 16px; box-shadow: 0 2px 3px rgb(26 53 65 / 2%); }
.message.outgoing { border-color: #d1e9e9; background: #e0f2f1; border-radius: 16px 4px 16px 16px; }
.message p { font-size: .87rem; line-height: 1.6; }
.message time { margin-top: .4rem; font-size: .64rem; color: #8c9da4; }
.system-note { max-width: 90%; padding: .55rem .8rem; border-radius: 10px; background: #eaf0f3; line-height: 1.5; overflow-wrap: anywhere; }
.composer { padding: .8rem 1rem 1rem; background: #fff; }
.composer form { border-color: #d8e3e8; border-radius: 14px; box-shadow: 0 2px 5px rgb(26 53 65 / 3%); }
.composer form:focus-within { border-color: #c7d4d9; box-shadow: none; }
.composer textarea:focus-visible { outline: none; }
.composer textarea { border-radius: 14px; padding: .9rem 1rem .25rem; font-size: .87rem; line-height: 1.5; }
.composer-tools { gap: 3px; padding: .25rem .45rem .5rem; }
.send-button { width: 38px; height: 38px; border-radius: 11px; }
.pending-files article { border-radius: 11px; background: #f5f8fa; }
.pending-files article > button:hover { background: #e7edf1; }
.pending-files img { flex-shrink: 0; }
.ai-suggestion { border: 1px solid #dceef0; border-radius: 11px; }
.queue-claim { padding: 1rem; }
.claim-button { border-radius: 12px; }
.client-card { background: #fff; }
.client-card > header { height: 4.6rem; position: sticky; top: 0; z-index: 1; background: #fff; }
.client-card h2 { font-size: .88rem; }
.client-person { padding: 1.2rem 1rem 1rem; gap: .65rem; }
.client-person strong { font-size: .86rem; line-height: 1.45; }
.profile-actions { gap: 1px; }
.contact-lines { padding-inline: 1rem; }
.contact-lines p { grid-template-columns: 5rem minmax(0,1fr); font-size: .73rem; }
.open-mis-link { margin-inline: 1rem; padding: .72rem; border-radius: 10px; background: #f4fafb; }
.side-section { padding: 1rem; }
.section-title h3 { font-size: .77rem; }
.pet-row { align-items: flex-start; padding: .5rem 0; }
.pet-icon { flex: 0 0 36px; width: 36px; height: 36px; border-radius: 11px; }
.pet-row small { line-height: 1.5; }
.appointment-card { border: 1px solid #e7eef1; border-radius: 11px; background: #f8fafb; }
.appointment-card > div { min-width: 0; }
.comment-list article { border: 1px solid #eaf0f3; border-radius: 12px; background: #f6f9fa; }
.comment-list article { position: relative; }
.comment-list article > strong { display: block; padding-right: 24px; font-weight: 500; }
.comment-list .note-delete { position: absolute; top: 7px; right: 7px; width: 26px; height: 26px; margin: 0; display: grid; place-items: center; border-radius: 6px; color: #89979d; }
.comment-list .note-delete:hover { background: #fbecef; color: #ac5965; text-decoration: none; }
.note-delete svg { width: 15px; height: 15px; }
.conversation-copy strong, .dialog-person strong, .client-person strong, .take-next-button b, .queue-tabs button, .section-title h3, .pet-row b, .inbox-heading h1 { font-weight: 500; }
.message-author, .composer-tools > span { font-weight: 400; }
.comment-form { border-radius: 12px; }
.comment-form textarea { border-radius: 12px; }
.comment-form textarea:focus-visible { outline: none; }
.comment-form:focus-within { border-color: #c7d4d9; box-shadow: none; }
.dialog-empty { display: none; }
.operator-shell.no-selection .dialog-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  flex-direction: column; padding: 2rem; text-align: center; color: #728890;
}
.dialog-empty > span { display: grid; place-items: center; width: 72px; height: 72px; margin-bottom: 1.25rem; border-radius: 24px; background: #e4f0f3; color: var(--brand); }
.dialog-empty svg { width: 30px; height: 30px; }
.dialog-empty strong { color: #455f69; font-size: 1rem; font-weight: 650; }
.dialog-empty p { margin: .7rem 0 0; font-size: .82rem; line-height: 1.8; }
.operator-shell.no-selection .client-card { background: #f9fbfc; }
.operator-shell.no-selection .queue-claim { display: none; }
.operator-dialog:not(.attachment-viewer) { border: 1px solid #e3ebef; border-radius: 18px; padding: 1.4rem; box-shadow: 0 24px 80px rgb(22 47 58 / 18%); }
dialog::backdrop { background: rgb(25 43 53 / 35%); backdrop-filter: blur(3px); }
.operator-dialog input, .operator-dialog textarea, .operator-dialog select { border-radius: 10px; }
.search-filters { padding: 1rem; border-radius: 12px; background: #f5f8fa; }
.template-popover, .emoji-popover, .profile-menu { border-radius: 14px; box-shadow: var(--ui-shadow); }
.toast { max-width: min(30rem, calc(100vw - 24px)); padding: .65rem .85rem; border-radius: 8px; font-size: .75rem; font-weight: 400; line-height: 1.45; text-align: center; box-shadow: 0 4px 16px rgb(25 43 53 / 12%); }

/* Manager and sign-in */
.admin-shell { grid-template-columns: 14rem minmax(0, 1fr); }
.admin-sidebar { background: #f9fbfc; border-right: 1px solid var(--line); }
.admin-sidebar nav button { border-radius: 11px; margin-block: 3px; padding: .85rem .9rem; }
.admin-sidebar nav button.active { background: var(--brand-soft); color: var(--brand-deep); }
.admin-sidebar nav button:hover:not(.active) { background: #eef3f6; }
.admin-header { background: #fff; border-bottom-color: var(--line); padding-inline: 2rem; }
.admin-header h1 { letter-spacing: -.035em; }
.admin-content { max-width: 90rem; padding: 1.75rem 2rem 3rem; }
.stat-grid { gap: .85rem; }
.stat-grid article { border-radius: 15px; box-shadow: 0 3px 10px rgb(26 53 65 / 3%); }
.stat-grid b { color: #274b58; font-variant-numeric: tabular-nums; }
.stat-grid span { line-height: 1.5; }
.welcome-panel { border-radius: 18px; background: linear-gradient(120deg, #226c7b, #329fae); box-shadow: 0 8px 24px rgb(47 158 174 / 13%); }
.table-card, .settings-card, .audit-list { border-radius: 15px; box-shadow: 0 3px 12px rgb(26 53 65 / 3%); }
.table-card { overflow-x: auto; }
th { background: #f4f7f9; }
tbody tr:hover { background: #f8fbfc; }
.settings-card { padding: 1.25rem; }
.settings-card > header { gap: .75rem; }
.settings-card h3 { line-height: 1.5; }
.settings-card p, .section-toolbar p { line-height: 1.6; }
.settings-card label { line-height: 1.5; }
.settings-card input, .settings-card textarea, .settings-card select, .login-card input { border-color: #d6e2e7; border-radius: 10px; }
.settings-card input:focus, .settings-card textarea:focus, .settings-card select:focus, .login-card input:focus { box-shadow: var(--ui-focus); border-color: var(--brand); }
.primary-button, .secondary-button, .header-actions a, .header-actions button { border-radius: 10px; min-height: 38px; }
.integration-icon { border-radius: 13px; }
.max-tool-panel, .max-session-panel, .max-qr-panel { border-radius: 13px; background: #f7fafb; }
.integration-actions { flex-wrap: wrap; gap: .5rem; }
.login-page { min-height: 100dvh; background: radial-gradient(ellipse at 20% 10%, #dfedf2, transparent 55%), #f4f7f9; }
.login-card { width: min(27rem, 100%); padding: 2.25rem; border-radius: 22px; box-shadow: 0 20px 70px rgb(39 73 88 / 10%); }
.login-card h1 { font-size: 1.5rem; line-height: 1.3; }
.login-card .primary-button { min-height: 46px; }

/* Clinic widget */
.chat-widget { border: 0; border-radius: 20px; box-shadow: 0 16px 60px rgb(24 63 79 / 20%); }
.widget-heading { padding: 1rem 1.15rem; background: linear-gradient(110deg, #2993a4, #39aab7); }
.widget-heading #closeWidget { width: 36px; height: 36px; border-radius: 11px; }
.widget-thread { padding: 1.1rem; background: #fff; }
.widget-message { padding: .85rem .95rem .6rem; border-radius: 4px 16px 16px 16px; background: #f0f4f6; }
.widget-message p { font-size: .95rem; line-height: 1.6; }
.widget-message.from-client { border-radius: 16px 4px 16px 16px; background: #e4f4f6; color: #214a53; box-shadow: none; }
.widget-message.from-client time { color: #73929a; }
.widget-actions button { border: 1px solid #9cd4dd; border-radius: 14px; background: #f6fbfc; padding: .85rem 1rem; font-size: .88rem; color: #287582; }
.widget-actions button:hover { background: #eaf6f8; }
.widget-composer { align-items: end; padding: .7rem .75rem .8rem; gap: .3rem; }
.widget-composer textarea { min-width: 0; font-size: 16px; max-height: 144px; line-height: 1.5; }
.widget-composer textarea:focus-visible { outline: none; border: 0; box-shadow: none; }
#submitRating { font-weight: 400; }
.renovatio-confirmation { padding: 12px 16px; border-radius: 10px; background: #f0f7f8; }
.renovatio-confirmation p { margin: 4px 0; font-size: 13px; font-weight: 400; }
.widget-composer button { flex-shrink: 0; width: 38px; height: 38px; border-radius: 11px; }
.widget-composer .widget-send { background: var(--brand); }
.widget-launcher { font-weight: 400; font-size: 1.06rem; box-shadow: 0 8px 26px rgb(47 158 174 / 20%); }
.widget-rating { border-radius: 16px; }
.widget-feedback textarea { border-radius: 10px; }

/* A compact, consistent full-screen media toolbar. */
.attachment-viewer header { min-height: 64px; gap: .65rem; padding: .65rem 1rem; }
.attachment-viewer .viewer-title { flex: 1 1 12rem; }
.attachment-viewer .viewer-title b { max-width: 100%; font-size: .8rem; }
.attachment-viewer .viewer-tools { min-width: 0; flex-wrap: wrap; gap: 6px; }
.attachment-viewer .viewer-tools a, .attachment-viewer .viewer-tools button { min-height: 34px; height: auto; border-radius: 9px; font-size: .72rem; }
.attachment-viewer .viewer-tools [data-viewer-close] { width: 34px; min-height: 34px; }
.attachment-viewer .viewer-zoom { gap: 4px; }
.attachment-viewer .viewer-zoom button { min-width: 32px; }
.attachment-viewer .viewer-zoom output { font-variant-numeric: tabular-nums; }
.viewer-nav { width: 40px; height: 48px; border-radius: 12px; }

@media (max-width: 78rem) {
  .operator-shell { grid-template-columns: 4.25rem 18rem minmax(0, 1fr); }
  .client-info-toggle, .client-info-close { display: grid; }
  .operator-shell.client-open .client-card {
    display: block; position: fixed; z-index: 35; inset: 0 0 0 auto; width: min(350px, 100vw);
    height: 100dvh; border-left: 1px solid var(--line); box-shadow: -16px 0 60px rgb(26 53 65 / 18%);
  }
  .dialog-heading { padding-inline: .85rem; }
  .admin-content { padding-inline: 1.25rem; }
  .settings-grid { gap: 1rem; }
}
@media (min-width: 52.01rem) and (max-width: 64rem) {
  .operator-shell { grid-template-columns: 4rem 16rem minmax(0, 1fr); }
  .dialog-actions { gap: 1px; }
  .action-icon { width: 32px; height: 34px; }
  .dialog-person strong { max-width: 10rem; }
}
@media (max-width: 52rem) {
  .operator-shell { display: block; width: 100%; height: 100dvh; min-height: 0; }
  .operator-shell .rail {
    position: fixed; inset: auto 0 0; display: flex; flex-direction: row; justify-content: space-between;
    height: calc(64px + env(safe-area-inset-bottom)); padding: 8px 1rem calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line); border-right: 0; z-index: 30;
  }
  .rail .sova-mark { display: none; }
  .rail nav, .rail-bottom { display: flex; align-items: center; gap: 12px; margin: 0; }
  .rail-button { width: 42px; height: 42px; }
  .operator-shell:not(.no-selection) .rail { display: none; }
  .operator-shell .inbox { display: flex; width: 100%; height: calc(100dvh - 64px - env(safe-area-inset-bottom)); min-height: 0; }
  .operator-shell .dialog { display: none; width: 100%; height: 100dvh; border: 0; min-height: 0; }
  .operator-shell:not(.no-selection) .inbox { display: none; }
  .operator-shell:not(.no-selection) .dialog { display: grid; }
  .operator-shell .client-card { display: none; }
  .operator-shell.no-selection .dialog-empty { display: none; }
  .mobile-back { display: grid; place-items: center; flex-shrink: 0; width: 32px; height: 36px; border: 0; border-radius: 10px; background: #f0f5f7; color: var(--brand-deep); }
  .mobile-avatar { display: grid; flex: 0 0 32px; width: 32px; height: 32px; }
  .dialog { grid-template-rows: auto minmax(0, 1fr) auto; }
  .dialog-heading { flex-wrap: wrap; padding: .65rem .7rem; gap: .55rem; }
  .dialog-person { flex: 1; }
  .dialog-actions { justify-content: flex-end; flex: 1 0 100%; border-top: 1px solid #edf2f5; padding-top: .35rem; }
  .dialog-actions .action-icon { width: 38px; height: 34px; }
  .dialog-actions .client-info-toggle { margin-right: auto; }
  .thread { padding: 1rem .8rem; }
  .message { max-width: 90%; }
  .composer { padding: .6rem .6rem max(.6rem, env(safe-area-inset-bottom)); }
  .composer-tools > span { display: none; }
  .source-tabs { scrollbar-width: none; }
  .profile-menu { position: fixed; left: auto; right: .8rem; bottom: calc(74px + env(safe-area-inset-bottom)); width: min(17rem, calc(100vw - 1.6rem)); }
  .operator-shell.settings-mode .inbox { display: none; }
  .operator-shell.settings-mode .dialog { display: grid; height: calc(100dvh - 64px - env(safe-area-inset-bottom)); }
  .operator-settings-panel { padding: 1.25rem 1rem; }
  .operator-settings-panel > header h2 { font-size: 1.3rem; }
  .operator-dialog:not(.attachment-viewer) { max-height: calc(100dvh - 24px); width: min(36rem, calc(100vw - 24px)); padding: 1.1rem; }
  .admin-shell { grid-template-columns: 4.5rem minmax(0, 1fr); }
  .admin-content { padding: 1rem; }
  .admin-header { padding: 1rem; flex-wrap: wrap; gap: .75rem; }
  .admin-sidebar { padding-inline: .6rem; }
  .admin-sidebar nav button { padding: .7rem; justify-content: center; font-size: 0; }
  .admin-sidebar nav i { font-size: 1.1rem; }
  .admin-brand > div, .admin-user > div { display: none; }
  .admin-sidebar .admin-brand > span { width: 42px; height: 42px; }
  .settings-card { padding: 1rem; }
  .settings-card > header { flex-wrap: wrap; }
  .section-toolbar { flex-wrap: wrap; align-items: flex-start; }
  .stat-grid { gap: .65rem; }
  .stat-grid article { padding: .85rem; }
  .stat-grid b { font-size: 1.7rem; }
  .integration-actions > button { flex: 1 1 auto; }
  .widget-composer { padding-bottom: max(.75rem, env(safe-area-inset-bottom)); }
  .chat-widget { max-height: 100dvh; }
  .embedded .chat-widget { border-radius: 16px 16px 0 0; }
  .widget-thread { padding: 1rem .8rem; }
  .widget-actions button { font-size: .86rem; }
  .attachment-viewer header { padding: .6rem; }
  .attachment-viewer .viewer-title { flex-basis: 100%; }
  .attachment-viewer .viewer-tools { width: 100%; justify-content: flex-end; }
  .attachment-viewer .viewer-zoom { margin-right: auto; }
  .viewer-zoom input { width: 3.5rem; }
  .viewer-nav.viewer-prev { left: .5rem; }
  .viewer-nav.viewer-next { right: .5rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

.conversation-thread-anchor { padding: 4px 0 8px; color: #819099; font-size: 11px; font-weight: 400; }
.conversation-thread-anchor a { color: inherit; text-decoration: none; }
.conversation-thread-anchor a:hover { color: #269cac; text-decoration: underline; }
