:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --border: #e3e8ef;
  --text: #18212f;
  --muted: #6b7686;
  --primary: #0a6cf5;
  --primary-dark: #0857c9;
  --green: #12a150;
  --red: #e5484d;
  --orange: #e88a1a;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 16px rgba(16, 24, 40, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  letter-spacing: 0;
}

.hidden { display: none !important; }

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

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.brand-text strong {
  display: block;
  font-size: 16px;
}

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

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eef4ff 0%, #f6f8fb 55%, #eefaf2 100%);
  padding: 24px;
}

.login-card {
  width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-card .brand-text h1 {
  margin: 0;
  font-size: 20px;
}

.login-card .brand-text p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 22px;
}

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

.input,
.form-stack input,
.form-stack select {
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
  outline: none;
  width: 100%;
}

.input:focus,
.form-stack input:focus,
.form-stack select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(10, 108, 245, 0.12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { border-color: #c7d0dd; background: #fafbfc; }

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

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

.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: #eef1f5; color: var(--text); }

.btn.danger {
  border-color: #f3c1c3;
  color: var(--red);
}

.btn.danger:hover { background: #fff1f1; }

.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; }
.btn.xs { height: 28px; padding: 0 8px; font-size: 12px; }
.btn.btn-block { width: 100%; }

.hint {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

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

.sidebar {
  background: #fff;
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 40px;
  padding: 0 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  text-align: left;
}

.nav-item:hover { background: #f3f6fa; color: var(--text); }

.nav-item.active {
  background: #eaf2ff;
  color: var(--primary);
  font-weight: 600;
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

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

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

.topbar h2 {
  margin: 0;
  font-size: 20px;
}

.topbar p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 13px;
  background: #eefaf2;
  color: var(--green);
  font-size: 12px;
}

.badge.muted {
  background: #eef1f5;
  color: var(--muted);
}

.view { display: none; }
.view.active { display: block; }

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

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
}

.stat-card strong {
  font-size: 30px;
  line-height: 1.1;
}

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

.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
  min-width: 0;
}

.panel.narrow {
  max-width: 640px;
}

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

.panel-head h3 {
  margin: 0;
  font-size: 15px;
}

.legend {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-left: 6px;
}

.dot.green { background: var(--green); }
.dot.blue { background: var(--primary); }
.dot.red { background: var(--red); }

.map-svg {
  width: 100%;
  height: auto;
  background: #fbfcfe;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.feed-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 340px;
  overflow: auto;
}

.feed-list li {
  display: flex;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid #eef1f5;
  font-size: 13px;
}

.feed-list li:last-child { border-bottom: none; }

.feed-time {
  color: var(--muted);
  flex: none;
  font-size: 12px;
  padding-top: 1px;
}

.feed-type {
  flex: none;
  min-width: 64px;
  text-align: center;
  font-size: 12px;
  border-radius: 4px;
  padding: 1px 6px;
  height: 20px;
  line-height: 18px;
}

.feed-type.ok { background: #eefaf2; color: var(--green); }
.feed-type.info { background: #eaf2ff; color: var(--primary); }
.feed-type.warn { background: #fff4e5; color: var(--orange); }
.feed-type.err { background: #fff0f0; color: var(--red); }

.table-wrap {
  overflow: auto;
}

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

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #eef1f5;
  font-size: 13px;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: #fafbfc;
  white-space: nowrap;
}

td { white-space: nowrap; }

.status-pill {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 12px;
  font-size: 12px;
  background: #eef1f5;
  color: var(--muted);
}

.status-pill.online { background: #eefaf2; color: var(--green); }
.status-pill.on_trip { background: #eaf2ff; color: var(--primary); }
.status-pill.dispatching { background: #fff4e5; color: var(--orange); }
.status-pill.completed { background: #eefaf2; color: var(--green); }
.status-pill.expired, .status-pill.cancelled { background: #fff0f0; color: var(--red); }
.status-pill.arrived { background: #eaf2ff; color: var(--primary); }
.status-pill.accepted { background: #eaf2ff; color: var(--primary); }
.status-pill.offline { background: #eef1f5; color: var(--muted); }

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

.row-actions .btn { height: 28px; padding: 0 8px; font-size: 12px; }

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

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

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

.toolbar-actions .input {
  width: 220px;
}

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

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: 20px;
}

.modal {
  width: 460px;
  max-width: 100%;
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.25);
}

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

.modal-head h3 { margin: 0; font-size: 16px; }

.icon-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}

.icon-btn:hover { background: #f0f2f5; color: var(--text); }

.modal-body {
  padding: 18px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
  margin-bottom: 16px;
}

.detail-grid > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

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

.detail-grid strong {
  font-size: 14px;
  word-break: break-word;
}

.modal-sub {
  margin: 18px 0 8px;
  font-size: 14px;
}

.detail-note {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff7ed;
  color: #9a5b13;
  font-size: 13px;
  line-height: 1.5;
}

.modal .table-wrap {
  max-height: 200px;
  overflow: auto;
}

.modal .table-wrap table {
  min-width: 440px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 1200;
  max-width: 360px;
  padding: 12px 16px;
  background: #18212f;
  color: #fff;
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.3);
  font-size: 13px;
}

.empty-row td {
  text-align: center;
  color: var(--muted);
  padding: 28px 12px;
}

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

.feed-empty {
  color: var(--muted);
  text-align: center;
  padding: 30px 0;
  font-size: 13px;
}

@media (max-width: 980px) {
  .app-wrap { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row;
    align-items: center;
    padding: 10px 14px;
    overflow-x: auto;
  }
  .nav { flex-direction: row; }
  .nav-item { flex: none; }
  .sidebar-foot { border: none; padding: 0; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel-grid { grid-template-columns: 1fr; }
  .main { padding: 16px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-actions { flex-wrap: wrap; }
  .toolbar-actions .input { flex: 1; min-width: 160px; }
}
