/* =====================================================================
   ระบบงานทะเบียนรถ — Design system (rewrite)
   แนวทาง: minimal สว่าง · ไซด์บาร์น้ำเงินเข้ม · accent มรกต
   ใช้ CSS เอง (ไม่พึ่ง Bootstrap) · ฟอนต์ IBM Plex Sans Thai · ไอคอน Lucide
   ===================================================================== */

/* ---------- tokens ---------- */
:root {
  --bg:          #f4f6fa;
  --surface:     #ffffff;
  --surface-2:   #f9fbfd;
  --border:      #e7ebf1;
  --border-2:    #dce2ea;

  --text:        #18222f;
  --muted:       #687585;
  --faint:       #9aa5b3;

  --navy:        #0e2a47;
  --navy-2:      #15436b;
  --sidebar:     #0c2138;
  --sidebar-2:   #0a1b2e;
  --sidebar-tx:  #9fb0c3;
  --sidebar-hd:  #5c728a;

  --emerald:     #0ea06f;
  --emerald-d:   #0b8a5e;
  --emerald-sft: #e7f6ef;

  --danger:      #df3f3a;
  --danger-sft:  #fdebeb;
  --warn:        #cf7a1c;
  --warn-sft:    #fbf2e4;

  --r:    12px;
  --r-sm: 9px;
  --r-lg: 16px;
  --r-pill: 999px;

  --sh-1: 0 1px 2px rgba(16,32,55,.05);
  --sh-2: 0 10px 30px -12px rgba(16,32,55,.22);
  --sh-pop: 0 18px 48px -16px rgba(13,28,50,.32);

  --ring: 0 0 0 3px rgba(14,160,111,.20);

  --sidebar-w: 256px;
  --topbar-h: 64px;

  --ease: cubic-bezier(.4, 0, .2, 1);
}

/* ---------- reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
/* attribute hidden ต้องชนะกฎ display ของ component เสมอ (bell-menu/badge, bulk-bar, ฟอร์มค่าใช้จ่าย ฯลฯ) */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'IBM Plex Sans Thai', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
h1, h2, h3, h4, h5 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
::selection { background: rgba(14,160,111,.18); }

/* scrollbar */
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-thumb { background: #c9d2dd; border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: #aab6c4; background-clip: content-box; }

/* ---------- app shell ---------- */
.app { min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: var(--sidebar-tx);
  display: flex; flex-direction: column;
  z-index: 60;
  transition: transform .3s var(--ease);
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 22px;
  color: #fff;
}
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--emerald), #0c8f63);
  box-shadow: 0 6px 16px -4px rgba(14,160,111,.6);
  flex-shrink: 0;
}
.brand-mark svg { width: 21px; height: 21px; color: #fff; }
.brand-name { font-size: 15.5px; font-weight: 600; color: #fff; line-height: 1.2; }
.brand-sub { font-size: 11px; color: #6f8398; letter-spacing: .04em; text-transform: uppercase; }

.nav { padding: 8px 14px; flex: 1; overflow-y: auto; }
.nav-group { margin-top: 18px; }
.nav-group:first-child { margin-top: 4px; }
.nav-label {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; border: 0; background: none; cursor: pointer; text-align: left;
  font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  color: #56708a; padding: 2px 12px 8px; font-weight: 600; font-family: inherit;
}
.nav-label:hover { color: #7f97b0; }
.nav-caret { width: 14px; height: 14px; opacity: .6; transition: transform .18s; flex-shrink: 0; }
.nav-group.collapsed .nav-caret { transform: rotate(-90deg); }
.nav-group.collapsed .nav-items { display: none; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 10px;
  color: var(--sidebar-tx); font-weight: 500; font-size: 14px;
  position: relative; transition: background .16s, color .16s;
}
.nav-link svg { width: 18px; height: 18px; opacity: .85; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #e9eff5; }
.nav-link.active { background: rgba(14,160,111,.16); color: #fff; }
.nav-link.active::before {
  content: ''; position: absolute; left: -14px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--emerald);
}
.nav-link.active svg { opacity: 1; color: var(--emerald); }
.nav-badge {
  margin-left: auto; font-size: 11px; font-weight: 600;
  background: var(--danger); color: #fff; border-radius: var(--r-pill);
  min-width: 20px; height: 18px; padding: 0 6px; display: grid; place-items: center;
}

.sidebar-foot { padding: 14px 22px; border-top: 1px solid rgba(255,255,255,.07); font-size: 11.5px; color: #59708a; }

/* main + topbar */
.main { margin-left: var(--sidebar-w); min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  background: rgba(255,255,255,.82);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  padding: 0 26px;
}
.topbar h1 { font-size: 17px; font-weight: 600; }
.topbar .crumb { color: var(--faint); font-size: 13px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted);
  display: grid; place-items: center; transition: .16s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-2); }
.icon-btn svg { width: 18px; height: 18px; }
.hamburger { display: none; }

.userchip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 6px 12px; border-radius: var(--r-pill);
  border: 1px solid var(--border); background: var(--surface);
  position: relative; transition: .16s;
}
.userchip:hover { border-color: var(--border-2); box-shadow: var(--sh-1); }
.userchip .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 600;
}
.userchip .u-name { font-size: 13.5px; font-weight: 600; line-height: 1.1; }
.userchip .u-role { font-size: 11px; color: var(--muted); }
.userchip svg { width: 15px; height: 15px; color: var(--faint); }

/* ===== กระดิ่งแจ้งเตือน ===== */
.bell-wrap { position: relative; margin-left: auto; }
.bell-btn { position: relative; }
.bell-badge { position: absolute; top: -3px; right: -3px; min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; border-radius: 9px;
  display: grid; place-items: center; line-height: 1; box-shadow: 0 0 0 2px #fff; }
.bell-menu { position: absolute; top: calc(100% + 8px); right: 0; width: 370px; max-height: 460px;
  background: #fff; border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 18px 44px -14px rgba(14,42,71,.4); overflow: hidden; display: flex; flex-direction: column; z-index: 60; }
.bell-head { padding: 12px 14px; font-weight: 700; font-size: 13px; color: var(--navy);
  border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 7px; background: var(--surface-2); }
.bell-head svg { width: 15px; height: 15px; color: var(--emerald-d); }
.bell-list { overflow-y: auto; flex: 1; }
.bell-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--border); cursor: pointer; text-decoration: none; }
.bell-item:hover { background: var(--surface-2); }
.bell-item .bi-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.bell-item .bi-main { flex: 1; min-width: 0; }
.bell-item .bi-plate { font-weight: 600; color: var(--navy); font-size: 13.5px; }
.bell-item .bi-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bell-item .bi-days { font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.bell-empty { padding: 26px 14px; text-align: center; color: var(--muted); font-size: 13px; }
.bell-empty svg { width: 26px; height: 26px; color: var(--emerald); margin-bottom: 4px; }
.bell-foot { display: block; padding: 10px 14px; text-align: center; font-size: 12.5px; color: var(--emerald-d);
  font-weight: 600; text-decoration: none; border-top: 1px solid var(--border); background: var(--surface-2); }
.bell-foot:hover { background: var(--emerald-sft); }
@media (max-width: 480px) { .bell-menu { width: calc(100vw - 32px); right: -60px; } }

.menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 200px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r);
  box-shadow: var(--sh-pop); padding: 6px; z-index: 70;
  opacity: 0; visibility: hidden; transform: translateY(-6px); transition: .16s;
}
.menu.open { opacity: 1; visibility: visible; transform: translateY(0); }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 11px; border: 0; background: none; border-radius: 8px;
  color: var(--text); font-size: 13.5px; text-align: left;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-sft); }
.menu-item svg { width: 16px; height: 16px; }
.menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }
.menu .muted-row { padding: 7px 11px; font-size: 12px; color: var(--muted); }

/* page container — เต็มความกว้างของพื้นที่เนื้อหา */
.page { padding: 26px; width: 100%; }
.page-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-title h2 { font-size: 22px; }
.page-title p { margin: 3px 0 0; color: var(--muted); font-size: 13.5px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px;
  font-size: 14px; font-weight: 600; border: 1px solid transparent;
  transition: .15s var(--ease); white-space: nowrap;
}
.btn svg { width: 17px; height: 17px; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: #143a5f; }
.btn-accent { background: var(--emerald); color: #fff; box-shadow: 0 8px 18px -8px rgba(14,160,111,.7); }
.btn-accent:hover { background: var(--emerald-d); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: #c9d2dd; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c8352f; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15px; border-radius: 12px; font-weight: 700; }
.btn-icon { width: 34px; height: 34px; padding: 0; }
.btn-icon.btn-sm { width: 31px; height: 31px; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn[disabled] { opacity: .6; pointer-events: none; }

/* ---------- panels / cards ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.panel-pad { padding: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.panel-head h3 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.panel-head h3 svg { width: 17px; height: 17px; color: var(--muted); }

/* ---------- stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 18px 20px; position: relative; overflow: hidden; transition: .18s var(--ease);
}
.tile:hover { border-color: var(--border-2); box-shadow: var(--sh-2); transform: translateY(-2px); }
.tile .t-top { display: flex; align-items: center; justify-content: space-between; }
.tile .t-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; }
.tile .t-ic svg { width: 19px; height: 19px; }
.tile .t-val { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin-top: 12px; font-variant-numeric: tabular-nums; line-height: 1; }
.tile .t-lab { font-size: 13px; color: var(--muted); margin-top: 6px; }
.ic-navy   { background: #eaf0f7; color: var(--navy); }
.ic-emerald{ background: var(--emerald-sft); color: var(--emerald-d); }
.ic-danger { background: var(--danger-sft); color: var(--danger); }
.ic-warn   { background: var(--warn-sft); color: var(--warn); }
.ic-muted  { background: #eef1f5; color: var(--muted); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12.5px; font-weight: 600; color: #46566a; }
.field > label .req { color: var(--danger); }
.input, .select, .textarea {
  width: 100%; height: 42px; padding: 0 13px;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 10px;
  font-size: 14px; color: var(--text); font-family: inherit; transition: .15s;
}
.textarea { height: auto; padding: 11px 13px; resize: vertical; min-height: 64px; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--emerald); box-shadow: var(--ring); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23687585' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.input-wrap { position: relative; }
.input-wrap > svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--faint); }
.input-wrap .input { padding-left: 40px; }

.form-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.c2{grid-column:span 2}.c3{grid-column:span 3}.c4{grid-column:span 4}.c5{grid-column:span 5}.c6{grid-column:span 6}.c7{grid-column:span 7}.c8{grid-column:span 8}.c12{grid-column:span 12}
.form-section-title {
  grid-column: 1/-1; display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  color: var(--emerald-d); margin-top: 6px; padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.form-section-title svg { width: 16px; height: 16px; }

/* ---------- toolbar ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .input-wrap { flex: 1; min-width: 220px; }
.toolbar .select { width: auto; min-width: 150px; height: 42px; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
table.tbl thead th {
  background: var(--surface-2); color: var(--muted);
  font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  text-align: left; padding: 13px 14px; white-space: nowrap;
  border-bottom: 1px solid var(--border); position: sticky; top: 0;
}
table.tbl tbody td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
table.tbl tbody tr { transition: background .12s; }
table.tbl tbody tr:hover { background: #f7f9fc; }
table.tbl tbody tr:last-child td { border-bottom: 0; }
.t-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.t-num { font-variant-numeric: tabular-nums; }
.cell-ellipsis { max-width: 160px; overflow: hidden; text-overflow: ellipsis; display: inline-block; vertical-align: bottom; }
.row-actions { display: inline-flex; gap: 6px; }

/* sticky last column */
.tbl .stick-r { position: sticky; right: 0; background: var(--surface); box-shadow: -10px 0 12px -10px rgba(16,32,55,.16); }
.tbl thead .stick-r { background: var(--surface-2); }
.tbl tbody tr:hover .stick-r { background: #f7f9fc; }

/* plate */
.plate {
  display: inline-block; font-weight: 700; font-size: 13.5px; letter-spacing: .03em;
  padding: 4px 9px; border-radius: 7px;
  border: 1.5px solid #ccd6e2; box-shadow: inset 0 -2px 0 rgba(0,0,0,.10);
  background: #fff; color: #14233a;
}
/* สีป้ายตามจริง — ขาว/เหลือง/แดง/เขียว/ส้ม/ฟ้า/ดำ */
.plate-white  { background: #ffffff; color: #14233a; border-color: #cbd5e1; }
.plate-yellow { background: #fbd84a; color: #14233a; border-color: #c39414; }
.plate-red    { background: #d92e2e; color: #ffffff; border-color: #8e1a1a; }
.plate-green  { background: #1f8a4c; color: #ffffff; border-color: #145931; }
.plate-orange { background: #ff8b2e; color: #14233a; border-color: #b85e15; }
.plate-blue   { background: #1d6dd3; color: #ffffff; border-color: #103f7e; }
.plate-black  { background: #14233a; color: #ffffff; border-color: #000000; }

/* ตัวเลือกสีป้าย (radio picker) */
.plate-color-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.pcp-opt {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px; border: 1.5px solid var(--border-2); border-radius: 10px;
  background: var(--surface); cursor: pointer; transition: .15s;
}
.pcp-opt:hover { border-color: var(--emerald); background: var(--surface-2); }
.pcp-opt input[type="radio"] { display: none; }
.pcp-opt:has(input:checked) { border-color: var(--emerald); background: var(--emerald-sft); box-shadow: var(--ring); }
.pcp-name { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.pcp-opt:has(input:checked) .pcp-name { color: var(--text); font-weight: 600; }
.thumb { width: 44px; height: 44px; border-radius: 9px; object-fit: cover; border: 1px solid var(--border); cursor: pointer; background: var(--surface-2); }
.thumb-empty { width: 44px; height: 44px; border-radius: 9px; border: 1px dashed var(--border-2); display: grid; place-items: center; color: var(--faint); cursor: pointer; }
.thumb-empty svg { width: 18px; height: 18px; }

/* ---------- badges ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600; line-height: 1; }
.pill svg { width: 13px; height: 13px; }
.pill-ok    { background: var(--emerald-sft); color: var(--emerald-d); }
.pill-off   { background: #eef1f5; color: var(--muted); }
.pill-danger{ background: var(--danger-sft); color: var(--danger); }
.pill-warn  { background: var(--warn-sft); color: var(--warn); }
.txt-danger { color: var(--danger); font-weight: 600; }
.txt-warn   { color: var(--warn); font-weight: 600; }
.txt-ok     { color: var(--emerald-d); font-weight: 600; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

/* empty / loading state */
.state { text-align: center; padding: 54px 20px; color: var(--muted); }
.state svg { width: 38px; height: 38px; color: var(--faint); margin-bottom: 10px; }
.spinner { width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
.spinner-dark { border-color: rgba(14,160,111,.25); border-top-color: var(--emerald); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- modal (custom) ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(11,24,40,.46); backdrop-filter: blur(3px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto;
  opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s;
}
.overlay.open { opacity: 1; visibility: visible; }
.modal {
  width: 100%; max-width: 760px; margin: auto; background: var(--surface);
  border-radius: var(--r-lg); box-shadow: var(--sh-pop);
  transform: translateY(14px) scale(.99); transition: transform .22s var(--ease);
  display: flex; flex-direction: column; max-height: calc(100vh - 80px);
}
.overlay.open .modal { transform: none; }
/* modal ฟอร์มใหญ่ — กว้างพอเหมาะ (สูงสุด 1080px) จอเล็กยืดตามพื้นที่ */
.modal-full { max-width: 1080px; width: calc(100vw - 32px); max-height: calc(100vh - 80px); }
.modal-head { display: flex; align-items: center; gap: 11px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head .m-ic { width: 34px; height: 34px; border-radius: 9px; background: var(--emerald-sft); color: var(--emerald-d); display: grid; place-items: center; }
.modal-head .m-ic svg { width: 18px; height: 18px; }
.modal-head h3 { font-size: 16px; }
.modal-head .x { margin-left: auto; width: 34px; height: 34px; border-radius: 8px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; }
.modal-head .x:hover { background: var(--surface-2); color: var(--text); }
.modal-head .x svg { width: 18px; height: 18px; }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* detail view (read) rows */
.dl { display: grid; grid-template-columns: 150px 1fr; gap: 2px 16px; font-size: 13.5px; }
.dl dt { color: var(--muted); padding: 7px 0; }
.dl dd { margin: 0; padding: 7px 0; border-bottom: 1px solid var(--border); }

/* ===== หน้า "ดูข้อมูล" 2 คอลัมน์ + แกลเลอรี ===== */
.vw { text-align: left; }
/* แถวหัว modal: ป้ายทะเบียนอยู่กลาง · ปุ่มประวัติชิดขวา */
.vw-head { position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 38px; flex-wrap: wrap; }
.vw-head-actions { position: absolute; right: 0; top: 50%; transform: translateY(-50%); display: flex; gap: 8px; }
@media (max-width: 720px) { .vw-head-actions { position: static; transform: none; } }
.vw-grid { display: grid; grid-template-columns: 360px 1fr; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .vw-grid { grid-template-columns: 1fr; } }
/* ข้อมูลรถ · เจ้าของ · ภาษี เรียง 3 คอลัมน์ข้างกัน (ฝั่งขวา) */
.vw-cols3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; align-items: start; margin-bottom: 12px; }
.vw-cols3 .vw-sec { margin-bottom: 0; }
.vw-cols3 .vw-row { grid-template-columns: 95px 1fr; }
.vw-cols3 .rcards { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
@media (max-width: 1100px) { .vw-cols3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 720px)  { .vw-cols3 { grid-template-columns: 1fr; } }
/* ข้อมูลรถ+เจ้าของ (ซ้อน) | ภาษี·พ.ร.บ.·ประกัน */
.vw-cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; margin-bottom: 12px; }
.vw-cols2 .vw-sec { margin-bottom: 0; }
.vw-cols2 .vw-row { grid-template-columns: 100px 1fr; }
.vw-cols2 .rcards { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
@media (max-width: 1100px) { .vw-cols2 { grid-template-columns: 1fr; } }
.vw-col-stack { display: flex; flex-direction: column; gap: 12px; }
/* ปุ่มใน footer modal */
.vw-foot { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.vw-sec { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: 14px 16px; margin-bottom: 12px; }
.vw-sec-h {
  font-size: 11.5px; font-weight: 700; color: var(--emerald-d);
  letter-spacing: .06em; text-transform: uppercase;
  padding-bottom: 8px; margin-bottom: 6px; border-bottom: 1px solid var(--border);
}
.vw-row { display: grid; grid-template-columns: 130px 1fr; gap: 8px; padding: 6px 0; font-size: 13.5px; border-bottom: 1px dashed var(--border); }
.vw-row:last-child { border-bottom: 0; }
.vw-l { color: var(--muted); }
.vw-r { color: var(--text); word-break: break-word; }

/* แถบทำงานแบบกลุ่ม (bulk) */
.bulk-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--navy); color: #fff; border-radius: var(--r);
  padding: 10px 16px; margin-bottom: 14px; box-shadow: var(--shadow);
  animation: lb-in .15s ease;
}
.bulk-count { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.bulk-count svg { width: 18px; height: 18px; }
.bulk-count b { font-size: 16px; }
.bulk-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.bulk-bar .btn-ghost { background: rgba(255, 255, 255, .14); color: #fff; border-color: transparent; }
.bulk-bar .btn-ghost:hover { background: rgba(255, 255, 255, .26); }
.col-chk { width: 38px; text-align: center; }
.col-chk input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--navy); }

/* จำนวนไฟล์แนบในตารางทะเบียนรถ (รูป / เอกสาร) — ไม่มีไฟล์ = สีเทา */
.fchips { display: inline-flex; flex-direction: column; align-items: stretch; gap: 4px; text-decoration: none; }
.fchip { display: inline-flex; align-items: center; gap: 4px; min-width: 40px; justify-content: center;
  font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: var(--r-pill); border: 1px solid; font-variant-numeric: tabular-nums; }
.fchip svg { width: 13px; height: 13px; }
.fchip-img { background: var(--emerald-sft); color: var(--emerald-d); border-color: #bfe6d4; }
.fchip-doc { background: #e8f0fb; color: #1d5fb8; border-color: #c2d6f2; }
.fchip-off { background: var(--surface-2); color: #b4bcc7; border-color: var(--border); font-weight: 500; }
.fchips:hover .fchip { filter: brightness(.96); }

/* ===== แก้ไขหลายคัน (bulk edit) ===== */
.be-steps { display: flex; gap: 6px; list-style: none; margin: 0 6px 0 auto; padding: 0; counter-reset: be; }
.be-steps + .x { margin-left: 0; }
.be-steps li { counter-increment: be; font-size: 12px; padding: 5px 11px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--faint); border: 1px solid var(--border); white-space: nowrap; }
.be-steps li::before { content: counter(be) ". "; }
.be-steps li.active { background: var(--emerald-sft); color: var(--emerald-d); border-color: var(--emerald); font-weight: 600; }
.be-steps li.done { color: var(--emerald-d); }
.be-hint { font-size: 13px; margin: 0 0 14px; line-height: 1.7; }
.be-tag { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 6px; background: var(--warn-sft); color: var(--warn); white-space: nowrap; }
.be-checks { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 18px; }
.be-chk { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border: 1.5px solid var(--border-2); border-radius: 10px; font-size: 13.5px; cursor: pointer; background: var(--surface); transition: .15s; }
.be-chk:hover { border-color: var(--emerald); }
.be-chk input { width: 15px; height: 15px; accent-color: var(--emerald); margin: 0; }
.be-chk:has(input:checked) { border-color: var(--emerald); background: var(--emerald-sft); font-weight: 600; }
.be-sec-title { font-size: 14px; font-weight: 700; color: var(--navy); margin: 4px 0 10px; }
.be-sec-title .muted { font-weight: 400; font-size: 12.5px; }
.be-shared { border: 1px solid var(--border); border-radius: var(--r); padding: 4px 14px; margin-bottom: 20px; }
.be-row { display: grid; grid-template-columns: 190px minmax(0, 1fr) 160px; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.be-row:last-child { border-bottom: 0; }
.be-lab { font-size: 13.5px; font-weight: 600; color: var(--text); }
.be-opt { font-size: 13px; }
.be-opt .select { height: 38px; font-size: 13px; }
.be-clear { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--muted); }
.be-clear input { accent-color: var(--danger); }
.be-req { font-size: 12px; }
.be-ctl .is-off { opacity: .45; }
.be-grid-wrap { max-height: 460px; overflow: auto; border: 1px solid var(--border); border-radius: var(--r); }
.be-grid thead th { z-index: 1; }
.be-grid tbody td { padding: 6px 10px; vertical-align: top; }
.be-grid .input { height: 36px; min-width: 150px; }
.be-grid td.be-chg .input { border-color: var(--emerald); background: var(--emerald-sft); }
.be-old { font-size: 11.5px; color: var(--faint); margin-top: 3px; }
.be-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.be-metric { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: 12px 14px; }
.be-metric span { display: block; font-size: 12.5px; color: var(--muted); }
.be-metric b { font-size: 22px; color: var(--navy); }
.be-alert { background: var(--danger-sft); color: var(--danger); border-radius: var(--r); padding: 12px 16px; margin-bottom: 14px; font-size: 13.5px; }
.be-alert b { display: inline-flex; align-items: center; gap: 6px; }
.be-alert svg { width: 16px; height: 16px; }
.be-alert ul { margin: 6px 0 0 20px; padding: 0; line-height: 1.7; }
.be-alert-info { background: var(--surface-2); color: var(--muted); }
.be-cars { display: flex; flex-direction: column; gap: 6px; }
.be-car { border: 1px solid var(--border); border-radius: var(--r-sm); padding: 8px 12px; }
.be-car summary { cursor: pointer; display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.be-car summary .be-n { margin-left: auto; font-size: 12px; color: var(--emerald-d); font-weight: 600; }
.be-car .eh-changes { padding: 4px 0 2px; }
.be-car .eh-old, .be-car .eh-new { white-space: pre-line; }
.be-foot-note { margin-right: auto; font-size: 12.5px; align-self: center; }
@media (max-width: 760px) {
  .be-steps { display: none; }
  .be-row { grid-template-columns: 1fr; gap: 6px; }
  .be-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ===== หน้าตั้งค่าระบบ ===== */
.set-list { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: #fff; }
.set-list-head { display: flex; align-items: center; gap: 8px; padding: 11px 14px;
  background: var(--surface-2); border-bottom: 1px solid var(--border); font-weight: 700; color: var(--navy); font-size: 14px; }
.set-list-head svg { width: 17px; height: 17px; color: var(--emerald); }
.set-list-body { max-height: 320px; overflow-y: auto; }
.set-item { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.set-item:last-child { border-bottom: 0; }
.set-item:hover { background: var(--surface-2); }
.set-item-name { flex: 1; font-size: 13.5px; color: var(--text); word-break: break-word; }
.set-item-use { font-size: 11px; font-weight: 700; color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; }
.set-list-add { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--surface-2); }
.set-list-add .input { height: 36px; }

.setting-link { display: flex; align-items: center; gap: 12px; padding: 14px 16px; text-decoration: none;
  border: 1px solid var(--border); border-radius: 12px; background: #fff; transition: .15s; }
.setting-link:hover { border-color: var(--border-2); box-shadow: var(--sh-1); transform: translateY(-1px); }
.setting-link .sl-ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.setting-link .sl-ic svg { width: 20px; height: 20px; }
.setting-link span b { display: block; color: var(--navy); font-size: 14px; }
.setting-link span small { color: var(--muted); font-size: 12px; }

/* ประวัติการแก้ไขรายคัน — ไทม์ไลน์ */
.eh-list { display: flex; flex-direction: column; gap: 2px; }
.eh-item { display: flex; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--border); }
.eh-item:last-child { border-bottom: 0; }
.eh-ic {
  flex: 0 0 34px; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface-2); color: var(--navy);
}
.eh-ic svg { width: 17px; height: 17px; }
.eh-main { flex: 1; min-width: 0; }
.eh-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.eh-meta { font-size: 12px; color: var(--faint); white-space: nowrap; }
.eh-sum { font-size: 13px; color: var(--muted); margin-top: 2px; }
.eh-changes { margin-top: 8px; display: flex; flex-direction: column; gap: 5px; }
.eh-chg {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 13px; background: var(--surface-2); border-radius: 8px; padding: 6px 10px;
}
.eh-chg svg { width: 14px; height: 14px; color: var(--faint); flex: 0 0 auto; }
.eh-field { font-weight: 600; color: var(--navy); min-width: 90px; }
.eh-old { color: var(--danger); text-decoration: line-through; opacity: .8; word-break: break-word; }
.eh-new { color: var(--emerald); font-weight: 600; word-break: break-word; }

/* Lightbox พรีวิวรูปในระบบ (ซ้อนทับทุกชั้น รวม SweetAlert) */
.img-lightbox {
  position: fixed; inset: 0; z-index: 3000; display: none;
  align-items: center; justify-content: center;
  background: rgba(8, 15, 24, .9); backdrop-filter: blur(3px);
  animation: lb-in .15s ease;
}
.img-lightbox.open { display: flex; }
.img-lightbox img {
  max-width: 92vw; max-height: 90vh; border-radius: 10px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .6); background: #0e1924;
}
.img-lightbox .lb-close {
  position: fixed; top: 16px; right: 22px; width: 42px; height: 42px;
  border: 0; border-radius: 50%; background: rgba(255, 255, 255, .12);
  color: #fff; font-size: 26px; line-height: 1; cursor: pointer;
  display: grid; place-items: center; transition: background .15s ease;
}
.img-lightbox .lb-close:hover { background: rgba(255, 255, 255, .25); }
@keyframes lb-in { from { opacity: 0; } to { opacity: 1; } }

/* แกลเลอรีรูป — รูปหลัก + แถบรูปย่อย (ฝั่งซ้าย sticky ให้รูปลอยอยู่ขณะเลื่อนข้อมูล) */
.vw-left { position: sticky; top: 0; }
.vw-gallery { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); padding: 12px; margin-bottom: 12px; }
.vw-main {
  display: block; width: 100%; aspect-ratio: 4/3; max-height: 260px;
  background: #0e1924; border-radius: var(--r-sm); overflow: hidden;
  border: 1px solid var(--border);
}
.vw-main img { width: 100%; height: 100%; object-fit: contain; display: block; }
.vw-main-empty {
  display: grid; place-items: center; gap: 6px;
  aspect-ratio: auto; min-height: 150px;
  background: var(--surface); color: var(--faint); font-size: 13px;
}
.vw-main-empty svg { width: 32px; height: 32px; }
.vw-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.vw-th {
  width: 64px; height: 64px; padding: 0; border-radius: 9px; overflow: hidden;
  border: 2px solid transparent; background: var(--surface); cursor: pointer;
  transition: border-color .15s ease, transform .15s ease;
}
.vw-th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vw-th:hover { transform: translateY(-1px); }
.vw-th.active { border-color: var(--emerald); }

/* การ์ดต่ออายุ — ภาษี/พ.ร.บ./กรมธรรม์/ประกันสินค้า */
.rcards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
@media (max-width: 720px) { .rcards { grid-template-columns: 1fr; } }
.rcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; border-left: 4px solid var(--border-2);
}
.rcard-h { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 14px; }
.rcard-h svg { width: 16px; height: 16px; color: var(--muted); }
.rcard-h b { color: var(--text); }
.rcard-st { margin-left: auto; }
.rcard-body { display: flex; flex-direction: column; gap: 4px; }
.rc-row { display: flex; justify-content: space-between; font-size: 13px; }
.rc-l { color: var(--muted); }
.rc-r { color: var(--text); font-weight: 500; text-align: right; }
.rcard.rc-ok       { border-left-color: var(--emerald); }
.rcard.rc-warn     { border-left-color: var(--warn); }
.rcard.rc-overdue  { border-left-color: var(--danger); background: #fff7f7; }
.rcard.rc-empty    { border-left-color: var(--border-2); }

/* pill สีใหม่สำหรับแท็กเอกสาร */
.pill-blue    { background: #dbeafe; color: #1e3a8a; }
.pill-emerald { background: var(--emerald-sft); color: var(--emerald-d); }
.pill-purple  { background: #f3e8ff; color: #5b21b6; }

/* ไทม์ไลน์ประวัติการต่อ */
.rh-timeline { display: flex; flex-direction: column; gap: 0; margin-top: 8px; position: relative; padding-left: 14px; }
.rh-timeline::before {
  content: ''; position: absolute; left: 5px; top: 8px; bottom: 8px;
  width: 2px; background: var(--border);
}
.rh-item { position: relative; padding: 10px 0 10px 16px; }
.rh-dot {
  position: absolute; left: -14px; top: 14px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--muted); border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border);
}
.rh-tax    .rh-dot, .rh-dot.rh-tax    { background: var(--warn); }
.rh-ctpl   .rh-dot, .rh-dot.rh-ctpl   { background: #1d4ed8; }
.rh-ins    .rh-dot, .rh-dot.rh-ins    { background: var(--emerald); }
.rh-cargo  .rh-dot, .rh-dot.rh-cargo  { background: #7c3aed; }
.rh-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 13px; }
.rh-file { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--text); text-decoration: none; }
.rh-file:hover { color: var(--emerald-d); text-decoration: underline; }
.rh-file svg { width: 15px; height: 15px; color: var(--muted); }

.vw-sec-h { display: flex; align-items: center; gap: 6px; }
.vw-sec-h svg { width: 14px; height: 14px; }

/* ---------- file attachments ---------- */
.dropzone { display: block; border: 1.5px dashed var(--border-2); border-radius: var(--r); padding: 22px 16px; text-align: center; color: var(--muted); transition: .15s; cursor: pointer; }
.dropzone:hover { border-color: var(--emerald); background: var(--emerald-sft); color: var(--emerald-d); }
.dropzone.drag { border-color: var(--emerald); background: var(--emerald-sft); color: var(--emerald-d); border-style: solid; }
.dropzone svg { width: 26px; height: 26px; color: var(--emerald); margin-bottom: 4px; }
.dropzone > div:nth-of-type(1) { font-weight: 600; color: var(--text); }

/* แถวควบคุมเอกสาร: ประเภท + คำอธิบาย + วันที่ ในแถวเดียว */
.doc-controls { display: grid; grid-template-columns: 210px 1fr 190px; gap: 12px; margin-bottom: 6px; }
.hint-line { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.hint-line svg { width: 14px; height: 14px; flex-shrink: 0; }
.hint-line b { color: var(--text); font-weight: 600; }

/* แก้ไขแท็ก/วันที่ในรายการเอกสาร */
.fmeta { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.date-mini { height: 30px; padding: 0 8px; border: 1px solid var(--border-2); border-radius: 8px; background: var(--surface); font-size: 12.5px; color: var(--text); font-family: inherit; }
.date-mini:focus { outline: none; border-color: var(--emerald); box-shadow: var(--ring); }
@media (max-width: 720px) { .doc-controls { grid-template-columns: 1fr; } }
.file-grid { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 10px; }
.fthumb { position: relative; width: 80px; height: 80px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.fthumb img { width: 100%; height: 100%; object-fit: cover; }
.fthumb.new { border: 2px solid var(--emerald); }
.fthumb .del { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; border: 0; border-radius: 50%; background: rgba(223,63,58,.92); color: #fff; display: grid; place-items: center; }
.fthumb .del svg { width: 13px; height: 13px; }
.ftag { position: absolute; left: 4px; bottom: 4px; background: var(--emerald); color: #fff; font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 5px; }
/* ตั้งรูปหลัก */
.fthumb.is-primary { border: 2px solid var(--emerald); box-shadow: 0 0 0 3px rgba(14,160,111,.22); }
.fthumb .setpri { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border: 0; border-radius: 50%;
  background: rgba(14,42,71,.55); color: #fff; display: grid; place-items: center; cursor: pointer; opacity: 0; transition: opacity .15s; }
.fthumb:hover .setpri { opacity: 1; }
.fthumb .setpri:hover { background: var(--emerald); }
.fthumb .setpri svg { width: 13px; height: 13px; }
.primary-badge { position: absolute; left: 0; right: 0; bottom: 0; background: var(--emerald); color: #fff;
  font-size: 10px; font-weight: 700; padding: 2px 0; text-align: center; display: flex; align-items: center; justify-content: center; gap: 3px; }
.primary-badge svg { width: 11px; height: 11px; }
.flist { display: flex; flex-direction: column; gap: 7px; margin-top: 10px; }
.fitem { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); font-size: 13px; }
.fitem svg { width: 18px; height: 18px; color: var(--muted); flex-shrink: 0; }
.fitem.new { border-color: var(--emerald); }
.fitem .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-select {
  height: 30px; padding: 0 26px 0 10px; border: 1px solid var(--border-2); border-radius: 8px;
  background: var(--surface); font-size: 12.5px; color: var(--text); font-family: inherit; flex-shrink: 0;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23687585' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
.tag-select:focus { outline: none; border-color: var(--emerald); box-shadow: var(--ring); }
.fmeta { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.date-mini {
  height: 30px; padding: 0 8px; border: 1px solid var(--border-2); border-radius: 8px;
  background: var(--surface); font-size: 12.5px; color: var(--text); font-family: inherit;
}
.date-mini:focus { outline: none; border-color: var(--emerald); box-shadow: var(--ring); }
.dropzone.drag-on { border-color: var(--emerald); background: var(--emerald-sft); color: var(--emerald-d); }

/* chart container */
.chart-box { position: relative; height: 280px; }

/* ---------- login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-art {
  background: linear-gradient(155deg, var(--sidebar) 0%, var(--navy) 55%, #0d3a59 100%);
  color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.auth-art::after { content: ''; position: absolute; width: 460px; height: 460px; border-radius: 50%; background: radial-gradient(circle, rgba(14,160,111,.35), transparent 70%); right: -120px; bottom: -120px; }
.auth-art .a-brand { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.auth-art h2 { font-size: 30px; line-height: 1.25; position: relative; z-index: 1; max-width: 380px; }
.auth-art .a-feats { display: flex; flex-direction: column; gap: 14px; position: relative; z-index: 1; }
.auth-art .a-feat { display: flex; align-items: center; gap: 12px; color: #cfe0ee; font-size: 14.5px; }
.auth-art .a-feat .fic { width: 34px; height: 34px; border-radius: 9px; background: rgba(255,255,255,.1); display: grid; place-items: center; }
.auth-art .a-feat svg { width: 17px; height: 17px; color: var(--emerald); }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px; }
.auth-card { width: 100%; max-width: 360px; }
.auth-card h1 { font-size: 24px; margin-bottom: 4px; }
.auth-card .sub { color: var(--muted); margin-bottom: 26px; font-size: 14px; }
.auth-card .field { margin-bottom: 16px; }
.pw-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border: 0; background: none; color: var(--faint); border-radius: 7px; display: grid; place-items: center; }
.pw-toggle:hover { color: var(--muted); }
.hint { margin-top: 18px; font-size: 12.5px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.hint b { color: var(--text); }

/* ---------- utilities ---------- */
.row-line { display: flex; align-items: center; gap: 8px; }
.mt-0{margin-top:0}.mb-0{margin-bottom:0}
.text-end { text-align: right; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.fade-up { animation: fadeUp .4s var(--ease) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== ปฏิทิน (FullCalendar) legend + ปรับธีม ===== */
.cal-legend { display: flex; gap: 8px; flex-wrap: wrap; }
.cal-lg { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px; }
.cal-lg::before { content: ''; width: 8px; height: 8px; border-radius: 50%; }
.cal-lg-tax   { background: #fef3c7; color: #92400e; } .cal-lg-tax::before   { background: #b45309; }
.cal-lg-ctpl  { background: #dbeafe; color: #1e3a8a; } .cal-lg-ctpl::before  { background: #1d4ed8; }
.cal-lg-ins   { background: #e7f6ef; color: #065f46; } .cal-lg-ins::before   { background: #0b8a5e; }
.cal-lg-cargo { background: #f3e8ff; color: #5b21b6; } .cal-lg-cargo::before { background: #7c3aed; }
.fc { font-family: inherit; }
.fc .fc-toolbar-title { font-size: 18px; font-weight: 700; }
.fc .fc-button { background: var(--surface); color: var(--text); border: 1px solid var(--border-2); font-weight: 600; box-shadow: none; text-transform: none; }
.fc .fc-button:hover { background: var(--surface-2); }
.fc .fc-button-primary:not(:disabled).fc-button-active { background: var(--navy); color: #fff; border-color: var(--navy); }
.fc .fc-event { border-radius: 6px; font-weight: 600; padding: 2px 6px; cursor: pointer; }
.fc .fc-daygrid-day.fc-day-today { background: #fffbeb; }

/* ===== หน้ารายงาน ===== */
.rep-card { display: flex; flex-direction: column; gap: 6px; }
.rep-bars { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.rep-bar { display: flex; align-items: center; gap: 8px; font-size: 13.5px; padding: 4px 0; border-bottom: 1px dashed var(--border); }
.rep-bar:last-child { border-bottom: 0; }
.rep-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.rep-d-expired  { background: #df3f3a; } .rep-d-expiring { background: #cf7a1c; }
.rep-d-ok       { background: #0ea06f; } .rep-d-nodate   { background: #c9d2dd; }
.rep-val { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ===== ใบคุมสถานะภาษี ===== */
.tax-sum-tbl th, .tax-sum-tbl td { white-space: nowrap; }
.tax-sum-tbl thead th { background: var(--navy); color: #fff; font-size: 12.5px; }
.tax-sum-tbl thead th:first-child { text-align: left; padding-left: 14px; }
.tax-sum-tbl .row-label { font-weight: 600; background: var(--surface-2); }
.tax-sum-tbl td.t-num { text-align: center; font-variant-numeric: tabular-nums; min-width: 44px; }
.tax-sum-tbl td.clickable { cursor: pointer; transition: background .12s; }
.tax-sum-tbl td.clickable:hover { background: var(--emerald-sft); color: var(--emerald-d); }
.tax-sum-tbl .clickable-th { cursor: pointer; }
.tax-sum-tbl .clickable-th:hover { background: var(--navy-2); }

/* แถวรวมท้ายตาราง */
.tbl tfoot .sum-row td { background: var(--surface-2); font-weight: 700; border-top: 2px solid var(--border-2); padding: 12px 14px; }

/* คำใบ้ในฟอร์ม: ลิงก์ไปเมนูที่เกี่ยวข้อง */
.form-hint {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 14px 16px; background: #f7f9fc;
  border: 1px dashed var(--border-2); border-radius: 10px;
  font-size: 13.5px; color: var(--muted);
}
.form-hint > svg { flex-shrink: 0; margin-top: 2px; color: var(--emerald-d); }
.form-hint b { display: block; color: var(--text); margin-bottom: 6px; }
.form-hint a {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 3px 6px 3px 0; padding: 5px 11px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-weight: 500; transition: .15s;
}
.form-hint a:hover { background: var(--emerald-sft); border-color: var(--emerald); color: var(--emerald-d); }
.form-hint a svg { width: 14px; height: 14px; }

.month-tabs {
  display: flex; gap: 6px; flex-wrap: wrap; margin: 18px 0 0;
  padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
}
.mtab {
  border: 0; background: transparent; padding: 8px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--muted);
  transition: background .15s, color .15s;
}
.mtab:hover { background: var(--surface-2); color: var(--text); }
.mtab.active { background: var(--navy); color: #fff; }

/* แถวที่นัดเลื่อนมาในเดือนนี้ — แสดงพื้นแยก */
.tbl tbody tr.row-deferred { background: #fff8eb; }
.tbl tbody tr.row-deferred:hover { background: #fff0d6; }
.tbl tbody tr.row-error    { background: var(--danger-sft); }
.tbl tbody tr.row-error:hover { background: #fbd8d8; }

/* ===== Permission picker ===== */
.perm-group { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; }
.perm-group-h { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 13.5px; }
.perm-group-h b { color: var(--navy); }
.perm-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 16px; padding: 10px 14px; }
@media (max-width: 720px) { .perm-list { grid-template-columns: 1fr; } }
.perm-item { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13.5px; cursor: pointer; }
.perm-item input { width: 16px; height: 16px; }

/* ===== Reports catalog ===== */
.reports-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (max-width: 860px) { .reports-grid { grid-template-columns: 1fr; } }
.reports-group-title {
  font-size: 12.5px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  color: var(--emerald-d); padding: 6px 0 8px; margin-top: 6px;
  border-bottom: 1px solid var(--border);
}
.reports-group-title:first-child { margin-top: 0; }
.report-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px;
  text-decoration: none; color: var(--text); transition: .15s;
  background: var(--surface);
}
.report-card:hover { border-color: var(--emerald); background: var(--emerald-sft); }
.report-card .rc-ic { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--navy); flex-shrink: 0; }
.report-card .rc-ic svg { width: 22px; height: 22px; }
.report-card .rc-title { font-weight: 700; font-size: 14px; }
.report-card .rc-desc { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.report-card .rc-arrow { margin-left: auto; color: var(--muted); width: 18px; height: 18px; flex-shrink: 0; }
.report-card:hover .rc-arrow { color: var(--emerald-d); }

/* ===== Backup: ตารางเลือกล้างข้อมูล ===== */
#tablesGrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
@media (max-width: 860px) { #tablesGrid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { #tablesGrid { grid-template-columns: 1fr; } }
.table-pick {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); cursor: pointer; transition: .15s;
}
.table-pick:hover { background: var(--surface-2); border-color: var(--border-2); }
.table-pick:has(input:checked) { border-color: var(--danger); background: var(--danger-sft); }
.table-pick input { width: 16px; height: 16px; flex-shrink: 0; }
.table-pick .t-name { flex: 1; font-size: 13px; }
.table-pick .t-name code { background: transparent; padding: 0; color: var(--text); font-weight: 600; }
.table-pick .t-cnt { font-size: 11.5px; flex-shrink: 0; }

/* Toggle ขอบเขตข้อมูล (เดือน/ปี/ทั้งหมด) ในหน้าปฏิทิน */
.scope-toggle {
  display: inline-flex; padding: 4px; gap: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
.scope-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: 0; cursor: pointer;
  padding: 7px 13px; border-radius: 7px;
  font-size: 13px; font-weight: 600; color: var(--muted);
  font-family: inherit; transition: .15s;
}
.scope-btn:hover { color: var(--text); }
.scope-btn.active { background: var(--navy); color: #fff; }
.scope-btn small { font-size: 11.5px; font-weight: 600; opacity: .85; }
.scope-btn.active small { opacity: 1; }

/* ---------- ส่งแจ้งเตือนเข้ากลุ่ม LINE ---------- */
.line-steps { margin: 0 0 14px; padding-left: 20px; font-size: 13px; line-height: 1.65; color: #334155; }
.line-steps li { margin-bottom: 4px; }
.line-lab { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.line-note { font-size: 12px; line-height: 1.6; margin: 8px 0 0; }
.line-id { font-family: monospace; font-size: 11px; color: var(--faint); }

/* ---------- สิทธิ์ / ปิดปรับปรุงระบบ ---------- */
.nav-maint {
  margin-left: auto; font-size: 10px; font-weight: 600; white-space: nowrap;
  padding: 1px 7px; border-radius: var(--r-pill);
  background: rgba(207,122,28,.18); color: #f0b46a;
}
.nav-link.is-maint { opacity: .55; }
.bell-spacer { margin-left: auto; }
.maint-banner {
  display: flex; align-items: center; gap: 10px; margin-bottom: 18px;
  padding: 10px 14px; border-radius: var(--r); font-size: 13.5px;
  background: var(--warn-sft); border: 1px solid #f0d3a8; color: #7a4a0c;
}
.maint-banner svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--warn); }
.maint-banner a { margin-left: auto; font-weight: 600; color: var(--navy); white-space: nowrap; }
.blocked-page {
  max-width: 520px; margin: 48px auto; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 36px 28px; box-shadow: var(--sh-1);
}
.blocked-page h2 { font-size: 20px; margin: 14px 0 6px; }
.blocked-page p { color: var(--muted); margin: 0 0 20px; }
.blocked-ic {
  display: inline-grid; place-items: center; width: 58px; height: 58px; border-radius: 16px;
  background: var(--warn-sft); color: var(--warn);
}
.blocked-ic svg { width: 28px; height: 28px; }
.maint-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.maint-card {
  width: 100%; max-width: 480px; text-align: center; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-lg); padding: 38px 28px; box-shadow: var(--sh-2);
}
.maint-card h1 { font-size: 22px; margin: 16px 0 8px; }
.maint-card p { color: var(--muted); margin: 0 0 16px; }
.maint-until {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; margin-bottom: 18px;
  border-radius: var(--r-pill); background: var(--warn-sft); color: #7a4a0c; font-size: 13.5px;
}
.maint-until svg { width: 16px; height: 16px; }
.maint-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.maint-who { margin-top: 18px; font-size: 12.5px; color: var(--faint); }
.maint-note {
  display: flex; gap: 10px; margin-bottom: 18px; padding: 12px 14px; border-radius: var(--r);
  background: var(--warn-sft); border: 1px solid #f0d3a8; color: #7a4a0c; font-size: 13px; line-height: 1.55;
}
.maint-note svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--warn); margin-top: 2px; }
.maint-note small { display: block; margin-top: 4px; color: #9a6a2a; }
.maint-modes { display: flex; gap: 8px; flex-wrap: wrap; }
.maint-mode {
  display: flex; align-items: center; gap: 8px; padding: 9px 14px; cursor: pointer;
  border: 1px solid var(--border-2); border-radius: var(--r-sm); font-size: 13.5px; font-weight: 500;
}
.maint-mode:has(input:checked) { border-color: var(--warn); background: var(--warn-sft); color: #7a4a0c; }
.maint-mode input { accent-color: var(--warn); }
.maint-menus { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.maint-menus fieldset { border: 1px solid var(--border); border-radius: var(--r-sm); padding: 8px 12px 10px; margin: 0; }
.maint-menus legend { font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 4px; }
.maint-menus label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; padding: 3px 0; cursor: pointer; }
.maint-state {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  padding: 3px 10px; border-radius: var(--r-pill); margin-left: auto;
}
.maint-state.on { background: var(--warn-sft); color: #9a5a0c; }
.maint-state.off { background: var(--emerald-sft); color: var(--emerald-d); }

@media print {
  .sidebar, .topbar, .scrim, .page-title .row-line, .no-print { display: none !important; }
  .main { margin-left: 0 !important; }
  .page { padding: 0 !important; }
  .panel { box-shadow: none !important; border-color: #ccc !important; }
}

/* SweetAlert tweaks */
.swal2-popup { font-family: 'IBM Plex Sans Thai', sans-serif !important; border-radius: var(--r-lg) !important; }
.swal2-styled { border-radius: 10px !important; font-weight: 600 !important; }
.swal2-styled.swal2-confirm { background: var(--navy) !important; }

/* ---------- mobile sidebar ---------- */
.scrim { position: fixed; inset: 0; background: rgba(11,24,40,.45); z-index: 55; display: none; }
.scrim.open { display: block; }
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--sh-pop); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .hamburger { display: grid; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
}
@media (max-width: 560px) {
  .page { padding: 16px; }
  .topbar { padding: 0 16px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .c2,.c3,.c4,.c6,.c8 { grid-column: span 12; }
  .userchip .u-meta { display: none; }
}
