*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --brand: #e85d5d;
  --brand-dark: #d94848;
  --brand-soft: rgba(232, 93, 93, 0.1);
  --surface: #eef1f6;
  --surface-raised: #ffffff;
  --surface-overlay: #f8fafc;
  --border: #e2e8f0;
  --border-subtle: #f1f5f9;
  --text: #475569;
  --text-strong: #1e293b;
  --text-muted: #94a3b8;
  --radius: 8px;
  --radius-lg: 10px;
  --row-height: 40px;
}

body {
  font-family: "Inter", system-ui, sans-serif;
  background: var(--surface);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.4;
  font-size: 13px;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.6;
}

.hidden {
  display: none !important;
}

.mono { font-family: ui-monospace, "Cascadia Code", monospace; font-size: 0.92em; }
.muted { color: var(--text-muted); }

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.brand h1 {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-strong);
  line-height: 1.2;
}

.brand p {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.label-hint {
  font-weight: 400;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-primary {
  background: var(--brand);
  color: white;
}

.btn-primary:hover { background: var(--brand-dark); }

.btn-primary:disabled,
.btn-secondary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.loading .btn-icon-svg {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn-secondary {
  background: var(--surface-raised);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover { background: var(--surface-overlay); }

.btn-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
  text-decoration: none;
}

.btn-icon:hover {
  background: var(--border-subtle);
  color: var(--text-strong);
}

.btn-icon.danger:hover {
  background: #fef2f2;
  color: #ef4444;
}

/* Main */
.main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 12px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Stats */
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.75rem;
}

.stat-chip-label {
  color: var(--text-muted);
}

.stat-chip-value {
  font-weight: 700;
  color: var(--text-strong);
}

.stat-white { color: var(--text-strong); }
.stat-amber { color: #d97706; }
.stat-indigo { color: #6366f1; }
.stat-rose { color: #e11d48; }
.stat-emerald { color: #059669; }
.stat-brand { color: var(--brand); }

/* Filters */
.filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (min-width: 640px) {
  .filters {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
}

.search-wrap {
  position: relative;
  flex: 1;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-wrap input {
  width: 100%;
  padding: 6px 12px 6px 32px;
}

.filters select,
.search-wrap input,
.field input,
.field select,
.field textarea {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-strong);
  font-size: 0.8125rem;
  font-family: inherit;
  transition: border-color 0.15s;
}

.filters select,
.search-wrap input {
  padding: 6px 10px;
}

.filters select:focus,
.search-wrap input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: rgba(232, 93, 93, 0.45);
  box-shadow: 0 0 0 2px var(--brand-soft);
}

.filters select { cursor: pointer; min-width: 140px; }

.filter-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.filter-check input {
  accent-color: var(--brand);
}

.btn-compact {
  padding: 6px 10px;
  font-size: 0.75rem;
  white-space: nowrap;
}

/* Purchases list */
.purchases {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  overflow-x: auto;
}

.tracking-br {
  color: #0891b2;
}

.tracking-dual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
}

@media (max-width: 720px) {
  .tracking-dual {
    grid-template-columns: 1fr;
  }
}

.tracking-section {
  min-width: 0;
  height: 100%;
  padding: 10px;
  background: var(--surface-overlay);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.tracking-section-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-strong);
  margin-bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.tracking-section-code {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

.tracking-updated {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin: -4px 0 8px;
}

.btn-icon-br {
  color: #0891b2;
}

.btn-icon-br:hover {
  background: #ecfeff;
  color: #0e7490;
}

.list-header,
.purchase-row {
  display: grid;
  grid-template-columns: minmax(170px, 2fr) minmax(120px, 2.5fr) 92px minmax(168px, 1.2fr);
  gap: 8px;
  align-items: center;
  min-width: 680px;
}

.list-header-actions {
  text-align: right;
}

.list-header {
  padding: 5px 10px;
  background: var(--surface-overlay);
  border-bottom: 1px solid var(--border);
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.purchase-group {
  border-bottom: 1px solid var(--border-subtle);
}

.purchase-group:last-child {
  border-bottom: none;
}

.purchase-row {
  padding: 4px 10px;
  min-height: var(--row-height);
  transition: background 0.1s;
}

.purchase-group.is-archived .purchase-row {
  opacity: 0.72;
}

.archived-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 5px;
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-overlay);
  border: 1px solid var(--border);
  border-radius: 4px;
  vertical-align: middle;
}

.payment-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 5px 10px 7px 10px;
  background: #fffbeb;
  border-bottom: 1px solid #fef3c7;
  font-size: 0.6875rem;
}

.payment-links-modal {
  margin-bottom: 12px;
  border: 1px solid #fef3c7;
  border-radius: var(--radius);
}

.payment-links-label {
  font-weight: 600;
  color: #b45309;
}

.payment-link {
  color: #b45309;
  text-decoration: none;
  font-weight: 500;
}

.payment-link:hover {
  text-decoration: underline;
}

.payment-link-primary {
  padding: 2px 8px;
  background: #fef3c7;
  border-radius: 4px;
}

.payment-link-primary:hover {
  background: #fde68a;
  text-decoration: none;
}

.purchase-row:hover {
  background: #fafbfd;
}

.row-cell {
  min-width: 0;
}

.row-product {
  display: flex;
  align-items: center;
  gap: 8px;
}

.row-product-text {
  min-width: 0;
  flex: 1;
}

.row-product h3 {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.order-link {
  color: var(--brand);
  text-decoration: none;
  font-family: ui-monospace, "Cascadia Code", monospace;
}

.order-link:hover {
  text-decoration: underline;
}

.row-meta {
  font-size: 0.6875rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.row-event {
  font-size: 0.75rem;
  color: var(--text);
}

.row-event-text {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.row-event time {
  display: block;
  font-size: 0.625rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.row-finance {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  line-height: 1.25;
}

.row-delivery-line {
  font-size: 0.6875rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-price {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-strong);
  white-space: nowrap;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  min-width: 0;
  max-width: 100%;
}

.track-menu {
  position: relative;
  display: inline-flex;
}

.track-menu-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 9.5rem;
  padding: 4px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  z-index: 30;
  flex-direction: column;
  gap: 2px;
}

.track-menu:hover .track-menu-dropdown,
.track-menu:focus-within .track-menu-dropdown,
.track-menu.open .track-menu-dropdown {
  display: flex;
}

.track-menu-item {
  display: block;
  padding: 6px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  border-radius: 6px;
  white-space: nowrap;
}

.track-menu-item:hover {
  background: var(--brand-soft);
  color: var(--brand);
}

/* Badges — tons pastéis */
.badge {
  flex-shrink: 0;
  padding: 2px 6px;
  font-size: 0.625rem;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-pendente { background: #f1f5f9; color: #64748b; border-color: #e2e8f0; }
.badge-pago { background: #eff6ff; color: #3b82f6; border-color: #dbeafe; }
.badge-enviado { background: #eef2ff; color: #6366f1; border-color: #e0e7ff; }
.badge-em_transito { background: #fffbeb; color: #d97706; border-color: #fef3c7; }
.badge-alfandega { background: #fff7ed; color: #ea580c; border-color: #ffedd5; }
.badge-retido_alfandega { background: #fff1f2; color: #e11d48; border-color: #ffe4e6; }
.badge-aguardando_pagamento { background: #fefce8; color: #ca8a04; border-color: #fef9c3; }
.badge-liberado_alfandega { background: #ecfeff; color: #0891b2; border-color: #cffafe; }
.badge-falha_entrega { background: #fef2f2; color: #dc2626; border-color: #fee2e2; }
.badge-problema { background: #faf5ff; color: #9333ea; border-color: #f3e8ff; }
.badge-entregue { background: #ecfdf5; color: #059669; border-color: #d1fae5; }
.badge-cancelado { background: #f8fafc; color: #94a3b8; border-color: #e2e8f0; }

.days-late { color: #dc2626; font-size: 0.6875rem; }
.days-soon { color: #d97706; font-size: 0.6875rem; }
.days-normal { color: var(--text-muted); font-size: 0.6875rem; }

.status-select {
  width: 22px;
  height: 22px;
  padding: 0;
  font-size: 0;
  background: var(--surface-overlay);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: transparent;
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}

.status-select option {
  font-size: 0.8125rem;
  color: var(--text-strong);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.12);
  animation: fadeIn 0.25s ease-out;
  max-width: calc(100% - 32px);
  text-align: center;
}

.toast-success {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.toast-info {
  background: var(--surface-raised);
  color: var(--text);
  border: 1px solid var(--border);
}

.toast-error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(6px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Empty state */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  text-align: center;
  animation: fadeIn 0.3s ease-out;
}

.empty-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.empty h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-strong);
  margin-bottom: 4px;
}

.empty p {
  font-size: 0.8125rem;
  color: var(--text-muted);
  max-width: 360px;
  margin-bottom: 16px;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.25);
  backdrop-filter: blur(2px);
}

.modal:not(.hidden) {
  display: flex;
}

.modal.hidden {
  display: none !important;
  pointer-events: none;
}

.modal-box {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 512px;
  max-height: 90vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.12);
  animation: modalIn 0.2s ease-out;
}

body.modal-open {
  overflow: hidden;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-raised);
}

.modal-header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-strong);
}

.modal-form {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 7px 10px;
}

.field textarea { resize: none; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field-row-3 { grid-template-columns: 2fr 1fr; }

.form-actions {
  display: flex;
  gap: 8px;
  padding-top: 4px;
}

.form-actions .btn { flex: 1; justify-content: center; }

.modal-box-wide {
  max-width: 920px;
}

.tracking-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 400;
}

.tracking-body {
  padding: 12px 16px 16px;
  max-height: 72vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.tracking-dual .tracking-timeline {
  max-height: 52vh;
  overflow-y: auto;
}

.tracking-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 24px 16px;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.tracking-spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.tracking-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.tracking-meta span {
  font-size: 0.6875rem;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface-overlay);
  border: 1px solid var(--border);
  color: var(--text);
}

.tracking-timeline {
  display: flex;
  flex-direction: column;
}

.tracking-event {
  display: flex;
  gap: 10px;
  position: relative;
  padding-bottom: 12px;
}

.tracking-event:last-child {
  padding-bottom: 0;
}

.tracking-event::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 12px;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

.tracking-event:last-child::before {
  display: none;
}

.tracking-dot {
  flex-shrink: 0;
  width: 9px;
  height: 9px;
  margin-top: 3px;
  border-radius: 50%;
  background: var(--border);
  border: 2px solid var(--surface-raised);
  position: relative;
  z-index: 1;
}

.tracking-event:first-child .tracking-dot {
  background: var(--brand);
  box-shadow: 0 0 0 2px var(--brand-soft);
}

.tracking-event-content {
  flex: 1;
  min-width: 0;
}

.tracking-event-time {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-strong);
  margin-bottom: 2px;
  font-variant-numeric: tabular-nums;
}

.tracking-event-content h4 {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-strong);
  line-height: 1.35;
}

.tracking-event-content p {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.35;
}

.tracking-event-location {
  font-size: 0.6875rem !important;
}

.tracking-empty {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.tracking-help-links {
  text-align: center;
  margin-top: 8px;
  font-size: 0.8125rem;
}

.tracking-help-links a {
  color: var(--brand);
  text-decoration: none;
}

.tracking-help-links a:hover {
  text-decoration: underline;
}

.settings-info {
  font-size: 0.6875rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 4px;
}

.settings-info a {
  color: var(--brand);
  text-decoration: none;
}

.settings-info a:hover {
  text-decoration: underline;
}

.settings-info code {
  font-size: 0.625rem;
  background: var(--surface-overlay);
  padding: 1px 4px;
  border-radius: 3px;
}

.check-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--text);
  cursor: pointer;
}

.check-label input {
  margin-top: 2px;
  accent-color: var(--brand);
  flex-shrink: 0;
}

.check-label-strong {
  font-weight: 600;
  color: var(--text-strong);
}

.check-label-compact {
  font-size: 0.75rem;
}

.notify-fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.notify-fieldset legend {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 0 4px;
}

.notify-config {
  margin-left: 22px;
  padding: 8px 0 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.notify-fieldset-nested {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--surface-overlay);
}

.field-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.field-inline input[type="number"] {
  width: 4rem;
  padding: 6px 8px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.8125rem;
}

.notify-status-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 12px;
}

@media (min-width: 480px) {
  .notify-status-grid { grid-template-columns: repeat(3, 1fr); }
}

.import-tabs {
  display: flex;
  gap: 4px;
  padding: 0 20px 12px;
  border-bottom: 1px solid var(--border);
}

.import-tab {
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}

.import-tab:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.import-tab.active {
  background: var(--brand-soft);
  color: var(--brand);
}

.import-panel {
  padding-top: 4px;
}

.import-file-name {
  margin-top: 8px;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.import-preview {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.import-preview-count {
  margin: 0 0 10px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.import-preview-empty {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.import-preview-table-wrap {
  overflow-x: auto;
}

.import-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.import-preview-table th,
.import-preview-table td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.import-preview-table th {
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.import-preview-more {
  margin: 8px 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

@media (max-width: 900px) {
  .list-header {
    display: none;
  }

  .purchases {
    overflow-x: hidden;
  }

  .purchase-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-width: 0;
    gap: 8px;
    padding: 10px 12px;
  }

  .row-product {
    align-items: flex-start;
  }

  .row-product h3 {
    white-space: normal;
    line-height: 1.35;
  }

  .row-meta {
    white-space: normal;
    line-height: 1.4;
  }

  .row-event {
    padding-top: 6px;
    border-top: 1px solid var(--border-subtle);
  }

  .row-finance {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
  }

  .row-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 4px;
    padding-top: 6px;
    border-top: 1px solid var(--border-subtle);
  }

  .status-select {
    margin-left: auto;
  }
}

@media (max-width: 768px) {
  .header-inner {
    flex-wrap: wrap;
    gap: 8px;
  }

  .header-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
    width: 100%;
  }

  .modal {
    padding: 8px;
    align-items: flex-end;
  }

  .modal-box {
    max-height: 92vh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }

  .modal-box-wide {
    max-width: 100%;
  }

  .import-tabs {
    padding: 0 12px 10px;
    overflow-x: auto;
  }

  .filters select {
    min-width: 0;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .header-inner { padding: 8px 12px; }
  .main { padding: 10px 12px 20px; }
  .brand p { display: none; }
  #btn-refresh-all .btn-label,
  #btn-alerts .btn-label,
  #btn-export .btn-label,
  #btn-import .btn-label,
  #btn-import-aliexpress .btn-label { display: none; }
  #btn-new { padding: 6px 10px; font-size: 0.75rem; }
  .field-row { grid-template-columns: 1fr; }
  .field-row-3 { grid-template-columns: 1fr; }
  .stat-chip { font-size: 0.6875rem; padding: 3px 8px; }
  .payment-links { flex-direction: column; align-items: flex-start; }
}

/* Auth */
#auth-screen:not(.hidden) {
  position: fixed;
  inset: 0;
  z-index: 300;
  overflow-y: auto;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(160deg, #fff5f5 0%, var(--surface) 45%, #eef2ff 100%);
}

#auth-screen.hidden {
  display: none !important;
  pointer-events: none !important;
  visibility: hidden !important;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
  padding: 28px 24px;
}

.auth-brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 22px;
}

.auth-brand h1 {
  font-size: 1.25rem;
  color: var(--text-strong);
  margin-bottom: 4px;
}

.auth-brand p {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.auth-tab {
  border: 1px solid var(--border);
  background: var(--surface-overlay);
  color: var(--text);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-weight: 600;
  cursor: pointer;
}

.auth-tab.active {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand-dark);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-strong);
}

.auth-form input {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font: inherit;
}

.auth-form input:focus {
  outline: 2px solid var(--brand-soft);
  border-color: var(--brand);
}

.auth-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.btn-block {
  width: 100%;
  justify-content: center;
  margin-top: 4px;
}

#home-screen.hidden {
  display: none !important;
  pointer-events: none !important;
}

#app-shell:not(.hidden) {
  position: relative;
  z-index: 10;
  min-height: 100vh;
  background: var(--surface);
}

#app-shell.hidden {
  display: none !important;
  pointer-events: none !important;
}

.user-badge {
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 4px;
}

/* Landing / Home */
.home-screen {
  background: #fff;
  color: var(--text-strong);
}

.home-screen:not(.hidden) {
  position: relative;
  z-index: 1;
}

.home-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
}

.home-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-strong);
  text-decoration: none;
}

.home-nav-links {
  display: flex;
  gap: 24px;
}

.home-nav-links a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
}

.home-nav-links a:hover {
  color: var(--brand);
}

.home-nav-actions {
  display: flex;
  gap: 8px;
}

.btn-lg {
  padding: 12px 22px;
  font-size: 0.95rem;
}

.home-hero {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 48px;
  align-items: center;
  max-width: 1180px;
  margin: 0 auto;
  padding: 56px 24px 40px;
}

.home-eyebrow {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--brand);
  margin-bottom: 12px;
}

.home-hero h1 {
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  line-height: 1.15;
  color: var(--text-strong);
  margin-bottom: 16px;
}

.home-hero-lead {
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--text);
  max-width: 520px;
  margin-bottom: 28px;
}

.home-hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.home-hero-points {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.home-hero-points li::before {
  content: "✓ ";
  color: var(--brand);
  font-weight: 700;
}

.home-hero-visual img,
.home-feature-img img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
}

.home-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  max-width: 1180px;
  margin: 0 auto 24px;
  padding: 0 24px;
}

.home-stat {
  text-align: center;
  padding: 20px 16px;
  background: var(--surface-overlay);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.home-stat strong {
  display: block;
  font-size: 1.5rem;
  color: var(--brand);
  margin-bottom: 4px;
}

.home-stat span {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.home-section {
  max-width: 1180px;
  margin: 0 auto;
  padding: 48px 24px 24px;
}

.home-section-head {
  text-align: center;
  max-width: 680px;
  margin: 0 auto 48px;
}

.home-section-head h2 {
  font-size: clamp(1.4rem, 3vw, 2rem);
  margin-bottom: 12px;
  color: var(--text-strong);
}

.home-section-head p {
  font-size: 1rem;
  color: var(--text);
  line-height: 1.6;
}

.home-feature {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: center;
  margin-bottom: 64px;
}

.home-feature-reverse .home-feature-text {
  order: 2;
}

.home-feature-reverse .home-feature-img {
  order: 1;
}

.home-feature-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.home-feature-text h3 {
  font-size: 1.5rem;
  color: var(--text-strong);
  margin-bottom: 12px;
}

.home-feature-text p {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text);
  margin-bottom: 16px;
}

.home-feature-text ul {
  margin-left: 18px;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.8;
}

.home-steps {
  max-width: 800px;
  margin: 0 auto;
  padding: 48px 24px;
  text-align: center;
}

.home-steps h2 {
  font-size: 1.75rem;
  margin-bottom: 32px;
  color: var(--text-strong);
}

.home-steps-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 20px;
  text-align: left;
}

.home-steps-list li {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 20px 24px;
  background: var(--surface-overlay);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.home-step-num {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  border-radius: 50%;
  font-size: 0.95rem;
}

.home-steps-list strong {
  display: block;
  color: var(--text-strong);
  margin-bottom: 4px;
}

.home-steps-list p {
  font-size: 0.9rem;
  color: var(--text);
}

.home-cta {
  text-align: center;
  padding: 64px 24px;
  margin: 24px 24px 0;
  background: linear-gradient(135deg, #fff5f5 0%, #eef1f6 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 1132px;
  margin-left: auto;
  margin-right: auto;
}

.home-cta h2 {
  font-size: 1.75rem;
  color: var(--text-strong);
  margin-bottom: 10px;
}

.home-cta p {
  color: var(--text);
  margin-bottom: 24px;
  font-size: 1rem;
}

.home-footer {
  text-align: center;
  padding: 32px 24px 48px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.auth-back {
  margin-top: 16px;
  text-align: center;
}

.link-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
}

.link-btn:hover {
  color: var(--brand);
}

@media (max-width: 900px) {
  .home-nav-links { display: none; }
  .user-badge { display: none; }
  #btn-logout .btn-label { display: none; }
  .home-hero {
    grid-template-columns: 1fr;
    padding-top: 32px;
  }
  .home-hero-visual { order: -1; }
  .home-stats { grid-template-columns: repeat(2, 1fr); }
  .home-feature,
  .home-feature-reverse {
    grid-template-columns: 1fr;
  }
  .home-feature-reverse .home-feature-text,
  .home-feature-reverse .home-feature-img {
    order: unset;
  }
  .home-nav-actions .btn-secondary { display: none; }
}

@media (max-width: 480px) {
  .home-hero-cta { flex-direction: column; }
  .home-hero-cta .btn { width: 100%; justify-content: center; }
  .home-stats { grid-template-columns: 1fr 1fr; }
}
