:root {
  --ink: #152234;
  --ink-soft: #52657a;
  --canvas: #f3f7fb;
  --paper: #ffffff;
  --line: #dce5ef;
  --blue: #2375e1;
  --blue-deep: #1755ad;
  --aqua: #e9f5ff;
  --yellow: #f4b740;
  --yellow-soft: #fff7df;
  --green: #1caa76;
  --red: #e25356;
  --red-soft: #fff0f0;
  --shadow: 0 10px 30px rgba(32, 58, 90, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-width: 320px; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% -15%, #e4f5ff 0, transparent 32rem),
    radial-gradient(circle at 0 100%, #fff7dc 0, transparent 30rem),
    var(--canvas);
  line-height: 1.35;
}
.dashboard-body { height: 100dvh; overflow: hidden; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 3px solid rgba(35, 117, 225, .35);
  outline-offset: 2px;
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.app-shell {
  width: min(1600px, 100%);
  height: 100dvh;
  min-height: 0;
  margin: 0 auto;
  padding: 10px;
  display: grid;
  grid-template-rows: 48px minmax(0, 1fr) 54px;
  gap: 10px;
}

.topbar {
  min-width: 0;
  padding: 5px 8px 5px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, .84);
  border: 1px solid rgba(220, 229, 239, .95);
  border-radius: 14px;
  box-shadow: 0 5px 20px rgba(32, 58, 90, .05);
  backdrop-filter: blur(16px) saturate(1.2);
}
.top-stats { display: flex; align-items: center; min-width: 0; margin-right: auto; }
.top-stat { min-width: 76px; padding: 0 12px; border-right: 1px solid var(--line); }
.top-stat:first-child { padding-left: 0; }
.top-stat span, .top-stat b { display: block; }
.top-stat span { color: #72849a; font-size: 11px; font-weight: 700; }
.top-stat b { margin-top: 1px; color: #183150; font-size: 15px; font-variant-numeric: tabular-nums; }
.top-actions { display: flex; align-items: center; gap: 6px; }
.select-wrap { display: block; }
select {
  height: 34px;
  padding: 0 27px 0 9px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
}

.button {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-weight: 760;
  font-size: 13px;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button-primary { color: white; background: linear-gradient(135deg, var(--blue), #3d91f1); box-shadow: 0 6px 14px rgba(35, 117, 225, .2); }
.button-primary:hover { box-shadow: 0 9px 18px rgba(35, 117, 225, .28); }
.button-secondary { color: var(--blue-deep); background: var(--aqua); border-color: #cde5fb; }
.button-quiet { color: var(--ink-soft); background: transparent; border-color: var(--line); }
.button-large { min-height: 38px; padding-inline: 15px; font-size: 13px; }
.button:disabled { cursor: not-allowed; opacity: .55; transform: none; box-shadow: none; }
.text-button { padding: 2px 0; color: var(--blue-deep); background: none; border: 0; font-size: 11px; font-weight: 800; }

.dashboard-main {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(124px, .28fr) minmax(0, 1fr);
  gap: 10px;
}
.system-section, .dashboard-grid { min-height: 0; }
.system-map {
  position: relative;
  height: 100%;
  padding: 7px 12px;
  display: grid;
  grid-template-rows: 40px 40px auto;
  gap: 4px;
  overflow: hidden;
  background: rgba(255, 255, 255, .9);
  border: 1px solid var(--line);
  border-radius: 15px;
  box-shadow: var(--shadow);
}
.system-map::before {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  background-image: radial-gradient(#dce7f2 1px, transparent 1px);
  background-size: 16px 16px;
  opacity: .36;
}
.map-flow {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}
.map-flow-label { display: flex; align-items: center; gap: 5px; color: var(--ink-soft); font-size: 12px; font-weight: 800; white-space: nowrap; }
.flow-glyph { width: 19px; height: 19px; display: grid; place-items: center; border-radius: 6px; font-size: 11px; }
.flow-order .flow-glyph { color: #946c09; background: var(--yellow-soft); }
.flow-shipment .flow-glyph { color: var(--blue-deep); background: var(--aqua); }
.map-chain { position: relative; min-width: 0; display: grid; grid-template-columns: repeat(5, minmax(64px, 1fr)); gap: 8px; align-items: stretch; }
.map-chain::before { position: absolute; top: 50%; left: 7%; right: 7%; content: ""; border-top: 1px dashed #cbd8e6; transform: translateY(-50%); }
.map-node { position: relative; z-index: 1; min-width: 0; min-height: 38px; padding: 4px 7px; display: flex; flex-direction: column; justify-content: center; background: #fbfdff; border: 1px solid #d6e2ef; border-radius: 8px; box-shadow: 0 4px 9px rgba(39, 72, 108, .04); }
.map-node strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.map-node > span { overflow: hidden; color: #71849a; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.map-node.active { border-color: #83bbf4; box-shadow: 0 0 0 2px rgba(35,117,225,.12), 0 4px 9px rgba(39,72,108,.04); }
.map-node.customer { background: #fffaf0; border-color: #f4df9b; }
.map-node.factory { background: #f8f4ff; border-color: #e0d5ff; }
.map-token { position: relative; z-index: 2; display: inline-flex; align-items: center; width: fit-content; max-width: 100%; margin-top: 2px; padding: 2px 5px; overflow: hidden; border-radius: 5px; box-shadow: 0 3px 7px rgba(24,50,81,.13); font-size: 10px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; animation: token-enter .38s cubic-bezier(.2,.9,.3,1) both; }
.map-token.order { color: #785700; background: #ffdc73; }
.map-token.shipment { color: white; background: #4a99ef; }
.map-token.hidden-token { color: #8391a1; background: #e7edf3; }
.flow-order .map-token.order { animation: signal-travel .6s cubic-bezier(.18,.83,.28,1) both; }
.flow-shipment .map-token.shipment { animation: cargo-travel .6s cubic-bezier(.18,.83,.28,1) both; }
.map-state-note { position: relative; z-index: 1; min-width: 0; margin: 0 0 0 116px; padding: 3px 7px; overflow: hidden; color: #5d748e; background: rgba(242, 249, 255, .9); border: 1px solid #d9ecfb; border-radius: 6px; font-size: 11px; line-height: 1.25; }

.dashboard-grid { display: grid; grid-template-columns: minmax(540px, 1.16fr) minmax(350px, .84fr); gap: 10px; }
.dashboard-panel { min-height: 0; background: rgba(255, 255, 255, .92); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.operations-section { position: relative; padding: 10px; display: grid; grid-template-rows: 17px minmax(0, 1fr) auto; gap: 7px; overflow: hidden; }
.panel-tools { min-height: 0; display: flex; justify-content: flex-end; align-items: center; }

.stage-grid { min-height: 0; display: grid; }
.stage-grid[data-mode="learn"] { grid-template-columns: minmax(0, 1fr); }
.stage-grid[data-mode="learn"] .pipeline-detail { display: none; }
.stage-grid[data-mode="sandbox"] { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(122px, 1fr)); gap: 8px; overflow: auto; padding-right: 2px; }
.stage-grid[data-mode="sandbox"] .stage-card { min-height: 122px; padding: 7px; }
.stage-grid[data-mode="sandbox"] .pipeline-detail,
.stage-grid[data-mode="sandbox"] .weekly-ledger,
.stage-grid[data-mode="sandbox"] .delivery-strip,
.stage-grid[data-mode="sandbox"] .next-week-strip,
.stage-grid[data-mode="sandbox"] .signal-queue { display: none; }
.stage-grid[data-mode="sandbox"] .stage-title { margin-bottom: 3px; }
.stage-grid[data-mode="sandbox"] .stage-title h3 { font-size: 13px; }
.stage-grid[data-mode="sandbox"] .role-tag { font-size: 9px; }
.stage-grid[data-mode="sandbox"] .stage-stats { gap: 3px; }
.stage-grid[data-mode="sandbox"] .mini-stat { padding: 3px 4px; }
.stage-grid[data-mode="sandbox"] .mini-stat span { font-size: 9px; }
.stage-grid[data-mode="sandbox"] .mini-stat b { font-size: 13px; }
.stage-grid[data-mode="sandbox"] .inventory-position { margin: 4px 0 3px; padding: 4px 5px; font-size: 10px; }
.stage-grid[data-mode="sandbox"] .inventory-position b { font-size: 11px; }
.stage-grid[data-mode="sandbox"] .supply-summary { margin: 0; padding: 3px 5px; font-size: 9px; white-space: nowrap; }
.stage-card { min-width: 0; height: 100%; padding: 9px; overflow: hidden; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 5px 14px rgba(42,72,103,.045); }
.stage-card.player-card { border-color: #8bc3f9; box-shadow: 0 0 0 2px rgba(35,117,225,.09), 0 7px 18px rgba(42,72,103,.07); }
.stage-card.locked { color: var(--ink-soft); background: #fbfcfe; }
.stage-card.entered { animation: card-breathe .55s ease both; }
.stage-title { display: flex; align-items: center; justify-content: space-between; gap: 7px; margin-bottom: 4px; }
.stage-title h3 { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 15px; letter-spacing: -.02em; }
.role-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; }
.role-tag { padding: 2px 5px; color: var(--blue-deep); background: var(--aqua); border-radius: 5px; font-size: 10px; font-weight: 800; }
.stage-stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
.mini-stat { min-width: 0; padding: 4px 6px; background: #f8fafd; border-radius: 7px; }
.mini-stat span, .mini-stat b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-stat span { color: #6c7e95; font-size: 10px; }
.mini-stat b { margin-top: 1px; font-size: 15px; font-variant-numeric: tabular-nums; }
.mini-stat.danger { background: var(--red-soft); }
.mini-stat.danger b { color: var(--red); }
.inventory-position { margin: 5px 0 3px; padding: 4px 7px; color: #1f528d; background: #eff8ff; border: 1px solid #d6ecff; border-radius: 8px; font-size: 11px; }
.inventory-position b { float: right; font-size: 13px; }
.guide-focus { outline: 2px solid rgba(82, 172, 255, .92); outline-offset: 3px; }
.weekly-ledger { display: flex; flex-wrap: wrap; align-items: center; gap: 1px 6px; margin: 3px 0 0; padding: 3px 6px; color: #466b8d; background: #f8fbfe; border: 1px solid #e0eaf3; border-radius: 7px; font-size: 10px; }
.weekly-ledger span { color: #66819d; font-weight: 800; }
.weekly-ledger b { color: #275781; font-size: 11px; font-variant-numeric: tabular-nums; }
.weekly-ledger em { color: #778da4; font-size: 9px; font-style: normal; }
.delivery-strip { display: flex; align-items: center; justify-content: space-between; gap: 7px; margin: 3px 0 0; padding: 3px 6px; color: #386486; background: #f3faff; border: 1px solid #d6ebfa; border-radius: 7px; font-size: 10px; }
.delivery-strip span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.delivery-strip b { color: var(--blue-deep); font-size: 12px; font-variant-numeric: tabular-nums; }
.delivery-strip em { flex: 0 0 auto; color: #7a91a8; font-size: 9px; font-style: normal; }
.next-week-strip { display: flex; align-items: center; gap: 8px; margin-top: 3px; padding: 3px 6px; color: #3d6688; background: #f4faff; border: 1px solid #d8eafa; border-radius: 7px; font-size: 10px; }
.next-week-strip strong { color: #1e5e9f; font-size: 11px; }
.next-week-strip span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.next-week-strip b { color: var(--blue-deep); font-size: 11px; font-variant-numeric: tabular-nums; }
.signal-queue { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; margin-top: 3px; padding: 3px 6px; color: #6c642e; background: #fffaf0; border: 1px solid #f3e4b7; border-radius: 7px; font-size: 10px; }
.signal-queue strong { color: #765a0d; }
.signal-queue span { white-space: nowrap; }
.signal-queue b { color: #84640b; font-variant-numeric: tabular-nums; }
.pipeline-block { margin-top: 6px; }
.pipeline-label { display: flex; justify-content: space-between; gap: 7px; margin-bottom: 3px; color: #62768f; font-size: 10px; font-weight: 760; }
.pipeline-label em { color: #8596a9; font-style: normal; font-weight: 600; }
.eta-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
.eta-slot { min-height: 31px; padding: 3px 4px; overflow: hidden; background: #f7f9fc; border: 1px solid #e5ebf2; border-radius: 6px; }
.eta-slot.order-slot { background: #fffbef; border-color: #f6e6ae; }
.eta-caption { display: block; color: #8797aa; font-size: 9px; line-height: 1; }
.eta-token { display: inline-flex; align-items: center; gap: 2px; max-width: 100%; margin-top: 2px; padding: 2px 3px; overflow: hidden; color: #276ebd; background: #dff0ff; border-radius: 4px; font-size: 10px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; animation: token-enter .32s ease both; }
.eta-token.order { color: #806003; background: #fff0bc; }
.eta-token.ghost { color: #8594a5; background: #eef2f6; }
.eta-token .token-icon { font-size: 10px; }
.eta-later { display: block; margin-top: 3px; color: #768aa0; font-size: 9px; }
.order-control { margin-top: 4px; padding-top: 4px; border-top: 1px solid #e7edf4; }
.order-control label { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; color: #4a607a; font-size: 11px; font-weight: 760; }
.order-value { color: var(--blue-deep); font-size: 17px; font-variant-numeric: tabular-nums; }
.order-inputs { display: grid; grid-template-columns: minmax(0, 1fr) 64px; align-items: center; gap: 8px; margin-top: 2px; }
.order-range { width: 100%; height: 22px; margin: 0; accent-color: var(--blue); }
.order-number { width: 64px; height: 31px; padding: 3px 5px; color: #174d87; background: #f8fbff; border: 1px solid #c6dff4; border-radius: 7px; font-size: 14px; font-weight: 800; text-align: center; }
.order-preview { margin: 3px 0 0; color: #718299; font-size: 10px; line-height: 1.3; }
.expedite-choice { display: flex !important; align-items: center !important; justify-content: flex-start !important; gap: 5px; margin-top: 4px; color: #6f5812 !important; font-size: 10px !important; font-weight: 760; }
.expedite-choice input { margin: 0; accent-color: #d89009; }
.expedite-choice em { min-width: 0; overflow: hidden; color: #8c7734; font-size: 9px; font-style: normal; text-overflow: ellipsis; white-space: nowrap; }
.locked-copy { min-height: 140px; display: grid; place-content: center; gap: 6px; color: #6b7f96; text-align: center; font-size: 11px; }
.locked-copy span { display: block; font-size: 19px; }
.private-panel { display: block; }
.stage-card.locked:not(.revealed) .private-panel { display: none; }

.coach-card { position: relative; min-width: 0; padding: 6px 8px; display: flex; align-items: center; gap: 8px; background: linear-gradient(132deg, #f7fcff, #fff 70%); border: 1px solid #cfe5f8; border-radius: 10px; }
.coach-copy { min-width: 0; flex: 1; }
.coach-copy strong { display: block; overflow: hidden; color: #1b4d83; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.coach-summary { display: -webkit-box; margin: 2px 0 0; overflow: hidden; color: var(--ink-soft); font-size: 11px; line-height: 1.32; -webkit-box-orient: vertical; -webkit-line-clamp: 1; }
.coach-actions { display: flex; flex: 0 0 auto; gap: 5px; }
.coach-actions .button { min-height: 30px; padding: 5px 8px; font-size: 11px; }
.sandbox-coach { flex-wrap: wrap; align-items: flex-start; padding: 6px 7px; }
.sandbox-coach .coach-summary { display: none; }
.sandbox-direct-controls { flex: 0 0 100%; order: 3; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.sandbox-direct-control { min-width: 0; display: grid; grid-template-rows: auto 24px; gap: 3px; padding: 4px 5px; color: #456886; background: #f4faff; border: 1px solid #d5eafa; border-radius: 7px; font-size: 10px; font-weight: 800; }
.sandbox-control-heading { min-width: 0; display: flex; align-items: center; gap: 4px; }
.sandbox-control-heading > span { color: #456886; }
.sandbox-control-heading output { margin-left: auto; color: var(--blue-deep); font-size: 12px; font-variant-numeric: tabular-nums; }
.sandbox-control-actions { display: grid; grid-template-columns: 24px minmax(0, 1fr) 24px; align-items: center; gap: 4px; }
.sandbox-control-actions button { width: 24px; height: 24px; padding: 0; display: grid; place-items: center; color: #1d5e9d; background: #fff; border: 1px solid #bcd8ef; border-radius: 6px; font-size: 16px; font-weight: 800; line-height: 1; }
.sandbox-control-actions input { width: 100%; height: 20px; margin: 0; accent-color: var(--blue); }
.sandbox-expedite { display: flex; align-items: center; gap: 2px; margin-left: 1px; color: #80610b; font-size: 9px; white-space: nowrap; }
.sandbox-expedite input { width: 12px; height: 12px; margin: 0; accent-color: #d89009; }
.coach-math { position: fixed; z-index: 20; top: 68px; bottom: 64px; left: max(12px, calc((100vw - 1600px) / 2 + 10px)); width: min(650px, calc(100vw - 24px)); max-height: none; padding: 12px; overflow: auto; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 14px; background: #fff; border: 1px solid #c6dff4; border-radius: 11px; box-shadow: 0 18px 45px rgba(32,58,90,.18); font-size: 12px; }
.coach-math[hidden] { display: none; }
.coach-math .math-header { position: sticky; top: -12px; z-index: 1; grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: -12px -12px 2px; padding: 10px 12px 8px; color: #1b4d83; background: #fff; border-bottom: 1px solid #dcecff; font-size: 13px; }
.math-close { min-height: 29px; padding: 4px 8px; color: var(--blue-deep); background: #edf7ff; border: 1px solid #c7e2f7; border-radius: 7px; font-size: 10px; font-weight: 800; }
.coach-math .math-label { color: #61748b; }
.coach-math .math-value { color: #174d87; font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.coach-math .math-total { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 12px; margin-top: 2px; padding-top: 6px; color: var(--blue-deep); border-top: 1px dashed #c6dff4; font-size: 13px; font-weight: 800; }
.coach-math .hand-calc-title { margin-top: 8px; color: #76570b; border-top-color: #f1d77f; }
.coach-math .hand-calc-title span:last-child { color: #8f7a3e; font-size: 10px; }
.coach-math .math-note { grid-column: 1 / -1; padding: 7px 8px; color: #5d7189; background: #f5faff; border: 1px solid #dcecff; border-radius: 8px; font-size: 11px; line-height: 1.45; }
.coach-sandbox-grid { display: grid; grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.coach-mini { display: grid; gap: 1px; padding: 7px; background: #f5faff; border: 1px solid #dcecff; border-radius: 8px; }
.coach-mini b { color: #1b4d83; font-size: 12px; }
.coach-mini span { color: #6a7f95; font-size: 10px; }
.coach-mini strong { color: var(--blue-deep); font-size: 13px; }

.analysis-section { min-height: 0; padding: 11px; display: grid; grid-template-rows: 17px minmax(0, 1fr) auto; gap: 6px; overflow: hidden; }
.chart-toolbar { min-height: 0; display: flex; justify-content: flex-end; align-items: center; }
.chart-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; color: #63768e; font-size: 11px; }
.chart-legend span { display: flex; align-items: center; gap: 4px; }
.chart-legend i { display: block; width: 13px; height: 3px; border-radius: 5px; }
.legend-demand { background: #8e9baa; }
.legend-order { background: var(--yellow); }
.legend-arrival { background: var(--blue); }
.legend-backlog { background: var(--red); }
.chart-wrap { min-height: 0; }
.chart-wrap canvas { display: block; width: 100%; height: 100%; }
.insight-strip { min-height: 31px; padding: 7px 9px; overflow: hidden; color: #406280; background: #f2f9ff; border-radius: 7px; font-size: 11px; line-height: 1.45; }

.action-bar { min-width: 0; padding: 7px 10px 7px 13px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #eaf4ff; background: linear-gradient(120deg, #102d50, #1a548c); border: 1px solid rgba(255,255,255,.1); border-radius: 14px; box-shadow: 0 11px 25px rgba(21,65,108,.17); }
.action-copy { min-width: 0; display: grid; gap: 1px; }
.action-copy strong, .action-copy span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.action-copy strong { font-size: 13px; }
.action-copy span { color: #c5ddf3; font-size: 11px; }
.action-controls { display: flex; flex: 0 0 auto; align-items: center; gap: 9px; }
.toggle-wrap { display: flex; align-items: center; gap: 4px; color: #d8e9f7; font-size: 10px; white-space: nowrap; }
.toggle-wrap input { margin: 0; accent-color: #8dcaff; }

.settings-dialog { width: min(620px, calc(100% - 28px)); max-height: min(700px, calc(100% - 28px)); padding: 18px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 28px 80px rgba(12,35,63,.3); }
.settings-dialog::backdrop { background: rgba(15,34,59,.46); backdrop-filter: blur(3px); }
.settings-topline { display: flex; align-items: center; justify-content: space-between; color: #6380a1; font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.settings-dialog h2 { margin: 8px 0 4px; color: #183a63; font-size: 23px; letter-spacing: -.04em; }
.settings-dialog > p { margin: 0; color: var(--ink-soft); font-size: 12px; line-height: 1.5; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 15px; }
.setting-field, .setting-range, .setting-switch, .setting-choice { min-width: 0; padding: 9px; background: #f8fbfe; border: 1px solid #e0eaf3; border-radius: 10px; }
.setting-field { display: grid; grid-template-columns: minmax(0, 1fr) 48px auto; align-items: center; gap: 5px; }
.setting-field span, .setting-range > span, .setting-switch b, .setting-switch small { display: block; }
.setting-field span, .setting-range > span { color: #435e7b; font-size: 11px; font-weight: 800; }
.setting-field small, .setting-range small, .setting-switch small { margin-top: 1px; color: #788ca3; font-size: 9px; font-weight: 600; }
.setting-field input { width: 48px; height: 29px; padding: 2px 4px; color: #174d87; background: #fff; border: 1px solid #bcd8ef; border-radius: 6px; font-weight: 800; text-align: center; }
.setting-field em { color: #6f849b; font-size: 10px; font-style: normal; }
.setting-seed { grid-template-columns: minmax(0, 1fr) 94px auto; }
.setting-seed input { width: 94px; }
.setting-range { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 8px; }
.setting-range output { color: var(--blue-deep); font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
.setting-range input { grid-column: 1 / -1; width: 100%; margin: 0; accent-color: var(--blue); }
.setting-switch { display: flex; align-items: center; gap: 8px; }
.setting-switch input { width: 16px; height: 16px; margin: 0; accent-color: #d89009; }
.setting-switch b { color: #745b11; font-size: 11px; }
.setting-switch small { color: #8a7b4c; }
.setting-choice { display: grid; grid-template-columns: minmax(0, 1fr) 132px; align-items: center; gap: 7px; }
.setting-choice b, .setting-choice small { display: block; }
.setting-choice b { color: #435e7b; font-size: 11px; }
.setting-choice small { margin-top: 1px; color: #788ca3; font-size: 9px; font-weight: 600; }
.setting-choice select { width: 100%; height: 29px; padding: 0 22px 0 6px; color: #174d87; border-color: #bcd8ef; border-radius: 6px; font-size: 11px; font-weight: 800; }
.expedite-setting { transition: opacity .16s ease; }
.expedite-setting.is-disabled { opacity: .48; }
.settings-preview { margin-top: 11px; padding: 8px 10px; color: #3f617f; background: #f1f9ff; border: 1px solid #d5eafa; border-radius: 9px; font-size: 11px; line-height: 1.45; }
.settings-actions { margin-top: 13px; }

.settings-dialog { overflow: auto; overscroll-behavior: contain; }
.result-dialog { width: min(720px, calc(100% - 30px)); max-height: min(760px, calc(100% - 30px)); padding: 18px; overflow: auto; overscroll-behavior: contain; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 25px; box-shadow: 0 28px 80px rgba(12,35,63,.3); }
.result-dialog::backdrop { background: rgba(15,34,59,.5); backdrop-filter: blur(4px); }
.result-topline { display: flex; align-items: center; justify-content: space-between; color: #6380a1; font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.icon-button { width: 29px; height: 29px; display: grid; place-items: center; color: #61748b; background: #f1f5f8; border: 0; border-radius: 9px; font-size: 20px; }
.result-dialog h2 { margin: 7px 0 4px; font-size: 27px; letter-spacing: -.055em; }
.result-dialog > p { margin: 0; color: var(--ink-soft); font-size: 14px; }
.result-context { margin-top: 7px; padding: 5px 8px; color: #406280; background: #f1f9ff; border: 1px solid #d5eafa; border-radius: 8px; font-size: 11px; line-height: 1.4; }
.result-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 11px 0; }
.result-metric { padding: 10px; background: #f7fafd; border: 1px solid #e4ecf4; border-radius: 12px; }
.result-metric span, .result-metric strong { display: block; }
.result-metric span { color: #788aa0; font-size: 10px; }
.result-metric strong { margin-top: 3px; font-size: 20px; font-variant-numeric: tabular-nums; }
.role-comparison { margin: 0 0 12px; overflow: hidden; border: 1px solid #e1eaf3; border-radius: 11px; }
.role-comparison-heading { padding: 5px 10px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; color: #345a7f; background: #f7fbff; border-bottom: 1px solid #e1eaf3; }
.role-comparison-heading strong { font-size: 12px; }
.role-comparison-heading span { color: #8294a8; font-size: 10px; }
.role-comparison-scroll { overflow-x: auto; }
.role-comparison table { width: 100%; min-width: 510px; border-collapse: collapse; font-size: 11px; }
.role-comparison th, .role-comparison td { padding: 4px 9px; border-bottom: 1px solid #edf2f6; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.role-comparison th { color: #7b8da2; background: #fff; font-size: 10px; font-weight: 800; }
.role-comparison th:first-child, .role-comparison td:first-child { text-align: left; }
.role-comparison tbody tr:last-child td { border-bottom: 0; }
.role-comparison tbody tr.is-current { background: #f1f9ff; }
.result-role-name { display: inline-flex; align-items: center; gap: 5px; color: #345a7f; font-weight: 800; }
.result-role-dot { width: 7px; height: 7px; border-radius: 50%; }
.result-role-note { display: block; margin-top: 1px; color: #8797aa; font-size: 9px; }
.turning-points { display: grid; gap: 7px; }
.turning-point { padding: 8px 10px; color: #536981; background: #fff9e7; border: 1px solid #f7e4ac; border-radius: 10px; font-size: 12px; }
.turning-point b { color: #604b0b; }
.turning-point.comparison { color: #3d6688; background: #f1f9ff; border-color: #d5eafa; }
.turning-point.comparison b { color: #1d5e9d; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 10px; }

.guide-dialog { position: fixed; inset: 0; width: 100dvw; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 0; overflow: visible; color: var(--ink); background: transparent; border: 0; }
.guide-dialog::backdrop { background: transparent; }
.guide-spotlight { position: fixed; z-index: 1; width: 0; height: 0; pointer-events: none; border: 2px solid rgba(82, 172, 255, .95); border-radius: 12px; box-shadow: 0 0 0 100vmax rgba(9, 27, 48, .33), 0 0 0 5px rgba(143, 210, 255, .22); transition: top .18s ease, left .18s ease, width .18s ease, height .18s ease; }
.guide-popover { position: fixed; z-index: 2; width: min(332px, calc(100vw - 24px)); padding: 13px; color: var(--ink); background: #fff; border: 1px solid #c9def2; border-radius: 14px; box-shadow: 0 18px 54px rgba(10, 35, 63, .28); }
.guide-topline { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: #66809e; font-size: 10px; font-weight: 800; letter-spacing: .06em; }
.guide-popover h2 { margin: 9px 0 5px; color: #183a63; font-size: 17px; letter-spacing: -.02em; }
.guide-popover p { margin: 0; color: #566d86; font-size: 12px; line-height: 1.55; }
.guide-suppress { display: flex; align-items: center; gap: 5px; margin-top: 10px; color: #6f8399; font-size: 10px; }
.guide-suppress input { margin: 0; accent-color: var(--blue); }
.guide-actions { display: flex; align-items: center; justify-content: space-between; gap: 9px; margin-top: 12px; }
.guide-actions > span { display: flex; gap: 5px; }
.guide-actions .button { min-height: 29px; padding: 5px 8px; font-size: 10px; }

@keyframes token-enter { from { opacity: 0; transform: translateY(-5px) scale(.88); } to { opacity: 1; transform: none; } }
@keyframes signal-travel { from { opacity: 0; transform: translateX(-18px) scale(.85); } 70% { opacity: 1; } to { opacity: 1; transform: none; } }
@keyframes cargo-travel { from { opacity: 0; transform: translateX(18px) scale(.85); } 70% { opacity: 1; } to { opacity: 1; transform: none; } }
@keyframes card-breathe { 0% { box-shadow: 0 0 0 0 rgba(35,117,225,.3); } 100% { box-shadow: 0 0 0 10px rgba(35,117,225,0); } }

@media (max-height: 690px) and (min-width: 861px) {
  .app-shell { grid-template-rows: 43px minmax(0, 1fr) 48px; padding: 7px; gap: 7px; }
  .dashboard-main { grid-template-rows: minmax(116px, .27fr) minmax(0, 1fr); gap: 7px; }
  .system-map { padding-block: 5px; grid-template-rows: 37px 37px auto; }
  .map-flow { grid-template-columns: 102px minmax(0, 1fr); }
  .map-node { min-height: 35px; padding-block: 3px; }
  .map-state-note { margin-left: 110px; font-size: 10px; }
  .stage-card { padding: 8px; }
  .stage-title { margin-bottom: 4px; }
  .pipeline-block { margin-top: 3px; }
  .inventory-position { margin-block: 4px; }
  .delivery-strip { margin-top: 3px; }
  .order-control { margin-top: 4px; padding-top: 4px; }
  .coach-card { padding: 6px 7px; }
}

@media (max-width: 860px) {
  .dashboard-body { height: auto; overflow: auto; }
  .app-shell { height: auto; min-height: 100dvh; grid-template-rows: auto auto auto; }
  .topbar { min-height: 48px; height: auto; flex-wrap: wrap; }
  .dashboard-main { grid-template-rows: 156px auto; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .operations-section { min-height: 420px; }
  .analysis-section { min-height: 360px; }
  .chart-wrap { min-height: 280px; }
}

@media (max-width: 590px) {
  .app-shell { padding: 7px; gap: 7px; }
  .topbar { padding: 7px; gap: 7px; }
  .top-stats { width: 100%; }
  .top-stat { flex: 1; min-width: 0; padding-inline: 8px; }
  .top-actions { width: 100%; }
  .top-actions > * { flex: 1; }
  .top-actions .button { flex: 0 0 auto; }
  select { width: 100%; }
  .dashboard-main { grid-template-rows: 168px auto; }
  .system-map { overflow-x: auto; }
  .map-flow { width: 660px; grid-template-columns: 108px 1fr; }
  .map-state-note { width: 660px; margin-left: 116px; }
  .dashboard-grid { gap: 7px; }
  .operations-section { min-height: 445px; padding: 8px; }
  .stage-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage-grid[data-mode="sandbox"] { grid-template-columns: 1fr; grid-template-rows: repeat(4, minmax(210px, auto)); }
  .sandbox-direct-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .action-bar { align-items: stretch; flex-direction: column; }
  .action-controls { justify-content: space-between; }
  .result-metrics { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .setting-choice { grid-template-columns: minmax(0, 1fr) 144px; }
  .guide-popover { width: calc(100vw - 20px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
