:root {
  --bg: #0f1419;
  --surface: #161d26;
  --surface2: #1c2530;
  --border: #2a3544;
  --text: #e8ecf1;
  --muted: #8b98a8;
  --accent: #e8b84a;
  --accent-dim: rgba(232, 184, 74, 0.15);
  --danger: #f07178;
  --success: #7fd962;
  --radius: 10px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #121920 0%, #0d1218 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.75rem;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.5rem 0.75rem 1.25rem;
  font-size: 1.05rem;
  color: var(--accent);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  transition: background 0.15s, color 0.15s;
}

.nav a:hover {
  background: var(--surface2);
  color: var(--text);
}

.nav a.active {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(232, 184, 74, 0.25);
}

.nav .ico {
  width: 1.1rem;
  height: 1.1rem;
  opacity: 0.85;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 20, 25, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.menu-toggle {
  display: none;
}

.page-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  flex: 1;
}

.topbar-actions {
  display: flex;
  gap: 0.5rem;
}

.content {
  padding: 1.5rem;
  flex: 1;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.panel + .panel {
  margin-top: 1.25rem;
}

.panel h2 {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.card-stat {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

.card-stat .label {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.card-stat .value {
  font-size: 1.5rem;
  font-weight: 700;
}

.card-stat .trend {
  margin-top: 0.5rem;
  font-size: 0.8rem;
}

.card-stat .trend.up {
  color: var(--success);
}

.card-stat .trend.down {
  color: var(--danger);
}

.card-stat .trend.neutral {
  color: var(--muted);
}

.timeline {
  list-style: none;
  padding: 0;
  margin: 0;
}

.timeline li {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}

.timeline li:last-child {
  border-bottom: none;
}

.timeline .time {
  color: var(--accent);
  margin-right: 0.5rem;
  font-variant-numeric: tabular-nums;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem 1.25rem;
  align-items: flex-end;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 140px;
}

.filter-field label {
  font-size: 0.8rem;
  color: var(--muted);
}

.filter-field input,
.filter-field select {
  padding: 0.5rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}

.filter-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-bottom: 0.1rem;
}

@media (max-width: 720px) {
  .filter-field {
    min-width: calc(50% - 0.75rem);
    flex: 1 1 140px;
  }
}

.panel .filter-bar + .table-wrap {
  margin-top: 1rem;
}

.table-wrap {
  overflow-x: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

table.data th,
table.data td {
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

table.data th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
}

.badge.ok {
  background: rgba(127, 217, 98, 0.15);
  color: var(--success);
}

.badge.off {
  background: rgba(240, 113, 120, 0.12);
  color: var(--danger);
}

.form-grid {
  display: grid;
  gap: 1rem;
  max-width: 520px;
}

.form-field label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.form-field input,
.form-field textarea,
.form-field select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.form-field textarea {
  min-height: 88px;
  resize: vertical;
}

.row-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.btn {
  border: none;
  cursor: pointer;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font: inherit;
  font-size: 0.9rem;
}

.btn.primary {
  background: var(--accent);
  color: #1a1408;
  font-weight: 600;
}

.btn.primary:hover {
  filter: brightness(1.05);
}

.btn.danger {
  background: rgba(240, 113, 120, 0.2);
  color: var(--danger);
  border: 1px solid rgba(240, 113, 120, 0.35);
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn.ghost:hover {
  color: var(--text);
  border-color: var(--muted);
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
  cursor: pointer;
}

.inline-form {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: 1fr 1fr auto;
  align-items: end;
}

@media (max-width: 720px) {
  .inline-form {
    grid-template-columns: 1fr;
  }
}

.empty {
  color: var(--muted);
  font-size: 0.92rem;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.75rem 1rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  max-width: min(420px, calc(100vw - 2rem));
  font-size: 0.9rem;
}

.toast.show {
  opacity: 1;
}

.breadcrumb-bar {
  padding: 0.75rem 1.25rem;
}

.breadcrumb-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.92rem;
}

.breadcrumb-link:hover {
  text-decoration: underline;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.detail-grid h2,
.logistics-readonly h3,
.ship-form h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 600;
}

.dl-rows {
  margin: 0;
}

.dl-rows > div {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 0.5rem 1rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}

.dl-rows > div:last-child {
  border-bottom: none;
}

.dl-rows dt {
  margin: 0;
  color: var(--muted);
}

.dl-rows dd {
  margin: 0;
  word-break: break-word;
}

.meta-line {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.amount-total {
  margin: 1rem 0 0;
  text-align: right;
  font-size: 1.05rem;
}

.amount-total strong {
  color: var(--accent);
  font-size: 1.25rem;
}

.status-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.link-order {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.link-order:hover {
  text-decoration: underline;
}

.ship-form {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.ship-grid {
  max-width: 560px;
}

.logistics-readonly {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--surface2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.input-inline {
  width: 6.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 240px;
    z-index: 20;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .menu-toggle {
    display: inline-flex;
  }
}
