:root{ --ink:#1a1a1a; --line:#c9c9c9; --brand:#7a1f2b; --bg:#f4f4f2; }
  *{ box-sizing:border-box; }
  body{ font-family:"Segoe UI",Arial,sans-serif; margin:0; background:var(--bg); color:var(--ink); }
  .app{ display:grid; grid-template-columns: 460px 1fr; min-height:100vh; }

  /* form panel */
  .panel{ background:#fff; border-right:1px solid var(--line); padding:16px 18px; overflow:auto; }
  .panel h2{ font-size:15px; margin:0 0 2px; }
  .panel p.hint{ font-size:12px; color:#666; margin:0 0 10px; }
  .grp{ border:1px solid #eee; border-radius:8px; padding:8px 12px 12px; margin-bottom:10px; }
  .grp > .gt{ font-size:11px; font-weight:700; text-transform:uppercase; color:var(--brand); letter-spacing:.5px; margin:2px 0 6px; }
  .fld{ margin:8px 0; }
  .fld label{ display:block; font-size:12px; font-weight:600; margin-bottom:3px; }
  select, input, textarea{ width:100%; font-family:inherit; font-size:13px; padding:7px; border:1px solid var(--line); border-radius:6px; background:#fff; }
  textarea{ resize:vertical; min-height:52px; }
  .other{ margin-top:5px; }
  .two{ display:flex; gap:8px; } .two > *{ flex:1; }
  .toolbar{ position:sticky; top:0; background:#fff; padding-bottom:8px; margin-bottom:6px; z-index:2; display:flex; gap:8px; flex-wrap:wrap; }
  button{ cursor:pointer; border:none; border-radius:6px; padding:9px 12px; font-size:13px; font-weight:600; }
  .primary{ background:var(--brand); color:#fff; }
  .ghost{ background:#eee; color:#333; }

  /* sheet */
  .stage{ padding:22px; display:flex; justify-content:center; align-items:flex-start; }
  .sheet{ background:#fff; width:210mm; min-height:297mm; padding:16mm 14mm; box-shadow:0 2px 16px rgba(0,0,0,.12); font-size:12.5px; line-height:1.5; }
  .lh{ display:flex; align-items:center; justify-content:space-between; border-bottom:2px solid #000; padding-bottom:8px; margin-bottom:10px; } .lh .logo{ width:22mm; height:22mm; object-fit:contain; } .lhtext{ text-align:center; flex:1; }
  .lh .name{ color:#000; font-weight:800; font-size:19px; font-family:Cambria,Georgia,serif; }
  .lh .sub{ font-size:11px; color:#000; font-weight:700; font-family:Cambria,Georgia,serif; }
  .title2{ text-align:center; font-weight:800; letter-spacing:2px; font-size:15px; margin:8px 0 12px; }
  .grid2{ display:grid; grid-template-columns:1fr 1fr; gap:2px 24px; margin-bottom:8px; }
  .f{ margin:3px 0; } .k{ font-weight:700; text-transform:uppercase; font-size:11px; color:#333; }
  .v{ outline:none; } .inline .v{ display:inline; }
  .v:empty:before{ content:attr(data-ph); color:#c8c8c8; font-style:italic; }
  .v:focus{ background:#fff7d6; box-shadow:0 0 0 2px #ffe9a6; border-radius:3px; }
  .sec{ margin-top:10px; } .sec > .v{ white-space:pre-line; } .sec .k{ display:block; border-bottom:1px solid var(--line); padding-bottom:2px; margin-bottom:3px; }
  .vitals{ display:grid; grid-template-columns:repeat(3,1fr); gap:2px 18px; }
  .sign{ margin-top:34px; } .sign .who{ font-weight:700; }
  .foot{ margin-top:16px; border-top:1px solid var(--line); padding-top:6px; font-size:10px; color:#666; text-align:center; }


  /* ===== sign-in / patient list screens ===== */
  [hidden]{ display:none !important; }
  .screen{ min-height:100vh; display:flex; align-items:flex-start; justify-content:center; padding:40px 16px; }
  .card{ background:#fff; border:1px solid var(--line); border-radius:12px; padding:28px 26px; width:100%; max-width:380px; box-shadow:0 2px 16px rgba(0,0,0,.08); }
  .card img{ display:block; margin:0 auto 10px; width:72px; height:72px; object-fit:contain; }
  .card h1{ font-size:18px; text-align:center; margin:0 0 4px; }
  .card .sub{ text-align:center; color:#666; font-size:13px; margin:0 0 14px; }
  .card label{ display:block; font-size:12px; font-weight:600; margin:12px 0 4px; }
  .card .primary{ width:100%; margin-top:16px; padding:11px; font-size:14px; }
  .msg{ font-size:12px; color:#b00; min-height:16px; margin-top:10px; }
  .msg.ok{ color:#087443; }
  .demo{ background:#fff4d6; border:1px solid #f0d58a; border-radius:8px; padding:8px 10px; font-size:12px; margin-top:14px; }
  .listwrap{ width:100%; max-width:980px; }
  .listhead{ display:flex; justify-content:space-between; align-items:flex-start; gap:12px; margin-bottom:10px; }
  .listhead h1{ font-size:20px; margin:0; }
  .listhead .sub{ font-size:13px; color:#666; margin-top:2px; }
  .listhead .actions{ display:flex; gap:8px; }
  #listSearch{ margin:8px 0; }
  #listTable{ width:100%; border-collapse:collapse; background:#fff; border:1px solid var(--line); font-size:13px; }
  #listTable th{ background:#faf3f4; text-align:left; padding:9px 10px; font-size:11px; text-transform:uppercase; color:var(--brand); border-bottom:1px solid var(--line); }
  #listTable td{ padding:10px; border-bottom:1px solid #eee; }
  #listTable tbody tr{ cursor:pointer; }
  #listTable tbody tr:hover, #listTable tbody tr:focus{ background:#fff7d6; outline:none; }
  .casebar{ display:flex; align-items:center; gap:8px; background:#faf3f4; border:1px solid #eadada; border-radius:8px; padding:8px 10px; margin-bottom:10px; }
  .casebar .cbtext{ flex:1; font-size:12px; line-height:1.3; }
  .casebar .cbtext span{ display:block; color:#666; }
  .casebar button{ padding:6px 10px; font-size:12px; }

  @media print{
    body{ background:#fff; } .app{ display:block; } .panel, .no-print{ display:none !important; }
    .stage{ padding:0; } .sheet{ box-shadow:none; width:auto; min-height:auto; padding:8mm 6mm; }
    @page{ size:A4; margin:10mm; }
  }

  /* ===== saving to the server ===== */
  .savebar{ display:flex; align-items:center; gap:10px; margin-bottom:10px; }
  .savebar button{ padding:7px 12px; }
  .savestatus{ font-size:12px; color:#666; }
  .savestatus.dirty{ color:#a15c00; }
  .savestatus.saving{ color:#555; }
  .savestatus.saved{ color:#087443; }
  .savestatus.error{ color:#b00; font-weight:600; }
  .conflict{ background:#fdecec; border:1px solid #f3b8b8; border-radius:8px; padding:10px 12px; margin-bottom:10px; font-size:12px; }
  .conflict .row{ margin-top:8px; display:flex; gap:8px; }
  .conflict .row button{ flex:1; padding:7px 8px; font-size:12px; }
  #listTable td.sumcol{ font-size:12px; color:#555; }
  #listTable td.sumcol b{ color:#087443; font-weight:600; }
