/*
 * ALEF Transport — X Platform Design System
 * Clean, minimal, white-first. Inspired by X (Twitter).
 */

/* ══════════════════════════════════════════════════════════════════════
   DESIGN TOKENS — X palette
══════════════════════════════════════════════════════════════════════ */
:root {
  /* X Blue */
  --x-blue:              #1D9BF0;
  --x-blue-hover:        #1A8CD8;
  --x-blue-surface:      rgba(29,155,240,0.10);
  --x-blue-border:       rgba(29,155,240,0.30);

  /* Surfaces */
  --md-bg:               #F7F9F9;
  --md-surface:          #FFFFFF;
  --md-surface-raised:   #FFFFFF;
  --md-surface-variant:  #F7F9F9;
  --md-surface-overlay:  rgba(255,255,255,0.97);

  /* Borders — X uses a very subtle warm gray */
  --md-border:           #EFF3F4;
  --md-border-strong:    #CFD9DE;
  --md-border-focus:     #1D9BF0;

  /* Text */
  --md-text:             #0F1419;
  --md-text-secondary:   #536471;
  --md-text-muted:       #8B98A5;
  --md-text-disabled:    #CFD9DE;

  /* Primary — X Blue */
  --md-primary:          #1D9BF0;
  --md-primary-hover:    #1A8CD8;
  --md-primary-surface:  rgba(29,155,240,0.10);
  --md-primary-border:   rgba(29,155,240,0.30);
  --md-primary-text:     #1D9BF0;
  --md-primary-muted:    #93C5FD;

  /* Semantic */
  --md-success:          #00BA7C;
  --md-success-surface:  #E6F8F3;
  --md-warning:          #FFD400;
  --md-warning-surface:  #FFFBCC;
  --md-danger:           #F4212E;
  --md-danger-surface:   #FEE2E4;
  --md-info:             #1D9BF0;
  --md-info-surface:     rgba(29,155,240,0.10);

  /* Sidebar — white, X style */
  --md-sidebar-bg:         #FFFFFF;
  --md-sidebar-border:     #EFF3F4;
  --md-sidebar-text:       #0F1419;
  --md-sidebar-text-hover: #0F1419;
  --md-sidebar-active-bg:  transparent;
  --md-sidebar-active-txt: #1D9BF0;

  /* Elevation — X uses almost no shadows */
  --md-shadow-sm:  0 1px 3px rgba(0,0,0,0.04);
  --md-shadow-md:  0 2px 8px rgba(0,0,0,0.06);
  --md-shadow-lg:  0 4px 16px rgba(0,0,0,0.08);
  --md-shadow-xl:  0 8px 32px rgba(0,0,0,0.10);

  /* Radius — X uses large pill radii */
  --md-radius-sm:    4px;
  --md-radius-md:    8px;
  --md-radius-lg:    16px;
  --md-radius-xl:    20px;
  --md-radius-pill:  9999px;

  /* Motion */
  --md-dur-fast:     80ms;
  --md-dur-base:     120ms;
  --md-dur-slow:     200ms;
  --md-ease:         cubic-bezier(0.4, 0, 0.2, 1);
}

/* ══════════════════════════════════════════════════════════════════════
   GLOBAL
══════════════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--md-bg);
  color: var(--md-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

[x-cloak] { display: none !important; }

/* ══════════════════════════════════════════════════════════════════════
   SCROLLBAR
══════════════════════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CFD9DE; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #8B98A5; }

/* ══════════════════════════════════════════════════════════════════════
   SIDEBAR — white, X-style
══════════════════════════════════════════════════════════════════════ */
.sidebar {
  background: var(--md-sidebar-bg);
  border-inline-end: 1px solid var(--md-border);
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--md-text-muted);
  padding: 0 12px;
  margin-bottom: 4px;
}

/* X nav item: large, hover shows light gray pill, active = blue text */
.nav-link {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 14px;
  border-radius: var(--md-radius-pill);
  font-size: 17px;
  font-weight: 400;
  color: var(--md-sidebar-text);
  transition: background var(--md-dur-base) var(--md-ease),
              color var(--md-dur-base) var(--md-ease);
  white-space: nowrap;
  position: relative;
}

.nav-link:hover {
  background: rgba(15,20,25,0.07);
  color: var(--md-text);
}

.nav-link.active {
  background: transparent;
  color: var(--x-blue);
  font-weight: 700;
}

/* No active bar — X uses bold + blue text only */
.nav-link.active::before { display: none; }

.nav-link .nav-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  opacity: 0.9;
  transition: opacity var(--md-dur-base) var(--md-ease);
}

.nav-link:hover .nav-icon,
.nav-link.active .nav-icon { opacity: 1; }

/* ══════════════════════════════════════════════════════════════════════
   CARDS
══════════════════════════════════════════════════════════════════════ */
.card {
  background: var(--md-surface);
  border: 1px solid var(--md-border);
  border-radius: var(--md-radius-lg);
  box-shadow: none;
}

.card-elevated {
  box-shadow: var(--md-shadow-sm);
}

.card-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--md-text);
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--md-border);
}

/* ══════════════════════════════════════════════════════════════════════
   BUTTONS — X-style pill buttons
══════════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--md-radius-pill);
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background var(--md-dur-base) var(--md-ease),
              color var(--md-dur-base) var(--md-ease),
              border-color var(--md-dur-base) var(--md-ease),
              transform var(--md-dur-fast) var(--md-ease);
  white-space: nowrap;
  user-select: none;
}

.btn:active { transform: scale(0.97); }

/* Primary — X Blue */
.btn-primary {
  background: var(--x-blue);
  color: #FFFFFF;
  border-color: var(--x-blue);
}
.btn-primary:hover {
  background: var(--x-blue-hover);
  border-color: var(--x-blue-hover);
}

/* Black — X also uses black as primary in some contexts */
.btn-black {
  background: #0F1419;
  color: #FFFFFF;
  border-color: #0F1419;
}
.btn-black:hover { background: #272C30; }

/* Tonal — light blue surface */
.btn-tonal {
  background: var(--x-blue-surface);
  color: var(--x-blue);
  border-color: transparent;
}
.btn-tonal:hover {
  background: rgba(29,155,240,0.15);
}

/* Outlined — X ghost button */
.btn-outline {
  background: transparent;
  color: var(--md-text);
  border-color: var(--md-border-strong);
}
.btn-outline:hover {
  background: rgba(15,20,25,0.05);
  border-color: var(--md-border-strong);
}

/* Danger */
.btn-danger {
  background: var(--md-danger);
  color: #FFFFFF;
  border-color: var(--md-danger);
}
.btn-danger:hover { background: #DC1822; border-color: #DC1822; }

/* Success */
.btn-green {
  background: var(--md-success);
  color: #FFFFFF;
  border-color: var(--md-success);
}
.btn-green:hover { background: #00A36C; }

/* Sizes */
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-xs { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* Icon-only */
.btn-icon {
  padding: 8px;
  border-radius: var(--md-radius-pill);
  background: transparent;
  border: 1px solid var(--md-border);
  color: var(--md-text-secondary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--md-dur-base) var(--md-ease);
}
.btn-icon:hover {
  background: rgba(15,20,25,0.07);
  color: var(--md-text);
}

/* ══════════════════════════════════════════════════════════════════════
   FORM ELEMENTS
══════════════════════════════════════════════════════════════════════ */
.label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--md-text-secondary);
  margin-bottom: 6px;
}

.label-required::after {
  content: ' *';
  color: var(--md-danger);
}

.input, .select {
  width: 100%;
  border: 1px solid var(--md-border-strong);
  border-radius: var(--md-radius-md);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  background: var(--md-surface);
  color: var(--md-text);
  transition: border-color var(--md-dur-base) var(--md-ease),
              box-shadow var(--md-dur-base) var(--md-ease);
  appearance: none;
  -webkit-appearance: none;
}

.input:focus, .select:focus {
  outline: none;
  border-color: var(--x-blue);
  box-shadow: 0 0 0 2px var(--x-blue-surface);
}

.input::placeholder { color: var(--md-text-muted); }

.input:disabled, .select:disabled {
  background: var(--md-bg);
  color: var(--md-text-muted);
  cursor: not-allowed;
}

.input-readonly {
  background: var(--md-bg);
  color: var(--md-text-secondary);
}

.input-group { position: relative; }
.input-group .input-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  left: 12px;
  inset-inline-start: 12px;
  color: var(--md-text-muted);
  pointer-events: none;
}
.input-group .input { padding-left: 36px; padding-inline-start: 36px; }

textarea.input { resize: vertical; min-height: 80px; }

.select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%238B98A5' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 32px;
}
html[dir="rtl"] .select {
  background-position: left 10px center;
  padding-right: 14px;
  padding-left: 32px;
}

.form-field { margin-bottom: 0; }
.form-hint { font-size: 12px; color: var(--md-text-muted); margin-top: 4px; }
.form-error-msg { font-size: 12px; color: var(--md-danger); margin-top: 4px; }

/* Tom Select overrides */
.ts-wrapper .ts-control {
  border: 1px solid var(--md-border-strong) !important;
  border-radius: var(--md-radius-md) !important;
  min-height: 40px !important;
  font-size: 14px !important;
  box-shadow: none !important;
  font-family: inherit !important;
  padding: 5px 10px !important;
  background: var(--md-surface) !important;
}
.ts-wrapper.focus .ts-control {
  border-color: var(--x-blue) !important;
  box-shadow: 0 0 0 2px var(--x-blue-surface) !important;
}
.ts-dropdown {
  border: 1px solid var(--md-border) !important;
  border-radius: var(--md-radius-lg) !important;
  box-shadow: var(--md-shadow-lg) !important;
  overflow: hidden;
  margin-top: 4px !important;
}
.ts-dropdown .option:hover, .ts-dropdown .option.active {
  background: var(--x-blue-surface) !important;
  color: var(--x-blue) !important;
}

/* ══════════════════════════════════════════════════════════════════════
   TABLES — X style: clean lines, no heavy background
══════════════════════════════════════════════════════════════════════ */
.th {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--md-text-muted);
  background: transparent;
  white-space: nowrap;
  border-bottom: 1px solid var(--md-border);
}

/* Sticky table headers — keep column context while scrolling long lists.
   Pure CSS; relies on the table's scroll container or the page scroll. */
thead .th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--md-surface);
}

.td {
  padding: 12px 16px;
  font-size: 14px;
  color: var(--md-text);
  vertical-align: middle;
  border-bottom: 1px solid var(--md-border);
}

.tr { transition: background var(--md-dur-fast) var(--md-ease); }
.tr:hover { background: rgba(15,20,25,0.025); }
.tr:last-child .td { border-bottom: none; }

/* ══════════════════════════════════════════════════════════════════════
   BADGES & STATUS
══════════════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: var(--md-radius-pill);
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
  background: currentColor;
}

.badge-gray   { background: #EFF3F4; color: #536471; }
.badge-blue   { background: rgba(29,155,240,0.12); color: #1D9BF0; }
.badge-green  { background: rgba(0,186,124,0.12); color: #00A36C; }
.badge-yellow { background: rgba(255,212,0,0.15); color: #8B6F00; }
.badge-orange { background: rgba(255,122,0,0.12); color: #B84500; }
.badge-red    { background: rgba(244,33,46,0.10); color: #F4212E; }
.badge-purple { background: rgba(120,86,255,0.10); color: #7856FF; }
.badge-indigo { background: rgba(29,155,240,0.12); color: #1D9BF0; }

/* ══════════════════════════════════════════════════════════════════════
   ALERTS / TOASTS
══════════════════════════════════════════════════════════════════════ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border-radius: var(--md-radius-lg);
  padding: 14px 18px;
  font-size: 14px;
  border-width: 1px;
  border-style: solid;
}

.alert-success {
  background: var(--md-success-surface);
  border-color: rgba(0,186,124,0.25);
  color: #00724A;
}
.alert-error {
  background: var(--md-danger-surface);
  border-color: rgba(244,33,46,0.20);
  color: #C41020;
}
.alert-warning {
  background: var(--md-warning-surface);
  border-color: rgba(255,212,0,0.30);
  color: #6B5000;
}
.alert-info {
  background: var(--md-info-surface);
  border-color: var(--x-blue-border);
  color: #0A6FAD;
}

/* ══════════════════════════════════════════════════════════════════════
   PAGE HEADER
══════════════════════════════════════════════════════════════════════ */
.page-header {
  padding: 20px 0 16px;
  border-bottom: 1px solid var(--md-border);
  margin-bottom: 24px;
}
.page-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--md-text);
  line-height: 1.2;
}
.page-subtitle {
  font-size: 14px;
  color: var(--md-text-secondary);
  margin-top: 2px;
}

/* ══════════════════════════════════════════════════════════════════════
   STAT CARDS — X style: no heavy background, bold numbers
══════════════════════════════════════════════════════════════════════ */
.stat-card {
  background: var(--md-surface);
  border: 1px solid var(--md-border);
  border-radius: var(--md-radius-lg);
  padding: 20px 24px;
}
.stat-label {
  font-size: 13px;
  color: var(--md-text-secondary);
  font-weight: 400;
}
.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--md-text);
  line-height: 1.1;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.stat-sub {
  font-size: 12px;
  color: var(--md-text-muted);
  margin-top: 4px;
}

/* ══════════════════════════════════════════════════════════════════════
   MODAL
══════════════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.40);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-box {
  background: var(--md-surface);
  border-radius: var(--md-radius-xl);
  box-shadow: var(--md-shadow-xl);
  width: 100%;
  max-width: 480px;
  padding: 28px;
}
.modal-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--md-text);
  margin-bottom: 16px;
}

/* ══════════════════════════════════════════════════════════════════════
   BOTTOM NAV (mobile) — X style
══════════════════════════════════════════════════════════════════════ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  background: var(--md-surface);
  border-top: 1px solid var(--md-border);
  display: flex;
  align-items: stretch;
  height: 56px;
  padding-bottom: env(safe-area-inset-bottom);
}

/* This bar is for small screens only. It carries `lg:hidden` in the markup,
   but app.css loads AFTER tailwind.css, so at equal specificity this rule's
   `display: flex` beat `.lg\:hidden`'s `display: none` and the bar showed up
   on desktop. Owning the breakpoint here keeps it correct regardless of the
   stylesheet order. */
@media (min-width: 1024px) {
  .bottom-nav { display: none; }
}

.bottom-nav > a, .bottom-nav > button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 10px;
  font-weight: 500;
  color: var(--md-text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  text-decoration: none;
  padding: 6px 4px;
  transition: color var(--md-dur-base) var(--md-ease);
}

.bottom-nav > a.active,
.bottom-nav > a:hover,
.bottom-nav > button:hover {
  color: var(--x-blue);
}

/* Fade-up animation for toasts */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
/* `backwards`, NOT `both`.
   `both` = backwards + forwards, and `forwards` makes the element KEEP the
   final keyframe forever. A retained transform — even the identity matrix a
   finished translateY(0) leaves behind — creates a stacking context and
   becomes the containing block for position:fixed descendants. Every .card
   carries .fade-up, so dropdown panels and modals were being trapped inside
   whichever card they opened from, and clipped by its overflow.
   `backwards` still hides the element during the stagger delay, then hands it
   back to its normal style: opacity 1, no transform, no stacking context. */
.fade-up { animation: fadeUp var(--md-dur-slow) var(--md-ease) backwards; }

/* ══════════════════════════════════════════════════════════════════════
   FOCUS — accessible
══════════════════════════════════════════════════════════════════════ */
:focus-visible {
  outline: 2px solid var(--x-blue);
  outline-offset: 2px;
}

/* ══════════════════════════════════════════════════════════════════════
   PRINT
══════════════════════════════════════════════════════════════════════ */
@media print {
  .sidebar, nav.bottom-nav, header { display: none !important; }
  body { background: white; }
  .card { box-shadow: none; border: 1px solid #EFF3F4; }
}

/* ══════════════════════════════════════════════════════════════════════
   STAT / KPI CARD TYPOGRAPHY
   Numbers are prominent (text-3xl equivalent); labels stay legible.
══════════════════════════════════════════════════════════════════════ */
.stat-num {
  font-size: 1.875rem;      /* 30px — text-3xl */
  line-height: 1.15;
  font-weight: 800;
  color: var(--md-text);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  letter-spacing: -0.01em;
}
@media (max-width: 640px) {
  .stat-num { font-size: 1.625rem; }  /* 26px — keep cards compact on mobile */
}

.page-sub {
  font-size: 0.875rem;      /* 14px — text-sm */
  color: var(--md-text-secondary);
  margin-top: 2px;
}

/* Trend chips on stat cards */
.chip-up, .chip-down {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--md-radius-pill);
  line-height: 1.4;
}
.chip-up   { background: var(--md-success-surface); color: #00724A; }
.chip-down { background: var(--md-danger-surface);  color: #C41020; }

/* ══════════════════════════════════════════════════════════════════════
   REQUIRED FIELD INDICATOR
   The .req-star is injected next to labels of required inputs (see layout).
══════════════════════════════════════════════════════════════════════ */
.req-star {
  color: var(--md-danger);
  font-weight: 700;
  margin-inline-start: 2px;
}

/* ══════════════════════════════════════════════════════════════════════
   SIDEBAR — visual section separators between nav groups
══════════════════════════════════════════════════════════════════════ */
.sidebar nav > div + div {
  padding-top: 1.25rem;
  border-top: 1px solid var(--md-border);
}

/* ══════════════════════════════════════════════════════════════════════
   iOS SAFARI — prevent auto-zoom on input focus (needs >= 16px font)
══════════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  .input, .select,
  input[type="text"], input[type="email"], input[type="password"],
  input[type="number"], input[type="search"], input[type="tel"],
  input[type="url"], input[type="date"], input[type="datetime-local"],
  textarea, select {
    font-size: 16px;
  }
  .ts-wrapper .ts-control,
  .ts-wrapper .ts-control input {
    font-size: 16px !important;
  }
}

/* ══════════════════════════════════════════════════════════════════════
   REDUCED MOTION
══════════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ══════════════════════════════════════════════════════════════════════
   SEARCHABLE SELECT — custom, zero-dependency (replaces Tom Select)
   ══════════════════════════════════════════════════════════════════════ */
.ss-wrap { position: relative; width: 100%; }
.ss-native { position: absolute !important; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.ss-control {
  display: flex; align-items: center; gap: 6px; width: 100%;
  min-height: 40px; text-align: start; cursor: pointer;
  padding-right: 8px; padding-inline-end: 8px; background: var(--md-surface);
}
.ss-control:focus-visible { outline: none; border-color: var(--x-blue);
  box-shadow: 0 0 0 2px var(--x-blue-surface); }
.ss-disabled .ss-control { cursor: not-allowed; opacity: .6; }
.ss-value { flex: 1; display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
  min-width: 0; overflow: hidden; }
.ss-placeholder { color: var(--md-text-muted); font-weight: 400; }
.ss-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px;
  background: var(--x-blue-surface); color: var(--x-blue); border-radius: var(--md-radius-pill);
  padding: 2px 8px; }
.ss-chip-x { cursor: pointer; font-weight: 700; line-height: 1; }
.ss-clear { color: var(--md-text-muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px; }
.ss-clear:hover { color: var(--md-danger); }
.ss-caret { width: 8px; height: 8px; flex: none; border-inline-end: 1.5px solid var(--md-text-muted);
  border-bottom: 1.5px solid var(--md-text-muted); transform: rotate(45deg); margin-top: -3px; }
/* Fixed, not absolute: cards are `overflow-hidden`, which clipped the open
   list to the card's edge — you could see one option and the rest was cut off.
   Coordinates are set from the trigger's rect when the panel opens. */
.ss-panel { position: fixed; z-index: 1100;
  background: var(--md-surface); border: 1px solid var(--md-border);
  border-radius: var(--md-radius-lg); box-shadow: var(--md-shadow-lg); overflow: hidden; display: none; }
.ss-panel.ss-open { display: block; }

/* The date picker's calendar, for exactly the same reason as .ss-panel above.
   It was `absolute z-50`, so the goods form's `card overflow-hidden` sliced it
   in half — two rows of dates visible and the rest of the month unreachable.
   Fixed positioning escapes every clipping ancestor at once; datePicker()'s
   placeDatePanel() supplies the coordinates. */
.dp-panel { position: fixed; z-index: 1100; }
.ss-search-row { padding: 8px; border-bottom: 1px solid var(--md-border); }
.ss-search { width: 100%; border: 1px solid var(--md-border-strong);
  border-radius: var(--md-radius-md); padding: 7px 10px; font-size: 14px; font-family: inherit; }
.ss-search:focus { outline: none; border-color: var(--x-blue); box-shadow: 0 0 0 2px var(--x-blue-surface); }
.ss-list { max-height: 240px; overflow-y: auto; padding: 4px; }
.ss-opt { padding: 8px 10px; font-size: 14px; border-radius: var(--md-radius-md); cursor: pointer; color: var(--md-text); }
.ss-opt:hover, .ss-opt.ss-active { background: var(--x-blue-surface); color: var(--x-blue); }
.ss-opt.ss-selected { font-weight: 600; }
.ss-opt.ss-selected::after { content: '\2713'; float: inline-end; color: var(--x-blue); }
.ss-opt-disabled { opacity: .45; cursor: not-allowed; }
.ss-empty { padding: 14px; text-align: center; font-size: 13px; color: var(--md-text-muted); }

/* Topbar global-search dropdown (was undefined) */
/* Physical fallbacks for logical inset positioning — Safari < 14.1 ignores
   inset-inline-* entirely, which collapsed/mis-placed dropdown panels. */
.dd-end { right: 0; }
html[dir="rtl"] .dd-end { right: auto; left: 0; }
html[dir="rtl"] .input-group .input-icon { left: auto; right: 12px; }
html[dir="rtl"] .input-group .input { padding-left: 12px; padding-right: 36px; }
.search-dropdown { position: absolute; z-index: 50; left: 0; right: 0; inset-inline: 0; top: calc(100% + 6px);
  background: var(--md-surface); border: 1px solid var(--md-border);
  border-radius: var(--md-radius-lg); box-shadow: var(--md-shadow-lg);
  overflow: hidden; max-height: 60vh; overflow-y: auto; }

/* Extra semantic button variants (used by <x-ui.button>) */
.btn-warning { background: var(--md-warning, #f59e0b); color: #fff; border-color: var(--md-warning, #f59e0b); }
.btn-warning:hover { filter: brightness(0.95); }
.btn-info { background: var(--md-info, #0ea5e9); color: #fff; border-color: var(--md-info, #0ea5e9); }
.btn-info:hover { filter: brightness(0.95); }

/* ══════════════════════════════════════════════════════════════════════
   PHASE 2–4 — safe cross-cutting polish (CSS-only, applies app-wide)
   ══════════════════════════════════════════════════════════════════════ */

/* Responsive tables: any card that directly wraps a <table> scrolls
   horizontally on small screens instead of clipping content. Vertical
   overflow stays hidden so rounded corners are preserved. */
.card:has(> table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.card:has(> table) > table { min-width: max-content; }
/* Explicit opt-in helper for markup that wants a scroll container. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Accessibility: consistent keyboard focus rings on all interactive
   elements (mouse clicks stay ring-free via :focus-visible). */
a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
.btn:focus-visible,
.nav-link:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--x-blue);
  outline-offset: 2px;
  border-radius: var(--md-radius-sm, 6px);
}

/* Dashboard stat cards: subtle hover lift for a more premium feel. */
.stat-card { transition: box-shadow .15s ease, transform .15s ease; }
.stat-card:hover { box-shadow: var(--md-shadow-lg); transform: translateY(-1px); }

/* Buttons: gentle press feedback + not-allowed cursor when disabled. */
.btn { transition: background .12s ease, border-color .12s ease, box-shadow .12s ease, transform .08s ease; }
.btn:active:not([disabled]):not([aria-disabled="true"]) { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; pointer-events: none; }

/* Cards: hairline hover elevation for clickable card links. */
a.card:hover, .card-hover:hover { box-shadow: var(--md-shadow-lg); }

/* Honor users who prefer reduced motion. */
@media (prefers-reduced-motion: reduce) {
  .stat-card, .btn, a.card, .card-hover { transition: none !important; }
  .stat-card:hover, .btn:active { transform: none !important; }
}

/* ══════════════════════════════════════════════════════════════════════
   Components that Blade referenced but no stylesheet defined. Under the
   Tailwind CDN these silently rendered as nothing; with the compiled build
   they still do, so the markup was there but invisible. Defined here to
   match the surrounding design system.
   ══════════════════════════════════════════════════════════════════════ */

/* Entrance cascade. .fade-up itself is defined above; the staggered delays
   were only ever declared inline on the system login page, so every other
   page animated as one block. */
.fade-up-1 { animation-delay: .06s; }
.fade-up-2 { animation-delay: .12s; }
.fade-up-3 { animation-delay: .18s; }
.fade-up-4 { animation-delay: .24s; }

/* Capacity / utilisation bars (loading plan truck fill, warehouse usage). */
.progress-bar {
  position: relative;
  width: 100%;
  height: 8px;
  border-radius: var(--md-radius-pill);
  background: var(--md-border);
  overflow: hidden;
}
.progress-fill {
  display: block;
  height: 100%;
  border-radius: var(--md-radius-pill);
  background: var(--md-primary);
  transition: width var(--md-dur-slow) var(--md-ease);
}

/* Empty states — shown whenever a list or filter returns nothing. */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 44px 20px;
  text-align: center;
}
.empty-state-icon {
  width: 44px;
  height: 44px;
  margin-bottom: 6px;
  color: var(--md-text-muted);
}
.empty-state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--md-text);
}
.empty-state-sub {
  font-size: 13px;
  color: var(--md-text-secondary);
  max-width: 34ch;
}

/* Card section headings (loading plan detail, handover). */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--md-border);
  background: var(--md-surface-variant);
  font-size: 14px;
  font-weight: 600;
  color: var(--md-text);
}

/* Compact form control, to pair with .btn-sm in filter bars and dense grids. */
.input-sm {
  padding: 6px 10px;
  font-size: 13px;
  border-radius: var(--md-radius-md);
  min-height: 32px;
}

.badge-teal { background: rgba(13,148,136,0.12); color: #0D9488; }
