:root{font-family:"Sukhumvit Set",Tahoma,system-ui,sans-serif;color:#203323;background:var(--surface);--surface:#f2f5ec;--ink:#19281c;--line:#d6dfd0;--muted:#536951;--accent:#a4cf57;line-height:1.5}
*{box-sizing:border-box} body{margin:0} button,input,select,textarea{font:inherit} button,a,input,select,textarea{-webkit-tap-highlight-color:transparent} button{cursor:pointer;border:1px solid transparent;background:var(--ink);color:white;border-radius:9px;padding:.62rem .92rem;font-weight:650;min-height:43px} button:hover:not(:disabled){filter:brightness(1.13)} button:disabled{cursor:default;opacity:.5} .secondary{color:var(--ink);background:#f7faf3;border-color:var(--line)} :focus-visible{outline:3px solid #729d43;outline-offset:2px}
.shell{max-width:1150px;margin:auto;padding:0 22px}.mast{background:var(--ink);color:#f5f9ee;border-bottom:0}.brand{display:flex;gap:12px;align-items:center;min-height:78px}.brand small{color:#b7ccab;font-size:.73rem;letter-spacing:.13em}.brand .badge{margin-left:auto;background:#dceabc}.badge{border-radius:20px;padding:.22rem .66rem;font-size:.83rem;font-weight:700;white-space:nowrap;color:#223221}.done{background:#d9eed9}.waiting{background:#faeac1}[hidden]{display:none!important}
.nav,.actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:20px}.intro{margin:22px 0 16px}h1,h2,p{margin:0}h1{font-size:clamp(1.5rem,4vw,2.2rem);line-height:1.25}h2{font-size:1.16rem}.intro p{margin-top:6px;color:var(--muted)}.workspace{display:grid;grid-template-columns:1.15fr 1fr;gap:16px;align-items:start}.panel{background:#fff;border:1px solid var(--line);border-radius:14px;padding:17px;box-shadow:0 6px 20px #2435230b}.sectionhead,.filters{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap}.filters{margin:12px 0}.filters input{flex:1;min-width:140px}.results{max-height:450px;overflow:auto;padding-right:5px}.product,.cartrow,.record{display:flex;gap:10px;align-items:center;justify-content:space-between;padding:9px 0;border-bottom:1px solid #e7ede2}.product button{white-space:nowrap}.cartrow div{flex:1;overflow-wrap:anywhere}.cartrow input{width:76px}.record{color:inherit;text-decoration:none}.record:hover{background:#f2f7eb}.record + button{margin-top:12px}.record strong{overflow-wrap:anywhere}small{display:block}.muted{color:var(--muted)}label{display:block;font-weight:650}input,select,textarea{padding:.52rem .62rem;color:var(--ink);border:1px solid #b5c6af;border-radius:8px;background:white;min-height:42px}label input,label textarea{display:block;width:100%;margin:4px 0 10px}textarea{height:65px;resize:vertical}hr{border:0;border-top:1px solid var(--line);margin:15px 0}#notice{margin-top:14px;border:1px solid var(--line);background:#e0efd8;padding:10px;border-radius:8px}#notice.error{background:#fce8e6;color:#872e29}.paper{margin-top:16px}dl{display:grid;grid-template-columns:max-content 1fr;gap:6px 14px}dt{font-weight:650}dd{margin:0;overflow-wrap:anywhere}table{width:100%;border-collapse:collapse}td,th{padding:8px;text-align:left;border-bottom:1px solid var(--line);overflow-wrap:anywhere}th{background:#e8f0df}td:nth-child(n+4),th:nth-child(n+4){text-align:right}.signatures{display:flex;justify-content:space-between;gap:20px;margin:36px 0 10px;flex-wrap:wrap}footer.shell{padding-top:24px;padding-bottom:24px;color:var(--muted);font-size:.85rem}
@media(max-width:730px){.workspace{grid-template-columns:1fr}.shell{padding-left:12px;padding-right:12px}.results{max-height:330px}.panel{padding:12px}td,th{padding:5px;font-size:.86rem}dl{grid-template-columns:1fr;gap:3px}dd{margin-bottom:4px}.brand img{width:34px;height:34px}}
@media print{@page{size:A4;margin:14mm}body{background:#fff;color:#000}.mast,.nav,.no-print,#notice,footer.shell{display:none!important}.shell,.paper{width:auto;max-width:none;margin:0;padding:0;border:0;box-shadow:none}.paper h1{font-size:21pt}.paper td,.paper th{padding:5pt;font-size:10pt;border-color:#aaa}.paper thead{display:table-header-group}.paper tr,.signatures{break-inside:avoid}.paper dl{grid-template-columns:max-content 1fr}.paper .badge{border:1px solid #aaa}.signatures{padding-top:8pt}}
.requisition-form{display:grid;gap:14px}.request-fields{display:grid;grid-template-columns:1fr 1fr;gap:0 14px;margin-top:10px}.category h2{scroll-margin-top:18px}.category .sectionhead{margin-bottom:10px}.entry-table td,.entry-table th,.detail-table td,.detail-table th{text-align:left}.entry-table :is(td,th):not(:first-child),.detail-table :is(td,th):nth-child(n+3):nth-child(-n+5){text-align:center}.detail-table :is(td,th):nth-child(6){text-align:right}.entry-table input{width:78px;min-width:0;text-align:center}.entry-table input:disabled{background:#f2f4ef}.entry-table{table-layout:fixed}.entry-table th:not(:first-child){width:94px}.entry-table .medicine-label{font-size:18px;line-height:24px}.entry-table input[aria-label^="เบิก "]{border-color:#718d5d}.entry-table tr.filled{background:#edf6e4}.submit-strip{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px 15px;background:#e5efda;border:1px solid #bdcdb5;border-radius:11px}.paper-category th{background:#dbe9d1;font-size:1em}.detail-table{table-layout:auto}.detail-table td:last-child{max-width:180px;white-space:pre-wrap}
@media screen and (max-width:730px){.request-fields{grid-template-columns:1fr}.entry-table,.entry-table tbody{display:block}.entry-table thead{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}.entry-table tr{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));padding:9px 4px;gap:4px;border-bottom:1px solid var(--line)}.entry-table td{border:0;padding:2px;min-width:0}.entry-table .medicine-label{grid-column:1/-1;font-size:16px;line-height:20.64px;font-weight:700}.entry-table td:not(:first-child)::before{content:attr(data-label);display:block;color:var(--muted);font-size:.75rem}.entry-table input{width:100%;min-width:0}.detail-table td,.detail-table th{font-size:.8rem;padding:4px}}
.detail-table thead th:nth-last-child(-n+2) { text-align: center; }
@media print{.detail-table .paper-category th{break-after:avoid;border-top:1px solid #999}.detail-table td:last-child{max-width:105pt}}

button.danger{color:#872e29;border-color:#e1bdb8;background:#fff5f3}

@media screen and (pointer:coarse){
  html{touch-action:pan-x pan-y}
  /* iOS zooms into form controls whose computed type size is below 16px. */
  input,select,textarea{font-size:16px}
}

.custom-items>.muted{font-size:.9rem}.custom-row{display:grid;grid-template-columns:minmax(0,3fr) minmax(0,1.2fr) minmax(0,1fr) auto;align-items:end;gap:10px;padding:12px 0 4px;border-top:1px solid var(--line)}.custom-rows:not(:empty){margin-top:14px}.custom-row label,.custom-row input{min-width:0}.custom-row button{margin-bottom:10px}
@media screen and (max-width:730px){.custom-row{grid-template-columns:1fr 1fr}.custom-row label:first-child{grid-column:1/-1}.custom-row button{grid-column:1/-1;justify-self:start;margin-bottom:4px}}

.brand-icon{border-radius:22%;object-fit:contain;flex:none}

.medicine-finder>input{width:100%;margin:5px 0 3px}
.medicine-results{display:grid;gap:6px;margin-top:8px}
.medicine-results>button{text-align:left;overflow-wrap:anywhere}
.entry-table tr:focus-within{background:#eff6e8}

.nav .nav-icon {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 9px;
}
.nav .refresh-icon { font-size: 1.45rem; line-height: 1; }
#manager-login, .nav .refresh-icon { margin-inline-start: auto; }
#manager-login:not([hidden]) + .refresh-icon { margin-inline-start: 0; }
#manager-login:hover { filter: brightness(1.13); }

@media screen{
 .medicine-finder{position:sticky;top:0;z-index:5;align-self:start;box-shadow:0 5px 16px #19281c18}
 .medicine-results{max-height:42vh;overflow-y:auto;overscroll-behavior:contain}
 .category h2{scroll-margin-top:145px}
}

.entry-table .medicine-unit{font-size:.875em;font-weight:500;line-height:0}


@media screen {
  /* WebKit samples the color of the header pinned to the viewport edge. */
  .page-surface { display: flow-root; }
  html.ios-standalone,
  .ios-standalone body { background-color: var(--ink); }
  .ios-standalone body { display: flex; flex-direction: column; min-height: 100dvh; }
  .ios-standalone .page-surface { flex: 1; background-color: var(--surface); }
  .ios-standalone .mast { position: sticky; top: 0; z-index: 6; }
  .ios-standalone .medicine-finder { top: var(--mast-height, 78px); }
  html.ios-standalone { scroll-padding-top: var(--mast-height, 78px); }
}

.requisition-intro { margin: 14px 0 7px; }
.medicine-finder + .category-filters { margin-top: -7px; }

.category-filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: safe center;
  gap: 5px 3px;
}
.category-chip {
  min-height: 38px;
  padding: 4px;
  border-color: #cbd8bf;
  border-radius: 999px;
  background: #f8faf5;
  color: var(--ink);
  font-size: .8125rem;
  line-height: 1.3;
  white-space: nowrap;
}
.category-chip[aria-pressed="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

@media screen and (min-width: 410px) {
  .category-chip { font-size: .875rem; }
}

@media screen and (min-width: 360px) and (max-width: 389px) {
  .category-chip { font-size: .75rem; }
}

@media screen and (max-width: 359px) {
  .category-filters {
    display: grid;
    grid-template-columns: repeat(6, max-content);
    overflow-x: auto;
    padding: 2px;
  }
}

/* Use the same A4 layout for measuring and printing the explicit pages. */
.print-copy {
  width: 182mm;
  color: #000;
}
.print-copy .print-page {
  display: flow-root;
  margin: 0;
}
.print-copy .no-print { display: none !important; }
.print-copy h1 { font-size: 21pt; }
.print-copy .print-category-badge {
  align-self: flex-start;
  border: 1px solid #9aac95;
  background: #e8f0df;
}
.print-copy dl { grid-template-columns: max-content 1fr; gap: 6px 14px; }
.print-copy dd { margin-bottom: 0; }
.print-copy .detail-table :is(td, th) {
  padding: 5pt;
  font-size: 10pt;
  border-color: #aaa;
  border-left: .6pt solid #aaa;
  border-right: .6pt solid #aaa;
}
.print-copy thead th { white-space: nowrap; border-top: .6pt solid #aaa; }
.print-copy .detail-table td:last-child { max-width: 105pt; }
.print-copy .paper-category th { border-top: 1px solid #999; }
.print-copy .print-page-table { table-layout: fixed; }
.print-copy .signatures { padding-top: 8pt; }

@media screen {
  .print-copy {
    position: absolute;
    top: 0;
    left: -10000px;
    visibility: hidden;
  }
}
@media print {
  .print-copy + .paper-source, .paper-source [data-print-omit] { display: none; }
  .print-copy .print-page + .print-page {
    page-break-before: always;
    break-before: page;
  }
}

.field-suggestion {
  display: none;
  min-height: 36px;
  margin-bottom: 8px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: .875rem;
}
.suggestible-field:focus-within .field-suggestion { display: inline-flex; align-items: center; }

.pdf-download { align-self: center; color: var(--ink); }
