:root {
  color-scheme: light;
  --ink: #172b4d;
  --muted: #6b778c;
  --line: #e2e6ec;
  --soft: #f4f6f8;
  --panel: #ffffff;
  --blue: #4f8deb;
  --blue-dark: #3475da;
  --blue-soft: #edf5ff;
  --green: #18a66a;
  --red: #e24b55;
  --shadow: 0 12px 36px rgba(31, 52, 91, 0.1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-width: 900px;
  overflow: hidden;
  color: var(--ink);
  background: #f4f5f7;
  font: 14px/1.45 Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.site-header {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.brand { display: flex; gap: 11px; align-items: center; color: inherit; text-decoration: none; }
.brand-logo { width: 34px; height: 34px; border-radius: 9px; object-fit: cover; box-shadow: 0 3px 10px rgba(56, 120, 216, .18); }
.brand b, .brand small { display: block; }
.brand b { color: #4f8deb; font-size: 16px; letter-spacing: -.2px; }
.brand small { margin-top: -1px; color: var(--muted); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.header-note { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.header-note span { width: 7px; height: 7px; border-radius: 99px; background: var(--green); box-shadow: 0 0 0 4px #ddf6eb; }

.planner-shell {
  min-width: 900px;
  height: calc(100vh - 58px);
  display: grid;
  grid-template-columns: 348px minmax(600px, 1fr) 352px;
  gap: 1px;
  background: var(--line);
}

.setup-panel, .stats-panel { overflow: auto; background: var(--panel); }
.setup-panel { padding: 16px 14px 34px; }
.stats-panel { padding: 16px 16px 30px; }
.scene-panel { min-width: 0; display: grid; grid-template-rows: auto 1fr auto; background: #eef3f9; }

.panel-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.panel-title h1, .panel-title h2 { margin: 0; font-size: 18px; letter-spacing: -.02em; }
.panel-title p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.eyebrow { color: var(--blue); font-size: 10px; font-weight: 800; letter-spacing: .16em; }

.mode-switch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; margin-bottom: 14px; border-radius: 11px; background: var(--soft); }
.mode-switch button { border: 0; border-radius: 8px; padding: 9px 8px; background: transparent; color: var(--muted); font-weight: 700; cursor: pointer; }
.mode-switch button.is-active { color: var(--blue); background: white; box-shadow: 0 2px 8px rgba(34, 53, 87, .1); }

.vehicle-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; margin-bottom: 12px; }
.vehicle-grid.truck { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.vehicle-chip { min-height: 42px; padding: 6px 4px; border: 1px solid var(--line); border-radius: 9px; background: white; color: #3e4c65; font-weight: 750; cursor: pointer; }
.vehicle-chip:hover { border-color: #9eb5ef; }
.vehicle-chip.is-active { color: var(--blue); border-color: var(--blue); background: var(--blue-soft); box-shadow: inset 0 0 0 1px var(--blue); }

.spec-strip { padding: 10px 11px; margin-bottom: 14px; border: 1px solid #dfe7f4; border-radius: 10px; background: #f8faff; color: #53617a; font-size: 11px; }
.spec-strip b { color: var(--ink); }
.import-card { display: flex; gap: 9px; align-items: center; margin: -3px 0 14px; padding: 9px; border: 1px dashed #b8cae5; border-radius: 10px; background: #f8fbff; }
.import-card small { flex: 0 0 auto; color: var(--muted); font-size: 9px; white-space: nowrap; }
.import-button { flex: 1; min-width: 0; min-height: 38px; color: var(--blue); }
.imported-volume { margin: -2px 0 8px; color: var(--muted); font-size: 9px; }
.imported-volume b { color: #40516d; }
.custom-spec-editor { padding: 11px; margin-bottom: 10px; border: 1px solid #dfe7f4; border-radius: 10px; background: #f8faff; }
.custom-spec-editor .choice-label { margin-top: 0; }
.field-row { display: grid; gap: 8px; }
.field-row.two { grid-template-columns: 1fr 1fr; }
.field-row.three { grid-template-columns: repeat(3, 1fr); }
.field { display: grid; gap: 5px; min-width: 0; color: #5f6d83; font-size: 11px; font-weight: 650; }
.field input, .field select, .toolbar-select { width: 100%; min-width: 0; height: 36px; padding: 0 9px; border: 1px solid #cfd8e6; border-radius: 8px; outline: none; color: var(--ink); background: white; }
.field input:focus, .field select:focus, .toolbar-select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(36, 92, 231, .11); }

.section-head { display: flex; justify-content: space-between; align-items: center; margin: 20px 0 10px; }
.section-head h2 { margin: 0; font-size: 14px; }
.section-head span { color: var(--muted); font-size: 11px; }

.cargo-card { position: relative; margin-bottom: 10px; padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: white; box-shadow: 0 3px 14px rgba(31, 52, 91, .045); }
.cargo-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.cargo-name-wrap { display: flex; min-width: 0; align-items: center; gap: 8px; }
.cargo-name-wrap input[type="color"] { width: 23px; height: 23px; padding: 0; border: 0; border-radius: 6px; overflow: hidden; cursor: pointer; }
.cargo-name { width: 100%; min-width: 0; border: 0; outline: none; font-weight: 800; }
.icon-button { display: grid; place-items: center; width: 28px; height: 28px; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 7px; background: white; color: var(--muted); cursor: pointer; }
.icon-button:hover { color: var(--red); border-color: #f0b5ba; background: #fff7f7; }
.dimension-labels { display: grid; grid-template-columns: 1fr 1fr 1fr 23px; gap: 6px; margin-bottom: 4px; color: #8a95a8; font-size: 9px; text-align: center; text-transform: uppercase; }
.dimension-row { display: grid; grid-template-columns: 1fr 1fr 1fr 23px; gap: 6px; align-items: center; margin-bottom: 9px; }
.dimension-row input { width: 100%; min-width: 0; height: 36px; padding: 0 5px; border: 1px solid #cfd8e6; border-radius: 8px; text-align: center; outline: none; }
.dimension-row span { color: var(--muted); font-size: 11px; }
.choice-label { display: block; margin: 11px 0 6px; color: #67758a; font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.label-with-help { display: inline-flex; align-items: center; gap: 5px; }
.help-button { display: inline-grid; place-items: center; width: 17px; height: 17px; padding: 0; border: 1px solid #b9c8dc; border-radius: 50%; color: var(--blue); background: white; font-size: 11px; font-weight: 900; line-height: 1; cursor: pointer; }
.help-button:hover, .help-button:focus-visible { color: white; border-color: var(--blue); background: var(--blue); outline: none; }
.choice-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.choice-grid.three { grid-template-columns: repeat(3, 1fr); }
.choice-button { min-height: 37px; padding: 4px 2px; border: 1px solid var(--line); border-radius: 8px; background: white; color: #657188; font-size: 10px; line-height: 1.15; cursor: pointer; }
.choice-button b, .choice-button small { display: block; }
.choice-button small { margin-top: 2px; font-size: 8px; }
.choice-button.is-active { color: var(--blue); border-color: var(--blue); background: var(--blue-soft); }
.pallet-switch { display: flex; justify-content: space-between; align-items: center; margin-top: 11px; padding-top: 10px; border-top: 1px solid #edf0f5; font-size: 11px; font-weight: 750; }
.pallet-box { padding: 10px; margin-top: 9px; border-radius: 9px; background: #f7f9fd; }

.secondary, .primary, .toolbar-button, .danger-button { min-height: 36px; border-radius: 8px; padding: 0 11px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.secondary, .toolbar-button { border: 1px solid #cdd7e6; background: white; color: #44526b; }
.secondary:hover, .toolbar-button:hover { border-color: #96ade2; color: var(--blue); }
.primary { border: 1px solid var(--blue); color: white; background: var(--blue); box-shadow: 0 7px 16px rgba(36, 92, 231, .18); }
.primary:hover { background: var(--blue-dark); }
.danger-button { border: 1px solid #f4b6bb; color: #c83240; background: #fff9f9; }
.wide { width: 100%; }
.add-cargo { width: 100%; margin: 2px 0 10px; }
.calculate { width: 100%; height: 44px; margin-top: 4px; }

.scene-toolbar { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; min-height: 88px; padding: 9px 12px; border-bottom: 1px solid var(--line); background: white; }
.toolbar-group { display: flex; gap: 6px; align-items: center; }
.toolbar-group.views { margin-left: auto; }
.toolbar-button { height: 36px; }
.toolbar-button.is-active { color: white; border-color: var(--blue); background: var(--blue); }
.toolbar-button.locked { color: white; border-color: var(--blue); background: var(--blue); }
.toolbar-select { width: auto; min-width: 118px; }
.toolbar-label { color: var(--muted); font-size: 11px; font-weight: 700; }

.scene-stage { position: relative; min-height: 0; overflow: hidden; background: radial-gradient(circle at 55% 45%, #fbfdff 0, #f0f5fb 58%, #e9eef5 100%); }
#scene-canvas { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#scene-canvas.is-locked { cursor: default; }
.loaded-badge { position: absolute; z-index: 2; top: 16px; left: 16px; padding: 9px 13px; border: 1px solid #d7e0ed; border-radius: 9px; background: rgba(255,255,255,.94); box-shadow: 0 5px 16px rgba(31, 52, 91, .08); font-size: 13px; font-weight: 800; }
.loaded-badge strong { margin-left: 6px; color: var(--blue); }
.empty-scene { position: absolute; left: 50%; bottom: 44px; transform: translateX(-50%); display: grid; gap: 3px; min-width: 300px; padding: 12px 18px; border: 1px solid #dce4ef; border-radius: 10px; color: #65728a; background: rgba(255,255,255,.88); text-align: center; pointer-events: none; }
.empty-scene b { color: #394761; }
.empty-scene[hidden] { display: none; }
.scene-hint { min-height: 48px; padding: 11px 16px; border-top: 1px solid var(--line); color: #7a879c; background: white; font-size: 11px; }
.scene-hint b { color: #4b5870; }

.stat-head { margin-bottom: 14px; }
.stat-head h2 { margin: 0; font-size: 17px; }
.stat-head p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.spec-card { padding: 13px; border: 1px solid var(--line); border-radius: 11px; background: #f8faff; }
.spec-card dl { display: grid; grid-template-columns: auto 1fr; gap: 7px 10px; margin: 0; font-size: 11px; }
.spec-card dt { color: var(--muted); }
.spec-card dd { min-width: 0; margin: 0; overflow-wrap: anywhere; text-align: right; font-weight: 750; }
.metric-list { margin: 16px 0; }
.metric { margin-bottom: 12px; }
.metric-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 3px 10px; margin-bottom: 5px; font-size: 11px; }
.metric-head span { color: var(--muted); }
.metric-head b { margin-left: auto; text-align: right; }
.progress { height: 7px; overflow: hidden; border-radius: 99px; background: #e6ebf2; }
.progress i { display: block; height: 100%; width: var(--progress); border-radius: inherit; background: var(--blue); }
.progress.weight i { background: var(--green); }
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin: 14px 0; }
.summary-grid span { padding: 10px; border: 1px solid #e3e8f0; border-radius: 9px; background: white; }
.summary-grid small, .summary-grid b { display: block; }
.summary-grid small { color: var(--muted); font-size: 9px; text-transform: uppercase; }
.summary-grid b { margin-top: 3px; font-size: 14px; }
.load-line { padding: 11px 0; border-top: 1px solid #e8ecf2; }
.load-line-head { display: flex; gap: 8px; justify-content: space-between; }
.load-line-head span { min-width: 0; }
.color-dot { display: inline-block; width: 9px; height: 9px; margin-right: 5px; border-radius: 3px; background: var(--dot); }
.load-line p { margin: 6px 0 0; color: #68758a; font-size: 10px; }
.alert { padding: 10px 11px; margin: 12px 0; border: 1px solid #f4c2c6; border-radius: 9px; color: #a42d38; background: #fff7f7; font-size: 11px; }
.empty-stats { display: grid; place-items: center; min-height: 250px; color: var(--muted); text-align: center; }
.empty-stats span { display: block; max-width: 210px; }

.modal-backdrop { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(13, 24, 46, .48); backdrop-filter: blur(4px); }
.modal-backdrop[hidden] { display: none; }
.tutorial-modal { position: relative; width: min(600px, 100%); max-height: 90vh; overflow: auto; padding: 30px; border-radius: 16px; background: white; box-shadow: 0 30px 90px rgba(12, 25, 50, .3); }
.tutorial-modal h2 { margin: 7px 40px 20px 0; font-size: 25px; line-height: 1.15; letter-spacing: -.03em; }
.help-modal { width: min(480px, 100%); }
.help-modal p { margin: 0 0 22px; color: var(--muted); font-size: 13px; line-height: 1.7; }
#help-modal[data-tone="warning"] .help-modal { border-top: 4px solid #e45661; }
#help-modal[data-tone="warning"] .eyebrow, #help-modal[data-tone="warning"] h2 { color: #b52f3b; }
.tutorial-modal ol { display: grid; gap: 12px; margin: 0 0 20px; padding: 0; list-style: none; counter-reset: steps; }
.tutorial-modal li { position: relative; display: grid; gap: 2px; padding-left: 40px; counter-increment: steps; }
.tutorial-modal li::before { content: counter(steps); position: absolute; left: 0; top: 0; display: grid; place-items: center; width: 27px; height: 27px; border-radius: 8px; color: var(--blue); background: var(--blue-soft); font-weight: 900; }
.tutorial-modal li span { color: var(--muted); font-size: 12px; }
.modal-close { position: absolute; top: 16px; right: 16px; width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 9px; background: white; color: var(--muted); cursor: pointer; }
.shortcut-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 13px; margin-bottom: 18px; border-radius: 10px; background: var(--soft); color: #5c687d; font-size: 10px; }
kbd { display: inline-block; min-width: 21px; padding: 2px 5px; margin-right: 3px; border: 1px solid #cbd5e3; border-bottom-width: 2px; border-radius: 5px; color: #334159; background: white; font: 700 9px/1.3 inherit; text-align: center; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: 24px; transform: translate(-50%, 16px); padding: 10px 15px; border-radius: 9px; color: white; background: #1d2c46; opacity: 0; pointer-events: none; transition: .2s ease; box-shadow: var(--shadow); }
.toast.is-visible { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 1380px) {
  .planner-shell { grid-template-columns: 330px minmax(580px, 1fr) 330px; }
  .toolbar-group.views { margin-left: 0; }
  .toolbar-button, .danger-button { padding-inline: 9px; }
}

@media (max-width: 1100px) {
  .planner-shell { grid-template-columns: 245px minmax(405px, 1fr) 255px; }
  .setup-panel, .stats-panel { padding: 12px 10px 24px; }
  .panel-title { margin-bottom: 11px; }
  .panel-title h1, .panel-title h2 { font-size: 16px; }
  .vehicle-grid { gap: 4px; }
  .vehicle-chip { min-height: 38px; font-size: 11px; }
  .cargo-card { padding: 10px; }
  .choice-grid { grid-template-columns: 1fr 1fr; }
  .choice-grid.three { grid-template-columns: repeat(3, 1fr); }
  .scene-toolbar { gap: 5px; padding: 7px 8px; }
  .toolbar-button, .danger-button { min-height: 32px; height: 32px; padding-inline: 7px; font-size: 11px; }
  .toolbar-select { min-width: 98px; width: 112px; height: 32px; font-size: 11px; }
  .toolbar-label { display: none; }
  .loaded-badge { top: 10px; left: 10px; }
  .spec-card { padding: 10px; }
  .spec-card dl { gap: 6px; font-size: 10px; }
  .metric-head b { max-width: 145px; font-size: 10px; }
  .summary-grid small { font-size: 8px; }
  .summary-grid b { font-size: 12px; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
}
