/* =========================================================
   PrimePrint by Double P — Design System v2
   แบรนด์: ฟ้า (โลโก้) + CMYK accent · มินิมอล อ่านง่าย ใช้ง่ายบนมือถือ
   ========================================================= */
:root {
  /* แบรนด์ */
  --sky-50: #F0F9FF;
  --sky-100: #E0F2FE;
  --sky-200: #BAE6FD;
  --sky-500: #0EA5E9;
  --sky-600: #0284C7;
  --sky-700: #0369A1;
  --magenta: #E4007F;
  --magenta-50: #FDF2F8;
  --magenta-100: #FCE7F3;
  --yellow: #FFE600;
  --yellow-50: #FEFCE8;
  --yellow-100: #FEF9C3;
  --brand-gradient: linear-gradient(90deg, #FFE600 0%, #E4007F 38%, #7C3AED 68%, #0EA5E9 100%);

  /* ความหมาย */
  --primary: var(--sky-600);
  --primary-hover: var(--sky-700);
  --primary-soft: var(--sky-100);
  --ok: #15803D;
  --ok-50: #F0FDF4;
  --ok-100: #DCFCE7;
  --danger: #DC2626;
  --danger-50: #FEF2F2;
  --danger-100: #FEE2E2;
  --warn: #A16207;

  /* พื้นผิว + ตัวอักษร */
  --bg: #F4F6FA;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --line: #E4E8EF;
  --line-strong: #CBD3DF;
  --ink: #0F172A;
  --ink-2: #334155;
  --muted: #5B6779;
  --nav-bg: #0B1726;
  --nav-ink: #A9B6C8;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 12px 32px -8px rgba(15, 23, 42, .18);
  --ring: 0 0 0 3px rgba(14, 165, 233, .35);
  --ease: cubic-bezier(.2, .7, .3, 1);

  --font: 'IBM Plex Sans Thai', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-head: 'Kanit', 'IBM Plex Sans Thai', system-ui, sans-serif;

  --sidebar-w: 248px;
  --topbar-h: 64px;
  --bottomnav-h: 64px;
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; max-width: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}
img, video, canvas, iframe { max-width: 100%; }
a { color: var(--sky-700); text-decoration: none; transition: color .15s; }
a:hover { color: var(--primary-hover); text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--font-head); font-weight: 500; line-height: 1.3; margin: 0 0 .6em; color: var(--ink); text-wrap: balance; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.08rem; }
h3 { font-size: .98rem; }
p { text-wrap: pretty; }
small, .muted { color: var(--muted); }
small { font-size: .82rem; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .88em; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }
.i { width: 20px; height: 20px; flex: none; }
.i.sm { width: 16px; height: 16px; }
.i.lg { width: 24px; height: 24px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ===== App shell ===== */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--nav-bg); color: var(--nav-ink);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 30;
}
.sidebar::before { content: ''; height: 4px; background: var(--brand-gradient); flex: none; }
.brand { display: flex; align-items: center; gap: 12px; padding: 18px 20px; color: #fff; }
.brand:hover { text-decoration: none; color: #fff; }
.brand img { width: 42px; height: 42px; object-fit: contain; background: #fff; border-radius: 10px; padding: 3px; }
.brand b { display: block; font-family: var(--font-head); font-weight: 500; font-size: 1.1rem; letter-spacing: .2px; line-height: 1.2; }
.brand small { display: block; color: var(--nav-ink); font-size: .75rem; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--sky-500), var(--sky-700)); color: #fff;
  font-family: var(--font-head); font-weight: 600; font-size: 1.05rem; letter-spacing: -.5px;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.12);
}
.sidebar nav { flex: 1; padding: 8px 12px; overflow-y: auto; }
.nav-label { font-size: .7rem; text-transform: uppercase; letter-spacing: 1px; color: #6B7A90; padding: 14px 12px 6px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; min-height: 44px;
  color: var(--nav-ink); font-weight: 500; margin-bottom: 2px; transition: background .15s, color .15s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: rgba(14,165,233,.16); color: #fff; box-shadow: inset 3px 0 0 var(--sky-500); }
.sidebar nav a.active .i { color: var(--sky-500); }
.me { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); display: flex; align-items: center; gap: 10px; }
.me .avatar { background: rgba(255,255,255,.1); color: #fff; }
.me .who { flex: 1; min-width: 0; }
.me .who b { display: block; color: #fff; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me .who small { color: var(--nav-ink); font-size: .75rem; }
.me a.icon-btn { color: var(--nav-ink); }
.me a.icon-btn:hover { color: #fff; background: rgba(255,255,255,.08); }

.avatar {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--sky-100); color: var(--sky-700); font-weight: 600; font-family: var(--font-head);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); display: flex; align-items: center; gap: 16px; padding: 0 28px;
  background: rgba(255,255,255,.88); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar .menu-btn { display: none; }
.page-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.page-title h1 { margin: 0; font-size: 1.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-title .back { color: var(--muted); display: grid; place-items: center; }
.top-search { position: relative; width: 300px; }
.top-search .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; pointer-events: none; }
.top-search input[type=search] { padding-left: 38px; background: var(--surface-2); border-color: transparent; height: 40px; }
.top-search input[type=search]:focus { background: #fff; }
.top-actions { display: flex; gap: 8px; align-items: center; }

.content { padding: 28px; max-width: 1320px; width: 100%; margin: 0 auto; }

/* แถบเมนูล่าง (มือถือ) */
.bottom-nav { display: none; }
.backdrop { display: none; }

@media (max-width: 960px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-102%); transition: transform .25s var(--ease); box-shadow: var(--shadow-lg); z-index: 50; }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(11,23,38,.45); z-index: 40; }
  .topbar { padding: 0 12px 0 8px; gap: 8px; height: 58px; }
  .topbar .menu-btn { display: grid; }
  .top-search, .top-actions .hide-m { display: none; }
  .content { padding: 16px 16px calc(var(--bottomnav-h) + 24px); }

  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(15,23,42,.06);
  }
  .bottom-nav a, .bottom-nav button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    font: inherit; font-size: .7rem; color: var(--muted); background: none; border: 0; cursor: pointer; min-height: 44px;
  }
  .bottom-nav a:hover { text-decoration: none; }
  .bottom-nav .active { color: var(--primary); font-weight: 600; }
  .bottom-nav .fab span {
    width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; margin-top: -22px;
    background: linear-gradient(135deg, var(--sky-500), var(--sky-700)); color: #fff;
    box-shadow: 0 8px 18px -4px rgba(2,132,199,.55), 0 0 0 4px #fff;
  }
  .bottom-nav .fab { color: var(--primary); font-weight: 600; }
}

/* ===== Page head (ภายในเนื้อหา) ===== */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { font-size: 1.4rem; margin: 0; }
.page-head p { margin: 2px 0 0; color: var(--muted); }

/* ===== Cards ===== */
.card {
  background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm); padding: 20px 22px; margin-bottom: 20px; min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; display: flex; align-items: center; gap: 8px; }
.card-head h2 .i { color: var(--primary); }
.card-head .sub { color: var(--muted); font-size: .85rem; font-weight: 400; font-family: var(--font); }
.card-head a { font-size: .88rem; display: inline-flex; align-items: center; gap: 2px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-head { padding: 18px 22px 0; }
.card.brand-border { position: relative; overflow: hidden; }
.card.brand-border::before { content: ''; position: absolute; inset: 0 0 auto; height: 4px; background: var(--brand-gradient); }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .i { width: 40px; height: 40px; color: var(--line-strong); margin-bottom: 8px; }
.empty h2 { color: var(--ink); }

.section-title { display: flex; align-items: center; gap: 10px; margin: 0 0 16px; }
.section-title .num {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--sky-100); color: var(--sky-700); font-weight: 600; font-size: .85rem;
}
.section-title h2 { margin: 0; }

/* ===== Grid ===== */
.grid { display: grid; gap: 20px; }
.grid > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.dash-grid { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) minmax(0, 1fr); }
@media (max-width: 1280px) { .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .dash-grid { grid-template-columns: 1fr; } }
.layout-side { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.layout-side > * { min-width: 0; }
.sticky-side { position: sticky; top: calc(var(--topbar-h) + 20px); }
@media (max-width: 1180px) { .layout-side { grid-template-columns: 1fr; } .sticky-side { position: static; } .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } .grid { gap: 14px; } }

/* ===== Stat tiles ===== */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px 14px 18px; display: block; color: inherit; transition: border-color .15s, box-shadow .15s, transform .15s;
  overflow: hidden;
}
.stat::before { content: ''; position: absolute; left: 0; top: 12px; bottom: 12px; width: 4px; border-radius: 0 4px 4px 0; background: var(--c, var(--primary)); }
.stat small { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: .82rem; line-height: 1.35; }
.stat b { font-family: var(--font-head); font-weight: 500; font-size: 1.75rem; display: block; line-height: 1.2; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .unit { font-size: .85rem; color: var(--muted); font-family: var(--font); font-weight: 400; }
a.stat:hover { text-decoration: none; border-color: var(--c, var(--primary)); box-shadow: var(--shadow); color: inherit; }
.stat.zero b { color: var(--line-strong); }
.stat.big { padding: 20px 22px; }
.stat.big b { font-size: 2rem; }
.stat .ico { position: absolute; right: 14px; top: 14px; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, var(--c, var(--primary)) 12%, #fff); color: var(--c, var(--primary)); }
@media (max-width: 720px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .stat b { font-size: 1.5rem; } }

/* ===== Greeting hero ===== */
.hello {
  position: relative; overflow: hidden; border-radius: var(--radius-lg); padding: 22px 24px; margin-bottom: 24px; color: #fff;
  background: radial-gradient(120% 140% at 100% 0%, rgba(228,0,127,.35) 0%, transparent 45%), linear-gradient(120deg, var(--sky-600) 0%, #0B4F7C 100%);
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.hello::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: var(--brand-gradient); }
.hello h2 { color: #fff; font-size: 1.35rem; margin: 0 0 2px; }
.hello p { margin: 0; color: rgba(255,255,255,.85); }
.hello .btn { background: #fff; color: var(--sky-700); }
.hello .btn:hover { background: var(--sky-50); color: var(--sky-700); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 8px 18px; border-radius: 10px; border: 1px solid transparent; cursor: pointer;
  font: inherit; font-weight: 600; font-size: .95rem; line-height: 1.2; background: var(--primary); color: #fff; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, color .15s; text-decoration: none;
}
.btn:hover { background: var(--primary-hover); color: #fff; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn .i { width: 18px; height: 18px; }
.btn.ghost { background: var(--surface); color: var(--ink-2); border-color: var(--line-strong); }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--muted); color: var(--ink); }
.btn.soft { background: var(--sky-100); color: var(--sky-700); }
.btn.soft:hover { background: var(--sky-200); }
.btn.pink { background: var(--magenta); }
.btn.pink:hover { background: #BE006A; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #B91C1C; }
.btn.danger-ghost { background: var(--surface); color: var(--danger); border-color: #FCA5A5; }
.btn.danger-ghost:hover { background: var(--danger-50); }
.btn.ok { background: var(--ok); }
.btn.ok:hover { background: #166534; }
.btn.sm { min-height: 34px; padding: 5px 12px; font-size: .85rem; border-radius: 8px; gap: 6px; }
.btn.sm .i { width: 16px; height: 16px; }
.btn.lg { min-height: 50px; padding: 12px 22px; font-size: 1.02rem; border-radius: 12px; }
.btn.block { width: 100%; }
.btn[disabled], .btn.loading { opacity: .6; pointer-events: none; }
.btn.loading::after { content: ''; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; border: 0; background: none;
  color: var(--ink-2); cursor: pointer; flex: none; transition: background .15s;
}
.icon-btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-row.end { justify-content: flex-end; }
form.inline { display: inline; }

/* ===== Badges / Tags ===== */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 999px; font-size: .8rem; font-weight: 600;
  color: color-mix(in srgb, var(--c) 78%, #000); background: color-mix(in srgb, var(--c) 13%, #fff); white-space: nowrap; line-height: 1.4;
}
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; }
.badge.lg { font-size: .92rem; padding: 5px 14px 5px 12px; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 6px; font-size: .76rem; background: #EEF2F7; color: var(--ink-2); font-weight: 600; white-space: nowrap; line-height: 1.6; }
.tag.low { background: var(--magenta-100); color: #A3005B; }
.tag.ok { background: var(--ok-100); color: var(--ok); }
.tag.warn { background: var(--yellow-100); color: #854D0E; }
.tag.sky { background: var(--sky-100); color: var(--sky-700); }

/* ===== Alerts / Toasts ===== */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; background: var(--ok-50); color: #14532D; border: 1px solid #BBF7D0; }
.alert .i { margin-top: 2px; }
.alert.err { background: var(--danger-50); color: #7F1D1D; border-color: #FECACA; }
.alert.warn { background: var(--yellow-50); color: #713F12; border-color: #FDE68A; }
.alert.info { background: var(--sky-50); color: #075985; border-color: var(--sky-200); }
.toasts { position: fixed; top: 16px; right: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100% - 32px)); }
.toast {
  display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--ink); color: #fff;
  box-shadow: var(--shadow-lg); font-weight: 500; animation: toast-in .25s var(--ease);
}
.toast .i { color: #4ADE80; }
.toast.err .i { color: #F87171; }
.toast.hide { opacity: 0; transform: translateY(-8px); transition: .3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
@media (max-width: 960px) { .toasts { top: auto; bottom: calc(var(--bottomnav-h) + 16px); left: 16px; right: 16px; max-width: none; } }

/* ===== Forms ===== */
label { display: block; font-weight: 500; font-size: .88rem; margin-bottom: 6px; color: var(--ink-2); }
label .req { color: var(--magenta); }
.field { margin-bottom: 16px; min-width: 0; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=email], input[type=tel],
input[type=search], input[type=month], input[type=datetime-local], input[type=url], select, textarea {
  width: 100%; min-width: 0; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 10px;
  font: inherit; font-size: 16px; background: #fff; color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
@media (min-width: 961px) { input, select, textarea { font-size: .95rem !important; } }
input::placeholder, textarea::placeholder { color: #94A3B8; }
input:hover, select:hover, textarea:hover { border-color: #94A3B8; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--sky-500); box-shadow: var(--ring); }
select { appearance: none; padding-right: 36px; cursor: pointer;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%235B6779' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center; }
textarea { min-height: 84px; resize: vertical; line-height: 1.6; }
input[type=color] { width: 44px; height: 38px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; cursor: pointer; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; flex: none; margin: 0; }
input[type=file] { font: inherit; max-width: 100%; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 400; color: var(--ink); cursor: pointer; min-height: 32px; margin: 0; }
.form-row { display: grid; gap: 0 14px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.form-row > * { min-width: 0; }

summary { list-style: none; cursor: pointer; }
summary::-webkit-details-marker { display: none; }
details[open] > summary { background: var(--sky-50); border-color: var(--sky-200); color: var(--sky-700); }

/* ตัวเลือกแบบการ์ด (radio) */
.choice-group { display: grid; gap: 8px; }
.choice {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px;
  cursor: pointer; font-weight: 500; margin: 0; transition: border-color .15s, background .15s;
}
.choice:hover { border-color: var(--sky-500); }
.choice:has(input:checked) { border-color: var(--sky-500); background: var(--sky-50); box-shadow: inset 0 0 0 1px var(--sky-500); }
.choice small { display: block; font-weight: 400; }
.chip-check { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: 999px; cursor: pointer; font-weight: 500; font-size: .88rem; margin: 0; min-height: 36px; }
.chip-check:has(input:checked) { border-color: var(--sky-500); background: var(--sky-50); color: var(--sky-700); }
.chip-check input { width: 16px; height: 16px; }

/* Filter bar + tabs */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters > * { width: auto; }
.filters .grow { flex: 1; min-width: 200px; position: relative; }
.filters .grow .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; pointer-events: none; }
.filters .grow input[type=search] { padding-left: 38px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tab {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px; min-height: 38px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); font-weight: 500; font-size: .9rem; white-space: nowrap;
  transition: border-color .15s, background .15s;
}
.tab:hover { border-color: var(--line-strong); text-decoration: none; color: var(--ink); }
.tab .count { background: #EEF2F7; color: var(--muted); border-radius: 999px; padding: 0 8px; font-size: .78rem; font-weight: 600; min-width: 24px; text-align: center; }
.tab .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--primary)); }
.tab.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.tab.active .count { background: rgba(255,255,255,.18); color: #fff; }
.seg { display: inline-flex; background: #EAEEF4; border-radius: 10px; padding: 3px; gap: 2px; }
.seg a { padding: 6px 14px; border-radius: 8px; color: var(--ink-2); font-weight: 500; font-size: .9rem; min-height: 34px; display: inline-flex; align-items: center; }
.seg a:hover { text-decoration: none; color: var(--ink); }
.seg a.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; margin: 0 -22px; padding: 0 22px; }
.card.flush .table-wrap { margin: 0; padding: 0; }
.card.flush th:first-child, .card.flush td:first-child { padding-left: 22px; }
.card.flush th:last-child, .card.flush td:last-child { padding-right: 22px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 12px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .78rem; font-weight: 600; color: var(--muted); white-space: nowrap; background: var(--surface-2); letter-spacing: .2px; }
tr:last-child td { border-bottom: 0; }
tbody tr, table tr { transition: background .1s; }
tr:hover td { background: #FAFCFE; }
td.r, th.r { text-align: right; }
td.c, th.c { text-align: center; }
tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--line); }
.nowrap { white-space: nowrap; }
.items-table input, .items-table select { min-height: 38px; padding: 6px 10px; }
.items-table td { padding: 8px 6px; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ===== Ticket list (การ์ดบนมือถือ / แถวบนจอใหญ่) ===== */
.tlist { list-style: none; margin: 0; padding: 0; }
.tlist li { border-bottom: 1px solid var(--line); }
.tlist li:last-child { border-bottom: 0; }
.trow {
  display: grid; grid-template-columns: 150px minmax(0, 1.6fr) minmax(0, 1fr) 120px 150px 110px 20px; gap: 14px; align-items: center;
  padding: 14px 22px; color: inherit; transition: background .12s;
}
.trow:hover { background: #F7FAFD; text-decoration: none; color: inherit; }
.trow .code { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.trow .code small { display: block; font-weight: 400; }
.trow .cust b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trow .cust small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trow .job { color: var(--ink-2); font-size: .9rem; display: flex; align-items: center; gap: 10px; min-width: 0; }
.trow .job > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.trow .jthumb { width: 44px; height: 44px; flex: none; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); }
.trow .amt { text-align: right; }
.trow .amt b { display: block; font-weight: 600; font-variant-numeric: tabular-nums; }
.trow .due { font-size: .85rem; color: var(--ink-2); white-space: nowrap; }
.trow .chev { color: var(--line-strong); }
.thead { display: grid; grid-template-columns: 150px minmax(0, 1.6fr) minmax(0, 1fr) 120px 150px 110px 20px; gap: 14px; padding: 10px 22px; background: var(--surface-2); border-bottom: 1px solid var(--line); font-size: .78rem; font-weight: 600; color: var(--muted); }
.thead .r { text-align: right; }
@media (max-width: 1100px) {
  .thead { display: none; }
  .trow { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "code status" "cust amt" "job due"; gap: 4px 12px; padding: 14px 16px; }
  .trow .code { grid-area: code; } .trow .st { grid-area: status; justify-self: end; }
  .trow .cust { grid-area: cust; } .trow .amt { grid-area: amt; }
  .trow .job { grid-area: job; } .trow .due { grid-area: due; justify-self: end; }
  .trow .chev { display: none; }
  .trow .code small { display: inline; margin-left: 6px; }
}

/* รายการแบบย่อ (แดชบอร์ด) */
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.mini-list li:last-child { border-bottom: 0; }
.mini-list .grow { flex: 1; min-width: 0; }
.mini-list .grow b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-list .grow small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-list a.row { display: flex; align-items: center; gap: 12px; color: inherit; flex: 1; min-width: 0; }
.mini-list a.row:hover { text-decoration: none; }
.mini-list a.row:hover b { color: var(--primary); }
.ico-box { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--sky-50); color: var(--sky-700); }
.ico-box.pink { background: var(--magenta-50); color: var(--magenta); }
.ico-box.yellow { background: var(--yellow-100); color: #854D0E; }
.ico-box.green { background: var(--ok-100); color: var(--ok); }

/* ===== Key-value / summary ===== */
.kv { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 10px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: .88rem; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 520px) { .kv { grid-template-columns: 1fr; gap: 0; } .kv dt { margin-top: 10px; } .kv dt:first-child { margin-top: 0; } }
.sum-box { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 16px; font-variant-numeric: tabular-nums; }
.sum-box > span:nth-child(even) { text-align: right; white-space: nowrap; }
.sum-box .grand { font-family: var(--font-head); font-size: 1.25rem; font-weight: 500; color: var(--ink); padding-top: 10px; border-top: 1px dashed var(--line-strong); }
.sum-box .bal { font-weight: 600; color: var(--magenta); }
.sum-box .paid { color: var(--ok); }

.money-hero { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.money-hero > div { background: var(--surface-2); padding: 12px 14px; }
.money-hero small { display: block; font-size: .78rem; }
.money-hero b { font-family: var(--font-head); font-weight: 500; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.money-hero .bal b { color: var(--magenta); }
.money-hero .done b { color: var(--ok); }

/* คิวช่างพิมพ์ */
.queue { display: grid; gap: 14px; }
.q-card { display: grid; grid-template-columns: 120px minmax(0, 1fr) 220px; gap: 18px; align-items: start; margin: 0; }
.q-thumb { aspect-ratio: 1; border-radius: 12px; background: var(--surface-2) center/cover no-repeat; border: 1px solid var(--line); display: grid; place-items: center; color: var(--muted); }
.q-top { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.q-body h3 { margin: 6px 0 2px; font-size: 1.1rem; }
.q-spec { margin: 0 0 6px; color: var(--ink-2); }
.q-files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.q-files .tag { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.q-file { display: inline-flex; gap: 2px; max-width: 100%; min-width: 0; }
.q-act { align-self: center; }
@media (max-width: 900px) { .q-card { grid-template-columns: 84px minmax(0, 1fr); } .q-act { grid-column: 1 / -1; } }

/* ยืนยันแบบ / ยืนยันการชำระ */
.confirm-step { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.confirm-step:last-child { border-bottom: 0; padding-bottom: 0; }
.confirm-step:first-of-type { padding-top: 0; }
.confirm-step .grow { flex: 1; min-width: 0; }
.confirm-step .grow b { display: block; font-weight: 600; }
.confirm-step .grow small { display: block; }
.confirm-step.done .grow b { color: var(--ok); }

/* หน้าต่างคีย์งาน */
.pack-view { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 18px; align-items: start; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.pack-thumb { aspect-ratio: 3 / 4; border-radius: 10px; background: #fff center/cover no-repeat; border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); text-align: center; }
.pack-view .kv { grid-template-columns: 90px minmax(0, 1fr); }
@media (max-width: 520px) { .pack-view { grid-template-columns: 1fr; } .pack-thumb { aspect-ratio: 4 / 3; } }
.note-box { background: var(--yellow-50); border: 1px solid #FDE68A; border-radius: 8px; padding: 8px 12px; }

/* ===== Files / Dropzone ===== */
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.file { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; font-size: .8rem; position: relative; transition: box-shadow .15s; }
.file:hover { box-shadow: var(--shadow); }
.file .thumb { aspect-ratio: 1; background: var(--surface-2) center/cover no-repeat; display: grid; place-items: center; color: var(--muted); font-weight: 600; font-size: .9rem; }
.file .name { padding: 6px 8px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--ink-2); }
.file form { position: absolute; top: 6px; right: 6px; opacity: 0; transition: opacity .15s; }
.file:hover form, .file:focus-within form { opacity: 1; }
@media (hover: none) { .file form { opacity: 1; } }
.file .del { width: 30px; height: 30px; border-radius: 8px; border: 0; background: rgba(15,23,42,.7); color: #fff; display: grid; place-items: center; cursor: pointer; }
.file .del .i { width: 16px; height: 16px; }
.dropzone {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center;
  border: 2px dashed var(--line-strong); border-radius: 12px; padding: 18px; background: var(--surface-2); color: var(--muted);
  cursor: pointer; transition: border-color .15s, background .15s; min-height: 110px;
}
.dropzone:hover, .dropzone.drag { border-color: var(--sky-500); background: var(--sky-50); color: var(--sky-700); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone b { color: var(--ink-2); font-weight: 500; }
.dropzone .picked { color: var(--sky-700); font-weight: 600; }

/* ===== ปุ่มเลือกไฟล์ (โลโก้ / สลิป) — ซ่อนปุ่มของเบราว์เซอร์ ใช้ปุ่มของระบบแทน ===== */
.pick-input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
.file-pick { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.file-pick label.btn { position: relative; margin: 0; }
.file-pick label.btn:focus-within { box-shadow: var(--ring); }
.file-pick .btn.toggle:has(input:checked) { border-color: var(--sky-500); background: var(--sky-50); color: var(--sky-700); }
.file-pick-body { display: grid; gap: 4px; min-width: 0; }
.file-pick-name { color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; }
.file-pick-name:empty { display: none; }
.logo-preview { width: 64px; height: 64px; flex: none; border: 1px dashed var(--line-strong); border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; color: var(--muted); }
.logo-preview img { width: 100%; height: 100%; object-fit: contain; padding: 6px; background: #fff; }
.logo-preview img:not([hidden]) + .ph { display: none; }
.file-chip { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-width: 0; padding: 4px 4px 4px 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font-size: .88rem; }
.file-chip img { width: 32px; height: 32px; flex: none; object-fit: cover; border-radius: 6px; }
.file-chip [data-file-name] { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* ===== Timeline ===== */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { padding: 4px 0 14px 22px; position: relative; font-size: .9rem; }
.timeline li::before { content: ''; position: absolute; left: 4px; top: 10px; width: 9px; height: 9px; border-radius: 50%; background: #fff; border: 2px solid var(--sky-500); }
.timeline li::after { content: ''; position: absolute; left: 8px; top: 21px; bottom: -2px; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline li small { display: block; }
.timeline .pay { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }

/* ===== Stepper (ขั้นตอนงาน) ===== */
.stepper { display: flex; list-style: none; margin: 0; padding: 0; counter-reset: s; }
.stepper li { flex: 1; text-align: center; position: relative; font-size: .82rem; color: var(--muted); padding-top: 38px; line-height: 1.35; min-width: 0; }
.stepper li::before {
  counter-increment: s; content: counter(s);
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 30px; height: 30px; border-radius: 50%; background: #fff; border: 2px solid var(--line-strong); z-index: 1;
  display: grid; place-items: center; font-size: .8rem; font-weight: 600; color: var(--muted);
}
.stepper li::after { content: ''; position: absolute; top: 14px; left: calc(-50% + 18px); right: calc(50% + 18px); height: 3px; border-radius: 3px; background: var(--line); }
.stepper li:first-child::after { display: none; }
.stepper li.done { color: var(--ink-2); }
.stepper li.done::before { content: '✓'; background: var(--sky-500); border-color: var(--sky-500); color: #fff; }
.stepper li.done::after, .stepper li.current::after { background: var(--sky-500); }
.stepper li.current { color: var(--magenta); font-weight: 600; }
.stepper li.current::before { background: var(--magenta); border-color: var(--magenta); color: #fff; box-shadow: 0 0 0 5px var(--magenta-100); }
.stepper .at { display: block; font-size: .72rem; color: var(--muted); font-weight: 400; margin-top: 2px; }
@media (max-width: 520px) { .stepper li { font-size: .72rem; padding-top: 34px; } .stepper li::before { width: 26px; height: 26px; } .stepper li::after { top: 12px; left: calc(-50% + 15px); right: calc(50% + 15px); } }

/* ===== Ticket header ===== */
.t-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px 24px; align-items: start; margin-bottom: 22px; }
.t-head h2 { font-size: 1.35rem; margin: 6px 0 4px; }
.t-head .meta { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: .88rem; }
.t-head .meta span { display: inline-flex; align-items: center; gap: 6px; }
.t-head .meta .i { width: 16px; height: 16px; }
.t-head .next { display: flex; flex-direction: column; gap: 8px; align-items: stretch; min-width: 240px; }
.t-head .next small { text-align: center; }
.status-more { display: flex; gap: 6px; }
.status-more select { min-height: 36px; font-size: .88rem !important; }
@media (max-width: 720px) { .t-head { grid-template-columns: 1fr; } .t-head .next { min-width: 0; } }

/* แถบบันทึก (ฟอร์มยาว) */
.savebar {
  position: sticky; bottom: 0; z-index: 15; margin: 8px -28px -28px; padding: 14px 28px;
  background: rgba(255,255,255,.94); backdrop-filter: blur(8px); border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.savebar .total small { display: block; font-size: .78rem; }
.savebar .total b { font-family: var(--font-head); font-weight: 500; font-size: 1.3rem; }
@media (max-width: 960px) { .savebar { bottom: var(--bottomnav-h); margin: 8px -16px 0; padding: 12px 16px; } }

/* ===== Login (เต็มจอ + ภาพลายเส้นโรงพิมพ์ + แอนิเมชัน) ===== */
.login-body { background: #F4F6FA; }
.login-page { min-height: 100vh; min-height: 100dvh; display: flex; }
.login-panel {
  position: relative; flex: 1; overflow: hidden; display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh;
  background: radial-gradient(60% 50% at 50% 42%, #FFFFFF 0%, rgba(255,255,255,0) 70%), #F4F6FA;
}
.login-panel::before { content: ''; position: absolute; inset: 0 0 auto; height: 4px; background: var(--brand-gradient); z-index: 3; }
.login-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 28px clamp(20px, 4vw, 56px); position: relative; z-index: 2; }
.login-top .brand { padding: 0; color: var(--ink); }
.login-top .brand b { font-size: 1.35rem; }
.login-top .brand img { width: 56px; height: 56px; padding: 5px; border-radius: 16px; background: #fff; box-shadow: 0 6px 16px -8px rgba(15,23,42,.25), 0 0 0 1px rgba(15,23,42,.05); }
.login-top .brand small { color: var(--muted); }
.login-top .actions { display: flex; gap: 10px; }
.round-btn {
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid #1F2937; color: #1F2937; background: transparent; transition: background .15s, color .15s, transform .15s;
}
.round-btn:hover { background: #1F2937; color: #fff; text-decoration: none; transform: translateY(-2px); }
.round-btn.dark { background: #1F2937; color: #fff; }
.login-stage { flex: 1; position: relative; display: grid; place-items: center; padding: 8px 24px 90px; }
.login-card {
  position: relative; z-index: 2; width: 100%; max-width: 420px; background: #fff; border-radius: 24px;
  padding: 36px 34px 28px; box-shadow: 0 30px 60px -30px rgba(15,23,42,.25), 0 0 0 1px rgba(15,23,42,.05);
}
.login-card h1 { font-size: 1.85rem; line-height: 1.25; margin: 0 0 8px; font-weight: 500; }
.login-card .lead { color: var(--muted); margin: 0 0 24px; }
.input-icon { position: relative; margin-bottom: 14px; }
.input-icon > .i { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--ink-2); pointer-events: none; }
.input-icon input[type=text], .input-icon input[type=password] {
  min-height: 56px; padding: 12px 48px 12px 50px; border-radius: 14px; background: #F7F8FA; border-color: #E2E6EC; font-size: 16px !important;
}
.input-icon input:focus { background: #fff; }
.input-icon .peek { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border: 0; background: none; border-radius: 10px; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.input-icon .peek:hover, .input-icon .peek.on { color: var(--ink); background: #EEF1F5; }
.login-card .btn.lg { min-height: 56px; border-radius: 14px; font-size: 1.05rem; margin-top: 6px; }
.login-help { text-align: center; margin: 18px 0 0; font-size: .85rem; color: var(--muted); }
.login-help a { color: var(--ink); font-weight: 600; }
.login-art { position: absolute; bottom: 70px; z-index: 1; pointer-events: none; width: clamp(280px, 31vw, 560px); height: auto; overflow: visible; }
.login-art.left { left: clamp(8px, 3vw, 60px); }
.login-art.right { right: clamp(8px, 3vw, 60px); }
.login-foot { position: absolute; left: 0; right: 0; bottom: 24px; text-align: center; font-size: .78rem; color: var(--muted); z-index: 2; }
.bg-dots { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.bg-dots span { position: absolute; left: var(--x); top: var(--y); width: var(--s); height: var(--s); border-radius: 50%; background: var(--c); opacity: .55; }
@media (max-width: 1100px) { .login-art { width: 27vw; } }
@media (max-width: 900px) {
  .login-top { padding: 20px; }
  .login-top .actions .round-btn:not(.keep) { display: none; }
  .login-stage { display: flex; flex-direction: column; align-items: center; padding: 8px 16px 60px; }
  .login-art.left { display: none; }
  .login-art.right { position: static; order: 2; width: min(78%, 300px); margin-top: 20px; }
  .login-card { padding: 28px 22px 24px; }
  .bg-dots span:nth-child(n+6) { display: none; }
}

/* แอนิเมชัน (ปิดเองเมื่อผู้ใช้ตั้งค่าลดการเคลื่อนไหว) */
@media (prefers-reduced-motion: no-preference) {
  .login-card { animation: card-in .7s var(--ease) both; }
  .login-art.left { animation: art-in-l .9s var(--ease) .15s both; }
  .login-art.right { animation: art-in-r .9s var(--ease) .25s both; }
  .bg-dots span { animation: drift 9s ease-in-out infinite; animation-delay: var(--d); }
  .login-art g, .login-art path, .login-art circle, .login-art rect { transform-box: fill-box; }
  .a-head { transform-origin: 50% 100%; animation: nod 2.4s ease-in-out infinite; }
  .a-arm { transform-origin: 0% 0%; animation: type .45s ease-in-out infinite alternate; }
  .a-glow { animation: glow 1.6s ease-in-out infinite; }
  .a-eye { transform-origin: center; animation: blink 4s infinite; }
  .a-spark { animation: spark 1.8s ease-in-out infinite; transform-origin: 100% 100%; }
  .a-arrow { animation: grow 3s ease-in-out infinite; transform-origin: 0% 100%; }
  .a-leg { transform-origin: 0% 0%; animation: swing 3.2s ease-in-out infinite; }
  .a-float { animation: bob 3s ease-in-out infinite; }
  .a-float.d2 { animation-delay: -1s; } .a-float.d3 { animation-delay: -2s; }
  .a-cloud { animation: cloud 7s ease-in-out infinite; } .a-cloud.d2 { animation-duration: 9s; animation-delay: -3s; }
  .a-printer { transform-origin: 50% 100%; animation: rumble 2.6s ease-in-out infinite; }
  .a-paper { animation: print 2.6s cubic-bezier(.4, 0, .2, 1) infinite; }
  .a-sheet-in { animation: feed 2.6s ease-in-out infinite; }
  .a-blink { animation: led 1.3s steps(1) infinite; } .a-blink.d2 { animation-delay: -.65s; }
  .a-hop { transform-origin: 50% 100%; animation: hop 2.6s ease-in-out infinite; }
  .a-sway { transform-origin: 50% 100%; animation: sway 3.5s ease-in-out infinite; }
}
@keyframes card-in { from { opacity: 0; transform: translateY(24px) scale(.98); } }
@keyframes art-in-l { from { opacity: 0; transform: translateX(-40px); } }
@keyframes art-in-r { from { opacity: 0; transform: translateX(40px); } }
@keyframes drift { 0%, 100% { transform: translate(0, 0); } 33% { transform: translate(14px, -18px); } 66% { transform: translate(-10px, 10px); } }
@keyframes nod { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(4deg) translateY(1px); } }
@keyframes type { from { transform: rotate(0); } to { transform: rotate(-5deg); } }
@keyframes glow { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes spark { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .25; transform: scale(.85); } }
@keyframes grow { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12) translate(2px, -2px); } }
@keyframes swing { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(2.5deg); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes cloud { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(-18px); } }
@keyframes rumble { 0%, 60%, 100% { transform: translateY(0); } 10%, 30%, 50% { transform: translateY(-1.5px); } 20%, 40% { transform: translateY(.5px); } }
@keyframes print { 0% { transform: translateY(-64px); opacity: 1; } 55% { transform: translateY(0); } 85% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(6px); opacity: 0; } }
@keyframes feed { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(8px); } }
@keyframes led { 0%, 49% { opacity: 1; } 50%, 100% { opacity: .2; } }
@keyframes hop { 0%, 55%, 100% { transform: translateY(0); } 70% { transform: translateY(-12px); } 80% { transform: translateY(0) scaleY(.95); } }
@keyframes sway { 0%, 100% { transform: rotate(-4deg); } 50% { transform: rotate(4deg); } }

/* ===== พิมพ์ ===== */
@media print {
  .sidebar, .topbar, .no-print, .backdrop, .bottom-nav, .toasts, .savebar { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 0; padding: 0; }
}

/* เติมเข้า (เขียว) / เบิกออก (แดง) ตามแบบร่างลูกค้า */
.choice.move-in:has(input:checked) { border-color: var(--ok); background: var(--ok-50); box-shadow: inset 0 0 0 1px var(--ok); color: var(--ok); }
.choice.move-out:has(input:checked) { border-color: var(--danger); background: var(--danger-50); box-shadow: inset 0 0 0 1px var(--danger); color: var(--danger); }
.choice.move-in input { accent-color: var(--ok); }
.choice.move-out input { accent-color: var(--danger); }

.bal-text { color: var(--magenta) !important; font-weight: 500; }

/* ส่วนที่ล็อกได้ (ราคาหลังออกใบกำกับภาษี) */
fieldset.lockable { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.lockable[disabled] .card { background: var(--surface-2); }
fieldset.lockable[disabled] input, fieldset.lockable[disabled] .choice, fieldset.lockable[disabled] button { cursor: not-allowed; }

/* เลือกหลายงาน + แถบเปลี่ยนสถานะ */
.tlist li.has-check { display: flex; align-items: center; padding-left: 16px; }
.tlist li.has-check .trow { flex: 1; min-width: 0; padding-left: 14px; }
.row-check { display: grid; place-items: center; width: 32px; height: 44px; margin: 0; cursor: pointer; flex: none; }
.thead { grid-template-columns: 32px 150px minmax(0, 1.6fr) minmax(0, 1fr) 120px 150px 110px 20px; padding-left: 16px; }
.tlist li.has-check:has(input:checked) { background: var(--sky-50); }
.bulk-bar {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 30; width: max-content; max-width: calc(100% - 32px);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; border-radius: 14px;
  background: var(--ink); color: #fff; box-shadow: var(--shadow-lg);
}
.bulk-bar select { width: auto; min-width: 160px; }
.bulk-bar .btn.ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.3); }
@media (min-width: 961px) { .bulk-bar { margin-left: calc(var(--sidebar-w) / 2); } }
@media (max-width: 960px) { .bulk-bar { bottom: calc(var(--bottomnav-h) + 12px); } }

/* ข้อความส่งลูกค้า / บันทึกทีม / QR */
.msg-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.msg-item details { margin-top: 4px; font-size: .85rem; }
.msg-item summary { padding: 2px 4px; }
.msg-preview { white-space: pre-wrap; word-break: break-word; font: inherit; font-size: .85rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 6px 0 0; }
.notes { list-style: none; margin: 0 0 12px; padding: 0; }
.notes li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.notes li:last-child { border-bottom: 0; }
.notes .grow { flex: 1; min-width: 0; }
.notes p { margin: 2px 0 0; overflow-wrap: anywhere; }
.avatar.sm { width: 30px; height: 30px; font-size: .8rem; }
.qr-box { margin: 4px 0 12px; }
.qr-box svg { max-width: 100%; height: auto; }

/* ===== ปฏิทินภาษาไทย (แทนช่องวันที่ / เดือน / วันเวลา ของเบราว์เซอร์) ===== */
.dp { position: relative; display: block; min-width: 0; }
.filters .dp { min-width: 170px; }
.dp-btn { width: 100%; min-height: 42px; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: #fff; color: var(--ink); font: inherit; font-size: 16px; text-align: left; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
@media (min-width: 961px) { .dp-btn { font-size: .95rem; } }
.dp-btn:hover { border-color: #94A3B8; }
.dp-btn:focus-visible, .dp-btn[aria-expanded=true] { outline: none; border-color: var(--sky-500); box-shadow: var(--ring); }
.dp-btn:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
.dp-btn .i { color: var(--primary); }
.dp-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dp-text.is-empty { color: #94A3B8; }
.dp-text small { color: var(--muted); margin-left: 6px; }
.dp-text small.late { color: var(--danger); }

/* popup ลอย (ปฏิทิน + dropdown) — อยู่ใต้ body จึงไม่โดนกรอบการ์ดตัด */
.pk-pop { position: fixed; z-index: 1000; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden; }
.pk-pop::before { content: ''; position: absolute; inset: 0 0 auto; height: 3px; background: var(--brand-gradient); }
.dp-pop { width: 300px; max-width: calc(100vw - 16px); padding: 12px; }
.dp-quick { display: flex; flex-wrap: wrap; gap: 4px; padding-bottom: 10px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.dp-quick button { flex: 1; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); border-radius: 999px; padding: 4px 8px; font: inherit; font-size: .78rem; white-space: nowrap; cursor: pointer; }
.dp-quick button:hover { border-color: var(--sky-200); background: var(--sky-50); color: var(--sky-700); }
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.dp-head .icon-btn { width: 34px; height: 34px; }
.dp-title { font-family: var(--font-head); font-weight: 500; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.dp-grid.months { grid-template-columns: repeat(3, 1fr); gap: 6px; }
.dp-grid .dow { font-size: .75rem; color: var(--muted); padding: 4px 0; }
.dp-grid .dow.sun { color: var(--danger); }
.dp-grid button { aspect-ratio: 1; border: 0; border-radius: 8px; background: none; color: var(--ink); font: inherit; font-size: .9rem; cursor: pointer; }
.dp-grid.months button { aspect-ratio: auto; padding: 12px 0; }
.dp-grid button:hover { background: var(--sky-50); color: var(--sky-700); }
.dp-grid button.sun { color: var(--danger); }
.dp-grid button.past { color: #A0AEC0; }
.dp-grid button.today { box-shadow: inset 0 0 0 1.5px var(--sky-500); font-weight: 600; }
.dp-grid button.sel { background: var(--primary); color: #fff; font-weight: 600; }
.dp-grid button:focus-visible { outline: none; box-shadow: var(--ring); }
.dp-foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.dp-foot .grow { flex: 1; }
.dp-foot input.dp-time { width: 84px; min-height: 36px; padding: 4px 8px; text-align: center; }
.dp-foot input.dp-time.bad { border-color: var(--danger); }

/* dropdown (แทนรายการของ <select>) */
select.cs-open { border-color: var(--sky-500); box-shadow: var(--ring); }
.cs-pop { display: flex; flex-direction: column; max-width: min(420px, calc(100vw - 16px)); padding: 6px; padding-top: 9px; }
.cs-search { margin-bottom: 6px; min-height: 36px !important; }
.cs-list { overflow-y: auto; max-height: 300px; outline: none; }
.cs-list:focus, .cs-list:focus-visible { outline: none; box-shadow: none; }
.cs-opt { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: .92rem; line-height: 1.4; }
.cs-opt.active { background: var(--sky-50); color: var(--sky-700); }
.cs-opt.sel { font-weight: 600; color: var(--primary); }
.cs-opt .i { width: 16px; height: 16px; margin-left: auto; flex: none; color: var(--primary); }
.cs-opt.off { color: #A0AEC0; cursor: not-allowed; background: none; }
.cs-empty { padding: 10px; color: var(--muted); font-size: .88rem; text-align: center; }

/* คำแนะนำตอนพิมพ์ (แทน datalist) — ข้อความรองเช่นเบอร์โทร */
.ac-pop .cs-opt small { margin-left: auto; color: var(--muted); font-size: .8rem; white-space: nowrap; }
.ac-pop .cs-opt.active small { color: var(--sky-700); }

/* ช่องตัวเลข: ซ่อนลูกศรขึ้น/ลงของเบราว์เซอร์ */
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-outer-spin-button, input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* กล่องยืนยัน (แทน confirm ของเบราว์เซอร์) */
.confirm-dlg { border: 0; border-radius: var(--radius-lg); padding: 28px 24px 20px; width: min(400px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); color: var(--ink); text-align: center; overflow: hidden; }
.confirm-dlg::before { content: ''; position: absolute; inset: 0 0 auto; height: 4px; background: var(--brand-gradient); }
.confirm-dlg.danger::before { background: var(--danger); }
.confirm-dlg::backdrop { background: rgba(11, 23, 38, .45); }
.confirm-dlg[open] { animation: dlg-in .16s var(--ease); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.confirm-icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 12px; background: var(--sky-100); color: var(--primary); }
.confirm-dlg.warn .confirm-icon { background: var(--yellow-100); color: var(--warn); }
.confirm-dlg.danger .confirm-icon { background: var(--danger-100); color: var(--danger); }
.confirm-dlg h3 { margin: 0 0 6px; font-size: 1.05rem; line-height: 1.5; }
.confirm-dlg p { margin: 0 0 20px; color: var(--muted); line-height: 1.6; }
.confirm-dlg p:empty { display: none; }
.confirm-dlg h3:has(+ p:empty) { margin-bottom: 20px; }
.confirm-dlg .btn-row { flex-wrap: nowrap; }
.confirm-dlg .btn-row .btn { flex: 1; justify-content: center; }

/* เลือกสี (แทน input type=color) */
.cp { position: relative; display: inline-block; max-width: 100%; }
.field > .cp { display: block; }
.cp-native { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.cp-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; width: 100%; padding: 6px 12px 6px 6px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: #fff; color: var(--ink); font: inherit; font-size: .9rem; font-variant-numeric: tabular-nums; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.cp-btn:hover { border-color: #94A3B8; }
.cp-btn:focus-visible, .cp-btn[aria-expanded=true] { outline: none; border-color: var(--sky-500); box-shadow: var(--ring); }
.cp-dot { width: 28px; height: 28px; border-radius: 7px; flex: none; box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .12); }
.cp-pop { width: 296px; max-width: calc(100vw - 16px); padding: 14px 12px 12px; }
.cp-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.cp-sw { aspect-ratio: 1; border: 0; border-radius: 8px; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .12); transition: transform .1s; }
.cp-sw:hover { transform: scale(1.1); }
.cp-sw.sel { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink); }
.cp-sw:focus-visible { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--sky-500); border-radius: 8px; }
.cp-row { display: flex; align-items: center; gap: 6px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.cp-row .grow { flex: 1; }
.cp-row input.cp-text { width: 92px; min-height: 34px; padding: 4px 8px; font-variant-numeric: tabular-nums; text-transform: uppercase; }
.cp-row input.cp-text.bad { border-color: var(--danger); }

/* ข้อความลอยตอนชี้ (แทน title ของเบราว์เซอร์) */
.tip { position: fixed; z-index: 1100; max-width: 260px; padding: 6px 10px; border-radius: 8px; background: var(--nav-bg); color: #fff; font-size: .8rem; line-height: 1.45;
  box-shadow: var(--shadow-lg); pointer-events: none; animation: tip-in .12s var(--ease); }
@keyframes tip-in { from { opacity: 0; transform: translateY(2px); } }

/* หน้ายอด COD */
.cod-hero { align-items: center; }
.cod-hero h2 { font-size: clamp(2rem, 7vw, 2.75rem); line-height: 1.2; margin: 2px 0; }
.cod-hero h2 small { font-size: 1rem; font-weight: 400; color: rgba(255,255,255,.85); }
.cod-hero input { width: auto; max-width: 100%; }
.cod-row { border-top: 1px solid var(--line); }
.cod-row:first-of-type { border-top: 0; }
.cod-row summary { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 4px; cursor: pointer; list-style: none; border-radius: var(--radius-sm); transition: background-color .15s var(--ease); }
.cod-row summary::-webkit-details-marker { display: none; }
.cod-row summary:hover { background: var(--surface-2); }
.cod-row summary:focus-visible { outline: none; box-shadow: var(--ring); }
.cod-row summary > .i { flex: none; color: var(--muted); transition: transform .15s var(--ease); }
.cod-row[open] summary > .i { transform: rotate(90deg); }
.cod-row .grow { flex: 1; min-width: 0; }
.cod-row .cod-date { flex: 1 0 auto; white-space: nowrap; }
.cod-money { flex: none; font-family: var(--font-head); font-weight: 500; font-size: 1.25rem; color: var(--ok); white-space: nowrap; }
.cod-more { margin: 0 0 12px; padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius-sm); }
.cod-more p { margin: 0; color: var(--muted); font-size: .88rem; }
.cod-items { list-style: none; margin: 6px 0 0; padding: 0; }
.cod-items li { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.cod-items a { color: inherit; }
.cod-items a:hover b { color: var(--primary); }
.cod-items a b, .cod-items a small { display: block; }
.cod-items small { color: var(--muted); font-size: .82rem; line-height: 1.5; }
.cod-items .tag { flex: none; }
.cod-amt { flex: none; white-space: nowrap; }
@media (max-width: 720px) {
  .cod-row summary { flex-wrap: wrap; }
  .cod-row summary .tag { order: 1; }
  .cod-items li { flex-wrap: wrap; }
  .cod-items .grow { flex-basis: 100%; }
  .cod-items .cod-amt { margin-left: auto; }
}
@media (prefers-reduced-motion: reduce) { .cod-row summary, .cod-row summary > .i { transition: none; } }
