/* Minimal theme: white surfaces, one accent, hairline borders, generous spacing. */
:root {
  --bg: #f6f7f9; --card: #fff; --ink: #1f2430; --muted: #6e7483; --faint: #9aa0ac; --line: #e6e8ec;
  --brand: #2456c9; --brand-soft: #edf2fd;
  --declared: #f3f7fe; --found: #fef8f0; --result: #f2f9f3;
  --ok: #eaf6ee; --ok-ink: #1d6b3c; --err: #fdeeee; --err-ink: #a12020;
  --red: #c62828; --green: #2e7d32; --calc: #f7f8fa;
  --radius: 10px; --shadow: 0 1px 2px rgba(20, 24, 33, .04);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 "Sarabun", "TH Sarabun New", "Leelawadee UI", "Tahoma", system-ui, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.3rem; font-weight: 600; margin: 0 0 .75rem; }
h2 { font-size: 1rem; font-weight: 600; margin: 0 0 .75rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
h3 { font-size: .95rem; font-weight: 600; margin: 0 0 .6rem; display: flex; align-items: center; gap: .75rem; }
code { background: #f0f2f5; padding: .1rem .35rem; border-radius: 4px; font-size: .85em; }
.muted, .hint { color: var(--muted); font-size: .87rem; font-weight: normal; }
.grow { flex: 1; }

/* ---- top bar ---- */
.topbar { display: flex; align-items: center; gap: 1.75rem; background: var(--card); border-bottom: 1px solid var(--line);
  padding: 0 1.25rem; height: 54px; position: relative; z-index: 20; }
.topbar a { color: var(--ink); text-decoration: none; }
.brand { font-weight: 700; display: flex; align-items: center; gap: .5rem; white-space: nowrap; }
.brand::before { content: ""; width: 10px; height: 10px; border-radius: 3px; background: var(--brand); }
.topbar nav { display: flex; gap: .15rem; flex: 1; height: 100%; overflow-x: auto; }
.topbar nav a { display: flex; align-items: center; padding: 0 .8rem; color: var(--muted); border-bottom: 2px solid transparent;
  white-space: nowrap; }
.topbar nav a:hover { color: var(--ink); text-decoration: none; }
.topbar nav a.on { color: var(--ink); border-bottom-color: var(--brand); font-weight: 600; }
.me { position: relative; }
.me > button { display: flex; align-items: center; gap: .5rem; border: 0; background: none; padding: .3rem .4rem; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-weight: 700; font-size: .9rem; }
button.link { background: none; border: 0; color: var(--brand); cursor: pointer; padding: 0; font: inherit; }
button.link:hover { text-decoration: underline; }

/* ---- dropdown menus ---- */
.menu { position: absolute; right: 0; top: calc(100% + 4px); min-width: 210px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 10px 30px rgba(20, 24, 33, .12); padding: .35rem; z-index: 50; }
.menu a, .menu button { display: flex; width: 100%; text-align: left; padding: .45rem .7rem; border: 0; border-radius: 6px;
  background: none; color: var(--ink); font: inherit; cursor: pointer; gap: .6rem; align-items: center; }
.menu a:hover, .menu button:hover:not(:disabled) { background: var(--bg); text-decoration: none; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: .3rem 0; }
.menu .menu-label { font-size: .78rem; color: var(--faint); padding: .35rem .7rem .15rem; }
.menu form { margin: 0; }
.menu-wrap { position: relative; display: inline-block; }
.menu.columns { max-height: 60vh; overflow: auto; min-width: 240px; }
.menu.columns label { flex-direction: row; align-items: center; gap: .55rem; padding: .25rem .7rem; color: var(--ink); font-size: .92rem; cursor: pointer; }

/* ---- layout ---- */
main { max-width: 1180px; margin: 0 auto; padding: 1.25rem 1.25rem 3rem; }
main.wide { max-width: none; }
main.narrow { max-width: 600px; }
main.narrow-wide { max-width: 900px; }
body.fullheight { height: 100vh; display: flex; flex-direction: column; }
body.fullheight main { flex: 1; display: flex; flex-direction: column; min-height: 0; padding-bottom: 1rem; width: 100%; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.15rem 1.25rem;
  margin-bottom: 1rem; box-shadow: var(--shadow); }
.pagehead { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin: 0 0 1rem; flex-wrap: wrap; }
.pagehead h1 { margin: 0; }
.toolbar-inline { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---- form controls ---- */
label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--muted); }
label.inline { flex-direction: row; align-items: center; gap: .5rem; color: var(--ink); font-size: .95rem; }
input, select, textarea { font: inherit; color: var(--ink); padding: .45rem .6rem; border: 1px solid #d5d9e0;
  border-radius: 8px; background: #fff; min-width: 0; width: 100%; transition: border-color .15s, box-shadow .15s; }
input[type=checkbox] { width: auto; accent-color: var(--brand); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input::placeholder { color: var(--faint); }
input.tiny { width: 5rem; }
input.invalid { border-color: var(--red); background: var(--err); }
button, .button { font: inherit; padding: .45rem .95rem; border-radius: 8px; border: 1px solid #d5d9e0; background: #fff;
  color: var(--ink); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: .4rem;
  white-space: nowrap; line-height: 1.4; transition: background .15s, border-color .15s; }
button:hover:not(:disabled), .button:hover { border-color: #b9bfca; background: #fafbfc; text-decoration: none; }
button:disabled { opacity: .4; cursor: not-allowed; }
button.primary, .button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover:not(:disabled), .button.primary:hover { background: #1d48ad; border-color: #1d48ad; }
button.ghost, .button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
button.ghost:hover:not(:disabled), .button.ghost:hover { background: #eef0f3; color: var(--ink); border-color: transparent; }
button.danger { border-color: #f0c9c9; color: var(--red); }
button.danger:hover:not(:disabled) { background: var(--err); border-color: #e6a9a9; }
button.small, .button.small { padding: .2rem .6rem; font-size: .85rem; }
button.icon { padding: .4rem .6rem; }
.stack { display: flex; flex-direction: column; gap: .9rem; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .8rem 1rem; align-items: end; }
.fields .span2 { grid-column: span 2; }
label.error input, label.error select { border-color: var(--red); background: var(--err); }
.field-error { color: var(--err-ink); font-size: .8rem; }
.badge { display: inline-grid; place-items: center; min-width: 1.25rem; height: 1.25rem; padding: 0 .35rem; border-radius: 99px;
  background: var(--brand); color: #fff; font-size: .75rem; font-weight: 700; }

/* ---- flash / toast ---- */
.flash { padding: .65rem .95rem; border-radius: var(--radius); margin-bottom: 1rem; background: var(--ok); color: var(--ok-ink); }
.flash.error { background: var(--err); color: var(--err-ink); }
.errors { color: var(--err-ink); max-height: 300px; overflow: auto; }
#toasts { position: fixed; right: 1.25rem; bottom: 1.25rem; display: flex; flex-direction: column; gap: .5rem; z-index: 1000; max-width: min(440px, 90vw); }
.toast { padding: .65rem 1rem; border-radius: var(--radius); background: #1f2430; color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.18);
  transition: opacity .4s, transform .4s; }
.toast.error { background: var(--err-ink); }
.toast.out { opacity: 0; transform: translateY(8px); }

/* ---- filter bar: search + dates always visible, the rest behind "ตัวกรอง" ---- */
.filters { margin-bottom: .9rem; }
.filters .filter-main { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.filters .search { flex: 1 1 260px; position: relative; }
.filters .search input { padding-left: 2.1rem; }
.filters .search::before { content: ""; position: absolute; left: .75rem; top: 50%; width: 12px; height: 12px; margin-top: -8px;
  border: 2px solid var(--faint); border-radius: 50%; }
.filters .search::after { content: ""; position: absolute; left: 1.55rem; top: 50%; width: 6px; height: 2px; margin-top: 4px;
  background: var(--faint); transform: rotate(45deg); }
.filters .dates { display: flex; gap: .35rem; align-items: center; color: var(--muted); }
.filters .dates input { width: 150px; }
.filters .dates select { width: 140px; }
.filters .filter-more { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .6rem .8rem;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem 1rem; margin-top: .55rem; }
.filters label.active select, .filters label.active input { border-color: var(--brand); background: var(--brand-soft); }
.filters .dates input.active, .filters .dates select.active { border-color: var(--brand); background: var(--brand-soft); }
.chip { padding: .15rem .7rem; border-radius: 99px; font-size: .85rem; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---- master grid ---- */
.toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .6rem; min-height: 40px; }
.selection-bar { display: flex; gap: .4rem; align-items: center; background: var(--brand-soft); border-radius: 8px; padding: .2rem .3rem .2rem .8rem; }
.selection-bar > span { color: var(--brand); font-weight: 600; margin-right: .25rem; }
.summary { display: flex; gap: 1.1rem; flex-wrap: wrap; color: var(--muted); font-size: .9rem; }
.summary b { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 600; }
#grid { flex: 1; min-height: 420px; width: 100%; }
.ag-theme-quartz {
  --ag-font-family: "Sarabun", "TH Sarabun New", "Leelawadee UI", "Tahoma", system-ui, sans-serif;
  --ag-font-size: 14px; --ag-row-height: 38px; --ag-header-height: 40px;
  --ag-active-color: #2456c9; --ag-range-selection-border-color: #2456c9;
  --ag-border-color: #e6e8ec; --ag-row-border-color: #eef0f3; --ag-header-background-color: #fafbfc;
  --ag-header-foreground-color: #5c6271; --ag-wrapper-border-radius: 10px; --ag-odd-row-background-color: #fff;
  --ag-row-hover-color: #f6f8fc; --ag-selected-row-background-color: #edf2fd;
}
.ag-theme-quartz .ag-header-cell-text { font-weight: 600; }
.ag-theme-quartz .calc { background: var(--calc); color: #4a5060; }
.ag-theme-quartz .short-pos { color: var(--red); font-weight: 600; }
.ag-theme-quartz .short-neg { color: var(--green); font-weight: 600; }
.ag-theme-quartz .changed { background: #fff7dc; }
.ag-theme-quartz .code-R { color: var(--red); font-weight: 700; }
.ag-theme-quartz .code-G { color: var(--green); font-weight: 700; }
.ag-theme-quartz .code-Y { color: #9a7400; font-weight: 700; }
.ag-theme-quartz .grp-d { box-shadow: inset 0 -2px 0 #9dbcf0; }
.ag-theme-quartz .grp-f { box-shadow: inset 0 -2px 0 #f0c48c; }
.ag-theme-quartz .grp-r { box-shadow: inset 0 -2px 0 #9fd2a6; }
.ag-theme-quartz .ag-floating-bottom .ag-row { font-weight: 700; background: #fafbfc; }

/* ---- dialogs ---- */
dialog { border: 0; border-radius: 14px; padding: 0; box-shadow: 0 24px 64px rgba(0,0,0,.22); max-height: 92vh; color: var(--ink); }
dialog::backdrop { background: rgba(20, 24, 33, .4); }
dialog.confirm { padding: 1.4rem 1.5rem; max-width: 440px; }
dialog.confirm p { margin: 0 0 1.1rem; }
.row-dialog { width: min(1040px, 96vw); }
.row-dialog form { display: flex; flex-direction: column; max-height: 92vh; }
.row-dialog header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.4rem; border-bottom: 1px solid var(--line); }
.row-dialog header h2 { margin: 0; font-size: 1.1rem; }
.row-dialog .close { text-decoration: none; font-size: 1.15rem; color: var(--muted); }
.dialog-body { padding: 1.1rem 1.4rem; overflow: auto; }
.dialog-body section { margin-bottom: 1.1rem; }
.row-dialog footer { padding: .8rem 1.4rem; border-top: 1px solid var(--line); }
.narrow-dialog { width: min(620px, 96vw); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.side-d, .side-f, .result { border-radius: var(--radius); padding: .95rem 1.05rem; }
.side-d { background: var(--declared); }
.side-f { background: var(--found); }
.result { background: var(--result); }
.computed { display: grid; grid-template-columns: auto 1fr; gap: .15rem 1rem; margin: .85rem 0 0; }
.computed dt { color: var(--muted); }
.computed dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.computed.big { max-width: 420px; font-size: 1.08rem; margin: 0; }
details.more { margin-top: .8rem; }
details.more > summary { cursor: pointer; color: var(--muted); font-size: .88rem; list-style: none; }
details.more > summary::before { content: "+ "; }
details.more[open] > summary::before { content: "– "; }
details.more > .fields { margin-top: .6rem; }
.pos { color: var(--red); }
.neg { color: var(--green); }
.thai-date { color: var(--brand); }
.actions-bar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.history-item { border-bottom: 1px solid var(--line); padding: .55rem 0; }
.history-item ul { margin: .25rem 0 0; padding-left: 1.2rem; font-size: .9rem; }

/* ---- dashboard ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1.05rem;
  display: flex; flex-direction: column; gap: .1rem; box-shadow: var(--shadow); }
.kpi span { color: var(--muted); font-size: .85rem; }
.kpi b { font-size: 1.35rem; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.3; }
.kpi small { color: var(--muted); font-size: .8rem; }
.kpi.hero { grid-column: span 2; }
.kpi.hero b { font-size: 2rem; }
.dash-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.dash-grid .card { margin: 0; min-width: 0; }
.dash-grid .span2 { grid-column: span 2; }
.dash-grid .span3 { grid-column: span 3; }
.chart { position: relative; height: 260px; }
.chart.tall { height: 290px; }

/* ---- plain tables (dashboard, settings, users, import) ---- */
.tablewrap { overflow-x: auto; }
table.grid { border-collapse: collapse; width: 100%; font-size: .92rem; }
.grid th, .grid td { border-bottom: 1px solid var(--line); padding: .5rem .6rem; text-align: left; vertical-align: top; }
.grid th { color: var(--muted); font-weight: 600; font-size: .85rem; white-space: nowrap; }
.grid tbody tr:hover td { background: #fafbfc; }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.grid .empty { text-align: center; color: var(--muted); padding: 1.5rem; }

/* ---- settings ---- */
.settings { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 1.5rem; }
.settings > div { min-width: 0; }
.tabs { display: flex; flex-direction: column; gap: .1rem; }
.tabs a { padding: .45rem .75rem; border-radius: 8px; text-decoration: none; color: var(--muted); }
.tabs a:hover { background: #eef0f3; color: var(--ink); }
.tabs a.on { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: inset 2px 0 0 var(--brand), var(--shadow); }
.tabs-label { font-size: .75rem; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; margin: .9rem .75rem .25rem; }
.tabs-label:first-child { margin-top: 0; }
.settings-table td { vertical-align: middle; }
.settings-table td form { margin: 0; }
.settings-table input, .settings-table textarea { padding: .35rem .5rem; }
.new-row td { background: #fafbfc; }
.row-actions { display: flex; gap: .3rem; }
.settings-table input.code { width: 9rem; }

/* ---- login ---- */
.login { margin-top: 9vh; padding: 1.75rem; }
.login h1 { text-align: center; margin-bottom: 1.25rem; }
.demo-bar { background: #fff4e5; color: #8a4b00; text-align: center; font-size: .82rem; padding: .3rem 1rem; border-bottom: 1px solid #f6dfbd; }
.instant-title { margin: 0 0 .5rem; font-weight: 600; font-size: .9rem; }
.instant-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.instant-buttons form { margin: 0; }
.instant-btn { width: 100%; height: 100%; text-align: left; white-space: normal; padding: .75rem .9rem;
  display: flex; flex-direction: column; align-items: flex-start; gap: .15rem; }
.instant-btn b { font-size: 1rem; }
.instant-btn small { font-size: .78rem; opacity: .8; }
.divider { display: flex; align-items: center; gap: .75rem; color: var(--faint); font-size: .85rem; margin: 1.25rem 0 .9rem; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

/* ---- reports (drawn like the Excel sheets) ---- */
.report-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin: 0 0 .75rem; }
.tabs-h { display: inline-flex; gap: .2rem; background: #eceef2; border-radius: 10px; padding: .2rem; flex-wrap: wrap; }
.tabs-h button { border: 0; background: transparent; color: var(--muted); border-radius: 8px; }
.tabs-h button:hover:not(:disabled) { background: transparent; color: var(--ink); }
.tabs-h button.on { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(20,24,33,.1); }
.company-chips { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; margin-bottom: .6rem; }
.report-sheet { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow); }
.sheet-scroll { overflow-x: auto; }
.sheet-title { font-weight: 700; font-size: 1.12rem; text-align: center; }
.sheet-subtitle { font-weight: 700; font-size: 1.02rem; text-align: center; margin-bottom: .7rem; }
.sheet-flex { display: flex; gap: 1.25rem; align-items: flex-start; }
/* screen uses normal digits; the Excel download keeps the original TH SarabunIT๙ (Thai digits) */
table.xl { border-collapse: collapse; font: 15px/1.35 "Sarabun", "TH SarabunPSK", "Leelawadee UI", "Tahoma", sans-serif; }
#arrest-table td:nth-child(9), #arrest-table td:nth-child(15) { min-width: 150px; }
#arrest-table td:nth-child(20), #seizure-table td:nth-child(18) { min-width: 220px; }
#seizure-table td:nth-child(12) { min-width: 190px; }
#seizure-table td:nth-child(13) { min-width: 150px; }
table.xl th, table.xl td { border: 1px solid #c3c9d3; padding: .25rem .5rem; vertical-align: middle; }
table.xl th { font-weight: 600; text-align: center; white-space: nowrap; background: #fff; }
table.xl td.c { text-align: center; }
table.xl td.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.xl td.r { text-align: right; }
table.xl td.b { font-weight: 700; }
table.xl td.nowrap { white-space: nowrap; }
table.xl td.mark { font-size: 1.1rem; color: var(--ink); }
table.xl td.code-R { color: var(--red); font-weight: 700; }
table.xl td.code-G { color: var(--green); font-weight: 700; }
table.xl tfoot td { font-weight: 700; background: #f6f7f9; }
table.xl tbody tr:hover td { background: #f6f9fe; }
table.xl .empty { text-align: center; color: var(--muted); padding: 1.5rem; }
/* header fills = the original sheets' theme colours at 80% tint */
table.xl .f-green, .f-green-all th { background: #e2efda; }
table.xl .f-slate { background: #d6dce4; }
table.xl .f-blue { background: #ddebf7; }
table.xl .f-orange { background: #fbe5d6; }
table.xl td.f-yellow { background: #fff2cc; }
.profile-table { min-width: 420px; max-width: 560px; }
.profile-table td:nth-child(2) { white-space: normal; }

/* ---- import ---- */
.steps { display: flex; gap: .5rem; list-style: none; padding: 0; margin: 0 0 1rem; color: var(--muted); flex-wrap: wrap; font-size: .88rem; }
.steps li { display: flex; align-items: center; gap: .5rem; }
.steps li + li::before { content: ""; width: 24px; border-top: 1px solid #cfd3da; }
.steps li.on { color: var(--brand); font-weight: 600; }
.steps li.done { color: var(--ok-ink); }
.dropzone { border: 1.5px dashed #c9ced6; border-radius: var(--radius); padding: 1.6rem; align-items: center; text-align: center;
  color: var(--ink); background: #fafbfc; gap: .6rem; }
.dropzone input { max-width: 420px; }
.import-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; margin: .5rem 0 1.1rem; }
.import-stats div { border: 1px solid var(--line); border-radius: var(--radius); padding: .65rem .85rem; display: flex; flex-direction: column; }
.import-stats b { font-size: 1.45rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.import-stats span { color: var(--muted); font-size: .85rem; }
.import-stats .good b { color: var(--green); }
.import-stats .bad b { color: var(--red); }

@media (max-width: 900px) {
  .topbar { gap: .75rem; padding: 0 .75rem; }
  .brand span { display: none; }
  .dash-grid { grid-template-columns: 1fr; }
  .dash-grid .span2, .dash-grid .span3, .kpi.hero { grid-column: auto; }
  .two-col, .settings { grid-template-columns: 1fr; }
  .fields .span2 { grid-column: auto; }
  .instant-buttons { grid-template-columns: 1fr; }
  .tabs { flex-direction: row; flex-wrap: wrap; }
  .tabs-label { display: none; }
  body.fullheight { height: auto; }
  #grid { flex: none; height: 75vh; }
  .filters .dates { flex-wrap: wrap; }
  .filters .dates input { width: 140px; }
}
@media (max-width: 700px) { .import-stats { grid-template-columns: repeat(2, 1fr); } .sheet-flex { flex-direction: column; } }
table.xl .lines > div { line-height: 1.35; }
table.xl .c-lines { text-align: center; }
#express-table td { vertical-align: top; }
.menu .menu-bulk { display: flex; gap: .3rem; padding: .2rem .3rem .35rem; border-bottom: 1px solid var(--line); margin-bottom: .2rem; }
.menu .menu-bulk button { flex: 1; justify-content: center; border: 1px solid var(--line); padding: .3rem .5rem; font-size: .85rem; }

/* ---- autocomplete (combo) ---- */
.combo { position: relative; }
.combo-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 60; margin: 0; padding: .3rem; list-style: none;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(20, 24, 33, .14);
  max-height: 260px; overflow: auto; min-width: 280px; }
.combo-list li { display: flex; gap: .6rem; align-items: baseline; padding: .4rem .6rem; border-radius: 6px; cursor: pointer; color: var(--ink); }
.combo-list li b { font-weight: 600; font-variant-numeric: tabular-nums; min-width: 4.5rem; }
.combo-list li span { color: var(--muted); }
.combo-list li.on, .combo-list li:hover { background: var(--brand-soft); }
.combo-list li.on span { color: var(--ink); }
.combo-list li.inactive { opacity: .55; }
.combo-list li.empty { color: var(--muted); cursor: default; background: none; }
input.autofilled, select.autofilled { animation: autofill 1.6s ease-out; }
@keyframes autofill { 0% { background: #dbe7fd; border-color: var(--brand); } 100% { background: #fff; } }
.combo-list li b { white-space: nowrap; }
.settings-table select { min-width: 9.5rem; }
.settings-table input:not(.tiny):not(.code):not([type=checkbox]) { min-width: 10rem; }
.settings-table td.row-actions { white-space: nowrap; }
@media (max-width: 1360px) {
  .settings { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .settings-table input:not(.tiny):not(.code):not([type=checkbox]) { min-width: 8rem; }
  .settings-table input.code { width: 7.5rem; }
  .tabs { flex-direction: row; flex-wrap: wrap; }
  .tabs-label { display: none; }
}
.instant-btn.wide { width: 100%; }
.instant-sub { margin: .9rem 0 .45rem; font-size: .88rem; font-weight: 600; }
.instant-buttons.teams { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }
.instant-buttons.teams .instant-btn { align-items: center; text-align: center; padding: .6rem .5rem; }

/* ---- memo templates ---- */
.inline-upload { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.inline-upload input[type=file] { max-width: 230px; font-size: .85rem; }
.nowrap { white-space: nowrap; }
.instant form + .instant-buttons { margin-top: .6rem; }

/* ---- สถานะคดี ---- */
.case-status-menu { left: 0; right: auto; }
.ag-theme-quartz .case-status { font-weight: 500; }
.ag-theme-quartz .cs-recorded { color: #8a5a00; }
.ag-theme-quartz .cs-ordered { color: #2456c9; }
.ag-theme-quartz .cs-sent { color: #6b3fb8; }
.ag-theme-quartz .cs-settled { color: #0f7a55; }
.ag-theme-quartz .cs-closed { color: #5c6271; }
.case-status-menu button { flex-direction: column; align-items: flex-start; gap: 0; }
.case-status-menu button small { font-size: .78rem; }
.case-status-menu button:disabled { color: var(--faint); cursor: not-allowed; }

/* ---- ติดตามสถานะคดี ---- */
.progress-tiles { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
a.progress-tile { color: inherit; display: flex; flex-direction: column; gap: .15rem; }
a.progress-tile:hover { text-decoration: none; border-color: #b9bfca; }
.progress-tile span { display: flex; align-items: center; gap: .4rem; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex: none; margin-right: .35rem;
  vertical-align: -1px; }
.progress-tile .swatch { margin-right: 0; }
.table-view { margin-top: .6rem; }
.table-view summary { cursor: pointer; color: var(--muted); font-size: .87rem; }

/* settings tables: the บันทึก / ลบ column stays in view when the table scrolls sideways */
.settings-table td.row-actions { display: table-cell; position: sticky; right: 0; background: var(--card);
  box-shadow: -8px 0 8px -8px rgba(29, 36, 51, .18); }
.settings-table td.row-actions form { display: inline-block; vertical-align: middle; }
.settings-table td.row-actions form + form { margin-left: .3rem; }
.settings-table thead th:last-child { position: sticky; right: 0; background: var(--card); }
.settings-table tr.new-row td.row-actions { background: #fafbfc; }
.chip.warn { background: #fff4dc; border-color: #f3d79a; color: #7a5300; }
tr.missing td:first-child b { color: var(--muted); }
