*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%}
body{margin:0;font-family:"Segoe UI",system-ui,-apple-system,Roboto,Arial,sans-serif;background:#eef1f5;color:#1d2733;font-size:16px}
button,input,select,textarea{font:inherit;color:inherit}
[hidden]{display:none!important}
.boot{padding:40px;text-align:center;color:#5a6673}
/* top bar */
.top{background:#1f3a5f;color:#fff;padding:10px 20px;display:flex;align-items:center;gap:14px;flex-wrap:wrap;position:sticky;top:0;z-index:20}
.top img{height:40px;background:#fff;border-radius:6px;padding:2px 6px}
.top h1{font-size:20px;margin:0;font-weight:600}
.top .r{margin-left:auto;display:flex;gap:6px;align-items:center;flex-wrap:wrap;font-size:14px}
.top .who{opacity:.9;margin-right:6px}
.top .tb{background:transparent;border:1px solid rgba(255,255,255,.45);color:#fff;border-radius:7px;padding:7px 11px;cursor:pointer;font-size:14px}
.top .tb.on{background:#fff;color:#1f3a5f}
/* layout */
.wrap{display:grid;grid-template-columns:280px 1fr;gap:18px;padding:18px 20px;max-width:1500px;margin:0 auto}
.card{background:#fff;border-radius:10px;box-shadow:0 1px 3px rgba(0,0,0,.08);padding:16px;min-width:0}
.side h3{margin:0 0 10px;font-size:15px}
.search{width:100%;padding:10px;border:1px solid #c9d1db;border-radius:7px;margin-bottom:10px;font-size:16px}
.plist{max-height:42vh;overflow:auto;margin:0 -4px;padding:0 4px}
.pt{padding:10px;border-radius:7px;margin-bottom:4px;cursor:pointer;border:0;background:none;width:100%;text-align:left;display:block}
.pt:hover{background:#f2f6fb}.pt.sel{background:#e3edfb;font-weight:600}
.pt small{display:block;color:#6b7785;font-weight:400;font-size:13px}
.btn{white-space:nowrap;display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:10px 16px;min-height:44px;border-radius:8px;border:1px solid #1f3a5f;color:#1f3a5f;background:#fff;font-weight:600;font-size:15px;cursor:pointer;text-decoration:none}
.btn:disabled{opacity:.5;cursor:default}
.btn.p{background:#1f3a5f;color:#fff}.btn.g{background:#2e7d32;border-color:#2e7d32;color:#fff}
.btn.d{border-color:#c62828;color:#c62828}.btn.sm{min-height:34px;padding:5px 10px;font-size:13.5px}
.btn.w{width:100%}
.hist{margin-top:14px;border-top:1px solid #e3e7ec;padding-top:10px}
.hist button{display:flex;justify-content:space-between;gap:8px;width:100%;padding:9px 4px;font-size:14px;color:#3b4652;border:0;border-bottom:1px dashed #e3e7ec;background:none;text-align:left;cursor:pointer}
.hist button:hover{background:#f6f9fc}
.hist .st{font-size:11.5px;padding:1px 7px;border-radius:10px;background:#fff3cd;color:#7a5b00;white-space:nowrap}
.hist .st.signed{background:#e2f2e3;color:#1b5e20}
.vabox{margin-top:12px;border:1px solid #dbe2ea;border-radius:8px;padding:10px;background:#f8fafc;font-size:14px}
.vabox h4{margin:0 0 6px;font-size:13px;text-transform:uppercase;color:#1f3a5f;letter-spacing:.03em;display:flex;justify-content:space-between;align-items:center}
.auth{border-top:1px dashed #dbe2ea;padding-top:6px;margin-top:6px}
.auth .big{font-size:20px;font-weight:700;color:#1f3a5f}
.warn{background:#fdecea;color:#b71c1c;border-radius:6px;padding:5px 8px;font-size:13px;font-weight:600;margin-top:5px}
.muted{color:#6b7785;font-size:13px}
/* editor */
.hdr{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;margin-bottom:14px}
.hdr .svc select{font-weight:700;color:#1f3a5f;border:2px solid #1f3a5f;background:#f4f8fd}
label,.lbl{display:block;font-size:12px;font-weight:600;color:#5a6673;text-transform:uppercase;letter-spacing:.03em;margin-bottom:4px}
select,input[type=text],input[type=date],input[type=time],input[type=email],input[type=password],input[type=number],textarea{width:100%;border:1px solid #c9d1db;border-radius:7px;padding:9px 10px;background:#fff;min-height:44px;font-size:16px}
textarea{min-height:64px;resize:vertical}
.ro-field{border:1px solid #e3e7ec;border-radius:7px;padding:10px;background:#f6f8fa;min-height:44px;font-weight:600}
.grid{display:grid;grid-template-columns:1.15fr 1fr;grid-template-areas:"s d" "o d" "a d" "p d";gap:0 18px;align-items:start}
.ga-s{grid-area:s}.ga-o{grid-area:o}.ga-a{grid-area:a}.ga-p{grid-area:p}.ga-d{grid-area:d}
.sec{border-left:5px solid #1f3a5f;padding:10px 12px 12px;margin-bottom:12px;background:#f8fafc;border-radius:6px}
.sec h2{margin:0 0 8px;font-size:17px;color:#1f3a5f}
.g3{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin-top:8px}
.fld{margin-top:8px}
.chips{display:flex;flex-wrap:wrap;gap:6px}
.chip{padding:8px 13px;min-height:40px;border-radius:20px;border:1px solid #c9d1db;background:#fff;font-size:15px;cursor:pointer;user-select:none}
.chip.on{background:#1f3a5f;color:#fff;border-color:#1f3a5f}
.scale{display:flex;gap:4px;flex-wrap:wrap}
.scale button{width:40px;height:40px;border:1px solid #c9d1db;border-radius:7px;display:flex;align-items:center;justify-content:center;font-size:15px;background:#fff;cursor:pointer}
.scale button.on{background:#c62828;color:#fff;border-color:#c62828}
.oline{background:#fff;border:1px solid #dbe2ea;border-radius:8px;padding:8px 10px 10px;margin-bottom:8px}
.ohead{display:flex;justify-content:space-between;align-items:center;margin-bottom:4px}
.rg{background:#1f3a5f;color:#fff;border-radius:14px;padding:4px 14px;font-size:14px;font-weight:600}
.x{color:#7a8592;font-size:26px;line-height:1;background:none;border:0;cursor:pointer;width:44px;height:40px}
.mbtn{width:100%;text-align:left;border:1px solid #c9d1db;border-radius:7px;padding:9px 10px;background:#fff;min-height:44px;cursor:pointer;display:flex;justify-content:space-between;gap:8px}
.mbtn:after{content:"▾";color:#7a8592}.mbtn.open{border:2px solid #1f3a5f}
.dd{border:1px solid #1f3a5f;border-radius:8px;margin-top:6px;padding:8px;background:#f4f8fd}
.ddh{font-size:12.5px;font-weight:700;color:#1f3a5f;margin-bottom:6px}
.cl{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:5px}
.ck{font-size:14px;padding:9px 8px;border:1px solid #c9d1db;border-radius:7px;background:#fff;cursor:pointer;text-align:left;min-height:42px}
.ck.on{background:#e3edfb;border-color:#1f3a5f;font-weight:600}
.ck:before{content:"☐ "}.ck.on:before{content:"✔ "}
.add{display:inline-block;border:1.5px dashed #1f3a5f;color:#1f3a5f;border-radius:8px;padding:9px 16px;font-weight:700;font-size:15px;background:#fff;cursor:pointer}
.addpick{margin-top:8px;padding:8px;border:1px dashed #9fb3cc;border-radius:8px;background:#fff}
/* body diagram */
.tools{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:6px;margin:8px 0}
.tool{border:1px solid #c9d1db;border-radius:7px;padding:7px 8px;font-size:14px;background:#fff;display:flex;gap:7px;align-items:center;cursor:pointer;min-height:42px;text-align:left}
.tool svg{width:20px;height:20px;flex:none}
.tool.on{border:2px solid #c62828;background:#fff4f4}
.bodybox{position:relative;touch-action:manipulation;user-select:none;-webkit-user-select:none}
.bodybox img{width:100%;display:block;border:1px solid #e3e7ec;border-radius:6px;cursor:crosshair}
.mk{position:absolute;transform:translate(-50%,-50%);width:4.6%;min-width:16px;pointer-events:none}
.mk svg{width:100%;height:auto;display:block}
.tip{font-size:13px;color:#5a6673;margin-top:4px}
.dtools{display:flex;gap:6px;margin-top:6px}
.sigbox{margin-top:14px}
.sigbox img{max-height:60px;max-width:100%;display:block;background:#fff}
.foot{display:flex;gap:10px;justify-content:flex-end;margin-top:12px;align-items:center;flex-wrap:wrap}
.foot .note{font-size:13px;color:#6b7785;margin-right:auto}
.banner{background:#e2f2e3;border:1px solid #a5d6a7;color:#1b5e20;border-radius:8px;padding:10px 12px;margin-bottom:12px;font-weight:600}
.banner.draft{background:#fff8e1;border-color:#ffe082;color:#6d4c00}
.ro .chip,.ro .ck,.ro .scale button,.ro .tool,.ro .bodybox,.ro .x,.ro .add,.ro .mbtn{pointer-events:none}
.ro .add,.ro .x,.ro .dtools,.ro .tools{display:none}
.addenda{margin-top:12px;border-top:1px solid #e3e7ec;padding-top:10px}
.adn{background:#f8fafc;border-radius:6px;padding:8px 10px;margin-bottom:6px;font-size:14px;white-space:pre-wrap}
.empty{padding:40px 10px;text-align:center;color:#5a6673}
.empty h2{color:#1f3a5f}
/* auth pages */
.authpage{min-height:100vh;display:flex;align-items:center;justify-content:center;padding:20px}
.authcard{background:#fff;border-radius:12px;box-shadow:0 4px 20px rgba(0,0,0,.1);padding:28px;width:100%;max-width:420px}
.authcard .logo{display:block;max-width:260px;width:80%;margin:0 auto 10px}
.authcard h1{text-align:center;color:#1f3a5f;margin:6px 0 18px;font-size:24px}
.authcard .fld{margin-top:12px}
.err{background:#fdecea;color:#b71c1c;padding:9px 11px;border-radius:7px;margin-top:12px;font-size:14.5px}
.ok{background:#e2f2e3;color:#1b5e20;padding:9px 11px;border-radius:7px;margin-top:12px;font-size:14.5px}
.linkbtn{background:none;border:0;color:#1f3a5f;text-decoration:underline;cursor:pointer;padding:8px 0;font-size:15px}
#lock{position:fixed;inset:0;background:#1f3a5f;z-index:100}
/* modal */
#modal{position:fixed;inset:0;background:rgba(15,25,40,.55);z-index:60;display:flex;align-items:flex-start;justify-content:center;overflow:auto;padding:30px 12px}
.mbox{background:#fff;border-radius:12px;padding:20px;width:100%;max-width:560px}
.mbox h2{margin:0 0 10px;color:#1f3a5f}
.mbox .row{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.mbox .acts{display:flex;justify-content:flex-end;gap:8px;margin-top:16px;flex-wrap:wrap}
.sigpad{border:2px dashed #9fb3cc;border-radius:8px;width:100%;height:160px;touch-action:none;background:#fff;display:block}
.temp{font-family:ui-monospace,Menlo,Consolas,monospace;font-size:22px;background:#f4f8fd;border:2px solid #1f3a5f;border-radius:8px;padding:10px;text-align:center;margin:10px 0;user-select:all}
#toast{position:fixed;bottom:20px;left:50%;transform:translateX(-50%);background:#1d2733;color:#fff;padding:12px 18px;border-radius:8px;z-index:200;font-size:15px;max-width:90vw}
#toast.e{background:#b71c1c}
/* admin */
.tabs{display:flex;gap:6px;margin-bottom:14px;flex-wrap:wrap}
.tabs button{padding:10px 16px;border-radius:8px;border:1px solid #c9d1db;background:#fff;cursor:pointer;font-weight:600}
.tabs button.on{background:#1f3a5f;color:#fff;border-color:#1f3a5f}
.filters{display:grid;grid-template-columns:2fr 1fr 1fr 1fr auto;gap:10px;align-items:end;margin-bottom:12px}
table.t{width:100%;border-collapse:collapse;font-size:14.5px}
table.t th{text-align:left;font-size:12px;text-transform:uppercase;color:#5a6673;border-bottom:2px solid #dbe2ea;padding:8px 6px}
table.t td{border-bottom:1px solid #eef1f5;padding:8px 6px;vertical-align:middle}
table.t input[type=checkbox]{width:22px;height:22px}
.tscroll{overflow-x:auto}
.litem{display:flex;gap:6px;align-items:center;margin-bottom:6px}
.litem input[type=text]{flex:1}
.litem.off input[type=text]{color:#9aa4ae;text-decoration:line-through}
.pill{font-size:12px;border-radius:10px;padding:2px 8px;background:#eef1f5}
.pill.r{background:#fdecea;color:#b71c1c}.pill.g{background:#e2f2e3;color:#1b5e20}
/* print view (screen preview) */
#printView{position:fixed;inset:0;background:#596273;z-index:80;overflow:auto;padding:70px 10px 30px}
.pbar{position:fixed;top:0;left:0;right:0;background:#1f3a5f;color:#fff;padding:10px 16px;display:flex;gap:10px;align-items:center;z-index:81}
.pbar .sp{margin-right:auto;font-weight:600}
.page{background:#fff;width:8.5in;min-height:11in;margin:0 auto 20px;padding:.45in .5in;color:#111;font-size:11.5px;position:relative}
.ph{display:flex;align-items:center;justify-content:space-between;border-bottom:2px solid #1f3a5f;padding-bottom:8px}
.ph img{height:52px}.ph .ci{text-align:right;font-size:11px;color:#333}
.ptitle{background:#111;color:#fff;display:flex;justify-content:space-between;align-items:center;padding:7px 12px;margin:10px 0 8px;letter-spacing:.06em}
.ptitle .t1{font-size:18px}.ptitle .svc{font-size:15px;font-weight:700;background:#fff;color:#111;padding:3px 10px;border-radius:4px;letter-spacing:.04em}
.pinfo{display:grid;grid-template-columns:repeat(4,1fr);gap:4px 12px;border:1px solid #ccc;padding:7px 9px;border-radius:4px;margin-bottom:8px}
.pinfo div b{display:block;font-size:9px;text-transform:uppercase;color:#555;letter-spacing:.04em}
.pcols{display:grid;grid-template-columns:1.25fr 1fr;gap:14px}
.psec{margin-bottom:7px}
.psec h3{margin:0 0 3px;font-size:12.5px;border-bottom:1px solid #999;padding-bottom:2px;letter-spacing:.04em}
.psec p{margin:1px 0;line-height:1.35}
.psec p b{font-weight:600}
.pbody{position:relative}.pbody img{width:100%;display:block;border:1px solid #ddd}
.pbody .mk{width:4%;min-width:9px}
.legend{display:grid;grid-template-columns:1fr 1fr;gap:2px 8px;margin-top:6px;font-size:10.5px;border:1px solid #bbb;border-radius:6px;padding:6px}
.legend span{display:flex;align-items:center;gap:5px}.legend svg{width:13px;height:13px}
.psig{margin-top:12px;border-top:1px solid #999;padding-top:6px;display:flex;align-items:flex-end;gap:14px}
.psig img{max-height:50px;max-width:220px}
.pfoot{position:absolute;bottom:.3in;left:.5in;right:.5in;font-size:9px;color:#777;display:flex;justify-content:space-between;border-top:1px solid #ddd;padding-top:4px}
.wm{position:absolute;top:40%;left:0;right:0;text-align:center;font-size:46px;white-space:nowrap;color:rgba(198,40,40,.12);transform:rotate(-25deg);font-weight:800;pointer-events:none}
/* responsive */
@media (max-width:1100px){.grid{grid-template-columns:1fr;grid-template-areas:"s" "o" "d" "a" "p"}.ga-d{position:static;margin-bottom:12px}}
@media (max-width:860px){
  .wrap{grid-template-columns:1fr;padding:10px;gap:10px}
  .hdr{grid-template-columns:1fr 1fr}
  .filters{grid-template-columns:1fr 1fr}
  .plist{max-height:30vh}
  .top{padding:8px 10px;gap:8px;position:static}.top h1{font-size:17px}.top img{height:34px}
  .top .who{display:none}
}
@media (max-width:520px){
  .g3{grid-template-columns:1fr 1fr}
  .tools{grid-template-columns:1fr 1fr}
  .mbox .row{grid-template-columns:1fr}
  .card{padding:12px}
  .foot .btn{flex:1 1 45%}
}
@media print{
  @page{size:letter;margin:0}
  body{background:#fff}
  body>*:not(#printView){display:none!important}
  #printView{position:static;padding:0;background:#fff;overflow:visible}
  .pbar{display:none}
  .page{margin:0;box-shadow:none;page-break-after:always;break-after:page;width:8.5in;height:11in;overflow:hidden}
  .page:last-child{page-break-after:auto;break-after:auto}
}
