/* AMS Office Stock — ธีมเดียวกับ AMS: กรมท่า #12304A · ฟ้าอมเขียว #00A6A6 · พื้นหลัง #F7FAFC · พื้นผิวรอง #EAF3F6
   หัวเว็บสีกรมท่า, เมนู/สถานะเลือกใช้ฟ้าอมเขียว, ปุ่มหลักกรมท่า, การ์ดขาวขอบฟ้าอ่อน */
:root {
  --navy: #12304A; --navy-2: #1B4466; --teal: #00A6A6; --teal-ink: #007A7A; --teal-soft: #D9F2F2;
  --bg: #F7FAFC; --surface: #FFFFFF; --surface-2: #EAF3F6; --text: #12304A; --muted: #587085; --border: #D3E2EA;
  --primary: #12304A; --primary-strong: #0C2236; --primary-soft: #EAF3F6; --on-primary: #FFFFFF;
  --accent: #00A6A6; --accent-ink: #007A7A; --accent-soft: #D9F2F2; --on-accent: #FFFFFF;
  --header-bg: #12304A; --header-fg: #FFFFFF; --header-muted: #B9D3E3;
  --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(18,48,74,.06), 0 4px 14px rgba(18,48,74,.06);
  --nav-h: 64px; --top-h: 56px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B1622; --surface: #12222F; --surface-2: #19303F; --text: #E4EEF5; --muted: #9CB3C4; --border: #26404F;
    --primary: #00A6A6; --primary-strong: #33BFBF; --primary-soft: #19303F; --on-primary: #06151F;
    --accent: #00A6A6; --accent-ink: #4FD1D1; --accent-soft: #123B42; --on-accent: #06151F;
    --header-bg: #0E2236; --header-fg: #FFFFFF; --header-muted: #9CB3C4;
    --danger: #FF8A7F; --danger-soft: #3B1714; --warn: #F2B84B; --warn-soft: #3A2A0C; --ok: #6FD3A8; --ok-soft: #123024; --info-soft: #14263F; --info: #8FB8F2;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0B1622; --surface: #12222F; --surface-2: #19303F; --text: #E4EEF5; --muted: #9CB3C4; --border: #26404F;
  --primary: #00A6A6; --primary-strong: #33BFBF; --primary-soft: #19303F; --on-primary: #06151F;
  --accent: #00A6A6; --accent-ink: #4FD1D1; --accent-soft: #123B42; --on-accent: #06151F;
  --header-bg: #0E2236; --header-fg: #FFFFFF; --header-muted: #9CB3C4;
  --danger: #FF8A7F; --danger-soft: #3B1714; --warn: #F2B84B; --warn-soft: #3A2A0C; --ok: #6FD3A8; --ok-soft: #123024; --info-soft: #14263F; --info: #8FB8F2;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", "Noto Sans Thai", "Sarabun", "Leelawadee UI", Tahoma, sans-serif; }
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 + ฟ้าอมเขียว #00A6A6 ===== */
.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); } }
