:root {
  --ink: #14325C;        /* Securelink navy */
  --ink-2: #1F63B5;      /* action blue */
  --paper: #EEF1F5;
  --sheet: #FFFFFF;
  --line: #D5DCE5;
  --text: #1B2533;
  --muted: #5E6B7C;
  --signed: #1E7A4F;
  --signed-bg: #E4F3EA;
  --wait: #9A6200;
  --wait-bg: #FFF3DC;
  --back: #B42318;
  --back-bg: #FDECEA;
  --radius: 6px;
  --display: "Barlow Semi Condensed", "Arial Narrow", "Segoe UI", sans-serif;
  --body: "Source Sans 3", "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--paper); color: var(--text); font: 15px/1.5 var(--body); font-variant-numeric: tabular-nums; }
a { color: var(--ink-2); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink-2); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); color: var(--ink); margin: 0; line-height: 1.15; }
h1 { font-size: 30px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }
.boot { padding: 40px; color: var(--muted); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--ink); color: #DCE6F3; padding: 22px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { font-family: var(--display); color: #fff; font-size: 21px; font-weight: 700; line-height: 1.1; padding: 0 10px 18px; }
.brand small { display: block; font-family: var(--body); font-size: 12.5px; font-weight: 400; color: #9FB4CF; margin-top: 4px; }
.side a { color: #DCE6F3; text-decoration: none; padding: 8px 10px; border-radius: 5px; display: flex; justify-content: space-between; align-items: center; }
.side a:hover { background: rgba(255,255,255,.07); }
.side a.on { background: #fff; color: var(--ink); font-weight: 600; }
.side .badge { background: #F2B233; color: #14325C; font-weight: 700; font-size: 12px; border-radius: 10px; padding: 0 7px; min-width: 20px; text-align: center; }
.side .sep { height: 1px; background: rgba(255,255,255,.12); margin: 12px 6px; }
.side .me { margin-top: auto; padding: 10px; font-size: 13px; color: #9FB4CF; }
.side .me strong { color: #fff; display: block; font-weight: 600; }
.side .me button { background: none; border: 0; color: #9FB4CF; padding: 0; margin-top: 6px; cursor: pointer; text-decoration: underline; }
.main { padding: 28px 34px 60px; max-width: 1320px; width: 100%; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.pagehead p { margin: 4px 0 0; color: var(--muted); }

/* ---------- common ---------- */
.card { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.card > h2, .card > h3 { margin-bottom: 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 16px; }
.btn { border: 1px solid var(--ink-2); background: var(--ink-2); color: #fff; border-radius: 5px; padding: 7px 14px; cursor: pointer; font-weight: 600; text-decoration: none; display: inline-flex; gap: 6px; align-items: center; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: #fff; color: var(--ink-2); }
.btn.ok { background: var(--signed); border-color: var(--signed); }
.btn.danger { background: #fff; color: var(--back); border-color: #E4B4AF; }
.btn.small { padding: 3px 9px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.linkbtn { background: none; border: 0; color: var(--ink-2); cursor: pointer; padding: 0; text-decoration: underline; }
label.f { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 13.5px; color: var(--ink); }
label.f span.hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], input[type=time], select, textarea {
  border: 1px solid #BFC9D6; border-radius: 5px; padding: 7px 9px; background: #fff; font-weight: 400; width: 100%; min-width: 0;
}
textarea { min-height: 70px; resize: vertical; }
input[type=file] { font-size: 13px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); padding: 7px 8px; white-space: nowrap; }
td { border-bottom: 1px solid #E8ECF1; padding: 8px; vertical-align: top; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #F6F8FB; }
.num { text-align: right; }
.tablewrap { overflow-x: auto; }
.empty { padding: 26px; text-align: center; color: var(--muted); }
.err { background: var(--back-bg); color: var(--back); border-radius: 5px; padding: 9px 12px; white-space: pre-line; margin: 10px 0; }
.note { background: #EAF1FA; border-left: 3px solid var(--ink-2); padding: 9px 12px; border-radius: 0 5px 5px 0; margin: 0 0 12px; font-size: 14px; }

.pill { display: inline-block; border-radius: 11px; padding: 1px 9px; font-size: 12.5px; font-weight: 600; white-space: nowrap; background: #E7ECF2; color: var(--ink); }
.pill.draft { background: #EEF0F3; color: var(--muted); }
.pill.in_progress { background: #E3EDFA; color: var(--ink-2); }
.pill.returned { background: var(--back-bg); color: var(--back); }
.pill.closed, .pill.issued_from_stock { background: var(--signed-bg); color: var(--signed); }
.pill.cancelled { background: #EEF0F3; color: #8A94A3; text-decoration: line-through; }
.tat { font-weight: 600; font-size: 13px; white-space: nowrap; }
.tat.over { color: var(--back); }
.tat.met { color: var(--signed); }
.tat.running { color: var(--wait); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--ink); padding: 20px; }
.login form { background: #fff; border-radius: 8px; padding: 30px; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; }
.login h1 { font-size: 26px; }

/* ---------- stage bar (a real sequence) ---------- */
.stages { display: flex; gap: 0; margin: 4px 0 20px; overflow-x: auto; }
.stage { flex: 1 1 0; min-width: 118px; padding: 9px 12px 10px; background: #fff; border: 1px solid var(--line); border-left: 0; font-size: 13px; position: relative; }
.stage:first-child { border-left: 1px solid var(--line); border-radius: 6px 0 0 6px; }
.stage:last-child { border-radius: 0 6px 6px 0; }
.stage b { display: block; font-family: var(--display); font-size: 15px; font-weight: 600; color: var(--muted); }
.stage .n { font-family: var(--display); font-weight: 700; color: #A9B4C2; margin-right: 4px; }
.stage.done { background: var(--signed-bg); }
.stage.done b, .stage.done .n { color: var(--signed); }
.stage.now { background: var(--ink); border-color: var(--ink); }
.stage.now b, .stage.now .n, .stage.now { color: #fff; }
.stage.skip { opacity: .45; }
.stage.skip b { text-decoration: line-through; }

/* ---------- request detail ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.mrno { font-family: var(--display); font-weight: 700; color: var(--ink-2); font-size: 17px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 18px; }
.facts div { font-size: 14px; }
.facts dt, .facts .k { color: var(--muted); font-size: 12.5px; }
.action { border: 2px solid var(--ink); }
.action h2 { display: flex; justify-content: space-between; gap: 10px; }
.checklist { list-style: none; padding: 0; margin: 0 0 14px; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px dashed var(--line); flex-wrap: wrap; }
.checklist .mark { width: 20px; height: 20px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 12px; font-weight: 700; border: 1.5px solid #BFC9D6; color: transparent; }
.checklist li.have .mark { background: var(--signed); border-color: var(--signed); color: #fff; }
.checklist .doc-name { flex: 1 1 200px; }
.inline-up { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; width: 100%; padding-left: 30px; }
.inline-up input[type=text] { max-width: 260px; }
.options { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.options label { display: flex; gap: 8px; align-items: flex-start; border: 1px solid var(--line); border-radius: 5px; padding: 9px 11px; cursor: pointer; }
.options label:has(input:checked) { border-color: var(--ink-2); background: #F1F6FD; }

/* routing slip: approvers sign down the slip */
.slip { list-style: none; margin: 0; padding: 0; }
.slip .stg { font-family: var(--display); font-weight: 600; color: var(--ink); font-size: 14.5px; margin: 14px 0 4px; }
.slip .stg:first-child { margin-top: 0; }
.slip li.s { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 7px 0 7px 12px; border-left: 3px solid #D5DCE5; font-size: 13.5px; }
.slip li.s .who { grid-column: 1 / -1; color: var(--muted); font-size: 12.5px; }
.slip li.s.done { border-left-color: var(--signed); }
.slip li.s.active { border-left-color: #F2B233; background: var(--wait-bg); }
.slip li.s.skipped { opacity: .45; }
.slip li.s.skipped .lbl { text-decoration: line-through; }
.slip li.s.returned { border-left-color: var(--back); }
.stamp { font-family: var(--display); font-weight: 700; font-size: 11.5px; letter-spacing: .04em; border: 1.5px solid currentColor; border-radius: 3px; padding: 0 5px; align-self: start; transform: rotate(-3deg); white-space: nowrap; }
.stamp.approved, .stamp.completed, .stamp.accept, .stamp.accepted, .stamp.for_purchase { color: var(--signed); }
.stamp.returned, .stamp.rejected { color: var(--back); }
.stamp.waiting { color: var(--wait); transform: none; border-style: dashed; }
.stamp.na { color: var(--muted); }
.log { list-style: none; margin: 0; padding: 0; font-size: 13px; max-height: 360px; overflow-y: auto; }
.log li { padding: 6px 0; border-bottom: 1px solid #EDF0F4; }
.log time { color: var(--muted); display: block; font-size: 12px; }

/* queue */
.qitem { display: grid; grid-template-columns: 150px 1fr auto; gap: 12px; align-items: center; padding: 12px 4px; border-bottom: 1px solid #E8ECF1; text-decoration: none; color: inherit; }
.qitem:hover { background: #F6F8FB; }
.qitem .step { font-weight: 600; color: var(--ink); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.stat b { font-family: var(--display); font-size: 30px; color: var(--ink); display: block; line-height: 1.1; }
.stat.warn b { color: var(--back); }

/* process guide */
.guide-stage { display: grid; grid-template-columns: 210px 1fr; gap: 18px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.guide-stage:last-child { border-bottom: 0; }
.guide-stage ol { margin: 0; padding-left: 20px; }
.guide-stage li { margin-bottom: 7px; }
.guide-stage .req { font-size: 13px; color: var(--muted); }
.roles-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px 14px; }
.roles-grid label { display: flex; gap: 8px; font-size: 14px; align-items: flex-start; }
.roles-grid small { display: block; color: var(--muted); }

.items td input, .items td textarea { width: 100%; }
.items td textarea { min-height: 38px; }

dialog { border: 0; border-radius: 8px; padding: 22px; width: min(640px, 94vw); box-shadow: 0 20px 60px rgba(10, 25, 50, .35); }
dialog::backdrop { background: rgba(12, 28, 52, .45); }
.banner { background: var(--wait-bg); color: var(--wait); padding: 8px 12px; border-radius: 5px; margin-bottom: 12px; display: flex; justify-content: space-between; gap: 10px; }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 6px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 50; max-width: 90vw; }
#toast.show { opacity: 1; }

@media (max-width: 1080px) {
  .detail { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; }
  .side .brand { width: 100%; padding-bottom: 8px; }
  .side .sep, .side .me small { display: none; }
  .side .me { margin: 0; width: 100%; }
  .main { padding: 18px 14px 50px; }
  .grid2, .grid3, .stats { grid-template-columns: 1fr 1fr; }
  .qitem { grid-template-columns: 1fr; gap: 2px; }
  .guide-stage { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
