:root {
  color-scheme: light;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background: #f5f7f8;
  color: #172126;
  --accent: #147c72;
  --accent-strong: #0f5f57;
  --line: #d9e1e5;
  --muted: #64747c;
  --panel: #ffffff;
  --danger: #b3261e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: #f5f7f8;
}

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

button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  min-height: 36px;
  padding: 0 12px;
  cursor: pointer;
}

button.secondary {
  background: #fff;
  color: var(--accent-strong);
}

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

button.small {
  min-height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

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

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

textarea {
  min-height: 78px;
  resize: vertical;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 16px 40px rgba(29, 51, 59, 0.1);
}

.login-panel h1,
.page-title h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.25;
}

.login-panel p,
.muted {
  color: var(--muted);
  margin: 6px 0 0;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 232px 1fr;
}

.sidebar {
  background: #10282c;
  color: #dce8e8;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  font-weight: 700;
  font-size: 18px;
  margin: 0 0 18px;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mobile-menu-toggle {
  display: none;
}

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

.nav button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  text-align: left;
  background: transparent;
  border-color: transparent;
  color: #dce8e8;
}

.nav button.active {
  background: #1f494d;
  border-color: #2b5d62;
}

.nav-ship-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  margin-left: 2px;
  fill: none;
  stroke: #b8f0e8;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav button.active .nav-ship-icon {
  stroke: #ffffff;
}

.page-title h1 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.title-ship-icon {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.main {
  min-width: 0;
  padding: 22px;
}

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

.page-title {
  display: grid;
  gap: 4px;
}

.grid {
  display: grid;
  gap: 14px;
}

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

.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.inventory-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.inventory-panel {
  min-width: 0;
}

.inventory-panel table {
  min-width: 560px;
}

.report-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.report-columns table {
  min-width: 700px;
}

.report-form {
  grid-template-columns: minmax(132px, 150px) minmax(150px, 168px) minmax(150px, 168px) minmax(118px, 140px) 1fr;
  align-items: end;
}

.offshore-form {
  grid-template-columns: 1.25fr 0.8fr 0.7fr 0.7fr 0.9fr 1fr 1fr auto;
}

.offshore-inbound-bar {
  display: grid;
  grid-template-columns: minmax(220px, 360px) auto;
  gap: 10px;
  align-items: end;
  margin: 12px 0;
}

.date-field input {
  min-width: 0;
}

.series-filter {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 36px;
  color: #35474e;
  font-size: 13px;
}

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

.series-filter label {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  color: #172126;
}

.series-filter input {
  width: auto;
  min-height: 0;
  padding: 0;
}

.quick-range {
  display: flex;
  gap: 8px;
  align-items: end;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.quick-range button {
  min-width: 82px;
}

.chart-card {
  min-width: 0;
}

.chart-legend {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-right: 6px;
  vertical-align: -1px;
}

.legend-dot.purchase,
.purchase-point {
  background: #147c72;
  fill: #147c72;
}

.legend-dot.outbound,
.outbound-point {
  background: #b6652d;
  fill: #b6652d;
}

.trend-chart {
  width: 100%;
  min-height: 260px;
  display: block;
}

.trend-chart text {
  fill: var(--muted);
  font-size: 12px;
}

.axis,
.grid-line {
  stroke: var(--line);
  stroke-width: 1;
}

.line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.purchase-line {
  stroke: #147c72;
}

.outbound-line {
  stroke: #b6652d;
}

.empty-chart {
  display: grid;
  place-items: center;
  min-height: 220px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #f8fbfb;
}

.metric {
  display: grid;
  gap: 8px;
}

.metric strong {
  font-size: 24px;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-title h2 {
  margin: 0;
  font-size: 18px;
}

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(220px, 360px) auto auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.search-box {
  position: relative;
  min-width: 0;
}

.search-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 8;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(22, 42, 49, 0.14);
}

.search-suggestions button {
  display: block;
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: #172126;
  text-align: left;
}

.search-suggestions button:hover {
  background: #eef6f4;
  color: var(--accent-strong);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.form-grid label,
.stack label {
  display: grid;
  gap: 5px;
  color: #35474e;
  font-size: 13px;
}

.stack {
  display: grid;
  gap: 10px;
}

.advanced-login {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #f8fbfb;
}

.advanced-login summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}

.advanced-login label {
  margin-top: 10px;
}

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

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.pagination span {
  min-width: 150px;
  text-align: center;
}

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

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

th {
  background: #eef3f4;
  color: #405159;
  font-weight: 700;
}

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

tr.clickable-row {
  cursor: pointer;
}

tr.clickable-row:hover td,
tr.clickable-row:focus-visible td {
  background: #eef6f4;
}

tr.clickable-row:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #e8f3f1;
  color: #0f5f57;
  font-size: 12px;
}

.danger-status {
  background: #f8e7e5;
  color: var(--danger);
}

.offshore-status-arrived_shipping_warehouse {
  background: #e9f3ff;
  color: #215c91;
}

.offshore-status-at_sea {
  background: #fff2de;
  color: #8a4d12;
}

.offshore-status-in_stock {
  background: #e8f3f1;
  color: #0f5f57;
}

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

.row-check {
  width: 18px;
  min-height: 18px;
  padding: 0;
}

.timeline {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 4px 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfb;
}

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

.timeline-item strong {
  font-size: 13px;
}

.timeline-item em {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.error {
  color: var(--danger);
  min-height: 20px;
}

.success {
  color: var(--accent-strong);
  min-height: 20px;
}

.section-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.section-tabs button {
  background: #fff;
  color: #1d383d;
  border-color: var(--line);
}

.section-tabs button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.mobile-inventory-tabs {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(9, 25, 28, 0.42);
  z-index: 10;
}

.modal {
  width: min(560px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 18px 48px rgba(10, 28, 31, 0.22);
}

.detail-modal {
  width: min(680px, 100%);
}

.detail-grid {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 10px 14px;
  margin-top: 10px;
}

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

.detail-grid strong {
  font-weight: 600;
}

.confirm-row {
  margin-top: 16px;
}

.confirm-row label {
  display: grid;
  gap: 6px;
  color: #35474e;
  font-size: 13px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.modal-grid {
  grid-template-columns: 1fr 1fr auto;
  margin-top: 14px;
}

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

  .sidebar {
    position: sticky;
    z-index: 9;
    height: auto;
    padding: 10px 12px;
  }

  .sidebar-head {
    min-height: 42px;
  }

  .brand {
    margin: 0;
    font-size: 16px;
  }

  .mobile-menu-toggle {
    display: inline-grid;
    place-items: center;
    gap: 4px;
    width: 38px;
    min-width: 38px;
    min-height: 38px;
    padding: 0;
    border-color: #2b5d62;
    background: #1f494d;
  }

  .mobile-menu-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: #dce8e8;
  }

  .nav {
    display: none;
    margin-top: 10px;
  }

  .sidebar.open .nav {
    display: grid;
    grid-template-columns: 1fr;
  }

  .nav button {
    min-height: 42px;
  }

  .grid.cols-2,
  .grid.cols-3,
  .grid.cols-4,
  .inventory-columns,
  .report-columns,
  .form-grid,
  .offshore-inbound-bar,
  .modal-grid,
  .search-row {
    grid-template-columns: 1fr;
  }

  .timeline-item,
  .timeline-item em {
    grid-template-columns: 1fr;
    grid-column: auto;
  }

  .pagination {
    justify-content: stretch;
  }

  .pagination button,
  .pagination span {
    flex: 1;
  }

  .mobile-inventory-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
  }

  .mobile-inventory-tabs button {
    background: #fff;
    color: #1d383d;
    border-color: var(--line);
  }

  .mobile-inventory-tabs button.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
  }

  .inventory-panel {
    display: none;
  }

  .inventory-panel.mobile-active {
    display: block;
  }
}
