:root {
  --primary: #1D5FD1; --bg: #F3F6FB; --text: #15233B; --muted: #56657D; --label: #3A4A63;
  --line: #DCE3EE; --soft: #E3ECFB; --late: #B42318; --late-bg: #FDE2E0; --today: #A04A00; --today-bg: #FFF0DC;
  --ok: #1B7A3E; --ok-bg: #DDF3E4;
}
* { box-sizing: border-box; }
body { margin: 0; background: #E4E9F2; color: var(--text); font-family: 'Be Vietnam Pro', system-ui, sans-serif; font-size: 15px; }
#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; background: var(--bg); display: flex; flex-direction: column; }
button, input, select, textarea { font-family: inherit; font-size: 15px; color: var(--text); }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
a { color: var(--primary); }
h1, h2, p { margin: 0; }

.top { background: #fff; padding: 14px 12px; display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--line); }
.top h1 { font-size: 19px; }
.back { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; color: var(--text); text-decoration: none; font-size: 30px; line-height: 1; }
.page { flex: 1; padding: 16px 16px 24px; display: flex; flex-direction: column; gap: 14px; }
.card { background: #fff; border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.muted { color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); text-align: center; padding: 24px 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--label); }
.field input, .field select, .field textarea, .input { width: 100%; min-height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font-size: 15px; font-weight: 500; }
.field textarea { padding: 10px 12px; resize: vertical; }

.btn { min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: var(--text); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.btn.outline { border: 2px solid var(--primary); color: var(--primary); }
.btn.danger { color: var(--late); }
.btn.small { min-height: 40px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.link { border: 0; background: transparent; min-height: 44px; font-size: 14px; font-weight: 600; color: var(--muted); text-decoration: underline; }

/* Đăng nhập */
.start { flex: 1; min-height: 100dvh; padding: 40px 28px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 18px; background: var(--primary); color: #fff; text-align: center; }
.logo { width: 96px; height: 96px; border-radius: 28px; background: #fff; display: flex; align-items: center; justify-content: center; }
.start .btn { width: 100%; min-height: 56px; border: 0; border-radius: 16px; color: var(--primary); font-size: 17px; margin-top: 24px; }
.person { min-height: 76px; border-radius: 16px; border: 1px solid var(--line); background: #fff; display: flex; align-items: center; gap: 12px; padding: 8px 14px; text-align: left; }
.person b { display: block; font-size: 16px; font-weight: 600; }
.avatar { width: 44px; height: 44px; flex-shrink: 0; border: 0; border-radius: 22px; background: var(--soft); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 17px; font-weight: 700; }
.avatar.boss { background: var(--primary); color: #fff; }
.question { background: var(--primary); color: #fff; border-radius: 20px; padding: 22px 20px; display: flex; flex-direction: column; gap: 8px; }
.question strong { font-size: 21px; line-height: 1.35; }
.question span { font-size: 13px; font-weight: 600; color: #DCE7FB; }
.answer { min-height: 64px; padding: 8px; border-radius: 16px; border: 1px solid var(--line); background: #fff; font-size: 17px; font-weight: 700; }
.answer.bad { border: 2px solid var(--late); background: var(--late-bg); color: var(--late); }
.tease { background: var(--today-bg); border-radius: 14px; padding: 14px 16px; color: #7A3A00; font-weight: 700; }

/* Trang chủ */
.home-head { background: #fff; padding: 20px 16px 14px; display: flex; flex-direction: column; gap: 14px; }
.home-head .title { font-size: 22px; font-weight: 700; }
.search { width: 100%; height: 46px; padding: 0 14px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.stat { background: #fff; border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.stat b { font-size: 26px; }
.stat span { font-size: 12px; color: var(--muted); }
.stat.today b { color: var(--today); }
.stat.late { background: #FFF1F1; }
.stat.late b, .stat.late span { color: var(--late); }
.stat.work b { color: var(--primary); }
.big { text-decoration: none; border-radius: 18px; padding: 18px 16px; display: flex; flex-direction: column; justify-content: flex-end; gap: 8px; min-height: 120px; border: 2px solid var(--primary); background: #fff; color: var(--text); }
.big b { font-size: 18px; }
.big i { font-style: normal; font-size: 30px; line-height: 1; color: var(--primary); }
.big span { font-size: 12px; color: var(--muted); }
.big.primary { background: var(--primary); color: #fff; }
.big.primary i, .big.primary span { color: #fff; }
.alert { display: flex; justify-content: space-between; align-items: center; min-height: 48px; padding: 0 16px; border-radius: 14px; background: var(--today-bg); color: #7A3A00; font-weight: 700; text-decoration: none; }

.case { background: #fff; border-radius: 14px; padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; border: 1px solid #E6EBF2; text-decoration: none; color: var(--text); }
.case.late { border: 1.5px solid #E8A39C; }
.case .info { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.case .info b { font-size: 15px; font-weight: 600; }
.list { display: flex; flex-direction: column; gap: 10px; }
.tag { flex-shrink: 0; font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 20px; background: var(--soft); color: var(--primary); }
.tag.late { background: var(--late-bg); color: var(--late); }
.tag.today { background: var(--today-bg); color: var(--today); }
.tag.done { background: var(--ok-bg); color: var(--ok); }

nav.bottom { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line); display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 8px 4px calc(10px + env(safe-area-inset-bottom)); }
nav.bottom a { text-decoration: none; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); font-size: 11px; padding: 6px 0; }
nav.bottom a.on { color: var(--primary); font-weight: 700; }
nav.bottom svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Sơ đồ răng */
.chart { touch-action: none; user-select: none; -webkit-user-select: none; display: flex; flex-direction: column; gap: 10px; }
.jaw { display: flex; gap: 3px; }
.half { flex: 1; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 1px; }
.chart-card { padding-left: 6px; padding-right: 6px; }
.chart-card > :not(.chart) { margin: 0 8px; }
.midline { width: 2px; background: #8FA3C2; border-radius: 1px; }
.tooth { height: 50px; padding: 0; border: 1px solid var(--line); background: #fff; color: var(--label); font-size: 11px; font-weight: 600; touch-action: none; }
.upper .tooth { border-radius: 10px 10px 4px 4px; }
.lower .tooth { border-radius: 4px 4px 10px 10px; }
.tooth.on { background: var(--primary); border-color: var(--primary); color: #fff; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 40px; min-width: 46px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--line); background: #fff; color: var(--label); font-size: 14px; font-weight: 600; }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }

.check { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 14px; border-radius: 12px; background: #FFF6E8; font-weight: 600; color: #7A3A00; }
.check small { display: block; font-weight: 400; font-size: 12px; }
input[type=checkbox], input[type=radio] { width: 22px; height: 22px; flex-shrink: 0; accent-color: var(--primary); }

.combo { position: relative; }
.combo-list { position: absolute; z-index: 5; left: 0; right: 0; top: 100%; max-height: 260px; overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 8px 24px rgba(21,35,59,.15); }
.combo-list button { width: 100%; min-height: 44px; padding: 0 14px; text-align: left; border: 0; border-bottom: 1px solid var(--bg); background: #fff; }
.combo-list button.add { color: var(--primary); font-weight: 700; }

.photo { width: 100%; border-radius: 12px; border: 1px solid var(--line); }
.file { min-height: 52px; border-radius: 12px; border: 1.5px dashed #8FA3C2; background: #F7F9FD; color: var(--label); font-weight: 600; display: flex; align-items: center; justify-content: center; cursor: pointer; }

.savebar { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line); padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 12px; }
.savebar .sum { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.savebar .calc { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.mini { height: 34px; padding: 0 6px; border: 1px solid #8FA3C2; border-radius: 6px; font-size: 14px; font-weight: 600; color: var(--primary); }
.mini.qty { width: 46px; }
.mini.price { width: 88px; }
.savebar .btn { padding: 0 14px; flex-shrink: 0; }
.total { font-size: 18px; font-weight: 700; }

dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; }
dt { color: var(--muted); font-size: 13px; }
dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; white-space: pre-wrap; }
.history { font-size: 13px; display: flex; flex-direction: column; gap: 2px; padding-bottom: 8px; border-bottom: 1px solid var(--bg); overflow-wrap: anywhere; }

dialog { width: min(92vw, 420px); border: 0; border-radius: 18px; padding: 20px; color: var(--text); }
dialog::backdrop { background: rgba(21,35,59,.5); }
dialog form { display: flex; flex-direction: column; gap: 12px; }
.error { color: var(--late); font-size: 13px; font-weight: 600; }
#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); width: max-content; max-width: 90vw; padding: 12px 18px; border-radius: 12px; background: var(--text); color: #fff; font-weight: 600; z-index: 20; display: none; }
#toast.show { display: block; }

.price-row { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 6px 0; border: 0; border-bottom: 1px solid var(--bg); background: transparent; text-align: left; }
.price-row .own { color: #C2570C; }
