/* Hệ thiết kế "Hành trình tìm con" – xem design-system/MASTER.md */
:root {
  --bg: #FFF7FA;
  --card: #FFFFFF;
  --ink: #2B2125;
  --ink-2: #4A3B41;
  --muted: #6B5A61;
  --line: #F5E1E9;
  --line-2: #EBD3DE;
  --soft: #F8E8EF;
  --peach: #F0528C;
  --peach-dark: #C2185B;
  --peach-darker: #8C1043;
  --peach-tint: #FDE3EE;
  --green: #3F6B34;
  --green-dark: #2E5226;
  --green-tint: #E8F3E3;
  --danger: #B42318;
  --radius: 18px;
  --shadow: 0 6px 20px rgba(194, 24, 91, 0.08);
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 15px; line-height: 1.5; }
a { color: var(--peach-dark); }
a:hover { color: var(--peach-darker); }
h1 { font-size: 24px; margin: 0; line-height: 1.3; }
h2 { font-size: 17px; margin: 0; }
h3 { font-size: 15px; margin: 0; }
p { margin: 0; }
:focus-visible { outline: 3px solid var(--peach); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.bold { font-weight: 700; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; }
.grow { flex: 1 1 auto; min-width: 0; }
.hidden { display: none !important; }

.card { background: var(--card); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.card.accent { border: 2px solid var(--peach); }
.card.tint { background: var(--peach-tint); box-shadow: none; }
.card.green { background: var(--green-tint); box-shadow: none; }

.btn {
  min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line-2);
  background: var(--card); color: var(--ink); font: inherit; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none;
}
.btn:hover { background: #FFF0F5; color: var(--ink); }
.btn.primary { background: var(--peach-dark); color: #fff; border-color: var(--peach-dark); font-weight: 600; }
.btn.primary:hover { background: var(--peach-darker); color: #fff; }
.btn.green { background: var(--green); color: #fff; border-color: var(--green); font-weight: 600; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.link { border: none; background: none; color: var(--peach-dark); padding: 0 4px; font-weight: 600; }
.btn:disabled { opacity: 0.5; cursor: default; }

.chip { display: inline-flex; align-items: center; font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--soft); color: var(--ink-2); white-space: nowrap; }
.chip.proc { background: var(--peach-dark); color: #fff; font-weight: 700; }
.chip.ok { background: var(--green-tint); color: var(--green-dark); font-weight: 600; }
.chip.warn { background: var(--peach-tint); color: var(--peach-darker); font-weight: 600; }

label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line-2); border-radius: 12px;
  min-height: 44px; padding: 8px 12px; width: 100%;
}
textarea { min-height: 88px; resize: vertical; }
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; accent-color: var(--green); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13px; padding: 8px; }
td { padding: 10px 8px; border-top: 1px solid var(--soft); vertical-align: top; }
.table-wrap { overflow-x: auto; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tile { background: var(--bg); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; }
.tile .k { font-size: 12px; color: var(--muted); }
.tile .v { font-size: 16px; font-weight: 700; }

.list-item { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--soft); }
.list-item:first-child { border-top: none; }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 12px 18px; border-radius: 12px; z-index: 50; max-width: 90vw; font-size: 14px;
}
.toast.err { background: var(--danger); }

dialog { border: none; border-radius: 20px; padding: 0; width: min(520px, 94vw); max-height: 90vh; }
dialog::backdrop { background: rgba(43, 33, 37, 0.45); }
dialog form, dialog .dlg { padding: 22px; display: flex; flex-direction: column; gap: 14px; }

.empty { text-align: center; color: var(--muted); padding: 24px 8px; }
.pin-code { font-size: 36px; font-weight: 700; letter-spacing: 6px; text-align: center; color: var(--peach-dark); }
.msg { max-width: 85%; padding: 10px 14px; border-radius: 16px; font-size: 14px; white-space: pre-wrap; word-wrap: break-word; }
.msg.me { align-self: flex-end; background: var(--peach-tint); border-bottom-right-radius: 4px; }
.msg.them { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg .meta { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ---------- Khung trang nhân viên ---------- */
.app { min-height: 100vh; display: flex; }
.side {
  width: 240px; flex-shrink: 0; background: #fff; border-right: 1px solid var(--line); padding: 24px 14px;
  display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 0 12px 18px; }
.brand .t { font-size: 17px; font-weight: 700; color: var(--peach-dark); }
.nav a {
  min-height: 44px; display: flex; align-items: center; justify-content: space-between; padding: 0 12px; border-radius: 12px;
  color: var(--ink); text-decoration: none; font-size: 15px;
}
.nav a.on { background: var(--peach-tint); color: var(--peach-darker); font-weight: 600; }
.nav a .badge { font-size: 12px; font-weight: 700; color: #fff; background: var(--peach-dark); border-radius: 999px; padding: 1px 8px; }
.main { flex: 1; min-width: 0; padding: 28px clamp(16px, 3vw, 40px) 40px; display: flex; flex-direction: column; gap: 20px; max-width: 1280px; }
.cols { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.cols > .c3 { flex: 3 1 440px; min-width: 0; }
.cols > .c2 { flex: 2 1 300px; min-width: 0; }
.proc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 12px 14px; min-height: 46px; display: inline-flex; align-items: center; text-decoration: none; color: var(--muted); white-space: nowrap; border-bottom: 3px solid transparent; }
.tabs a.on { color: var(--peach-darker); font-weight: 600; border-bottom-color: var(--peach-dark); }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.step { display: flex; flex-direction: column; gap: 6px; }
.step .bar { height: 6px; border-radius: 3px; background: var(--soft); }
.step.done .bar { background: var(--green); }
.step.cur .bar { background: var(--peach); }
.bottom-nav { display: none; }

@media (max-width: 820px) {
  .side { display: none; }
  .main { padding: 20px 16px 110px; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; background: #fff;
    border-top: 1px solid var(--line); padding: 6px 4px calc(8px + env(safe-area-inset-bottom)); z-index: 20;
  }
  .bottom-nav a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px;
    text-decoration: none; color: var(--muted); font-size: 11px; position: relative;
  }
  .bottom-nav a.on { color: var(--peach-dark); font-weight: 600; }
  .bottom-nav .badge { position: absolute; top: 2px; right: 22%; background: var(--peach-dark); color: #fff; font-size: 10px; border-radius: 999px; padding: 0 6px; }
  h1 { font-size: 21px; }
}

/* ---------- Bệnh nhân (điện thoại) ---------- */
.p-app { max-width: 480px; margin: 0 auto; min-height: 100vh; padding: 24px 18px 110px; display: flex; flex-direction: column; gap: 16px; }
.p-nav {
  position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr); padding: 6px 4px calc(10px + env(safe-area-inset-bottom)); z-index: 20;
}
.p-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 52px; justify-content: center; text-decoration: none; color: var(--muted); font-size: 12px; }
.p-nav a.on { color: var(--peach-dark); font-weight: 600; }
.timeline { display: flex; flex-direction: column; }
.tl { display: flex; gap: 12px; }
.tl .rail { display: flex; flex-direction: column; align-items: center; }
.tl .dot { width: 28px; height: 28px; border-radius: 14px; border: 2px solid var(--line-2); background: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.tl.done .dot { background: var(--green); border-color: var(--green); }
.tl.cur .dot { border: 3px solid var(--peach); }
.tl .line { width: 2px; flex: 1; min-height: 20px; background: var(--line); }
.tl.done .line { background: var(--green); }
.tl .body { padding: 3px 0 16px; }
.tl.cur .name { color: var(--peach-dark); font-weight: 700; }
.count { background: var(--peach-tint); border-radius: 14px; padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
.count .n { font-size: 32px; font-weight: 700; color: var(--peach-dark); line-height: 1; }
.date-box { width: 54px; height: 58px; border-radius: 12px; background: var(--green-tint); color: var(--green); display: flex; flex-direction: column; align-items: center; justify-content: center; flex-shrink: 0; }
.date-box .d { font-size: 20px; font-weight: 700; line-height: 1.1; }
.date-box .w { font-size: 11px; font-weight: 600; }
.login { max-width: 420px; margin: 0 auto; padding: 48px 20px; display: flex; flex-direction: column; gap: 18px; min-height: 100vh; justify-content: center; }

/* Tuổi: vợ > 32 tuổi đỏ, ≤ 32 xanh */
.age { display: inline-block; font-size: 0.72em; font-weight: 700; padding: 1px 8px; border-radius: 999px; vertical-align: middle; background: var(--soft); color: var(--ink-2); white-space: nowrap; }
.age.old { background: #FDE2E1; color: var(--danger); }
.age.young { background: var(--green-tint); color: var(--green-dark); }
.live-hint { display: block; min-height: 1.2em; margin-top: 2px; font-weight: 500; }

/* Ô số điện thoại: ✓ xanh bên trong ô khi đúng, viền đỏ khi sai */
.phone-field { position: relative; display: block; }
.phone-field input { width: 100%; padding-right: 40px; letter-spacing: 0.3px; font-variant-numeric: tabular-nums; }
.phone-field .ph-ok { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--green); font-weight: 700; opacity: 0; transition: opacity .15s; pointer-events: none; }
.phone-field.ok .ph-ok { opacity: 1; }
.phone-field.bad input { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.12); }
.phone-field.intl.ok .ph-ok::after { content: ' QT'; font-size: 11px; }
.login-pick { color: var(--ink-2); cursor: pointer; }
.login-pick input[type=radio] { width: 18px; height: 18px; min-height: 0; flex: none; margin: 0; padding: 0; accent-color: var(--peach-dark); box-shadow: none; }

/* Hồ sơ bệnh nhân: thanh đề mục dính trên cùng khi cuộn */
.rec-tabs { position: sticky; top: 0; z-index: 15; background: var(--bg); margin: -8px 0 -6px; }
.pin-strip { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; background: var(--peach-tint); color: var(--peach-darker); border-radius: 12px; padding: 10px 14px; font-size: 13px; }

/* Phiếu khám ban đầu */
.intake .sec-t { font-size: 15px; color: var(--peach-darker); padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.intake-head { position: sticky; top: 46px; z-index: 5; background: #fff; margin: -18px -20px 0; padding: 12px 20px; border-radius: var(--radius) var(--radius) 0 0; border-bottom: 1px solid var(--line); }
.intake-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 16px; }
.intake-grid.two { grid-template-columns: 1fr 1fr; }
.field-block { display: flex; flex-direction: column; gap: 6px; }
.field-block > .field { font-size: 13px; color: var(--muted); }
.intake textarea { min-height: 64px; resize: none; overflow: hidden; }
.intake input.bad { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.12); }
.live-hint.bad { color: var(--danger); }
.save-state.ok { color: var(--green-dark); font-weight: 600; }
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg-opt { flex: 1 1 0; min-width: 120px; position: relative; }
.seg-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg-opt span { display: flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: 12px; background: #fff; cursor: pointer; font-weight: 500; }
.seg-opt input:checked + span { background: var(--peach-dark); border-color: var(--peach-dark); color: #fff; font-weight: 600; }
.seg-opt input:focus-visible + span { outline: 3px solid var(--peach); outline-offset: 2px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.qchip { min-height: 38px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--bg); color: var(--ink-2); font: inherit; font-size: 13px; cursor: pointer; }
.qchip:hover { background: var(--peach-tint); border-color: var(--peach); }
.seg.freq { display: grid; grid-template-columns: repeat(4, 1fr); }
.seg.freq .seg-opt { min-width: 0; }
.seg.freq .seg-opt span { flex-direction: column; gap: 2px; min-height: 60px; padding: 6px 10px; text-align: center; line-height: 1.25; }
.seg.freq small { font-size: 12px; font-weight: 400; opacity: 0.85; }
.qchip.on { background: var(--peach-tint); border-color: var(--peach); color: var(--peach-darker); font-weight: 600; }
@media (max-width: 820px) {
  .seg-opt { min-width: 0; }
  .seg.freq { grid-template-columns: 1fr 1fr; }
  .intake-head { flex-wrap: nowrap; }
  .intake-head h2 { font-size: 16px; }
  .rec-actions { flex-wrap: nowrap; width: 100%; }
  .rec-actions .btn { min-height: 42px; padding: 0 10px; font-size: 14px; flex: 1 1 auto; }
}

/* Phiếu khám chi tiết (bản 1.3.0) */
.intake .sec-t h3 { font-size: 15px; color: var(--peach-darker); }
.intake .sec-t.row { padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.intake-cols { display: grid; gap: 24px; }
@media (min-width: 1000px) { .intake-cols.two { grid-template-columns: 1fr 1fr; gap: 28px; } }
.side-switch { display: none; }
.seg-btn { flex: 1; min-height: 46px; border: 1px solid var(--line-2); border-radius: 12px; background: #fff; font: inherit; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.seg-btn.on { background: var(--peach-dark); color: #fff; border-color: var(--peach-dark); }
.seg.two-line .seg-opt span { flex-direction: column; gap: 2px; min-height: 56px; text-align: center; line-height: 1.25; }
.seg.two-line small { font-size: 12px; font-weight: 400; opacity: .85; }
.seg.sm { gap: 6px; }
.seg.sm .seg-opt { flex: 0 1 auto; min-width: 0; }
.seg.sm .seg-opt span { min-height: 40px; padding: 0 12px; font-size: 14px; }
.para { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.para input { text-align: center; }
.pcard { border: 1px solid var(--line-2); border-radius: 16px; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; background: #fff; }
.tcard { border-radius: 12px; padding: 12px 14px; background: var(--bg); display: flex; flex-direction: column; gap: 10px; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 16px; align-items: start; }
.pgrid.five { grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); }
.stepper { display: flex; align-items: stretch; }
.stepper input { text-align: center; border-radius: 0; min-width: 0; padding: 8px 4px; font-variant-numeric: tabular-nums; }
.stepper .st { width: 40px; flex: none; border: 1px solid var(--line-2); background: var(--bg); font: inherit; font-size: 20px; cursor: pointer; color: var(--peach-dark); }
.stepper .st:first-child { border-radius: 12px 0 0 12px; border-right: none; }
.stepper .st:last-child { border-radius: 0 12px 12px 0; border-left: none; }
.psum { background: var(--green-tint); color: var(--green-dark); border-radius: 12px; padding: 10px 14px; line-height: 1.6; white-space: pre-wrap; }
.chip.flag, .pin-strip .flag { background: #FDE2E1; color: var(--danger); font-weight: 600; border-radius: 999px; padding: 2px 10px; }
@media (max-width: 999px) {
  .side-switch { display: flex; gap: 8px; position: sticky; top: 112px; z-index: 4; background: #fff; padding: 6px 0; }
  .intake[data-show="vo"] [data-side="chong"], .intake[data-show="chong"] [data-side="vo"] { display: none; }
}
@media (max-width: 820px) { .side-switch { top: 104px; } .para { gap: 6px; } }
@media (max-width: 820px) {
  .intake .seg:not(.freq):not(.two-line) .seg-opt { flex: 1 1 auto; }
  .intake .seg:not(.freq):not(.two-line) .seg-opt span { white-space: nowrap; padding: 0 12px; font-size: 14px; }
}

/* Dải báo trên bản thử */
.staging-bar { background: var(--green-tint); color: var(--green-dark); text-align: center; font-size: 13px; padding: 8px 16px; border-bottom: 1px solid #CFE3C6; }

/* ---------- Công cụ lâm sàng (bản 1.4.0) ---------- */
.tool-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.tool h2 { color: var(--peach-darker); }
.semen-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px 14px; }
.tool-out { display: flex; flex-direction: column; gap: 6px; background: var(--bg); border-radius: 12px; padding: 10px 12px; min-height: 44px; }
.tool-nums { display: flex; flex-wrap: wrap; gap: 4px 16px; font-variant-numeric: tabular-nums; }
.cycle-tools { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; }
.tool-sec { border: 1px solid var(--line-2); border-radius: 14px; padding: 10px 14px; background: #fff; }
.tool-sec > summary { cursor: pointer; min-height: 32px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; list-style: none; }
.tool-sec > summary::-webkit-details-marker { display: none; }
.tool-sec > summary::before { content: '›'; font-size: 18px; color: var(--peach-dark); transition: transform .15s; }
.tool-sec[open] > summary::before { transform: rotate(90deg); }
.tool-sec[open] > summary { margin-bottom: 10px; }
.tool-sec[open] { display: flex; flex-direction: column; gap: 10px; }
.tool-sec table input { min-height: 38px; padding: 4px 8px; font-size: 14px; }
.tool-sec td { vertical-align: middle; }
.advice { font-size: 13px; padding: 8px 12px; border-radius: 10px; background: var(--soft); }
.advice.go { background: var(--green-tint); color: var(--green-dark); font-weight: 600; }
.advice.warn { background: #FDE2E1; color: var(--danger); font-weight: 600; }
.med-table tr.today td:first-child { box-shadow: inset 3px 0 0 var(--peach); }
.scan-chart { width: 100%; max-width: 560px; height: auto; display: block; }
.scan-chart .grid { stroke: var(--line); stroke-width: 1; }
.scan-chart .ax { font-size: 11px; fill: var(--muted); font-family: inherit; }
.scan-chart polyline { fill: none; stroke-width: 2.5; }
.scan-chart polyline.lead, .scan-chart circle.lead { stroke: var(--peach-dark); }
.scan-chart circle.lead { fill: var(--peach-dark); }
.scan-chart polyline.endo, .scan-chart circle.endo { stroke: var(--green); }
.scan-chart circle.endo { fill: var(--green); }
.scan-chart .bar { fill: var(--peach-tint); }
.chart-key { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--muted); }
.chart-key i { display: inline-block; width: 14px; height: 4px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.k-lead { background: var(--peach-dark); } .k-endo { background: var(--green); } .k-bar { background: var(--peach-tint); height: 10px !important; }

/* Bệnh nhân */
.trig { border: 2px solid var(--peach); }
.trig-time { font-size: 34px; font-weight: 700; color: var(--peach-dark); line-height: 1.1; font-variant-numeric: tabular-nums; }
.trig-time span { font-size: 15px; font-weight: 600; color: var(--ink-2); }
.trig-left { font-weight: 600; }
.med-row { display: flex; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--soft); }
.med-row:first-of-type { border-top: none; }
.med-time { min-width: 52px; font-weight: 700; color: var(--peach-dark); font-variant-numeric: tabular-nums; }
.prep-list, .guide-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; line-height: 1.5; }
.preg-ga { font-size: 28px; font-weight: 700; color: var(--green-dark); }

/* Gợi ý chỉ hiện khi bấm vào ô (bản 1.4.1) */
.intake .field-block.has-quick > .quick { display: none; }
.intake .field-block.has-quick:focus-within > .quick { display: flex; }
/* Điều trị trước: mỗi chu kỳ 1 thẻ, tiêu đề kèm kết quả */
.pcard-head { padding-bottom: 8px; border-bottom: 1px solid var(--line); }
#prior { display: flex; flex-direction: column; gap: 12px; }

/* Điều trị trước đây: danh sách gọn + popup (bản 1.4.2) */
.plist { display: flex; flex-direction: column; border: 1px solid var(--line-2); border-radius: 14px; background: #fff; }
.prow { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--line); }
.prow:first-child { border-top: none; }
.prior-dlg { width: min(760px, 96vw); padding: 0; }
.prior-dlg .dlg-form { display: flex; flex-direction: column; max-height: 90vh; padding: 0; gap: 0; }
.prior-dlg .dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.prior-dlg .dlg-head h2 { color: var(--peach-darker); }
.prior-dlg .dlg-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.prior-dlg .dlg-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 20px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #fff; }
@media (max-width: 600px) {
  .prior-dlg { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
  .prior-dlg .dlg-form { height: 100%; max-height: 100dvh; }
  .prior-dlg .dlg-foot .btn { min-height: 48px; }
}

/* Phiếu khám: thanh 3 mục ghim trên cùng; khám nam khoa là mục phụ (bản 1.4.2) */
.intake-head { display: flex; flex-direction: column; gap: 8px; }
.sec-nav { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.sec-nav button { flex: 1 1 0; min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--bg); color: var(--ink-2); font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; }
.sec-nav button.on { background: var(--peach-dark); border-color: var(--peach-dark); color: #fff; }
.intake [data-sec] { scroll-margin-top: 170px; }
.intake .side-switch { display: none !important; }
.intake[data-show="vo"] [data-side="chong"], .intake[data-show="chong"] [data-side="vo"] { display: flex !important; }
.andro-fs { border: none; padding: 0; margin: 0; min-width: 0; }
.andro-fs[disabled] { display: none; }
.andro > summary .chip { margin-left: 4px; }

/* Ghi chú PARA tự hiện */
.para-note { background: var(--bg); border-radius: 12px; padding: 10px 12px; }
.para-grp { display: flex; flex-direction: column; gap: 4px; }
.para-note.flash { animation: flash 1.2s ease-out 1; }
@keyframes flash { from { box-shadow: 0 0 0 3px var(--peach); } to { box-shadow: 0 0 0 0 transparent; } }

/* Tiền sử gộp 1 ô (bản 1.4.3) */
.hist > summary { flex-wrap: wrap; }
.hist-sum { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.hist-sum .chip { white-space: normal; }

/* Cận lâm sàng (bản 1.5.0) */
.cls-bar { gap: 8px; }
.cls-todo { gap: 4px; white-space: normal; }
.cls-todo small { font-weight: 400; opacity: .8; }
.x { border: none; background: none; color: inherit; font: inherit; font-size: 18px; line-height: 1; cursor: pointer; padding: 0 4px; min-width: 28px; min-height: 28px; border-radius: 8px; }
.x:hover { background: rgba(0,0,0,.06); }
.cls-sheet table { width: auto; min-width: 100%; }
.cls-sheet th, .cls-sheet td { white-space: nowrap; padding: 4px 6px; vertical-align: middle; }
.cls-sheet thead th { text-align: center; font-variant-numeric: tabular-nums; }
.cls-sheet thead th.newest { color: var(--peach-darker); font-weight: 700; }
.cls-sheet .sticky { position: sticky; left: 0; background: #fff; z-index: 1; text-align: left; color: var(--ink); font-weight: 600; font-size: 14px; border-right: 1px solid var(--soft); }
.cls-sheet tbody th.sticky { min-width: 175px; max-width: 240px; white-space: normal; }
.cls-rh { display: flex; align-items: flex-start; gap: 2px; line-height: 1.3; }
.cls-rh > span { padding-top: 5px; }
.cls-rh small { display: block; font-size: 12px; }
.cls-sheet tbody th small { font-weight: 400; }
.cls-cell { border: none; background: none; font: inherit; font-size: 14px; font-variant-numeric: tabular-nums; padding: 6px 10px; border-radius: 8px; cursor: pointer; min-height: 36px; min-width: 52px; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.cls-cell:hover { background: var(--soft); }
.cls-cell.bad { background: #FDE2E1; color: var(--danger); font-weight: 700; }
.cls-cell.warn { background: #FFF1DC; color: #8A4B00; font-weight: 600; }
.cls-star { border: none; background: none; cursor: pointer; font-size: 17px; color: #E3CDD7; min-width: 30px; min-height: 30px; border-radius: 8px; padding: 0; }
.cls-star.on { color: #D99A00; }
.cls-star:hover { background: var(--soft); }
.cls-list { display: flex; flex-direction: column; }
.cls-row { display: flex; align-items: center; gap: 6px; padding: 6px 0; border-top: 1px solid var(--soft); }
.cls-row:first-child { border-top: none; }
.cls-row .d { font-size: 13px; color: var(--muted); min-width: 84px; font-variant-numeric: tabular-nums; }
.cls-open-row { flex: 1; text-align: left; border: none; background: none; font: inherit; font-size: 14px; color: var(--ink); cursor: pointer; padding: 6px 8px; border-radius: 8px; line-height: 1.45; }
.cls-open-row:hover { background: var(--soft); }
.cls-open-row .bad { color: var(--danger); font-weight: 600; }
.cls-entry { border: 2px solid var(--peach); }
.cls-head { gap: 12px; align-items: center; }
.cls-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 10px; }
.cls-item { border: 1px solid var(--line-2); border-radius: 14px; padding: 10px 12px; background: #fff; display: flex; flex-direction: column; gap: 8px; }
.cls-item.filled { border-color: var(--green); background: #FBFEF9; }
.cls-item-h { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.cls-item-h .x { margin-left: auto; }
.cls-ed { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cls-ed input.num { width: 120px; font-variant-numeric: tabular-nums; }
.cls-ed input.sm { width: 76px; }
.cls-ed select { width: auto; }
.grow { flex: 1 1 200px; min-width: 0; }
.cls-st { display: inline-flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.cls-st:empty { display: none; }
.cls-hint { font-size: 12px; color: var(--muted); }
.cls-hint.bad { color: var(--danger); font-weight: 600; }
.cls-grp { display: flex; flex-direction: column; gap: 4px; }
.cls-chips .qchip { min-height: 36px; }
.cls-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 4px 12px; }
.cls-checks label { display: flex; align-items: center; gap: 8px; font-size: 14px; min-height: 34px; }
.cls-checks label.sub { padding-left: 14px; color: var(--ink-2); }
@media (max-width: 600px) { .cls-items { grid-template-columns: 1fr; } .cls-sheet tbody th.sticky { min-width: 128px; max-width: 150px; font-size: 13px; }
  .cls-sheet .cls-star { min-width: 24px; font-size: 15px; } }

/* 1.6.0: quên mật khẩu / PIN */
.ok-box { background: var(--green-tint); color: var(--green-dark); border-radius: 12px; padding: 10px 14px; font-size: 14px; line-height: 1.45; }
.cls-item .stack > input.grow, dialog .cls-item .stack > input.grow { flex: none; }
.cls-vgroup { grid-column: 1 / -1; border: 1px solid var(--line-2); border-radius: 14px; padding: 10px 12px; background: #fff; display: flex; flex-direction: column; gap: 8px; }
.cls-vgroup.filled { border-color: var(--green); background: #FBFEF9; }
.cls-vitems { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.cls-vitems .cls-item { padding: 8px 10px; }
.cls-sugg .advice { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; justify-content: space-between; }
input[data-year].invalid { border-color: var(--danger); box-shadow: 0 0 0 2px #FDE2E1; }
.code-chip { font: inherit; font-size: 12px; font-weight: 700; letter-spacing: .5px; font-variant-numeric: tabular-nums; border: 1px solid var(--line-2); background: #fff; color: var(--peach-darker); cursor: pointer; }
.code-txt { font-weight: 500; letter-spacing: .3px; font-variant-numeric: tabular-nums; }

/* Nhãn mức chứng cứ (y học thực chứng) */
.ev { display: inline-flex; align-items: center; font: inherit; font-size: 11px; font-weight: 600; line-height: 1.3; padding: 2px 8px; border-radius: 999px; border: 1px solid transparent; cursor: pointer; vertical-align: middle; white-space: normal; text-align: left; }
.ev-high { background: #E3F1E0; color: #2E5226; border-color: #C5E0BD; }
.ev-mid { background: #FFF1DC; color: #7A4300; border-color: #F3D9AE; }
.ev-low { background: #EEEAEC; color: #5A4A51; border-color: #DCD3D7; }
.ev:hover { filter: brightness(.96); }
.ev-table td { vertical-align: top; }
