:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #eef4ff;
  --ink: #172033;
  --muted: #68758a;
  --line: #dce3ef;
  --primary: #1769e0;
  --primary-dark: #0f4fad;
  --accent: #19a974;
  --warning: #d97706;
  --danger: #dc2626;
  --shadow: 0 16px 40px rgba(28, 42, 68, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(23, 105, 224, 0.09), transparent 34%),
    linear-gradient(315deg, rgba(25, 169, 116, 0.09), transparent 30%),
    var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: 100vh;
  padding: 28px 20px;
  background: rgba(255, 255, 255, 0.86);
  border-right: 1px solid rgba(220, 227, 239, 0.85);
  backdrop-filter: blur(14px);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  color: #fff;
  background: var(--primary);
  border-radius: 8px;
  font-size: 22px;
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h3,
.panel p,
.search-copy h3,
.search-copy p,
.tracking-card h3 {
  margin: 0;
}

.brand h1 {
  font-size: 22px;
  line-height: 1.2;
}

.brand p,
.muted {
  color: var(--muted);
}

.nav-tabs {
  display: grid;
  gap: 10px;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  text-align: left;
}

.nav-tab span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: var(--primary);
  background: var(--surface-soft);
  border-radius: 8px;
  font-weight: 700;
}

.nav-tab.active {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
  box-shadow: var(--shadow);
}

.summary-card {
  margin-top: auto;
  padding: 18px;
  background: var(--ink);
  border-radius: 8px;
  color: #fff;
}

.summary-card .label {
  margin: 0 0 14px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 13px;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.summary-grid strong {
  display: block;
  font-size: 28px;
}

.summary-grid span {
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.eyebrow {
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar h2 {
  margin-top: 4px;
  font-size: clamp(24px, 4vw, 38px);
  line-height: 1.12;
}

.ghost-button,
.primary-button,
.search-form button,
.icon-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  transition:
    transform 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease;
}

.ghost-button {
  padding: 0 16px;
  color: var(--primary);
  background: var(--surface);
  border: 1px solid var(--line);
}

.primary-button,
.search-form button {
  padding: 0 18px;
  color: #fff;
  background: var(--primary);
  font-weight: 700;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  min-height: 42px;
  margin-top: 16px;
  padding: 0 16px;
  color: #fff;
  background: var(--primary);
  border-radius: 8px;
  font-weight: 700;
  text-decoration: none;
}

.primary-button:hover,
.search-form button:hover {
  background: var(--primary-dark);
}

button:active {
  transform: translateY(1px);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.search-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(320px, 1.4fr);
  align-items: center;
  gap: 18px;
  margin-bottom: 20px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.filter-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) 140px 140px 140px auto;
  gap: 10px;
}

.search-copy h3 {
  margin-top: 6px;
  font-size: 24px;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(23, 105, 224, 0.72);
  box-shadow: 0 0 0 4px rgba(23, 105, 224, 0.12);
}

.result-layout {
  min-height: 360px;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 360px;
  padding: 32px;
  text-align: center;
  background: rgba(255, 255, 255, 0.74);
  border: 1px dashed #c8d4e6;
  border-radius: 8px;
}

.empty-state h3,
.empty-state p {
  margin: 0;
}

.empty-state p {
  color: var(--muted);
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  color: var(--primary);
  background: var(--surface-soft);
  border-radius: 8px;
  font-size: 36px;
}

.tracking-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.tracking-card {
  padding: 24px;
}

.tracking-head,
.panel-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.tracking-number {
  margin-top: 6px;
  font-size: 26px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  color: #fff;
  background: var(--accent);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.status-badge.pending {
  background: var(--warning);
}

.status-badge.error {
  background: var(--danger);
}

.shipment-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 22px 0;
}

.shipment-meta div {
  padding: 14px;
  background: #f7f9fd;
  border: 1px solid #e8eef8;
  border-radius: 8px;
}

.shipment-meta span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.timeline {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline li {
  position: relative;
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 20px;
  padding: 0 0 22px 24px;
}

.timeline li::before {
  content: "";
  position: absolute;
  top: 7px;
  left: 5px;
  width: 10px;
  height: 10px;
  background: var(--primary);
  border: 3px solid #dbeafe;
  border-radius: 50%;
}

.timeline li::after {
  content: "";
  position: absolute;
  top: 24px;
  bottom: 0;
  left: 11px;
  width: 1px;
  background: var(--line);
}

.timeline li:last-child::after {
  display: none;
}

.timeline time {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.timeline strong {
  display: block;
  margin-bottom: 4px;
}

.timeline span {
  color: var(--muted);
}

.note {
  margin: 0;
  color: var(--muted);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.82fr);
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  padding: 20px;
}

.panel h3 {
  margin-top: 4px;
  font-size: 20px;
}

.form-panel,
.event-form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.three-col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.upload-zone {
  display: grid;
  grid-template-columns: minmax(260px, 0.72fr) minmax(260px, 1fr);
  gap: 14px;
  align-items: stretch;
}

.file-picker {
  align-content: start;
}

.image-preview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  place-items: stretch;
  gap: 10px;
  min-height: 220px;
  overflow: hidden;
  color: var(--muted);
  background: #f7f9fd;
  border: 1px dashed #c8d4e6;
  border-radius: 8px;
}

.image-preview img {
  width: 100%;
  height: 170px;
  object-fit: contain;
  background: #fff;
  border: 1px solid #e8eef8;
  border-radius: 8px;
}

.image-preview span {
  display: grid;
  place-items: center;
  min-height: 160px;
  text-align: center;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  color: var(--primary);
  background: var(--surface-soft);
}

.list-panel {
  overflow: hidden;
}

.compact-input {
  max-width: 280px;
}

.table-wrap {
  margin-top: 16px;
  overflow: auto;
}

.shipment-list {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.shipment-card {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 16px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.thumb-button {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 150px;
  overflow: hidden;
  color: var(--muted);
  background: #f7f9fd;
  border: 1px solid #e8eef8;
  border-radius: 8px;
}

.thumb-button img {
  width: 100%;
  height: 150px;
  object-fit: contain;
  background: #fff;
}

.shipment-info {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.shipment-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.shipment-title h3 {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  font-size: 22px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.info-grid div,
.detail-fields div,
.detail-meta div {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 10px;
  background: #f7f9fd;
  border: 1px solid #e8eef8;
  border-radius: 8px;
}

.info-grid span,
.detail-fields span,
.detail-meta span {
  color: var(--muted);
  font-size: 12px;
}

.info-grid strong,
.detail-fields strong,
.detail-meta strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.ops-table {
  min-width: 1180px;
}

.ops-table td {
  vertical-align: top;
}

.ops-table td span {
  color: var(--muted);
  font-size: 12px;
}

.table-thumb {
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  overflow: hidden;
  color: var(--muted);
  background: #f7f9fd;
  border: 1px solid #e8eef8;
  border-radius: 8px;
}

.table-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.address-cell {
  max-width: 280px;
  white-space: normal;
  overflow-wrap: anywhere;
}

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.small-button {
  min-height: 34px;
  padding: 0 10px;
  color: var(--ink);
  background: #f7f9fd;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.api-notes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.api-notes div {
  display: grid;
  gap: 8px;
  padding: 16px;
  background: #f7f9fd;
  border: 1px solid #e8eef8;
  border-radius: 8px;
}

.api-notes span {
  color: var(--muted);
  line-height: 1.6;
}

.detail-dialog {
  width: min(1120px, calc(100vw - 28px));
  max-height: min(860px, calc(100vh - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
}

.detail-dialog::backdrop {
  background: rgba(15, 23, 42, 0.48);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.dialog-head h3 {
  margin: 4px 0 0;
  font-size: 22px;
}

.detail-body {
  display: grid;
  grid-template-columns: minmax(320px, 1.2fr) minmax(280px, 0.8fr);
  gap: 16px;
  padding: 18px;
}

.detail-image {
  display: grid;
  place-items: center;
  min-height: 420px;
  overflow: auto;
  color: var(--muted);
  background: #f7f9fd;
  border: 1px solid #e8eef8;
  border-radius: 8px;
}

.detail-image img {
  max-width: 100%;
  max-height: 72vh;
  object-fit: contain;
  background: #fff;
}

.detail-fields,
.detail-form {
  display: grid;
  align-content: start;
  gap: 10px;
}

.detail-form {
  max-height: 72vh;
  overflow: auto;
  padding-right: 4px;
}

.form-section-title h4,
.form-section-title p {
  margin: 0;
}

.form-section-title h4 {
  margin-top: 4px;
  font-size: 18px;
}

.detail-meta {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 44px));
  padding: 13px 16px;
  color: #fff;
  background: var(--ink);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    padding: 18px;
  }

  .nav-tabs {
    grid-template-columns: repeat(3, 1fr);
  }

  .summary-card {
    margin-top: 0;
  }

  main {
    padding: 20px;
  }

  .search-panel,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .filter-grid,
  .upload-zone,
  .detail-body {
    grid-template-columns: 1fr;
  }

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

  .api-notes {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  main {
    padding: 14px;
  }

  .topbar,
  .tracking-head,
  .panel-title {
    align-items: stretch;
    flex-direction: column;
  }

  .nav-tab {
    justify-content: center;
    padding: 10px 8px;
  }

  .nav-tab span {
    display: none;
  }

  .search-form,
  .two-col,
  .three-col,
  .shipment-meta {
    grid-template-columns: 1fr;
  }

  .shipment-card {
    grid-template-columns: 1fr;
  }

  .shipment-title {
    flex-direction: column;
  }

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

  .timeline li {
    grid-template-columns: 1fr;
    gap: 4px;
  }

.compact-input {
  max-width: none;
}
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgb(15 23 42 / 0.42);
  backdrop-filter: blur(2px);
}

.loading-overlay[hidden] {
  display: none;
}

.loading-box {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 180px;
  padding: 16px 18px;
  color: #122033;
  background: #fff;
  border: 1px solid #e5eaf3;
  border-radius: 8px;
  box-shadow: 0 22px 55px rgb(15 23 42 / 0.22);
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #d7e4f7;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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