:root {
  --bg: #f3f6f5;
  --panel: #ffffff;
  --ink: #16231e;
  --muted: #68756f;
  --line: #e3eae6;
  --green: #087f5b;
  --green-dark: #056647;
  --green-soft: #e5f5ef;
  --navy: #102b25;
  --navy-2: #173a32;
  --blue: #2c68c9;
  --blue-soft: #e8f0fc;
  --amber: #bb6b09;
  --amber-soft: #fff1d6;
  --red: #b93b3b;
  --red-soft: #fdeaea;
  --shadow: 0 10px 28px rgba(18, 45, 37, 0.06);
}

[hidden] { display: none !important; }
.login-page { display: grid; min-height: 100vh; place-items: center; padding: 24px; }
.login-card { width: min(420px, 100%); padding: 36px; border: 1px solid var(--line); border-radius: 16px; background: white; box-shadow: var(--shadow); }
.login-card .brand-mark { margin-bottom: 20px; }
.login-card h1 { font-size: 25px; }
.login-card > p { color: var(--muted); margin-bottom: 24px; }
#loginError { color: var(--red); min-height: 20px; font-size: 13px; }

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family:
    "Microsoft YaHei UI", "PingFang SC", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  display: flex;
  width: 246px;
  flex-direction: column;
  padding: 28px 18px 22px;
  color: #fff;
  background:
    radial-gradient(circle at 15% 10%, rgba(38, 128, 99, 0.36), transparent 26%),
    linear-gradient(165deg, #12352c 0%, #0b241e 72%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 30px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 12px;
  color: #073a29;
  background: #d8f3e9;
  font-weight: 900;
  letter-spacing: -1px;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  margin-bottom: 3px;
  font-size: 16px;
}

.brand span {
  color: rgba(255, 255, 255, 0.55);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 14px;
  border-radius: 9px;
  color: rgba(255, 255, 255, 0.66);
  text-decoration: none;
  transition: 160ms ease;
}

.nav-link span {
  width: 18px;
  color: #8fcdb7;
  font-size: 20px;
  text-align: center;
}

.nav-link:hover,
.nav-link.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.09);
}

.privacy-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.045);
}

.privacy-card strong,
.privacy-card span {
  display: block;
}

.privacy-card strong {
  margin-bottom: 4px;
  font-size: 12px;
}

.privacy-card span {
  color: rgba(255, 255, 255, 0.5);
  font-size: 10px;
}

.status-dot {
  width: 8px;
  height: 8px;
  margin-top: 3px;
  border-radius: 50%;
  background: #5ce2ad;
  box-shadow: 0 0 0 4px rgba(92, 226, 173, 0.11);
}

.main {
  min-width: 0;
  margin-left: 246px;
  padding: 34px 38px 28px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 28px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 7px;
  color: var(--green);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 7px;
  font-size: clamp(26px, 3vw, 34px);
  letter-spacing: -0.035em;
}

h2 {
  margin-bottom: 6px;
  font-size: 19px;
  letter-spacing: -0.02em;
}

.topbar p:last-child,
.panel-heading p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

.header-actions,
.table-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.table-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.button {
  display: inline-flex;
  min-height: 39px;
  align-items: center;
  justify-content: center;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  transition:
    background 140ms ease,
    border 140ms ease,
    transform 140ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.button.primary {
  color: #fff;
  background: var(--green);
}

.button.primary:hover:not(:disabled) {
  background: var(--green-dark);
}

.button.secondary {
  border-color: #d9e3de;
  color: #31463e;
  background: #fff;
}

.button.dark {
  color: #fff;
  background: var(--navy);
}

.button.danger {
  color: var(--red);
}

.button.ghost {
  border-color: #eed9d9;
  background: #fff;
}

.button.wide {
  width: 100%;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 15px;
  margin-bottom: 18px;
}

@media (max-width: 1360px) and (min-width: 1101px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 118px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stat-icon {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border-radius: 10px;
  font-size: 19px;
  font-weight: 800;
}

.stat-icon.green {
  color: var(--green);
  background: var(--green-soft);
}

.stat-icon.blue {
  color: var(--blue);
  background: var(--blue-soft);
}

.stat-icon.amber {
  color: var(--amber);
  background: var(--amber-soft);
}

.stat-icon.red {
  color: var(--red);
  background: var(--red-soft);
}

.stat-card span,
.stat-card strong,
.stat-card small {
  display: block;
}

.stat-card span {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.stat-card strong {
  margin-bottom: 1px;
  font-size: 26px;
  line-height: 1.1;
}

.stat-card small {
  color: #9aa59f;
  font-size: 10px;
}

.carrier-panel {
  scroll-margin-top: 18px;
}

.carrier-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px;
  padding: 20px 24px 14px;
}

.carrier-stat-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid #dde7e2;
  border-radius: 10px;
  color: var(--ink);
  cursor: pointer;
  background: #fbfdfc;
  text-align: left;
  transition: 150ms ease;
}

.carrier-stat-card:hover {
  border-color: #8fc5b1;
  background: #f4faf7;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(18, 45, 37, 0.07);
}

.carrier-card-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.carrier-initial {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  border-radius: 8px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-weight: 900;
}

.carrier-stat-card:nth-child(2n) .carrier-initial {
  color: var(--blue);
  background: var(--blue-soft);
}

.carrier-stat-card:nth-child(3n) .carrier-initial {
  color: var(--amber);
  background: var(--amber-soft);
}

.carrier-view-link {
  color: #8a9992;
  font-size: 9px;
  font-weight: 700;
}

.carrier-stat-card > strong {
  display: block;
  overflow: hidden;
  margin-bottom: 4px;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.carrier-count {
  margin-bottom: 10px;
  color: #173c31;
  font-size: 22px;
  font-weight: 900;
}

.carrier-count small {
  color: #86958e;
  font-size: 9px;
  font-weight: 600;
}

.carrier-stat-card progress {
  display: block;
  width: 100%;
  height: 7px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: #e9efec;
  appearance: none;
}

.carrier-stat-card progress::-webkit-progress-bar {
  border-radius: 999px;
  background: #e9efec;
}

.carrier-stat-card progress::-webkit-progress-value {
  border-radius: 999px;
  background: var(--green);
}

.carrier-stat-card progress::-moz-progress-bar {
  border-radius: 999px;
  background: var(--green);
}

.carrier-stat-card p {
  margin: 7px 0 0;
  color: #7d8c85;
  font-size: 10px;
}

.carrier-stat-card p b {
  color: #40574e;
}

.carrier-stats-empty {
  grid-column: 1 / -1;
  padding: 30px;
  color: #91a099;
  text-align: center;
}

.carrier-disclaimer {
  margin: 0;
  padding: 0 24px 18px;
  color: #89978f;
  font-size: 9px;
}

.panel {
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px 17px;
  border-bottom: 1px solid var(--line);
}

.auto-dedupe-badge {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid #c8eadc;
  border-radius: 999px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 11px;
  font-weight: 800;
}

.import-grid {
  display: grid;
  grid-template-columns: 1fr 42px 1fr;
  gap: 20px;
  padding: 23px 24px 25px;
}

.import-column {
  min-width: 0;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: #34483f;
  font-size: 12px;
  font-weight: 800;
}

.text-input,
.paste-area,
.select-input,
.search-box {
  border: 1px solid #dbe4df;
  border-radius: 8px;
  background: #fff;
  outline: none;
  transition:
    border 140ms ease,
    box-shadow 140ms ease;
}

.text-input:focus,
.paste-area:focus,
.select-input:focus,
.search-box:focus-within {
  border-color: #55a68a;
  box-shadow: 0 0 0 3px rgba(8, 127, 91, 0.1);
}

.text-input {
  width: 100%;
  height: 41px;
  padding: 0 12px;
  margin-bottom: 12px;
}

.drop-zone {
  display: flex;
  min-height: 151px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  margin-bottom: 11px;
  padding: 20px;
  border: 1.5px dashed #adcbc0;
  border-radius: 10px;
  cursor: pointer;
  background: #f8fbfa;
  text-align: center;
  transition: 150ms ease;
}

.drop-zone:hover,
.drop-zone.dragging {
  border-color: var(--green);
  background: #f0f9f5;
}

.drop-zone.has-file {
  border-style: solid;
  border-color: #74b79f;
  background: var(--green-soft);
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.upload-icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  margin-bottom: 9px;
  border-radius: 50%;
  color: var(--green);
  background: var(--green-soft);
  font-size: 23px;
  font-weight: 900;
}

.drop-zone strong {
  max-width: 100%;
  overflow: hidden;
  margin-bottom: 4px;
  color: #29463c;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drop-zone small,
.input-note {
  color: #8b9993;
  font-size: 10px;
}

.paste-area {
  display: block;
  width: 100%;
  height: 200px;
  resize: vertical;
  padding: 12px;
  color: #263a32;
  line-height: 1.55;
}

.paste-area::placeholder,
.text-input::placeholder,
.search-box input::placeholder {
  color: #a7b1ad;
}

.input-note {
  margin: 7px 0 10px;
}

.import-divider {
  position: relative;
  display: grid;
  place-items: center;
  color: #a2ada8;
  font-size: 10px;
}

.import-divider::before {
  position: absolute;
  inset: 3px 50% 3px auto;
  width: 1px;
  content: "";
  background: var(--line);
}

.import-divider span {
  z-index: 1;
  padding: 7px 0;
  background: #fff;
}

.import-result {
  margin: 0 24px 24px;
  padding: 14px 16px;
  border: 1px solid #cbe7dc;
  border-radius: 9px;
  color: #255442;
  background: #eef8f4;
}

.marketing-panel {
  scroll-margin-top: 18px;
}

.marketing-guide {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin: 0;
  border-bottom: 1px solid var(--line);
  background: var(--line);
}

.marketing-guide div {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 24px;
  color: #52665e;
  background: #f9fbfa;
  font-size: 11px;
}

.marketing-guide strong {
  display: grid;
  width: 23px;
  height: 23px;
  flex: 0 0 23px;
  place-items: center;
  border-radius: 50%;
  color: var(--green);
  background: var(--green-soft);
  font-size: 10px;
}

.marketing-import-grid {
  padding-bottom: 20px;
}

.marketing-result {
  margin-bottom: 20px;
}

.result-download {
  color: var(--green-dark);
  font-weight: 800;
  text-decoration: none;
}

.result-download:hover {
  text-decoration: underline;
}

.marketing-history-heading {
  display: flex;
  justify-content: space-between;
  padding: 18px 24px 13px;
  border-top: 1px solid var(--line);
}

.marketing-history-heading h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.marketing-history-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.result-title {
  margin-bottom: 6px;
  font-weight: 800;
}

.result-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  font-size: 12px;
}

.result-metrics strong {
  color: var(--ink);
}

.table-heading {
  align-items: center;
}

.search-box {
  display: flex;
  width: min(270px, 29vw);
  height: 38px;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
}

.search-box span {
  color: #7c8d86;
  font-size: 19px;
}

.search-box input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
}

.select-input {
  height: 38px;
  padding: 0 30px 0 11px;
  color: #34483f;
}

.date-input {
  width: 142px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid #dbe4df;
  border-radius: 8px;
  color: #34483f;
  background: #fff;
}

.date-input[hidden] {
  display: none;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}

th,
td {
  padding: 12px 15px;
  border-bottom: 1px solid #edf1ef;
  text-align: left;
}

th {
  color: #6b7b74;
  background: #fafcfa;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

tbody tr:hover {
  background: #fbfdfc;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.checkbox-cell {
  width: 36px;
  padding-right: 2px;
}

input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--green);
}

.number-main {
  color: #163d31;
  font-weight: 800;
}

.carrier-pill,
.vendor-pill,
.count-pill,
.status-number {
  display: inline-flex;
  align-items: center;
  padding: 4px 7px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 800;
}

.carrier-pill {
  color: #315d4e;
  background: #edf5f2;
}

.vendor-pill {
  color: #31528a;
  background: #edf2fb;
}

.vendor-count {
  color: #173c31;
  font-size: 14px;
}

.vendor-create-form {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(260px, 1.4fr) auto;
  align-items: end;
  gap: 12px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: #fbfdfc;
}

.vendor-create-form .text-input {
  margin-bottom: 0;
}

.vendor-select {
  width: 100%;
  margin-bottom: 12px;
}

.vendor-note {
  max-width: 320px;
  overflow: hidden;
  color: #66776f;
  text-overflow: ellipsis;
}

.vendor-cell {
  display: flex;
  align-items: center;
  gap: 5px;
}

.vendor-edit-button {
  padding: 2px 4px;
  border: 0;
  color: #7b8c84;
  cursor: pointer;
  background: transparent;
  font-size: 9px;
}

.vendor-edit-button:hover {
  color: var(--green);
  text-decoration: underline;
}

.count-pill {
  min-width: 24px;
  justify-content: center;
  color: #486057;
  background: #f0f3f2;
}

.status-number.added {
  color: var(--green);
  background: var(--green-soft);
}

.status-number.duplicate {
  color: var(--amber);
  background: var(--amber-soft);
}

.status-number.invalid {
  color: var(--red);
  background: var(--red-soft);
}

.invalid-link {
  color: var(--red);
  font-weight: 800;
  text-decoration: none;
}

.invalid-link:hover {
  text-decoration: underline;
}

.source-cell {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-subtitle {
  display: block;
  max-width: 190px;
  overflow: hidden;
  margin-top: 3px;
  color: #8b9993;
  font-size: 9px;
  font-weight: 400;
  text-overflow: ellipsis;
}

.batch-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.mini-button,
.export-menu summary {
  display: inline-flex;
  min-height: 29px;
  align-items: center;
  justify-content: center;
  padding: 0 9px;
  border: 1px solid #dce5e0;
  border-radius: 6px;
  color: #40554d;
  cursor: pointer;
  background: #fff;
  font-size: 10px;
  font-weight: 800;
  text-decoration: none;
}

.mini-button.primary-mini {
  border-color: #bee0d4;
  color: var(--green-dark);
  background: var(--green-soft);
}

.mini-button:disabled {
  cursor: default;
  color: #789087;
  background: #f0f5f3;
  opacity: 0.72;
}

.commit-button:not(:disabled) {
  color: #fff;
  background: var(--navy);
}

.export-menu {
  position: relative;
}

.export-menu summary {
  list-style: none;
}

.export-menu summary::-webkit-details-marker {
  display: none;
}

.export-menu[open] > div {
  position: absolute;
  right: 0;
  z-index: 12;
  display: grid;
  min-width: 108px;
  margin-top: 5px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  box-shadow: var(--shadow);
}

.export-menu div a {
  padding: 7px 8px;
  border-radius: 5px;
  color: #40554d;
  text-decoration: none;
}

.export-menu div a:hover {
  background: var(--green-soft);
}

.empty-cell {
  height: 92px;
  color: #91a099;
  text-align: center;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 18px;
  border-top: 1px solid var(--line);
  color: #718078;
  font-size: 11px;
}

.duplicate-summary {
  padding: 13px 18px;
  border-top: 1px solid var(--line);
  color: #718078;
  font-size: 11px;
}

.pagination > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-button {
  height: 31px;
  padding: 0 10px;
  border: 1px solid #dce5e0;
  border-radius: 6px;
  color: #40554d;
  cursor: pointer;
  background: #fff;
}

.page-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

footer {
  display: flex;
  justify-content: space-between;
  padding: 3px 4px 0;
  color: #8c9994;
  font-size: 10px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  max-width: min(390px, calc(100vw - 48px));
  padding: 12px 15px;
  border-radius: 9px;
  color: #fff;
  background: var(--navy);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.2);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: 180ms ease;
}

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

.toast.error {
  background: #8f3030;
}

@media (max-width: 1100px) {
  .sidebar {
    width: 210px;
  }

  .main {
    margin-left: 210px;
    padding: 28px 24px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .carrier-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .table-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .table-actions {
    width: 100%;
  }

  .search-box {
    width: auto;
    flex: 1;
  }
}

@media (max-width: 760px) {
  .sidebar {
    position: static;
    width: auto;
    padding: 15px;
  }

  .brand {
    padding-bottom: 14px;
  }

  .nav {
    display: flex;
    overflow-x: auto;
  }

  .nav-link {
    flex: 0 0 auto;
  }

  .privacy-card {
    display: none;
  }

  .main {
    margin-left: 0;
    padding: 22px 14px;
  }

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

  .header-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .header-actions .button {
    flex: 1;
  }

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

  .marketing-guide {
    grid-template-columns: 1fr;
  }

  .import-divider {
    height: 16px;
  }

  .import-divider::before {
    inset: 50% 0 auto;
    width: auto;
    height: 1px;
  }

  .import-divider span {
    padding: 0 8px;
  }

  .table-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .vendor-create-form {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .batch-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .search-box {
    width: 100%;
    flex: none;
  }

  footer {
    gap: 5px;
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .carrier-stats-grid {
    grid-template-columns: 1fr;
  }

  .panel-heading,
  .import-grid {
    padding-right: 16px;
    padding-left: 16px;
  }

  .auto-dedupe-badge {
    display: none;
  }
}
