:root{
  --purple:#4f0056;
  --purple-2:#7a1680;
  --gold:#f5b300;
  --bg:#f5f1f7;
  --card:#ffffff;
  --ink:#16151a;
  --muted:#6b6570;
  --line:#eadfed;
  --ok:#14783e;
  --warn:#b45309;
  --danger:#b91c1c;
  --radius:18px;
  --shadow:0 18px 50px rgba(45,21,54,.12);
  --doc-font:'TH Sarabun New','TH SarabunPSK','Sarabun','Leelawadee UI',Tahoma,sans-serif;
}
*{box-sizing:border-box}
html,body{margin:0;min-height:100%;background:var(--bg);color:var(--ink);font-family:'Sarabun','Leelawadee UI',Tahoma,sans-serif;font-size:14px}
button,input,select,textarea{font:inherit}
button{border:0;cursor:pointer;white-space:nowrap}
.appbar{position:sticky;top:0;z-index:20;display:flex;align-items:center;justify-content:space-between;gap:16px;padding:12px 18px;background:linear-gradient(90deg,#3f0048,#6a0b73);color:#fff;box-shadow:0 8px 28px rgba(63,0,72,.25)}
.brand-group{display:flex;align-items:center;gap:12px;min-width:0}
.brand-mark{width:40px;height:40px;border-radius:14px;display:grid;place-items:center;background:#fff;color:var(--purple);font-weight:800;letter-spacing:.4px;flex:0 0 auto}
.appbar h1{margin:0;font-size:18px;line-height:1.2}
.appbar p{margin:2px 0 0;font-size:12px;opacity:.86}
.line-status{font-size:12px;background:rgba(255,255,255,.15);border:1px solid rgba(255,255,255,.22);padding:7px 10px;border-radius:999px;max-width:45%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.workspace{max-width:1500px;margin:0 auto;padding:16px;display:grid;grid-template-columns:minmax(360px,480px) 1fr;gap:16px;align-items:start}
.panel{background:var(--card);border:1px solid rgba(79,0,86,.12);border-radius:var(--radius);box-shadow:var(--shadow);overflow:hidden}
.panel-head,.preview-head{padding:15px 17px;border-bottom:1px solid var(--line);background:linear-gradient(180deg,#fff,#fcf8fd)}
.panel-head h2,.preview-head strong{margin:0;color:var(--purple);font-size:17px;display:block}
.panel-head p,.preview-head span{margin:4px 0 0;color:var(--muted);font-size:12px;display:block;line-height:1.45}
.control-panel{position:sticky;top:76px;max-height:calc(100vh - 92px);display:flex;flex-direction:column}
.section-card{margin:14px 16px;padding:14px;border:1px solid #eadfed;border-radius:16px;background:#fff}
.section-card.compact{margin-top:0}
.section-card h4{margin:0 0 10px;color:var(--purple);font-size:15px}
.dynamic-form{padding:0 16px 0;overflow:auto;display:grid;gap:12px}
.form-section-title{padding:10px 12px;border:1px solid #eadfed;border-radius:14px;background:#fbf5fc;color:var(--purple);font-weight:800;font-size:13px;margin-top:2px}
.field-group label,.section-card label{display:block;font-weight:700;color:#351a3a;margin-bottom:6px;font-size:13px}
.req-star{color:#b91c1c}
input,select,textarea{width:100%;border:1px solid #d8c7dd;border-radius:12px;background:#fff;padding:10px 11px;color:#1f1b24;outline:none;transition:.15s}
textarea{min-height:150px;resize:vertical;line-height:1.65}
input:focus,select:focus,textarea:focus{border-color:#7a1680;box-shadow:0 0 0 3px rgba(122,22,128,.12)}
.template-row,.range-row{display:flex;gap:8px;align-items:center}
.range-row input{padding:0}.range-row span{min-width:48px;text-align:right;color:var(--purple);font-weight:700}
.hint{font-size:11.5px;color:var(--muted);margin-top:6px;line-height:1.45}
.action-bar{display:flex;gap:8px;flex-wrap:wrap;padding:12px 16px 16px;border-top:1px solid var(--line);background:rgba(255,255,255,.94)}
.primary,.secondary,.ghost,.danger,.icon-btn,.upload-label{border-radius:12px;padding:10px 13px;font-weight:700;display:inline-flex;align-items:center;justify-content:center;gap:7px;transition:.16s;text-decoration:none}
.primary{background:var(--purple);color:#fff}.primary:hover{background:#390040;transform:translateY(-1px)}
.secondary{background:#f1e4f3;color:var(--purple)}.secondary:hover{background:#e7d4eb}
.ghost{background:#f4f4f5;color:#35303a}.ghost:hover{background:#e7e7ea}
.danger{background:#fee2e2;color:#991b1b}.danger:hover{background:#fecaca}
.icon-btn{width:40px;height:40px;padding:0;background:#f1e4f3;color:var(--purple);font-size:18px;line-height:1}.icon-btn:hover{background:#e6d1ea}
.upload-label{background:#f1e4f3;color:var(--purple);cursor:pointer}
.fit-status{font-size:12px;margin-top:7px;border-radius:999px;padding:6px 10px;display:inline-flex;font-weight:700}.fit-status.ok{background:#dcfce7;color:#166534}.fit-status.warn{background:#fef3c7;color:#92400e}.fit-status.danger{background:#fee2e2;color:#991b1b}
.preview-panel{min-height:calc(100vh - 34px)}
.preview-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.paper-meta{font-size:12px;color:var(--muted);font-weight:700;text-align:right}
.preview-scroll{overflow:auto;padding:20px;background:linear-gradient(135deg,#eee7f0,#faf8fb)}
.paper-shell{width:max-content;min-width:100%;display:grid;place-items:start center;padding:8px 0 32px}
.paper-stack{display:grid;gap:16px;justify-items:center}
.paper{width:210mm;height:297mm;position:relative;overflow:hidden;background:#fff;box-shadow:0 20px 70px rgba(0,0,0,.22);flex:0 0 auto;page-break-after:always;break-after:page}
.paper:last-child{page-break-after:auto;break-after:auto}
.template-bg{position:absolute;inset:0;width:100%;height:100%;object-fit:fill;z-index:0;pointer-events:none;user-select:none}
.blank-bg{position:absolute;inset:0;background:#fff;z-index:0}.blank-bg:before{content:"";position:absolute;left:14mm;right:14mm;top:14mm;height:18mm;border-bottom:1.4pt solid #4f0056}.blank-title{position:absolute;top:17mm;right:16mm;color:#4f0056;font-family:Georgia,'Times New Roman',serif;font-size:18pt;font-weight:700;z-index:1}.blank-code{position:absolute;left:14mm;bottom:8mm;color:#6b7280;font-size:8pt;z-index:1}
.render-field{position:absolute;z-index:2;color:#111;overflow:hidden;white-space:pre-wrap;word-break:break-word;font-family:var(--doc-font);line-height:1.12;padding:0 .75mm;text-rendering:geometricPrecision;-webkit-font-smoothing:antialiased}
.render-field:not(.body-field):not(.signature-field):not(.check-field){display:flex;align-items:center}
.render-field.align-center{text-align:center;justify-content:center}.render-field.align-right{text-align:right;justify-content:flex-end}.render-field.bold{font-weight:700}.render-field.small{font-size:10pt}.render-field.body-field{line-height:1.45;padding:.4mm .9mm}.render-field.signature-field{line-height:1.22;text-align:center;padding:0}
.render-field .sig-space{height:8mm}
.empty-field{color:transparent}
.check-field{display:grid;place-items:center;padding:0!important;font-family:var(--doc-font);font-weight:700;line-height:1;color:#111;overflow:visible!important}
.check-field.empty-field{color:transparent}
.sig-grid{display:grid;grid-template-columns:1fr 1fr 1fr;gap:5mm;text-align:center;font-size:inherit;line-height:1.25}
.sig-box-title{font-weight:700;margin-bottom:2mm}.sig-line{border-bottom:1px dotted #555;height:7mm;margin:0 1mm 1mm}.sig-name{font-weight:600}.sig-position{font-size:.88em;min-height:4mm}.sig-approval{display:flex;justify-content:center;gap:4mm;margin-top:1.5mm;font-size:.88em;white-space:nowrap}.sig-blank{min-height:20mm}.signature-field .sig-grid{align-items:start}
.grid-2{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.manager-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:10px}.manager-actions.right{justify-content:flex-end}
.template-list{display:grid;gap:8px}.template-item{border:1px solid #eadfed;border-radius:14px;padding:10px;display:grid;grid-template-columns:1fr auto;gap:8px;align-items:center}.template-item strong{display:block;color:#34123a}.template-item small{display:block;color:var(--muted);margin-top:2px}.template-actions{display:flex;gap:6px;align-items:center}.template-actions button{padding:8px 10px;border-radius:10px}
.dialog{border:0;border-radius:20px;box-shadow:0 28px 90px rgba(0,0,0,.35);padding:0;max-width:760px;width:calc(100vw - 24px);max-height:90vh;overflow:hidden}.large-dialog{max-width:1120px}.dialog::backdrop{background:rgba(20,10,25,.58)}.dialog-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;padding:16px 18px;border-bottom:1px solid var(--line);background:linear-gradient(180deg,#fff,#fbf7fc)}.dialog-head h3{margin:0;color:var(--purple);font-size:18px}.dialog-head p{margin:3px 0 0;color:var(--muted);font-size:12px;line-height:1.45}.dialog-body{padding:16px;overflow:auto;max-height:calc(90vh - 78px)}
.field-table-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-top:14px}.field-table-head h4{margin:0}.table-scroll{overflow:auto;border:1px solid #eadfed;border-radius:14px}.field-table{border-collapse:collapse;min-width:980px;width:100%;font-size:12px}.field-table th{background:#f8f0fa;color:var(--purple);text-align:left;padding:9px;border-bottom:1px solid #eadfed}.field-table td{padding:6px;border-bottom:1px solid #f0e7f2;vertical-align:top}.field-table input,.field-table select{border-radius:9px;padding:7px 8px;font-size:12px}.field-table .num{max-width:70px}.field-table .type{max-width:98px}.field-table .options{min-width:170px}.json-output{min-height:330px;font-family:Consolas,monospace;font-size:12px;line-height:1.45}
@media (max-width:1200px){.workspace{grid-template-columns:1fr}.control-panel{position:relative;top:auto;max-height:none}.preview-panel{min-height:auto}.paper-stack{gap:8mm}.paper{transform:scale(.78);transform-origin:top center;margin-bottom:-65mm}.paper-shell{height:auto;overflow:hidden}}
@media (max-width:760px){.appbar{align-items:flex-start;flex-direction:column;padding:11px}.line-status{max-width:100%;width:100%}.workspace{padding:10px;gap:10px}.panel{border-radius:14px}.section-card{margin:10px;padding:12px}.dynamic-form{padding:0 10px}.grid-2{grid-template-columns:1fr}.action-bar{position:sticky;bottom:0;z-index:5}.primary,.secondary,.ghost,.danger,.upload-label{flex:1 1 46%;padding:10px 9px}.preview-head{display:none}.preview-scroll{padding:8px}.paper-stack{gap:5mm}.paper{transform:scale(.49);margin-bottom:-150mm}.paper-shell{height:auto;padding-top:0}.dialog{width:calc(100vw - 12px)}}
@media print{
  @page{size:A4;margin:0}
  html,body{width:210mm;background:#fff!important;overflow:visible!important}
  .appbar,.control-panel,.preview-head{display:none!important}
  .workspace,.preview-panel,.preview-scroll,.paper-shell,.paper-stack{display:block!important;margin:0!important;padding:0!important;border:0!important;box-shadow:none!important;background:#fff!important;width:210mm!important;max-width:none!important;overflow:visible!important}
  .paper{box-shadow:none!important;transform:none!important;margin:0!important;width:210mm!important;height:297mm!important;page-break-after:always!important;break-after:page!important}
  .paper:last-child{page-break-after:auto!important;break-after:auto!important}
}

/* V13.2 user font controls */
.font-control-card{display:grid;gap:10px}
.font-style-tools{display:grid;gap:8px;margin-top:6px;padding-top:10px;border-top:1px dashed #eadfed}
.style-toggle-row{display:flex;gap:8px;flex-wrap:wrap}
.style-toggle{display:inline-flex!important;align-items:center;gap:7px;width:auto!important;margin:0!important;padding:8px 10px;border:1px solid #d8c7dd;border-radius:999px;background:#fbf7fc;color:#4f0056;font-weight:800;cursor:pointer}
.style-toggle input{width:auto;min-height:0;margin:0;accent-color:#4f0056}
.render-field.doc-bold,.render-field.doc-bold *{font-weight:700!important}
.render-field.doc-italic,.render-field.doc-italic *{font-style:italic!important}

/* V7 mobile and visual calibration upgrades */
.mobile-tabs{display:none;position:sticky;top:0;z-index:19;background:#fff;border-bottom:1px solid #eadfed;padding:8px;gap:8px;box-shadow:0 6px 18px rgba(63,0,72,.08)}
.mobile-tab{flex:1;border-radius:999px;padding:10px 8px;font-weight:800;background:#f3e8f5;color:#4f0056;border:1px solid #eadfed}
.mobile-tab.active{background:#4f0056;color:#fff;border-color:#4f0056}
.calibrator-dialog{max-width:min(1380px,calc(100vw - 18px));width:calc(100vw - 18px);height:calc(100vh - 18px);max-height:calc(100vh - 18px)}
.calibrator-dialog .dialog-body{max-height:calc(100vh - 94px)}
.calibrator-body{padding:12px;background:#f8f5fa}
.calibrator-toolbar{display:grid;grid-template-columns:120px minmax(260px,1fr) 120px auto;gap:10px;align-items:end;margin-bottom:12px}
.calibrator-toolbar label{display:block;font-size:12px;font-weight:800;color:#4f0056;margin-bottom:5px}
.cal-actions{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
.calibrator-main{display:grid;grid-template-columns:minmax(320px,1fr) 270px;gap:12px;align-items:start}
.calibrator-stage-wrap{overflow:auto;background:#e9e0ec;border:1px solid #d9c2df;border-radius:18px;padding:14px;max-height:calc(100vh - 210px);text-align:center}
.cal-stage{position:relative;width:210mm;height:297mm;background:#fff;box-shadow:0 18px 60px rgba(0,0,0,.22);display:inline-block;vertical-align:top;touch-action:none;user-select:none}
.cal-bg{position:absolute;inset:0;width:100%;height:100%;object-fit:fill;pointer-events:none;user-select:none;z-index:0}
.cal-box{position:absolute;z-index:2;border:1.5px solid rgba(79,0,86,.95);background:rgba(249,212,49,.20);box-shadow:0 0 0 2px rgba(255,255,255,.75);border-radius:2mm;cursor:move;touch-action:none;overflow:hidden;color:#4f0056;font-size:8pt;font-weight:800;text-align:left;padding:1mm;line-height:1.1}
.cal-box.active{background:rgba(79,0,86,.18);border-color:#f9d431;box-shadow:0 0 0 3px rgba(79,0,86,.45),0 0 0 6px rgba(249,212,49,.65)}
.cal-box span{pointer-events:none;display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;background:rgba(255,255,255,.72);border-radius:999px;padding:.5mm 1mm;max-width:100%}
.resize-handle{position:absolute;right:0;bottom:0;width:5mm;height:5mm;background:#4f0056;border-radius:3mm 0 0 0;cursor:nwse-resize}.resize-handle:after{content:"";position:absolute;right:1mm;bottom:1mm;width:2mm;height:2mm;border-right:1px solid #fff;border-bottom:1px solid #fff}
.calibrator-side{background:#fff;border:1px solid #eadfed;border-radius:18px;padding:14px;box-shadow:0 10px 28px rgba(79,0,86,.08)}
.calibrator-side h4{margin:0 0 10px;color:#4f0056}.cal-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px}.cal-grid label{font-size:12px;font-weight:800;color:#4f0056}.cal-grid input{margin-top:4px;padding:9px;border-radius:10px;font-size:14px}
.nudge-pad{display:grid;grid-template-columns:1fr 1fr 1fr;gap:7px;margin:14px auto 10px;max-width:170px}.nudge-pad button{border-radius:14px;background:#f1e4f3;color:#4f0056;font-weight:900;font-size:20px;padding:12px 0}.nudge-pad button[data-nudge="up"]{grid-column:2}.nudge-pad button[data-nudge="left"]{grid-column:1}.nudge-pad button[data-nudge="right"]{grid-column:3}.nudge-pad button[data-nudge="down"]{grid-column:2}
@media (max-width:900px){
  .appbar{position:sticky;top:0;z-index:21}.mobile-tabs{display:flex}.workspace{grid-template-columns:1fr;padding:8px}.workspace.mobile-show-form .preview-panel{display:none}.workspace.mobile-show-preview .control-panel{display:none}.workspace.mobile-show-preview .preview-panel{display:block}.control-panel{max-height:none}.panel-head{display:none}.section-card{margin:8px;padding:11px}.dynamic-form{padding:0 8px;gap:9px}.field-group{background:#fff;border:1px solid #eadfed;border-radius:14px;padding:10px}.form-section-title{position:sticky;top:95px;z-index:4}.field-group label,.section-card label{font-size:14px}input,select,textarea{font-size:16px;min-height:46px;border-radius:14px;padding:12px}textarea{min-height:120px}.action-bar{position:sticky;bottom:0;z-index:10;background:rgba(255,255,255,.97);backdrop-filter:blur(8px);border-radius:18px 18px 0 0;box-shadow:0 -12px 30px rgba(0,0,0,.12)}.action-bar button{min-height:44px}.primary,.secondary,.ghost,.danger,.upload-label{flex:1 1 100%;font-size:14px}.preview-scroll{height:calc(100vh - 132px);overflow:auto;padding:10px}.paper-shell{min-width:max-content;display:block;padding:0 8px 18px}.paper-stack{display:block}.paper{transform:none!important;width:210mm!important;height:297mm!important;margin:0 0 12px!important}.calibrator-dialog{width:100vw;height:100vh;max-width:100vw;max-height:100vh;border-radius:0}.calibrator-dialog .dialog-head{position:sticky;top:0;z-index:4}.calibrator-dialog .dialog-body{max-height:calc(100vh - 70px);padding:8px}.calibrator-toolbar{grid-template-columns:1fr;gap:8px}.cal-actions button{flex:1 1 45%;min-height:42px}.calibrator-main{grid-template-columns:1fr}.calibrator-stage-wrap{max-height:58vh;padding:10px;border-radius:14px}.cal-stage{width:210mm;height:297mm}.calibrator-side{border-radius:14px}.cal-grid input{font-size:16px;min-height:42px}.cal-box{font-size:7pt;border-width:2px}.resize-handle{width:8mm;height:8mm}.nudge-pad{max-width:220px}.nudge-pad button{font-size:24px;padding:14px 0}
}

/* V8 Admin / LIFF routing */
[hidden] { display: none !important; }
.single-form-hidden { display: none !important; }
.access-denied { padding: 18px; border: 1px solid rgba(192,17,124,.25); border-radius: 14px; background: #fff4fb; color: #5b1749; line-height: 1.65; }
.admin-dialog { width: min(1180px, 96vw); }
.admin-manager { display: grid; gap: 16px; max-height: 78vh; overflow: auto; }
.admin-status-grid { display: grid; grid-template-columns: minmax(240px, .7fr) 1.3fr; gap: 16px; align-items: start; }
.admin-status-grid span { display: block; margin-top: 6px; padding: 10px 12px; border-radius: 12px; background: rgba(97,49,119,.08); word-break: break-all; }
.admin-textarea { min-height: 120px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }
.admin-table input, .admin-table select { min-width: 130px; }
.admin-table small { display:block; color: var(--muted); margin-top: 3px; }
.admin-form-table th:first-child, .admin-form-table td:first-child { min-width: 230px; }
.admin-form-table th:nth-child(5), .admin-form-table td:nth-child(5) { min-width: 360px; }
.liff-link-row { display:flex; gap:8px; min-width: 330px; }
.liff-link-row input { flex:1; font-size: 12px; }
.admin-actions { position: sticky; bottom: 0; background: rgba(255,255,255,.92); backdrop-filter: blur(10px); padding: 12px; border-radius: 16px; border: 1px solid rgba(97,49,119,.12); }
.wide-scroll { overflow-x: auto; }
@media (max-width: 720px){
  .admin-status-grid { grid-template-columns: 1fr; }
  .admin-dialog { width: 100vw; max-width: 100vw; height: 96vh; max-height: 96vh; margin: 0; }
  .admin-manager { max-height: calc(96vh - 90px); }
  .admin-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .admin-actions .primary { grid-column: 1 / -1; }
}

/* V8.1 mobile refinements */
@media (max-width:900px){
  html,body{overflow-x:hidden;}
  .appbar{position:relative;top:auto;z-index:1;padding:10px 12px;}
  .brand-mark{width:34px;height:34px;border-radius:12px;font-size:13px;}
  .appbar h1{font-size:16px;}
  .appbar p{font-size:11px;line-height:1.35;}
  .line-status{font-size:11px;padding:6px 9px;}
  .mobile-tabs{position:sticky;top:0;z-index:30;padding:7px 8px;overflow-x:auto;scrollbar-width:none;}
  .mobile-tabs::-webkit-scrollbar{display:none;}
  .mobile-tab{min-width:92px;flex:0 0 auto;padding:9px 10px;font-size:13px;}
  .workspace{padding:8px 8px calc(12px + env(safe-area-inset-bottom));}
  .template-row{align-items:stretch;}
  .template-row .icon-btn{height:auto;min-height:46px;}
  .dynamic-form{padding-bottom:4px;}
  .field-group{box-shadow:0 6px 18px rgba(79,0,86,.04);}
  .field-group label,.section-card label{line-height:1.35;}
  select{background-color:#fff;}
  textarea{line-height:1.55;}
  .action-bar{display:grid;grid-template-columns:1fr 1fr;gap:8px;padding:10px 10px calc(10px + env(safe-area-inset-bottom));}
  .action-bar button,.action-bar .upload-label{width:100%;min-width:0;white-space:normal;line-height:1.25;}
  .action-bar .primary{grid-column:1 / -1;}
  .action-bar .danger{grid-column:1 / -1;}
  .preview-scroll{height:calc(100svh - 74px);-webkit-overflow-scrolling:touch;overscroll-behavior:contain;}
  .paper-shell{min-width:max-content;}
  .paper{box-shadow:0 10px 36px rgba(0,0,0,.20);}
  .calibrator-dialog{height:100svh;max-height:100svh;}
  .calibrator-dialog .dialog-head h3{font-size:16px;}
  .calibrator-dialog .dialog-head p{font-size:11.5px;}
  .calibrator-dialog .dialog-body{max-height:calc(100svh - 70px);}
  .calibrator-stage-wrap{-webkit-overflow-scrolling:touch;overscroll-behavior:contain;}
  .calibrator-side{margin-bottom:calc(12px + env(safe-area-inset-bottom));}
  .dialog-head{padding:12px 14px;}
  .dialog-body{padding:10px;}
  .table-scroll,.wide-scroll{-webkit-overflow-scrolling:touch;}
  .admin-dialog{height:100svh;max-height:100svh;border-radius:0;}
  .admin-manager{max-height:calc(100svh - 78px);padding-bottom:calc(74px + env(safe-area-inset-bottom));}
  .admin-actions{position:sticky;bottom:0;z-index:6;margin:0 -2px;grid-template-columns:1fr 1fr;gap:8px;padding-bottom:calc(12px + env(safe-area-inset-bottom));}
  .admin-actions button,.admin-actions .upload-label{width:100%;min-width:0;white-space:normal;}
}

@media (max-width:390px){
  .mobile-tab{min-width:84px;font-size:12px;padding:8px 8px;}
  .action-bar{grid-template-columns:1fr;}
  .action-bar .primary,.action-bar .danger{grid-column:auto;}
}

/* V12 mobile preview / workflow upgrades */
.preview-tools{display:flex;align-items:center;gap:8px;flex-wrap:wrap;justify-content:flex-end}
.preview-tools label{font-size:11px;color:var(--muted);font-weight:800}
.preview-tools select{width:auto;min-width:120px;padding:7px 10px;border-radius:10px;font-size:12px}
.preview-tools .secondary{padding:8px 10px;font-size:12px}
.paper-shell.fit-width{min-width:0;width:100%;display:flex;justify-content:center;align-items:flex-start;overflow:visible}
.paper-stack.preview-scaled{display:block;justify-items:center;transform-origin:top center}
.paper.preview-zoomed{transform:scale(var(--preview-scale,1)) !important;transform-origin:top center !important;margin-bottom:var(--preview-margin,12px) !important}
.workflow-card{background:linear-gradient(135deg,#fff,#fbf5fc)}
.workflow-head{display:flex;align-items:center;justify-content:space-between;gap:10px}
.status-pill{display:inline-flex;align-items:center;justify-content:center;margin-top:6px;border-radius:999px;padding:7px 12px;font-weight:900;font-size:12px;letter-spacing:.2px;text-transform:uppercase}
.status-pill.draft{background:#f3f4f6;color:#374151}.status-pill.submitted{background:#dbeafe;color:#1d4ed8}.status-pill.approved{background:#dcfce7;color:#166534}.status-pill.rejected{background:#fee2e2;color:#991b1b}.status-pill.printed{background:#fef3c7;color:#92400e}
.mini-btn{padding:8px 10px;font-size:12px;min-height:auto}.primary.submit{background:#7a1680}.primary.submit:hover{background:#5f1065}
.history-manager{display:grid;gap:12px}.history-list{display:grid;gap:10px;max-height:340px;overflow:auto}.history-item{border:1px solid #eadfed;border-radius:14px;padding:11px;background:#fff;display:grid;grid-template-columns:1fr auto;gap:10px;align-items:start}.history-item strong{display:block;color:#351a3a}.history-item small{display:block;color:var(--muted);line-height:1.5;margin-top:3px}.history-actions{display:flex;gap:6px;flex-wrap:wrap;justify-content:flex-end}.history-actions button{padding:8px 9px;border-radius:10px;font-size:12px}
.test-highlight{outline:1.4pt dashed #c0117c;outline-offset:-1mm;background:rgba(245,179,0,.08)}
.test-overflow{outline:2pt solid #dc2626!important;background:rgba(254,226,226,.42)!important}
@media (max-width:900px){
  .preview-head{display:flex;position:sticky;top:43px;z-index:2;padding:8px 10px;align-items:flex-start;background:rgba(255,255,255,.96);backdrop-filter:blur(8px)}
  .preview-head strong,.preview-head span{font-size:12px}.preview-tools{width:100%;justify-content:flex-start}.preview-tools select{flex:1;min-width:110px;min-height:38px}.preview-tools .secondary{min-height:38px;flex:0 0 auto}
  .preview-scroll{height:calc(100svh - 115px)!important;padding:8px 4px!important;background:#eee7f0}.paper-shell.fit-width{padding:4px 0 22px!important}.paper-stack.preview-scaled{width:auto}.paper.preview-zoomed{box-shadow:0 12px 38px rgba(0,0,0,.22)}
  .workflow-head{align-items:flex-start}.status-pill{font-size:11px;padding:6px 10px}.history-dialog{width:100vw;max-width:100vw;height:100svh;max-height:100svh;border-radius:0}.history-manager{max-height:calc(100svh - 78px);padding-bottom:calc(16px + env(safe-area-inset-bottom))}.history-item{grid-template-columns:1fr}.history-actions{justify-content:stretch}.history-actions button{flex:1 1 45%}
}
@media print{.paper.preview-zoomed{transform:none!important;margin:0!important}.test-highlight,.test-overflow{outline:none!important;background:transparent!important}}

/* V12 form-specific refinements */
.render-field.whiteout-field{z-index:1;background:#fff!important;color:transparent!important;border:0!important;padding:0!important;overflow:hidden!important}
.render-field.image-field{padding:0!important;background:#fff;display:flex;align-items:center;justify-content:center;border:0;overflow:hidden}
.render-field.image-field img{width:100%;height:100%;object-fit:contain;display:block}
.file-image-control{display:grid;gap:8px}
.file-image-actions{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:12px;color:var(--muted)}
.small-button{padding:7px 10px;border-radius:10px;font-size:12px}
.ioc-signature-grid{grid-template-columns:1.15fr .9fr 1.15fr;gap:4.5mm;align-items:start;height:100%}
.sig-col{min-height:58mm;display:flex;flex-direction:column;justify-content:flex-start;text-align:center}
.ioc-approval-panel{display:flex;justify-content:center;gap:5mm;align-items:center;border:1px solid #333;border-radius:2mm;padding:1.3mm 1mm;margin:0 1mm 1.2mm;font-weight:800;font-size:1.08em;line-height:1.15;background:rgba(255,255,255,.72)}
.approval-choice{white-space:nowrap}
.sig-note{font-size:.82em;line-height:1.25;text-align:left;border:1px solid #aaa;border-radius:1.5mm;min-height:10.5mm;padding:1mm 1.2mm;margin:0 .8mm 1.3mm;background:rgba(255,255,255,.72);overflow:hidden}
.requester-note{min-height:16mm;margin-bottom:2mm}.approval-note{min-height:14mm}
.sig-note-empty{border-color:transparent;background:transparent;color:transparent}
.sig-line-block{margin-top:auto}
.sig-line{height:7mm}.sig-empty-col .sig-line,.sig-empty-col .sig-name,.sig-empty-col .sig-position{display:none}
@media(max-width:900px){.file-image-actions{font-size:13px}.small-button{min-height:38px}}
/* V12 IOC approval sizing */
.ioc-approval-panel.approval-panel-large{min-height:12mm;font-size:1.22em;gap:6mm;margin-bottom:3mm;border-width:1.2px}
.ioc-signature-grid .sig-line-block{padding-top:1mm}


/* V12.1 Admin access fix */
.admin-entry{border-color:#613177!important;color:#613177!important;font-weight:800!important;background:#fff!important;}
.mobile-tab[data-target="admin"]{font-weight:800;}
@media (max-width: 760px){
  .toolbar{grid-template-columns:1fr 1fr;}
  #openAdminBtn{display:inline-flex!important;justify-content:center;}
}


/* V12.2 admin/workflow/mobile safety additions */
.preview-tools{display:flex;gap:8px;align-items:center;justify-content:flex-end;flex-wrap:wrap;margin:8px 0 10px;}
.preview-tools label{font-size:12px;color:#555;}
.preview-tools select{min-height:34px;border:1px solid #ddd;border-radius:10px;padding:4px 8px;background:#fff;}
button.small{padding:6px 10px;font-size:12px;}
.workflow-card{margin-top:12px;}
.workflow-status{font-weight:700;color:#613177;margin-bottom:4px;}
.history-list{display:grid;gap:10px;margin:10px 0 14px;max-height:280px;overflow:auto;}
.history-item{border:1px solid #e5e0ea;border-radius:14px;padding:12px;background:#fff;}
.history-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:8px;}
@media(max-width:860px){.preview-tools{justify-content:flex-start}.action-bar{grid-template-columns:1fr 1fr}.action-bar button,.action-bar label{min-height:44px}.workflow-card{margin-bottom:70px}}

/* V12.3 UX simplification + separated Admin page */
.appbar-actions{display:flex;align-items:center;gap:10px;min-width:0;justify-content:flex-end;max-width:55%;}
.appbar-actions .line-status{max-width:100%;}
.admin-link{display:inline-flex;align-items:center;justify-content:center;padding:8px 12px;border-radius:999px;background:rgba(255,255,255,.16);border:1px solid rgba(255,255,255,.28);color:#fff;text-decoration:none;font-weight:800;font-size:12px;white-space:nowrap;}
.admin-link:hover{background:rgba(255,255,255,.25)}
.quick-form-card h4{display:flex;align-items:center;gap:8px;}
.quick-form-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px;}
.quick-form-btn{width:100%;min-height:72px;text-align:left;border:1px solid #eadfed;background:#fff;border-radius:16px;padding:11px 12px;color:#2d1731;box-shadow:0 6px 18px rgba(79,0,86,.05);white-space:normal;}
.quick-form-btn strong{display:block;color:#4f0056;font-size:13px;line-height:1.25;}
.quick-form-btn span{display:block;margin-top:5px;color:#6b6570;font-size:11px;line-height:1.25;}
.quick-form-btn.active{border-color:#4f0056;background:linear-gradient(180deg,#fff,#fbf2fd);box-shadow:0 0 0 3px rgba(79,0,86,.08);}
.admin-protected[hidden],.admin-locked-message[hidden]{display:none!important;}
body:not(.is-admin) .admin-protected{display:none!important;}
body.is-admin .admin-locked-message{display:none!important;}
body:not(.is-admin) .admin-locked-message{display:block;}

.admin-page{background:linear-gradient(135deg,#f8f2fb,#fff8e4);min-height:100vh;}
.admin-page-shell{max-width:1240px;margin:0 auto;padding:18px;}
.admin-login-card{max-width:560px;margin:56px auto;background:#fff;border:1px solid rgba(79,0,86,.12);border-radius:24px;box-shadow:0 26px 80px rgba(45,21,54,.16);padding:28px;}
.admin-login-card h2{margin:8px 0 8px;color:#4f0056;font-size:26px;}
.admin-login-card p{margin:0 0 18px;color:#534756;line-height:1.65;}
.login-badge{display:inline-flex;align-items:center;border-radius:999px;padding:7px 11px;background:#fff2c9;color:#7c4a00;font-weight:900;font-size:12px;}
.admin-login-row input{min-height:48px;}
.admin-workspace{display:grid;gap:16px;}
.admin-overview-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:14px;}
.admin-summary-card{background:#fff;border:1px solid rgba(79,0,86,.12);border-radius:20px;padding:16px 18px;box-shadow:0 12px 32px rgba(45,21,54,.08);}
.admin-summary-card span{display:block;color:#6b6570;font-size:12px;font-weight:800;}
.admin-summary-card strong{display:block;color:#4f0056;font-size:26px;line-height:1.2;margin-top:5px;}
.admin-summary-card small{display:block;color:#6b6570;margin-top:5px;line-height:1.45;}
.admin-quick-actions{display:grid;grid-template-columns:repeat(4,1fr);gap:10px;}
.admin-quick-actions a,.admin-quick-actions button{text-align:center;min-height:44px;white-space:normal;}
.admin-tool-card{margin-top:0;}
.admin-page-actions{margin:0 16px 20px;}
body.locked .admin-workspace{display:none!important;}
body.locked .admin-login-card{display:block;}

@media (max-width:900px){
  .appbar-actions{max-width:100%;width:100%;justify-content:space-between;}
  .admin-link{padding:8px 10px;}
  .quick-form-grid{grid-template-columns:1fr;}
  .quick-form-btn{min-height:auto;}
  .admin-page-shell{padding:10px;}
  .admin-login-card{margin:18px auto;padding:18px;border-radius:20px;}
  .admin-overview-grid{grid-template-columns:1fr;gap:10px;}
  .admin-quick-actions{grid-template-columns:1fr 1fr;}
  .admin-page-actions{display:grid;grid-template-columns:1fr 1fr;margin:0 8px 14px;gap:8px;}
  .admin-page-actions .primary{grid-column:1 / -1;}
}


/* V12.5 employee import + print A4 hard lock */
.admin-import-card .admin-quick-actions{align-items:center;}
.admin-table th:nth-child(1){min-width:250px}
.admin-table th:nth-child(2){min-width:110px}
.admin-table th:nth-child(3){min-width:170px}
.admin-table th:nth-child(4){min-width:160px}
.admin-table th:nth-child(5){min-width:190px}
.admin-table th:nth-child(6){min-width:190px}

@media print{
  @page{size:210mm 297mm;margin:0!important;}
  *{-webkit-print-color-adjust:exact!important;print-color-adjust:exact!important;}
  html,body{margin:0!important;padding:0!important;width:210mm!important;min-width:210mm!important;height:auto!important;background:#fff!important;overflow:visible!important;}
  body.is-printing .appbar,
  body.is-printing .mobile-tabs,
  body.is-printing .control-panel,
  body.is-printing .preview-head,
  body.is-printing .preview-tools,
  body.is-printing .workflow-card,
  body.is-printing dialog{display:none!important;}
  body.is-printing .workspace,
  body.is-printing .preview-panel,
  body.is-printing .preview-scroll,
  body.is-printing .paper-shell,
  body.is-printing .paper-stack{display:block!important;position:static!important;margin:0!important;padding:0!important;border:0!important;box-shadow:none!important;background:#fff!important;width:210mm!important;min-width:210mm!important;max-width:210mm!important;height:auto!important;overflow:visible!important;}
  body.is-printing .paper{display:block!important;position:relative!important;margin:0!important;padding:0!important;width:210mm!important;min-width:210mm!important;max-width:210mm!important;height:297mm!important;min-height:297mm!important;max-height:297mm!important;overflow:hidden!important;box-shadow:none!important;transform:none!important;page-break-after:always!important;break-after:page!important;}
  body.is-printing .paper:last-child{page-break-after:auto!important;break-after:auto!important;}
  body.is-printing .template-bg{width:210mm!important;height:297mm!important;object-fit:fill!important;}
  body.is-printing .render-field{transform:none!important;}
}

/* V12.6 IOC multi-page continuation */
.ioc-continuation-bg{position:absolute;inset:0;background:#fff;z-index:0}
.ioc-page-number{font-family:var(--doc-font);font-weight:700;text-align:center;color:#111}
.ioc-continuation-marker{font-style:normal;text-align:right;color:#111;line-height:1.1;overflow:visible!important;white-space:nowrap!important}
.ioc-body-chunk{line-height:1.45!important;overflow:hidden!important}
.ioc-dynamic-signature{overflow:hidden!important}
.sig-lead{font-weight:600;margin-bottom:2mm;min-height:5mm;line-height:1.25;text-align:center}
.ioc-signature-grid .sig-col{min-height:0;height:100%}
.ioc-signature-grid .sig-line-block{width:100%;margin-top:auto}
body.is-printing .ioc-continuation-bg{background:#fff!important}

/* V12.7 org approval admin */
.admin-table{min-width:1650px}
.admin-table input,.admin-table select{min-width:120px}
.admin-table .admin-user-id{min-width:230px}
.admin-table .admin-user-reports,.admin-table .admin-user-approver,.admin-table .admin-user-approver2{min-width:230px}
.admin-table .admin-user-org-role{min-width:150px}


/* V12.8 document font: rendered document data uses TH Sarabun family */
.paper,
.paper .render-field,
.paper .render-field *,
.paper .sig-grid,
.paper .sig-grid *,
.paper .sig-lead,
.paper .ioc-page-number,
.paper .ioc-continuation-marker,
.paper .blank-code {
  font-family: var(--doc-font) !important;
}
body.is-printing .paper,
body.is-printing .paper .render-field,
body.is-printing .paper .render-field *,
body.is-printing .paper .sig-grid,
body.is-printing .paper .sig-grid *,
body.is-printing .paper .sig-lead,
body.is-printing .paper .ioc-page-number,
body.is-printing .paper .ioc-continuation-marker,
body.is-printing .paper .blank-code {
  font-family: var(--doc-font) !important;
}


/* V12.9 IOC signature alignment and controllable size */
.ioc-dynamic-signature{overflow:visible!important;}
.ioc-signature-grid{align-items:stretch!important;}
.ioc-signature-grid .sig-col{height:100%;min-height:0;display:flex!important;flex-direction:column!important;}
.ioc-signature-grid .sig-line-block{margin-top:auto!important;width:100%;padding-top:0!important;}
.ioc-signature-grid .sig-lead{height:6mm;min-height:6mm;margin-bottom:1.5mm;line-height:1.15;display:flex;align-items:flex-end;justify-content:center;font-weight:600;}
.ioc-signature-grid .sig-lead-empty{visibility:hidden;}
.ioc-signature-grid .sig-line{height:5mm;margin:0 1mm 1mm;border-bottom:1px dotted #555;}
.ioc-signature-grid .sig-name{font-weight:600;line-height:1.15;min-height:4.5mm;}
.ioc-signature-grid .sig-position{font-size:.92em;line-height:1.15;min-height:4.5mm;}


/* V13.0 IOC signature fixed baseline + larger controllable text */
.ioc-dynamic-signature{overflow:visible!important;}
.ioc-signature-grid{
  display:grid!important;
  grid-template-columns:1.15fr .9fr 1.15fr!important;
  gap:6mm!important;
  height:100%!important;
  align-items:stretch!important;
  text-align:center!important;
}
.ioc-signature-grid .sig-col{
  position:relative!important;
  height:100%!important;
  min-height:0!important;
  display:block!important;
  text-align:center!important;
}
.ioc-signature-grid .ioc-approval-panel{
  position:absolute!important;
  top:0!important;
  left:0!important;
  right:0!important;
  margin:0!important;
  min-height:12mm!important;
  font-size:1.10em!important;
  line-height:1.15!important;
  display:flex!important;
  align-items:center!important;
  justify-content:center!important;
  gap:4mm!important;
}
.ioc-signature-grid .sig-note{
  position:absolute!important;
  top:14.5mm!important;
  left:0!important;
  right:0!important;
  min-height:12mm!important;
  margin:0!important;
  font-size:.95em!important;
  line-height:1.25!important;
  padding:1mm 1.2mm!important;
}
.ioc-signature-grid .sig-note-empty{
  border-color:transparent!important;
  background:transparent!important;
  color:transparent!important;
}
.ioc-signature-grid .sig-line-block{
  position:absolute!important;
  top:34mm!important;
  left:0!important;
  right:0!important;
  width:100%!important;
  margin:0!important;
  padding:0!important;
}
.ioc-signature-grid .sig-lead{
  height:7mm!important;
  min-height:7mm!important;
  margin:0 0 1.5mm 0!important;
  line-height:1.15!important;
  display:flex!important;
  align-items:flex-end!important;
  justify-content:center!important;
  font-weight:700!important;
}
.ioc-signature-grid .sig-lead-empty{visibility:hidden!important;}
.ioc-signature-grid .sig-line{
  height:4mm!important;
  margin:0 0 1.2mm 0!important;
  border-bottom:1px dotted #555!important;
}
.ioc-signature-grid .sig-name{
  font-weight:700!important;
  line-height:1.15!important;
  min-height:5mm!important;
}
.ioc-signature-grid .sig-position{
  font-size:.96em!important;
  line-height:1.15!important;
  min-height:5mm!important;
}
.ioc-signature-grid .approval-choice{white-space:nowrap!important;}


/* V13.1 IOC signature compact spacing */
.ioc-signature-grid{
  gap:4mm!important;
}
.ioc-signature-grid .ioc-approval-panel{
  min-height:11mm!important;
  font-size:1.05em!important;
  gap:3.2mm!important;
}
.ioc-signature-grid .sig-note{
  top:12.5mm!important;
  min-height:10.5mm!important;
  font-size:.90em!important;
  line-height:1.18!important;
  padding:.8mm 1mm!important;
}
.ioc-signature-grid .sig-line-block{
  top:26mm!important;
}
.ioc-signature-grid .sig-lead{
  height:5mm!important;
  min-height:5mm!important;
  margin:0 0 .8mm 0!important;
  line-height:1.05!important;
}
.ioc-signature-grid .sig-line{
  height:2.6mm!important;
  margin:0 0 .8mm 0!important;
}
.ioc-signature-grid .sig-name{
  line-height:1.05!important;
  min-height:3.8mm!important;
}
.ioc-signature-grid .sig-position{
  font-size:.94em!important;
  line-height:1.05!important;
  min-height:3.8mm!important;
}

/* V13.3 per-field font controls + IOC signature alignment */
.field-style-editor{display:grid;gap:9px;padding:10px;border:1px solid #eadfed;border-radius:14px;background:#fff}
.field-style-editor select{min-height:42px}
.field-style-toggle-row .style-toggle{flex:1 1 45%;justify-content:center;border-radius:14px;background:#fbf5fc}
.compact-actions{margin-top:2px;gap:7px}.compact-actions button{padding:8px 10px;font-size:12px}
.advanced-font-defaults{margin-top:10px;border:1px dashed #eadfed;border-radius:14px;padding:9px 10px;background:#fff}
.advanced-font-defaults summary{cursor:pointer;color:var(--purple);font-weight:900;margin-bottom:8px}
.render-field.field-bold,.render-field.field-bold *{font-weight:700!important}
.render-field.field-italic,.render-field.field-italic *{font-style:italic!important}
.paper [style*="font-weight:700"]{font-weight:700!important}
.paper [style*="font-style:italic"]{font-style:italic!important}
.ioc-signature-grid .sig-line-block{top:30mm!important;}
.ioc-signature-grid .sig-lead{height:3.4mm!important;min-height:3.4mm!important;margin:0 0 .5mm 0!important;line-height:1.0!important;align-items:flex-end!important;}
.ioc-signature-grid .sig-line{height:2.4mm!important;margin:0 0 .7mm 0!important;}
.ioc-signature-grid .sig-name{line-height:1.0!important;min-height:3.5mm!important;}
.ioc-signature-grid .sig-position{line-height:1.0!important;min-height:3.5mm!important;}
@media (max-width:900px){.field-style-toggle-row .style-toggle{flex:1 1 100%}.compact-actions{display:grid;grid-template-columns:1fr 1fr}.advanced-font-defaults summary{font-size:14px}}

/* V13.4 simpler per-field controls + compact IOC signature */
.simple-font-card{gap:8px!important}
.field-label-row{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:6px}
.field-label-row label{margin:0!important;line-height:1.25;min-width:0}
.field-mini-toolbar{display:inline-flex;align-items:center;justify-content:flex-end;gap:4px;flex:0 0 auto;flex-wrap:nowrap}
.mini-style-btn{border:1px solid #e2d3e7;background:#fff;color:#4f0056;border-radius:9px;min-width:28px;height:28px;padding:0 7px;font-size:12px;font-weight:900;line-height:1;box-shadow:0 2px 7px rgba(79,0,86,.05)}
.mini-style-btn:hover{background:#fbf2fd;border-color:#b78ac2}
.mini-style-btn.active{background:#4f0056;color:#fff;border-color:#4f0056}
.mini-style-btn.italic{font-style:italic}
.mini-style-btn.reset{min-width:28px;color:#6b6570;background:#f7f4f8}
@media(max-width:760px){.field-label-row{align-items:flex-start;flex-direction:column}.field-mini-toolbar{width:100%;justify-content:flex-start}.mini-style-btn{height:32px;min-width:36px}}

.ioc-signature-grid.ioc-signature-grid-v134{
  grid-template-columns:1fr 1fr 1fr!important;
  gap:5mm!important;
  height:100%!important;
  align-items:stretch!important;
}
.ioc-signature-grid-v134 .sig-col{
  position:relative!important;
  display:block!important;
  height:100%!important;
  min-height:0!important;
  text-align:center!important;
}
.ioc-signature-grid-v134 .ioc-approval-panel{
  position:absolute!important;
  top:0!important;
  left:0!important;
  right:0!important;
  margin:0!important;
  min-height:11mm!important;
  height:11mm!important;
  padding:.8mm 1mm!important;
  border:1px solid #333!important;
  border-radius:1.8mm!important;
  font-size:1.05em!important;
  line-height:1.05!important;
  display:flex!important;
  align-items:center!important;
  justify-content:center!important;
  gap:3mm!important;
  background:rgba(255,255,255,.72)!important;
}
.ioc-signature-grid-v134 .sig-note{display:none!important}
.ioc-signature-grid-v134 .sig-line-block{
  position:absolute!important;
  top:16mm!important;
  left:0!important;
  right:0!important;
  width:100%!important;
  margin:0!important;
  padding:0!important;
}
.ioc-signature-grid-v134 .sig-lead{
  height:7mm!important;
  min-height:7mm!important;
  margin:0 0 .9mm 0!important;
  padding:0 1mm!important;
  line-height:1.12!important;
  display:flex!important;
  align-items:flex-end!important;
  justify-content:center!important;
  text-align:center!important;
  font-weight:600!important;
  overflow:hidden!important;
  white-space:normal!important;
}
.ioc-signature-grid-v134 .sig-lead-empty{visibility:hidden!important}
.ioc-signature-grid-v134 .sig-line{
  height:1.4mm!important;
  margin:0 0 .9mm 0!important;
  border-bottom:1px dotted #555!important;
}
.ioc-signature-grid-v134 .sig-name{
  font-weight:600!important;
  line-height:1.05!important;
  min-height:3mm!important;
  margin:0 0 .7mm 0!important;
}
.ioc-signature-grid-v134 .sig-position{
  font-size:.94em!important;
  line-height:1.05!important;
  min-height:3mm!important;
  margin:0!important;
}
.ioc-signature-grid-v134 .approval-choice{white-space:nowrap!important}

/* V13.7 IOC signature ultra-compact line/name/position spacing */
.ioc-signature-grid-v134 .sig-line-block{
  top:15.5mm!important;
}
.ioc-signature-grid-v134 .sig-lead{
  height:5.2mm!important;
  min-height:5.2mm!important;
  margin:0 0 .45mm 0!important;
  line-height:1.0!important;
}
.ioc-signature-grid-v134 .sig-line{
  height:0!important;
  min-height:0!important;
  margin:0 0 .15mm 0!important;
  padding:0!important;
  line-height:0!important;
  border-bottom:1px dotted #555!important;
}
.ioc-signature-grid-v134 .sig-name{
  line-height:.92!important;
  min-height:0!important;
  margin:0 0 .05mm 0!important;
  padding:0!important;
  font-weight:600!important;
}
.ioc-signature-grid-v134 .sig-position{
  line-height:.92!important;
  min-height:0!important;
  margin:0!important;
  padding:0!important;
  font-size:.94em!important;
}
.ioc-signature-grid-v134 .sig-name:empty,
.ioc-signature-grid-v134 .sig-position:empty{display:none!important;}


/* V13.8 IOC signature no-gap override: force exact absolute spacing for dotted line, name and position */
.ioc-signature-grid-v134 .sig-line-block{
  top:15.2mm!important;
  height:18mm!important;
  position:absolute!important;
  left:0!important;
  right:0!important;
  margin:0!important;
  padding:0!important;
}
.ioc-signature-grid-v134 .sig-lead{
  position:absolute!important;
  left:0!important;
  right:0!important;
  top:0!important;
  height:5mm!important;
  min-height:5mm!important;
  margin:0!important;
  padding:0 1mm!important;
  line-height:1!important;
  display:flex!important;
  align-items:flex-end!important;
  justify-content:center!important;
}
.ioc-signature-grid-v134 .sig-line{
  position:absolute!important;
  left:1mm!important;
  right:1mm!important;
  top:5.3mm!important;
  height:0!important;
  min-height:0!important;
  margin:0!important;
  padding:0!important;
  line-height:0!important;
  border-bottom:1px dotted #555!important;
}
.ioc-signature-grid-v134 .sig-name{
  position:absolute!important;
  left:0!important;
  right:0!important;
  top:5.15mm!important;
  min-height:0!important;
  margin:0!important;
  padding:0!important;
  line-height:.78!important;
  font-weight:600!important;
  transform:translateY(0)!important;
}
.ioc-signature-grid-v134 .sig-position{
  position:absolute!important;
  left:0!important;
  right:0!important;
  top:8.3mm!important;
  min-height:0!important;
  margin:0!important;
  padding:0!important;
  line-height:.82!important;
  font-size:.94em!important;
}
.ioc-signature-grid-v134 .sig-name:empty,
.ioc-signature-grid-v134 .sig-position:empty{display:none!important;}

/* V13.9 IOC signature balanced gap: not too close, not too far */
.ioc-signature-grid-v134 .sig-line-block{
  top:15.2mm!important;
  height:20mm!important;
  position:absolute!important;
  left:0!important;
  right:0!important;
  margin:0!important;
  padding:0!important;
}
.ioc-signature-grid-v134 .sig-lead{
  position:absolute!important;
  left:0!important;
  right:0!important;
  top:0!important;
  height:5.2mm!important;
  min-height:5.2mm!important;
  margin:0!important;
  padding:0 1mm!important;
  line-height:1.02!important;
  display:flex!important;
  align-items:flex-end!important;
  justify-content:center!important;
}
.ioc-signature-grid-v134 .sig-line{
  position:absolute!important;
  left:1mm!important;
  right:1mm!important;
  top:5.9mm!important;
  height:0!important;
  min-height:0!important;
  margin:0!important;
  padding:0!important;
  line-height:0!important;
  border-bottom:1px dotted #555!important;
}
.ioc-signature-grid-v134 .sig-name{
  position:absolute!important;
  left:0!important;
  right:0!important;
  top:7.25mm!important;
  min-height:0!important;
  margin:0!important;
  padding:0!important;
  line-height:.92!important;
  font-weight:600!important;
  transform:none!important;
}
.ioc-signature-grid-v134 .sig-position{
  position:absolute!important;
  left:0!important;
  right:0!important;
  top:10.65mm!important;
  min-height:0!important;
  margin:0!important;
  padding:0!important;
  line-height:.95!important;
  font-size:.94em!important;
}
.ioc-signature-grid-v134 .sig-name:empty,
.ioc-signature-grid-v134 .sig-position:empty{display:none!important;}

/* V14.2 IOC signature exact spacing requested by user
   - Dotted line: 15mm
   - Name in parentheses: 17mm
   - Position: 22mm */
.ioc-signature-grid-v134 .sig-line-block{
  top:15.2mm!important;
  height:36mm!important;
  position:absolute!important;
  left:0!important;
  right:0!important;
  margin:0!important;
  padding:0!important;
}
.ioc-signature-grid-v134 .sig-lead{
  position:absolute!important;
  left:0!important;
  right:0!important;
  top:0!important;
  height:5.4mm!important;
  min-height:5.4mm!important;
  margin:0!important;
  padding:0 1mm!important;
  line-height:1.04!important;
  display:flex!important;
  align-items:flex-end!important;
  justify-content:center!important;
  text-align:center!important;
}
.ioc-signature-grid-v134 .sig-line{
  position:absolute!important;
  left:1mm!important;
  right:1mm!important;
  top:15mm!important;
  height:0!important;
  min-height:0!important;
  margin:0!important;
  padding:0!important;
  line-height:0!important;
  border-bottom:1px dotted #555!important;
}
.ioc-signature-grid-v134 .sig-name{
  position:absolute!important;
  left:0!important;
  right:0!important;
  top:17mm!important;
  min-height:0!important;
  margin:0!important;
  padding:0!important;
  line-height:.96!important;
  font-weight:600!important;
  transform:none!important;
}
.ioc-signature-grid-v134 .sig-position{
  position:absolute!important;
  left:0!important;
  right:0!important;
  top:22mm!important;
  min-height:0!important;
  margin:0!important;
  padding:0!important;
  line-height:.98!important;
  font-size:.94em!important;
}

/* =========================================================
   V15 Preview-first UX
   ========================================================= */
body.preview-first-v15{background:#f5f2f7;color:#241527;overflow:hidden}
body.preview-first-v15 .appbar{height:68px;min-height:68px;padding:10px 18px;background:linear-gradient(135deg,#3d0847,#61166d);box-shadow:0 8px 24px rgba(47,5,55,.18)}
body.preview-first-v15 .brand-mark{background:linear-gradient(145deg,#d8ae4b,#f4d77e);color:#401049;box-shadow:none}
body.preview-first-v15 .brand-group h1{font-size:1.08rem}
body.preview-first-v15 .brand-group p{font-size:.76rem;opacity:.82}
body.preview-first-v15 .mobile-tabs{display:none!important}
body.preview-first-v15 .workspace{height:calc(100vh - 68px);display:grid;grid-template-columns:minmax(0,1fr) 370px;gap:0;max-width:none;padding:0;overflow:hidden}
body.preview-first-v15 .preview-panel{order:1;border:0;border-radius:0;background:#e9e5ec;min-width:0;height:100%;display:flex;flex-direction:column}
body.preview-first-v15 .control-panel{order:2;width:auto;max-width:none;height:100%;overflow:auto;border:0;border-left:1px solid #dfd5e2;border-radius:0;background:#fff;padding:14px;box-shadow:-10px 0 34px rgba(59,20,65,.08)}
body.preview-first-v15 .control-panel>.panel-head,
body.preview-first-v15 #quickFormCard,
body.preview-first-v15 #dataForm,
body.preview-first-v15 .font-control-card,
body.preview-first-v15 .workflow-card{display:none!important}
body.preview-first-v15 #openTemplateManagerBtn{display:none!important}
body.preview-first-v15 .pf-document-selector{margin:0 0 12px;padding:12px;border:1px solid #e8deeb;background:#fbf9fc}
body.preview-first-v15 .pf-document-selector label{font-weight:700;color:#4f0b59}
body.preview-first-v15 .pf-document-selector .template-row{grid-template-columns:1fr}
body.preview-first-v15 .preview-head{min-height:66px;padding:12px 18px;background:#fff;border-bottom:1px solid #e4dce6;display:flex;align-items:center;gap:16px;flex-wrap:wrap}
body.preview-first-v15 .preview-head>div:first-child{margin-right:auto}
body.preview-first-v15 .preview-head strong{font-size:1rem;color:#3f1646}
body.preview-first-v15 .preview-head span{display:block;color:#756779;font-size:.78rem}
body.preview-first-v15 .paper-meta{background:#f2ebf4;color:#60166c;border:1px solid #decce2;border-radius:999px;padding:6px 10px;font-weight:700;font-size:.73rem}
body.preview-first-v15 .pf-legend{display:flex!important;align-items:center;gap:10px;flex-wrap:wrap}
body.preview-first-v15 .pf-legend span{display:inline-flex;align-items:center;gap:5px;font-size:.7rem;color:#655b68}
.pf-dot{width:11px;height:11px;border-radius:3px;display:inline-block;background:#fff}
.pf-dot-empty{border:1.5px dashed #979097}.pf-dot-active{border:2px solid #7d1b8a;background:#f5e9f8}.pf-dot-filled{border:2px solid #13864d;background:#e5f7ed}.pf-dot-required{border:2px solid #cf2d3d;background:#fff0f2}
body.preview-first-v15 .pf-progress{display:flex;align-items:center;gap:12px;padding:9px 18px;background:#fff;border-bottom:1px solid #e6dee8}
.pf-progress-track{height:7px;background:#eee7f0;border-radius:999px;overflow:hidden;flex:1}
.pf-progress-track span{display:block;height:100%;width:0;background:linear-gradient(90deg,#6a1975,#a53cad);transition:width .25s ease}
.pf-progress strong{font-size:.72rem;color:#4d4051;white-space:nowrap}
body.preview-first-v15 .preview-tools{padding:8px 18px;background:#f8f6f9;border-bottom:1px solid #dfd7e1}
body.preview-first-v15 .preview-scroll{flex:1;min-height:0;padding:22px 18px 50px;overflow:auto}
body.preview-first-v15 .paper-shell{min-height:100%}
body.preview-first-v15 .paper{box-shadow:0 16px 42px rgba(39,20,42,.20)}
body.preview-first-v15 #refreshPreviewBtn{display:none}

/* Preview field states */
body.preview-first-v15 #paperStack [data-source]{cursor:pointer;outline-offset:-1px;transition:outline-color .12s,background-color .12s,box-shadow .12s}
body.preview-first-v15 #paperStack [data-source].pf-empty{outline:1.2px dashed rgba(108,104,110,.70);background:rgba(255,255,255,.08)}
body.preview-first-v15 #paperStack [data-source].pf-active{outline:2px solid #7b1b89;background:rgba(126,31,142,.10);box-shadow:0 0 0 2px rgba(126,31,142,.10) inset;z-index:15}
body.preview-first-v15 #paperStack [data-source].pf-filled{outline:1.6px solid rgba(15,139,76,.80);background:rgba(30,176,97,.06)}
body.preview-first-v15 #paperStack [data-source].pf-required-empty{outline:1.8px solid #d42f43;background:rgba(222,42,64,.08);animation:pf-required-pulse 1.8s ease-in-out infinite}
@keyframes pf-required-pulse{0%,100%{box-shadow:0 0 0 0 rgba(210,43,63,.05)}50%{box-shadow:0 0 0 2px rgba(210,43,63,.15)}}
body.preview-first-v15 #paperStack .ioc-signature-grid [data-source]{position:relative;cursor:pointer;border-radius:2px}

/* Field editor */
.pf-field-editor{margin:0 0 12px;padding:0!important;border:1px solid #e1d5e4!important;overflow:hidden;background:#fff!important;box-shadow:0 8px 24px rgba(75,25,82,.07)}
.pf-editor-head{padding:13px 14px;background:linear-gradient(135deg,#f7f0f9,#fff);border-bottom:1px solid #eadfed;display:flex;align-items:center;justify-content:space-between;gap:10px}
.pf-editor-head h3{margin:2px 0 0;font-size:1rem;color:#3d1543;line-height:1.35}
.pf-kicker{font-size:.68rem;color:#876e8d;font-weight:700;text-transform:uppercase;letter-spacing:.03em}
.pf-sheet-toggle{display:none}
.pf-editor-body{padding:14px}
.pf-field-control input,.pf-field-control textarea,.pf-field-control select{width:100%;font-size:16px!important;border:1.5px solid #d8cadc;border-radius:10px;padding:11px 12px;background:#fff;color:#2d1a31;outline:none}
.pf-field-control textarea{min-height:135px;resize:vertical;line-height:1.5}
.pf-field-control input:focus,.pf-field-control textarea:focus,.pf-field-control select:focus{border-color:#7a1b87;box-shadow:0 0 0 3px rgba(122,27,135,.12)}
.pf-select-wrap{display:grid;gap:8px}
.pf-file-control{display:grid;gap:9px}.pf-file-control span{font-size:.78rem;color:#766b78}
.pf-empty-editor{padding:24px 10px;text-align:center;color:#786b7b;background:#faf7fb;border:1px dashed #d9ccdc;border-radius:10px;font-size:.84rem}
.pf-style-tools{display:flex;align-items:center;gap:7px;margin-top:12px;padding:9px;border-radius:10px;background:#f7f3f8;border:1px solid #e7dce9}
.pf-style-tools>span{font-size:.73rem;font-weight:700;color:#68556c;margin-right:2px}
.pf-style-tools button{width:34px;height:32px;padding:0;border-radius:8px;border:1px solid #d6c8d9;background:#fff;color:#4f1d57;font-size:.9rem;cursor:pointer}
.pf-style-tools button.active{background:#6b1977;color:#fff;border-color:#6b1977}
.pf-style-tools strong{min-width:45px;text-align:center;font-size:.76rem;color:#4b3e4e}
.pf-save-next{width:100%;margin-top:13px;min-height:44px}
body.preview-first-v15 .action-bar{display:grid;grid-template-columns:1fr 1fr;gap:8px;position:static;padding:0;background:transparent;border:0}
body.preview-first-v15 .action-bar>*{display:none!important}
body.preview-first-v15 .action-bar #pfPreviousBtn,
body.preview-first-v15 .action-bar #pfNextBtn,
body.preview-first-v15 .action-bar #saveDraftBtn,
body.preview-first-v15 .action-bar #pfReviewBtn,
body.preview-first-v15 .action-bar #submitApprovalBtn,
body.preview-first-v15 .action-bar #downloadPdfBtn{display:inline-flex!important;justify-content:center;align-items:center;min-height:42px;font-size:.78rem;padding:8px 9px}
body.preview-first-v15 .action-bar #downloadPdfBtn,
body.preview-first-v15 .action-bar #submitApprovalBtn{grid-column:span 1}

/* Review */
.pf-review-dialog{width:min(620px,calc(100vw - 24px))}
.pf-review-status{display:flex;flex-direction:column;gap:3px;padding:12px 14px;border-radius:10px;margin-bottom:12px}
.pf-review-status.success{background:#eaf8f0;color:#17683e;border:1px solid #bfe7cf}
.pf-review-status.danger{background:#fff0f2;color:#9a2332;border:1px solid #f0c1c8}
.pf-review-status span{font-size:.78rem}
.pf-approval-summary{border:1px solid #e4dae6;border-radius:10px;overflow:hidden}
.pf-summary-row{display:grid;grid-template-columns:150px 1fr;gap:12px;padding:10px 12px;border-bottom:1px solid #eee6ef}
.pf-summary-row:last-child{border-bottom:0}.pf-summary-row span{color:#7c6e7f;font-size:.78rem}.pf-summary-row strong{color:#3a243e;font-size:.84rem}
.pf-approval-error{margin-top:12px;padding:11px 13px;border-radius:9px;background:#fff2e6;color:#934900;border:1px solid #f0c99f;font-size:.8rem}

body.pdf-capture #paperStack [data-source],
body.preview-first-v15.printing #paperStack [data-source]{outline:none!important;background:transparent!important;box-shadow:none!important;animation:none!important}

@media(max-width:980px){
  body.preview-first-v15 .workspace{grid-template-columns:minmax(0,1fr) 330px}
}
@media(max-width:760px){
  body.preview-first-v15{overflow:hidden}
  body.preview-first-v15 .appbar{height:58px;min-height:58px;padding:8px 12px}
  body.preview-first-v15 .brand-group p{display:none}
  body.preview-first-v15 .workspace{height:calc(100vh - 58px);display:block;position:relative}
  body.preview-first-v15 .preview-panel{height:100%;padding-bottom:43vh}
  body.preview-first-v15 .preview-head{padding:9px 12px;min-height:52px}
  body.preview-first-v15 .preview-head>div:first-child span{display:none}
  body.preview-first-v15 .pf-legend{display:none!important}
  body.preview-first-v15 .pf-progress{padding:7px 12px}
  body.preview-first-v15 .preview-tools{padding:6px 12px}
  body.preview-first-v15 .preview-scroll{padding:12px 8px 40px}
  body.preview-first-v15 .control-panel{position:fixed;left:0;right:0;bottom:0;z-index:100;width:100%;height:auto;max-height:48vh;border:0;border-radius:18px 18px 0 0;padding:10px 12px calc(10px + env(safe-area-inset-bottom));box-shadow:0 -12px 36px rgba(46,15,52,.20);transition:transform .22s ease;overflow:auto}
  body.preview-first-v15 .control-panel.pf-sheet-collapsed{transform:translateY(calc(100% - 64px))}
  body.preview-first-v15 .pf-document-selector{display:block;margin:0 0 8px;padding:8px 10px}
  body.preview-first-v15 .pf-document-selector label{font-size:.7rem}
  body.preview-first-v15 .pf-document-selector .hint{display:none}
  body.preview-first-v15 .pf-field-editor{margin-bottom:8px}
  body.preview-first-v15 .pf-editor-head{padding:10px 12px}
  body.preview-first-v15 .pf-editor-body{padding:10px 12px}
  body.preview-first-v15 .pf-editor-head h3{font-size:.9rem}
  body.preview-first-v15 .pf-sheet-toggle{display:inline-flex}
  body.preview-first-v15 .pf-field-control textarea{min-height:82px}
  body.preview-first-v15 .pf-style-tools{margin-top:8px;padding:6px}
  body.preview-first-v15 .pf-save-next{margin-top:8px;min-height:40px}
  body.preview-first-v15 .action-bar{grid-template-columns:repeat(3,minmax(0,1fr));gap:6px}
  body.preview-first-v15 .action-bar #pfPreviousBtn,
  body.preview-first-v15 .action-bar #pfNextBtn,
  body.preview-first-v15 .action-bar #saveDraftBtn,
  body.preview-first-v15 .action-bar #pfReviewBtn,
  body.preview-first-v15 .action-bar #submitApprovalBtn,
  body.preview-first-v15 .action-bar #downloadPdfBtn{min-height:38px;font-size:.68rem;padding:6px 4px}
  .pf-summary-row{grid-template-columns:105px 1fr}
}
@media print{
  body.preview-first-v15 #paperStack [data-source]{outline:none!important;background:transparent!important;box-shadow:none!important;animation:none!important}
}

/* =========================================================
   V15 Admin information architecture
   ========================================================= */
body.admin-v15-page{margin:0;background:#f5f2f7;color:#2a1c2e;overflow:hidden}
.admin-v15-shell{display:grid;grid-template-columns:260px minmax(0,1fr);min-height:100vh}
.admin-sidebar{background:linear-gradient(180deg,#3e0b47,#26042d);color:#fff;padding:18px 14px;display:flex;flex-direction:column;min-height:100vh;box-shadow:8px 0 28px rgba(45,8,51,.12);z-index:20}
.admin-brand{display:flex;align-items:center;gap:11px;padding:2px 6px 18px;border-bottom:1px solid rgba(255,255,255,.12);margin-bottom:14px}.admin-brand .brand-mark{width:42px;height:42px}.admin-brand strong{display:block;font-size:1rem}.admin-brand span{display:block;font-size:.68rem;opacity:.66;margin-top:2px}
.admin-nav{display:grid;gap:6px}.admin-nav button{width:100%;display:flex;align-items:center;gap:10px;border:0;border-radius:10px;padding:11px 12px;background:transparent;color:rgba(255,255,255,.78);font:600 .82rem 'Sarabun',sans-serif;text-align:left;cursor:pointer}.admin-nav button:hover{background:rgba(255,255,255,.08);color:#fff}.admin-nav button.active{background:linear-gradient(135deg,#7f218d,#a23caf);color:#fff;box-shadow:0 8px 18px rgba(0,0,0,.15)}.admin-nav button span{width:22px;text-align:center;font-size:.9rem}
.admin-sidebar-foot{margin-top:auto;display:grid;gap:8px;padding-top:16px;border-top:1px solid rgba(255,255,255,.12)}.admin-sidebar-foot a,.admin-sidebar-foot button{color:#fff;background:rgba(255,255,255,.07);border:0;border-radius:9px;padding:9px 10px;text-align:center;text-decoration:none;font:600 .75rem 'Sarabun';cursor:pointer}
.admin-main{min-width:0;height:100vh;overflow:auto;padding:0 24px 36px}.admin-topbar{position:sticky;top:0;z-index:10;display:flex;justify-content:space-between;align-items:center;gap:14px;padding:17px 0 14px;background:rgba(245,242,247,.94);backdrop-filter:blur(12px);border-bottom:1px solid #e5dce8}.admin-topbar h1{font-size:1.25rem;margin:0;color:#3e1545}.admin-topbar p{margin:3px 0 0;font-size:.76rem;color:#76677a}.admin-cloud-badge{font-size:.72rem;font-weight:700;color:#8b4d10;background:#fff5e8;border:1px solid #efd5ae;border-radius:999px;padding:7px 10px}.admin-cloud-badge.online{color:#17663e;background:#eaf8f0;border-color:#bde4ce}
.admin-view{display:none;padding-top:18px}.admin-view.active{display:block}
.admin-kpi-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px}.admin-kpi-grid article{background:#fff;border:1px solid #e6dce8;border-radius:14px;padding:16px;box-shadow:0 8px 24px rgba(59,22,65,.05)}.admin-kpi-grid article span,.status-tile>span{font-size:.72rem;color:#7f7082}.admin-kpi-grid article strong{display:block;font-size:1.7rem;color:#4a1852;margin:5px 0 1px}.admin-kpi-grid article small,.status-tile small{font-size:.68rem;color:#918595}
.admin-dashboard-grid{display:grid;grid-template-columns:1.35fr .85fr;gap:14px;margin-top:14px}.admin-card{background:#fff;border:1px solid #e6dce8;border-radius:14px;padding:16px;box-shadow:0 8px 24px rgba(59,22,65,.05)}.admin-card h2{font-size:1rem;margin:0;color:#421849}.admin-card h3{font-size:.9rem;color:#421849}.admin-card p{font-size:.73rem;color:#817383;margin:3px 0 0}.admin-card-head{display:flex;align-items:center;justify-content:space-between;gap:14px;margin-bottom:13px}.admin-card-head-wrap{flex-wrap:wrap}.admin-actions-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.admin-actions-row input[type=search]{min-width:240px}
.readiness-list{display:grid;gap:8px}.readiness-item{display:grid;grid-template-columns:30px minmax(0,1fr) auto;gap:9px;align-items:center;padding:10px;border-radius:10px;background:#f8f5f9;border:1px solid #ece4ee}.readiness-item>span{width:26px;height:26px;border-radius:50%;display:grid;place-items:center;font-weight:800}.readiness-item.ok>span{background:#dff5e8;color:#14733f}.readiness-item.pending>span{background:#fff0df;color:#a55a08}.readiness-item strong{font-size:.78rem}.readiness-item small{font-size:.66rem;color:#8d7f90}.admin-shortcuts{display:grid;grid-template-columns:1fr 1fr;gap:9px}.admin-shortcuts button{border:1px solid #dfd2e2;background:#faf7fb;color:#531e5b;border-radius:10px;padding:15px 8px;font:700 .76rem 'Sarabun';cursor:pointer}.admin-shortcuts button:hover{background:#f2e9f4}
.admin-clean-table{width:100%;border-collapse:collapse;font-size:.74rem}.admin-clean-table th{background:#f7f3f8;color:#655568;text-align:left;padding:10px;border-bottom:1px solid #e6dce8;white-space:nowrap}.admin-clean-table td{padding:10px;border-bottom:1px solid #eee7ef;color:#433647;vertical-align:middle}.admin-clean-table tbody tr:hover{background:#fbf8fc}.admin-table-wrap{overflow:auto;border:1px solid #e6dce8;border-radius:10px}.employee-name-link{border:0;background:transparent;color:#651b70;font:700 .76rem 'Sarabun';cursor:pointer;padding:0}.line-link-badge,.send-status{display:inline-block;padding:4px 7px;border-radius:999px;font-size:.63rem;font-weight:700}.line-link-badge.linked,.send-status.sent{background:#e4f7ec;color:#167244}.line-link-badge.unlinked,.send-status.failed{background:#f2eef3;color:#7d6c81}.admin-empty{padding:24px;text-align:center;color:#8a7b8d;font-size:.78rem}.admin-upload-btn,.admin-actions-row button,.admin-card-head button,.designer-topbar button,.designer-toolbar button,.admin-card>button{border:1px solid #dacdde;background:#fff;color:#571d60;border-radius:9px;padding:9px 11px;font:700 .73rem 'Sarabun';cursor:pointer}.admin-upload-btn{display:inline-flex;align-items:center}.admin-card button.primary,.admin-actions-row button.primary,.designer-topbar button.primary{background:#6d1a79;border-color:#6d1a79;color:#fff}
.admin-v15-page input,.admin-v15-page select,.admin-v15-page textarea{font-family:'Sarabun',sans-serif;border:1px solid #d9cedc;border-radius:9px;padding:9px 10px;background:#fff;color:#302235;outline:none}.admin-v15-page input:focus,.admin-v15-page select:focus,.admin-v15-page textarea:focus{border-color:#7a1b87;box-shadow:0 0 0 3px rgba(122,27,135,.1)}
.employee-drawer{position:fixed;right:0;top:0;bottom:0;width:min(430px,100vw);background:#fff;z-index:150;transform:translateX(105%);transition:transform .22s ease;display:flex;flex-direction:column;box-shadow:-14px 0 38px rgba(43,12,49,.18)}.employee-drawer.open{transform:translateX(0)}.drawer-backdrop{position:fixed;inset:0;background:rgba(26,9,30,.35);z-index:140;opacity:0;visibility:hidden;transition:.2s}.drawer-backdrop.show{opacity:1;visibility:visible}.employee-drawer-head{display:flex;justify-content:space-between;align-items:center;padding:16px 18px;border-bottom:1px solid #eadfeb}.employee-drawer-head span{font-size:.66rem;color:#8b778f}.employee-drawer-head h2{margin:2px 0 0;font-size:1.1rem;color:#421749}.employee-drawer-head button{border:0;background:#f2ebf4;width:34px;height:34px;border-radius:50%;font-size:1.2rem;cursor:pointer}.employee-drawer-body{padding:16px 18px;display:grid;gap:11px;overflow:auto}.employee-drawer-body label{display:grid;gap:5px;font-size:.72rem;font-weight:700;color:#5b4b5e}.employee-drawer-body textarea{min-height:70px}.employee-drawer-foot{margin-top:auto;padding:13px 18px;border-top:1px solid #eadfeb;display:flex;align-items:center;justify-content:space-between}.employee-drawer-foot>div{display:flex;gap:8px}.employee-drawer-foot button{border:1px solid #d9cddc;background:#fff;border-radius:9px;padding:9px 12px;font:700 .73rem 'Sarabun';cursor:pointer}.employee-drawer-foot button.primary{background:#6d1a79;color:#fff;border-color:#6d1a79}.employee-drawer-foot button.danger{color:#a92738;border-color:#edc5cc}
.admin-login-overlay{position:fixed;inset:0;z-index:300;background:linear-gradient(135deg,#32083a,#5e1469);display:grid;place-items:center;padding:18px}.admin-login-overlay[hidden]{display:none}.admin-login-box{width:min(390px,100%);background:#fff;border-radius:18px;padding:28px;box-shadow:0 24px 70px rgba(0,0,0,.28);text-align:center}.admin-login-box .brand-mark{margin:0 auto 12px}.admin-login-box h2{margin:0;color:#421649}.admin-login-box p{font-size:.75rem;color:#817383}.admin-login-box input{width:100%;font-size:1rem;text-align:center;margin:10px 0}.admin-login-box button{width:100%;min-height:44px}.admin-login-box span{display:block;color:#ad2738;font-size:.72rem;margin-top:8px}
.csv-mapping-dialog{width:min(800px,calc(100vw - 24px))}.csv-mapping-rows{display:grid;gap:7px}.csv-mapping-rows>div{display:grid;grid-template-columns:1fr 1fr;gap:12px;align-items:center;padding:8px 10px;border-radius:9px;background:#f8f5f9}.csv-mapping-rows span{font-size:.75rem;font-weight:700}.csv-preview{margin-top:14px}.csv-preview>strong{display:block;font-size:.75rem;margin-bottom:7px}
.access-matrix th:not(:first-child),.access-matrix td{text-align:center}.access-matrix input[type=checkbox]{width:18px;height:18px;accent-color:#721b80}
.designer-card{padding:0;overflow:hidden}.designer-topbar{display:flex;align-items:end;justify-content:space-between;gap:12px;padding:13px 15px;border-bottom:1px solid #e5dbe7;background:#fff;flex-wrap:wrap}.designer-selects{display:flex;gap:9px}.designer-selects label{display:grid;gap:4px;font-size:.65rem;font-weight:700;color:#766478}.designer-modes{display:flex;border:1px solid #dacddd;border-radius:9px;overflow:hidden}.designer-modes button{border:0;border-right:1px solid #e0d5e2;border-radius:0;background:#fff}.designer-modes button:last-child{border-right:0}.designer-modes button.active{background:#6d1a79;color:#fff}.designer-toolbar{display:flex;align-items:center;gap:7px;padding:8px 15px;background:#f8f5f9;border-bottom:1px solid #e6dce8;flex-wrap:wrap}.designer-toolbar span{font-size:.65rem;color:#8a7c8d;margin-left:auto}.designer-layout{display:grid;grid-template-columns:minmax(0,1fr) 290px;min-height:620px}.designer-stage-wrap{background:#dcd7df;padding:20px;overflow:auto}.designer-stage{position:relative;width:min(720px,100%);aspect-ratio:210/297;margin:auto;background-color:#fff;background-size:100% 100%;background-repeat:no-repeat;box-shadow:0 12px 34px rgba(42,19,46,.18);user-select:none}.designer-stage[data-mode=add]{cursor:crosshair}.designer-field-box{position:absolute;border:1.5px dashed #8b8390;background:rgba(255,255,255,.14);min-width:8px;min-height:8px;cursor:pointer}.designer-field-box:hover{border-color:#722080}.designer-field-box.selected{border:2px solid #7c1d89;background:rgba(124,29,137,.12);z-index:5}.designer-field-box span{position:absolute;left:0;top:-18px;background:#5c1766;color:#fff;font-size:9px;padding:2px 4px;border-radius:3px;white-space:nowrap;max-width:130px;overflow:hidden;text-overflow:ellipsis}.designer-resize-handle{position:absolute;right:-5px;bottom:-5px;width:10px;height:10px;background:#7b1c88;border:2px solid #fff;border-radius:2px;cursor:nwse-resize}.designer-inspector{border-left:1px solid #e5dbe7;background:#fff;padding:14px;overflow:auto}.designer-inspector h3{margin:0 0 12px}.designer-inspector label{display:grid;gap:5px;margin-bottom:10px;font-size:.68rem;font-weight:700;color:#645368}.designer-inspector .admin-check{display:flex;align-items:center;gap:7px}.designer-inspector details{margin:12px 0;padding:9px;border:1px solid #e3d8e5;border-radius:9px}.designer-inspector summary{font-size:.7rem;font-weight:700;cursor:pointer}.inspector-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:9px}.designer-inspector .danger{width:100%;color:#a52738;border-color:#e9c0c7;background:#fff}
.line-status-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px}.status-tile{display:flex;flex-direction:column}.status-tile strong{font-size:1.05rem;color:#4d1b55;margin:6px 0}.status-tile strong.ok{color:#167242}.status-tile strong.pending{color:#a35a0d}.admin-card>label{display:grid;gap:5px;font-size:.71rem;font-weight:700;color:#5d4d61;margin-bottom:10px}.admin-inline-result{font-size:.72rem;margin-top:9px}.admin-inline-result.success{color:#14713f}.admin-inline-result.error{color:#a72739}.system-facts{display:grid;gap:7px}.system-facts>div{display:flex;justify-content:space-between;gap:12px;padding:8px 0;border-bottom:1px solid #eee7ef}.system-facts span{font-size:.71rem;color:#807282}.system-facts strong{font-size:.72rem;color:#3e3042}
.admin-toast{position:fixed;right:18px;bottom:18px;z-index:400;padding:11px 14px;border-radius:10px;background:#3b2a3f;color:#fff;box-shadow:0 10px 30px rgba(0,0,0,.18);font-size:.75rem}.admin-toast.success{background:#176c43}.admin-toast.warning{background:#96530e}
@media(max-width:1100px){.admin-kpi-grid,.line-status-grid{grid-template-columns:1fr 1fr}.admin-dashboard-grid{grid-template-columns:1fr}.designer-layout{grid-template-columns:minmax(0,1fr) 260px}}
@media(max-width:760px){body.admin-v15-page{overflow:auto}.admin-v15-shell{display:block}.admin-sidebar{position:sticky;top:0;min-height:auto;padding:8px;z-index:50}.admin-brand{display:none}.admin-nav{display:flex;overflow:auto;gap:5px}.admin-nav button{flex:0 0 auto;width:auto;padding:8px 9px;font-size:.68rem}.admin-nav button span{display:none}.admin-sidebar-foot{display:none}.admin-main{height:auto;overflow:visible;padding:0 10px 24px}.admin-topbar{padding:11px 0}.admin-topbar h1{font-size:1rem}.admin-topbar p{display:none}.admin-kpi-grid,.line-status-grid{grid-template-columns:1fr 1fr;gap:8px}.admin-kpi-grid article{padding:12px}.admin-kpi-grid article strong{font-size:1.3rem}.admin-card{padding:12px}.admin-actions-row{width:100%}.admin-actions-row input[type=search]{width:100%;min-width:0}.designer-layout{display:block}.designer-stage-wrap{padding:10px}.designer-inspector{border-left:0;border-top:1px solid #e5dbe7}.designer-topbar{align-items:stretch}.designer-selects{width:100%}.designer-selects label{flex:1}.designer-modes{width:100%}.designer-modes button{flex:1}.designer-toolbar span{display:none}.pf-summary-row{grid-template-columns:100px 1fr}}


/* V15.0.2 IOC: rows after signature (copy / coordinator) */
.ioc-post-signature-field,
.ioc-dynamic-post-signature{
  display:block!important;
  align-items:initial!important;
  padding:0 1mm!important;
  overflow:visible!important;
  line-height:1.18!important;
  white-space:normal!important;
}
.ioc-post-signature{
  width:100%;
  height:100%;
  display:grid;
  align-content:start;
  gap:1.6mm;
}
.ioc-post-signature.has-copy.has-coordinator{
  grid-template-rows:minmax(7mm,auto) minmax(16mm,1fr);
}
.ioc-post-signature.has-copy:not(.has-coordinator){
  grid-template-rows:minmax(7mm,auto);
}
.ioc-post-signature.has-coordinator:not(.has-copy){
  grid-template-rows:minmax(16mm,auto);
}
.ioc-post-row{
  width:100%;
  padding:.8mm 1mm;
  border-radius:1.2mm;
}
.ioc-post-row > div{
  display:flex;
  align-items:flex-end;
  gap:1.6mm;
  min-height:5.6mm;
}
.ioc-post-label{
  flex:0 0 auto;
  font-weight:600;
  white-space:nowrap;
}
.ioc-post-value{
  display:inline-block;
  flex:1 1 auto;
  min-width:18mm;
  min-height:4.5mm;
  padding:0 .8mm .35mm;
  border-bottom:1px dotted #555;
  white-space:pre-wrap;
  overflow-wrap:anywhere;
}
.ioc-copy-row{
  display:flex;
  align-items:flex-end;
  gap:1.6mm;
}
.ioc-copy-row .ioc-post-value{min-width:55mm}
.ioc-coordinator-row{display:grid;gap:.5mm}
body.is-printing .ioc-post-row{outline:none!important;background:transparent!important;box-shadow:none!important}


/* =========================================================
   V15.0.4 native print isolation
   Prevent the Preview-first progress/header/toolbars from
   appearing when users print with Ctrl+P or the browser menu.
   ========================================================= */
@media print{
  @page{size:A4 portrait;margin:0!important}
  html,
  body,
  body.preview-first-v15{
    margin:0!important;
    padding:0!important;
    width:210mm!important;
    min-width:210mm!important;
    max-width:210mm!important;
    height:auto!important;
    min-height:0!important;
    background:#fff!important;
    overflow:visible!important;
  }

  body.preview-first-v15 .appbar,
  body.preview-first-v15 .mobile-tabs,
  body.preview-first-v15 .control-panel,
  body.preview-first-v15 .preview-head,
  body.preview-first-v15 .preview-tools,
  body.preview-first-v15 .pf-progress,
  body.preview-first-v15 .pf-legend,
  body.preview-first-v15 .workflow-card,
  body.preview-first-v15 dialog,
  body.preview-first-v15 .field-sheet,
  body.preview-first-v15 .field-sheet-backdrop,
  body.preview-first-v15 .ws-print-frame{
    display:none!important;
  }

  body.preview-first-v15 #workspace,
  body.preview-first-v15 .workspace,
  body.preview-first-v15 .preview-panel,
  body.preview-first-v15 .preview-scroll,
  body.preview-first-v15 .paper-shell,
  body.preview-first-v15 #paperStack,
  body.preview-first-v15 .paper-stack{
    display:block!important;
    position:static!important;
    inset:auto!important;
    margin:0!important;
    padding:0!important;
    border:0!important;
    border-radius:0!important;
    box-shadow:none!important;
    background:#fff!important;
    width:210mm!important;
    min-width:210mm!important;
    max-width:210mm!important;
    height:auto!important;
    min-height:0!important;
    max-height:none!important;
    overflow:visible!important;
    transform:none!important;
  }

  body.preview-first-v15 #paperStack .paper{
    display:block!important;
    position:relative!important;
    margin:0!important;
    padding:0!important;
    width:210mm!important;
    min-width:210mm!important;
    max-width:210mm!important;
    height:297mm!important;
    min-height:297mm!important;
    max-height:297mm!important;
    overflow:hidden!important;
    box-shadow:none!important;
    transform:none!important;
    transform-origin:top left!important;
    page-break-after:always!important;
    break-after:page!important;
  }

  body.preview-first-v15 #paperStack .paper:last-child{
    page-break-after:auto!important;
    break-after:auto!important;
  }

  body.preview-first-v15 #paperStack .template-bg{
    position:absolute!important;
    inset:0!important;
    display:block!important;
    width:210mm!important;
    height:297mm!important;
    object-fit:fill!important;
  }

  body.preview-first-v15 #paperStack [data-source]{
    outline:none!important;
    background:transparent!important;
    box-shadow:none!important;
    animation:none!important;
  }
}


/* V15.0.5 IOC optional footer collapse
   Empty copy/coordinator sections are not rendered and reserve no space. */
.ioc-post-signature:empty,
.ioc-post-signature-field:empty,
.ioc-dynamic-post-signature:empty{
  display:none!important;
}
