.vendor-tools-page {
  display: grid;
  gap: var(--momo-space-5);
  color: var(--momo-text-primary);
}

.vendor-tools-page .container,
.vendor-tools-page .container-fluid {
  max-width: 100%;
  padding: 0 !important;
}

.vendor-tools-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: var(--momo-space-2);
  color: var(--momo-page-accent-dark);
  font-family: var(--momo-font-mono);
  font-size: var(--momo-text-label);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.vendor-tools-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--momo-space-4);
  align-items: end;
  padding: var(--momo-space-5);
  border: 1px solid var(--momo-border-light);
  border-radius: var(--momo-radius-lg);
  background:
    radial-gradient(circle at 14px 14px, rgba(172, 92, 58, 0.16) 1.2px, transparent 1.4px) 0 0 / 18px 18px,
    var(--momo-bg-surface);
}

.vendor-tools-header h1 {
  margin: 0;
  font-family: var(--momo-font-display);
  font-size: clamp(1.55rem, 2.2vw, 2.2rem);
  font-weight: 800;
  letter-spacing: 0;
  color: var(--momo-text-primary);
}

.vendor-tools-header p {
  max-width: 760px;
  margin: var(--momo-space-2) 0 0;
  color: var(--momo-text-secondary);
  line-height: 1.65;
}

.vendor-tools-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.vendor-tools-nav a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 7px 11px;
  border: 1px solid var(--momo-border-light);
  border-radius: var(--momo-radius-sm);
  background: var(--momo-bg-elevated);
  color: var(--momo-text-secondary);
  font-family: var(--momo-font-display);
  font-size: var(--momo-text-body-sm);
  font-weight: 650;
  text-decoration: none;
}

.vendor-tools-nav a:hover,
.vendor-tools-nav a.is-active {
  border-color: var(--momo-page-accent-line);
  background: var(--momo-page-accent-soft);
  color: var(--momo-page-accent-dark);
}

.vendor-tools-body {
  display: grid;
  gap: var(--momo-space-4);
}

.vendor-tools-page h2,
.vendor-tools-page h3,
.vendor-tools-page h4,
.vendor-tools-page h5,
.vendor-tools-page h6 {
  color: var(--momo-text-primary);
  font-family: var(--momo-font-display);
  letter-spacing: 0;
}

.vendor-tools-page h2 {
  font-size: 1.28rem;
  font-weight: 800;
}

.vendor-tools-page .section-tabs,
.vendor-tools-page .table-container,
.vendor-tools-page .stats-card,
.vendor-tools-page .card {
  border: 1px solid var(--momo-border-light) !important;
  border-radius: var(--momo-radius-md) !important;
  background: var(--momo-bg-surface) !important;
  box-shadow: none !important;
}

.vendor-tools-page .section-tabs {
  overflow: hidden;
  margin-bottom: var(--momo-space-4);
}

.vendor-tools-page .section-tabs .nav-link {
  border: 0;
  border-radius: 0;
  padding: 0.82rem 1rem;
  color: var(--momo-text-secondary);
  font-family: var(--momo-font-display);
  font-weight: 700;
}

.vendor-tools-page .section-tabs .nav-link.active {
  background: var(--momo-text-primary) !important;
  color: var(--momo-bg-paper) !important;
}

.vendor-tools-page .section-tabs .nav-link:hover:not(.active) {
  background: var(--momo-bg-paper);
  color: var(--momo-text-primary);
}

.vendor-tools-page .stats-card {
  padding: var(--momo-space-4);
  min-height: 118px;
}

.vendor-tools-page .stats-number,
.vendor-tools-page h3[id^="stat"] {
  color: var(--momo-text-primary) !important;
  font-family: var(--momo-font-mono);
  font-size: clamp(1.45rem, 2vw, 1.95rem) !important;
  font-weight: 800 !important;
  letter-spacing: 0;
}

.vendor-tools-page .table-container {
  overflow: hidden;
}

.vendor-tools-page .table-container .table-responsive {
  max-width: 100%;
  overflow-x: auto;
}

.vendor-tools-page .table {
  min-width: 860px;
}

.vendor-tools-page .table tbody tr:hover {
  transform: none !important;
}

.vendor-tools-page .email-badge,
.vendor-tools-page .status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin: 2px;
  padding: 3px 8px;
  border: 1px solid var(--momo-border-light);
  border-radius: var(--momo-radius-sm);
  background: var(--momo-bg-paper);
  color: var(--momo-text-secondary);
  font-family: var(--momo-font-mono);
  font-size: 0.78rem;
  font-weight: 700;
}

.vendor-tools-page .status-sent {
  border-color: var(--momo-success-border);
  background: var(--momo-success-bg);
  color: var(--momo-success-text);
}

.vendor-tools-page .status-failed {
  border-color: var(--momo-danger-border);
  background: var(--momo-danger-bg);
  color: var(--momo-danger-text);
}

.vendor-tools-page .status-pending {
  border-color: var(--momo-warning-border);
  background: var(--momo-warning-bg);
  color: var(--momo-warning-text);
}

.vendor-tools-page .upload-area {
  border: 1px dashed var(--momo-page-accent-line) !important;
  border-radius: var(--momo-radius-md) !important;
  padding: clamp(1.2rem, 4vw, 2.6rem) !important;
  background:
    radial-gradient(circle at 10px 10px, rgba(172, 92, 58, 0.13) 1.1px, transparent 1.3px) 0 0 / 16px 16px,
    var(--momo-bg-elevated) !important;
  cursor: pointer;
}

.vendor-tools-page .upload-area:hover,
.vendor-tools-page .upload-area.dragover {
  border-color: var(--momo-page-accent-dark) !important;
  background-color: var(--momo-page-accent-soft) !important;
  transform: none !important;
}

.vendor-tools-page .upload-icon {
  color: var(--momo-page-accent-dark) !important;
}

.vendor-tools-page .modal-header {
  border-bottom: 1px solid var(--momo-border-light);
  background: var(--momo-text-primary) !important;
  color: var(--momo-bg-paper) !important;
}

.vendor-tools-page .modal-content {
  border: 1px solid var(--momo-border-light);
  border-radius: var(--momo-radius-md);
  background: var(--momo-bg-surface);
}

.vendor-tools-page .alert-info {
  border-color: var(--momo-info-border);
  background: var(--momo-info-bg);
  color: var(--momo-info-text);
}

.vendor-tools-page .alert-danger {
  border-color: var(--momo-danger-border);
  background: var(--momo-danger-bg);
  color: var(--momo-danger-text);
}

@media (max-width: 900px) {
  .vendor-tools-header {
    grid-template-columns: 1fr;
    align-items: start;
    padding: var(--momo-space-4);
  }

  .vendor-tools-nav {
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  .vendor-tools-page {
    gap: var(--momo-space-4);
  }

  .vendor-tools-header {
    border-radius: var(--momo-radius-md);
  }

  .vendor-tools-nav a {
    flex: 1 1 calc(50% - 8px);
    justify-content: center;
  }

  .vendor-tools-page .row {
    row-gap: var(--momo-space-3);
  }

  .vendor-tools-page .table-container {
    padding: 10px;
  }

  .vendor-tools-page .table {
    min-width: 0;
  }

  .vendor-tools-page .table-container .table-responsive {
    overflow-x: visible;
  }

  .vendor-tools-page .table-container table,
  .vendor-tools-page .table-container tbody,
  .vendor-tools-page .table-container tr,
  .vendor-tools-page .table-container td {
    display: block;
    width: 100%;
  }

  .vendor-tools-page .table-container thead {
    display: none;
  }

  .vendor-tools-page .table-container tbody {
    display: grid;
    gap: 10px;
  }

  .vendor-tools-page .table-container tbody tr {
    overflow: hidden;
    border: 1px solid var(--momo-border-light);
    border-radius: var(--momo-radius-sm);
    background: var(--momo-bg-elevated);
  }

  .vendor-tools-page .table-container tbody td {
    display: grid;
    grid-template-columns: 5.8rem minmax(0, 1fr);
    gap: 10px;
    min-height: 40px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--momo-border-light);
    text-align: left !important;
    overflow-wrap: anywhere;
  }

  .vendor-tools-page .table-container tbody td:last-child {
    border-bottom: 0;
  }

  .vendor-tools-page .table-container tbody td::before {
    color: var(--momo-text-tertiary);
    font-family: var(--momo-font-mono);
    font-size: 0.74rem;
    font-weight: 800;
  }

  .vendor-tools-page .table-container tbody td[colspan] {
    display: block;
  }

  .vendor-tools-page .table-container tbody td[colspan]::before {
    content: none;
  }

  .vendor-tools-page[data-vendor-tool="management"] .table-container tbody td:nth-child(1)::before { content: "代碼"; }
  .vendor-tools-page[data-vendor-tool="management"] .table-container tbody td:nth-child(2)::before { content: "廠商"; }
  .vendor-tools-page[data-vendor-tool="management"] .table-container tbody td:nth-child(3)::before { content: "郵件"; }
  .vendor-tools-page[data-vendor-tool="management"] .table-container tbody td:nth-child(4)::before { content: "數量"; }
  .vendor-tools-page[data-vendor-tool="management"] .table-container tbody td:nth-child(5)::before { content: "操作"; }

  .vendor-tools-page[data-vendor-tool="email"] .table-container tbody td:nth-child(1)::before { content: "ID"; }
  .vendor-tools-page[data-vendor-tool="email"] .table-container tbody td:nth-child(2)::before { content: "批次"; }
  .vendor-tools-page[data-vendor-tool="email"] .table-container tbody td:nth-child(3)::before { content: "廠商"; }
  .vendor-tools-page[data-vendor-tool="email"] .table-container tbody td:nth-child(4)::before { content: "收件"; }
  .vendor-tools-page[data-vendor-tool="email"] .table-container tbody td:nth-child(5)::before { content: "主旨"; }
  .vendor-tools-page[data-vendor-tool="email"] .table-container tbody td:nth-child(6)::before { content: "商品"; }
  .vendor-tools-page[data-vendor-tool="email"] .table-container tbody td:nth-child(7)::before { content: "狀態"; }
  .vendor-tools-page[data-vendor-tool="email"] .table-container tbody td:nth-child(8)::before { content: "時間"; }
}

@media (max-width: 520px) {
  .vendor-tools-nav a {
    flex-basis: 100%;
  }

  .vendor-tools-page .d-flex.justify-content-between {
    align-items: stretch !important;
    flex-direction: column;
    gap: 10px;
  }
}
