/* ============================================================
   Kanbar Studio — design system
   A quiet atelier: warm paper, espresso ink, terracotta accent.
   Fraunces (display serif) + Karla (humanist sans).
   Mobile-first; sidebar appears ≥ 1024px.
   ============================================================ */

:root {
  --paper:   #F6F1EA;
  --surface: #FFFDF9;
  --sunken:  #EFE7DB;
  --ink:     #262019;
  --ink-2:   #55493C;
  --muted:   #8A7C6B;
  --line:    #E5DBCB;
  --line-2:  #D8CCB8;

  --accent:      #A65A3A;   /* terracotta — Lebanon Dental Studio */
  --accent-ink:  #7E4128;
  --accent-soft: #F4E4D9;
  --sage:        #3E6B5C;   /* C.Metric */
  --sage-soft:   #E2EBE6;

  --ok:      #4A7A47;
  --ok-soft: #E4EEDD;
  --warn:    #A3742A;
  --warn-soft:#F5E9D2;
  --bad:     #A03B32;
  --bad-soft:#F6E0DC;
  --info-soft:#E8E4F0;
  --info:    #5B5378;

  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body: 'Karla', 'Segoe UI', system-ui, sans-serif;

  --r-sm: 8px; --r-md: 14px; --r-lg: 20px;
  --shadow: 0 1px 2px rgba(56,44,30,.06), 0 6px 24px -12px rgba(56,44,30,.18);
  --tap: 46px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 85% -10%, #FBF4E8 0%, transparent 60%),
    radial-gradient(900px 600px at -10% 100%, #F1E9DC 0%, transparent 55%),
    var(--paper);
  min-height: 100vh;
}

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.01em; margin: 0 0 .4em; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.15rem; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--sunken); padding: .1em .35em; border-radius: 5px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.mt { margin-top: 1rem; } .mb { margin-bottom: 1rem; }
.ic { width: 21px; height: 21px; flex: 0 0 auto; }

/* ---------- shell ---------- */
.frame { min-height: 100vh; display: flex; flex-direction: column; }
.content { flex: 1; width: 100%; max-width: 880px; margin: 0 auto; padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); }
.content-wide { max-width: 1180px; }
.frame-bare .content { display: flex; align-items: center; justify-content: center; padding-bottom: 16px; }

.sidebar { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top-title { font-size: 1.35rem; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-back { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%; color: var(--ink); }
.top-back:hover { background: var(--sunken); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.top-search {
  display: none; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 14px; color: var(--muted);
}
.top-search input { border: 0; outline: 0; background: transparent; font: inherit; width: 150px; color: var(--ink); }

/* mobile bottom tab bar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 2px 7px; font-size: .68rem; letter-spacing: .02em;
  color: var(--muted); position: relative;
}
.tab:hover { text-decoration: none; }
.tab.active { color: var(--accent-ink); }
.tab.active .ic { stroke-width: 2.1; }
.tab-dot { position: absolute; top: 7px; right: calc(50% - 16px); width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }

@media (min-width: 1024px) {
  .tabbar { display: none; }
  .top-search { display: inline-flex; }
  .frame { margin-left: 232px; }
  .content { padding-bottom: 40px; }
  .sidebar {
    display: flex; flex-direction: column;
    position: fixed; inset: 0 auto 0 0; width: 232px; z-index: 60;
    background: linear-gradient(180deg, #2B241C 0%, #241E17 100%);
    color: #EFE7DA; padding: 22px 14px 18px;
  }
  .brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 22px; }
  .brand-mark {
    width: 42px; height: 42px; border-radius: 12px;
    display: grid; place-items: center;
    background: var(--accent); color: #FFF6EC;
    font-family: var(--font-display); font-size: 1.15rem; font-weight: 600;
  }
  .brand-text { display: flex; flex-direction: column; line-height: 1.1; }
  .brand-name { font-family: var(--font-display); font-size: 1.25rem; }
  .brand-sub { font-size: .72rem; letter-spacing: .28em; text-transform: uppercase; color: #B7A895; }
  .side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
  .nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 12px; border-radius: 10px;
    color: #C9BCA8; font-size: .95rem;
  }
  .nav-item:hover { background: rgba(255,255,255,.05); color: #F2EADC; text-decoration: none; }
  .nav-item.active { background: rgba(166,90,58,.22); color: #FFD9C4; }
  .nav-badge {
    margin-left: auto; font-style: normal; font-size: .72rem;
    background: var(--bad); color: #fff; border-radius: 999px; padding: 1px 8px;
  }
  .side-foot { border-top: 1px solid rgba(255,255,255,.08); padding: 14px 10px 0; display: flex; flex-direction: column; gap: 2px; }
  .side-user { font-size: .85rem; color: #E8DECD; }
  .side-logout { font-size: .78rem; color: #A4937C; }
  .side-logout:hover { color: #FFD9C4; }
}

/* ---------- cards, grids ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.card.pad { padding: 20px; }
.card-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 16px 20px 0;
}
.card-head h2, .card-head h3 { margin-bottom: 0; }
.card-body { padding: 14px 20px 18px; }
.grid-2 { display: grid; gap: 16px; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.stat-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 760px) { .stat-row { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.stat b { display: block; font-family: var(--font-display); font-size: 1.55rem; font-weight: 500; line-height: 1.15; }
.stat span { font-size: .78rem; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.stat.stat-accent { background: linear-gradient(135deg, var(--accent-soft), var(--surface) 70%); }
.stat.stat-bad b { color: var(--bad); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 10px 18px;
  border: 1px solid var(--line-2); border-radius: 12px;
  background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; font-size: .95rem;
  cursor: pointer; text-decoration: none;
  transition: transform .06s ease, background .15s ease;
}
.btn:hover { text-decoration: none; background: var(--sunken); }
.btn:active { transform: scale(.985); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #FFF6EC; }
.btn-primary:hover { background: var(--accent-ink); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--sunken); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--line-2)); }
.btn-danger:hover { background: var(--bad-soft); }
.btn-sm { min-height: 36px; padding: 5px 12px; font-size: .85rem; border-radius: 10px; }
.btn-wa { background: #128C50; border-color: #128C50; color: #fff; }
.btn-wa:hover { background: #0E7040; }
.btn-block { width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* floating action button (mobile) */
.fab {
  position: fixed; right: 18px; bottom: calc(76px + env(safe-area-inset-bottom)); z-index: 45;
  width: 58px; height: 58px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent); color: #FFF6EC;
  box-shadow: 0 8px 24px -6px rgba(126,65,40,.55);
}
.fab .ic { width: 26px; height: 26px; }
.fab:hover { text-decoration: none; background: var(--accent-ink); }
@media (min-width: 1024px) { .fab { display: none; } }

/* ---------- chips / badges ---------- */
.chip {
  display: inline-block; padding: 3px 11px; border-radius: 999px;
  font-size: .75rem; font-weight: 700; letter-spacing: .03em;
  background: var(--sunken); color: var(--ink-2); white-space: nowrap;
}
.chip-completed, .chip-paid, .chip-received, .chip-booked, .chip-done, .chip-confirmed, .chip-active
  { background: var(--ok-soft); color: var(--ok); }
.chip-in_progress, .chip-sent, .chip-contacted, .chip-scheduled, .chip-expected
  { background: var(--warn-soft); color: var(--warn); }
.chip-cancelled, .chip-no_show, .chip-dismissed, .chip-waived { background: var(--sunken); color: var(--muted); }
.chip-planned, .chip-pending, .chip-draft, .chip-preparing { background: var(--info-soft); color: var(--info); }
.chip-no_answer, .chip-remake, .chip-overdue { background: var(--bad-soft); color: var(--bad); }
.chip-snoozed { background: var(--sage-soft); color: var(--sage); }
.clinic-chip {
  display: inline-block; padding: 2px 10px; border-radius: 7px;
  font-size: .72rem; font-weight: 700; letter-spacing: .05em;
  color: var(--chip, var(--accent)); background: color-mix(in srgb, var(--chip, var(--accent)) 13%, #fff);
  border: 1px solid color-mix(in srgb, var(--chip, var(--accent)) 30%, transparent);
  white-space: nowrap;
}
.alert-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bad-soft); color: var(--bad);
  border: 1px solid color-mix(in srgb, var(--bad) 25%, transparent);
  padding: 5px 12px; border-radius: 10px; font-size: .85rem; font-weight: 700;
}

/* ---------- flash ---------- */
.flash { padding: 12px 18px; border-radius: var(--r-md); margin-bottom: 14px; font-weight: 600; border: 1px solid; }
.flash-ok   { background: var(--ok-soft);  color: var(--ok);  border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.flash-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.flash-err  { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }

/* ---------- forms ---------- */
form { margin: 0; }
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: .8rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 5px; }
.field .hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=search], input[type=email], input[type=password], input[type=tel],
input[type=number], input[type=date], input[type=time], input[type=datetime-local], select, textarea {
  width: 100%; min-height: var(--tap);
  padding: 10px 14px;
  border: 1px solid var(--line-2); border-radius: 12px;
  background: #FFFEFB; color: var(--ink);
  font: inherit;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; border-color: var(--accent); }
.form-grid { display: grid; gap: 0 16px; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid .span-2 { grid-column: span 2; } }
fieldset { border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 16px 6px; margin: 0 0 16px; }
legend { font-family: var(--font-display); font-size: 1.02rem; padding: 0 8px; }
.seg { display: flex; border: 1px solid var(--line-2); border-radius: 12px; overflow: hidden; }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(var(--tap) - 2px); padding: 4px 8px;
  font-size: .88rem; font-weight: 600; color: var(--muted); cursor: pointer;
  border-left: 1px solid var(--line);
}
.seg label:first-child span { border-left: 0; }
.seg input:checked + span { background: var(--accent-soft); color: var(--accent-ink); }
.check { display: flex; align-items: center; gap: 10px; min-height: var(--tap); font-weight: 600; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }

/* ---------- tables / list rows ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .93rem; }
.tbl th {
  text-align: left; font-size: .72rem; letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.rowlink { cursor: pointer; }
.tbl tr.rowlink:hover { background: #FBF6EE; }
.tbl .right { text-align: right; }

.rowlist { display: flex; flex-direction: column; }
.row-item {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 20px; border-bottom: 1px solid var(--line);
  color: inherit; min-height: 60px;
}
.row-item:last-child { border-bottom: 0; }
.row-item:hover { background: #FBF6EE; text-decoration: none; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-sub { font-size: .84rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.row-end { text-align: right; flex-shrink: 0; }
.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 600; font-size: .95rem;
  background: var(--accent-soft); color: var(--accent-ink);
}
.avatar.av-sage { background: var(--sage-soft); color: var(--sage); }

/* ---------- timeline ---------- */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--line-2); border-radius: 2px; }
.tl-item { position: relative; padding: 0 0 18px; }
.tl-item::before {
  content: ''; position: absolute; left: -21px; top: 5px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--accent);
}
.tl-date { font-size: .78rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }

/* ---------- dental chart ---------- */
.dental-chart { user-select: none; }
.dc-arch { display: flex; justify-content: center; gap: 3px; margin-bottom: 6px; flex-wrap: nowrap; }
.dc-gap { width: 12px; }
.dc-tooth {
  width: clamp(28px, 5.4vw, 40px); height: 52px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 1.5px solid var(--line-2); border-radius: 9px;
  background: #FFFEFB; cursor: pointer;
  font-size: .72rem; font-weight: 700; color: var(--ink-2);
  transition: all .12s ease;
}
.dc-tooth svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.dc-tooth:hover { border-color: var(--accent); }
.dc-tooth.sel { background: var(--accent); border-color: var(--accent-ink); color: #FFF6EC; transform: translateY(-2px); }
.dc-tooth.has-planned { box-shadow: inset 0 -4px 0 var(--info); }
.dc-tooth.has-progress { box-shadow: inset 0 -4px 0 var(--warn); }
.dc-tooth.has-done { box-shadow: inset 0 -4px 0 var(--ok); }
.dc-legend { display: flex; gap: 16px; justify-content: center; margin-top: 10px; font-size: .76rem; color: var(--muted); flex-wrap: wrap; }
.dc-legend i { display: inline-block; width: 14px; height: 5px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }
.dc-quick { display: flex; gap: 8px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }

/* ---------- calendar ---------- */
.cal-controls { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.cal-day-col { min-width: 0; }
.cal-day-head { text-align: center; font-size: .78rem; font-weight: 700; color: var(--muted); padding: 6px 0; }
.cal-day-head.today { color: var(--accent-ink); }
.cal-day-head b { display: block; font-family: var(--font-display); font-size: 1.2rem; color: var(--ink); }
.cal-day-head.today b { color: var(--accent); }
.appt {
  display: block; padding: 8px 10px; margin-bottom: 6px;
  border-radius: 10px; border-left: 4px solid var(--chip, var(--accent));
  background: color-mix(in srgb, var(--chip, var(--accent)) 10%, var(--surface));
  font-size: .8rem; line-height: 1.3; color: inherit;
}
.appt:hover { text-decoration: none; filter: brightness(.97); }
.appt b { display: block; }
.appt.is-cancelled, .appt.is-no_show { opacity: .45; text-decoration: line-through; }
.appt time { font-weight: 700; color: var(--ink-2); }
.day-agenda .appt { font-size: .95rem; padding: 14px; }

/* month grid */
.cal-month { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cm-head { text-align: center; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 4px 0; }
.cm-cell {
  min-height: 96px; border: 1px solid var(--line); border-radius: 10px;
  background: #FFFEFB; padding: 6px; display: flex; flex-direction: column; gap: 3px;
}
.cm-other { opacity: .45; background: transparent; }
.cm-today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cm-daynum { font-family: var(--font-display); font-weight: 600; color: var(--ink); align-self: flex-end; padding: 0 3px; }
.cm-today .cm-daynum { color: var(--accent-ink); }
.cm-daynum:hover { text-decoration: none; background: var(--sunken); border-radius: 6px; }
.cm-appt {
  display: block; font-size: .68rem; line-height: 1.25; padding: 2px 6px;
  border-radius: 6px; border-left: 3px solid var(--chip, var(--accent));
  background: color-mix(in srgb, var(--chip, var(--accent)) 11%, var(--surface));
  color: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cm-appt:hover { text-decoration: none; filter: brightness(.96); }
.cm-appt.is-cancelled, .cm-appt.is-no_show { opacity: .4; text-decoration: line-through; }
.cm-more { font-size: .66rem; color: var(--muted); padding-left: 6px; }

/* procedure step chips */
.steps-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.step-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .74rem; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: var(--sunken); color: var(--muted); border: 1px solid var(--line-2);
}
.step-chip.done { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.step-chip form { display: inline; }
.step-chip button {
  border: 0; background: none; font: inherit; color: var(--accent-ink);
  cursor: pointer; padding: 0; font-weight: 700;
}
.step-chip button:hover { text-decoration: underline; }
.step-arrow { color: var(--line-2); font-size: .8rem; }

/* ---------- bar chart (server-rendered) ---------- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 8px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; height: 100%; justify-content: flex-end; }
.bar i { display: block; width: 100%; max-width: 44px; border-radius: 6px 6px 0 0; background: linear-gradient(180deg, var(--accent) 0%, #C07A55 100%); }
.bar i.bar-sage { background: linear-gradient(180deg, var(--sage) 0%, #5E8A79 100%); }
.bar span { font-size: .68rem; color: var(--muted); white-space: nowrap; }
.bar b { font-size: .7rem; font-weight: 700; color: var(--ink-2); }

/* ---------- files / photo grid ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.photo-cell { position: relative; border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--line); background: var(--sunken); aspect-ratio: 1; }
.photo-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-cell .ph-doc { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: .8rem; font-weight: 700; text-align: center; padding: 8px; }
.photo-meta { position: absolute; left: 0; right: 0; bottom: 0; padding: 18px 8px 6px; font-size: .68rem; color: #fff; background: linear-gradient(transparent, rgba(20,14,8,.75)); }

/* ---------- login ---------- */
.login-card { width: min(400px, 92vw); }
.login-brand { text-align: center; margin-bottom: 20px; }
.login-brand .brand-mark { width: 62px; height: 62px; margin: 0 auto 12px; border-radius: 18px; display: grid; place-items: center; background: var(--accent); color: #FFF6EC; font-family: var(--font-display); font-size: 1.6rem; }
.login-brand h1 { font-size: 1.7rem; margin: 0; }
.login-brand p { color: var(--muted); font-size: .85rem; letter-spacing: .18em; text-transform: uppercase; margin: 2px 0 0; }

/* ---------- print documents ---------- */
.print-toolbar { display: flex; justify-content: space-between; padding: 14px 18px; max-width: 800px; margin: 0 auto; }
.print-page {
  background: #fff; max-width: 800px; margin: 0 auto 40px;
  padding: 48px 52px; border: 1px solid var(--line); border-radius: 6px;
  font-size: .95rem;
}
.doc-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 3px solid var(--accent); padding-bottom: 18px; margin-bottom: 24px; }
.doc-head h1 { font-size: 1.6rem; margin: 0; }
.doc-head .doc-clinic { text-align: right; font-size: .85rem; color: var(--ink-2); }
.doc-title { font-size: 1.25rem; margin: 18px 0 8px; }
.doc-table { width: 100%; border-collapse: collapse; margin: 10px 0 18px; }
.doc-table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; border-bottom: 2px solid var(--ink); padding: 7px 8px; }
.doc-table td { padding: 8px; border-bottom: 1px solid #ddd; vertical-align: top; }
.doc-total td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: 0; font-size: 1.05rem; }
.doc-foot { margin-top: 34px; font-size: .8rem; color: var(--muted); border-top: 1px solid #ddd; padding-top: 12px; }
.doc-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.doc-photos img { width: 100%; border-radius: 4px; }

@media print {
  .noprint, .tabbar, .sidebar, .topbar, .fab { display: none !important; }
  body { background: #fff; }
  .print-page { border: 0; margin: 0; padding: 0; max-width: none; }
  .frame { margin: 0; }
  a { color: inherit; }
}

/* ---------- misc ---------- */
.divider { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.pill-filter { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; -webkit-overflow-scrolling: touch; }
.pill-filter a {
  flex-shrink: 0; padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface);
  font-size: .85rem; font-weight: 600; color: var(--ink-2); white-space: nowrap;
}
.pill-filter a:hover { text-decoration: none; background: var(--sunken); }
.pill-filter a.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.empty { text-align: center; padding: 42px 20px; color: var(--muted); }
.empty h3 { color: var(--ink-2); }
.kv { display: grid; grid-template-columns: minmax(110px, 34%) 1fr; gap: 6px 14px; font-size: .93rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.balance-pos { color: var(--bad); font-weight: 700; }
.balance-zero { color: var(--ok); font-weight: 700; }

/* typeahead dropdown under the global search */
.top-search { position: relative; }
.ts-drop {
  display: none; position: absolute; top: calc(100% + 6px); right: 0; z-index: 90;
  min-width: 280px; max-width: 340px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: 0 12px 32px rgba(40, 30, 20, .14);
  overflow: hidden; padding: 6px;
}
.ts-drop.open { display: block; }
.ts-item {
  display: flex; flex-direction: column; gap: 1px;
  padding: 9px 12px; border-radius: 9px; color: var(--ink); font-size: .9rem;
}
.ts-item:hover, .ts-item.sel { background: var(--sunken); text-decoration: none; }
.ts-sub { font-size: .78rem; color: var(--muted); }
