/* ============================================================
   AI RevenueOS — Polish Layer
   Loaded last. Purely additive: depth, motion, gradients, finish.
   No class renames, no layout/structure changes — safe to drop in.
   ============================================================ */

/* ---- ambient background depth ---- */
body {
  background:
    radial-gradient(1100px 560px at 100% -8%, rgba(172, 137, 89, 0.10), transparent 62%),
    radial-gradient(820px 480px at -6% 104%, rgba(74, 79, 60, 0.07), transparent 58%),
    var(--canvas);
  background-attachment: fixed;
}

/* ---- entrance motion ---- */
@keyframes os-rise { from { opacity: 0; transform: translateY(13px); } to { opacity: 1; transform: translateY(0); } }
@keyframes os-fade { from { opacity: 0; } to { opacity: 1; } }

.view > .view-head,
.view > .dash-hero { animation: os-rise 440ms cubic-bezier(.22, .7, .28, 1) backwards; }
.view .card,
.view .stat-card { animation: os-rise 480ms cubic-bezier(.22, .7, .28, 1) backwards; }
.view .grid > *:nth-child(2) { animation-delay: 55ms; }
.view .grid > *:nth-child(3) { animation-delay: 110ms; }
.view .grid > *:nth-child(4) { animation-delay: 165ms; }
.view .grid > *:nth-child(5) { animation-delay: 220ms; }
.inbox, .kanban { animation: os-fade 320ms ease backwards; }

@media (prefers-reduced-motion: reduce) {
  .view > .view-head, .view > .dash-hero,
  .view .card, .view .stat-card,
  .inbox, .kanban { animation: none !important; }
}

/* ---- cards: softer layered depth ---- */
.card {
  box-shadow: 0 1px 2px rgba(60, 50, 35, 0.05), 0 10px 26px -16px rgba(60, 50, 35, 0.22);
  transition: box-shadow 240ms ease, border-color 240ms ease;
}
.card:hover {
  border-color: var(--border-2);
  box-shadow: 0 2px 5px rgba(60, 50, 35, 0.06), 0 16px 34px -18px rgba(60, 50, 35, 0.30);
}
/* keep inline icons on the same line as the heading text */
.card-head h3, .card-head h4 { display: flex; align-items: center; gap: 6px; }
.card-head h3 > svg, .card-head h4 > svg { flex-shrink: 0; }

/* ---- stat cards: hero tiles ---- */
.stat-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(157deg, var(--surface) 40%, var(--surface-2));
  box-shadow: 0 1px 2px rgba(60, 50, 35, 0.05), 0 12px 28px -18px rgba(60, 50, 35, 0.24);
  transition: transform 260ms cubic-bezier(.22, .7, .28, 1), box-shadow 260ms ease;
}
.stat-card::after {
  content: '';
  position: absolute; top: -42px; right: -34px;
  width: 116px; height: 116px; border-radius: 50%;
  background: radial-gradient(circle, rgba(172, 137, 89, 0.14), transparent 70%);
  background: radial-gradient(circle, color-mix(in srgb, var(--ic, var(--clay)) 24%, transparent), transparent 70%);
  pointer-events: none;
}
.stat-card > * { position: relative; z-index: 1; }
.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 12px rgba(60, 50, 35, 0.07), 0 22px 40px -18px rgba(60, 50, 35, 0.32);
}
.stat-card .stat-value { font-size: 28px; }
.stat-card:hover .stat-ic { transform: scale(1.07); }

/* sparkline slot — bleeds to the card edges */
.stat-spark { margin: auto -20px -16px; padding-top: 8px; }
.stat-spark svg { display: block; width: 100%; }

/* ---- icon chip (stat cards + inline) — selector matches components' .stat-card .stat-ic specificity ---- */
.stat-card .stat-ic,
.stat-ic {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: grid; place-items: center;
  flex-shrink: 0;
  background: var(--ic, var(--primary));
  background: linear-gradient(143deg, color-mix(in srgb, var(--ic, var(--primary)) 88%, #fff), var(--ic, var(--primary)));
  color: #fff;
  box-shadow: 0 5px 12px -3px color-mix(in srgb, var(--ic, var(--primary)) 42%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.30);
  transition: transform 260ms cubic-bezier(.22, .7, .28, 1);
}
.stat-card .stat-ic svg,
.stat-ic svg { width: 17px; height: 17px; }

/* ---- buttons: gradient fills + tactile press ---- */
.btn {
  transition: background 160ms ease, box-shadow 160ms ease,
              border-color 160ms ease, transform 90ms ease, filter 160ms ease;
}
.btn-primary {
  background: linear-gradient(180deg, #585e47, var(--primary));
  box-shadow: 0 2px 7px -1px rgba(74, 79, 60, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.10);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #4d533f, var(--primary-hover));
  box-shadow: 0 5px 14px -2px rgba(74, 79, 60, 0.52), inset 0 1px 0 rgba(255, 255, 255, 0.10);
}
.btn-clay {
  background: linear-gradient(180deg, #ba9869, var(--clay));
  box-shadow: 0 2px 7px -1px rgba(172, 137, 89, 0.46), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.btn-clay:hover:not(:disabled) {
  background: linear-gradient(180deg, #a9865b, var(--clay-hover));
  box-shadow: 0 5px 14px -2px rgba(172, 137, 89, 0.54), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.btn-ghost { box-shadow: 0 1px 2px rgba(60, 50, 35, 0.06); }
.btn-ghost:hover:not(:disabled) { border-color: var(--tan); }
.btn-primary:active:not(:disabled),
.btn-clay:active:not(:disabled),
.btn-ghost:active:not(:disabled),
.btn-subtle:active:not(:disabled),
.btn-danger:active:not(:disabled) { transform: translateY(1px); }

/* ---- sidebar ---- */
.sidebar {
  background: linear-gradient(184deg, var(--surface), var(--surface-2));
  box-shadow: 14px 0 30px -26px rgba(60, 50, 35, 0.55);
}
.sidebar-brand .logo-mark { box-shadow: 0 5px 13px -3px rgba(74, 79, 60, 0.50); }
/* the login-card logo inherits no size (only .sidebar-brand .logo-mark is sized) */
.brand-row .logo-mark {
  width: 42px; height: 42px;
  border-radius: 12px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--primary);
  box-shadow: 0 6px 15px -3px rgba(74, 79, 60, 0.52);
}
.brand-row .logo-mark img { width: 100%; height: 100%; object-fit: cover; }
.nav-item { transition: background 160ms ease, color 160ms ease; }
.nav-item.active {
  background: linear-gradient(134deg, #585e47, var(--primary));
  box-shadow: 0 7px 17px -7px rgba(74, 79, 60, 0.60);
}
.user-chip { transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease, transform 90ms ease; }

/* ---- topbar: frosted ---- */
.topbar {
  background: linear-gradient(180deg, rgba(246, 242, 234, 0.92), rgba(244, 239, 230, 0.82));
  backdrop-filter: saturate(150%) blur(12px);
  -webkit-backdrop-filter: saturate(150%) blur(12px);
  box-shadow: 0 1px 0 var(--border), 0 14px 26px -24px rgba(60, 50, 35, 0.60);
}

/* ---- inputs ---- */
.input, .select, .textarea {
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}
.input:hover:not(:focus), .select:hover:not(:focus),
.textarea:hover:not(:focus) { border-color: var(--tan); }

/* ---- tables ---- */
.table thead th { background: var(--surface-2); }
.table tbody tr.row-click { transition: background 140ms ease; }

/* ---- tabs / segmented ---- */
.tab { transition: color 150ms ease, border-color 150ms ease; }
.segmented { box-shadow: inset 0 1px 2px rgba(60, 50, 35, 0.07); }
.segmented button { transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease; }

/* ---- insight rank chip ---- */
.insight-row .ins-rank {
  background: linear-gradient(142deg, #5b6149, var(--primary));
  color: var(--on-primary);
  box-shadow: 0 3px 8px -2px rgba(74, 79, 60, 0.45);
}

/* ---- charts: subtle sheen ---- */
.bar-fill { box-shadow: inset 0 -1px 2px rgba(0, 0, 0, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.18); }
.funnel-svg { display: block; width: 100%; }
.progress > span { background: linear-gradient(90deg, var(--clay), var(--primary)); }
.score-bar > span { box-shadow: inset 0 -1px 2px rgba(0, 0, 0, 0.12); }

/* ---- avatar ---- */
.avatar { box-shadow: inset 0 0 0 1px rgba(60, 50, 35, 0.07), 0 2px 6px -2px rgba(60, 50, 35, 0.30); }

/* ---- conversation inbox ---- */
.conv-item { position: relative; transition: background 150ms ease; }
.conv-item.active::before {
  content: '';
  position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0;
  background: var(--primary);
}
.bubble { box-shadow: 0 1px 3px rgba(60, 50, 35, 0.08); }
.bubble.admin { background: linear-gradient(158deg, #585e47, var(--primary)); }
.kan-card { transition: box-shadow 180ms ease, transform 180ms ease, border-color 180ms ease; }
.kan-card:hover { transform: translateY(-2px); border-color: var(--border-2); }

/* ---- modal / toast ---- */
.modal-overlay { backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.modal { box-shadow: 0 30px 64px -22px rgba(40, 34, 24, 0.50); }
.toast { box-shadow: 0 8px 22px -8px rgba(60, 50, 35, 0.35); }

/* ---- auth / login ---- */
.auth-visual::after {
  background: linear-gradient(152deg, rgba(74, 79, 60, 0.52) 0%,
              rgba(44, 42, 36, 0.28) 44%, rgba(28, 26, 20, 0.80) 100%);
}
.auth-card { animation: os-rise 520ms cubic-bezier(.22, .7, .28, 1) backwards; }
.demo-accounts .da-row { transition: color 130ms ease; border-radius: var(--r-sm); }

/* ---- filter pill ---- */
.filter-pill { transition: border-color 150ms ease, box-shadow 150ms ease; }
.filter-pill:hover { border-color: var(--tan); }

/* ---- sidebar brand → clinic switcher ---- */
.sidebar-brand {
  width: 100%; text-align: left; cursor: pointer;
  transition: background 150ms ease;
}
.sidebar-brand:hover { background: var(--surface-3); }
.sidebar-brand .brand-text { flex: 1; min-width: 0; }
.sidebar-brand .brand-sub { color: var(--clay); font-weight: 500; text-transform: none; letter-spacing: 0; }
.brand-switch {
  color: var(--muted); flex-shrink: 0; display: grid; place-items: center;
  transition: transform 250ms ease, color 150ms ease;
}
.sidebar-brand:hover .brand-switch { color: var(--primary); transform: rotate(-90deg); }

/* ---- clinic picker (workspace lobby) ---- */
.picker-page {
  min-height: 100vh; display: flex; flex-direction: column;
  position: relative; isolation: isolate;
  background:
    radial-gradient(1100px 620px at 8% -10%, rgba(172, 137, 89, 0.18), transparent 60%),
    radial-gradient(960px 560px at 102% -4%, rgba(74, 79, 60, 0.16), transparent 56%),
    radial-gradient(800px 520px at 50% 116%, rgba(81, 124, 106, 0.12), transparent 60%),
    linear-gradient(180deg, var(--canvas) 0%, var(--canvas-2) 100%);
}
/* a warm spa photograph washed behind everything for atmosphere + depth */
.picker-page::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: url('/assets/images/background.png') center 22% / cover no-repeat;
  opacity: 0.14; filter: blur(2px) saturate(1.06);
  -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 52%, transparent 95%);
          mask-image: linear-gradient(180deg, #000 0%, #000 52%, transparent 95%);
}
/* a soft cream veil over the photo keeps text + cards perfectly legible */
.picker-page::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--canvas) 58%, transparent) 0%,
    color-mix(in srgb, var(--canvas) 78%, transparent) 100%);
}
.picker-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-4) var(--sp-8);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 5;
}
.picker-top .logo-mark {
  width: 32px; height: 32px; border-radius: 9px; overflow: hidden;
  background: var(--primary); color: var(--on-primary);
  display: grid; place-items: center; font-weight: 600;
  box-shadow: 0 4px 10px -2px rgba(74, 79, 60, 0.45);
}
.picker-top .logo-mark img { width: 100%; height: 100%; object-fit: cover; }
.picker-body {
  flex: 1; width: 100%; max-width: 1120px; margin: 0 auto;
  padding: var(--sp-12) var(--sp-8);
}
.picker-head { margin-bottom: var(--sp-10); position: relative;
  animation: os-rise 440ms cubic-bezier(.22, .7, .28, 1) backwards; }
.picker-eyebrow {
  display: inline-flex; align-items: center; gap: 9px;
  font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--clay); margin-bottom: var(--sp-3);
}
.picker-eyebrow::before { content: ""; width: 26px; height: 1.5px;
  background: var(--clay); opacity: 0.55; }
.picker-head h1 {
  font-family: 'Fraunces', Georgia, 'Times New Roman', serif;
  font-optical-sizing: auto; font-weight: 500;
  font-size: clamp(34px, 5.2vw, 54px); line-height: 1.02;
  letter-spacing: -0.022em; color: var(--ink);
}
.picker-head h1 em { font-style: italic; font-weight: 400; color: var(--clay); }
.picker-head p { color: var(--ink-2); margin-top: var(--sp-3);
  font-size: var(--fs-md); max-width: 54ch; }

.clinic-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-6); }
.clinic-card {
  position: relative; display: flex; flex-direction: column; text-align: left;
  background: linear-gradient(168deg, var(--surface) 28%, var(--surface-2));
  border: 1px solid var(--border); border-radius: var(--r-xl); overflow: hidden;
  box-shadow: 0 1px 2px rgba(60, 50, 35, 0.05), 0 18px 42px -26px rgba(60, 50, 35, 0.42);
  transition: transform 280ms cubic-bezier(.22, .7, .28, 1), box-shadow 280ms ease;
  animation: os-rise 480ms cubic-bezier(.22, .7, .28, 1) backwards;
}
/* accent frame that brightens on hover */
.clinic-card::after {
  content: ""; position: absolute; inset: 0; z-index: 3; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--cc-accent, var(--clay)) 46%, transparent);
  opacity: 0; transition: opacity 240ms ease;
}
.clinic-grid > *:nth-child(2) { animation-delay: 70ms; }
.clinic-grid > *:nth-child(3) { animation-delay: 140ms; }
.clinic-grid > *:nth-child(4) { animation-delay: 210ms; }
.clinic-grid > *:nth-child(5) { animation-delay: 280ms; }
.clinic-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 8px 16px rgba(60, 50, 35, 0.08), 0 32px 56px -28px rgba(60, 50, 35, 0.5);
}
.clinic-card:hover::after { opacity: 1; }

/* ---- cover banner (uploadable) ---- */
.cc-banner { position: relative; height: 124px; overflow: hidden; }
.cc-cover {
  position: absolute; inset: 0; display: block; width: 100%; padding: 0; border: 0;
  background: var(--surface-3); overflow: hidden;
}
.cc-cover-img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transform: scale(1.03); transition: transform 620ms cubic-bezier(.22, .7, .28, 1);
}
.clinic-card:hover .cc-cover-img { transform: scale(1.09); }
.cc-cover-wash {
  position: absolute; inset: 0; mix-blend-mode: multiply;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--cc-accent, var(--clay)) 58%, transparent) 0%, transparent 58%),
    linear-gradient(0deg, rgba(28, 24, 18, 0.22), transparent 54%);
}
.cc-cover-edit { cursor: pointer; }
.cc-cover-hint {
  position: absolute; left: 12px; bottom: 12px; z-index: 2;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px 5px 9px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 600; color: #fff;
  background: rgba(28, 24, 18, 0.5);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; transform: translateY(4px); transition: opacity 180ms ease, transform 180ms ease;
}
.cc-cover-edit:hover .cc-cover-hint { opacity: 1; transform: none; }

/* hover tools (edit / remove) — float over the banner */
.cc-tools {
  position: absolute; top: 10px; right: 10px; z-index: 4; display: flex; gap: 6px;
  opacity: 0; transform: translateY(-4px);
  transition: opacity 180ms ease, transform 180ms ease;
}
.clinic-card:hover .cc-tools, .clinic-card:focus-within .cc-tools { opacity: 1; transform: none; }
.cc-tool {
  width: 31px; height: 31px; border-radius: 9px; display: grid; place-items: center;
  color: var(--ink-2); background: rgba(255, 255, 255, 0.88); border: none;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); box-shadow: var(--sh-sm);
  transition: background 140ms ease, color 140ms ease, transform 140ms ease;
}
.cc-tool:hover { background: #fff; color: var(--ink); transform: translateY(-1px); }
.cc-tool-danger:hover { background: var(--danger-bg); color: var(--danger); }

/* ---- card body ---- */
.cc-body { position: relative; z-index: 1; display: flex; flex-direction: column;
  gap: var(--sp-2); padding: 0 var(--sp-5) var(--sp-5); }
.cc-badge-row { margin-top: -32px; margin-bottom: var(--sp-1); }
.cc-logo {
  width: 60px; height: 60px; border-radius: 18px; overflow: hidden;
  display: grid; place-items: center; color: #fff;
  font-weight: 700; font-size: var(--fs-xl); background: var(--cc-accent, var(--primary));
  box-shadow: 0 10px 22px -8px color-mix(in srgb, var(--cc-accent, var(--brown)) 55%, rgba(60, 50, 35, 0.5)),
              0 0 0 4px var(--surface),
              inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.cc-logo img { width: 100%; height: 100%; object-fit: cover; }
.cc-name { font-size: var(--fs-xl); font-weight: 600; letter-spacing: -0.015em; color: var(--ink); }
.cc-tag { color: var(--muted); font-size: var(--fs-sm); line-height: 1.5; min-height: 1.5em; flex: 1; }
.cc-stats {
  display: flex; gap: var(--sp-4); flex-wrap: wrap;
  font-size: var(--fs-xs); color: var(--ink-2);
  margin-top: var(--sp-1); padding-top: var(--sp-3); border-top: 1px solid var(--border);
}
.cc-stats span { display: inline-flex; align-items: center; gap: 5px; }
.cc-stats svg { color: var(--cc-accent, var(--clay)); opacity: 0.9; }
.cc-enter { margin-top: var(--sp-4); display: inline-flex; align-items: center;
  justify-content: center; gap: 8px; }
.cc-enter svg { transition: transform 200ms ease; }
.clinic-card:hover .cc-enter svg { transform: translateX(3px); }

/* "new clinic" card */
.clinic-card.cc-new {
  align-items: center; justify-content: center; text-align: center; gap: var(--sp-2);
  padding: var(--sp-8) var(--sp-5); min-height: 320px; cursor: pointer;
  border-style: dashed; border-color: var(--border-2); box-shadow: none;
  background:
    radial-gradient(440px 220px at 50% 122%, rgba(172, 137, 89, 0.12), transparent),
    var(--surface-2);
}
.clinic-card.cc-new::after { display: none; }
.clinic-card.cc-new:hover { transform: translateY(-4px); border-color: var(--clay);
  background: radial-gradient(440px 220px at 50% 122%, rgba(172, 137, 89, 0.16), transparent), var(--surface); }
.cc-plus {
  width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center;
  background: var(--clay-soft); color: var(--clay); margin-bottom: var(--sp-1);
  transition: transform 240ms cubic-bezier(.22, .7, .28, 1);
}
.clinic-card.cc-new:hover .cc-plus { transform: scale(1.06) rotate(90deg); }

@media (max-width: 940px) { .clinic-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) {
  .clinic-grid { grid-template-columns: 1fr; }
  .picker-body { padding: var(--sp-8) var(--sp-4); }
  .picker-top { padding: var(--sp-4); }
}
@media (hover: none) {
  .cc-tools { opacity: 1; transform: none; }
  .cc-cover-hint { opacity: 1; transform: none; }
}

/* ---- clinic business image upload ---- */
.cc-logo-edit { position: relative; cursor: pointer; }
.cc-logo-cam {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(40, 34, 24, 0.55); color: #fff;
  opacity: 0; transition: opacity 150ms ease;
}
.cc-logo-edit:hover .cc-logo-cam { opacity: 1; }
.nc-logo-pick {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3); border: 1px dashed var(--border-2);
  border-radius: var(--r-md); cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}
.nc-logo-pick:hover { border-color: var(--clay); background: var(--surface-2); }
.nc-logo-preview {
  width: 46px; height: 46px; border-radius: 11px; flex-shrink: 0;
  display: grid; place-items: center; overflow: hidden;
  background: var(--primary-soft); color: var(--primary);
}
.nc-logo-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ---- edit clinic: brand-accent swatches ---- */
.ec-swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ec-swatch {
  width: 28px; height: 28px; border-radius: 8px; cursor: pointer; border: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 1px 2px rgba(60, 50, 35, 0.18);
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.ec-swatch:hover { transform: translateY(-1px); }
.ec-swatch.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--ink); }
.ec-custom {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  position: relative; overflow: hidden; cursor: pointer;
  border: 1px dashed var(--border-2); color: var(--muted);
  transition: border-color 120ms ease, color 120ms ease;
}
.ec-custom:hover { border-color: var(--clay); color: var(--clay); }
.ec-custom input[type="color"] {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; cursor: pointer; border: none; padding: 0;
}

/* ---- Treatments view ---- */
.tx-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); flex-wrap: wrap; margin-bottom: var(--sp-4);
}
.tx-cats { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.tx-cat {
  padding: 6px 14px; border-radius: var(--r-pill); cursor: pointer;
  font-size: var(--fs-sm); font-weight: 600; color: var(--ink-2);
  background: var(--surface-2); border: 1px solid var(--border);
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}
.tx-cat:hover { border-color: var(--border-2); background: var(--surface-3); }
.tx-cat.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.tx-search { min-width: 220px; }
.tx-search .input { width: 100%; }

.tx-card { transition: transform 160ms ease, box-shadow 160ms ease; }
.tx-card:hover { transform: translateY(-3px); box-shadow: var(--sh-md); }
.tx-card.is-hidden { opacity: 0.62; }
.tx-thumb {
  position: relative; height: 132px;
  background-color: var(--surface-3); background-position: center;
  background-size: cover; background-repeat: no-repeat;
  display: grid; place-items: center;
}
.tx-thumb-ph { color: var(--border-2); }
.tx-flag {
  position: absolute; top: 10px; right: 10px;
  padding: 3px 9px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 600; color: #fff;
  background: rgba(40, 34, 24, 0.62); backdrop-filter: blur(2px);
}
.tx-meta {
  display: flex; align-items: center; gap: 5px;
  margin-top: var(--sp-3); font-size: var(--fs-xs); color: var(--muted);
}
.tx-meta svg { opacity: 0.8; }

/* treatment editor — photo picker + per-branch prices */
.tx-img-pick {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-3); margin-bottom: var(--sp-4);
  border: 1px dashed var(--border-2); border-radius: var(--r-md);
}
.tx-img-prev {
  width: 84px; height: 84px; border-radius: var(--r-md); flex-shrink: 0;
  display: grid; place-items: center; overflow: hidden;
  background: var(--primary-soft); color: var(--primary);
}
.tx-img-prev img { width: 100%; height: 100%; object-fit: cover; }
.tx-img-side { display: flex; flex-direction: column; gap: var(--sp-2); }
.tx-img-side .btn label { cursor: pointer; }
.tx-branch-prices { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-2); }
.tx-bp-row { display: flex; align-items: center; gap: var(--sp-2); }
.tx-bp-row span { flex: 1; }
.tx-bp-row .input { max-width: 116px; }
@media (max-width: 720px) { .tx-branch-prices { grid-template-columns: 1fr; } }

/* ---------- AI markdown (bold / italic / lists / tables in chat replies) ---------- */
.md-body { line-height: 1.55; }
.md-body .md-p { margin: 0 0 .5em; }
.md-body .md-p:first-child, .md-body .md-h:first-child,
.md-body .md-list:first-child, .md-body .md-tablewrap:first-child { margin-top: 0; }
.md-body .md-p:last-child, .md-body .md-list:last-child,
.md-body .md-tablewrap:last-child, .md-body .md-h:last-child { margin-bottom: 0; }
.md-body strong { font-weight: 700; }
.md-body em { font-style: italic; }
.md-body del { opacity: .7; }
.md-body a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.md-body .md-list { margin: .25em 0 .55em; padding-left: 1.3em; }
.md-body .md-list li { margin: .12em 0; }
.md-body .md-list li::marker { color: var(--primary); }
.md-body .md-h { font-weight: 700; line-height: 1.3; margin: .55em 0 .3em; }
.md-body .md-h1 { font-size: 1.16em; }
.md-body .md-h2 { font-size: 1.08em; }
.md-body .md-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .86em; background: rgba(120, 110, 90, .16); padding: .06em .36em; border-radius: 5px; }
.md-body .md-quote { margin: .35em 0; padding: .1em 0 .1em .7em;
  border-left: 3px solid var(--border-2); color: var(--ink-2); }
.md-body .md-hr { border: 0; border-top: 1px solid var(--border-2); margin: .6em 0; }
.md-body .md-tablewrap { overflow-x: auto; margin: .4em 0 .5em; }
.md-body .md-table { border-collapse: collapse; width: 100%; font-size: .92em; }
.md-body .md-table th, .md-body .md-table td {
  border: 1px solid var(--border-2); padding: 5px 9px; text-align: left; vertical-align: top; }
.md-body .md-table th { background: rgba(120, 110, 90, .12); font-weight: 600; }

/* ---------- Knowledge Base: article rows + Hours & Info ---------- */
.kb-type {
  display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0;
  padding: 4px 10px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 600; white-space: nowrap;
  color: var(--c, var(--ink-2));
  background: color-mix(in srgb, var(--c, var(--ink-2)) 15%, transparent);
}
.kb-type svg { width: 12px; height: 12px; }
.kb-art-row { transition: background 140ms ease; }
.kb-art-row:hover { background: var(--surface-2); }
.kb-art-row:last-child { border-bottom: none !important; }

.kb-branch { transition: transform 160ms ease, box-shadow 160ms ease; }
.kb-branch:hover { transform: translateY(-3px); box-shadow: var(--sh-md); }
.kb-branch-sum { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-sm); color: var(--ink-2); }
.kb-seg { display: flex; justify-content: space-between; gap: var(--sp-4); }
.kb-seg b { font-weight: 600; color: var(--ink-1, var(--ink-2)); }
.kb-addr {
  display: flex; align-items: flex-start; gap: 6px;
  margin-top: var(--sp-3); font-size: var(--fs-xs); color: var(--muted);
}
.kb-addr svg { flex-shrink: 0; margin-top: 2px; opacity: .8; }

.kb-hours-edit { display: flex; flex-direction: column; gap: 8px; }
.kb-he-row { display: grid; grid-template-columns: 92px 42px 1fr; align-items: center; gap: 12px; }
.kb-he-day { font-weight: 600; font-size: var(--fs-sm); }
.kb-he-times { display: flex; align-items: center; gap: 8px; }
.kb-he-times .select { padding: 6px 8px; flex: 1; min-width: 0; }
.kb-he-row.is-closed .kb-he-times { opacity: .35; pointer-events: none; }

/* ---- Doctors & Staff (team) + per-branch schedule ---- */
.tm-branch .card-head { display: flex; align-items: center; justify-content: space-between; }
.tm-row { display: flex; align-items: center; gap: var(--sp-3);
  padding: 10px 8px; border-bottom: 1px solid var(--border); }
.tm-branch .card-body .tm-row:last-child { border-bottom: none; }
.tm-row-main { flex: 1; min-width: 0; }
.tm-row-main .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-row.row-click { cursor: pointer; border-radius: var(--r-sm); transition: background 140ms ease; }
.tm-row.row-click:hover { background: var(--surface-2); }
.tm-row.row-click > .muted:last-child { opacity: 0; transition: opacity 140ms ease; }
.tm-row.row-click:hover > .muted:last-child { opacity: 1; }

.tm-sched-bar { display: flex; align-items: center; gap: var(--sp-3);
  flex-wrap: wrap; margin-bottom: 16px; }
.tm-sched { padding: 0; overflow: hidden; }
.tm-slot { display: flex; align-items: center; gap: var(--sp-3);
  padding: 12px var(--sp-5); border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 140ms ease; }
.tm-slot:last-child { border-bottom: none; }
.tm-slot:hover { background: var(--surface-2); }
.tm-slot-time { width: 58px; flex-shrink: 0; color: var(--ink); }
.tm-slot-main { flex: 1; min-width: 0; }
.tm-slot-doc { flex-shrink: 0; }
.tm-slot-doc .select { padding: 6px 10px; font-size: var(--fs-sm); min-width: 150px; }
@media (max-width: 720px) {
  .tm-slot { flex-wrap: wrap; }
  .tm-slot-doc .select { min-width: 120px; }
}

/* ---- customer "products of interest" ---- */
.cust-prod { display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border); }
.cust-prod:last-child { border-bottom: none; }
.cust-prod-ic { width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  overflow: hidden; display: grid; place-items: center;
  background: var(--surface-3); color: var(--clay); }
.cust-prod-ic img { width: 100%; height: 100%; object-fit: cover; }
.cust-prod-main { flex: 1; min-width: 0; }
.cust-prod-main .strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
