:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --ink: #17211d;
  --muted: #66736d;
  --line: #d7dfdb;
  --brand: #0d7c66;
  --brand-dark: #075949;
  --accent: #b26b13;
  --danger: #b3332b;
  --shadow: 0 14px 34px rgba(21, 41, 34, 0.09);
}

* {
  box-sizing: border-box;
}

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

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

button {
  min-height: 40px;
  border: 0;
  border-radius: 7px;
  padding: 0 14px;
  color: #fff;
  background: var(--brand);
  cursor: pointer;
}

button:hover {
  background: var(--brand-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.ghost {
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

button.danger {
  background: var(--danger);
}

button.icon-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
  color: var(--ink);
  background: var(--surface-2);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 20px 24px;
  color: #fff;
  background: #16362f;
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: 24px;
}

.eyebrow {
  margin: 0;
  color: #b9d5cc;
  font-size: 12px;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.language-switcher {
  display: grid;
  grid-template-columns: auto minmax(120px, 150px);
  align-items: center;
  gap: 8px;
  color: #d8e8e3;
  font-size: 13px;
}

.language-switcher select {
  min-height: 38px;
  color: var(--ink);
  background: #fff;
}

.auth-status {
  align-self: center;
  color: #d8e8e3;
  font-size: 13px;
}

.layout {
  display: grid;
  grid-template-columns: 210px 1fr;
  min-height: calc(100vh - 84px);
}

.sidebar {
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: #f9fbfa;
}

.nav-button {
  width: 100%;
  margin-bottom: 8px;
  text-align: left;
  color: var(--ink);
  background: transparent;
}

.nav-button.active,
.nav-button:hover {
  color: #fff;
  background: var(--brand);
}

.content {
  padding: 24px;
  overflow: auto;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.section-head h2,
.panel h3 {
  margin: 0 0 6px;
}

.section-head p {
  margin: 0;
  color: var(--muted);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.kpi span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.kpi strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.dashboard-search {
  padding: 16px;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.dashboard-search-results {
  margin-top: 14px;
}

.dashboard-main {
  margin-top: 4px;
}

.compact-head {
  margin-bottom: 10px;
}

.compact-head h3 {
  margin: 0 0 4px;
}

.compact-head p {
  margin: 0;
  color: var(--muted);
}

.dashboard-container-table {
  min-width: 640px;
}

.container-management-table {
  min-width: 720px;
}

.dashboard-container-table td:first-child {
  font-size: 18px;
  font-weight: 700;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 10px 2px 0;
  color: var(--muted);
  font-size: 13px;
}

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

.dialog-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 16px;
}

.login-form {
  min-width: min(460px, calc(100vw - 48px));
}

.form-message {
  margin: 0;
  color: var(--danger);
  min-height: 20px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.panel,
.form-grid,
.lookup-box,
.report-tools {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.panel-note {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.55;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
  padding: 18px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
}

textarea {
  resize: vertical;
}

.wide {
  grid-column: span 2;
}

.full {
  grid-column: 1 / -1;
}

.inline-option {
  justify-content: flex-end;
}

.check-control {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
}

.check-control input {
  width: auto;
  min-height: auto;
}

.cargo-code-field input {
  min-height: 52px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0;
  background: #edf4f1;
}

.cargo-code-field input.manual-code {
  background: #fff;
  border-color: var(--accent);
}

.admin-setting-form {
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

#destinationAdminList {
  max-height: 620px;
  overflow: auto;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.photo-box {
  border: 1px dashed #b9c7c1;
  border-radius: 8px;
  padding: 14px;
}

.photo-controls {
  display: grid;
  grid-template-columns: 150px 130px minmax(220px, 1fr);
  gap: 10px;
  align-items: center;
}

.inline-check {
  flex-direction: row;
  align-items: center;
  color: var(--ink);
}

.inline-check input {
  width: auto;
  min-height: auto;
}

.toggle-row {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  align-items: center;
}

.admin-panel {
  display: none;
}

.admin-stack {
  display: grid;
  gap: 18px;
}

.admin-pricing-grid,
.admin-destination-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.admin-table-wrap table {
  min-width: 980px;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.photo-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.photo-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.photo-meta {
  display: grid;
  gap: 6px;
  padding: 8px;
  font-size: 12px;
}

.filters,
.lookup-box,
.report-tools {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px;
  margin-bottom: 16px;
}

.filters input {
  flex: 1;
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  color: #31443d;
  background: #edf4f1;
  font-weight: 700;
  white-space: nowrap;
}

td .row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

td button {
  min-height: 32px;
  padding: 0 9px;
  font-size: 13px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  color: #0d4337;
  background: #dff3ec;
  white-space: nowrap;
}

.container-card {
  padding: 12px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.container-card.active {
  border-color: var(--brand);
  box-shadow: inset 3px 0 0 var(--brand);
}

.meter {
  height: 10px;
  margin: 8px 0;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8e5;
}

.meter span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.stack {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.compact table {
  min-width: 560px;
}

.manifest {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.manifest tr.marker-stock td {
  background: #fff200;
}

.manifest tr.marker-marked td {
  background: #ffd9d9;
}

.manifest tr.marker-tax td {
  background: #dcecff;
}

.announcement-panel {
  margin-bottom: 18px;
}

.announcement-text {
  min-height: 92px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  line-height: 1.65;
  white-space: normal;
}

.lookup-result {
  margin-bottom: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.track-page {
  min-height: 100vh;
  background: #edf3f0;
}

.track-shell {
  width: min(980px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 36px 0;
}

.track-card {
  max-width: 460px;
  margin: 0 auto 22px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.track-card h1 {
  margin: 4px 0 8px;
}

.track-card p {
  margin: 0 0 16px;
  color: var(--muted);
}

.track-login {
  display: grid;
  gap: 12px;
}

.track-results {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

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

.detail-item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fafcfa;
}

.detail-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

dialog {
  width: min(980px, calc(100vw - 30px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.25);
}

#detailDialog {
  width: min(1240px, calc(100vw - 24px));
}

dialog::backdrop {
  background: rgba(5, 20, 16, 0.46);
}

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

.dialog-head h2 {
  margin: 0;
}

#detailBody {
  padding: 16px;
}

.container-detail-wrap {
  max-height: min(62vh, 680px);
}

.container-detail-table {
  min-width: 1080px;
}

.container-detail-table th,
.container-detail-table td {
  padding: 9px 10px;
}

.cell-muted {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.note-cell {
  max-width: 220px;
  line-height: 1.45;
}

.sticky-actions {
  position: sticky;
  right: 0;
  z-index: 1;
  background: var(--surface);
  box-shadow: -8px 0 10px rgba(244, 246, 245, 0.82);
}

th.sticky-actions {
  z-index: 2;
  background: #edf4f1;
}

.container-detail-table .row-actions {
  min-width: 210px;
}

.master-list {
  display: grid;
  gap: 8px;
}

.master-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.master-row span {
  flex: 1;
}

@media (max-width: 980px) {
  .layout,
  .split {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-button {
    flex: 0 0 auto;
    width: auto;
    white-space: nowrap;
  }

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

  .admin-pricing-grid,
  .admin-destination-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .topbar,
  .top-actions,
  .section-head,
  .filters,
  .lookup-box,
  .report-tools,
  .photo-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    padding: 16px;
  }

  .language-switcher {
    grid-template-columns: 1fr;
  }

  .content {
    padding: 16px;
  }

  .kpi-grid,
  .form-grid,
  .admin-pricing-grid,
  .admin-destination-form,
  .photo-controls,
  .detail-grid,
  .dialog-form {
    grid-template-columns: 1fr;
  }

  .dashboard-search-bar {
    grid-template-columns: 1fr;
  }

  .wide {
    grid-column: span 1;
  }
}

@media print {
  body * {
    visibility: hidden;
  }

  .print-area,
  .print-area * {
    visibility: visible;
  }

  .print-area {
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    padding: 16px;
    background: #fff;
  }

  .no-print {
    display: none !important;
  }
}
