/* ============================================================
   PACDASH — Modern dashboard theme (light + dark)
   ============================================================ */

:root,
[data-bs-theme="light"] {
  --pac-primary:        #2563eb;
  --pac-primary-600:    #1d4ed8;
  --pac-primary-soft:   rgba(37, 99, 235, .10);
  --pac-bg:             #f4f6fb;
  --pac-surface:        #ffffff;
  --pac-surface-2:      #f8fafc;
  --pac-border:         #e5e8ef;
  --pac-border-strong:  #d4d9e3;
  --pac-text:           #0f172a;
  --pac-text-muted:     #64748b;
  --pac-text-subtle:    #94a3b8;

  --pac-success:        #16a34a;
  --pac-warning:        #d97706;
  --pac-danger:         #dc2626;
  --pac-info:           #0891b2;
  --pac-purple:         #7c3aed;

  --pac-side-bg:        #0f172a;
  --pac-side-text:      #cbd5e1;
  --pac-side-muted:     #64748b;
  --pac-side-hover:     rgba(255, 255, 255, .06);
  --pac-side-active:    rgba(59, 130, 246, .18);
  --pac-side-border:    rgba(255, 255, 255, .06);

  --pac-topbar-bg:      rgba(255, 255, 255, .82);
  --pac-code-bg:        #f1f5f9;

  --pac-shadow-sm:      0 1px 2px rgba(15, 23, 42, .05);
  --pac-shadow:         0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --pac-shadow-md:      0 10px 24px -8px rgba(15, 23, 42, .12), 0 2px 6px rgba(15, 23, 42, .05);

  --pac-radius:         14px;
  --pac-radius-sm:      10px;
  --pac-side-w:         256px;
  --pac-side-w-mini:    76px;
  --pac-topbar-h:       64px;

  --bs-body-bg:         var(--pac-bg);
  --bs-body-color:      var(--pac-text);
  --bs-border-color:    var(--pac-border);
  --bs-primary:         var(--pac-primary);
  --bs-primary-rgb:     37, 99, 235;
  --bs-link-color:      var(--pac-primary);
  --bs-link-color-rgb:  37, 99, 235;
  --bs-link-hover-color: var(--pac-primary-600);
}

[data-bs-theme="dark"] {
  --pac-primary:        #3b82f6;
  --pac-primary-600:    #60a5fa;
  --pac-primary-soft:   rgba(59, 130, 246, .16);
  --pac-bg:             #0b1120;
  --pac-surface:        #111827;
  --pac-surface-2:      #172033;
  --pac-border:         #1f2a3d;
  --pac-border-strong:  #2b3850;
  --pac-text:           #e5e7eb;
  --pac-text-muted:     #94a3b8;
  --pac-text-subtle:    #64748b;

  --pac-success:        #22c55e;
  --pac-warning:        #f59e0b;
  --pac-danger:         #f87171;
  --pac-info:           #22d3ee;
  --pac-purple:         #a78bfa;

  --pac-side-bg:        #080d1a;
  --pac-side-border:    rgba(255, 255, 255, .05);

  --pac-topbar-bg:      rgba(11, 17, 32, .78);
  --pac-code-bg:        #1b2438;

  --pac-shadow-sm:      0 1px 2px rgba(0, 0, 0, .3);
  --pac-shadow:         0 1px 3px rgba(0, 0, 0, .35);
  --pac-shadow-md:      0 12px 28px -10px rgba(0, 0, 0, .6);

  --bs-body-bg:         var(--pac-bg);
  --bs-body-color:      var(--pac-text);
  --bs-border-color:    var(--pac-border);
  --bs-primary-rgb:     59, 130, 246;
  --bs-link-color:      #60a5fa;
  --bs-link-color-rgb:  96, 165, 250;
  --bs-link-hover-color: #93c5fd;
}

/* ---------- Base ---------- */
html {
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
}
@media (min-width: 1200px) { html { font-size: 15px; } }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--pac-bg);
  font-family: "Inter", "Noto Sans Thai", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--pac-text);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01", "tnum";
}

::selection { background: var(--pac-primary-soft); }

.btn { border-radius: var(--pac-radius-sm); font-weight: 500; }
.btn-primary {
  --bs-btn-bg: var(--pac-primary);
  --bs-btn-border-color: var(--pac-primary);
  --bs-btn-hover-bg: var(--pac-primary-600);
  --bs-btn-hover-border-color: var(--pac-primary-600);
  --bs-btn-active-bg: var(--pac-primary-600);
  --bs-btn-disabled-bg: var(--pac-primary);
  --bs-btn-disabled-border-color: var(--pac-primary);
  box-shadow: 0 1px 2px rgba(37, 99, 235, .25);
}
.btn:focus-visible,
.form-control:focus,
.form-check-input:focus {
  box-shadow: 0 0 0 .22rem var(--pac-primary-soft);
  border-color: var(--pac-primary);
}
.form-control {
  border-radius: var(--pac-radius-sm);
  border-color: var(--pac-border-strong);
  background-color: var(--pac-surface);
  color: var(--pac-text);
}
.form-control::placeholder { color: var(--pac-text-subtle); }

code {
  background: var(--pac-code-bg);
  color: var(--pac-text);
  padding: .12rem .4rem;
  border-radius: 6px;
  font-size: .82em;
}

/* ---------- Sidebar ---------- */
.side-menu {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--pac-side-w);
  background: var(--pac-side-bg);
  color: var(--pac-side-text);
  display: flex;
  flex-direction: column;
  z-index: 1035;
  border-right: 1px solid var(--pac-side-border);
  transition: width .22s ease, transform .22s ease;
}

.side-brand {
  height: var(--pac-topbar-h);
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 0 1.1rem;
  text-decoration: none;
  border-bottom: 1px solid var(--pac-side-border);
  flex-shrink: 0;
}
.side-brand .brand-mark {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .1);
}
.side-brand .brand-mark img { max-width: 34px; max-height: 30px; object-fit: contain; }
.side-brand .brand-text { display: flex; flex-direction: column; line-height: 1.15; white-space: nowrap; }
.side-brand .brand-name { color: #fff; font-weight: 700; font-size: 1.05rem; letter-spacing: .02em; }
.side-brand .brand-tag  { color: var(--pac-side-muted); font-size: .72rem; font-weight: 500; }

.side-scroll { flex: 1; overflow-y: auto; padding: .75rem .75rem 1rem; }

.side-menu .nav-section {
  font-size: .68rem;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: .12em;
  color: var(--pac-side-muted);
  padding: 1rem .75rem .45rem;
  white-space: nowrap;
}

.side-nav { gap: 2px; }
.side-nav .nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: .75rem;
  color: var(--pac-side-text);
  padding: .6rem .8rem;
  border-radius: 10px;
  font-size: .92rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.side-nav .nav-link .icon { font-size: 1.1rem; width: 22px; text-align: center; flex-shrink: 0; opacity: .85; }
.side-nav .nav-link:hover { background: var(--pac-side-hover); color: #fff; }
.side-nav .nav-link.active {
  background: var(--pac-side-active);
  color: #fff;
  font-weight: 600;
}
.side-nav .nav-link.active .icon { color: #60a5fa; opacity: 1; }
.side-nav .nav-link.active::before {
  content: "";
  position: absolute;
  left: -.75rem; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: #3b82f6;
}

.side-footer { padding: .9rem; border-top: 1px solid var(--pac-side-border); flex-shrink: 0; }
.side-meta {
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--pac-side-border);
  border-radius: 10px;
  padding: .65rem .8rem;
  font-size: .78rem;
  display: grid;
  gap: .3rem;
  white-space: nowrap;
}
.side-meta div { display: flex; justify-content: space-between; gap: .5rem; }
.side-meta span   { color: var(--pac-side-muted); }
.side-meta strong { color: #fff; font-weight: 600; }

/* Desktop collapsed (icon-only) */
.side-menu.collapsed { width: var(--pac-side-w-mini); }
.side-menu.collapsed .brand-text,
.side-menu.collapsed .nav-link .label,
.side-menu.collapsed .nav-section,
.side-menu.collapsed .side-footer { display: none; }
.side-menu.collapsed .side-brand { justify-content: center; padding: 0; }
.side-menu.collapsed .nav-link { justify-content: center; padding: .65rem; }
.side-menu.collapsed .side-scroll { padding-top: 1.25rem; }
.side-menu.collapsed .side-nav + .nav-section + .side-nav,
.side-menu.collapsed .side-nav ~ .side-nav {
  margin-top: .75rem; padding-top: .75rem; border-top: 1px solid var(--pac-side-border);
}

/* ---------- App shell ---------- */
.app-shell {
  margin-left: var(--pac-side-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left .22s ease;
}
.side-menu.collapsed ~ .app-shell { margin-left: var(--pac-side-w-mini); }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  height: var(--pac-topbar-h);
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: 0 1.5rem;
  background: var(--pac-topbar-bg);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--pac-border);
}
.topbar-title { display: flex; align-items: center; gap: .5rem; min-width: 0; font-size: .92rem; }
.topbar-title .crumb { color: var(--pac-text-muted); }
.topbar-title .crumb-sep { color: var(--pac-text-subtle); font-size: .7rem; }
.topbar-title .crumb-current { font-weight: 600; color: var(--pac-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--pac-border);
  background: var(--pac-surface);
  color: var(--pac-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  padding: 0;
  transition: background .15s, color .15s, border-color .15s;
  flex-shrink: 0;
}
.icon-btn:hover { color: var(--pac-primary); border-color: var(--pac-border-strong); background: var(--pac-surface-2); }

.theme-icon-dark { display: none; }
[data-bs-theme="dark"] .theme-icon-light { display: none; }
[data-bs-theme="dark"] .theme-icon-dark  { display: inline; }

.meta-chip {
  align-items: center;
  gap: .4rem;
  height: 32px;
  padding: 0 .75rem;
  border-radius: 999px;
  border: 1px solid var(--pac-border);
  background: var(--pac-surface);
  color: var(--pac-text-muted);
  font-size: .8rem;
  font-weight: 500;
  white-space: nowrap;
}
.meta-chip i { color: var(--pac-primary); }

/* ---------- Main ---------- */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 1.75rem 1.75rem 2rem;
  width: 100%;
  max-width: 1680px;
  animation: pac-fade .25s ease-out;
}
@keyframes pac-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Page header ---------- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.page-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -.025em;
  color: var(--pac-text);
  display: flex;
  align-items: center;
  gap: .7rem;
}
.page-header h1 .ph-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--pac-primary);
  background: var(--pac-primary-soft);
}
.page-header .subtitle { color: var(--pac-text-muted); font-size: .9rem; margin-top: .3rem; }
.page-header .actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.search-box { position: relative; min-width: 300px; }
.search-box .bi-search {
  position: absolute; left: .8rem; top: 50%; transform: translateY(-50%);
  color: var(--pac-text-subtle); pointer-events: none;
}
.search-box .form-control { padding-left: 2.2rem; height: 38px; }
.search-form { display: flex; gap: .5rem; }
.search-form .btn { height: 38px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  height: 32px;
  padding: 0 .8rem;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 500;
  background: var(--pac-surface);
  border: 1px solid var(--pac-border);
  color: var(--pac-text-muted);
}
.pill.warn { background: rgba(217, 119, 6, .1); border-color: rgba(217, 119, 6, .25); color: var(--pac-warning); }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pac-success); box-shadow: 0 0 0 3px rgba(22, 163, 74, .18); }

/* ---------- Cards ---------- */
.chart-card,
.table-card,
.stat-card {
  background: var(--pac-surface);
  border: 1px solid var(--pac-border);
  border-radius: var(--pac-radius);
  box-shadow: var(--pac-shadow);
}
.chart-card,
.table-card { padding: 1.25rem 1.35rem; }
.chart-card { height: 100%; }
.row > * > .chart-card + .chart-card { margin-top: 1rem; height: auto; }

.chart-card h5,
.table-card h5 {
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -.01em;
  color: var(--pac-text);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.chart-card h5 i,
.table-card h5 i { color: var(--pac-text-subtle); font-size: 1rem; }
.card-sub { color: var(--pac-text-muted); font-size: .8rem; font-weight: 400; margin-left: auto; }
.chart-card .chart-wrap { position: relative; width: 100%; }

/* ---------- Stat cards ---------- */
.stat-card {
  --accent: var(--pac-primary);
  padding: 1.15rem 1.25rem;
  height: 100%;
  position: relative;
  overflow: hidden;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--pac-shadow-md); border-color: var(--pac-border-strong); }
.stat-card .stat-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
.stat-card .stat-body { min-width: 0; }
.stat-card .stat-label {
  font-size: .78rem;
  color: var(--pac-text-muted);
  font-weight: 500;
}
.stat-card .stat-value {
  font-size: 1.65rem;
  font-weight: 700;
  margin-top: .15rem;
  color: var(--pac-text);
  letter-spacing: -.025em;
  line-height: 1.2;
  word-break: break-word;
}
.stat-card .stat-sub { font-size: .78rem; color: var(--pac-text-subtle); margin-top: .2rem; }
.stat-card .stat-label-th { font-size: .82rem; color: var(--pac-text-muted); margin-top: 1px; font-weight: 500; }
.stat-card.success { --accent: var(--pac-success); }
.stat-card.warning { --accent: var(--pac-warning); }
.stat-card.danger  { --accent: var(--pac-danger); }
.stat-card.info    { --accent: var(--pac-info); }
.stat-card.purple  { --accent: var(--pac-purple); }

/* ---------- Tables ---------- */
.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--pac-text);
  --bs-table-border-color: var(--pac-border);
  --bs-table-hover-bg: var(--pac-surface-2);
  --bs-table-hover-color: var(--pac-text);
  --bs-table-striped-bg: var(--pac-surface-2);
  --bs-table-striped-color: var(--pac-text);
  margin-bottom: 0;
}
.table-card .table > :not(caption) > * > * {
  padding: .7rem .85rem;
  font-size: .875rem;
  border-bottom-color: var(--pac-border);
}
.table thead th,
.table-card .table thead th {
  background: var(--pac-surface-2) !important;
  color: var(--pac-text-muted) !important;
  font-weight: 600;
  font-size: .72rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
  border-bottom: 1px solid var(--pac-border);
}
.table-card .table thead th:first-child { border-top-left-radius: 8px; }
.table-card .table thead th:last-child  { border-top-right-radius: 8px; }
.table-card .table tbody tr:last-child td { border-bottom: 0; }
.table-card .table-flush { margin: -.25rem -.35rem; }

.table-borderless > :not(caption) > * > * { border: 0; }
.kv-table th { color: var(--pac-text-muted); font-weight: 500; }

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--pac-text-muted);
}
.empty-state i { font-size: 2.2rem; color: var(--pac-text-subtle); display: block; margin-bottom: .6rem; }

/* Pagination */
.pagination { gap: 4px; margin: 1rem 0 0; flex-wrap: wrap; }
.pagination .page-link {
  color: var(--pac-text-muted);
  background: var(--pac-surface);
  border-color: var(--pac-border);
  border-radius: 8px !important;
  min-width: 34px;
  text-align: center;
  font-size: .85rem;
}
.pagination .page-link:hover { background: var(--pac-surface-2); color: var(--pac-primary); }
.pagination .page-item.active .page-link {
  background-color: var(--pac-primary);
  border-color: var(--pac-primary);
  color: #fff;
}

/* ---------- Badges ---------- */
.badge-status {
  padding: .38em .7em;
  font-size: .74em;
  font-weight: 600;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  border: 1px solid transparent;
}
.badge-status::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-booked   { background: rgba(37, 99, 235, .1);  color: #1d4ed8; border-color: rgba(37, 99, 235, .2); }
.badge-onboard  { background: rgba(22, 163, 74, .1);  color: #15803d; border-color: rgba(22, 163, 74, .2); }
.badge-pending  { background: rgba(217, 119, 6, .1);  color: #b45309; border-color: rgba(217, 119, 6, .22); }
.badge-canceled { background: rgba(220, 38, 38, .08); color: #b91c1c; border-color: rgba(220, 38, 38, .2); }
.badge-info     { background: rgba(8, 145, 178, .1);  color: #0e7490; border-color: rgba(8, 145, 178, .22); }
.badge-warning  { background: rgba(217, 119, 6, .1);  color: #b45309; border-color: rgba(217, 119, 6, .22); }
[data-bs-theme="dark"] .badge-booked   { color: #93c5fd; }
[data-bs-theme="dark"] .badge-onboard  { color: #86efac; }
[data-bs-theme="dark"] .badge-pending  { color: #fcd34d; }
[data-bs-theme="dark"] .badge-canceled { color: #fca5a5; }
[data-bs-theme="dark"] .badge-info     { color: #67e8f9; }
[data-bs-theme="dark"] .badge-warning  { color: #fcd34d; }

.badge-soft {
  background: var(--pac-primary-soft);
  color: var(--pac-primary);
  font-weight: 600;
  border-radius: 8px;
  padding: .4em .65em;
}

/* ---------- Tracking groups ---------- */
.track-group {
  border: 1px solid var(--pac-border);
  border-radius: var(--pac-radius-sm);
  overflow: hidden;
  background: var(--pac-surface);
}
.track-group + .track-group { margin-top: 1rem; }
.track-group-head {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  padding: .75rem 1rem;
  background: var(--pac-surface-2);
  border-bottom: 1px solid var(--pac-border);
}
.track-group-head .meta { color: var(--pac-text-muted); font-size: .82rem; }
.track-group-head .count { margin-left: auto; color: var(--pac-text-subtle); font-size: .78rem; }
.track-group .table thead th { background: transparent !important; }

/* ---------- Steps (Sync flow) ---------- */
.steps { list-style: none; padding: 0; margin: 0; counter-reset: step; }
.steps li {
  position: relative;
  counter-increment: step;
  padding: 0 0 1rem 2.6rem;
  font-size: .86rem;
  color: var(--pac-text-muted);
}
.steps li:last-child { padding-bottom: 0; }
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: -1px;
  width: 26px; height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 600;
  color: var(--pac-primary);
  background: var(--pac-primary-soft);
}
.steps li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 12.5px; top: 28px; bottom: 2px;
  width: 1px;
  background: var(--pac-border-strong);
}

/* ---------- Alerts ---------- */
.alert {
  border-radius: var(--pac-radius-sm);
  font-size: .9rem;
  display: flex;
  gap: .6rem;
  align-items: flex-start;
}
.alert > i { font-size: 1.1rem; line-height: 1.3; }
.alert-dismissible { padding-right: 3rem; }

/* ---------- Dropdowns ---------- */
.dropdown-menu {
  border: 1px solid var(--pac-border);
  border-radius: var(--pac-radius-sm);
  box-shadow: var(--pac-shadow-md);
  padding: .35rem;
}
.dropdown-item { border-radius: 6px; }

/* ---------- Footer ---------- */
.footer {
  padding: 1rem 1.75rem;
  color: var(--pac-text-subtle);
  font-size: .8rem;
  border-top: 1px solid var(--pac-border);
}

/* ---------- Backdrop (mobile) ---------- */
.sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(2, 6, 23, .5);
  backdrop-filter: blur(2px);
  z-index: 1030;
  opacity: 0; visibility: hidden;
  transition: opacity .2s ease, visibility .2s ease;
}
.sidebar-backdrop.show { opacity: 1; visibility: visible; }

/* =================== RESPONSIVE =================== */
@media (max-width: 991.98px) {
  .side-menu {
    transform: translateX(-100%);
    box-shadow: 8px 0 32px rgba(2, 6, 23, .35);
  }
  .side-menu.show { transform: none; }
  .side-menu.collapsed { width: var(--pac-side-w); }
  .app-shell,
  .side-menu.collapsed ~ .app-shell { margin-left: 0; }
  .topbar { padding: 0 1rem; }
  .main-content { padding: 1.25rem 1rem 1.5rem; }
  .footer { padding: 1rem; }
}

@media (max-width: 575.98px) {
  .page-header h1 { font-size: 1.3rem; }
  .page-header h1 .ph-icon { width: 36px; height: 36px; font-size: 1rem; }
  .page-header > div:last-child,
  .page-header form,
  .search-box { width: 100%; min-width: 0; }
  .search-form .search-box { flex: 1; }
  .stat-card { padding: 1rem; }
  .stat-card .stat-value { font-size: 1.4rem; }
  .chart-card,
  .table-card { padding: 1rem; }
}

/* Mobile card-style table */
@media (max-width: 767.98px) {
  .table-card .table-responsive { border: 0; }
  .table-card .table thead { display: none; }
  .table-card .table tbody tr {
    display: block;
    margin-bottom: .75rem;
    border: 1px solid var(--pac-border);
    border-radius: var(--pac-radius-sm);
    background: var(--pac-surface);
    box-shadow: var(--pac-shadow-sm);
  }
  .table-card .table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .55rem .85rem;
    border: 0;
    border-bottom: 1px solid var(--pac-border);
    text-align: right !important;
    gap: .75rem;
  }
  .table-card .table tbody td:last-child { border-bottom: 0; }
  .table-card .table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--pac-text-muted);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    text-align: left;
    flex-shrink: 0;
    max-width: 55%;
  }
  .table-card .table tbody td[colspan] { justify-content: center; }
  .table-card .table tbody td[colspan]::before { content: none; }
}

/* ---------- Kendo Grid (Shipments page) ---------- */
.table-card .k-grid {
  border: 0;
  background: transparent;
  font-size: .875rem;
}
.table-card .k-grid-header,
.table-card .k-grid-content { background: transparent; }
.table-card .k-grid-header { border-bottom: 1px solid var(--pac-border); }
.table-card .k-grid-header th,
.table-card .k-grid td { border-color: var(--pac-border); }
.table-card .k-grid-header th {
  background: var(--pac-surface-2);
  font-weight: 600;
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--pac-text-muted);
  padding: .65rem .85rem;
}
.table-card .k-grid td { padding: .55rem .85rem; }
.table-card .k-grid code {
  background: var(--pac-code-bg, var(--pac-surface-2));
  color: var(--pac-text);
  padding: .15rem .4rem;
  border-radius: 4px;
  font-size: .82em;
  border: 1px solid var(--pac-border);
}
.table-card .k-grid-toolbar {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--pac-border);
  padding: .5rem 0 .85rem;
  margin-bottom: .75rem;
  gap: .5rem;
  flex-wrap: wrap;
}
.table-card .k-grid-toolbar .pacdash-grid-search {
  width: 280px;
  max-width: 100%;
  height: 36px;
  padding: .375rem .75rem;
  border-radius: var(--pac-radius-sm);
  border: 1px solid var(--pac-border);
  background: var(--pac-surface);
  margin-right: .25rem;
  color: var(--pac-text);
}
.table-card .k-grid-toolbar .pacdash-grid-search:focus {
  outline: none;
  border-color: var(--pac-primary);
  box-shadow: 0 0 0 .2rem rgba(37, 99, 235, .15);
}
.table-card .k-grid-toolbar .k-button {
  border-radius: var(--pac-radius-sm);
  font-weight: 500;
}
.table-card .k-pager {
  background: transparent;
  border-color: var(--pac-border);
  padding-top: .75rem;
}
.table-card .k-grid tr:hover { background: var(--pac-surface-2); }
.table-card .k-grid tr.k-alt { background: rgba(248, 250, 252, .5); }
.table-card .k-grid tr.k-alt:hover { background: var(--pac-surface-2); }

@media (max-width: 575.98px) {
  .table-card .k-grid-toolbar .pacdash-grid-search {
    width: 100%;
    margin-bottom: .5rem;
  }
  .table-card .k-grid-toolbar .k-button { flex: 1; }
}

/* ---------- Shipment tracking popup ---------- */
.table-card .k-grid tbody tr[data-uid] { cursor: pointer; }

.modal-content {
  background: var(--pac-surface);
  color: var(--pac-text);
  border: 1px solid var(--pac-border);
  border-radius: var(--pac-radius);
  box-shadow: var(--pac-shadow-md);
}
.modal-header,
.modal-footer { border-color: var(--pac-border); }
.modal-backdrop.show { opacity: .45; }

.trk-modal .modal-header { align-items: flex-start; gap: .75rem; padding: 1.1rem 1.35rem; }
.trk-modal .modal-title { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.trk-modal .modal-title .ph-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--pac-primary); background: var(--pac-primary-soft); font-size: 1rem;
}
.trk-modal .trk-route { color: var(--pac-text-muted); font-size: .85rem; margin-top: .2rem; }
.trk-modal .modal-body { padding: 1.25rem 1.35rem; }

.trk-summary {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .75rem 1rem;
  padding: .9rem 1rem;
  margin-bottom: 1.25rem;
  background: var(--pac-surface-2);
  border: 1px solid var(--pac-border);
  border-radius: var(--pac-radius-sm);
}
.trk-summary .k { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--pac-text-subtle); font-weight: 600; }
.trk-summary .v { font-size: .88rem; font-weight: 500; color: var(--pac-text); word-break: break-word; }

.trk-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.trk-heading h6 { margin: 0; font-weight: 600; }
.trk-heading .count { font-size: .8rem; color: var(--pac-text-muted); }

.trk-timeline { list-style: none; margin: 0; padding: 0; }
.trk-timeline li { position: relative; display: flex; gap: .9rem; padding-bottom: 1.1rem; }
.trk-timeline li:last-child { padding-bottom: 0; }
.trk-timeline li:not(:last-child)::before {
  content: "";
  position: absolute;
  left: 15px; top: 34px; bottom: 2px;
  width: 2px;
  background: var(--pac-border);
}
.trk-dot {
  width: 32px; height: 32px; border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .9rem;
  color: var(--pac-text-muted);
  background: var(--pac-surface-2);
  border: 1px solid var(--pac-border);
}
.trk-timeline li.latest .trk-dot {
  color: #fff;
  background: var(--pac-primary);
  border-color: var(--pac-primary);
  box-shadow: 0 0 0 4px var(--pac-primary-soft);
}
.trk-timeline li.void { opacity: .55; }
.trk-timeline li.void .trk-title { text-decoration: line-through; }
.trk-body { flex: 1; min-width: 0; padding-top: .2rem; }
.trk-top { display: flex; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }
.trk-title { font-weight: 600; font-size: .92rem; }
.trk-title code { font-size: .72rem; margin-left: .35rem; vertical-align: middle; }
.trk-when { font-size: .8rem; color: var(--pac-text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.trk-th { font-size: .85rem; color: var(--pac-text-muted); margin-top: .1rem; }
.trk-remark {
  font-size: .82rem;
  margin-top: .4rem;
  padding: .4rem .6rem;
  border-radius: 8px;
  background: var(--pac-surface-2);
  border: 1px solid var(--pac-border);
  color: var(--pac-text);
}
.trk-user { font-size: .75rem; color: var(--pac-text-subtle); margin-top: .3rem; }
.trk-state { text-align: center; padding: 2.5rem 1rem; color: var(--pac-text-muted); }
.trk-state i { font-size: 2rem; display: block; margin-bottom: .5rem; color: var(--pac-text-subtle); }

/* Comma-separated lists in grid cells (Invoice No / PO Number) */
.table-card .k-grid td.cell-list { white-space: normal; word-break: break-word; font-size: .8rem; line-height: 1.35; }
.trk-summary .wide { grid-column: 1 / -1; }

/* ============================================================
   Security: login page, user menu, admin screens
   ============================================================ */

/* ---------- Login ---------- */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background:
    radial-gradient(900px 500px at 0% 0%, rgba(37, 99, 235, .10), transparent 60%),
    radial-gradient(800px 500px at 100% 100%, rgba(124, 58, 237, .08), transparent 60%),
    var(--pac-bg);
}
.auth-shell {
  width: 100%;
  max-width: 920px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--pac-surface);
  border: 1px solid var(--pac-border);
  border-radius: 20px;
  box-shadow: var(--pac-shadow-md);
  overflow: hidden;
}
.auth-aside {
  background: linear-gradient(160deg, #0f172a 0%, #1e3a8a 100%);
  color: #cbd5e1;
  padding: 3rem 2.5rem;
  display: flex;
  align-items: center;
}
.auth-aside h2 { color: #fff; font-weight: 700; font-size: 1.6rem; margin: 1.25rem 0 .5rem; letter-spacing: -.02em; }
.auth-aside p { font-size: .92rem; margin-bottom: 1.5rem; }
.auth-aside ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .7rem; font-size: .9rem; }
.auth-aside li i { color: #60a5fa; margin-right: .5rem; }
.auth-logo {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.auth-logo img { max-width: 46px; max-height: 40px; object-fit: contain; }
.auth-logo.sm { width: 44px; height: 44px; border: 1px solid var(--pac-border); margin-bottom: 1rem; }
.auth-logo.sm img { max-width: 36px; max-height: 30px; }

.auth-card { padding: 3rem 2.5rem 2rem; }
.auth-card-head h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; margin: 0 0 .3rem; }
.auth-card-head p { color: var(--pac-text-muted); font-size: .92rem; margin-bottom: 1.75rem; }
.auth-foot { margin: 2rem 0 0; font-size: .75rem; color: var(--pac-text-subtle); text-align: center; }

.input-icon { position: relative; }
.input-icon > i {
  position: absolute; left: .85rem; top: 50%; transform: translateY(-50%);
  color: var(--pac-text-subtle); pointer-events: none;
}
.input-icon .form-control { padding-left: 2.5rem; height: 44px; }
.input-icon .input-reveal {
  position: absolute; right: .35rem; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: var(--pac-text-subtle);
  width: 36px; height: 36px; border-radius: 8px;
}
.input-icon .input-reveal:hover { color: var(--pac-primary); background: var(--pac-surface-2); }
.input-icon:has(.input-reveal) .form-control { padding-right: 2.75rem; }

.field-error { display: block; color: var(--pac-danger); font-size: .8rem; margin-top: .3rem; }
.field-error:empty { display: none; }
.form-hint { color: var(--pac-text-muted); font-size: .8rem; margin-top: .35rem; }
.form-label { font-weight: 500; font-size: .88rem; }
.form-select { border-radius: var(--pac-radius-sm); border-color: var(--pac-border-strong); background-color: var(--pac-surface); color: var(--pac-text); }
.form-actions { display: flex; gap: .5rem; margin-top: 1.5rem; }
.validation-summary-valid { display: none; }

@media (max-width: 991.98px) {
  .auth-shell { grid-template-columns: 1fr; max-width: 440px; }
  .auth-aside { display: none; }
  .auth-card { padding: 2rem 1.5rem 1.5rem; }
}

/* ---------- User menu ---------- */
.user-btn {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  height: 38px;
  padding: 0 .6rem 0 .3rem;
  border-radius: 999px;
  border: 1px solid var(--pac-border);
  background: var(--pac-surface);
  color: var(--pac-text);
}
.user-btn:hover { border-color: var(--pac-border-strong); background: var(--pac-surface-2); }
.user-text { flex-direction: column; line-height: 1.1; text-align: left; }
.user-name { font-size: .82rem; font-weight: 600; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-group { font-size: .7rem; color: var(--pac-text-muted); }
.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--pac-primary), var(--pac-purple));
  flex-shrink: 0;
  margin-right: .5rem;
  vertical-align: middle;
}
.user-btn .avatar { margin-right: 0; }
.dropdown-header { font-size: .78rem; }
.dropdown-item { font-size: .88rem; }

/* ---------- Admin screens ---------- */
.module-chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.module-chip {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .74rem; font-weight: 500;
  padding: .2rem .55rem;
  border-radius: 999px;
  background: var(--pac-surface-2);
  border: 1px solid var(--pac-border);
  color: var(--pac-text-muted);
  white-space: nowrap;
}
.module-chip i { color: var(--pac-primary); }

.perm-section {
  font-size: .7rem; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--pac-text-subtle);
  margin: 1rem 0 .5rem;
}
.perm-section:first-of-type { margin-top: 0; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .6rem; }
.perm-item {
  display: flex; align-items: flex-start; gap: .65rem;
  padding: .75rem .85rem;
  border: 1px solid var(--pac-border);
  border-radius: var(--pac-radius-sm);
  background: var(--pac-surface);
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.perm-item:hover { border-color: var(--pac-border-strong); }
.perm-item:has(input:checked) { border-color: var(--pac-primary); background: var(--pac-primary-soft); }
.perm-item:has(input:disabled) { cursor: default; }
.perm-item .form-check-input { margin-top: .2rem; flex-shrink: 0; }
.perm-icon {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--pac-primary); background: var(--pac-surface-2);
}
.perm-text { display: flex; flex-direction: column; min-width: 0; }
.perm-text strong { font-size: .88rem; font-weight: 600; }
.perm-text small { color: var(--pac-text-muted); font-size: .76rem; }

.state-card { text-align: center; padding: 3rem 1.5rem; max-width: 640px; margin: 2rem auto; height: auto; }
.state-card h1 { font-size: 1.3rem; font-weight: 700; margin: 1rem 0 .4rem; }
.state-card p { color: var(--pac-text-muted); }
.state-icon {
  width: 64px; height: 64px; border-radius: 18px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.8rem;
  color: var(--pac-primary); background: var(--pac-primary-soft);
}
.state-icon.danger { color: var(--pac-danger); background: rgba(220, 38, 38, .1); }
.state-links { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; margin-top: 1.25rem; }

/* ---------- Shipments help banner ---------- */
.shipments-help {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  border-radius: var(--pac-radius);
  border: 1px solid rgba(13, 202, 240, .25);
  background: linear-gradient(135deg, rgba(13, 202, 240, .08), rgba(13, 110, 253, .06));
  color: var(--pac-text);
  box-shadow: var(--pac-shadow-sm);
}
.shipments-help .help-icon {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--pac-primary);
  background: rgba(13, 110, 253, .12);
  box-shadow: 0 0 0 4px rgba(13, 110, 253, .06);
}
.shipments-help .help-body { flex: 1; min-width: 0; }
.shipments-help .help-title { font-weight: 500; line-height: 1.5; font-size: .92rem; }
.shipments-help .help-title strong { color: var(--pac-primary); font-weight: 600; }
.shipments-help .help-title .lang-pair,
.shipments-help .help-tip .lang-pair {
  display: inline;
}
.shipments-help .help-title .lang-en,
.shipments-help .help-tip .lang-en {
  display: inline;
  color: var(--pac-text);
}
.shipments-help .help-title .lang-th,
.shipments-help .help-tip .lang-th {
  display: inline;
  color: var(--pac-text-muted);
  font-weight: 400;
}
.shipments-help .lang-divider {
  display: inline-block;
  width: 1px;
  height: 0.9em;
  background: var(--pac-border-strong);
  margin: 0 .55em;
  vertical-align: -2px;
}
.shipments-help .help-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin-top: .55rem;
  font-size: .82rem;
  color: var(--pac-text-muted);
}
.shipments-help .help-tag {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .55rem;
  border-radius: 999px;
  background: rgba(13, 110, 253, .1);
  color: var(--pac-primary);
  font-weight: 600;
  font-size: .72rem;
  letter-spacing: .04em;
}
.shipments-help .help-tip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  margin-left: auto;
}
.shipments-help .btn-close { margin-left: .5rem; align-self: flex-start; }

@media (max-width: 575.98px) {
  .shipments-help { flex-direction: column; gap: .65rem; }
  .shipments-help .help-tip { margin-left: 0; }
  .shipments-help .help-title .lang-en,
  .shipments-help .help-tip .lang-en { display: block; }
  .shipments-help .help-title .lang-divider,
  .shipments-help .help-tip .lang-divider { display: none; }
  .shipments-help .help-title .lang-th,
  .shipments-help .help-tip .lang-th { display: block; margin-top: .25rem; }
}
