/* ==========================================================================
   XMCP Inbound Portal — "Accent ladder" app style on a ruled T-frame.
   Viettel red at full strength only on small marks (primary button, active
   icon, selected card edge); its pale tints carry the areas.
   ========================================================================== */

/* Self-hosted fonts: Sarabun for content, FS Magistral for emphasis */
@font-face { font-family: 'Sarabun'; src: url('../fonts/Sarabun-Medium.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Sarabun'; src: url('../fonts/Sarabun-Medium.ttf') format('truetype'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Sarabun'; src: url('../fonts/Sarabun-SemiBold.ttf') format('truetype'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Sarabun'; src: url('../fonts/Sarabun-Bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'FS Magistral'; src: url('../fonts/FSMagistral-Bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'FS Magistral'; src: url('../fonts/FSMagistral-ExtraBold.ttf') format('truetype'); font-weight: 800; font-display: swap; }

:root {
  /* Red ladder (built from brand #E61E23) */
  --accent: #e61e23;
  --accent-hover: #c9191e;
  --accent-pressed: #ab1419;
  --accent-soft: #fdeeee;
  --accent-track: #f9d4d5;
  --accent-ink: #8f1418;

  /* Ground & surfaces (ground one step toward the palest red tint) */
  --ground: #fbf6f6;
  --surface: #ffffff;
  --raised: #f6f0f0;
  --active: #f3e9e9;

  /* Ink — high contrast deep black for effortless reading */
  --text: #000000;
  --text-2: #111827;
  --muted: #374151;
  --faint: #4b5563;
  --inverse: #ffffff;

  /* Lines */
  --border: #eadfdf;
  --rule: #f1e9e9;
  --control: #d3c8c8;

  /* Status pills */
  --pos-bg: #dcfce7;
  --pos-fg: #14532d;
  --warn-bg: #fffbeb;
  --warn-fg: #92400e;
  --neg-bg: #ffedea;
  --neg-fg: #831c1e;
  --neu-bg: #f1eded;
  --neu-fg: #374151;

  --r-chip: 4px;
  --r-control: 6px;
  --r-card: 8px;

  --font-sans: 'Sarabun', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'FS Magistral', 'Sarabun', 'Segoe UI', sans-serif;

  /* Aliases used by inline styles in the views */
  --text-primary: var(--text);
  --text-secondary: var(--text-2);
  --text-muted: var(--muted);
  --text-faint: var(--faint);
  --border-sheet: var(--border);
  --surface-raised: var(--raised);
  --pill-negative-fg: var(--neg-fg);
  --radius-control: var(--r-control);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
}

a { color: inherit; }

.tabular-nums { font-variant-numeric: tabular-nums; }

/* Codes (plates, mooc, ERP codes) keep Sarabun; only the figures are aligned. */
.mono-code { font-variant-numeric: tabular-nums; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* FS Magistral only on headings that must stand out (and the wordmark). Everything else is Sarabun. */
.page-title,
.modal-title,
.brand-title,
.brand-mark,
.settings-info-title,
.empty-state-title,
.auth-title {
  font-family: var(--font-display);
}

/* ==========================================================================
   1. SHELL — sidebar + 64px top bar on one tinted ground, divided by rules
   ========================================================================== */
.app-frame { display: flex; min-height: 100vh; }

.app-sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--ground);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0 12px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 64px;
  padding: 0 6px;
  margin: 0 -12px 12px;
  padding-left: 18px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}

.brand-logo {
  width: 38px;
  height: 38px;
  object-fit: contain;
  flex-shrink: 0;
  display: block;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--r-control);
  background: var(--accent);
  color: var(--inverse);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: -0.02em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-title { font-size: 14.5px; font-weight: 700; line-height: 1.15; letter-spacing: -0.01em; }
.brand-subtitle { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }

.sidebar-section-label { font-size: 12px; font-weight: 500; color: var(--muted); padding: 14px 10px 6px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--r-control);
  color: var(--text-2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background-color .12s ease, color .12s ease;
}

.nav-item:hover { background: var(--active); color: var(--text); }

.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }

.nav-icon { width: 18px; height: 18px; stroke-width: 1.9; flex-shrink: 0; color: var(--muted); }
.nav-item.active .nav-icon { color: var(--accent); }

.sidebar-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }

.user-card { display: flex; align-items: center; gap: 10px; padding: 6px 6px 8px; }

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-track);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-name { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta { font-size: 12px; color: var(--muted); margin-top: 1px; }

.sidebar-footer-actions { display: flex; justify-content: space-between; gap: 4px; }

.footer-link {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  background: none;
  border: none;
  padding: 6px 8px;
  border-radius: var(--r-chip);
  cursor: pointer;
  font-family: inherit;
}

.footer-link:hover { background: var(--active); color: var(--text); }
.footer-link.danger { color: var(--neg-fg); }

.app-stage { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.app-topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  background: var(--ground);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-context { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 13.5px; }
.topbar-org { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-crumb { color: var(--muted); white-space: nowrap; }

.topbar-right { display: flex; align-items: center; gap: 12px; height: 100%; flex-shrink: 0; }
.topbar-clock { font-size: 13px; font-weight: 500; color: var(--text-2); }
.topbar-divider { width: 1px; height: 26px; background: var(--border); flex-shrink: 0; }

.topbar-logout-btn {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-control);
  color: var(--text-2);
  cursor: pointer;
  padding: 0;
  transition: background-color .12s ease, color .12s ease, border-color .12s ease;
}

.topbar-logout-btn svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.9;
}

.topbar-logout-btn:hover {
  background: var(--neg-bg);
  border-color: var(--accent-track);
  color: var(--neg-fg);
}

.work-sheet { flex: 1; background: var(--surface); padding: 26px 29px 32px; min-width: 0; }

/* ==========================================================================
   2. TITLE ROW, BUTTONS
   ========================================================================== */
.page-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-title { margin: 0; font-size: 28px; font-weight: 700; letter-spacing: -0.025em; line-height: 1.15; }
.page-subtitle { margin: 4px 0 0; font-size: 13.5px; color: var(--muted); }

.header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--r-control);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}

.btn-primary { background: var(--accent); color: var(--inverse); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-pressed); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--control); }
.btn-secondary:hover { background: var(--raised); border-color: #c4b8b8; }

.btn-ghost { background: transparent; color: var(--text); height: 32px; padding: 0 10px; font-size: 13px; font-weight: 500; }
.btn-ghost:hover { background: var(--accent-soft); color: var(--accent-ink); }

.btn-danger-ghost { background: transparent; color: var(--accent); border-color: transparent; height: 32px; padding: 0 10px; font-size: 13px; font-weight: 600; }
.btn-danger-ghost:hover { background: var(--neg-bg); color: var(--accent-hover); }

.btn-danger { background: var(--accent); color: var(--inverse); border-color: var(--accent); }
.btn-danger:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger:active { background: var(--accent-pressed); border-color: var(--accent-pressed); }

.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; }

/* ==========================================================================
   3. COUNT CARDS THAT FILTER (date scopes)
   ========================================================================== */
.count-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.count-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 13px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  text-decoration: none;
  color: var(--text);
  transition: border-color .12s ease, background-color .12s ease;
}

a.count-card:hover { border-color: var(--accent-track); background: #fffafa; }

.count-card.selected { border: 1.5px solid var(--accent); background: var(--accent-soft); padding: 12.5px 15.5px; }

.count-card.static { background: var(--ground); }

.count-card-label { font-size: 13px; font-weight: 500; color: var(--muted); }
.count-card.selected .count-card-label { color: var(--accent-ink); }

.count-card-value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.count-card-value small { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.count-card.selected .count-card-value { color: var(--accent-ink); }

/* KPI strip (ERP screen) */
.kpi-divided-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  background: var(--surface);
  margin-bottom: 20px;
}

.kpi-cell { padding: 14px 18px; border-right: 1px solid var(--border); }
.kpi-cell:last-child { border-right: none; }
.kpi-label { font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 4px; }
.kpi-value { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }

/* ==========================================================================
   4. FILTER BAR & CONTROLS
   ========================================================================== */
.filter-toolbar,
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.filter-group { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; }

.form-control,
.form-select {
  height: 38px;
  padding: 0 12px;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text);
  background-color: var(--surface);
  border: 1px solid var(--control);
  border-radius: var(--r-control);
  outline: none;
  transition: border-color .12s ease, box-shadow .12s ease;
}

.form-select,
.page-size-select {
  appearance: none;
  -webkit-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='%23374151' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 14px 14px;
  padding-right: 32px;
}

.form-select:focus,
.page-size-select:focus {
  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='%23374151' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='18 15 12 9 6 15'/%3E%3C/svg%3E");
}

.form-control::placeholder,
.form-textarea::placeholder { color: var(--faint); }

.form-control:focus,
.form-select:focus,
.form-textarea:focus,
.date-range-picker:focus-within,
.vn-date-control:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft); /* taste-skill-ignore: focus ring, not elevation */
}

.date-range-picker {
  display: inline-flex;
  align-items: center;
  height: 38px;
  padding: 0 10px;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--control);
  border-radius: var(--r-control);
  transition: border-color .12s ease, box-shadow .12s ease;
}

.date-range-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.date-range-sep {
  font-size: 13px;
  color: var(--muted);
  padding: 0 2px;
}

.vn-date-inline {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 2px;
  cursor: pointer;
}

.vn-date-control {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 38px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--control);
  border-radius: var(--r-control);
  cursor: pointer;
  transition: border-color .12s ease, box-shadow .12s ease;
}

.vn-date-text {
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.vn-date-icon {
  width: 15px;
  height: 15px;
  color: var(--muted);
  flex-shrink: 0;
}

.vn-date-native {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: none;
  margin: 0;
  padding: 0;
}

.form-textarea {
  width: 100%;
  min-height: 84px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--control);
  border-radius: var(--r-control);
  resize: vertical;
  outline: none;
}


/* ==========================================================================
   5. TABLE & MOBILE TWO-LINE LIST
   ========================================================================== */
.data-table-wrap {
  width: 100%;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
}

.clean-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.clean-table th {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.015em;
  color: var(--text-2);
  background: var(--ground);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.clean-table td {
  padding: 12px 14px;
  height: 52px;
  border-bottom: 1px solid var(--rule);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  vertical-align: middle;
}

.clean-table tbody tr:last-child td {
  border-bottom: none;
}

.clean-table tbody tr {
  transition: background-color .1s ease;
}

.clean-table tbody tr:hover {
  background: var(--accent-soft);
}

.plate-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  background: var(--ground);
  border: 1px solid var(--border);
  border-radius: var(--r-chip);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.code-pill { font-variant-numeric: tabular-nums; }

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--r-chip);
  white-space: nowrap;
}

.status-pill.positive { background: var(--pos-bg); color: var(--pos-fg); }
.status-pill.warning { background: var(--warn-bg); color: var(--warn-fg); }
.status-pill.negative { background: var(--neg-bg); color: var(--neg-fg); }
.status-pill.neutral { background: var(--neu-bg); color: var(--neu-fg); }
.status-pill.accent { background: var(--accent-soft); color: var(--accent-ink); }

.row-actions { display: inline-flex; align-items: center; gap: 2px; justify-content: flex-end; width: 100%; }

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 14px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.pagination-meta {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.pagination-summary {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.page-size-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

.page-size-select {
  height: 32px;
  padding: 0 28px 0 9px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background-color: var(--surface);
  background-position: right 8px center;
  border: 1px solid var(--control);
  border-radius: var(--r-control);
  cursor: pointer;
}

.page-size-select:focus {
  outline: none;
  border-color: var(--accent);
}

.pagination-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.page-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--control);
  border-radius: var(--r-control);
  text-decoration: none;
  cursor: pointer;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}

.page-btn:hover:not(.disabled):not(.active) {
  background: var(--active);
}

.page-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent-track);
  color: var(--accent-ink);
}

.page-btn.disabled {
  color: var(--muted);
  background: var(--ground);
  border-color: var(--border);
  pointer-events: none;
  cursor: default;
}

.page-ellipsis {
  padding: 0 6px;
  font-size: 13.5px;
  color: var(--muted);
}


.filter-search { width: 200px; }
.filter-select { max-width: 190px; }

.mobile-vehicle-list { display: none; }

.mobile-vehicle-item { padding: 12px 2px; border-bottom: 1px solid var(--rule); }

.mobile-vehicle-line1,
.mobile-vehicle-line2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mobile-vehicle-line1 { margin-bottom: 6px; }
.mobile-vehicle-line2 { font-size: 14px; color: var(--text); }

.mobile-plate-group { display: flex; align-items: center; gap: 8px; min-width: 0; }
.mobile-mooc { font-size: 14px; color: var(--text); white-space: nowrap; }
.mobile-date { font-size: 14px; color: var(--text); white-space: nowrap; font-variant-numeric: tabular-nums; }
.mobile-product { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mobile-vehicle-line2 .row-actions { width: auto; flex-shrink: 0; margin-right: -8px; }

/* ==========================================================================
   6. MODALS & FAST BATCH ENTRY
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(23, 24, 26, 0.48);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}

.modal-backdrop.open { display: flex; }

.modal-dialog {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 48px rgba(23, 24, 26, 0.22); /* taste-skill-ignore: dialog overlay */
}

.modal-dialog > form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  margin: 0;
}

.modal-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-title { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.015em; }

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 9px;
  border-radius: var(--r-chip);
}

.modal-close:hover { background: var(--active); color: var(--text); }

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 18px 20px;
  overflow-y: auto;
}

.modal-footer {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--ground);
}

.form-field { margin-bottom: 14px; }
.form-field:last-child { margin-bottom: 0; }

.field-label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.field-label { display: inline-block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.field-label-row .field-label { margin-bottom: 0; }
.field-optional { font-size: 12px; color: var(--muted); }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.modal-dialog-sm {
  max-width: 440px;
}

.delete-confirm-summary {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--neg-bg);
  border: 1px solid var(--accent-track);
  border-radius: var(--r-control);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13.5px;
  color: var(--text-2);
}

.delete-confirm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.delete-confirm-label {
  color: var(--muted);
  font-weight: 500;
}

.modal-dialog-lg {
  max-width: 740px;
  min-height: 540px;
  overflow: visible;
}

.modal-dialog-lg > form {
  overflow: visible;
}

.modal-dialog-lg .modal-header {
  padding: 22px 28px;
}

.modal-dialog-lg .modal-body {
  padding: 28px 28px 36px;
  overflow: visible;
}

.modal-dialog-lg .modal-footer {
  padding: 18px 28px;
  border-radius: 0 0 12px 12px;
}

.modal-dialog-lg .form-field {
  margin-bottom: 24px;
}

.modal-dialog-lg .form-field:last-child {
  margin-bottom: 0;
}

.modal-dialog-lg .form-grid-2 {
  gap: 20px;
}

.modal-dialog-lg .field-label-row {
  margin-bottom: 8px;
}

.modal-dialog-lg .form-control,
.modal-dialog-lg .form-select,
.modal-dialog-lg .erp-select-trigger {
  height: 42px;
}

.modal-dialog-lg .erp-select-list {
  max-height: 280px;
}

.quick-date-pills { display: inline-flex; gap: 6px; }

.date-chip-btn {
  border: 1px solid var(--control);
  background: var(--surface);
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.date-chip-btn:hover,
.date-chip-btn.active { background: var(--accent-soft); border-color: var(--accent-track); color: var(--accent-ink); }

.plate-chip-tray {
  margin-top: 8px;
  padding: 10px;
  max-height: 132px;
  overflow-y: auto;
  background: var(--ground);
  border: 1px dashed var(--accent-track);
  border-radius: var(--r-control);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: flex-start;
  align-content: flex-start;
}

.tokenized-plate-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 6px 3px 9px;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  background: var(--surface);
  border: 1.5px solid var(--text);
  border-radius: var(--r-chip);
  color: var(--text);
}

.tokenized-plate-chip.duplicate { background: var(--neg-bg); border-color: var(--neg-fg); color: var(--neg-fg); }

.chip-remove-btn {
  background: none;
  border: none;
  padding: 0 3px;
  font-size: 15px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

.chip-remove-btn:hover { color: var(--accent); }

.batch-count { font-size: 12.5px; font-weight: 700; color: var(--accent-ink); }

/* ==========================================================================
   7. ADMIN PANELS, BANNERS, EMPTY STATE
   ========================================================================== */
.settings-row {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 24px;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}

.settings-info-title { margin: 0 0 4px; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.settings-info-desc { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; }

.settings-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 18px 20px;
}

/* ==========================================================================
   7B. ERP SEARCHABLE DROPLIST & MASTER-DETAIL ACCOUNT LAYOUT
   ========================================================================== */
.erp-searchable-select {
  position: relative;
  width: 100%;
}

.erp-select-trigger {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--control);
  border-radius: var(--r-control);
  cursor: pointer;
  text-align: left;
}

.erp-select-trigger:hover,
.erp-searchable-select.open .erp-select-trigger {
  border-color: var(--accent);
}

.erp-select-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.erp-select-label.placeholder {
  color: var(--muted);
}

.erp-select-chevron {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  display: inline-block;
  font-size: 0;
  line-height: 0;
  color: transparent;
  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='%23374151' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 14px 14px;
}

.erp-searchable-select.open .erp-select-chevron {
  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='%23374151' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='18 15 12 9 6 15'/%3E%3C/svg%3E");
}

.erp-select-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 80;
  background: var(--surface);
  border: 1px solid var(--text-2);
  border-radius: var(--r-control);
  overflow: hidden;
}

.erp-searchable-select.open .erp-select-dropdown {
  display: block;
}

.erp-select-search-wrap {
  padding: 8px;
  background: var(--ground);
  border-bottom: 1px solid var(--border);
}

.erp-select-search {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--control);
  border-radius: var(--r-chip);
  outline: none;
}

.erp-select-search:focus {
  border-color: var(--accent);
}

.erp-select-list {
  max-height: 210px;
  overflow-y: auto;
}

.erp-select-option {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  border-bottom: 1px solid var(--rule);
  cursor: pointer;
}

.erp-select-option:last-child {
  border-bottom: none;
}

.erp-select-option:hover,
.erp-select-option.highlighted {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.erp-select-option.selected {
  background: var(--active);
  font-weight: 600;
}

.erp-opt-code {
  flex-shrink: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.erp-opt-sep {
  flex-shrink: 0;
  color: var(--muted);
}

.erp-opt-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.erp-select-empty {
  padding: 14px 12px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.account-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: stretch;
  margin-bottom: 20px;
}

.back-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
  text-decoration: none;
  margin-bottom: 6px;
}

.back-nav-link:hover {
  color: var(--accent);
}

.detail-meta-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
  font-size: 13.5px;
  color: var(--text-2);
}

.readonly-box {
  background: var(--ground);
  color: var(--text-2);
}

.notice-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--r-control);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 16px;
}

.notice-banner.success { background: var(--pos-bg); color: var(--pos-fg); }
.notice-banner.error { background: var(--neg-bg); color: var(--neg-fg); }

.notice-close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: var(--r-chip);
  color: inherit;
  font-size: 18px;
  line-height: 1;
  opacity: 0.72;
  cursor: pointer;
}

.notice-close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.06);
}

.empty-state-box {
  text-align: center;
  padding: 44px 20px;
  background: var(--ground);
  border: 1px dashed var(--accent-track);
  border-radius: var(--r-card);
  margin-top: 8px;
}

.empty-state-title { margin: 0; font-size: 16px; font-weight: 700; }

/* ==========================================================================
   8. LOGIN
   ========================================================================== */
.auth-viewport {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--ground);
}

.auth-sheet {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 30px 28px;
}

/* ==========================================================================
   9. PHONE (< 768px): top bar + bottom bar, sheet becomes the screen
   ========================================================================== */
.mobile-topbar,
.mobile-bottom-bar { display: none; }

@media (max-width: 1023px) {
  .count-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .account-detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 767px) {
  .app-sidebar,
  .app-topbar { display: none; }

  .mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 90;
    height: 52px;
    padding: 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--ground);
    border-bottom: 1px solid var(--border);
  }

  .work-sheet { padding: 16px 16px 84px; }

  .page-header-row { margin-bottom: 12px; }
  .page-title { font-size: 22px; }
  .hide-on-phone { display: none; }

  .count-cards {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    margin: 0 -16px 12px;
    padding: 0 16px;
    scrollbar-width: none;
  }

  .count-card { flex: 0 0 auto; min-width: 128px; padding: 9px 12px; }
  .count-card.selected { padding: 8.5px 11.5px; }
  .count-card-value { font-size: 20px; }

  .kpi-divided-strip { grid-template-columns: 1fr 1fr; }
  .kpi-cell:nth-child(2) { border-right: none; }
  .kpi-cell:nth-child(-n+2) { border-bottom: 1px solid var(--border); }

  .filter-group .filter-search { flex: 1 1 100%; width: auto; }
  .date-range-picker { flex: 1 1 100%; width: 100%; max-width: 100%; justify-content: space-between; height: 42px; box-sizing: border-box; }
  .date-range-label { font-size: 12px; }
  .date-range-input { width: auto; flex: 1; min-width: 0; font-size: 13px; }

  .form-control,
  .form-select,
  .form-textarea { font-size: 16px; }

  .form-control,
  .form-select { height: 42px; }

  .form-grid-2,
  .settings-row { grid-template-columns: 1fr; gap: 10px; }

  .mobile-bottom-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    height: 60px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: var(--surface);
    border-top: 1px solid var(--border);
  }

  .mobile-nav-links { display: flex; gap: 4px; }

  .mobile-nav-link {
    padding: 8px 12px;
    border-radius: var(--r-control);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-2);
    text-decoration: none;
  }

  .mobile-nav-link.active { background: var(--accent-soft); color: var(--accent-ink); }

  .mobile-bottom-bar .btn-primary { height: 42px; padding: 0 16px; }
}

@media (max-width: 639px) {
  .desktop-table-only { display: none; }
  .mobile-vehicle-list { display: block; }
}
