:root {
  --bg: #eef1ee;
  --ink: #111715;
  --muted: #64706b;
  --line: #d8ded8;
  --panel: #ffffff;
  --panel-soft: #f7f8f4;
  --green: #12664f;
  --blue: #245f96;
  --amber: #b98020;
  --red: #b94848;
  --rail: #17211e;
  --shadow: 0 18px 48px rgba(22, 30, 28, 0.09);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(120deg, rgba(18, 102, 79, 0.08), transparent 34%), linear-gradient(300deg, rgba(36, 95, 150, 0.08), transparent 36%), var(--bg);
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
}
button, input { font: inherit; }
button { cursor: pointer; }
.tower-shell { display: grid; grid-template-columns: 220px minmax(0, 1fr) 400px; min-height: 100vh; }
.tower-sidebar { position: sticky; top: 0; display: flex; flex-direction: column; gap: 20px; min-height: 100vh; background: var(--rail); color: #f4f7f2; padding: 18px 14px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand span { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid rgba(255,255,255,.16); background: #eef1ee; color: #14211d; font-weight: 900; }
.brand strong { font-size: 19px; }
.app-switcher {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
}
.app-switcher a {
  display: grid;
  min-height: 30px;
  place-items: center;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 7px;
  color: rgba(244,247,242,.72);
  font-size: 11px;
  font-weight: 800;
  text-decoration: none;
}
.app-switcher a.active,
.app-switcher a:hover {
  background: rgba(255,255,255,.1);
  color: #fff;
}
.tower-nav { display: grid; gap: 7px; }
.tower-nav button { min-height: 42px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: rgba(244,247,242,.72); padding: 0 12px; text-align: left; }
.tower-nav button.active, .tower-nav button:hover { border-color: rgba(255,255,255,.16); background: rgba(255,255,255,.08); color: #fff; }
.sidebar-block { display: grid; gap: 8px; margin-top: auto; border-top: 1px solid rgba(255,255,255,.12); padding-top: 16px; }
.sidebar-block span, .tower-topbar span, .panel-head span, .hero-copy span, .fulfillment-card span, .metric span { color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: 0; }
.sidebar-block span { color: rgba(244,247,242,.62); }
.sidebar-block p { display: flex; justify-content: space-between; margin: 0; color: rgba(244,247,242,.86); }
.sidebar-block em { color: #91d4bd; font-style: normal; }
.tower-main { min-width: 0; }
.tower-topbar { display: flex; align-items: center; justify-content: space-between; min-height: 72px; border-bottom: 1px solid var(--line); background: rgba(244,246,242,.8); padding: 0 22px; backdrop-filter: blur(14px); }
.tower-topbar h1, .hero-copy h2, .panel-head h2 { margin: 3px 0 0; letter-spacing: 0; }
.tower-topbar h1 { font-size: 23px; }
.topbar-actions { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.topbar-actions label { display: flex; align-items: center; gap: 8px; }
.topbar-actions input { width: 230px; min-height: 38px; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 0 10px; }
.topbar-actions button, .panel-head button { min-height: 38px; border: 1px solid #17211e; border-radius: 8px; background: #17211e; color: #fff; padding: 0 14px; }
.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 164px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 3px;
}
.mode-switch button {
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0 8px;
  font-size: 12px;
  font-weight: 900;
}
.mode-switch button.active {
  background: var(--rail);
  color: #fff;
}
.demo-role-switch {
  position: relative;
}
.demo-role-switch summary {
  display: flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 900;
  list-style: none;
}
.demo-role-switch summary::-webkit-details-marker {
  display: none;
}
.demo-role-switch[open] .role-switch {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 5;
  box-shadow: var(--shadow);
}
.role-switch {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  width: min(360px, 44vw);
}
.hero-band { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(360px, .8fr); gap: 16px; padding: 18px 22px 0; }
.hero-copy, .hero-metrics, .surface, .fulfillment-card, .route-panel { border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.88); box-shadow: var(--shadow); }
.hero-copy { min-height: 148px; padding: 20px; }
.hero-copy h2 { max-width: 780px; font-size: 28px; line-height: 1.28; }
.hero-copy p { max-width: 720px; margin: 12px 0 0; color: var(--muted); line-height: 1.65; }
.hero-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; overflow: hidden; background: var(--line); }
.metric { display: grid; gap: 5px; min-height: 72px; background: var(--panel); padding: 14px; }
.metric strong { font-size: 27px; line-height: 1; }
.workbench { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; padding: 16px 22px 24px; }
.left-rail, .right-rail, .center-stage { display: grid; align-content: start; gap: 12px; }
.fulfillment-card { display: grid; gap: 9px; width: 100%; color: var(--ink); padding: 13px; text-align: left; }
.fulfillment-card.active, .fulfillment-card:hover { border-color: rgba(18,102,79,.42); box-shadow: 0 18px 38px rgba(18,102,79,.12); }
.fulfillment-card h3 { margin: 0; font-size: 16px; }
.fulfillment-card p { margin: 0; color: var(--muted); line-height: 1.45; }
.card-row, .panel-head, .system-link, .risk-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.status { display: inline-flex; align-items: center; min-height: 26px; border-radius: 999px; background: #e8ece8; color: var(--muted); padding: 0 9px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.status.medium, .status.warn { background: #fff1d9; color: var(--amber); }
.status.high, .status.critical { background: #fbe4e4; color: var(--red); }
.status.none, .status.low, .status.ok { background: #e1f2eb; color: var(--green); }
.route-panel, .surface { overflow: hidden; }
.panel-head { min-height: 62px; border-bottom: 1px solid var(--line); padding: 0 16px; }
.panel-head h2 { font-size: 18px; }
#etaText { color: var(--green); font-size: 14px; }
.map-viewport { position: relative; min-height: 430px; overflow: hidden; background: linear-gradient(150deg, rgba(255,255,255,.92), rgba(234,238,231,.9)), #f4f6f2; }
.terrain-grid { position: absolute; inset: -40px; background: linear-gradient(115deg, transparent 0 45%, rgba(18,102,79,.08) 45% 46%, transparent 46%), repeating-linear-gradient(165deg, rgba(36,95,150,.11) 0 1px, transparent 1px 34px), repeating-linear-gradient(25deg, rgba(185,128,32,.11) 0 1px, transparent 1px 46px); transform: perspective(760px) rotateX(58deg) rotateZ(-7deg) translateY(34px); transform-origin: center; }
.route-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.route-shadow, .route-line, .risk-line { fill: none; stroke-linecap: round; }
.route-shadow { stroke: rgba(17,23,21,.18); stroke-width: 18; transform: translateY(14px); }
.route-line { stroke: var(--blue); stroke-width: 7; stroke-dasharray: 18 12; animation: routeMove 1.8s linear infinite; }
.risk-line { stroke: var(--red); stroke-width: 9; opacity: .76; }
.node circle { fill: #fff; stroke: var(--green); stroke-width: 5; }
.node text { fill: var(--ink); font-size: 18px; font-weight: 800; }
.vehicle circle { fill: var(--rail); stroke: #fff; stroke-width: 4; }
.vehicle path { stroke: #fff; stroke-width: 3; stroke-linecap: round; }
.map-callout { position: absolute; display: grid; gap: 4px; max-width: 230px; border: 1px solid rgba(17,23,21,.12); border-radius: 8px; background: rgba(255,255,255,.9); padding: 10px 12px; box-shadow: 0 16px 34px rgba(20,28,26,.12); }
.map-callout span { color: var(--muted); line-height: 1.4; }
.map-callout.risk { right: 30px; top: 56px; }
.map-callout.energy { left: 28px; bottom: 28px; }
.permission-strip {
  display: grid;
  gap: 6px;
  padding: 13px 16px;
}
.permission-strip b {
  font-size: 16px;
}
.permission-strip p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}
.permission-strip .permission-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.permission-strip .permission-tags span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}
.permission-matrix {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.permission-matrix span {
  border: 1px dashed rgba(17, 23, 21, .18);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 800;
}
.archive-notice {
  display: grid;
  gap: 8px;
  margin-top: 4px;
  border: 1px solid rgba(24, 122, 88, .2);
  border-radius: 8px;
  background: #edf8f2;
  padding: 12px;
}
.archive-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.archive-links a {
  min-height: 32px;
  border: 1px solid rgba(24, 122, 88, .22);
  border-radius: 8px;
  background: #fff;
  color: var(--green);
  padding: 7px 10px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 900;
}
.customer-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}
.customer-summary article {
  display: grid;
  gap: 7px;
  min-height: 98px;
  background: var(--panel);
  padding: 14px;
}
.customer-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.customer-summary b {
  font-size: 17px;
}
.customer-summary p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(280px, .9fr); gap: 16px; }
.timeline, .system-links, .risk-list { display: grid; gap: 10px; padding: 14px; }
.timeline-item { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: start; }
.timeline-dot { width: 14px; height: 14px; margin: 3px auto 0; border-radius: 50%; background: var(--line); box-shadow: 0 0 0 5px #f3f6f1; }
.timeline-item.completed .timeline-dot { background: var(--green); }
.timeline-item.in_progress .timeline-dot { background: var(--amber); }
.timeline-item b, .system-link b, .risk-item b { display: block; margin-bottom: 4px; }
.timeline-item p, .system-link span, .risk-item p, .push-card p { margin: 0; color: var(--muted); line-height: 1.45; }
.system-link, .risk-item { border: 1px solid var(--line); border-radius: 8px; background: var(--panel-soft); padding: 12px; }
.risk-item { align-items: flex-start; }
.push-card { display: grid; gap: 10px; padding: 14px; }
.push-preview { display: grid; gap: 10px; border: 1px solid var(--line); border-radius: 8px; background: linear-gradient(145deg, #fff, #f6f7f2); padding: 14px; }
.archive-preview { background: #edf8f2; }
.push-preview h3 { margin: 0; font-size: 17px; }
.push-meta { display: flex; flex-wrap: wrap; gap: 8px; }
body[data-archive-mode="readonly"] .panel-head button:disabled {
  cursor: not-allowed;
  opacity: .54;
}
.dialog-rail {
  position: sticky;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  top: 0;
  height: 100vh;
  min-width: 0;
  border-left: 1px solid var(--line);
  background: rgba(238,241,238,.72);
  padding: 16px 16px 16px 0;
  overflow: auto;
}
.dialog-rail .right-rail {
  display: grid;
  gap: 12px;
}
.ai-console {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  min-height: 320px;
}
.chat-thread {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 0;
  max-height: 260px;
  overflow: auto;
  padding: 14px;
}
.chat-bubble {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 10px 12px;
}
.chat-bubble.user {
  margin-left: 24px;
  border-color: rgba(36,95,150,.22);
  background: #eef5fb;
}
.chat-bubble.assistant {
  margin-right: 24px;
}
.chat-bubble b {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--green);
}
.chat-bubble p {
  margin: 0;
  color: var(--ink);
  line-height: 1.45;
}
.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  border-top: 1px solid var(--line);
  padding: 10px 14px;
}
.quick-actions button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}
.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding: 12px 14px 14px;
}
.chat-form input {
  min-height: 38px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 10px;
}
.chat-form button {
  min-height: 38px;
  border: 1px solid var(--rail);
  border-radius: 8px;
  background: var(--rail);
  color: #fff;
  padding: 0 12px;
}
body:not([data-audience-mode="internal"]) .tower-shell {
  grid-template-columns: minmax(0, 1fr) 400px;
}
body:not([data-audience-mode="internal"]) .tower-sidebar,
body:not([data-audience-mode="internal"]) [data-internal-only] {
  display: none;
}
body[data-audience-mode="shipper"] .tower-topbar h1::after { content: " · 货主视图"; }
body[data-audience-mode="carrier"] .tower-topbar h1::after { content: " · 运输公司视图"; }
body[data-audience-mode="driver"] .tower-topbar h1::after { content: " · 司机视图"; }
body[data-audience-mode="forwarder"] .tower-topbar h1::after { content: " · 货代视图"; }
body:not([data-audience-mode="internal"]) .hero-copy span {
  color: var(--green);
}
body:not([data-audience-mode="internal"]) .hero-copy h2 {
  max-width: 900px;
}
body:not([data-audience-mode="internal"]) .hero-copy p {
  max-width: 820px;
}
body:not([data-audience-mode="internal"]) .workbench {
  grid-template-columns: 280px minmax(0, 1fr);
}
body:not([data-audience-mode="internal"]) .right-rail {
  grid-template-columns: 1fr;
}
body:not([data-audience-mode="internal"]) .detail-grid {
  grid-template-columns: 1fr;
}
body[data-audience-mode="shipper"] .map-callout.energy {
  display: none;
}
body[data-audience-mode="driver"] .hero-band {
  grid-template-columns: minmax(0, 1fr);
}
body[data-audience-mode="driver"] .hero-metrics,
body[data-audience-mode="driver"] #push {
  display: none;
}
@keyframes routeMove { to { stroke-dashoffset: -30; } }
@media (max-width: 1440px) {
  .tower-shell {
    grid-template-columns: 220px minmax(0, 1fr) 360px;
  }
  .workbench {
    grid-template-columns: 280px minmax(0, 1fr);
  }
}
@media (max-width: 1220px) {
  .tower-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }
  body:not([data-audience-mode="internal"]) .tower-shell {
    grid-template-columns: 1fr;
  }
  .dialog-rail {
    position: static;
    grid-column: 2;
    height: auto;
    border-top: 1px solid var(--line);
    border-left: 0;
    padding: 0 22px 24px;
  }
  body:not([data-audience-mode="internal"]) .dialog-rail { grid-column: auto; }
  .ai-console { min-height: 480px; }
  .workbench { grid-template-columns: 280px minmax(0, 1fr); }
  .right-rail { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .tower-shell, body:not([data-audience-mode="internal"]) .tower-shell, .hero-band, .workbench, body:not([data-audience-mode="internal"]) .workbench, .detail-grid, .right-rail, body:not([data-audience-mode="internal"]) .right-rail, .customer-summary { grid-template-columns: 1fr; }
  .tower-sidebar { position: sticky; top: 0; z-index: 3; min-height: auto; }
  .dialog-rail { grid-column: auto; padding: 0 14px 24px; }
  .tower-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tower-topbar, .topbar-actions { align-items: flex-start; flex-direction: column; }
  .topbar-actions { justify-content: flex-start; }
  .role-switch { width: min(100%, 430px); }
  .topbar-actions input { width: min(78vw, 320px); }
}
@media (max-width: 560px) {
  .hero-metrics { grid-template-columns: 1fr; }
  .workbench, .hero-band, .tower-topbar { padding-left: 14px; padding-right: 14px; }
  .map-viewport { min-height: 330px; }
}
