:root{
  --navy:#0f2a52;
  --navy-dark:#081a35;
  --paper:#f4f6f9;
  --card:#ffffff;
  --line:#dbe1ea;
  --ink:#1c2938;
  --muted:#5b6b7f;
  --accent:#2563eb;
  --good:#16794f;
  --warn:#b45309;
  --bad:#b91c1c;
  font-size:15px;
}
*{box-sizing:border-box;}
body{
  margin:0;
  font-family:"Segoe UI",Tahoma,Arial,sans-serif;
  background:var(--paper);
  color:var(--ink);
}
#root.login-screen{
  min-height:100vh;
  display:flex;align-items:center;justify-content:center;
  background:linear-gradient(160deg,var(--navy-dark),var(--navy));
}
.login-wrap{width:100%;display:flex;justify-content:center;padding:20px;}
.login-card{
  background:#fff;border-radius:14px;padding:34px 34px 28px;width:360px;max-width:100%;
  box-shadow:0 20px 60px rgba(0,0,0,.35);
  display:flex;flex-direction:column;align-items:center;
}
.login-logo{height:74px;margin-bottom:14px;}
.login-title{font-size:16px;font-weight:800;color:var(--navy-dark);text-align:center;}
.login-sub{font-size:12.5px;color:var(--muted);margin:6px 0 18px;text-align:center;}
.login-card .field{width:100%;}
.login-card input{width:100%;}
.login-card button{width:100%;margin-top:6px;padding:11px;font-size:14px;}
.login-error{
  width:100%;background:#fbe9e9;color:var(--bad);border-radius:7px;padding:9px 12px;font-size:12.5px;margin-bottom:12px;
}
.session-info{font-size:11px;color:#9db3d6;display:flex;flex-direction:column;gap:6px;margin-bottom:8px;}
.session-info button{padding:4px 8px;font-size:11px;}
.role-select-card{width:420px;}
.role-tile-grid{
  display:grid;grid-template-columns:1fr 1fr;gap:12px;width:100%;margin-top:6px;
}
.role-tile{
  display:flex;flex-direction:column;align-items:center;gap:8px;
  padding:20px 10px;border:1px solid var(--line);border-radius:12px;background:#f7faff;
  font-family:inherit;cursor:pointer;
}
.role-tile:hover{border-color:var(--accent);background:#eef4ff;transform:translateY(-1px);}
.role-tile-icon{font-size:28px;}
.role-tile-label{font-size:13.5px;font-weight:700;color:var(--navy-dark);}
.login-other-link{
  display:block;margin-top:16px;font-size:12px;color:var(--accent);text-align:center;text-decoration:none;width:100%;
}
.login-other-link:hover{text-decoration:underline;}

.app{
  display:flex;
  min-height:100vh;
}
.sidebar{
  width:220px;
  background:var(--navy-dark);
  color:#eaf0fb;
  flex-shrink:0;
  padding:20px 0;
  display:flex;
  flex-direction:column;
}
.brand{
  padding:0 20px 18px;
  border-bottom:1px solid rgba(255,255,255,.12);
  margin-bottom:10px;
}
.brand-title{font-weight:700;font-size:15px;line-height:1.3;}
.brand-sub{font-size:11.5px;color:#9db3d6;margin-top:4px;}
.navitem{
  padding:11px 20px;
  cursor:pointer;
  font-size:13.5px;
  color:#c7d4ea;
  border-left:3px solid transparent;
  user-select:none;
}
.navitem:hover{background:rgba(255,255,255,.06);}
.navitem.active{
  background:rgba(255,255,255,.1);
  color:#fff;
  border-left-color:var(--accent);
  font-weight:600;
}
.sidebar-foot{
  margin-top:auto;
  padding:14px 20px 0;
  font-size:10.5px;
  color:#6f84a8;
  border-top:1px solid rgba(255,255,255,.1);
}
.sidebar-foot .credit{
  margin-top:2px;
  font-size:13px;
  font-weight:800;
  letter-spacing:.02em;
  color:#ffd166;
  text-shadow:0 1px 3px rgba(0,0,0,.35);
}

#splash{
  position:fixed;inset:0;z-index:999;
  background:#ffffff;
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  color:var(--navy-dark);transition:opacity .35s ease;
}
#splash .splash-logos{display:flex;align-items:center;gap:26px;margin-bottom:20px;}
#splash .splash-logos img{height:130px;filter:drop-shadow(0 2px 6px rgba(0,0,0,.15));}
#splash .splash-title{font-size:22px;font-weight:700;letter-spacing:.02em;text-align:center;padding:0 20px;color:var(--navy-dark);}
#splash .splash-sub{font-size:12.5px;color:var(--muted);margin-top:8px;letter-spacing:.08em;text-transform:uppercase;}
#splash .splash-footer{
  position:absolute;bottom:26px;
  font-size:16px;font-weight:800;letter-spacing:.02em;
  color:var(--navy);
}
.main{
  flex:1;
  padding:26px 34px 60px;
  max-width:1180px;
}
.pagehead{margin-bottom:22px;}
.pagehead h1{font-size:20px;margin:0 0 4px;color:var(--navy-dark);}
.pagehead p{margin:0;color:var(--muted);font-size:13px;}
.card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:10px;
  padding:20px 22px;
  margin-bottom:18px;
}
.card h2{font-size:14.5px;margin:0 0 14px;color:var(--navy-dark);}
.row{display:flex;gap:12px;flex-wrap:wrap;}
.field{display:flex;flex-direction:column;gap:5px;margin-bottom:12px;}
.field label{font-size:11.5px;color:var(--muted);font-weight:600;text-transform:uppercase;letter-spacing:.03em;}
.field input, .field select{
  padding:8px 10px;
  border:1px solid var(--line);
  border-radius:6px;
  font-size:13.5px;
  min-width:160px;
  background:#fff;
  color:var(--ink);
}
.field input:focus, .field select:focus{outline:2px solid var(--accent);outline-offset:1px;}
button{
  font-family:inherit;
  font-size:13px;
  font-weight:600;
  border-radius:7px;
  border:1px solid var(--line);
  background:#fff;
  color:var(--navy-dark);
  padding:9px 16px;
  cursor:pointer;
}
button:hover{background:#eef2f8;}
button.primary{background:var(--navy);border-color:var(--navy);color:#fff;}
button.primary:hover{background:var(--navy-dark);}
button.ghost{border-color:transparent;background:transparent;color:var(--accent);padding:6px 8px;}
button.danger{color:var(--bad);}
button:disabled{opacity:.45;cursor:not-allowed;}
table.grid{width:100%;border-collapse:collapse;font-size:13px;}
table.grid th{
  text-align:left;
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:.03em;
  color:var(--muted);
  border-bottom:1px solid var(--line);
  padding:8px 10px;
}
table.grid td{padding:9px 10px;border-bottom:1px solid #eef1f6;}
table.grid tr:hover td{background:#f7f9fc;}
table.grid tr.family-start td{border-top:2px solid var(--line);}
.badge{display:inline-block;padding:2px 8px;border-radius:100px;font-size:11px;font-weight:700;}
.badge.ok{background:#e5f6ee;color:var(--good);}
.badge.warn{background:#fdf1e3;color:var(--warn);}
.badge.bad{background:#fbe9e9;color:var(--bad);}
.drop{
  border:2px dashed var(--line);
  border-radius:10px;
  padding:36px 20px;
  text-align:center;
  color:var(--muted);
  background:#fafcff;
  cursor:pointer;
}
.drop.drag{border-color:var(--accent);background:#eef4ff;}
.drop input{display:none;}
.small{font-size:12px;color:var(--muted);}
.tag{
  display:inline-flex;align-items:center;gap:5px;
  background:#eef2f8;border-radius:6px;padding:3px 9px;font-size:12px;color:var(--navy-dark);
}
.samplelist{display:flex;flex-direction:column;gap:8px;margin-top:14px;}
.samplerow{
  display:flex;align-items:center;justify-content:space-between;
  border:1px solid var(--line);border-radius:8px;padding:10px 14px;background:#fff;
}
.samplerow.active{border-color:var(--accent);box-shadow:0 0 0 2px rgba(37,99,235,.15);}
.samplerow .who{font-weight:600;font-size:13.5px;}
.samplerow .meta{font-size:11.5px;color:var(--muted);}
.editor-panel{
  border:1px solid var(--accent);
  border-radius:8px;
  background:#f7faff;
  padding:16px;
  margin:-2px 0 6px;
}
.typegrid{display:grid;grid-template-columns:repeat(auto-fill, minmax(180px,1fr));gap:10px;}
.typebtn{
  padding:16px 14px;text-align:left;font-size:13.5px;font-weight:700;
  border:1px solid var(--line);border-radius:9px;background:#fff;color:var(--navy-dark);
}
.typebtn:hover{border-color:var(--accent);background:#f2f7ff;}
.toolbar{display:flex;gap:10px;margin:14px 0;flex-wrap:wrap;align-items:center;}
.searchbox{flex:1;min-width:180px;}
.searchbox input{width:100%;}
.modal-backdrop{
  position:fixed;inset:0;background:rgba(10,18,32,.45);
  display:flex;align-items:center;justify-content:center;z-index:50;
}
.modal{
  background:#fff;border-radius:12px;padding:22px 24px;width:420px;max-width:92vw;
  box-shadow:0 20px 60px rgba(0,0,0,.25);
}
.modal.wide{width:820px;}
.modal h3{margin:0 0 14px;font-size:15px;}
.modal .actions{display:flex;justify-content:flex-end;gap:10px;margin-top:16px;}
.family-rows-head{
  display:grid;grid-template-columns:110px 1.4fr 160px 90px 90px 1fr 70px;gap:8px;
  font-size:11px;text-transform:uppercase;letter-spacing:.03em;color:var(--muted);padding:0 2px;margin-bottom:4px;
}
.family-rows{display:flex;flex-direction:column;gap:8px;max-height:320px;overflow-y:auto;margin-bottom:10px;}
.family-row{
  display:grid;grid-template-columns:110px 1.4fr 160px 90px 90px 1fr 70px;gap:8px;align-items:center;
}
.family-row select, .family-row input{
  padding:7px 8px;border:1px solid var(--line);border-radius:6px;font-size:12.5px;width:100%;
}
.family-row-dob{display:flex;flex-direction:column;gap:2px;}
.family-row-dob input{width:100%;}
.family-row-dob span{font-size:10.5px;color:var(--muted);}
.hint{font-size:12px;color:var(--muted);margin-top:6px;}
.unmapped{
  background:#fdf1e3;border:1px solid #f3d9ad;border-radius:8px;padding:12px 14px;margin-top:10px;font-size:12.5px;
}
.patientpicker{position:relative;display:inline-block;min-width:260px;margin:6px 8px 6px 0;vertical-align:top;}
.patientpicker input{width:100%;padding:8px 10px;border:1px solid var(--line);border-radius:6px;font-size:13px;}
.picker-results{
  position:absolute;top:calc(100% + 4px);left:0;right:0;z-index:20;
  background:#fff;border:1px solid var(--line);border-radius:8px;
  box-shadow:0 8px 22px rgba(20,30,50,.15);max-height:220px;overflow-y:auto;
}
.picker-row{padding:8px 12px;font-size:13px;cursor:pointer;}
.picker-row:hover{background:#eef4ff;}
.picker-empty{padding:8px 12px;font-size:12.5px;color:var(--muted);}
.dot{width:8px;height:8px;border-radius:50%;display:inline-block;margin-right:6px;}

/* ---------- Report sheet (letterhead) ---------- */
.sheet-wrap{background:#e8ecf3;padding:22px;border-radius:10px;overflow:auto;}
.sheet{
  width:794px;
  min-height:1000px;
  background:#fff;
  margin:0 auto;
  padding:34px 42px 50px;
  box-shadow:0 2px 10px rgba(0,0,0,.12);
  font-family:"Times New Roman",Georgia,serif;
  color:#000;
}
.sheet-header{
  display:flex;align-items:center;justify-content:center;gap:18px;
  border-bottom:2px solid #000;padding-bottom:10px;margin-bottom:14px;
}
.sheet-header img{height:64px;}
.sheet-header .htext{text-align:center;}
.sheet-header .htext .h1{font-size:25px;font-weight:800;letter-spacing:.02em;}
.sheet-header .htext .h2{font-size:17px;font-weight:600;margin-top:4px;}
.sheet-patient{
  display:grid;grid-template-columns:1fr 1fr;gap:2px 24px;font-size:13px;margin-bottom:10px;
}
.sheet-patient .pf{display:flex;gap:6px;}
.sheet-patient .pf b{font-weight:700;}
.sheet-patient input, .sheet-patient select{
  font-family:inherit;font-size:13px;border:none;border-bottom:1px dotted #888;background:transparent;
  padding:0 2px;min-width:110px;
}
.sheet-title{
  text-align:center;font-weight:700;font-size:15px;margin:12px 0 2px;letter-spacing:.03em;
}
.sheet-note{text-align:center;font-size:11.5px;font-style:italic;margin-bottom:10px;}
.sheet table{width:100%;border-collapse:collapse;font-size:12.5px;margin-bottom:4px;}
.sheet table th{
  border:1px solid #000;padding:5px 8px;background:#eef1f6;font-weight:700;text-align:left;
}
.sheet table td{border:1px solid #000;padding:5px 8px;}
.sheet .section-row td{background:#f4f4f4;font-weight:700;font-style:italic;}
.sheet .result-input{
  width:90px;border:none;border-bottom:1px solid #999;font-family:inherit;font-size:12.5px;background:transparent;
  padding:1px 2px;
}
.sheet .arrow{font-weight:700;margin-left:4px;}
.sheet table.summary-table{font-size:10.5px;}
.sheet table.summary-table th, .sheet table.summary-table td{padding:4px 6px;}
.sheet table.summary-table td.summary-results{max-width:260px;}
.sheet .arrow.up{color:#b91c1c;}
.sheet .arrow.down{color:#1d4ed8;}
.sheet-footer{margin-top:90px;display:flex;justify-content:space-between;font-size:13px;padding:0 10px;}
.sheet-footer .sig{text-align:center;}
.sheet-footer .line{margin-bottom:2px;}

@media print{
  body *{visibility:hidden;}
  .sheet-wrap, .sheet-wrap *{visibility:visible;}
  .sheet-wrap{position:absolute;left:0;top:0;padding:0;background:#fff;border-radius:0;}
  .sheet{box-shadow:none;margin:0;width:210mm;min-height:297mm;padding:14mm 16mm;}
  @page{size:A4;margin:0;}
}
