:root {
  --bg: #f6f1ea;
  --bg-soft: #fffaf4;
  --paper: #ffffff;
  --ink: #2b3238;
  --muted: #6b737a;
  --line: #eadfd3;
  --mint: #2f9e8f;
  --mint-soft: #e4f5f1;
  --peach: #e07a5f;
  --peach-soft: #fdeee8;
  --gold: #e9c46a;
  --work: #eef8f5;
  --now: #fff3d6;
  --shadow: 0 10px 30px rgba(43, 50, 56, 0.08);
  --radius: 18px;
  --safe-bottom: 88px;
  font-family: "Manrope", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #d8cfc4; color: var(--ink); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.phone {
  width: min(390px, 100%);
  height: min(844px, 100dvh);
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
}

.topbar {
  padding: 16px 18px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.brand { font-weight: 800; font-size: 18px; letter-spacing: -.02em; }
.brand span { color: var(--mint); }
.icon-btn {
  width: 40px; height: 40px; border: 0; border-radius: 14px;
  background: var(--paper); color: var(--ink); box-shadow: var(--shadow);
  display: grid; place-items: center;
}
.modes {
  display: flex; gap: 6px; padding: 0 16px 12px;
}
.chip {
  border: 0; background: transparent; color: var(--muted);
  padding: 8px 14px; border-radius: 999px; font-weight: 700;
}
.chip.active { background: var(--ink); color: #fff; }

.screen { display: none; flex: 1; overflow: auto; padding-bottom: var(--safe-bottom); }
.screen.active { display: block; }

.day-meta, .section-head {
  padding: 0 12px 10px;
  display: flex; justify-content: space-between; align-items: center;
}
.day-meta-text { flex: 1; text-align: center; min-width: 0; }
.day-meta h1, .section-head h1 { margin: 0; font-size: 18px; }
.sub { color: var(--muted); font-size: 13px; font-weight: 600; }

.grid-day { padding: 0 12px 72px; }
.slot {
  display: grid; grid-template-columns: 54px 1fr; min-height: 52px;
  border-top: 1px solid var(--line);
}
.slot .time { font-size: 12px; color: var(--muted); padding: 10px 6px 0 6px; font-weight: 700; }
.slot .cell {
  margin: 4px 0; border-radius: 12px; background: transparent;
  border: 1px dashed transparent; padding: 6px 10px;
}
.slot.work .cell { background: var(--work); border-color: #cfe8e2; }
.slot.now .cell { background: var(--now); border-color: #f0d48a; }
.slot.busy .cell { background: var(--paper); border: 0; box-shadow: var(--shadow); }
.slot .cell.plus {
  display: grid; place-items: center; color: #1f7a6f; font-weight: 800; font-size: 18px;
}
.appt {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.appt-main {
  border: 0; background: transparent; text-align: left; flex: 1; min-width: 0; padding: 0;
}
.appt b { font-size: 13px; }
.quick { display: flex; flex-direction: column; gap: 4px; flex-shrink: 0; }
.qbtn {
  border: 0; border-radius: 10px; padding: 7px 10px; font-weight: 800; font-size: 11px;
  background: var(--mint-soft); color: #1f7a6f;
}
.qbtn.danger { background: var(--peach-soft); color: #b24a32; }
.tag {
  font-size: 11px; font-weight: 800; border-radius: 999px; padding: 3px 8px;
}
.tag.scheduled { background: var(--mint-soft); color: #1f7a6f; }
.tag.done { background: #eaf4e3; color: #3d7a2e; }
.tag.no_show { background: var(--peach-soft); color: #b24a32; }

.week-list { padding: 0 12px 24px; display: grid; gap: 8px; }
.wrow {
  background: var(--paper); border-radius: 16px; padding: 12px 14px;
  box-shadow: var(--shadow); border: 0; text-align: left; width: 100%;
}
.wrow.off { background: #f3ece6; }
.wrow-h {
  display: flex; justify-content: space-between; align-items: baseline;
  font-weight: 800; border: 0; background: transparent; width: 100%; padding: 0; text-align: left;
}
.wrow-h .sub { font-weight: 700; }
.wpills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.wpill {
  background: var(--mint-soft); color: #1f7a6f;
  border: 0; border-radius: 10px; padding: 8px 10px; font-size: 12px; font-weight: 700;
}
.wpill.done { background: #eaf4e3; color: #3d7a2e; }
.wpill.no_show { background: var(--peach-soft); color: #b24a32; }

.month {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
  padding: 0 12px 24px;
}
.mh { text-align: center; font-size: 11px; color: var(--muted); font-weight: 800; padding: 4px 0 8px; }
.mcell {
  aspect-ratio: 1; border-radius: 12px; background: #fff; border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px;
}
.mcell .c { font-size: 10px; font-weight: 700; opacity: .75; }
.mh.off { color: #c4a090; }
.mcell.off {
  background: repeating-linear-gradient(-45deg, #f3ece6, #f3ece6 6px, #ebe3db 6px, #ebe3db 12px);
  color: #b39a8c; border-color: transparent; opacity: .85;
}
.mcell.off .c { font-size: 9px; letter-spacing: .02em; }
.wday.off { background: #f3ece6; opacity: .7; min-height: 120px; }
.woff { text-align: center; font-size: 10px; font-weight: 800; color: #b39a8c; margin-top: 12px; }
.dchip.off { opacity: .45; box-shadow: none; background: #efe7dc; }
.dchip.off .sh { color: #b39a8c; }
.mcell.today { box-shadow: 0 0 0 2px var(--ink); }
.mcell.hot { color: #fff; border-color: transparent; }
.mcell.hot .c { opacity: .9; }
.heat-legend {
  display: flex; gap: 4px; padding: 0 12px 20px; align-items: center;
}
.heat-legend .cap { font-size: 11px; font-weight: 800; color: var(--muted); margin-right: 4px; }
.hswatch {
  flex: 1; height: 28px; border-radius: 8px; border: 1px solid var(--line);
  display: grid; place-items: center; font-size: 10px; font-weight: 800;
}
.hswatch.hot { color: #fff; border-color: transparent; }

.fab {
  position: absolute; right: 18px; bottom: 96px; width: 56px; height: 56px;
  border: 0; border-radius: 20px; background: var(--ink); color: #fff;
  font-size: 28px; box-shadow: 0 12px 24px rgba(43,50,56,.28); z-index: 5;
}

.tabbar {
  position: absolute; left: 12px; right: 12px; bottom: 12px;
  height: 64px; background: var(--paper); border-radius: 22px;
  display: grid; grid-template-columns: 1fr 1fr; box-shadow: var(--shadow); z-index: 6;
}
.tab {
  border: 0; background: transparent; color: var(--muted); font-weight: 800;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.tab.active { color: var(--mint); }
.tab svg { width: 22px; height: 22px; }

.search {
  margin: 0 16px 12px; display: flex; align-items: center; gap: 8px;
  background: var(--paper); border-radius: 16px; padding: 12px 14px; box-shadow: var(--shadow);
}
.search input { border: 0; outline: 0; width: 100%; background: transparent; }
.plist { padding: 0 16px 20px; display: grid; gap: 10px; }
.prow { display: flex; gap: 8px; align-items: stretch; }
.prow .pcard { flex: 1; }
.prow .call { flex-shrink: 0; align-self: center; text-decoration: none; }
.pcard {
  background: var(--paper); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); display: flex; justify-content: space-between; align-items: center;
  border: 0; text-align: left; width: 100%;
}
.pcard .phone-n { color: var(--muted); font-size: 13px; font-weight: 600; }
.avatar {
  width: 42px; height: 42px; border-radius: 16px; background: var(--mint-soft);
  color: #1f7a6f; display: grid; place-items: center; font-weight: 800; margin-right: 12px;
}
.row { display: flex; align-items: center; }

.sheet {
  position: absolute; inset: 0; background: var(--bg); z-index: 8;
  display: none; flex-direction: column;
}
.sheet.open { display: flex; }
.sheet-head {
  display: flex; align-items: center; gap: 10px; padding: 16px 16px 8px;
}
.sheet-head h2 { margin: 0; font-size: 20px; flex: 1; }
.form { padding: 8px 16px 24px; overflow: auto; display: grid; gap: 10px; }
#apptForm.mode-visit .when-pick,
#apptForm.mode-visit .field-who { display: none; }
#apptForm.mode-move .field-who,
#apptForm.mode-move .field-clinic,
#apptForm.mode-move #nextBlock,
#apptForm.mode-move #notesToggle,
#apptForm.mode-move #notesWrap { display: none; }
#apptForm.mode-create .who-summary,
#apptForm.mode-create #nextBlock { display: none; }
.who-summary {
  background: var(--paper); border-radius: 16px; padding: 12px 14px; font-weight: 800;
}
.who-summary small { display: block; font-weight: 700; color: var(--muted); margin-top: 2px; }
.hchips { display: flex; flex-wrap: wrap; gap: 6px; }
.hchip {
  border: 1px solid var(--line); background: var(--paper); border-radius: 999px;
  padding: 8px 12px; font-weight: 800; font-size: 12px;
}
.hchip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.next-block { display: grid; gap: 8px; padding-top: 4px; }
.lead-s { margin: 0; font-weight: 700; color: var(--muted); }
.actions { display: flex; gap: 8px; }
label { font-size: 12px; font-weight: 800; color: var(--muted); display: grid; gap: 6px; }
input, textarea, select {
  border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: var(--paper);
}
.form-sticky {
  position: sticky; bottom: 0; background: var(--bg);
  padding: 10px 0 14px; margin-top: 4px;
}
.range { display: grid; gap: 6px; }
.range-row {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
}
.range-row span { font-weight: 800; color: var(--muted); }
.check {
  display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink);
}
.check input { width: 18px; height: 18px; }
.btn {
  border: 0; border-radius: 16px; padding: 14px 16px; font-weight: 800; flex: 1;
}
.btn.primary { background: var(--mint); color: #fff; }
.btn.ghost { background: var(--paper); }
.btn.danger { background: var(--peach); color: #fff; }

.seg { display: flex; background: #efe7dc; border-radius: 14px; padding: 4px; }
.seg button { flex: 1; border: 0; background: transparent; border-radius: 11px; padding: 8px; font-weight: 800; }
.seg button.active { background: var(--paper); }

.teeth { display: grid; gap: 10px; }
.arch { display: flex; justify-content: center; align-items: flex-end; gap: 2px; }
.arch.lower { align-items: flex-start; }
.arch .mid { width: 8px; flex-shrink: 0; }
.tooth {
  width: 32px; min-width: 0; min-height: 44px; padding: 4px 0 0;
  border: 0; background: transparent; color: #c4b6a8;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 1px;
}
.tooth svg { width: 24px; height: 28px; display: block; }
.arch.lower .tooth svg { transform: rotate(180deg); }
.tooth .tn { font-size: 9px; font-weight: 800; color: var(--muted); line-height: 1; }
.tooth.on { color: var(--peach); }
.tooth.on .tn { color: var(--peach); }
.tooth.prev:not(.on) { color: #8aa89e; }
.tooth.prev:not(.on) .tn { color: #5f8a80; }
.teeth.adult .arch { gap: 0; }
.teeth.adult .tooth { flex: 1; width: auto; min-height: 44px; }
.teeth.adult .tooth svg { width: 18px; height: 22px; }

.timeline { display: grid; gap: 8px; }
.titem {
  background: var(--paper); border-radius: 16px; padding: 12px 14px; box-shadow: var(--shadow);
  border: 0; text-align: left;
}
.empty { text-align: center; color: var(--muted); padding: 40px 24px; font-weight: 600; }

.toast {
  position: absolute; left: 50%; bottom: 92px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 12px;
  font-size: 13px; font-weight: 700; display: none; z-index: 9;
  white-space: normal; max-width: 82%; text-align: center;
}
.toast.show { display: block; }

.when-pick { display: grid; gap: 8px; }
.when-label { font-size: 12px; font-weight: 800; color: var(--muted); }
.when-summary { font-weight: 800; font-size: 15px; }
.when-summary small { display: block; font-weight: 700; color: var(--muted); font-size: 12px; margin-top: 2px; }
.day-strip-wrap { display: flex; align-items: center; gap: 6px; }
.day-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; flex: 1; }
.dchip {
  border: 0; background: var(--paper); border-radius: 14px; padding: 8px 0 7px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  box-shadow: var(--shadow);
}
.dchip .wd { font-size: 10px; font-weight: 800; color: var(--muted); text-transform: lowercase; }
.dchip .dn { font-size: 15px; font-weight: 800; }
.dchip .sh { font-size: 9px; font-weight: 800; color: var(--mint); }
.dchip.even .sh { color: var(--peach); }
.dchip.on { background: var(--ink); color: #fff; }
.dchip.on .wd, .dchip.on .sh { color: rgba(255,255,255,.72); }
.slot-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.schip {
  border: 1px solid var(--line); background: var(--paper); border-radius: 10px;
  padding: 6px 2px; font-weight: 800; font-size: 11px;
}
.schip:disabled { pointer-events: none; }
.schip.on { background: var(--mint); color: #fff; border-color: var(--mint); }
.schip.busy { background: var(--peach-soft); color: #b24a32; border-color: transparent; text-decoration: line-through; opacity: .7; }
.schip.busy.on { background: var(--ink); color: #fff; text-decoration: none; opacity: 1; }

.suggest-wrap { position: relative; }
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 3;
  background: var(--paper); border-radius: 14px; box-shadow: 0 12px 32px rgba(43,50,56,.16);
  overflow: hidden; max-height: 220px; overflow-y: auto;
}
.sitem {
  width: 100%; border: 0; background: transparent; text-align: left;
  padding: 10px 14px; display: flex; justify-content: space-between; gap: 8px; align-items: center;
}
.sitem + .sitem { border-top: 1px solid var(--line); }
.sitem:active, .sitem:hover { background: var(--mint-soft); }
.sitem .meta { color: var(--muted); font-size: 11px; font-weight: 700; white-space: nowrap; }

.vac-block { display: grid; gap: 10px; padding-top: 8px; }
.vac-list { display: grid; gap: 8px; }
.vac-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--paper); border-radius: 16px; padding: 10px 12px; box-shadow: var(--shadow);
}
.vac-form { display: grid; gap: 10px; }
.vac-form[hidden], #vacAdd[hidden] { display: none; }
.vac-cal-nav {
  display: flex; align-items: center;
  background: var(--paper); border-radius: 16px; box-shadow: var(--shadow);
}
.vac-cal-nav button {
  width: 44px; height: 44px; border: 0; background: transparent;
  font-size: 22px; font-weight: 800; color: var(--ink); flex-shrink: 0;
}
.vac-cal-nav b {
  flex: 1; text-align: center; font-size: 15px; text-transform: capitalize;
}
.vac-cal {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
}
.vhead { text-align: center; font-size: 10px; font-weight: 800; color: var(--muted); padding: 2px 0 4px; }
.vcell {
  aspect-ratio: 1; border: 0; border-radius: 12px; background: var(--paper);
  font-weight: 800; font-size: 13px; color: var(--ink);
}
.vcell.in { background: var(--mint-soft); color: #1f7a6f; }
.vcell.edge { background: var(--ink); color: #fff; }
.vcell.wk { color: #b39a8c; }
