/* ==========================================================================
   Dashboard de Encomendas — Design System & Estilos Modernos
   ========================================================================== */

:root {
  --bg-canvas: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-hover: #f8fafc;
  --bg-input: #ffffff;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --border-color: #e2e8f0;
  --border-strong: #cbd5e1;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-text: #4338ca;

  /* Cores semânticas de status */
  --delivered-bg: #ecfdf5;
  --delivered-text: #047857;
  --delivered-border: #a7f3d0;
  --delivered-dot: #10b981;

  --transit-bg: #eff6ff;
  --transit-text: #1d4ed8;
  --transit-border: #bfdbfe;
  --transit-dot: #3b82f6;

  --pending-bg: #fffbeb;
  --pending-text: #b45309;
  --pending-border: #fde68a;
  --pending-dot: #f59e0b;

  --issue-bg: #fef2f2;
  --issue-text: #b91c1c;
  --issue-border: #fecaca;
  --issue-dot: #ef4444;

  --other-bg: #f1f5f9;
  --other-text: #475569;
  --other-border: #e2e8f0;
  --other-dot: #64748b;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 4px 10px -4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 24px 48px -12px rgba(15, 23, 42, 0.22);

  --skeleton-base: #e2e8f0;
  --skeleton-highlight: #f1f5f9;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

[data-theme='dark'] {
  --bg-canvas: #0b1120;
  --bg-surface: #111827;
  --bg-subtle: #1e293b;
  --bg-hover: #172033;
  --bg-input: #0f172a;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --border-color: #1e293b;
  --border-strong: #334155;

  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-soft: rgba(99, 102, 241, 0.16);
  --accent-text: #a5b4fc;

  --delivered-bg: rgba(16, 185, 129, 0.14);
  --delivered-text: #6ee7b7;
  --delivered-border: rgba(16, 185, 129, 0.32);
  --delivered-dot: #34d399;

  --transit-bg: rgba(59, 130, 246, 0.15);
  --transit-text: #93c5fd;
  --transit-border: rgba(59, 130, 246, 0.32);
  --transit-dot: #60a5fa;

  --pending-bg: rgba(245, 158, 11, 0.14);
  --pending-text: #fcd34d;
  --pending-border: rgba(245, 158, 11, 0.32);
  --pending-dot: #fbbf24;

  --issue-bg: rgba(239, 68, 68, 0.15);
  --issue-text: #fca5a5;
  --issue-border: rgba(239, 68, 68, 0.32);
  --issue-dot: #f87171;

  --other-bg: rgba(148, 163, 184, 0.14);
  --other-text: #cbd5e1;
  --other-border: rgba(148, 163, 184, 0.25);
  --other-dot: #94a3b8;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.32);
  --shadow-md: 0 12px 28px rgba(0, 0, 0, 0.42);
  --shadow-lg: 0 24px 56px rgba(0, 0, 0, 0.65);

  --skeleton-base: #1e293b;
  --skeleton-highlight: #293548;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg-canvas);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  transition: background-color 0.2s ease, color 0.2s ease;
}

body.modal-open {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

code {
  font-family: var(--font-mono);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.container {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ==========================================================================
   Topbar
   ========================================================================== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--bg-surface) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 70px;
  padding-top: 10px;
  padding-bottom: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand__logo {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 6px 14px rgba(79, 70, 229, 0.28);
}

.brand__title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.brand__subtitle {
  margin: 1px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

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

/* Sync Status Pill */
.sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.76rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  white-space: nowrap;
}

.sync-pill__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
}

.sync-pill--live .sync-pill__dot {
  background: var(--delivered-dot);
}

.sync-pill--demo {
  background: var(--pending-bg);
  border-color: var(--pending-border);
  color: var(--pending-text);
}
.sync-pill--demo .sync-pill__dot {
  background: var(--pending-dot);
}

.sync-pill--loading .sync-pill__dot {
  background: var(--transit-dot);
  animation: pulseDot 1.2s ease-in-out infinite;
}

.sync-pill--error {
  background: var(--issue-bg);
  border-color: var(--issue-border);
  color: var(--issue-text);
}
.sync-pill--error .sync-pill__dot {
  background: var(--issue-dot);
}

/* Theme Icon Switching */
.theme-icon--sun {
  display: none;
}
[data-theme='dark'] .theme-icon--sun {
  display: block;
}
[data-theme='dark'] .theme-icon--moon {
  display: none;
}

/* ==========================================================================
   Buttons & Icon Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn--sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn--primary {
  background: var(--accent);
  color: #ffffff;
}
.btn--primary:hover {
  background: var(--accent-hover);
}

.btn--secondary {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--text-primary);
}
.btn--secondary:hover {
  background: var(--bg-subtle);
}

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn--ghost:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.icon-btn--toolbar {
  width: 36px;
  height: 36px;
}

.icon-btn--xs {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.icon-btn--copy.is-copied {
  background: var(--delivered-bg);
  border-color: var(--delivered-border);
  color: var(--delivered-text);
}

.is-spinning svg {
  animation: spin 0.85s linear infinite;
}

/* ==========================================================================
   Main Layout & Demo Banner
   ========================================================================== */
.main-content {
  padding-top: 24px;
  padding-bottom: 56px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.demo-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  color: var(--text-primary);
  font-size: 0.86rem;
}

.demo-banner[hidden] {
  display: none;
}

.demo-banner__text strong {
  color: var(--accent-text);
  margin-right: 4px;
}

/* ==========================================================================
   KPI Cards
   ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.kpi-card {
  position: relative;
  text-align: left;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.kpi-card--active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.kpi-card--skeleton {
  cursor: default;
  pointer-events: none;
}

.kpi-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.kpi-card__label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.kpi-card__icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-card--indigo .kpi-card__icon {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.kpi-card--blue .kpi-card__icon {
  background: var(--transit-bg);
  color: var(--transit-text);
}
.kpi-card--emerald .kpi-card__icon {
  background: var(--delivered-bg);
  color: var(--delivered-text);
}
.kpi-card--rose .kpi-card__icon {
  background: var(--issue-bg);
  color: var(--issue-text);
}
.kpi-card--slate .kpi-card__icon {
  background: var(--other-bg);
  color: var(--other-text);
}

.kpi-card__value {
  font-size: 1.95rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 4px;
}

.kpi-card__sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Controls Bar (Busca, Filtros, Ordenação, Toggle de View)
   ========================================================================== */
.controls-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.search-field {
  position: relative;
  flex: 1 1 300px;
  min-width: 220px;
}

.search-field__icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-field__input {
  width: 100%;
  height: 42px;
  padding: 0 42px 0 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  font-size: 0.9rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-field__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-field__input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.search-field__kbd {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  pointer-events: none;
}

.search-field__input:not(:placeholder-shown) ~ .search-field__kbd {
  display: none;
}

.search-field__clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
}

.controls-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.select-input {
  height: 42px;
  padding: 0 34px 0 13px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
}

.select-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.view-toggle {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
}

.view-toggle__btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.view-toggle__btn.is-active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

/* Filter Tabs */
.filter-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-size: 0.81rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-tab:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.filter-tab.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.filter-tab--danger.is-active {
  background: #dc2626;
  border-color: #dc2626;
}

.filter-tab--success.is-active {
  background: #059669;
  border-color: #059669;
}

.filter-tab__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

.filter-tab.is-active .filter-tab__count {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

.results-summary {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ==========================================================================
   Semantic Status Badges & Pills
   ========================================================================== */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.76rem;
  font-weight: 600;
  border: 1px solid transparent;
  max-width: 100%;
}

.status-badge__text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot--pulse {
  animation: pulseDot 1.8s ease-in-out infinite;
}

.status-badge--delivered {
  background: var(--delivered-bg);
  color: var(--delivered-text);
  border-color: var(--delivered-border);
}
.status-badge--delivered .status-dot {
  background: var(--delivered-dot);
}

.status-badge--in_transit {
  background: var(--transit-bg);
  color: var(--transit-text);
  border-color: var(--transit-border);
}
.status-badge--in_transit .status-dot {
  background: var(--transit-dot);
}

.status-badge--pending {
  background: var(--pending-bg);
  color: var(--pending-text);
  border-color: var(--pending-border);
}
.status-badge--pending .status-dot {
  background: var(--pending-dot);
}

.status-badge--issue {
  background: var(--issue-bg);
  color: var(--issue-text);
  border-color: var(--issue-border);
}
.status-badge--issue .status-dot {
  background: var(--issue-dot);
}

.status-badge--other {
  background: var(--other-bg);
  color: var(--other-text);
  border-color: var(--other-border);
}
.status-badge--other .status-dot {
  background: var(--other-dot);
}

.delay-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  background: var(--issue-bg);
  color: var(--issue-text);
  border: 1px solid var(--issue-border);
  font-size: 0.72rem;
  font-weight: 700;
}

.delay-tag--compact {
  padding: 2px 7px;
  font-size: 0.7rem;
}

.carrier-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.store-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.store-pill__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
}

.store-pill--amazon .store-pill__dot {
  background: #f59e0b;
}

.store-pill--ml .store-pill__dot {
  background: #eab308;
}

.store-pill--aliexpress .store-pill__dot {
  background: #ef4444;
}

.store-pill--shopee .store-pill__dot {
  background: #f97316;
}

.items-count-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 0.71rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.items-count-badge--xs {
  padding: 1px 7px;
  font-size: 0.68rem;
}

/* ==========================================================================
   Cards View
   ========================================================================== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.pkg-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-xs);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.pkg-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.pkg-card--alert {
  border-top: 3px solid var(--issue-dot);
}

.pkg-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.pkg-card__badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.pkg-card__title-block {
  margin-bottom: 14px;
}

.pkg-card__title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.pkg-card__title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.38;
  letter-spacing: -0.01em;
}

.pkg-card__title-btn {
  padding: 0;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--text-primary);
  font-weight: 700;
  transition: color 0.15s ease;
}

.pkg-card__title-btn:hover {
  color: var(--accent);
}

.pkg-card__subitems {
  margin: 7px 0 0;
  padding-left: 16px;
  font-size: 0.79rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.pkg-card__subitems li {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pkg-card__subitems-more {
  list-style: none;
  margin-left: -16px;
  color: var(--accent-text);
  font-weight: 600;
}

.pkg-card__meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.pkg-card__meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.pkg-row__title-line {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* Tracking Code Box */
.tracking-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  margin-bottom: 12px;
}

.tracking-box--empty {
  justify-content: center;
  border-style: dashed;
}

.tracking-box--lg {
  padding: 12px 14px;
  margin: 16px 0;
}

.tracking-box__code-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tracking-box__label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--text-muted);
}

.tracking-box__code {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tracking-box__placeholder {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.tracking-box__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.pkg-card__notes {
  margin: 0 0 12px;
  font-size: 0.82rem;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Progress Stepper */
.progress-track {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  margin-top: auto;
  padding-top: 4px;
  margin-bottom: 14px;
}

.progress-seg {
  height: 5px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
}

.progress-seg--delivered {
  background: var(--delivered-dot);
}
.progress-seg--in_transit {
  background: var(--transit-dot);
}
.progress-seg--pending {
  background: var(--pending-dot);
}
.progress-seg--issue {
  background: var(--issue-dot);
}

/* Card Footer */
.pkg-card__footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.meta-item--right {
  text-align: right;
  align-items: flex-end;
}

.meta-item__label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.meta-item__value {
  font-size: 0.81rem;
  font-weight: 600;
  color: var(--text-primary);
}

.meta-item__value small {
  font-weight: 500;
  color: var(--text-muted);
}

.meta-item--overdue .meta-item__value,
.meta-item--overdue .meta-item__value small,
.meta-item--overdue .meta-item__label {
  color: var(--issue-text);
}

/* ==========================================================================
   Compact List View (Table)
   ========================================================================== */
.table-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
}

.pkg-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}

.pkg-table th {
  text-align: left;
  padding: 13px 16px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
}

.pkg-row {
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.14s ease;
}

.pkg-row:last-child {
  border-bottom: none;
}

.pkg-row:hover {
  background: var(--bg-hover);
}

.pkg-row--alert {
  box-shadow: inset 3px 0 0 var(--issue-dot);
}

.pkg-cell {
  padding: 13px 16px;
  vertical-align: middle;
  font-size: 0.86rem;
}

.pkg-cell--product {
  max-width: 260px;
}

.pkg-row__title-btn {
  padding: 0;
  border: none;
  background: transparent;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
}

.pkg-row__title-btn:hover {
  color: var(--accent);
}

.pkg-row__store {
  font-size: 0.77rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.pkg-row__status-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.list-tracking {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.list-tracking__code {
  font-size: 0.81rem;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.carrier-text {
  font-weight: 500;
  color: var(--text-secondary);
}

.pkg-cell--date {
  white-space: nowrap;
  font-size: 0.82rem;
}

.pkg-cell--action {
  width: 48px;
  text-align: right;
}

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

.text-danger {
  color: var(--issue-text);
  font-weight: 600;
}

/* ==========================================================================
   States (Empty & Error)
   ========================================================================== */
.state-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 52px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.state-card--error {
  border-color: var(--issue-border);
}

.state-card__icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.state-card__icon--error {
  background: var(--issue-bg);
  color: var(--issue-text);
}

.state-card__title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
}

.state-card__desc {
  margin: 0;
  max-width: 520px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.state-card__actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* ==========================================================================
   Skeletons
   ========================================================================== */
.skeleton {
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    var(--skeleton-base) 25%,
    var(--skeleton-highlight) 50%,
    var(--skeleton-base) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.skeleton--circle {
  width: 34px;
  height: 34px;
  border-radius: 10px;
}

.skeleton--value {
  width: 64px;
  height: 30px;
  margin-bottom: 10px;
}

.skeleton--title {
  height: 20px;
}

.skeleton--text {
  height: 16px;
}

.skeleton--text-sm {
  height: 13px;
}

.skeleton--text-xs {
  height: 11px;
}

.skeleton--pill {
  height: 24px;
  border-radius: var(--radius-full);
}

.skeleton--box {
  height: 54px;
  border-radius: var(--radius-md);
}

.skeleton--bar {
  height: 6px;
  border-radius: var(--radius-full);
}

.list-skeleton-wrapper {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.list-skeleton-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-color);
}

.list-skeleton-row:last-child {
  border-bottom: none;
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-dialog {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.18s ease-out;
}

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

.modal-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.modal-body {
  padding: 20px;
}

/* Detail Modal Content */
.detail-header-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.detail-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.detail-subtitle {
  margin: 4px 0 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0 0;
}

.detail-kv {
  padding: 11px 13px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
}

.detail-kv dt {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.detail-kv dd {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  word-break: break-word;
}

.detail-kv--danger {
  background: var(--issue-bg);
  border-color: var(--issue-border);
}
.detail-kv--danger dd,
.detail-kv--danger dt {
  color: var(--issue-text);
}

.detail-section {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.detail-section--first {
  margin-top: 6px;
  padding-top: 0;
  border-top: none;
}

.detail-items-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.94rem;
  font-weight: 600;
  color: var(--text-primary);
}

.detail-section__title {
  margin: 0 0 8px;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.detail-notes {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

/* Settings Form */
.settings-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.84rem;
  font-weight: 600;
}

.text-input {
  width: 100%;
  height: 42px;
  padding: 0 13px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  font-size: 0.9rem;
}

.text-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-help {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.form-help code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-subtle);
  font-size: 0.76rem;
}

.settings-divider {
  height: 1px;
  background: var(--border-color);
}

.settings-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 4px;
}

/* ==========================================================================
   Toasts
   ========================================================================== */
.toast-container {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: calc(100vw - 40px);
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 15px;
  border-radius: var(--radius-md);
  background: #0f172a;
  color: #f8fafc;
  font-size: 0.84rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

[data-theme='dark'] .toast {
  background: #f8fafc;
  color: #0f172a;
}

.toast--visible {
  opacity: 1;
  transform: translateY(0);
}

.toast--success {
  background: #065f46;
  color: #ecfdf5;
}

.toast--error {
  background: #991b1b;
  color: #fef2f2;
}

.toast__icon {
  display: inline-flex;
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

@keyframes pulseDot {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.45;
    transform: scale(0.8);
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 1080px) {
  .cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sync-pill {
    display: none;
  }
}

@media (max-width: 640px) {
  .container {
    padding: 0 14px;
  }

  .brand__subtitle {
    display: none;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }

  .demo-banner {
    flex-direction: column;
    align-items: flex-start;
  }

  .controls-right {
    width: 100%;
    justify-content: space-between;
  }

  .sort-control {
    flex: 1;
  }

  .select-input {
    width: 100%;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }
}
