:root{font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif}
body{margin:0;background:#fafafa;color:#111}
.container{max-width:900px;margin:0 auto;padding:16px}
.topbar{background:#111;color:#fff}
.topbar .container{display:flex;align-items:center;justify-content:space-between;gap:12px}
.brand{font-weight:700}
.nav a{color:#fff;text-decoration:none;margin-left:12px}
h1{margin:10px 0 8px;font-size:22px}
h2{margin:14px 0 8px;font-size:16px}
.card{background:#fff;border:1px solid #e5e5e5;border-radius:14px;padding:12px;margin:10px 0}
.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(320px,1fr));gap:12px}
.table{width:100%;border-collapse:collapse;margin-top:10px;background:#fff}
.table th,.table td{border:1px solid #e5e5e5;padding:8px;text-align:left;vertical-align:top}
.form{display:grid;gap:10px;max-width:820px}
label{display:grid;gap:6px}
input,select,textarea{padding:8px;border:1px solid #cfcfcf;border-radius:10px;font:inherit;background:#fff}
textarea{min-height:90px}
.btn{display:inline-block;padding:8px 12px;border:1px solid #222;border-radius:12px;text-decoration:none;color:#111;background:#fff}
.btn.primary{background:#111;color:#fff}
.btnrow{display:flex;gap:10px;flex-wrap:wrap;margin-top:10px}
.flash{background:#fff6d6;border:1px solid #ffe2a1;padding:10px;border-radius:12px;margin:10px 0}
.mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;white-space:pre-wrap;background:#f6f6f6;border:1px solid #eaeaea;padding:10px;border-radius:12px;overflow:auto}
.small{font-size:12px;color:#444}


/* Tooth chart (UI) */
.toothchart{width:100%;border-collapse:collapse;background:#fff;border:1px solid #e5e5e5;border-radius:12px;overflow:hidden}
.toothchart td,.toothchart th{border:1px solid #e5e5e5;padding:6px;text-align:center;font-size:12px}
.toothchart .arch-title th{background:#f6f6f6;font-weight:700}
.toothchart .toothinput input{width:100%;max-width:62px;text-align:center}
.toothchart .toothnum td{font-weight:700}


/* Print-like checkbox rows for history/exam */
.hxbox{background:#fff;border:1px solid #e5e5e5;border-radius:14px;padding:10px}
.hxrow{display:grid;grid-template-columns:90px 90px 130px 1fr;gap:10px;align-items:center;margin:6px 0}
.hxname{font-weight:600}
.hxopt{display:flex;align-items:center;gap:6px}
.hxdetail{width:100%;padding:8px;border:1px solid #cfcfcf;border-radius:10px}


/* ===== BA-18 input layout (match print as close as possible) ===== */
.ba18paper{
  max-width: 210mm;
  margin: 0 auto;
  background:#fff;
  border:1px solid #e5e5e5;
  border-radius:16px;
  padding:14px 16px;
}
.ba18paper *{font-family:"Times New Roman", serif}
.ba18paper h2{font-size:14pt;margin:10px 0 6px}
.ba18paper h3{font-size:12pt;margin:8px 0 6px}
.ba18paper .sec-title{font-weight:700;font-size:13pt;margin:10px 0 6px}
.ba18paper .sub-title{font-weight:700;margin:6px 0 4px}
.ba18row{display:flex;gap:10px;flex-wrap:wrap;align-items:flex-end;margin:6px 0}
.ba18row .lbl{min-width:140px;font-weight:700}
.ba18row .fill{flex:1;min-width:160px;border-bottom:1px dotted #000;padding:2px 4px}
.ba18inline{display:flex;align-items:center;gap:14px;flex-wrap:wrap;margin:4px 0}
.ba18inline label{display:flex;align-items:center;gap:6px}
.ba18dots{margin:4px 0 10px}
.ba18dotline{min-height:26px;border-bottom:1px dotted #000;padding:2px 6px}
.ba18textarea{
  width:100%;
  border:none;
  border-bottom:1px dotted #000;
  border-radius:0;
  padding:6px 6px;
  background:#fff;
  resize:vertical;
  outline:none;
}
.ba18textarea:focus{border-bottom:2px dotted #000}
.ba18note{font-size:12px;color:#333;margin-top:2px}
.ba18table{width:100%;border-collapse:collapse;margin-top:6px}
.ba18table th,.ba18table td{border:1px solid #000;padding:6px;font-size:11pt;vertical-align:top}
.ba18table input{border:none;outline:none;width:100%;font-family:"Times New Roman", serif;font-size:11pt;padding:2px}
.ba18table input:focus{border-bottom:2px dotted #000}
.ba18hr{border:none;border-top:1px solid #000;margin:10px 0}
.ba18checkbox{display:flex;align-items:center;gap:6px}
.ba18checkbox input{width:16px;height:16px}
.ba18hx{
  border:1px solid #000;
  padding:8px;
  margin-top:6px;
}
.ba18hxrow{
  display:grid;
  grid-template-columns:70px 80px 120px 1fr;
  gap:8px;
  align-items:center;
  margin:6px 0;
}
.ba18hxrow .hxdetail{
  border:none;
  border-bottom:1px dotted #000;
  padding:4px 6px;
  outline:none;
  font-family:"Times New Roman", serif;
  font-size:11pt;
}
.ba18hxrow .hxdetail:focus{border-bottom:2px dotted #000}
.ba18toothchart{width:100%;border-collapse:collapse;margin-top:6px}
.ba18toothchart td,.ba18toothchart th{border:1px solid #000;padding:6px;text-align:center;font-size:11pt}
.ba18toothchart .arch-title th{font-weight:700}
.ba18toothchart input{
  width:100%;
  text-align:center;
  border:none;
  outline:none;
  font-family:"Times New Roman", serif;
  font-size:11pt;
}
.ba18toothchart input:focus{border-bottom:2px dotted #000}


/* BA-18 history section exactly like print */
.ba18hxprint{margin-top:6px}
.ba18hxline{
  display:grid;
  grid-template-columns:90px 110px 140px 1fr;
  gap:12px;
  align-items:center;
  margin:8px 0;
  font-size:11pt;
}
.ba18hxline .hxlabel{font-weight:700}
.ba18hxline .hxopt{display:flex;align-items:center;gap:8px}
.ba18hxline .hxopt input{width:16px;height:16px}
.ba18hxline .hxdots{
  border-bottom:1px dotted #000;
  padding:2px 6px;
}
.ba18hxline .hxtext{
  width:100%;
  border:none;
  outline:none;
  font-family:"Times New Roman", serif;
  font-size:11pt;
  background:#fff;
}
.ba18hxline .hxtext:focus{outline:none}


/* Force inline labels inside BA-18 lines (override global label{display:grid}) */
.ba18paper .ba18hxline label{display:flex !important; gap:8px !important; align-items:center !important; margin:0 !important}
.ba18paper .ba18hxline{white-space:nowrap}

/* Square checkbox like printed form */
.ba18chk{
  appearance:none;
  -webkit-appearance:none;
  width:16px;
  height:16px;
  border:2px solid #000;
  border-radius:2px;
  display:inline-block;
  position:relative;
  background:#fff;
}
.ba18chk:checked::after{
  content:"";
  position:absolute;
  left:4px;
  top:0px;
  width:5px;
  height:10px;
  border:solid #000;
  border-width:0 2px 2px 0;
  transform:rotate(45deg);
}


/* BA-18 exam checkbox lines */
.ba18examblock{margin-top:8px}
.ba18examline{
  display:flex;
  align-items:center;
  gap:14px;
  flex-wrap:wrap;
  margin:8px 0 4px;
  font-size:11pt;
}
.ba18examline .exlabel{font-weight:700}
.ba18examline .exopt{display:flex !important; align-items:center !important; gap:8px !important}
.ba18examline .exdots{
  flex:1;
  min-width:260px;
  border-bottom:1px dotted #000;
  padding:2px 6px;
}
.ba18examline .extext{
  width:100%;
  border:none;
  outline:none;
  font-family:"Times New Roman", serif;
  font-size:11pt;
  background:#fff;
}

.ba18big14{font-size:14pt;font-weight:700;margin:8px 0 4px}

/* more writing space for dotted note fields */
.ba18examline .exdots.long{min-width:420px}

.toothtip{position:fixed;z-index:9999;max-width:320px;background:#fff;border:1px solid #000;padding:8px;border-radius:10px;box-shadow:0 6px 18px rgba(0,0,0,.12);font-family:Times New Roman,serif;font-size:11pt;white-space:pre-wrap}

/* Header bar: light blue */
.header, header, .topbar, .navbar {
  background: #d9ecff !important;
}
.header a, header a, .topbar a, .navbar a {
  color: #000 !important;
}


/* BA-18 signature block (VII) */
.ba18signgrid{display:flex;gap:24px;margin:12px 0 4px}
.ba18signcol{flex:1;text-align:center}
@media (max-width:800px){.ba18signgrid{flex-direction:column}}


/* Form action buttons (save/cancel) */
.form-actions{display:flex;gap:10px;justify-content:flex-end;flex-wrap:wrap;margin:14px 0 4px}
.form-actions .btn{min-width:120px;text-align:center}

/* Table: hiển thị rõ như Excel */
#sheet { width: 100%; min-width: 1600px; border-collapse: collapse; }
#sheet th, #sheet td { vertical-align: top; }
#sheet thead th { position: sticky; top: 0; background: #fff; z-index: 2; }

/* Input/Textarea full width */
#sheet .inp { width: 100%; box-sizing: border-box; }
#sheet textarea.inp { min-height: 54px; resize: vertical; white-space: pre-wrap; }

/* Cột diễn biến/xử trí rộng hơn */
.th-date { width: 130px; }
.th-course { width: 320px; }
.th-mgmt { width: 320px; }
.th-service { width: 260px; }
.th-money { width: 130px; }
.th-status { width: 140px; }
.th-person { width: 140px; }

/* Modal */
.modal-backdrop { position: fixed; inset:0; background: rgba(0,0,0,.35); display:none; align-items:center; justify-content:center; z-index:9999; }
.modal { width: 900px; max-width: 95vw; background:#fff; border-radius:12px; padding:14px; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.modal .head { display:flex; gap:10px; align-items:center; justify-content:space-between; }
.modal .list { max-height: 420px; overflow:auto; border:1px solid #ddd; border-radius:10px; margin-top:10px; }
.modal table { width:100%; border-collapse:collapse; }
.modal th, .modal td { padding:8px; border-bottom:1px solid #eee; }
.modal tr:hover { background:#f6f6f6; cursor:pointer; }

/* ===== Vật liệu module helpers ===== */
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.grid3{display:grid;grid-template-columns:1fr 1fr 1fr;gap:12px}
@media (max-width:720px){
  .grid2,.grid3{grid-template-columns:1fr}
}
.alert{padding:10px 12px;border-radius:12px;margin:10px 0}
.alert.error{background:#ffecec;border:1px solid #ffb7b7}
.alert.success{background:#ecfff1;border:1px solid #a7f0bb}
.btn.danger{background:#a31400;color:#fff;border-color:#a31400}
