:root {
  --yc-yellow: #f5c400;
  --yc-yellow-2: #e6b800;
  --ink: #1c1c1c;
  --muted: #8a8a8a;
  --label: #6b6b6b;
  --line: #ececec;
  --line-2: #d8d8d8;
  --bg: #fff;
  --soft: #f7f7f7;
  --soft-2: #f0f0f0;
  --radius: 12px;
  --star: #222;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body.yc {
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: #c8ced6;
  font-size: 14px;
}
#app {
  min-height: 100%;
  padding: 20px 16px 28px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.yc-modal {
  width: min(1180px, 100%);
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 18px 48px rgba(28, 28, 28, .16);
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 48px);
  overflow: hidden;
}
.yc-modal-cols {
  display: grid;
  grid-template-columns: 292px 1fr;
  flex: 1;
  min-height: 0;
}
.yc-side {
  padding: 14px 14px 18px;
  border-right: 1px solid var(--line);
  background: #fff;
  overflow: auto;
}
.yc-main {
  padding: 14px 20px 8px;
  min-width: 0;
  overflow: auto;
}
.yc-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--line);
  background: #fff;
}
.back {
  appearance: none; border: 0; background: transparent;
  color: var(--muted); font: inherit; font-size: 13px; font-weight: 600;
  padding: 0 0 10px; cursor: pointer; display: flex; align-items: center; gap: 4px;
}
.back:hover { color: var(--ink); }
.client-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 12px; }
.client-head h2 { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.25; }
.client-phone { color: var(--muted); font-size: 13px; margin-top: 2px; }
.icon-btn {
  width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; color: var(--muted);
}
.tiles {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 14px;
}
.tile {
  appearance: none; border: 1px solid var(--line); background: #fff;
  border-radius: 12px; padding: 12px 6px 10px; cursor: pointer;
  display: grid; gap: 8px; justify-items: center; font: inherit;
  color: var(--ink); min-height: 78px;
}
.tile:hover { border-color: #ccc; background: var(--soft); }
.tile.active { border-color: #c5c5c5; background: #f3f3f3; }
.tile svg { width: 22px; height: 22px; stroke: #222; fill: none; stroke-width: 1.7; }
.tile span { font-size: 11px; font-weight: 600; text-align: center; line-height: 1.2; color: #333; }
.side-check { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--label); margin: 4px 0 14px; }
.side-block { margin-bottom: 16px; }
.side-block h3 {
  margin: 0 0 8px; font-size: 14px; font-weight: 700;
}
.side-add {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 13px; padding: 0; cursor: pointer;
}
.kv { display: grid; gap: 10px; }
.kv .k { font-size: 12px; color: var(--muted); }
.kv .v { font-size: 14px; color: var(--ink); margin-top: 2px; }
.net { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.client-pick {
  width: 100%; margin: 0 0 10px; font: inherit; border: 1px solid var(--line-2);
  border-radius: 8px; padding: 7px 8px; background: #fff;
}
.yc-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; margin-bottom: 10px;
}
.yc-head-left { display: flex; align-items: center; gap: 18px; min-width: 0; flex-wrap: wrap; }
h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.lede { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.yc-nav { display: flex; gap: 4px; }
.nav-item {
  appearance: none; border: 0; background: transparent;
  color: var(--muted); padding: 8px 10px; border-radius: 8px;
  font: inherit; cursor: pointer; font-weight: 600;
}
.nav-item:hover { background: var(--soft); color: var(--ink); }
.nav-item.active { background: var(--soft-2); color: var(--ink); }
.top-actions, .toolbar, .seg { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn, .btn-sm {
  appearance: none; border: 0; cursor: pointer; font: inherit;
  background: var(--yc-yellow); color: #111; border-radius: 10px;
  padding: 9px 14px; font-weight: 700;
}
.btn:hover, .btn-sm:hover { background: var(--yc-yellow-2); }
.btn.ghost, .btn-sm.ghost {
  background: #fff; color: var(--ink); border: 1px solid var(--line-2);
}
.btn.ghost.on { background: #ececec; color: var(--ink); border-color: #cfcfcf; }
.btn.danger { background: #fff; color: #c43c3c; border: 1px solid var(--line-2); }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.hidden { display: none !important; }
.panel, .pane, .card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.panel { padding: 14px 16px; }
.pane { padding: 12px; }
.card { padding: 12px; cursor: pointer; }
.card:hover { border-color: #ccc; }
.card h3 { margin: 0 0 6px; font-size: 15px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.meta { color: var(--muted); font-size: 13px; display: grid; gap: 3px; }
.yc-meta {
  display: grid; grid-template-columns: 1fr 160px 160px 1fr;
  gap: 12px 16px; align-items: end; margin-bottom: 12px;
}
.yc-meta label { display: grid; gap: 6px; font-size: 12px; color: var(--label); font-weight: 500; }
.hint {
  font-size: 13px; color: var(--label); margin: 8px 0 10px;
}
.hint b { color: var(--ink); }
.tabs {
  display: flex; flex-wrap: wrap; gap: 0; margin: 12px 0;
  border-bottom: 1px solid var(--line);
}
.tab {
  border: 0; background: transparent; border-bottom: 2px solid transparent;
  padding: 8px 12px; font: inherit; cursor: pointer; font-weight: 600;
  color: var(--muted); margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--yc-yellow); }
.work { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start; }
.work.exam { grid-template-columns: 1fr; }
.stack { display: grid; gap: 10px; }
.dual { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; min-height: 140px; }
.pane h4 {
  margin: 0 0 8px; font-size: 12px; font-weight: 700; color: var(--label);
}
.filter {
  width: 100%; font: inherit; border: 1px solid var(--line-2); border-radius: 8px;
  padding: 8px 10px; margin-bottom: 8px; background: #fff;
}
.src, .picked { display: flex; flex-direction: column; gap: 6px; max-height: 340px; overflow: auto; }
.item, .pick {
  text-align: left; border: 1px solid transparent; background: var(--soft);
  border-radius: 8px; padding: 7px 10px; font: inherit; font-size: 13px; cursor: pointer;
}
.item:hover, .pick:hover { background: #eee; }
.item.on {
  background: #e8e8e8; color: var(--ink); font-weight: 650;
  border-color: #cfcfcf;
}
.item.on::before { content: "✓ "; color: #666; }
.pick { display: flex; justify-content: space-between; gap: 8px; align-items: center; cursor: default; }
.pick b { font-weight: 700; }
.x {
  border: 0; background: #f3e0e0; color: #b42318;
  border-radius: 6px; width: 22px; height: 22px; cursor: pointer; font-weight: 800;
}
.group-label { font-size: 11px; font-weight: 700; color: var(--label); margin: 8px 0 4px; }
.tiny { font-size: 12px; color: var(--muted); margin: 6px 0; }

/* Official StAR formula — horizontal, as on the blank */
.star-formula {
  display: grid;
  grid-template-columns: 188px 1fr;
  border: 1px solid var(--star);
  background: #fff;
  overflow: hidden;
  margin-bottom: 4px;
}
.star-legend {
  padding: 8px 10px 10px;
  font-size: 11px; line-height: 1.42; color: #222;
  border-right: 1px solid var(--star);
  background: #fff;
}
.star-legend b { display: block; margin: 0 0 4px; }
.star-legend .mob { margin-top: 10px; }
.star-wrap { overflow-x: auto; }
.star-grid {
  width: 100%; min-width: 640px;
  border-collapse: collapse; table-layout: fixed;
}
.star-grid th, .star-grid td {
  border: 1px solid #333;
  height: 30px; text-align: center; padding: 0; font-size: 12px;
  vertical-align: middle;
}
.star-grid .lab {
  width: 128px; background: #f2f2f2; text-align: left;
  padding: 0 8px; font-weight: 600; font-size: 12px; white-space: nowrap;
}
.star-grid .num {
  cursor: pointer; font-weight: 700; background: #fff; user-select: none;
}
.star-grid .num:hover { background: #fff6c2; }
.star-grid .num.on { background: #e4e4e4; color: var(--ink); }
.star-grid td.on-col { background: #f2f2f2; }
.star-grid .split { border-left-width: 3px; }
.star-grid select {
  width: 100%; height: 28px; border: 0; background: transparent;
  text-align: center; font: inherit; font-weight: 700; cursor: pointer;
  appearance: auto;
}
.star-grid select.sel-on { font-weight: 800; }
.star-foot { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin: 6px 0 0; }
.tooth-dock { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tooth-chip {
  appearance: none; border: 1px solid var(--line); background: #fff;
  border-radius: 999px; padding: 4px 10px; font: inherit; font-size: 12px; font-weight: 700;
  cursor: pointer; color: var(--ink);
}
.tooth-chip:hover { background: #fff6c2; }
.tooth-chip.on { background: #e4e4e4; border-color: #cfcfcf; }
.pick-group {
  border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px 8px;
  background: #fafafa; display: flex; flex-direction: column; gap: 4px;
}
.pick-group.on { background: #f3f3f3; border-color: #cfcfcf; }
.pick-tooth {
  appearance: none; border: 0; background: transparent; text-align: left;
  font: inherit; font-size: 11px; font-weight: 800; color: var(--label);
  cursor: pointer; padding: 0 2px 4px;
}
.pick-tooth.dim { cursor: default; font-weight: 700; }
.tooth-sheet {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  background: #fff; margin: 8px 0 10px;
}
.tooth-sheet-head {
  display: flex; justify-content: space-between; gap: 12px; align-items: flex-start;
}
.tooth-sheet-head h3 { margin: 0 0 4px; font-size: 16px; }
.tooth-sheet-head p { margin: 0; font-size: 12px; color: var(--muted); }
.tooth-sheet .tooth-dock { margin: 10px 0 8px; }
.tooth-hist {
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
  background: #fafafa;
}
.hist-row { padding: 8px 0; border-top: 1px solid var(--line); }
.hist-row:first-of-type { border-top: 0; padding-top: 0; }
.hist-row.now { background: #fffbeb; margin: 0 -6px; padding: 8px 6px; border-radius: 8px; border-top: 0; }
.hist-date { font-size: 12px; font-weight: 700; color: var(--label); margin-bottom: 4px; }
.hist-block { font-size: 13px; color: var(--ink); margin-top: 4px; line-height: 1.4; }
.hist-block span { display: block; font-size: 11px; font-weight: 800; color: var(--label); text-transform: uppercase; letter-spacing: .04em; }
.hist-block.dim { color: var(--muted); font-size: 12px; }
.svc-chip b { margin-right: 4px; }
.note-field {
  display: block; margin-top: 4px; font-size: 12px; font-weight: 700; color: var(--label);
}
.note-field textarea {
  display: block; width: 100%; margin-top: 6px; min-height: 72px; resize: vertical;
  font: inherit; font-weight: 400; font-size: 13px; color: var(--ink);
  border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; background: #fff;
}
.free-add {
  display: flex; gap: 6px; margin-top: 8px; align-items: stretch;
}
.free-add input {
  flex: 1; min-width: 0; font: inherit; font-size: 13px;
  border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; background: #fff;
}
.free-add .btn { white-space: nowrap; }
.crm-services {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  margin: 10px 0 4px;
  background: #fff;
}
.crm-services-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  margin-bottom: 8px;
}
.crm-services-head h4 { margin: 0; font-size: 14px; }
.svc-cats { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.svc-cat {
  appearance: none; border: 1px solid var(--line); background: #fff;
  border-radius: 999px; padding: 5px 10px; font: inherit; font-size: 12px;
  cursor: pointer; color: var(--ink);
}
.svc-cat:hover { background: var(--soft); }
.svc-cat.on { background: #ececec; border-color: #cfcfcf; font-weight: 650; }
.svc-picked { display: flex; flex-wrap: wrap; gap: 6px; min-height: 28px; margin-bottom: 8px; }
.svc-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: #f3f3f3; border: 1px solid #e0e0e0; border-radius: 999px;
  padding: 4px 8px 4px 10px; font-size: 12px;
}
.svc-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px; max-height: 260px; overflow: auto;
}
.svc-item {
  appearance: none; border: 1px solid var(--line); background: #fff;
  border-radius: 12px; padding: 10px 12px; text-align: left; cursor: pointer;
  display: grid; gap: 3px; font: inherit;
}
.svc-item:hover { border-color: #ccc; background: var(--soft); }
.svc-item.on { border-color: #c5c5c5; background: #f3f3f3; }
.svc-code { font-size: 11px; color: var(--muted); font-weight: 600; }
.svc-title { font-size: 13px; font-weight: 650; color: var(--ink); }
.svc-meta { font-size: 12px; color: var(--muted); }
.services { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.price-item {
  display: flex; gap: 8px; align-items: center;
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px;
  background: #fff; cursor: pointer; font-size: 12px;
}
.price-item.on { border-color: #c5c5c5; background: #f3f3f3; }
.price-item i { font-style: normal; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.span-2 { grid-column: 1 / -1; }
.yc-form { display: grid; gap: 10px; }
.yc-row {
  display: grid; grid-template-columns: 180px 1fr 180px 1fr;
  gap: 8px 12px; align-items: center;
}
.yc-row label { color: var(--label); font-size: 13px; }
label { display: grid; gap: 5px; font-size: 12px; color: var(--label); font-weight: 500; }
input, select, textarea {
  font: inherit; border: 1px solid var(--line-2); border-radius: 8px;
  padding: 8px 10px; background: #fff; color: var(--ink);
}
.toast {
  position: fixed; right: 16px; bottom: 16px;
  background: #111; color: #fff; padding: 10px 12px;
  border-radius: 10px; z-index: 30; font-size: 13px;
}
.print-wrap { display: grid; gap: 16px; }
.sheet {
  position: relative; background: #fff center / 100% 100% no-repeat;
  box-shadow: 0 8px 24px rgba(0,0,0,.08); margin: 0 auto;
}
.sheet.a4 { width: 210mm; height: 297mm; }
.sheet.a5 { width: 210mm; height: 148mm; }
.sheet .fld {
  position: absolute; font-family: "Times New Roman", "Source Serif 4", serif;
  font-size: 10px; line-height: 1; color: #111; white-space: nowrap;
  overflow: hidden;
}
.sheet .fld.line {
  display: flex; align-items: flex-end;
  padding: 0 1px 1px;
}
.sheet .fld.cell {
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.sheet.a5 .fld { font-size: 9px; }
@media (max-width: 980px) {
  .yc-modal-cols { grid-template-columns: 1fr; }
  .yc-side { border-right: 0; border-bottom: 1px solid var(--line); }
  .yc-meta, .work, .dual, .form-grid, .yc-row, .star-formula { grid-template-columns: 1fr; }
  .star-legend { border-right: 0; border-bottom: 1px solid var(--star); }
}
body[data-view="print"] .yc-side,
body[data-view="print"] .yc-foot { display: none; }
body[data-view="print"] .yc-modal-cols { grid-template-columns: 1fr; }
body.embed { background: #fff; }
body.embed #app { padding: 0; }
body.embed .yc-modal { width: 100%; min-height: 100vh; border-radius: 0; box-shadow: none; }
@media print {
  body { background: #fff; }
  .yc-head, .lede, .toolbar, .toast, .hint, .tabs, .yc-nav, .yc-side, .yc-foot { display: none !important; }
  #app { padding: 0; }
  .yc-modal { box-shadow: none; border-radius: 0; width: 100%; min-height: 0; }
  .yc-modal-cols { display: block; }
  .sheet { box-shadow: none; page-break-after: always; }
}
@page a4page { size: A4 portrait; margin: 0; }
@page a5page { size: A5 landscape; margin: 0; }
body[data-print="a4"] { page: a4page; }
body[data-print="a5"] { page: a5page; }
