:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef3f7;
  --ink: #172026;
  --muted: #68727d;
  --line: #d9e0e7;
  --blue: #2777c7;
  --blue-dark: #18568f;
  --green: #1f8a70;
  --amber: #bc7b17;
  --coral: #c4513f;
  --violet: #7a5aa8;
  --shadow: 0 18px 45px rgba(38, 52, 66, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

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

button {
  cursor: pointer;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.icon-sprite {
  display: none;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  background: #172026;
  color: #f9fbfd;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: #f2c078;
  color: #172026;
}

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

.brand span,
.sidebar-note p,
.sidebar-note span {
  color: rgba(249, 251, 253, 0.68);
}

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

.nav-item {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: rgba(249, 251, 253, 0.78);
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.sidebar-note {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-note strong,
.sidebar-note span {
  display: block;
}

.sidebar-note p {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.5;
}

.workspace {
  display: grid;
  gap: 22px;
  align-content: start;
  padding: 28px;
}

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

.topbar h1,
.panel h2 {
  margin: 0;
}

.topbar h1 {
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.1;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.search-box {
  display: grid;
  grid-template-columns: 20px minmax(180px, 280px);
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.search-box input,
.search-box input:focus {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-width: 154px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.segmented button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.segmented button.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 10px rgba(23, 32, 38, 0.08);
}

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

.metric-tile {
  min-height: 132px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.metric-tile span,
.metric-tile small {
  color: var(--muted);
}

.metric-tile strong {
  display: block;
  margin: 12px 0 8px;
  font-size: 30px;
  line-height: 1;
}

.accent-blue {
  border-top: 4px solid var(--blue);
}

.accent-green {
  border-top: 4px solid var(--green);
}

.accent-amber {
  border-top: 4px solid var(--amber);
}

.accent-coral {
  border-top: 4px solid var(--coral);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.lower-grid {
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.8fr);
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(38, 52, 66, 0.06);
}

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

.panel-header.compact {
  padding-bottom: 14px;
}

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

.button-row.full {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.icon-button {
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}

.text-button {
  padding: 0 12px;
}

.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
}

.primary:hover {
  background: var(--blue-dark);
}

.secondary:hover,
.icon-button:hover {
  border-color: #b8c5cf;
}

.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

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

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

textarea {
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(39, 119, 199, 0.14);
  outline: 0;
}

.table-scroll {
  overflow: auto;
  max-width: 100%;
}

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

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

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

tbody tr:hover {
  background: #f8fafc;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status-production {
  background: rgba(188, 123, 23, 0.12);
  color: #89570f;
}

.status-ready {
  background: rgba(122, 90, 168, 0.13);
  color: #5f4285;
}

.status-sailing {
  background: rgba(39, 119, 199, 0.13);
  color: #18568f;
}

.status-arrived {
  background: rgba(31, 138, 112, 0.13);
  color: #166651;
}

.status-delivered {
  background: rgba(23, 32, 38, 0.1);
  color: #34414d;
}

.neutral {
  background: #eef3f7;
  color: #52606b;
}

.form-stack {
  display: grid;
  gap: 12px;
  padding: 18px;
}

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

.upload-strip {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(140px, 0.8fr) minmax(180px, 0.8fr);
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.file-drop {
  position: relative;
  align-content: end;
}

.file-drop span {
  display: inline-grid;
  grid-auto-flow: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border: 1px dashed #9fb1c0;
  border-radius: var(--radius);
  background: #f8fbfd;
  color: var(--ink);
}

.file-drop svg {
  position: absolute;
  right: 18px;
  bottom: 9px;
}

.file-drop input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.document-list,
.activity-log,
.wide-label {
  padding: 0 18px 18px;
}

.doc-item,
.log-item,
.client-order {
  display: grid;
  gap: 6px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.doc-item:last-child,
.log-item:last-child,
.client-order:last-child {
  border-bottom: 0;
}

.doc-top,
.client-order-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.doc-meta,
.log-item,
.client-order p {
  color: var(--muted);
  font-size: 13px;
}

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

.doc-link.disabled {
  color: var(--muted);
  pointer-events: none;
}

.import-grid {
  padding: 18px;
}

.wide-label {
  display: grid;
}

.client-panel {
  overflow: hidden;
}

.client-picker {
  min-width: 180px;
}

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

.route-card {
  min-height: 240px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #edf5f5;
}

.route-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.client-summary strong {
  display: block;
  margin-bottom: 8px;
  font-size: 22px;
}

.client-summary p {
  margin: 0 0 12px;
  color: var(--muted);
}

.client-orders {
  display: grid;
  gap: 4px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #172026;
  color: #ffffff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  pointer-events: none;
}

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

@media (max-width: 1180px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .content-grid,
  .lower-grid,
  .client-layout {
    grid-template-columns: 1fr;
  }
}

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

  .sidebar {
    position: static;
    height: auto;
  }

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

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

  .search-box {
    grid-template-columns: 20px 1fr;
  }

  .upload-strip,
  .form-two,
  .import-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .workspace,
  .sidebar {
    padding: 16px;
  }

  .dashboard-grid,
  .nav-list,
  .button-row.full {
    grid-template-columns: 1fr;
  }

  .panel-header,
  .doc-top,
  .client-order-top {
    align-items: flex-start;
    flex-direction: column;
  }
}
