:root {
  --navy: #071f35;
  --navy-2: #0a2d49;
  --navy-3: #0f3b5c;
  --teal: #008b8b;
  --teal-2: #00a4a3;
  --teal-soft: #d7f5f1;
  --amber: #e5a000;
  --red: #e43d42;
  --blue: #0877c8;
  --purple: #7947d9;
  --ink: #0b2340;
  --muted: #5d7188;
  --line: #d7e2ec;
  --soft: #f7fafc;
  --white: #ffffff;
  --shadow: 0 16px 40px rgba(8, 32, 54, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(120deg, #f8fbfe 0%, #edf4f8 100%);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button { -webkit-appearance: none; appearance: none; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

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

.sidebar {
  color: var(--white);
  background:
    radial-gradient(circle at 90% 10%, rgba(0, 164, 163, 0.34), transparent 34%),
    linear-gradient(180deg, #08283f 0%, #061c31 54%, #04192d 100%);
  padding: 16px 12px 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 4px;
  min-height: 60px;
}

.brand-mark {
  width: 80px;
  height: 54px;
  border: 3px solid var(--white);
  display: grid;
  place-items: center;
  font-size: 34px;
  font-weight: 850;
  line-height: 1;
  letter-spacing: 0;
}

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

.brand strong {
  color: var(--teal-2);
  font-size: 25px;
  line-height: .92;
}

.brand small {
  color: #d6e4ee;
  font-size: 12px;
  margin-top: 3px;
}

.nav-list {
  display: grid;
  gap: 9px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 47px;
  border: 0;
  border-radius: 6px;
  padding: 0 13px;
  color: #f0f7fb;
  background: transparent;
  text-align: left;
  font-weight: 650;
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease;
}

.nav-symbol {
  width: 24px;
  color: #ffffff;
  font-size: 22px;
  line-height: 1;
  text-align: center;
}

.nav-item:hover,
.nav-item.active {
  background: linear-gradient(90deg, rgba(0, 164, 163, 0.8), rgba(0, 132, 132, 0.34));
}

.nav-item:hover { transform: translateX(2px); }

.sidebar-footer {
  margin: auto -12px 0;
  padding: 16px 14px 18px;
  display: grid;
  gap: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.sidebar-footer .footer-action {
  min-height: 38px;
  padding: 0 10px;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  color: var(--white);
}

.user-card > div {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.18);
  font-weight: 800;
}

.user-card b,
.user-card small {
  display: block;
}

.user-card b { font-size: 12px; }
.user-card small { color: #c8d8e4; margin-top: 3px; }

.workspace {
  min-width: 0;
  padding: 24px 30px 28px;
  display: grid;
  gap: 16px;
}

.topbar {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.screen-label,
.panel-label {
  margin: 0 0 4px;
  color: #435c74;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .11em;
  text-transform: uppercase;
}

h1, h2, p { margin: 0; }

h1 {
  color: var(--ink);
  font-size: 30px;
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  color: var(--ink);
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 14px;
  min-width: 0;
  flex-wrap: wrap;
}

.search {
  position: relative;
  display: block;
}

.search::after {
  content: "⌕";
  position: absolute;
  right: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: #536b82;
  font-size: 24px;
  line-height: 1;
}

.search input {
  width: 292px;
  height: 40px;
  border: 1px solid #cbd8e3;
  border-radius: 5px;
  padding: 0 42px 0 16px;
  background: rgba(255, 255, 255, .92);
  color: var(--ink);
}

.primary-button,
.ghost-button {
  min-height: 40px;
  border-radius: 5px;
  padding: 0 18px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 750;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.primary-button {
  color: var(--white);
  background: linear-gradient(180deg, #009b99, #007d7c);
  box-shadow: 0 10px 24px rgba(0, 139, 139, .18);
}

.ghost-button {
  color: var(--ink);
  background: rgba(255, 255, 255, .88);
  border-color: #cbd8e3;
}

.primary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.search input:focus,
.dialog-card input:focus,
.dialog-card select:focus,
.external-track input:focus,
.external-track select:focus {
  border-color: var(--teal);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(0, 139, 139, .14);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 13px;
}

.kpi,
.panel {
  background: rgba(255, 255, 255, .88);
  border: 1px solid #d0dde8;
  border-radius: 7px;
  box-shadow: var(--shadow);
}

.kpi {
  position: relative;
  min-height: 112px;
  padding: 18px 16px;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  cursor: pointer;
}

.kpi:hover { transform: translateY(-1px); }

.kpi-badge {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--white);
  background: radial-gradient(circle at 30% 25%, #10b8b4, var(--teal));
  font-style: normal;
  font-size: 30px;
  line-height: 1;
  box-shadow: inset 0 -8px 16px rgba(0, 0, 0, .12);
}

.kpi.warning .kpi-badge { background: radial-gradient(circle at 30% 25%, #ff7266, #e9362f); }
.kpi.amber .kpi-badge { background: radial-gradient(circle at 30% 25%, #ffc247, #e39b00); }

.kpi span,
.kpi small {
  display: block;
  color: var(--muted);
}

.kpi strong {
  display: block;
  margin: 3px 0 3px;
  color: var(--ink);
  font-size: 30px;
  line-height: 1;
}

.kpi em {
  align-self: start;
  color: var(--teal);
  font-size: 12px;
  font-style: normal;
  white-space: nowrap;
}

.kpi.warning em { color: var(--red); }
.kpi.amber em { color: #c56f00; }

.spark {
  position: absolute;
  right: 16px;
  bottom: 22px;
  width: 72px;
  height: 30px;
  fill: none;
  stroke: var(--teal);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.spark.red { stroke: var(--red); }

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 416px;
  gap: 17px;
  align-items: start;
}

.lower-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 416px;
  gap: 17px;
  align-items: start;
}

.panel {
  padding: 22px;
  overflow: hidden;
}

.shipment-panel { min-height: 430px; }

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

.panel-head.compact { align-items: center; }

.shipment-panel h2 {
  font-size: 24px;
  line-height: 1.12;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.in-progress { color: #006a67; background: var(--teal-soft); }
.delayed { color: #a30516; background: #ffe2e6; }
.closed { color: #4c6175; background: #e9f0f5; }
.quote { color: #8a5400; background: #fff0c5; }

.shipment-meta {
  display: grid;
  grid-template-columns: 1.05fr 1.05fr 1.08fr .92fr .72fr;
  gap: 11px;
  margin-bottom: 21px;
}

.shipment-meta div,
.mini-card {
  background: rgba(248, 251, 253, .8);
  border: 1px solid #d6e2ec;
  border-radius: 6px;
  padding: 13px;
}

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

.shipment-meta strong {
  font-size: 15px;
}

.timeline {
  position: relative;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin: 3px 13px 21px;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 42px;
  right: 42px;
  top: 20px;
  height: 3px;
  background: #8998a8;
}

.stage {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 6px;
  min-height: 82px;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: center;
  padding: 0;
}

.stage::before {
  content: "✓";
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--teal);
  background: #f6fffd;
  border: 3px solid var(--teal);
  font-size: 24px;
  font-weight: 800;
}

.stage.current::before {
  content: "⌂";
  color: var(--teal);
  background: #eefbf9;
}

.stage:not(.done):not(.current)::before {
  content: "▱";
  color: #718395;
  background: var(--white);
  border-color: #8c9cac;
}

.stage strong {
  display: block;
  font-size: 13px;
  line-height: 1.1;
}

.stage small {
  color: var(--muted);
  font-size: 12px;
}

.stage.done small,
.stage.current small { color: var(--teal); }

.detail-split {
  display: grid;
  grid-template-columns: .92fr 1fr 1fr;
  gap: 15px;
}

.mini-card {
  min-height: 132px;
}

.mini-card p {
  margin-top: 8px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
}

.notes-card p {
  color: var(--ink);
}

.right-stack {
  display: grid;
  gap: 16px;
}

.checklist-panel { min-height: 244px; }

.checklist {
  display: grid;
  gap: 0;
}

.check-item {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.check-item:last-child { border-bottom: 0; }
.check-item b { font-size: 13px; }
.check-item span { color: var(--muted); font-size: 12px; margin-left: 8px; }
.check-item:hover b { color: var(--teal); }

.dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--white);
  font-size: 12px;
  font-style: normal;
  background: var(--teal);
}

.dot.missing { background: var(--red); }

.qr-panel { min-height: 170px; }

.qr-layout {
  display: grid;
  grid-template-columns: 116px 1fr;
  gap: 16px;
  align-items: center;
  margin-top: 9px;
}

.qr-code {
  width: 112px;
  aspect-ratio: 1;
  border: 7px solid var(--white);
  outline: 1px solid #cbd8e3;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--white);
}

.qr-code span {
  background: var(--navy);
  margin: 2px;
}

.qr-code span:nth-child(2n),
.qr-code span:nth-child(7),
.qr-code span:nth-child(13),
.qr-code span:nth-child(19) { background: var(--white); }

.qr-layout p {
  color: var(--muted);
  margin: 8px 0 6px;
}

.qr-layout small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 12px;
}

.label-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.label-actions .ghost-button {
  padding: 0 10px;
  min-width: 0;
  font-size: 12px;
}

.table-panel { min-height: 320px; }

.table-panel .panel-head {
  margin-bottom: 14px;
}

.table-wrap {
  overflow: auto;
}

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

th, td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  color: #405a74;
  font-size: 11px;
  font-weight: 800;
}

tbody tr.selected,
tbody tr:hover { background: #f2fbfc; }

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

.row-menu {
  color: #6c7d8d;
  font-size: 20px;
  text-align: right;
}

.empty-row {
  color: var(--muted);
  text-align: center;
  padding: 24px 10px;
}

.movement-panel { min-height: 335px; }

.movement-list {
  display: grid;
  gap: 0;
  position: relative;
}

.movement-list div {
  position: relative;
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 12px;
  padding: 9px 0 9px 0;
  border-left: 0;
}

.movement-list div::before {
  content: "";
  position: absolute;
  left: 72px;
  top: 14px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--teal);
}

.movement-list div:nth-child(2)::before { background: var(--blue); }
.movement-list div:nth-child(3)::before { background: var(--amber); }
.movement-list div:nth-child(4)::before { background: var(--purple); }
.movement-list div:nth-child(5)::before { background: var(--red); }

.movement-list b,
.movement-list span {
  display: block;
}

.movement-list b {
  color: var(--ink);
  font-size: 13px;
}

.movement-list span {
  color: var(--muted);
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.25;
}

dialog {
  border: 0;
  border-radius: 10px;
  box-shadow: 0 24px 80px rgba(16, 42, 67, 0.28);
  padding: 0;
}

dialog::backdrop {
  background: rgba(16, 42, 67, 0.32);
}

.dialog-card {
  width: min(460px, 92vw);
  padding: 22px;
  display: grid;
  gap: 14px;
}

.dialog-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.dialog-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  padding: 10px 12px;
  border: 1px solid #d9eee9;
  border-radius: 6px;
  background: #f2fbf9;
}

.tracking-result {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid #bee8e2;
  border-radius: 7px;
  background: #f0fbf9;
}

.tracking-result[hidden] {
  display: none;
}

.tracking-result span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.tracking-result strong {
  color: var(--teal);
}

.tracking-result p {
  padding: 0;
  border: 0;
  background: transparent;
}

.dialog-card input,
.dialog-card select {
  border: 1px solid var(--line);
  border-radius: 6px;
  height: 40px;
  padding: 0 10px;
  color: var(--ink);
  background: var(--white);
}

.dialog-card menu {
  margin: 6px 0 0;
  padding: 0;
  display: flex;
  justify-content: end;
  gap: 10px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 44px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--navy);
  color: var(--white);
  box-shadow: 0 16px 40px rgba(16, 42, 67, 0.22);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

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

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 12px;
  }
  .brand { min-height: 48px; }
  .brand-mark { width: 58px; height: 40px; font-size: 24px; }
  .brand strong { font-size: 21px; }
  .nav-list { display: flex; overflow-x: auto; scrollbar-width: none; }
  .nav-list::-webkit-scrollbar { display: none; }
  .nav-item { flex: 0 0 auto; }
  .sidebar-footer { display: none; }
  .workspace { padding: 18px; }
  .main-grid, .lower-grid, .kpi-grid { grid-template-columns: 1fr; }
  .shipment-meta { grid-template-columns: 1fr 1fr; }
  .detail-split { grid-template-columns: 1fr; }
  .topbar, .topbar-actions { align-items: stretch; flex-direction: column; }
  .search input, .primary-button, .ghost-button { width: 100%; }
}

@media (max-width: 640px) {
  .workspace { padding: 14px; }
  .shipment-meta { grid-template-columns: 1fr; }
  .timeline { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-inline: 0; }
  .timeline::before { display: none; }
  .kpi { grid-template-columns: 52px 1fr; }
  .kpi em, .spark { display: none; }
  .qr-layout { grid-template-columns: 1fr; }
}
