/* Dentopia / Patient Reviews — components. Uses tokens.css only. */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--page);
  font-family: var(--font);
  font-size: var(--fs-ui);
  line-height: var(--lh-ui);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.icon { display: block; flex-shrink: 0; width: 16px; height: 16px; fill: currentColor; }
.icon-14 { width: 14px; height: 14px; }
.icon-18 { width: 18px; height: 18px; }
.icon-20 { width: 20px; height: 20px; }
.muted { color: var(--ink-40); }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- App frame ---------- */
.app {
  position: fixed; inset: var(--frame-inset);
  display: grid; grid-template-columns: var(--sidebar-w) 1fr;
  background: var(--surface);
  border-radius: var(--r-frame);
  box-shadow: inset 0 0 0 1px var(--line);
  overflow: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--surface-sunken);
  padding: 24px 12px 16px;
  display: flex; flex-direction: column; min-height: 0;
}
.brand { padding: 0 10px 24px; }
.brand-name {
  display: block; font-size: var(--fs-body); line-height: var(--lh-body);
  font-weight: var(--fw-semibold); font-style: italic; letter-spacing: 0.32px;
  color: var(--ink-strong);
}
.brand-sub { display: block; margin-top: 2px; font-size: var(--fs-tiny); line-height: var(--lh-tiny); color: var(--ink-40); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  height: 38px; padding: 0 10px; border-radius: var(--r-control);
  font-size: var(--fs-ui); line-height: var(--lh-ui); color: var(--ink-80);
}
.nav-item .icon { width: 20px; height: 20px; color: var(--ink-60); }
.nav-item .count { margin-left: auto; font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-40); }
.nav-item:hover { background: var(--fill); }
.nav-item.is-active { background: var(--fill); color: var(--ink-strong); font-weight: var(--fw-semibold); }
.nav-item.is-active .icon { color: var(--ink); }

.mode-card {
  margin-top: auto;
  background: var(--surface); border-radius: var(--r-control);
  box-shadow: inset 0 0 0 1px var(--line);
  padding: 12px;
}
.mode-card-head { display: flex; align-items: center; gap: 8px; font-size: var(--fs-small); line-height: var(--lh-small); font-weight: var(--fw-semibold); }
.progress { margin-top: 8px; height: 4px; border-radius: var(--r-round); background: var(--fill-strong); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: var(--r-round); background: var(--ink-strong); }
.mode-card-meta { margin-top: 8px; font-size: var(--fs-tiny); line-height: var(--lh-tiny); color: var(--ink-40); }
.mode-card-link { display: inline-block; margin-top: 6px; font-size: var(--fs-small); line-height: var(--lh-small); color: var(--link); }

/* ---------- Main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  flex: none; height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 var(--content-pad-r) 0 var(--content-pad-l);
  border-bottom: 1px solid var(--line);
}
.crumbs { display: flex; align-items: center; gap: 8px; font-size: var(--fs-ui); line-height: var(--lh-ui); }
.crumbs .sep, .crumbs .parent { color: var(--ink-40); }
.crumbs .current { color: var(--ink); font-weight: var(--fw-medium); }
.search {
  margin-left: auto; width: 300px; height: 36px;
  display: flex; align-items: center; gap: 10px; padding: 0 12px;
  background: var(--surface-sunken); border-radius: var(--r-control);
  color: var(--ink-40);
}
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font: inherit; font-size: var(--fs-ui); color: var(--ink); }
.search input::placeholder { color: var(--ink-40); }

.scroll { flex: 1; min-height: 0; overflow: auto; }
.section { padding: 0 var(--content-pad-r) 0 var(--content-pad-l); }
.summary { padding-top: 22px; font-size: var(--fs-ui); line-height: var(--lh-ui); color: var(--ink-40); }

/* Stat cards */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; padding-top: 16px; padding-bottom: 16px; }
.stat { border-radius: var(--r-card); box-shadow: inset 0 0 0 1px var(--line); padding: 14px 16px; }
.stat-label { display: flex; align-items: center; gap: 6px; font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-40); }
.stat-value { margin-top: 6px; font-size: var(--fs-title); line-height: var(--lh-title); font-weight: var(--fw-semibold); }

/* Dots */
.dot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: var(--r-round); background: var(--grey); }
.dot-6 { width: 6px; height: 6px; }
.dot.green { background: var(--green); } .dot.red { background: var(--red); }
.dot.yellow { background: var(--yellow); } .dot.blue { background: var(--blue); }
.dot.indigo { background: var(--indigo); } .dot.purple { background: var(--purple); }
.dot.grey { background: var(--grey); }

/* Filter pills */
.filters { display: flex; align-items: flex-start; gap: 16px; padding-bottom: 14px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.pill {
  display: inline-flex; align-items: center; gap: 8px;
  height: var(--control-h); padding: 0 12px; border-radius: var(--r-control);
  box-shadow: inset 0 0 0 1px var(--line);
  font-size: var(--fs-ui); line-height: var(--lh-ui); white-space: nowrap;
}
.pill .n { color: var(--ink-40); }
.pill:hover { background: var(--fill); }
.pill.is-active { background: var(--ink-strong); color: var(--on-dark); box-shadow: none; }
.pill.is-active .n { color: var(--ink-40); color: rgba(255,255,255,0.6); }
.tools { display: flex; gap: 6px; flex: none; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--control-h); padding: 0 14px; border-radius: var(--r-control);
  font-size: var(--fs-ui); line-height: var(--lh-ui); white-space: nowrap;
}
.btn-lg { height: var(--control-h-lg); padding: 0 16px; }
.btn-secondary { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line-control); }
.btn-secondary:hover { background: var(--fill); }
.btn-primary { background: var(--ink-strong); color: var(--on-dark); font-weight: var(--fw-medium); }
.btn-primary:hover { background: #000; }
.btn-ghost { box-shadow: none; }
.btn-ghost:hover { background: var(--fill); }
.btn-block { width: 100%; }
.btn-icon { width: 32px; padding: 0; }
.btn[disabled], .btn.is-disabled { opacity: 0.4; pointer-events: none; }

/* ---------- Table ---------- */
.table { width: 100%; }
.thead, .trow {
  display: grid;
  grid-template-columns: 16px 28px minmax(0, 360px) minmax(0, 192px) minmax(0, 136px) minmax(0, 196px) minmax(0, 1fr) 72px;
  column-gap: 0; align-items: center;
  padding: 0 var(--content-pad-r) 0 var(--content-pad-l);
}
.thead { height: 25px; padding-bottom: 8px; align-items: start; border-bottom: 1px solid var(--line); font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-40); }
.thead .right, .trow .right { justify-self: end; }
.trow { height: var(--row-h); border-bottom: 1px solid var(--line-soft); }
.trow:hover { background: rgba(0,0,0,0.02); }
.check { width: 16px; height: 16px; border-radius: var(--r-check); box-shadow: inset 0 0 0 1px var(--line-check); }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  flex: none; width: 32px; height: 32px; border-radius: var(--r-round); background: var(--fill);
  display: grid; place-items: center;
  font-size: var(--fs-small); line-height: var(--lh-small); font-weight: var(--fw-semibold); color: var(--ink-60);
}
.avatar-36 { width: 36px; height: 36px; font-size: var(--fs-ui); line-height: var(--lh-ui); }
.who-text { min-width: 0; }
.who-name { display: flex; align-items: center; gap: 6px; font-size: var(--fs-ui); line-height: var(--lh-ui); font-weight: var(--fw-medium); }
.who-sub { font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-40); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-ui); line-height: var(--lh-ui); }
.status .icon { width: 14px; height: 14px; color: var(--ink-80); }
.cell { font-size: var(--fs-ui); line-height: var(--lh-ui); color: var(--ink-80); padding-right: 16px; min-width: 0; }
.cell-sub { font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-40); }
.cell-time { font-size: var(--fs-ui); line-height: var(--lh-ui); color: var(--ink); }

.tfoot {
  flex: none; height: 52px; display: flex; align-items: center;
  padding: 0 var(--content-pad-r) 0 var(--content-pad-l);
  border-top: 1px solid var(--line);
  font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-40);
}
.pager { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.pager a { height: 28px; min-width: 28px; padding: 0 12px; border-radius: var(--r-control); display: inline-flex; align-items: center; justify-content: center; font-size: var(--fs-ui); line-height: var(--lh-ui); color: var(--ink); }
.pager a.num { padding: 0; }
.pager a.is-current { background: var(--fill); }
.pager a.is-disabled { color: var(--ink-20); pointer-events: none; }

/* ---------- Detail view ---------- */
.detail { flex: 1; min-height: 0; display: grid; grid-template-columns: var(--list-w) minmax(0, 1fr) var(--panel-w); }
.list { border-right: 1px solid var(--line); overflow: auto; min-height: 0; }
.list-head {
  position: sticky; top: 0; background: var(--surface); z-index: 1;
  display: flex; align-items: center; gap: 12px; height: 57px; padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-ui); line-height: var(--lh-ui); font-weight: var(--fw-medium);
}
.list-head .count { margin-left: auto; font-size: var(--fs-small); line-height: var(--lh-small); font-weight: var(--fw-regular); color: var(--ink-40); }
.list-item { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
.list-item .dot { margin-top: 6px; }
.list-item:hover { background: rgba(0,0,0,0.02); }
.list-item.is-active { background: var(--fill); }
.list-name { font-size: var(--fs-ui); line-height: var(--lh-ui); font-weight: var(--fw-medium); }
.list-sub { margin-top: 2px; font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-40); }

.thread { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.thread-head { flex: none; display: flex; align-items: center; gap: 12px; height: 69px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.thread-who { min-width: 0; }
.thread-name { font-size: var(--fs-body); line-height: var(--lh-body); font-weight: var(--fw-semibold); }
.thread-phone { margin-top: 4px; display: flex; align-items: center; gap: 6px; font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-40); }
.thread-phone .icon { width: 14px; height: 14px; color: var(--ink); }
.thread-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.status-chip { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-radius: var(--r-control); box-shadow: inset 0 0 0 1px var(--line-control); font-size: var(--fs-ui); line-height: var(--lh-ui); }
.chat { flex: 1; min-height: 0; overflow: auto; background: var(--surface-sunken); padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.chat-label { align-self: center; font-size: var(--fs-tiny); line-height: var(--lh-tiny); color: var(--ink-40); }
.note { align-self: center; padding: 6px 12px; border-radius: var(--r-round); background: var(--fill); font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-60); text-align: center; }
.msg { max-width: 477px; display: flex; flex-direction: column; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.msg.in { align-self: flex-start; align-items: flex-start; }
.bubble { padding: 10px 14px; border-radius: var(--r-card); font-size: var(--fs-ui); line-height: var(--lh-ui); white-space: pre-wrap; }
.msg.out .bubble { background: var(--bubble-out); }
.msg.in .bubble { background: var(--bubble-in); }
.msg-meta { margin-top: 4px; font-size: var(--fs-tiny); line-height: var(--lh-tiny); color: var(--ink-40); }
.msg.out .msg-meta { padding-right: 4px; } .msg.in .msg-meta { padding-left: 4px; }

.panel { overflow: auto; min-height: 0; padding: 20px; display: flex; flex-direction: column; gap: 20px; }
.banner { height: 38px; display: flex; align-items: center; justify-content: center; gap: 8px; border-radius: var(--r-control); background: var(--fill); font-size: var(--fs-ui); line-height: var(--lh-ui); color: var(--ink-60); }
.panel-label { font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-40); margin-bottom: 10px; }
.kv { display: grid; grid-template-columns: 112px 1fr; row-gap: 10px; column-gap: 12px; font-size: var(--fs-ui); line-height: var(--lh-ui); }
.kv dt { color: var(--ink-40); } .kv dd { margin: 0; color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 4px 10px; border-radius: var(--r-round); background: var(--fill); font-size: var(--fs-small); line-height: var(--lh-small); }
.textarea { width: 100%; min-height: 72px; resize: vertical; border: 0; outline: 0; border-radius: var(--r-control); background: var(--surface-sunken); padding: 10px 12px; font: inherit; font-size: var(--fs-ui); line-height: var(--lh-ui); color: var(--ink); }
.textarea::placeholder { color: var(--ink-40); }
.row-2 { display: flex; gap: 6px; margin-top: 10px; }
.row-2 .btn-primary { flex: 1; }
.activity { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.activity li { display: grid; grid-template-columns: 6px 1fr; column-gap: 10px; }
.activity .dot { margin-top: 7px; }
.activity .what { font-size: var(--fs-ui); line-height: var(--lh-ui); }
.activity .when { font-size: var(--fs-tiny); line-height: var(--lh-tiny); color: var(--ink-40); }

/* ---------- Cases (list cards) ---------- */
.page-head { display: flex; align-items: flex-start; gap: 16px; padding-top: 24px; padding-bottom: 16px; }
.page-title { margin: 0; font-size: var(--fs-title); line-height: var(--lh-title); font-weight: var(--fw-semibold); }
.page-sub { margin-top: 8px; font-size: var(--fs-ui); line-height: var(--lh-ui); color: var(--ink-40); }
.page-head .btn { margin-left: auto; margin-top: 20px; }
.cards { display: flex; flex-direction: column; gap: 8px; padding-bottom: 24px; }
.card-row {
  display: grid; grid-template-columns: 16px 28px 200px 190px minmax(0, 1fr) 56px auto;
  align-items: center; column-gap: 0;
  height: 60px; padding: 12px 16px; border-radius: var(--r-card); box-shadow: inset 0 0 0 1px var(--line);
}
.card-row .num { font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-40); text-align: center; }
.card-row .msg-preview { font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-60); padding-right: 16px; }
.card-row .age { font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-40); }
.card-row .actions { display: flex; gap: 12px; align-items: center; }
.case-row {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 60px;
  padding: 0 16px;
  border-radius: var(--r-card);
  box-shadow: inset 0 0 0 1px var(--line);
  background: var(--surface);
}
.case-row .who-text { flex: 0 0 156px; width: 156px; min-width: 156px; }
.case-row .who-name, .case-row .who-sub { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-row .status-pill { flex: 0 0 140px; width: 140px; box-sizing: border-box; white-space: nowrap; }
.case-row .chip { flex: 0 0 84px; width: 84px; box-sizing: border-box; justify-content: flex-start; }
.case-row .msg-preview { flex: 1 1 0; min-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-row .age { flex: 0 0 40px; white-space: nowrap; color: var(--ink-40); font-size: var(--fs-small); line-height: var(--lh-small); }
.case-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; }
.case-status { display: flex; align-items: center; gap: 8px; margin: 0; }
.case-status select.input { width: auto; height: 32px; }
.resolve-note { display: inline-flex; align-items: center; gap: 6px; }
.resolve-note[hidden] { display: none !important; }
.resolve-note .input { width: 140px; height: 32px; }
.dash-head { align-items: center; }
.range-bar { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.range-bar .input, .range-bar .btn { height: 36px; margin: 0; border-radius: var(--r-control); box-sizing: border-box; }
.range-bar input.input { border: 0; outline: 0; background: var(--surface-sunken); font: inherit; font-size: var(--fs-ui); color: inherit; padding: 0 10px; }
.stats.dash-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: stretch; }
.dash-cards .stat { height: 100%; }

/* ---------- Modal ---------- */
.scrim {
  position: absolute; inset: 0; background: var(--scrim);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding: 24px 16px; box-sizing: border-box;
  overflow: hidden; z-index: 10;
}
.modal {
  width: 460px; max-width: 100%;
  max-height: calc(100vh - 48px);
  overflow-y: auto; overscroll-behavior: contain;
  min-height: 0; flex: 0 1 auto;
  background: var(--surface); border-radius: var(--r-frame); box-shadow: inset 0 0 0 1px var(--line);
  padding: 24px; display: flex; flex-direction: column; gap: 20px;
}
.modal-panel { padding: 0 0 24px; }
.modal-panel > *:not(.modal-head) { margin-left: 24px; margin-right: 24px; }
.modal-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: flex-start;
  background: var(--surface);
}
.modal-panel .modal-head { margin: 0; padding: 24px 24px 4px; }
.modal-title { margin: 0; font-size: var(--fs-modal); line-height: var(--lh-modal); font-weight: var(--fw-semibold); }
.modal-sub { margin-top: 2px; font-size: var(--fs-ui); line-height: var(--lh-ui); color: var(--ink-40); }
.modal-close { margin-left: auto; width: 32px; height: 32px; display: grid; place-items: center; border-radius: var(--r-control); color: var(--ink-40); }
.modal-close:hover { background: var(--fill); }
.box { border-radius: var(--r-card); box-shadow: inset 0 0 0 1px var(--line); padding: 14px 16px; }
.box-row { display: flex; align-items: center; gap: 12px; }
.box-title { font-size: var(--fs-ui); line-height: var(--lh-ui); font-weight: var(--fw-medium); }
.box-sub { font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-40); }
.info { border-radius: var(--r-card); background: var(--surface-sunken); padding: 14px 16px; }
.info .box-title { margin-bottom: 4px; }
.info p { margin: 0; font-size: var(--fs-ui); line-height: var(--lh-ui); color: var(--ink-60); }
.field-label { font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-40); margin-bottom: 6px; }
.segmented { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--r-control); background: var(--surface-sunken); }
.segmented span { height: 28px; padding: 0 12px; display: inline-flex; align-items: center; border-radius: var(--r-seg); font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-40); }
.segmented span.is-on { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.segmented.is-locked { opacity: 0.7; }
.input { height: 36px; padding: 0 12px; border-radius: var(--r-control); background: var(--surface-sunken); display: flex; align-items: center; font-size: var(--fs-ui); line-height: var(--lh-ui); }
.mini-table { width: 100%; border-collapse: collapse; font-size: var(--fs-ui); line-height: var(--lh-ui); }
.mini-table td { padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.mini-table td:last-child { text-align: right; color: var(--ink-60); }
.mini-table tr:last-child td { border-bottom: 0; }
.locked { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-small); line-height: var(--lh-small); color: var(--ink-40); }
.locked .icon { width: 14px; height: 14px; }

/* Patients, block list, sign-in */
.table-appts .thead,
.table-appts .trow {
  grid-template-columns: minmax(180px, 1.5fr) minmax(120px, 0.9fr) minmax(140px, 1fr) minmax(180px, 1.1fr) minmax(240px, auto);
}
.table-blocked .thead,
.table-blocked .trow {
  grid-template-columns: minmax(200px, 1.3fr) 110px minmax(160px, 1.6fr) 140px 110px;
  column-gap: 12px;
}
.table-blocked .who-sub { white-space: nowrap; }
.table-blocked .b-reason, .table-blocked .b-by { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-appts .trow { height: auto; min-height: var(--row-h); padding-top: 10px; padding-bottom: 10px; }
.appt-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.block-form { display: flex; align-items: center; gap: 6px; }
.block-form .input, .filters-form .input, .login-wrap .input, select.input {
  border: 0; outline: 0; font: inherit; color: inherit; background: var(--surface-sunken);
}
.block-form .input { width: 140px; }
.filters-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters-form .input, .filters-form select.input { width: auto; }
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-wrap .modal { width: min(460px, 100%); }
.login-wrap .brand { padding: 0; }
.login-wrap input.input { display: block; width: 100%; height: 40px; box-sizing: border-box; }
.login-wrap .btn { height: 40px; margin: 0; }
.stat-sub { margin-top: 4px; font-size: var(--fs-tiny); line-height: var(--lh-tiny); color: var(--ink-40); }
.overview { display: flex; flex-wrap: wrap; gap: 12px; padding-top: 16px; padding-bottom: 4px; }
.overview .stat { flex: 1 1 140px; }
.msg-sentiment { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; }
.status .chip { margin-left: 8px; }
.thread-head { height: auto; min-height: 69px; flex-wrap: wrap; padding-top: 12px; padding-bottom: 12px; }
.nav form { margin: 0; }
.nav form .nav-item { width: 100%; text-align: left; }

.dash-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.9fr); gap: 16px; padding: 0 var(--content-pad-r) 28px var(--content-pad-l); align-items: start; }
.dash-side { display: grid; gap: 16px; }
.panel-card { min-width: 0; border-radius: var(--r-card); box-shadow: inset 0 0 0 1px var(--line); padding: 16px; background: var(--surface); }
.panel-title { margin: 0 0 8px; font-size: var(--fs-body); line-height: var(--lh-body); font-weight: var(--fw-semibold); }
.needs-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.needs-table th { text-align: left; font-size: var(--fs-small); line-height: var(--lh-small); font-weight: var(--fw-medium); color: var(--ink-40); padding: 8px 8px 8px 0; }
.needs-table td { padding: 10px 8px 10px 0; border-top: 1px solid var(--line-soft); vertical-align: top; font-size: var(--fs-ui); line-height: var(--lh-ui); }
.needs-table th:nth-child(1),
.needs-table td:nth-child(1),
.needs-table th:nth-child(3),
.needs-table td:nth-child(3),
.needs-table th:nth-child(4),
.needs-table td:nth-child(4),
.needs-table th:nth-child(5),
.needs-table td:nth-child(5) { white-space: nowrap; width: 1%; }
.needs-table td:first-child .box-sub { white-space: nowrap; }
.summary-cell { max-width: none; width: auto; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--r-round); background: var(--fill); font-size: var(--fs-small); line-height: var(--lh-small); white-space: nowrap; }
.donut-wrap { display: flex; gap: 16px; align-items: center; }
.donut { width: 112px; height: 112px; flex: none; }
.legend { flex: 1; min-width: 0; }
.legend-row { display: flex; align-items: center; justify-content: flex-start; gap: 8px; padding: 4px 0; font-size: var(--fs-small); line-height: var(--lh-small); white-space: nowrap; }
.recent-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.recent-row .who-text { min-width: 0; }
.recent-row .who-sub { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.settings-grid { display: grid; gap: 12px; }
.status-form { display: grid; gap: 8px; min-width: 180px; }
.checkin-form { display: inline-flex; align-items: center; gap: 8px; }
.page-head .filters-form { margin-left: auto; }
.page-head .filters-form input[type="search"] { width: 240px; }

/* Empty state */
.empty { padding: 64px 0; text-align: center; color: var(--ink-40); font-size: var(--fs-ui); line-height: var(--lh-ui); }
.empty strong { display: block; color: var(--ink); font-weight: var(--fw-medium); margin-bottom: 4px; }

/* ---------- Mobile (under 768px) ---------- */
.mobile-only { display: none; }
@media (max-width: 767px) {
  .mobile-only { display: flex; }
  body { background: var(--surface); }
  .app { inset: 0; border-radius: 0; box-shadow: none; display: block; }
  .main { position: absolute; inset: 0 0 calc(64px + env(safe-area-inset-bottom)) 0; }

  /* Sidebar becomes the bottom tab bar */
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    height: calc(64px + env(safe-area-inset-bottom));
    padding: 6px 8px env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .brand, .mode-card { display: none; }
  .nav { flex-direction: row; gap: 4px; height: 52px; overflow-x: auto; }
  .nav-item {
    flex: 1 0 auto; flex-direction: column; justify-content: center; gap: 2px;
    height: 52px; min-width: 64px; padding: 0 4px; font-size: var(--fs-tiny); line-height: var(--lh-tiny);
  }
  .nav form .nav-item { min-width: 64px; }
  .nav-item .count { display: none; }
  .nav-item.is-active { background: none; }
  .nav-item:hover { background: none; }

  /* Top bar: crumbs, then full-width search */
  .topbar { height: auto; flex-wrap: wrap; gap: 10px; padding: 12px 16px; }
  .crumbs .parent, .crumbs .sep { display: none; }
  .crumbs .current { font-size: var(--fs-body); line-height: var(--lh-body); font-weight: var(--fw-semibold); }
  .search { width: 100%; margin-left: 0; height: 44px; }

  .section { padding-left: 16px; padding-right: 16px; }
  .summary { padding-top: 16px; }

  /* Stats and pills scroll sideways */
  .stats { display: flex; overflow-x: auto; scrollbar-width: none; }
  .stats::-webkit-scrollbar, .pills::-webkit-scrollbar { display: none; }
  .stat { flex: 0 0 140px; }
  .filters { padding-bottom: 8px; }
  .pills { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .pill { height: 36px; }
  .tools { display: none; }

  /* Table rows become cards */
  .thead { display: none; }
  .trow {
    height: auto; padding: 12px 16px; row-gap: 6px;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "who act" "status status";
  }
  .trow > .check, .trow > span:nth-child(2), .trow > .c-treat, .trow > .c-visit, .trow > .c-open { display: none; }
  .trow > .who { grid-area: who; }
  .trow > .status { grid-area: status; padding-left: 44px; }
  .trow > .c-act { grid-area: act; padding-right: 0; text-align: right; }
  .trow > .c-act .cell-sub { display: none !important; }
  .tfoot { padding: 0 16px; height: 48px; }
  .tfoot { font-size: 0; } /* hide the "Showing…" sentence, keep the pager */
  .pager { margin-left: 0; width: 100%; justify-content: space-between; }
  .pager a { font-size: var(--fs-ui); height: 36px; }

  /* Conversation: thread first, details stacked below */
  .detail { display: block; overflow: auto; }
  .list { display: none; }
  .thread { border-right: 0; }
  .thread-head { height: auto; padding: 12px 16px; flex-wrap: wrap; position: sticky; top: 0; background: var(--surface); z-index: 2; }
  .back { width: 32px; height: 32px; align-items: center; justify-content: center; margin-left: -8px; border-radius: var(--r-control); }
  .thread-actions { width: 100%; margin-left: 0; }
  .thread-actions .btn { flex: 1; height: 44px; }
  .status-chip { height: 44px; }
  .chat { overflow: visible; padding: 16px; }
  .msg { max-width: 85%; }
  .panel { overflow: visible; padding: 20px 16px 24px; border-top: 1px solid var(--line); }
  .row-2 .btn { height: 44px; }

  /* Cases: stacked cards */
  .page-head { flex-wrap: wrap; padding-top: 16px; }
  .page-title { display: none; }
  .page-sub { margin-top: 0; }
  .page-head .btn { margin: 0; }
  .card-row {
    height: auto; padding: 14px 16px; row-gap: 8px;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "who age" "status status" "msg msg" "actions actions";
  }
  .card-row > .check, .card-row > .num { display: none; }
  .card-row > .who-text { grid-area: who; }
  .card-row > .status { grid-area: status; }
  .card-row > .msg-preview { grid-area: msg; white-space: normal; padding-right: 0; }
  .card-row > .age { grid-area: age; }
  .card-row > .actions { grid-area: actions; }
  .card-row .actions .btn { flex: 1; height: 44px; }
  .table-appts .trow {
    height: auto;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "who" "status" "when" "pract" "act";
  }
  .table-appts .trow > .who { grid-area: who; }
  .table-appts .trow > .status { grid-area: status; padding-left: 44px; }
  .table-appts .trow > .c-visit { display: block; grid-area: when; padding-left: 44px; }
  .table-appts .trow > .c-treat { display: block; grid-area: pract; padding-left: 44px; }
  .table-appts .trow > .c-open { display: flex; grid-area: act; justify-content: flex-start; padding-left: 44px; }
  .table-blocked .trow {
    height: auto;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "who act" "when when" "reason reason" "by by";
    row-gap: 4px;
    padding: 12px 16px;
  }
  .table-blocked .trow > .who { grid-area: who; }
  .table-blocked .trow > .b-when { display: block; grid-area: when; padding-left: 44px; }
  .table-blocked .trow > .b-reason { display: block; grid-area: reason; padding-left: 44px; white-space: normal; }
  .table-blocked .trow > .b-by { display: block; grid-area: by; padding-left: 44px; }
  .table-blocked .trow > .right { grid-area: act; justify-self: end; }
  .table-appts .appt-actions { flex-wrap: wrap; justify-content: flex-start; width: 100%; }
  .block-form { flex-wrap: wrap; width: 100%; }
  .block-form .input { width: 100%; height: 44px; }
  .block-form .btn, .table-appts .appt-actions > form .btn { height: 44px; }

  /* Modal becomes a full-height sheet */
  .scrim { position: fixed; padding: 24px 0 0; justify-content: flex-end; align-items: stretch; z-index: 30; overflow: hidden; }
  .modal { width: 100%; max-height: calc(100vh - 48px); overflow-y: auto; border-radius: var(--r-frame) var(--r-frame) 0 0; padding: 20px 16px calc(24px + env(safe-area-inset-bottom)); }
  .modal-panel { padding: 0 0 calc(24px + env(safe-area-inset-bottom)); }
  .modal-panel > *:not(.modal-head) { margin-left: 16px; margin-right: 16px; }
  .modal-panel .modal-head { margin: 0; padding: 20px 16px 4px; }
  .input { height: 44px; }
  .dash-cards { grid-template-columns: 1fr 1fr; }
  .dash-grid { grid-template-columns: 1fr; padding: 12px 16px 24px; }
  .donut-wrap { align-items: flex-start; }
  .page-head .filters-form { margin-left: 0; width: 100%; }
  .page-head .filters-form input[type="search"] { width: 100%; height: 44px; }
}
