/* AMS Office Stock — ธีมตาม AMS จริง (Brand Kit 20/10/2569, จาก reference/ams-theme.json)
   primary #0B2A5B · primary-dark #071D42 · secondary #176B9B · accent #12AEC1 · accent-bg #E7F8FB · bg #F7FAFC · ฟอนต์ Prompt/Inter
   ย้ายเฉพาะ design tokens (ไม่นำ CSS AMS ทั้งไฟล์มาวาง) */
:root {
  --navy: #0B2A5B; --navy-2: #176B9B; --navy-dark: #071D42; --teal: #12AEC1; --teal-ink: #0B7F8F; --teal-soft: #E7F8FB;
  --bg: #F7FAFC; --surface: #FFFFFF; --surface-2: #EEF4F9; --text: #102A43; --muted: #5F7088; --border: #DCE8F2;
  --primary: #0B2A5B; --primary-strong: #071D42; --primary-soft: #E7F8FB; --on-primary: #FFFFFF;
  --accent: #12AEC1; --accent-ink: #0B7F8F; --accent-soft: #E7F8FB; --on-accent: #071D42;
  --header-bg: #FFFFFF; --header-fg: #0B2A5B; --header-muted: #5F7088;
  --danger: #C0352B; --danger-soft: #FCE8E6; --warn: #9A5B00; --warn-soft: #FFF2D9; --ok: #11795A; --ok-soft: #DDF3EA; --info-soft: #E3EEF8; --info: #1D4F91;
  --radius: 10px; --shadow: 0 1px 2px rgba(15,23,42,.05), 0 4px 14px rgba(15,23,42,.06);
  --nav-h: 64px; --top-h: 60px;
  --font: 'Prompt', 'Inter', system-ui, -apple-system, "Segoe UI", "Noto Sans Thai", "Sarabun", "Leelawadee UI", Tahoma, sans-serif;
  color-scheme: light only;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent-ink); }
h1 { font-size: 1.35rem; margin: 0 0 12px; }
h2 { font-size: 1.1rem; margin: 0 0 10px; }
h3 { font-size: 1rem; margin: 0 0 8px; }
small, .muted { color: var(--muted); }
.hidden { display: none !important; }

/* layout */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 0 16px; padding-top: env(safe-area-inset-top); height: calc(var(--top-h) + env(safe-area-inset-top));
  background: var(--header-bg); color: var(--header-fg); border-bottom: 3px solid var(--teal); }
.topbar .brand { font-weight: 700; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1.08rem; letter-spacing: .01em; }
.topbar .brand-short { display: none; }
@media (max-width: 359px) { .topbar .brand-full { display: none; } .topbar .brand-short { display: inline; } }
@media (max-width: 480px) { .topbar .who { font-size: .78rem; max-width: 40vw; } }
.topbar-logo { height: 32px; width: auto; display: block; }
.topbar .who small { color: var(--header-muted) !important; }
.topbar button { background: transparent; color: inherit; border: 0; font: inherit; padding: 8px; min-height: 44px; border-radius: 8px; }
.topbar .who { font-size: .85rem; opacity: .9; text-align: right; line-height: 1.2; max-width: 45vw; overflow: hidden; text-overflow: ellipsis; }
main { padding: 16px; padding-bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); max-width: 1200px; margin: 0 auto; }
.bottomnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
.bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: var(--nav-h); color: var(--muted); text-decoration: none; font-size: .75rem; }
.bottomnav a.active { color: var(--accent-ink); font-weight: 700; box-shadow: inset 0 3px 0 var(--accent); }
.bottomnav svg, .sidenav svg { width: 24px; height: 24px; }
.sidenav { display: none; }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 30; }
.drawer { position: fixed; top: 0; bottom: 0; left: 0; width: min(300px, 85vw); background: var(--surface); z-index: 31; padding: calc(16px + env(safe-area-inset-top)) 12px 16px; overflow-y: auto; box-shadow: var(--shadow); }
.navlist a { display: flex; align-items: center; gap: 12px; padding: 12px; min-height: 48px; border-radius: 10px; color: var(--text); text-decoration: none; }
.navlist a.active { background: var(--accent-soft); color: var(--text); font-weight: 700; box-shadow: inset 4px 0 0 var(--accent); }
.navlist a:hover:not(.active) { background: var(--surface-2); }
.navlist a.active svg { color: var(--accent-ink); }
.navlist hr { border: 0; border-top: 1px solid var(--border); margin: 8px 0; }
@media (min-width: 900px) {
  .bottomnav, .menu-btn { display: none !important; }
  .sidenav { display: block; position: fixed; top: var(--top-h); bottom: 0; left: 0; width: 248px; background: var(--surface); border-right: 1px solid var(--border); padding: 12px; overflow-y: auto; }
  main { margin-left: 248px; padding: 24px; padding-bottom: 32px; max-width: none; }
}

/* components */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card.tight { padding: 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1; min-width: 0; }
.space-between { justify-content: space-between; }
.grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid.cols-2 { grid-template-columns: 1fr 1fr; } .grid.cols-3 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .grid.cols-4 { grid-template-columns: repeat(4, 1fr); } .grid.dash { grid-template-columns: 1fr 1fr; } }
.kpis { display: grid; gap: 10px; grid-template-columns: repeat(2, 1fr); margin-bottom: 14px; }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1100px) { .kpis { grid-template-columns: repeat(8, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; text-decoration: none; color: inherit; display: block; }
.kpi { border-top: 3px solid var(--accent); }
.kpi .v { font-size: 1.6rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--text); }
.kpi .l { font-size: .8rem; color: var(--muted); }
.kpi.kpi-alert { border-top-color: var(--danger); }
.kpi.kpi-alert .v { color: var(--danger); }
.kpi.kpi-warn { border-top-color: var(--warn); }
.kpi.kpi-warn .v { color: var(--warn); }

label { display: block; font-size: .9rem; font-weight: 600; margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.field .hint { font-size: .8rem; color: var(--muted); margin-top: 2px; }
input, select, textarea { width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-height: 44px; }
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 1px; border-color: var(--accent); }
input[type=checkbox], input[type=radio] { width: 22px; height: 22px; min-height: 0; vertical-align: middle; accent-color: var(--accent); }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600; min-height: 44px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn.primary:hover:not(:disabled) { background: var(--primary-strong); }
.btn.accent { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn:not(.primary):not(.danger):not(.ghost):hover:not(:disabled) { border-color: var(--accent); }
.btn.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent-ink); }
.btn.small { min-height: 36px; padding: 6px 10px; font-size: .9rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 20px; height: 20px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.sticky-actions { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); background: var(--bg); padding: 10px 0; z-index: 5; }
@media (min-width: 900px) { .sticky-actions { bottom: 0; } }
.choice { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .choice { grid-template-columns: 1fr 1fr; } }
.choice a { display: block; padding: 18px; border-radius: var(--radius); border: 2px solid var(--border); background: var(--surface); text-decoration: none; color: inherit; }
.choice a:hover { border-color: var(--accent); }
.choice a { border-top: 4px solid var(--accent); }
.choice a strong { display: block; font-size: 1.1rem; color: var(--text); margin-bottom: 4px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.alert { border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; border: 1px solid transparent; }
.alert.danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.info { background: var(--info-soft); color: var(--info); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert ul { margin: 4px 0 0; padding-left: 20px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: var(--surface-2); color: var(--text); font-weight: 700; white-space: nowrap; position: sticky; top: 0; border-bottom: 2px solid var(--border); }
tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 40%, transparent); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }

.list { display: flex; flex-direction: column; gap: 10px; }
.list-item { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; color: inherit; text-decoration: none; }
.list-item .t { font-weight: 700; }
.list-item .s { font-size: .88rem; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }

.lines .line { border: 1px solid var(--border); border-radius: 10px; padding: 10px; margin-bottom: 10px; background: var(--surface); }
.lines .line .row > * { min-width: 0; }
.line-grid { display: grid; gap: 8px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .line-grid { grid-template-columns: 2fr 1fr 1fr auto; align-items: end; } .line-grid.rcv { grid-template-columns: 2fr 1fr 1fr 1fr; } }
.line.bad { border-color: var(--danger); background: var(--danger-soft); }
.line.warn { border-color: var(--warn); }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.photo { position: relative; border-radius: 10px; overflow: hidden; background: var(--surface-2); aspect-ratio: 1; border: 1px solid var(--border); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .x { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.65); color: #fff; border: 0; border-radius: 999px; width: 32px; height: 32px; font-size: 18px; }
.photo .st { position: absolute; left: 0; right: 0; bottom: 0; font-size: .75rem; padding: 3px 6px; background: rgba(0,0,0,.6); color: #fff; }
.photo.big { aspect-ratio: auto; }
.photo.big img { height: auto; max-height: 70vh; object-fit: contain; }
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 14px; text-align: center; background: var(--surface); }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.tabs a, .tabs button { flex: none; padding: 8px 14px; min-height: 40px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; font: inherit; font-size: .92rem; cursor: pointer; }
.tabs .active { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.tabs a:hover:not(.active) { border-color: var(--accent); }
.filters { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; margin-bottom: 12px; }
@media (min-width: 900px) { .filters { grid-template-columns: repeat(5, 1fr); align-items: end; } }
.filters .field { margin: 0; }

.bars .bar { display: grid; grid-template-columns: minmax(80px, 38%) 1fr auto; gap: 8px; align-items: center; margin: 6px 0; font-size: .9rem; }
.bars .track { height: 12px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.bars .fill { height: 100%; background: var(--accent); border-radius: 6px; }
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: .95rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 420px) { .dl { grid-template-columns: 1fr; } .dl dt { margin-top: 6px; } }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { border-left: 3px solid var(--border); padding: 4px 0 10px 12px; font-size: .9rem; }

.offline-banner { position: sticky; top: calc(var(--top-h) + env(safe-area-inset-top)); z-index: 19; background: var(--danger); color: #fff; padding: 8px 16px; text-align: center; font-weight: 600; }
@media (min-width: 900px) { .offline-banner { margin-left: 248px; } }
.toast-wrap { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 50; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 480px); }
.toast { background: var(--navy); color: #fff; padding: 12px 14px; border-radius: 10px; box-shadow: var(--shadow); }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); color: #fff; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--surface); width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; border-radius: 16px 16px 0 0; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .modal-backdrop { align-items: center; } .modal { border-radius: 16px; } }
.spinner { display: inline-block; width: 20px; height: 20px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { padding: 40px; text-align: center; }
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px 16px; background: linear-gradient(var(--header-bg) 0 38%, var(--bg) 38% 100%); }
.login { width: min(420px, 100%); border-top: 4px solid var(--teal); margin: 0; }
.login-title { text-align: center; margin-bottom: 14px; }
.login-brand { text-align: center; color: var(--header-fg); }
.login-brand h1 { font-size: 1.9rem; margin: 0; letter-spacing: .01em; color: var(--header-fg); }
.login-brand p { margin: 4px 0 0; color: var(--header-muted); }
.login-logo { max-height: 72px; width: auto; display: block; margin: 0 auto 10px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; overflow-wrap: anywhere; }
.pre { white-space: pre-wrap; font-size: .85rem; background: var(--surface-2); padding: 10px; border-radius: 8px; max-height: 240px; overflow: auto; }
.qtybox { font-variant-numeric: tabular-nums; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }

.line.skipped { background: var(--surface-2); border-style: dashed; }
.timestem-notice ul { margin: 6px 0 4px; }
.tree, .tree ul { list-style: none; margin: 0; padding-left: 18px; }
.tree { padding-left: 0; }
.tree li { position: relative; padding: 4px 0 4px 14px; border-left: 2px solid var(--border); }
.tree li::before { content: ''; position: absolute; left: 0; top: 16px; width: 10px; border-top: 2px solid var(--border); }
.tree .node { display: inline-block; padding: 6px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.badge.out { background: var(--danger); color: #fff; }

/* เครดิตผู้ออกแบบ (รูปแบบเดียวกับ AMS — ตำแหน่งยืนยันอีกครั้งเมื่อได้ภาพอ้างอิง) */
.credit { display: flex; align-items: center; gap: 8px; font-size: .78rem; color: var(--muted); line-height: 1.35; }
.credit-logo { height: 22px; width: auto; flex: none; }
.credit.side { margin-top: 16px; padding: 12px; border-top: 1px solid var(--border); }
.credit.login-credit { justify-content: center; text-align: center; }
.sidenav { display: none; }
@media (min-width: 900px) { .sidenav { display: flex; flex-direction: column; } .sidenav .credit.side { margin-top: auto; } }
.drawer { display: flex; flex-direction: column; }
.drawer .credit.side { margin-top: auto; }
.drawer-head { padding: 0 12px 10px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.drawer-brand { font-weight: 700; color: var(--accent-ink); font-size: .85rem; letter-spacing: .02em; margin-bottom: 6px; }
.drawer-logo { max-height: 36px; width: auto; display: block; margin-bottom: 6px; }
.card { border-color: var(--border); }
.section-title h1 { color: var(--text); }
h1 { color: var(--text); }

.filters > *, .grid > *, .line-grid > * { min-width: 0; }
.topbar svg { width: 24px; height: 24px; display: block; }
.card.login { border-top: 4px solid var(--teal); }

/* ===== หน้า Login / OTP (v1.3) — Light Corporate: กรมท่า #12304A + ฟ้าอมเขียว #12AEC1 ===== */
.login-wrap { position: relative; isolation: isolate; min-height: 100vh; min-height: 100dvh; justify-content: flex-start; background: var(--bg);
  padding: calc(env(safe-area-inset-top, 0px) + clamp(24px, 6vh, 56px)) 16px calc(env(safe-area-inset-bottom, 0px) + 24px); }
.login-wrap::before { content: ''; position: absolute; inset: 0 0 auto 0; height: calc(env(safe-area-inset-top, 0px) + clamp(24px, 6vh, 56px) + 196px); background: var(--header-bg); border-bottom: 3px solid var(--teal); z-index: -1; }
.login-brand { display: flex; flex-direction: column; align-items: center; }
.login-brand h1 { font-size: clamp(1.6rem, 5vw, 2rem); }
.login-logo { max-height: 72px; max-width: 220px; margin: 0 auto 10px; }
.logo-slot { width: 76px; height: 76px; margin: 0 auto 10px; border: 2px dashed color-mix(in srgb, var(--header-fg) 55%, transparent); border-radius: 16px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--header-fg); background: color-mix(in srgb, var(--header-fg) 8%, transparent); }
.logo-slot-mark { font-weight: 800; letter-spacing: .12em; font-size: .9rem; }
.logo-slot-note { font-size: .6rem; line-height: 1.15; text-align: center; color: var(--header-muted); padding: 0 4px; }
.card.login { width: min(440px, 100%); padding: 22px 22px 18px; box-shadow: 0 10px 30px rgba(18,48,74,.12); }
.login-title { font-size: 1.25rem; margin: 2px 0 14px; color: var(--text); }
.auth-desc { color: var(--muted); font-size: .92rem; margin: -6px 0 14px; text-align: center; overflow-wrap: anywhere; }
.auth-desc strong { color: var(--text); }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 72px; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); min-height: 36px; padding: 4px 10px; border: 0; border-radius: 8px; background: transparent;
  color: var(--accent-ink); font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; }
.pw-toggle:hover { background: var(--surface-2); }
.check-row { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 2px 0 14px; }
.check-row .check { align-items: center; margin: 0; font-size: .9rem; min-height: 32px; cursor: pointer; }
.check-row .check input { width: 20px; height: 20px; flex: none; }
.auth-links { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.auth-links.center { justify-content: center; }
.link-btn { border: 0; background: none; padding: 6px 2px; min-height: 36px; font: inherit; font-size: .92rem; font-weight: 600; color: var(--accent-ink); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.link-btn:hover { color: var(--primary); }
.login-hints { margin: 14px 0 0; padding: 12px 12px 12px 28px; background: var(--surface-2); border-radius: 10px; font-size: .8rem; color: var(--muted); line-height: 1.5; }
.login-hints li + li { margin-top: 4px; }
.otp-input { font-size: 1.6rem; letter-spacing: .5em; text-align: center; font-variant-numeric: tabular-nums; font-weight: 700; padding-left: calc(12px + .5em); }
.otp-input::placeholder { color: color-mix(in srgb, var(--muted) 55%, transparent); letter-spacing: .5em; }
.otp-timer { text-align: center; font-size: .88rem; color: var(--muted); margin: -4px 0 12px; font-variant-numeric: tabular-nums; }
.otp-timer.expired { color: var(--danger); font-weight: 600; }
.auth-form .btn.block + .btn.block { margin-top: 8px; }
.pw-rules { list-style: none; margin: 0 0 14px; padding: 0; font-size: .85rem; color: var(--muted); display: grid; gap: 4px; }
.pw-rules li { padding-left: 24px; position: relative; }
.pw-rules li::before { content: '○'; position: absolute; left: 4px; }
.pw-rules li.met { color: var(--ok); }
.pw-rules li.met::before { content: '✓'; font-weight: 700; }
.setup-steps { padding-left: 20px; font-size: .9rem; line-height: 1.6; }
.setup-steps code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .82rem; overflow-wrap: anywhere; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0 0 0 0) !important; white-space: nowrap !important; border: 0 !important; min-height: 0 !important; }
.credit.login-credit { margin-top: 4px; }
@media (max-width: 380px) { .card.login { padding: 18px 14px 14px; } .check-row { flex-direction: column; gap: 2px; } }
.sec-list { display: grid; gap: 0; margin-bottom: 12px; }
.sec-row { display: grid; grid-template-columns: 1fr minmax(120px, 200px); gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.sec-input { display: flex; align-items: center; gap: 8px; }
.sec-input input[type=number] { max-width: 110px; }
@media (max-width: 560px) { .sec-row { grid-template-columns: 1fr; gap: 6px; } }

/* ===== v4: วัสดุ (การ์ด/ตาราง/รูป), แถบโรงงาน, ตัวเลือกรูป ===== */
.mat-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); margin-bottom: 14px; }
.mat-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: inherit; box-shadow: var(--shadow); }
.mat-card:hover { border-color: var(--accent); }
.mat-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.mat-body .t { font-weight: 600; line-height: 1.3; overflow-wrap: anywhere; }
.mat-body .s { color: var(--muted); font-size: .85rem; }
.mat-qty { font-size: 1.25rem; font-weight: 700; }
.mat-qty small { font-weight: 400; margin-left: 4px; }
.img-box { position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.img-box img, .mat-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-missing { opacity: .4; }
.no-img { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); font-size: .85rem; text-align: center; padding: 8px; }
.no-img span:first-child { font-size: 1.8rem; }
.no-img.big { min-height: 200px; border: 2px dashed var(--border); border-radius: var(--radius); width: 100%; }
.thumb-sm { width: 44px; height: 44px; border-radius: 8px; overflow: hidden; background: var(--surface-2); display: flex; align-items: center; justify-content: center; flex: none; }
.thumb-sm img { width: 100%; height: 100%; object-fit: cover; }
.mat-detail { display: grid; gap: 14px; grid-template-columns: 1fr; }
.mat-hero { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.mat-hero .img-box { aspect-ratio: 4 / 3; max-height: 60vh; }
.mat-hero img { object-fit: contain; }
.mat-grid.pick { grid-template-columns: repeat(2, 1fr); max-height: 50vh; overflow-y: auto; }
.factory-bar, .factory-chip { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px; margin-bottom: 12px; display: inline-flex; align-items: center; gap: 6px; font-size: .95rem; }
.factory-bar select { min-height: 36px; border: 0; background: transparent; font-weight: 600; color: inherit; }
.view-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.view-toggle button { border: 0; background: var(--surface); color: var(--text); padding: 6px 14px; min-height: 36px; cursor: pointer; }
.view-toggle button.active { background: var(--primary); color: var(--on-primary); }
.ro-chip { background: var(--info-soft); color: var(--info); border-radius: 999px; padding: 2px 10px; font-size: .8rem; white-space: nowrap; }
.nav-sub { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 14px 2px; }
.back { display: inline-block; margin-bottom: 8px; text-decoration: none; }
.ok-card { border-color: var(--ok); background: var(--ok-soft); }
.grid.two { grid-template-columns: 1fr; }
.modal.wide { max-width: 860px; }
.photo-capture, .img-picker { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.card.tight { padding: 10px 12px; margin-bottom: 8px; }
.space-between { justify-content: space-between; }
.role-radios { display: flex; flex-direction: column; gap: 4px; margin: 4px 0; }
.pre { white-space: pre-wrap; font-family: ui-monospace, Menlo, monospace; font-size: .8rem; max-width: 520px; overflow-wrap: anywhere; }
@media (min-width: 640px) { .mat-grid { grid-template-columns: repeat(3, 1fr); } .grid.two { grid-template-columns: 1fr 1fr; } .mat-detail { grid-template-columns: minmax(280px, 40%) 1fr; } }
@media (min-width: 1000px) { .mat-grid { grid-template-columns: repeat(4, 1fr); } .mat-grid.pick { grid-template-columns: repeat(3, 1fr); } }

/* ---------- v2.1.0: ตะกร้าเบิก / ปุ่มย้อนกลับ / รับเข้าหน้าเดียว ---------- */
.mat-card .mat-link { display: flex; flex-direction: column; flex: 1; color: inherit; text-decoration: none; }
.mat-card .mat-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 10px 10px; }
.mat-card .mat-actions .btn { flex: 1 1 auto; }
td .mat-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0; min-width: 190px; }
.cart-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; color: inherit; text-decoration: none; font-size: 1.3rem; }
.cart-count { position: absolute; top: 2px; right: 0; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--danger); color: #fff; font-size: .75rem; font-weight: 700; line-height: 20px; text-align: center; }
.btn .cart-count { position: static; display: inline-block; margin-left: 4px; }
.cart-count.hidden { display: none; }
.back { display: inline-flex; align-items: center; min-height: 36px; font-weight: 600; }
.modal-back { background: none; border: 0; font: inherit; font-weight: 600; color: var(--accent-ink); cursor: pointer; padding: 4px 0; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: -4px 0 10px; }
.chip { font: inherit; font-size: .85rem; padding: 4px 10px; min-height: 32px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: inherit; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
ul.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.receive-choice a.active { border-color: var(--accent); background: var(--surface-2, var(--surface)); }
.section-h { margin: 18px 0 8px; font-size: 1.1rem; }

/* ===== v2.1.0 แบรนด์ AMS: โลโก้จริง, หัวเว็บ/เมนู/Login แบบ AMS (เฉพาะ token และรูปแบบที่เกี่ยวข้อง) ===== */
/* หัวเว็บ: พื้นขาว ตัวอักษรกรมท่า ให้โลโก้สีน้ำเงินเห็นชัด */
.topbar { border-bottom: 1px solid var(--border); box-shadow: 0 1px 0 rgba(11,42,91,.04), 0 2px 10px rgba(11,42,91,.05); }
.topbar .brand { color: var(--primary); font-weight: 700; }
.brand-link { display: flex; align-items: center; flex: none; border-radius: 10px; }
.brand-link:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.topbar-logo { height: 40px; width: 40px; object-fit: contain; border-radius: 9px; flex: none; }
.topbar button:focus-visible, .nav-collapse:focus-visible, .navlist a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn.accent, .login .btn.primary, .auth-form .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.accent:hover:not(:disabled), .login .btn.primary:hover:not(:disabled), .auth-form .btn.primary:hover:not(:disabled) { background: #0F9AAB; border-color: #0F9AAB; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(18,174,193,.22); }
.toast { background: var(--primary-strong); }
/* Sidebar: พื้นไล่สีฟ้าอ่อนแบบ AMS */
.sidenav, .drawer { background: linear-gradient(180deg, #F8FCFF 0%, #EAF6FF 100%); }
.navlist a { color: var(--primary); font-weight: 500; }
.navlist a:hover:not(.active) { background: var(--accent-soft); color: var(--primary-strong); }
.navlist a.active { background: var(--accent-soft); color: var(--primary-strong); box-shadow: inset 4px 0 0 var(--accent); }
.nav-ic { display: inline-flex; flex: none; }
.nav-label { min-width: 0; overflow-wrap: anywhere; }
.nav-collapse { display: none; }
.drawer-head .drawer-logo { height: 44px; width: 44px; object-fit: contain; border-radius: 10px; display: block; margin-bottom: 8px; }
.drawer-brand { color: var(--primary); font-size: .95rem; }
.credit-logo { height: 28px; width: 28px; object-fit: contain; border-radius: 6px; }
.credit-text { min-width: 0; overflow-wrap: anywhere; word-break: keep-all; }
@media (min-width: 900px) {
  .sidenav { width: 248px; transition: width .2s ease; }
  main { transition: margin-left .2s ease; }
  .nav-collapse { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; min-height: 0; margin: 0 0 6px auto; padding: 0; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--primary); cursor: pointer; }
  .nav-collapse svg { width: 18px; height: 18px; transition: transform .2s ease; }
  .nav-collapse:hover { background: var(--accent-soft); }
  #layout.nav-collapsed .sidenav { width: 76px; padding: 12px 8px; }
  #layout.nav-collapsed main { margin-left: 76px; }
  #layout.nav-collapsed .nav-collapse { margin: 0 auto 6px; }
  #layout.nav-collapsed .nav-collapse svg { transform: rotate(180deg); }
  #layout.nav-collapsed .navlist a { justify-content: center; padding: 12px 6px; }
  /* เก็บข้อความไว้ให้โปรแกรมอ่านหน้าจอ แต่ซ่อนจากสายตาเมื่อพับ */
  #layout.nav-collapsed .nav-label, #layout.nav-collapsed .nav-sub, #layout.nav-collapsed .credit-text { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  #layout.nav-collapsed .credit.side { justify-content: center; padding: 12px 0; }
}
/* Login / OTP / ตั้งรหัสผ่าน: พื้นฟ้าอ่อนเต็มหน้า การ์ดขาวกลางจอ โลโก้ในการ์ดด้านบน */
.login-wrap { background: linear-gradient(135deg, #F7FAFC 0%, #E0F2FE 100%); justify-content: center; padding: calc(env(safe-area-inset-top, 0px) + 20px) 16px calc(env(safe-area-inset-bottom, 0px) + 20px); }
.login-wrap::before { content: none; display: none; }
.auth-box { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px 28px 22px; box-shadow: 0 20px 25px -5px rgba(15,23,42,.08), 0 8px 10px -6px rgba(15,23,42,.08); }
.auth-box .card.login { width: auto; max-width: none; padding: 0; margin: 0; border: 0; border-top: 0; box-shadow: none; background: transparent; }
.login-brand { color: var(--primary); margin-bottom: 18px; }
.login-brand h1 { color: var(--primary-strong); font-size: clamp(1.4rem, 5vw, 1.6rem); font-weight: 700; }
.login-brand p { color: var(--muted); font-size: .9rem; }
.login-logo { height: 72px; width: 72px; max-height: none; max-width: none; object-fit: contain; margin: 0 auto 12px; border-radius: 14px; }
.logo-slot { border-color: var(--border); color: var(--primary); background: var(--surface-2); }
.logo-slot-note { color: var(--muted); }
.credit.login-credit { color: var(--muted); }
@media (max-width: 380px) { .auth-box { padding: 20px 16px 16px; } }
@media (max-height: 480px) and (orientation: landscape) { .login-wrap { justify-content: flex-start; } .login-logo { height: 48px; width: 48px; margin-bottom: 6px; } .login-brand { margin-bottom: 8px; } .login-brand p { display: none; } }
.brand-link:empty { display: none; }

/* UI-01: compact authentication, independent navigation scroll and About dialog */
:root { --top-h: 56px; }
.topbar-logo { width: 34px; height: 34px; }
.login-wrap { gap: 12px; padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); }
.auth-box { width: min(400px, 100%); padding: 18px 22px 16px; }
.login-logo { height: 48px; width: 48px; margin-bottom: 6px; border-radius: 10px; }
.login-brand { margin-bottom: 10px; }
.login-brand h1 { font-size: 1.35rem; }
.login-brand p { font-size: .8rem; margin-top: 4px; }
.login-title { font-size: 1.1rem; margin: 0 0 10px; }
.auth-box .field { margin-bottom: 10px; }
.auth-box .check-row { gap: 4px 12px; margin-bottom: 10px; }
.auth-box .check-row .check { font-size: .8rem; }
.auth-box .auth-links { margin-top: 6px; }
.auth-box .link-btn { font-size: .82rem; }
.auth-box .login-hints { font-size: .72rem; padding: 8px 10px 8px 24px; margin-top: 8px; }
.credit { width: 100%; border: 0; background: transparent; font-family: inherit; font-weight: 400; text-align: left; cursor: pointer; border-radius: 8px; }
.credit:hover { background: var(--accent-soft); }
.credit:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.credit-text { display: flex; flex-direction: column; gap: 3px; }
.credit-version { color: var(--accent-ink); font-size: .75rem; font-weight: 600; }
.credit.login-credit { width: auto; padding: 6px 10px; }
.nav-collapse { flex: 0 0 32px; height: 32px; width: 32px; min-height: 32px; }
.sidenav .navlist, .drawer .navlist { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }
.sidenav .credit.side, .drawer .credit.side { flex: 0 0 auto; margin-top: 8px; padding: 10px 8px; }
.drawer { overflow: hidden; }
.drawer-head { flex: 0 0 auto; }
.navlist a { min-height: 40px; padding: 8px 10px; font-size: .88rem; gap: 10px; }
.navlist svg { width: 20px; height: 20px; }
.nav-sub { padding: 6px 10px 2px; }
@media (min-width: 900px) {
  .sidenav { width: 232px; padding: 8px; overflow: hidden; top: calc(var(--top-h) + env(safe-area-inset-top)); }
  main { margin-left: 232px; padding: 20px; }
  #layout.nav-collapsed .sidenav { padding: 8px; }
  #layout.nav-collapsed .navlist a { padding: 8px 6px; }
  #layout.nav-collapsed .credit.side { padding: 10px 0; }
}
@media (max-height: 720px) {
  .login-wrap { justify-content: flex-start; }
  .auth-box { padding: 14px 20px; }
  .login-brand { margin-bottom: 8px; }
  .login-logo { width: 40px; height: 40px; }
}
@media (max-width: 380px) { .auth-box { padding: 14px; } }
.about-dialog { width: min(580px, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: 0; border: 1px solid var(--border); border-radius: 16px; color: var(--text); background: var(--surface); overflow-y: auto; box-shadow: 0 20px 60px #071d4233; }
.about-dialog::backdrop { background: #071d4277; backdrop-filter: blur(3px); }
.about-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.about-heading h2 { margin: 0; color: var(--primary); }
.about-close { flex: none; width: 44px; height: 44px; font: inherit; font-size: 1.8rem; color: var(--muted); background: transparent; border: 0; border-radius: 8px; cursor: pointer; }
.about-close:hover, .about-close:focus-visible { background: var(--accent-soft); outline-color: var(--accent); }
.about-body { text-align: center; padding: 24px 20px; background: linear-gradient(135deg, #fff, #e7f8fb); overflow-wrap: anywhere; }
.about-logo { display: block; width: 112px; height: 112px; object-fit: contain; margin: 0 auto 16px; }
.about-body h3 { color: var(--primary); font-size: 1.5rem; }
.about-version { font-weight: 600; color: var(--accent-ink); }

.login-help { font-size: .78rem; margin-top: 8px; color: var(--muted); }
.login-help summary { cursor: pointer; padding: 6px 0; min-height: 32px; color: var(--accent-ink); }
.login-help summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-height: 720px) and (min-width: 381px) {
  .login-brand { display: grid; grid-template-columns: 40px 1fr; column-gap: 10px; text-align: left; align-items: center; }
  .login-brand .login-logo { grid-row: 1 / 3; margin: 0; }
  .login-brand h1 { font-size: 1.15rem; }
  .login-brand p { font-size: .75rem; }
}

/* UI-02: readable, compact page components and consistent pale blue header. */
:root { --header-bg: #F0F9FF; }
.topbar { background: linear-gradient(180deg, #F8FCFF 0%, #EAF6FF 100%); }
.credit.side { font-size: .72rem; line-height: 1.4; gap: 7px; }
.credit.side .credit-logo { width: 24px; height: 24px; }
.credit.side .credit-text { gap: 2px; overflow-wrap: normal; word-break: normal; }
.credit-caption { font-size: .7rem; }
.credit-name { font-size: .74rem; font-weight: 500; }
.credit.side .credit-version { font-size: .72rem; }
main { min-width: 0; font-size: .9rem; }
main h1 { font-size: 1.25rem; line-height: 1.4; }
main h2 { font-size: 1.05rem; line-height: 1.45; }
main h3, main .section-h { font-size: 1rem; line-height: 1.45; }
main label { font-size: .84rem; }
main .btn { font-size: .88rem; padding: 8px 12px; }
main .btn.small { font-size: .82rem; padding: 6px 10px; }
main .btn svg { width: 18px; height: 18px; flex: none; }
main .tabs a, main .tabs button { font-size: .84rem; padding: 8px 12px; }
main table { font-size: .84rem; }
main th, main td { padding: 8px; }
main .section-title { flex-wrap: wrap; align-items: center; }
main .section-title h1 { min-width: 0; margin-bottom: 0; }
main .section-title > .row { min-width: 0; }
main .kpis { grid-template-columns: repeat(auto-fit, minmax(min(132px, 100%), 1fr)); gap: 10px; }
main .kpi { min-width: 0; padding: 10px; }
main .kpi .v { font-size: clamp(1.2rem, 1.6vw, 1.5rem); overflow-wrap: anywhere; }
main .kpi .l { font-size: .78rem; line-height: 1.5; }
main .list-item, main .card, main .row > *, .modal .row > * { min-width: 0; }
main .list-item .t, main .list-item .s, main td { overflow-wrap: anywhere; }
main input, main select, main textarea { min-width: 0; }
@media (min-width: 900px) {
  main input, main select, main textarea { font-size: .9rem; padding: 8px 10px; }
  main .filters { grid-template-columns: repeat(auto-fit, minmax(min(164px, 100%), 1fr)); }
}
@media (max-width: 480px) {
  main { padding-left: 12px; padding-right: 12px; }
  .topbar { padding-left: 8px; padding-right: 8px; gap: 6px; }
  .topbar .brand { font-size: .95rem; }
  .topbar .who { font-size: .72rem; max-width: 28vw; }
  .topbar-logo { width: 28px; height: 28px; }
  .topbar .brand-full { display: none; }
  .topbar .brand-short { display: inline; }
  .section-title > .row { flex-wrap: wrap; }
}

.cart-icon { display: inline-flex; }
.cart-icon svg { width: 22px; height: 22px; display: block; }
/* v2.2.0 — action quantities and executive summary */
.quick-actions { display: flex; flex-direction: column; gap: 8px; padding: 10px; }
.quick-action-row { display: grid; grid-template-columns: auto 120px 1fr; gap: 6px; align-items: center; min-width: 0; }
.quick-unit { font-size: .72rem; color: var(--muted); }
.quantity-control { display: flex; min-width: 0; align-items: stretch; }
.quantity-control input { width: 48px; min-width: 0; padding: 6px 2px; text-align: center; border-radius: 0; appearance: textfield; }
.quantity-control input::-webkit-inner-spin-button { appearance: none; }
.quantity-step { font: inherit; font-weight: 600; width: 36px; min-height: 44px; padding: 0; color: var(--primary); border: 1px solid var(--border); background: var(--surface-2); cursor: pointer; }
.quantity-step:first-child { border-radius: 8px 0 0 8px; }
.quantity-step:last-child { border-radius: 0 8px 8px 0; }
.quantity-step:disabled, .quantity-control input:disabled { opacity: .45; cursor: not-allowed; }
.quick-actions .btn { white-space: normal; line-height: 1.4; min-height: 44px; }
.quick-mode-hint { font-size: .7rem; line-height: 1.4; }
.mat-grid .quick-action-row { grid-template-columns: 110px minmax(0,1fr); }
.mat-grid .quick-unit { grid-column: 1/-1; }
.mat-grid .quantity-control input { width: 42px; }
.mat-grid .quantity-step { width: 34px; }
.mat-grid .img-box { aspect-ratio: 16/10; }
.mat-grid .img-box img { object-fit: contain; background: #fff; }
@media (min-width: 900px) { .mat-grid { grid-template-columns: repeat(auto-fill,minmax(250px,1fr)); } }
.table-wrap .quick-actions { min-width: 310px; }
.summary-metrics { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; margin-bottom: 14px; }
.summary-metric { display: flex; flex-direction: column; border: 1px solid var(--border); border-top: 3px solid var(--accent); padding: 12px; border-radius: 10px; background: white; }
.summary-metric span, .summary-metric small { color: var(--muted); font-size: .76rem; }
.summary-metric strong { font-size: 1.55rem; color: var(--primary); }
.summary-unit-picker { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.summary-unit-picker select { width: auto; min-width: 110px; margin-left: 8px; }
.summary-chart-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; margin-bottom: 14px; }
.summary-chart-card { background: white; border: 1px solid var(--border); border-radius: 10px; padding: 16px; min-width: 0; }
.chart-caption { font-size: .75rem; color: var(--muted); margin: 4px 0 12px; }
.summary-bar-row { display: grid; grid-template-columns: 135px minmax(50px,1fr) auto; gap: 8px; align-items: center; margin: 14px 0; font-size: .8rem; }
.summary-track { height: 12px; background: var(--surface-2); overflow: hidden; border-radius: 6px; }
.summary-fill { display: block; height: 100%; min-width: 0; border-radius: inherit; background: var(--accent); }
.summary-fill.received, .trend-bar.received { background: #12AEC1; }
.summary-fill.withdrawn, .trend-bar.withdrawn { background: #176B9B; }
.summary-fill.balance { background: #11795A; }
.requester-share { margin-bottom: 10px; font-size: .78rem; }
.requester-share .row { margin-bottom: 4px; }
.health-stack { display: flex; height: 24px; border-radius: 8px; overflow: hidden; background: var(--surface-2); margin-bottom: 12px; }
.health-part.normal { background: #11795A; }
.health-part.low { background: #DEA024; }
.health-part.out { background: #C0352B; }
.health-label::before { content: ''; display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; }
.health-label.normal::before { background: #11795A; }.health-label.low::before { background: #DEA024; }.health-label.out::before { background: #C0352B; }
.trend-bars { display: flex; height: 150px; gap: 8px; margin-top: 12px; }
.trend-group { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.trend-group small { font-size: .6rem; white-space: nowrap; margin-top: 6px; }
.trend-pair { display: flex; height: 120px; width: 100%; align-items: flex-end; justify-content: center; gap: 2px; border-bottom: 1px solid var(--border); }
.trend-bar { width: 38%; max-width: 20px; border-radius: 3px 3px 0 0; }
.chart-legend { display: flex; gap: 16px; justify-content: center; font-size: .75rem; margin-top: 10px; }
.chart-legend .received { color: #087C8D; }.chart-legend .withdrawn { color: #176B9B; }
.summary-notes { margin-bottom: 20px; font-size: .78rem; color: var(--muted); }
.summary-notes summary { cursor: pointer; padding: 8px 0; }
.stock-print-root { display: none; }
@media (max-width: 640px) { .summary-metrics { grid-template-columns: repeat(2,minmax(0,1fr)); } .summary-chart-grid { grid-template-columns: 1fr; } .quick-action-row { grid-template-columns: 110px 1fr; } .quick-unit { grid-column:1/-1; } .summary-bar-row { grid-template-columns: 110px minmax(40px,1fr) auto; } }
@page { size: A4 landscape; margin: 8mm; }
@media print {
  body > *:not(#stock-print-root) { display: none !important; }
  body { background: white; margin: 0; }
}
  #stock-print-root { width: 281mm; color: #102A43; font: 8pt/1.28 'Prompt',Tahoma,sans-serif; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  #stock-print-root * { box-shadow: none; }
  #stock-print-root h1 { font-size: 16pt; margin: 0 0 2mm; }
  #stock-print-root h2 { font-size: 9pt; margin: 2mm 0 1mm; }
  #stock-print-root p { margin: 1mm 0; }
  #stock-print-root .print-summary-head { display:flex; align-items:center; gap:3mm; border-bottom:1px solid #DCE8F2; padding-bottom:2mm; }
  #stock-print-root .print-summary-head small { margin-left:auto; max-width:42mm; }
  #stock-print-root .print-summary-head p { max-width:190mm; overflow-wrap:anywhere; }
  #stock-print-root .summary-metrics { gap:2mm; margin:2mm 0; }
  #stock-print-root .summary-metric { padding:2mm; border-radius:2mm; }
  #stock-print-root .summary-metric strong { font-size:14pt; }
  #stock-print-root .summary-metric span, #stock-print-root .summary-metric small { font-size:7pt; }
  #stock-print-root table { font-size:7pt; table-layout:fixed; width:100%; }
  #stock-print-root th, #stock-print-root td { padding:1mm; white-space:normal; overflow-wrap:anywhere; }
  #stock-print-root .table-wrap { overflow:visible; border-radius:1mm; }
  #stock-print-root .print-two { display:grid; grid-template-columns: 2fr 1fr; gap:3mm; }
  #stock-print-root footer { font-size:6.5pt; border-top:1px solid #DCE8F2; margin-top:2mm; padding-top:1mm; }
  #stock-print-root section, #stock-print-root tr { break-inside:avoid; }
@media print { #stock-print-root { display:block; } }

.material-table table { min-width: 1350px; }
.material-table th:nth-child(2), .material-table td:nth-child(2) { min-width: 90px; white-space: nowrap; }
.material-table th:nth-child(3), .material-table td:nth-child(3) { min-width: 210px; }
.material-table .thumb-sm { min-width: 44px; }
.summary-metric strong { overflow-wrap: anywhere; }
.mat-grid:not(.pick) { grid-template-columns: repeat(auto-fill,minmax(min(100%,250px),1fr)); }
.public-info-links { display:flex; justify-content:center; flex-wrap:wrap; gap:4px 14px; font-size:11px; line-height:1.5; margin-top:12px; }
.public-info-links a { color:var(--muted); text-underline-offset:3px; }
#stock-print-root .health-stack { height: 6mm; margin: 2mm 0; }
