:root{
    --brand-red:#d32131;
    --brand-red-dk:#a5192628;
    --ink:#111417;
    --ink-soft:#4a5157;
    --rule:#1b1f23;
    --hair:#9aa2a8;
    --paper:#ffffff;
    --desk:#e7e9ec;
    --chrome:#1b2026;
    --field:#0d3b8c;           /* entered data reads blue on screen, like a signed form */
    --focus:#fff3cd;
  }

  *{box-sizing:border-box;}

  html,body{margin:0;padding:0;}
  body{
    background:var(--desk);
    color:var(--ink);
    font-family:"Times New Roman",Times,Georgia,serif;
    font-size:16px;
    -webkit-text-size-adjust:100%;
  }

  /* ---------- screen chrome ---------- */
  .toolbar{
    position:sticky; top:0; z-index:50;
    background:var(--chrome);
    border-bottom:3px solid var(--brand-red);
    padding:10px 18px;
    display:flex; align-items:center; gap:18px; flex-wrap:wrap;
    font-family:"Arial Narrow",Arial,Helvetica,sans-serif;
  }
  .toolbar .tb-title{
    color:#fff; font-size:15px; letter-spacing:.09em; text-transform:uppercase;
    font-weight:700; margin-right:auto;
  }
  .toolbar .tb-title span{display:block;color:#9aa5af;font-weight:400;letter-spacing:.04em;text-transform:none;font-size:12px;}
  .btn{
    font:600 13px/1 "Arial Narrow",Arial,Helvetica,sans-serif;
    letter-spacing:.06em; text-transform:uppercase;
    background:#2c343d; color:#e8ecef; border:1px solid #444d57;
    padding:9px 14px; border-radius:2px; cursor:pointer;
  }
  .btn:hover{background:#39434e;}
  .btn:focus-visible{outline:2px solid var(--brand-red); outline-offset:2px;}
  .btn.primary{background:var(--brand-red); border-color:var(--brand-red); color:#fff;}
  .btn.primary:hover{background:#b81b29;}
  .tb-note{color:#8b959e;font-size:12px;font-family:Arial,Helvetica,sans-serif;}

  .deskpad{padding:26px 12px 60px;}

  /* ---------- branch bar + directory ---------- */
  .branchbar{
    background:#2c343d; border-bottom:1px solid #414b56;
    padding:9px 18px; display:flex; align-items:center; gap:10px; flex-wrap:wrap;
    font-family:Arial,Helvetica,sans-serif; font-size:13px; color:#c8d0d7;
  }
  .branchbar label{letter-spacing:.05em; text-transform:uppercase; font-size:11px; color:#8e99a3;}
  .branchbar select{
    font:14px/1.2 Arial,Helvetica,sans-serif;
    background:#151a20; color:#e8ecef; border:1px solid #4a545f;
    padding:7px 10px; border-radius:2px; min-width:19rem; max-width:100%;
  }
  .branchbar select:focus-visible{outline:2px solid var(--brand-red); outline-offset:1px;}
  .branchbar .btn{padding:7px 12px;}
  .bb-check{display:inline-flex; align-items:center; gap:6px; color:#c8d0d7; font-size:13px;}
  .bb-check input{width:14px; height:14px; accent-color:var(--brand-red);}
  .bb-status{color:#8e99a3; font-size:12px;}
  .bb-status.warn{color:#f0a742;}

  .dirpanel{
    background:#f6f7f8; border-bottom:1px solid #c9ced3;
    padding:16px 18px 20px; font-family:Arial,Helvetica,sans-serif;
  }
  .dirpanel[hidden]{display:none;}
  .dirpanel h3{margin:0 0 4px; font-size:15px; color:var(--ink);}
  .dirpanel p.dp-help{margin:0 0 12px; font-size:12.5px; color:#5c646b; max-width:62rem; line-height:1.5;}
  .dirpanel .dp-actions{display:flex; gap:10px; margin-bottom:14px; flex-wrap:wrap;}
  .dirpanel .btn{background:#e4e7ea; color:#22282e; border-color:#b8bfc5;}
  .dirpanel .btn:hover{background:#d6dade;}
  .dirpanel .btn.primary{background:var(--brand-red); color:#fff; border-color:var(--brand-red);}
  .dirwrap{max-height:23rem; overflow:auto; border:1px solid #c9ced3; background:#fff;}
  table.dirtable{width:100%; border-collapse:collapse; font-size:13px;}
  table.dirtable th{
    position:sticky; top:0; background:#eceef0; text-align:left;
    padding:7px 8px; border-bottom:1px solid #c9ced3; font-size:11px;
    letter-spacing:.06em; text-transform:uppercase; color:#4a5157;
  }
  table.dirtable td{padding:3px 8px; border-bottom:1px solid #e6e9eb; vertical-align:middle;}
  table.dirtable td.code{font-variant-numeric:tabular-nums; color:#5c646b; width:3.5rem;}
  table.dirtable td.bname{width:15rem; color:var(--ink);}
  table.dirtable input{
    width:100%; font:13px/1.3 Arial,Helvetica,sans-serif; color:var(--ink);
    border:1px solid transparent; background:transparent; padding:4px 5px; border-radius:2px;
  }
  table.dirtable input:hover{border-color:#d2d7db;}
  table.dirtable input:focus{outline:none; border-color:var(--brand-red); background:#fff;}
  table.dirtable tr.filled td.code{color:var(--brand-red); font-weight:700;}
  table.dirtable tr.flagged td.code{color:#b07514; font-weight:700;}
  table.dirtable tr.flagged td.bname::after{content:' \2014 confirm'; color:#b07514; font-size:11px;}

  /* ---------- the sheet ---------- */
  .sheet{
    background:var(--paper);
    width:8.5in; min-height:11in;
    margin:0 auto 26px;
    padding:0.45in 0.5in 0.5in;
    box-shadow:0 2px 14px rgba(20,24,28,.22);
    position:relative;
    display:flex; flex-direction:column;
  }

  /* letterhead repeated on every sheet */
  .letterhead{
    display:flex; align-items:flex-end; justify-content:space-between;
    gap:16px; padding-bottom:7px; margin-bottom:11px;
    border-bottom:2.5px solid var(--brand-red);
  }
  .letterhead img{height:0.52in; width:auto; display:block;}
  .letterhead .lh-meta{
    text-align:right; font-family:Arial,Helvetica,sans-serif;
    font-size:8pt; line-height:1.35; color:var(--ink-soft);
  }
  .letterhead .lh-meta strong{
    display:block; color:var(--ink); font-size:8.5pt;
    letter-spacing:.1em; text-transform:uppercase;
  }

  .formbox{border:1px solid var(--rule); padding:14px 16px 12px; flex:1; display:flex; flex-direction:column;}

  .form-title{
    text-align:center; font-family:Arial,Helvetica,sans-serif;
    font-weight:700; font-size:12.5pt; letter-spacing:.02em;
    margin:2px 0 4px;
  }
  .form-title em{font-style:italic; font-weight:700;}
  .titlerule{height:1px;background:var(--hair);margin:0 0 12px;}

  .topmeta{
    display:flex; gap:26px; justify-content:center; flex-wrap:wrap;
    margin:10px 0 16px; font-size:10.5pt;
  }

  h2.sec{
    font-family:Arial,Helvetica,sans-serif;
    font-size:10pt; font-weight:700; letter-spacing:.01em;
    margin:13px 0 5px;
  }
  h2.sec:first-of-type{margin-top:2px;}
  h3.sub{
    font-family:Arial,Helvetica,sans-serif;
    font-size:9pt; font-weight:700; margin:9px 0 3px 14px;
  }
  h4.subsub{
    font-family:"Times New Roman",Times,serif;
    font-size:9.5pt; font-weight:700; margin:7px 0 2px 26px;
  }
  .body{margin-left:14px;}
  .body.deep{margin-left:26px;}

  /* ---------- field rows ---------- */
  .row{display:flex; align-items:baseline; gap:14px; margin:0 0 4px;}
  .f{display:flex; align-items:baseline; gap:5px; flex:1 1 0; min-width:0;}
  .f.grow2{flex:1.8 1 0;}
  .f.grow3{flex:3 1 0;}
  .f.fixed{flex:0 0 auto;}
  .lbl{font-size:10pt; white-space:nowrap; color:var(--ink);}

  input.fld{
    font-family:Arial,Helvetica,sans-serif;
    font-size:9.5pt; color:var(--field);
    border:0; border-bottom:1px solid var(--rule);
    background:transparent; padding:1px 3px 1px; margin:0;
    flex:1 1 auto; min-width:0; width:100%;
    border-radius:0;
  }
  input.fld.short{flex:0 0 1.35in;}
  select.seln{
    font-family:Arial,Helvetica,sans-serif; font-size:9.5pt; color:var(--field);
    border:0; border-bottom:1px solid var(--rule); background:transparent;
    padding:1px 2px; margin:0; border-radius:0; flex:0 0 1.35in;
    appearance:none; -webkit-appearance:none; cursor:pointer;
    background-image:linear-gradient(45deg,transparent 50%,var(--hair) 50%),linear-gradient(135deg,var(--hair) 50%,transparent 50%);
    background-position:calc(100% - 9px) calc(50% + 1px),calc(100% - 5px) calc(50% + 1px);
    background-size:4px 4px,4px 4px; background-repeat:no-repeat;
  }
  select.seln:focus{outline:none; background-color:var(--focus); border-bottom:1.5px solid var(--brand-red);}
  select.seln.wide{flex:1 1 auto; width:100%; min-width:0;}
  select.seln optgroup{font-style:normal; font-weight:700; color:var(--ink); background:#f2f3f4;}
  select.seln option{color:var(--ink); font-weight:400;}
  input[type="date"].fld{font-variant-numeric:tabular-nums;}
  input[type="date"].fld::-webkit-calendar-picker-indicator{
    opacity:.45; cursor:pointer; margin-left:2px; padding:0;
  }
  input[type="date"].fld:hover::-webkit-calendar-picker-indicator{opacity:.9;}
  input[type="number"].fld{font-variant-numeric:tabular-nums;}
  input.fld.mid{flex:0 0 2.1in;}
  input.fld:focus{outline:none; background:var(--focus); border-bottom:1.5px solid var(--brand-red);}
  input.fld::placeholder{color:#b9c0c6; font-style:italic;}

  /* ---------- checkboxes ---------- */
  .ck{display:inline-flex; align-items:baseline; gap:5px; font-size:10pt; white-space:nowrap; margin-right:16px;}
  .ck input[type="checkbox"]{
    appearance:none; -webkit-appearance:none;
    width:10px; height:10px; flex:0 0 10px;
    border:1.2px solid var(--rule); background:#fff;
    margin:0; position:relative; top:1px; cursor:pointer; border-radius:0;
  }
  .ck input[type="checkbox"]:checked{background:var(--field); box-shadow:inset 0 0 0 1.6px #fff;}
  .ck input[type="checkbox"]:focus-visible{outline:2px solid var(--brand-red); outline-offset:1px;}
  .ck.stack{display:flex; margin:0 0 3px;}

  /* ---------- tables ---------- */
  table.grid{width:100%; border-collapse:collapse; margin:5px 0 4px; table-layout:fixed;}
  table.grid th{
    font-family:"Times New Roman",Times,serif; font-weight:700; font-size:9.5pt;
    border-top:1px solid var(--rule); border-bottom:1px solid var(--rule);
    padding:3px 4px; text-align:center; line-height:1.15;
  }
  table.grid td{
    border:1px solid var(--rule); padding:0; height:19px;
  }
  table.grid td.rowlbl{
    border-left:0; border-right:1px solid var(--rule);
    font-size:9.5pt; padding:2px 4px; text-align:left;
  }
  table.grid td:last-child{border-right:0;}
  table.grid th:first-child{text-align:left; padding-left:4px;}
  table.grid input.cell{
    width:100%; height:100%; min-height:18px;
    border:0; background:transparent; padding:1px 4px;
    font-family:Arial,Helvetica,sans-serif; font-size:9pt; color:var(--field);
    border-radius:0;
  }
  table.grid input.cell:focus{outline:none; background:var(--focus);}
  table.grid input.rowlblfld{
    border:0; border-bottom:1px dotted var(--hair); background:transparent;
    font-family:Arial,Helvetica,sans-serif; font-size:9pt; color:var(--field);
    width:100%; padding:0 2px;
  }
  table.grid input.rowlblfld:focus{outline:none;background:var(--focus);}

  /* ---------- certification blocks ---------- */
  .cert-stmt{font-size:10pt; margin:3px 0 8px 14px;}
  .signline{margin-left:14px;}

  .pagefoot{
    margin-top:auto; padding-top:9px;
    display:flex; justify-content:space-between; align-items:flex-end;
    font-family:Arial,Helvetica,sans-serif; font-size:7.5pt; color:var(--ink-soft);
  }
  .pagefoot .pf-right{font-size:8pt; color:var(--ink);}
  .lh-credit{display:block; font-size:6.5pt; color:#98a0a6; margin-top:1px;}
  .attrib{
    width:8.5in; margin:0 auto 26px; padding:0 .5in;
    font-family:Arial,Helvetica,sans-serif; font-size:7.5pt; color:#5c646b; line-height:1.45; text-align:left;
  }

  /* ---------- print ---------- */
  @page{ size:Letter; margin:0.4in; }
  @media print{
    body{background:#fff;}
    .toolbar,.deskpad>.screen-only,.screen-only{display:none !important;}
    .deskpad{padding:0;}
    .sheet{
      width:auto; min-height:0; margin:0; padding:0;
      box-shadow:none; break-after:page; page-break-after:always;
    }
    .sheet.tail{break-after:auto !important; page-break-after:auto !important;}
    .letterhead{break-inside:avoid;}
    h2.sec,h3.sub,h4.subsub{break-after:avoid; page-break-after:avoid;}
    table.grid,.row{break-inside:avoid; page-break-inside:avoid;}
    input.fld,input.cell,input.rowlblfld{color:#000; background:transparent !important;}
    input::placeholder{color:transparent !important; opacity:0;}
    input.fld:focus{border-bottom:1px solid var(--rule) !important;}
    select.seln{background-image:none !important; color:#000; border-bottom:1px solid var(--rule) !important;}
    input[type="date"]::-webkit-calendar-picker-indicator{display:none !important;}
    input[type="date"]:not(.has-value){color:transparent !important;}
    input[type="number"]::-webkit-inner-spin-button,
    input[type="number"]::-webkit-outer-spin-button{-webkit-appearance:none; display:none;}
    input.cell:focus,input.rowlblfld:focus{background:transparent !important;}
    .ck input[type="checkbox"]:checked{background:#000;}
    .ck input[type="checkbox"]{-webkit-print-color-adjust:exact; print-color-adjust:exact;}
    .letterhead{-webkit-print-color-adjust:exact; print-color-adjust:exact;}
    .attrib{display:none !important;}
    .lh-credit{display:block !important;}
    /* each sheet must fit the printable area on its own, or the renderer
       shrinks everything and lets the next letterhead bleed onto this page */
    .topmeta{margin:6px 0 10px;}
    h2.sec{margin:9px 0 3px;}
    h2.sec:first-of-type{margin-top:0;}
    h3.sub{margin:6px 0 2px;}
    h4.subsub{margin:5px 0 1px;}
    .row{margin-bottom:1px;}
    .cert-stmt{margin:2px 0 5px 14px;}
    table.grid{margin:3px 0 2px;}
    table.grid td{height:14px;}
    table.grid th{padding:2px 4px;}
    .formbox{padding:11px 14px 9px;}
    .pagefoot{padding-top:6px;}
  }

  @media screen and (max-width:900px){
    .sheet{width:100%; padding:14px;}
    .row{flex-wrap:wrap;}
    .f{flex:1 1 100%;}
    input.fld.short,input.fld.mid{flex:1 1 auto;}
  }
  /* ---------- supplements ---------- */
  .suppbar{
    background:#333c46; border-bottom:1px solid #414b56;
    padding:9px 18px; display:flex; align-items:center; gap:16px; flex-wrap:wrap;
    font-family:Arial,Helvetica,sans-serif; font-size:13px; color:#c8d0d7;
  }
  .suppbar > span.sb-lbl{letter-spacing:.05em; text-transform:uppercase; font-size:11px; color:#8e99a3;}
  .sb-check{display:inline-flex; align-items:center; gap:7px; cursor:pointer;}
  .sb-check input{width:15px; height:15px; accent-color:var(--brand-red); cursor:pointer;}
  .sheet[data-supp]{display:none;}
  .sheet[data-supp].on{display:flex;}
  .sheet.flow[data-supp].on{display:block;}

  /* flowing schedule sheets: header row repeats on every printed page */
  table.pagewrap{width:100%; border-collapse:collapse;}
  table.pagewrap > thead{display:table-header-group;}
  table.pagewrap > tbody{display:table-row-group;}
  table.pagewrap > thead > tr > td,
  table.pagewrap > tbody > tr > td{padding:0; border:0;}
  .flowbody{padding:0 2px;}
  .sheet.flow .form-title{line-height:1.25;}
  .rowtools{display:flex; align-items:center; gap:12px; margin:8px 0 4px;}
  .btn.tiny{padding:6px 11px; font-size:12px; background:#e4e7ea; color:#22282e; border-color:#b8bfc5;}
  .btn.tiny:hover{background:#d6dade;}
  .rt-count{font-family:Arial,Helvetica,sans-serif; font-size:12px; color:#5c646b;}
  .seemain{
    font-family:Arial,Helvetica,sans-serif; font-size:8.5pt; font-weight:700;
    text-align:center; margin:14px 0 4px; color:var(--ink);
  }
  table.grid tbody tr{break-inside:avoid; page-break-inside:avoid;}
  table.grid td.idx{
    border-left:0; text-align:right; padding:2px 5px;
    font-family:Arial,Helvetica,sans-serif; font-size:8pt; color:#8e99a3; width:2em;
  }

  @media print{
    .sheet.flow{break-after:page; page-break-after:always;}
    .sheet.flow.tail{break-after:auto !important; page-break-after:auto !important;}
    table.grid{break-inside:auto;}
    table.grid thead{display:table-header-group;}
  }

  /* ---------- setup screen ---------- */
  .setup{background:var(--desk); padding:30px 16px 70px; font-family:Arial,Helvetica,sans-serif;}
  .setup[hidden]{display:none;}
  .setup-inner{max-width:60rem; margin:0 auto; background:#fff; border:1px solid #cbd0d5;
    box-shadow:0 2px 14px rgba(20,24,28,.14); padding:26px 30px 30px;}
  .setup-head{display:flex; gap:20px; align-items:center; border-bottom:2.5px solid var(--brand-red);
    padding-bottom:16px; margin-bottom:22px;}
  .setup-logo{height:52px; width:auto;}
  .setup h1{margin:0 0 4px; font-size:23px; letter-spacing:-.01em; color:var(--ink);}
  .setup .lead{margin:0; font-size:14px; color:#5c646b; line-height:1.5;}
  fieldset.grp{border:0; border-top:1px solid #e0e4e7; margin:0; padding:16px 0 6px;}
  fieldset.grp legend{font-size:11px; letter-spacing:.1em; text-transform:uppercase;
    color:var(--brand-red); font-weight:700; padding:0 8px 0 0;}
  label.pick{display:flex; gap:11px; align-items:flex-start; padding:9px 10px; border:1px solid transparent;
    border-radius:3px; cursor:pointer;}
  label.pick:hover{background:#f5f6f7; border-color:#e0e4e7;}
  label.pick input{width:17px; height:17px; margin:1px 0 0; accent-color:var(--brand-red); cursor:pointer; flex:0 0 auto;}
  label.pick b{display:block; font-size:14.5px; font-weight:600; color:var(--ink);}
  label.pick i{display:block; font-style:normal; font-size:12.5px; color:#6b7379; margin-top:2px;}
  .grp-note{font-size:12.5px; color:#6b7379; margin:8px 2px 2px; display:flex; align-items:center; gap:12px; flex-wrap:wrap;}
  .grp-note .warn{color:#b8721a;}
  .fgrid{display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:13px 18px; padding:4px 2px 2px;}
  label.fl, div.fl{display:flex; flex-direction:column; gap:4px; min-width:0;}
  .fl[hidden], label.pick[hidden]{display:none !important;}
  .fl.wide2{grid-column:1 / -1;}
  label.fl > span, .fl > span{font-size:11.5px; letter-spacing:.03em; text-transform:uppercase; color:#6b7379; font-weight:600;}
  .fl input, .fl select{
    font:14px/1.3 Arial,Helvetica,sans-serif; color:var(--ink);
    border:1px solid #c2c8cd; border-radius:3px; padding:8px 9px; background:#fff; width:100%; min-width:0;
  }
  .fl input:focus, .fl select:focus{outline:none; border-color:var(--brand-red); box-shadow:0 0 0 2px rgba(211,33,49,.14);}
  .fl input::placeholder{color:#aab1b7;}
  .fl.phonepair .pp{display:flex; gap:8px;}
  .fl.phonepair .pp input{flex:1 1 auto; min-width:0;}
  .fl.phonepair .pp input.extbox{flex:0 0 5.5rem;}
  .qualblock{gap:6px;}
  .qualrow{display:flex; gap:8px; margin-bottom:7px; align-items:center;}
  .qualrow select{flex:0 0 13rem;}
  .qualrow input{flex:1 1 auto; min-width:0;}
  .qualrow select, .qualrow input{
    font:14px/1.3 Arial,Helvetica,sans-serif; color:var(--ink);
    border:1px solid #c2c8cd; border-radius:3px; padding:8px 9px; background:#fff;
  }
  .qualrow select:focus, .qualrow input:focus{outline:none; border-color:var(--brand-red); box-shadow:0 0 0 2px rgba(211,33,49,.14);}
  .qualrow .rm{
    flex:0 0 auto; border:1px solid #c9ced3; background:#f2f3f4; color:#6b7379;
    width:30px; height:32px; border-radius:3px; cursor:pointer; font-size:15px; line-height:1;
  }
  .qualrow .rm:hover{background:#e6e9eb; color:var(--brand-red);}
  .dirlist{display:flex; flex-direction:column; gap:7px; margin:6px 0 2px;}
  .direc{
    display:flex; align-items:center; gap:12px; padding:9px 11px;
    border:1px solid #dfe3e6; border-radius:3px; background:#fbfbfc;
  }
  .direc .dmeta{flex:1 1 auto; min-width:0;}
  .direc .dname{font-size:13.5px; font-weight:600; color:var(--ink); display:block;
    overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
  .direc .dsub{font-size:11.5px; color:#7a828a; display:block; margin-top:2px;}
  .direc .btn.tiny{flex:0 0 auto;}
  .dir-warn{color:#8a4b12; background:#fdf3e3; border:1px solid #f0d9b0; border-radius:3px; padding:9px 11px;}
  .dir-warn[hidden]{display:none;}
  .dir-cap-full{color:#b8721a; font-weight:600;}
  .setup-go{display:flex; align-items:center; gap:16px; margin-top:24px; padding-top:20px; border-top:1px solid #e0e4e7; flex-wrap:wrap;}
  .btn.big{padding:13px 26px; font-size:14px;}
  @media (max-width:640px){ .fgrid{grid-template-columns:minmax(0,1fr);} .setup-inner{padding:18px;} }

  /* forms hidden until chosen */
  .sheet[data-form]{display:none;}
  .sheet[data-form].on{display:flex;}
  table.grid.vf td.ckcell{text-align:center; vertical-align:middle;}
  table.grid.vf td.ckcell input{width:11px; height:11px; margin:3px auto; display:block;
    appearance:none; -webkit-appearance:none; border:1.2px solid var(--rule); background:#fff; border-radius:0; cursor:pointer;}
  table.grid.vf td.ckcell input:checked{background:var(--field); box-shadow:inset 0 0 0 1.6px #fff;}
  .deflines .row{margin-bottom:9px;}

  @media print{
    .setup{display:none !important;}
    table.grid.vf td.ckcell input:checked{background:#000;}
    table.grid.vf td.ckcell input{-webkit-print-color-adjust:exact; print-color-adjust:exact;}
  }

  @media (prefers-reduced-motion:reduce){*{transition:none !important;}}

/* =========================================================
   Touch and small screens
   Tablet is the primary device; phone must still be usable.
   ========================================================= */

/* Fingers, not mice: enlarge every hit target. */
@media (pointer: coarse) {
  .ck input[type="checkbox"]{
    width:18px; height:18px; flex:0 0 18px; top:3px;
  }
  .ck input[type="checkbox"]:checked{ box-shadow:inset 0 0 0 3px #fff; }
  .ck{ padding:4px 0; }
  table.grid.vf td.ckcell input{ width:18px; height:18px; margin:5px auto; }
  table.grid td{ height:34px; }
  .btn{ padding:12px 16px; }
  .btn.tiny{ padding:9px 13px; }
  .direc{ padding:12px; }
  .qualrow .rm{ width:40px; height:42px; font-size:18px; }
}

@media screen and (max-width: 900px) {
  .deskpad{ padding:12px 8px 48px; }
  .sheet{ box-shadow:0 1px 6px rgba(20,24,28,.16); }
  .formbox{ padding:12px 11px 10px; }
  .attrib{ width:auto; padding:0 10px; }

  /* long field labels must wrap instead of pushing the page sideways */
  .lbl{ white-space:normal; }
  .row{ margin-bottom:8px; }
  .f{ flex:1 1 100% !important; }
  .body, .body.deep{ margin-left:6px; }
  .topmeta{ gap:10px; }

  /* 16px minimum or iOS zooms the page on every field focus */
  input.fld, select.seln, input.cell, input.rowlblfld{ font-size:16px; }
  input.fld{ padding:6px 3px; }
  .fl input, .fl select, .qualrow select, .qualrow input{ font-size:16px; }

  h2.sec{ font-size:12px; }
  h3.sub, h4.subsub{ font-size:11.5px; }

  /* wide schedules pan sideways rather than squashing the page */
  .gridscroll{ overflow-x:auto; -webkit-overflow-scrolling:touch; margin:0 -4px; padding:0 4px; }
  .gridscroll table.grid{ min-width:640px; }

  /* toolbar: one scrollable strip instead of five stacked rows */
  .toolbar{ padding:8px 10px; gap:8px; flex-wrap:nowrap; overflow-x:auto; }
  .toolbar .tb-title{ display:none; }
  .toolbar .btn{ flex:0 0 auto; white-space:nowrap; }

  .setup{ padding:14px 8px 50px; }
  .setup-inner{ padding:16px 14px 20px; }
  .setup-head{ gap:12px; }
  .setup-logo{ height:38px; }
  .setup h1{ font-size:19px; }
  .qualrow{ flex-wrap:wrap; }
  .qualrow select{ flex:1 1 100%; }
  .qualrow input{ flex:1 1 auto; }
  .direc{ flex-wrap:wrap; }
  .direc .dmeta{ flex:1 1 100%; margin-bottom:6px; }
}

@media screen and (max-width: 560px) {
  .gridscroll table.grid{ min-width:560px; }
  .fl.phonepair .pp{ flex-wrap:wrap; }
  .fl.phonepair .pp input.extbox{ flex:0 0 5rem; }
}

/* ---- send menu ---- */
.sendwrap{ position:relative; flex:0 0 auto; }
.sendmenu{
  position:absolute; right:0; top:calc(100% + 8px); z-index:80;
  background:#fff; border:1px solid #c9ced3; border-radius:4px;
  box-shadow:0 8px 26px rgba(15,20,25,.3); min-width:15rem; padding:6px;
}
.sendmenu[hidden]{ display:none; }
.sendmenu button{
  display:block; width:100%; text-align:left; background:none; border:0;
  font:14px/1.3 Arial,Helvetica,sans-serif; color:var(--ink);
  padding:11px 12px; border-radius:3px; cursor:pointer;
}
.sendmenu button:hover:not(:disabled){ background:#f1f3f4; }
.sendmenu button:disabled{ color:#a8b0b6; cursor:default; }
.sendmenu button b{ display:block; font-weight:600; }
.sendmenu button i{ display:block; font-style:normal; font-size:11.5px; color:#7a828a; margin-top:2px; }
.sendmenu hr{ border:0; border-top:1px solid #e6e9eb; margin:5px 2px; }

/* The flowing schedule sheets use a wrapper table so the letterhead
   repeats on every printed page. On screen that table refuses to
   shrink below its content, so drop it to block layout — print keeps
   the table-header-group behaviour because this is screen-only. */
@media screen and (max-width: 900px) {
  table.pagewrap,
  table.pagewrap > thead,
  table.pagewrap > tbody,
  table.pagewrap > thead > tr,
  table.pagewrap > tbody > tr,
  table.pagewrap > thead > tr > td,
  table.pagewrap > tbody > tr > td{
    display:block; width:auto; max-width:100%;
  }
  .toolbar{ width:100%; max-width:100vw; }
}

/* Flex items default to min-width:auto, which refuses to shrink below
   their content — that stops overflow-x:auto from ever engaging. */
.formbox, .flowbody, .sheet{ min-width:0; }
.gridscroll{ min-width:0; max-width:100%; }

@media screen and (max-width: 900px) {
  /* long checkbox captions (ECS system features, special hazard notes)
     must wrap rather than run off the side */
  .ck{ white-space:normal; align-items:flex-start; margin-right:10px; }
  .ck.stack{ align-items:flex-start; }
  .topmeta{ flex-direction:column; align-items:stretch; }
  .topmeta .f.fixed{ flex:1 1 100%; }
  input.fld.short, input.fld.mid, select.seln{ flex:1 1 auto; width:100%; }
  .signline, .cert-stmt{ margin-left:4px; }
}

/* =========================================================
   PRINT RESET — must be last.
   The small-screen rules above are for filling the form in.
   Paper has to come out identical whether it was filled on a
   phone, a tablet or a PC, so every screen-side adjustment is
   undone here.
   ========================================================= */
@media print {
  .deskpad{ padding:0 !important; }
  .sheet{ width:auto !important; box-shadow:none !important; }
  .formbox{ padding:14px 16px 12px !important; }
  .attrib{ display:none !important; }

  .lbl{ white-space:nowrap !important; }
  .ck{ white-space:nowrap !important; align-items:baseline !important; margin-right:16px !important; padding:0 !important; }
  .ck.stack{ margin:0 0 3px !important; }
  .btn, .btn.tiny{ padding:0 !important; }
  .row{ margin-bottom:4px !important; }
  .f{ flex:1 1 0 !important; }
  .f.grow2{ flex:1.8 1 0 !important; }
  .f.grow3{ flex:3 1 0 !important; }
  .f.fixed{ flex:0 0 auto !important; }
  .body{ margin-left:14px !important; }
  .body.deep{ margin-left:26px !important; }
  .signline, .cert-stmt{ margin-left:14px !important; }

  .topmeta{ flex-direction:row !important; align-items:baseline !important; gap:26px !important; }
  .topmeta .f.fixed{ flex:0 0 auto !important; }
  input.fld.short{ flex:0 0 1.35in !important; width:auto !important; }
  input.fld.mid{ flex:0 0 2.1in !important; width:auto !important; }

  input.fld{ padding:1px 3px 1px !important; }
  input.rowlblfld{ padding:0 2px !important; }
  input.cell{ padding:1px 4px !important; }
  h2.sec{ font-size:10pt !important; }
  h3.sub{ font-size:9pt !important; }
  h4.subsub{ font-size:9.5pt !important; }

  /* schedules print full width, never as a scroll pane */
  /* the scroll wrappers are a screen affordance; take them out of the
     print box tree entirely so margins collapse as they did before */
  .gridscroll{ display:contents !important; }
  .gridscroll table.grid{ min-width:0 !important; width:100% !important; }
  table.grid td{ height:19px !important; }

  /* restore the repeating-letterhead wrapper on flowing sheets */
  table.pagewrap{ display:table !important; width:100% !important; }
  table.pagewrap > thead{ display:table-header-group !important; }
  table.pagewrap > tbody{ display:table-row-group !important; }
  table.pagewrap > thead > tr,
  table.pagewrap > tbody > tr{ display:table-row !important; }
  table.pagewrap > thead > tr > td,
  table.pagewrap > tbody > tr > td{ display:table-cell !important; }

  /* touch sizing is for fingers, not paper */
  .ck input[type="checkbox"]{ width:10px !important; height:10px !important; flex:0 0 10px !important; top:1px !important; }
  table.grid.vf td.ckcell input{ width:10px !important; height:10px !important; margin:3px auto !important; }
}

/* Toolbar labels shorten on small screens so the primary action
   (Print / PDF) stays reachable without scrolling the strip. */
.t-short{ display:none; }
@media screen and (max-width: 900px){
  .t-full{ display:none; }
  .t-short{ display:inline; }
  .toolbar{ gap:6px; padding:8px; }
  .toolbar .btn{ padding:12px 13px; }
}

/* On a phone the strip can't hold six buttons; wrap to two rows so
   Print / PDF is always reachable rather than scrolled off. */
@media screen and (max-width: 560px){
  .toolbar{ flex-wrap:wrap; overflow:visible; }
  .toolbar .btn{ flex:1 1 auto; text-align:center; }
  .sendwrap{ flex:1 1 auto; }
  .sendwrap .btn{ width:100%; }
  .sendmenu{ right:auto; left:0; min-width:min(20rem, 92vw); }
}

/* A dropdown anchored to a button in a wrapped toolbar runs off the
   side of a phone. Present it as a bottom sheet instead. */
@media screen and (max-width: 560px){
  .sendmenu{
    position:fixed; left:0; right:0; bottom:0; top:auto;
    min-width:0; width:auto; padding:8px 8px 14px;
    border:0; border-top:3px solid var(--brand-red);
    border-radius:12px 12px 0 0;
    box-shadow:0 -8px 30px rgba(15,20,25,.35);
  }
  .sendmenu button{ padding:15px 14px; font-size:15px; }
  .sendmenu button i{ font-size:12.5px; }
}

/* version badge on the entry page — screen only, never on paper */
.ver{
  display:inline-block; vertical-align:3px; margin-left:10px;
  font-size:11px; font-weight:700; letter-spacing:.08em; color:#7a828a;
  border:1px solid #d0d5d9; border-radius:11px; padding:3px 9px;
}
