:root {
  --bg: #f5f7f6;
  --panel: #ffffff;
  --panel-soft: #eef4f1;
  --ink: #17211f;
  --muted: #63716d;
  --line: #d8e1dd;
  --accent: #147d64;
  --accent-strong: #0e5f4b;
  --amber: #b46a13;
  --red: #b42318;
  --blue: #2463a6;
  --shadow: 0 12px 34px rgba(24, 42, 38, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, Segoe UI, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button,
summary {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  padding: 12px;
  gap: 10px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-main {
  min-height: 0;
  height: 100%;
}

.is-hidden {
  display: none !important;
}

.setup-screen {
  display: grid;
  min-height: 100%;
  place-items: center;
  padding: 20px;
}

.setup-card {
  display: grid;
  gap: 18px;
  width: min(760px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 22px;
}

.setup-copy {
  max-width: 560px;
}

.setup-copy h2 {
  margin-bottom: 6px;
  font-size: 20px;
}

.setup-copy p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
}

.setup-form {
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 220px);
  align-items: end;
}

.setup-form .dimensions-row {
  grid-column: 1 / -1;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.1;
}

h2,
h3 {
  margin-bottom: 4px;
  font-size: 14px;
}

.status-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.build-badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 900;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--amber);
}

.status-dot.is-ok {
  background: var(--accent);
}

.status-dot.is-bad {
  background: var(--red);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(620px, 1fr) 310px;
  gap: 10px;
  height: 100%;
  min-height: 0;
}

.planner-panel,
.context-panel {
  min-width: 0;
  min-height: 0;
}

.planner-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 10px;
}

.control-strip,
.action-strip,
.bottom-strip {
  display: grid;
  gap: 8px;
  align-items: end;
}

.planner-toolbar.control-strip {
  grid-template-columns: auto auto;
  justify-content: space-between;
  align-items: center;
  position: relative;
  z-index: 10;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.active-vehicle-strip {
  position: relative;
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.active-vehicle-strip strong {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--ink);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vehicle-library-action {
  flex: 0 0 auto;
  min-height: 30px;
  padding: 5px 10px;
  font-size: 12px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(11, 23, 20, 0.26);
}

.modal-panel {
  width: min(880px, 100%);
  max-height: min(720px, calc(100vh - 36px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(17, 32, 28, 0.24);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
  background: #fbfdfc;
}

.modal-head h2 {
  margin-bottom: 3px;
  font-size: 16px;
}

.modal-head p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.modal-close {
  flex: 0 0 auto;
}

.vehicle-library-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(300px, 1.1fr);
  gap: 14px;
  min-height: 0;
  padding: 14px;
  overflow: auto;
  scrollbar-width: thin;
}

.vehicle-library-section {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 10px;
}

.vehicle-library-section h3 {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.vehicle-library-list {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
}

.vehicle-library-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.vehicle-library-item.is-active {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.vehicle-library-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.vehicle-library-actions .primary-action,
.vehicle-library-actions .ghost-action,
.vehicle-library-actions .danger-action {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 12px;
}

.vehicle-quick-form {
  align-self: start;
}

.action-strip {
  grid-template-columns: minmax(220px, 1fr) 82px repeat(5, auto);
}

.toolbar-tools,
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.toolbar-tools {
  flex-wrap: nowrap;
}

.toolbar-actions {
  justify-content: flex-end;
}

.auto-mode-control {
  display: grid;
  grid-template-columns: auto minmax(132px, 158px);
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.auto-mode-control select {
  min-height: 34px;
  padding: 6px 28px 6px 10px;
  font-size: 12px;
  font-weight: 800;
}

.toolbar-field {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.cargo-select-control {
  min-width: 260px;
}

.toolbar-field.z-control {
  grid-template-columns: auto 68px;
  width: auto;
}

.planner-toolbar .primary-action,
.planner-toolbar .ghost-action,
.planner-toolbar .danger-action,
.planner-toolbar .icon-action,
.planner-toolbar .dropdown-panel > summary {
  align-self: center;
}

.planner-toolbar .icon-action {
  flex: 0 0 38px;
}

.planner-toolbar .rotate-plan-action,
.planner-toolbar .delete-plan-action {
  min-width: 128px;
}

.bottom-strip {
  grid-template-columns: minmax(0, 1fr) minmax(220px, 320px);
  align-items: stretch;
}

label {
  display: grid;
  gap: 4px;
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 7px 9px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 125, 100, 0.12);
}

.wide-control {
  min-width: 0;
}

.z-control {
  width: 92px;
}

.primary-action,
.ghost-action,
.icon-action,
.danger-action,
.dropdown-panel > summary {
  min-height: 34px;
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.primary-action {
  align-self: end;
  background: var(--accent);
  color: #fff;
}

.primary-action:hover {
  background: var(--accent-strong);
}

.ghost-action,
.dropdown-panel > summary {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.ghost-action.is-active {
  background: #fff3cc;
  border-color: #f2a900;
  color: #7a3f05;
}

.danger-action {
  background: #fff5f3;
  border-color: #f4c8c2;
  color: var(--red);
}

.icon-action {
  width: 38px;
  padding: 0;
  border-color: var(--line);
  background: #fff;
  color: var(--accent-strong);
  font-size: 18px;
}

.dropdown-panel {
  position: relative;
}

.dropdown-panel > summary {
  display: grid;
  place-items: center;
  list-style: none;
}

.dropdown-panel > summary::-webkit-details-marker {
  display: none;
}

.dropdown-panel[open] > summary {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.dropdown-panel > form,
.dropdown-panel > .dropdown-content,
.directory-layout {
  position: absolute;
  top: calc(100% + 7px);
  left: 0;
  z-index: 20;
  width: min(620px, calc(100vw - 34px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 12px;
}

.directory-menu .directory-layout {
  width: min(760px, calc(100vw - 34px));
}

.place-cargo-content {
  width: min(720px, calc(100vw - 34px));
}

.cargo-library-tools {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 190px) auto;
  align-items: end;
  gap: 8px;
  margin-bottom: 10px;
}

.cargo-library-search input {
  min-width: 0;
}

.cargo-filter-clear {
  min-height: 40px;
}

.cargo-library-summary {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-top: 10px;
}

.place-cargo-form {
  grid-template-columns: minmax(190px, 1fr) 82px auto;
  align-items: end;
}

.cargo-template-form {
  width: min(520px, calc(100vw - 34px));
}

.saved-cargo-list {
  max-height: 320px;
  margin-top: 10px;
  overflow-y: auto;
  scrollbar-width: thin;
}

form {
  display: grid;
  gap: 8px;
}

.task-form,
.form-grid,
.item-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.task-form .primary-action,
.item-form .primary-action,
.form-grid .primary-action {
  grid-column: 1 / -1;
}

.dimensions-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  grid-column: 1 / -1;
}

.checks {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  grid-column: 1 / -1;
}

.checks label {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-weight: 700;
}

.checks input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--accent);
}

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

.segmented {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  min-width: 138px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
  overflow: hidden;
}

.segment {
  min-height: 30px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.segment.is-active {
  background: var(--accent);
  color: #fff;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.list,
.task-list {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.compact-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.list-card,
.task-card,
.item-row {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.list-card,
.task-card {
  display: grid;
  gap: 4px;
  padding: 8px;
}

.task-card {
  text-align: left;
}

.task-card.is-active,
.item-row.is-selected {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.card-top,
.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-title {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.card-meta,
.item-meta,
.metric-grid span {
  color: var(--muted);
  font-size: 11px;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.cargo-template-card {
  gap: 8px;
}

.cargo-template-card-main {
  min-width: 0;
}

.cargo-template-card .card-title,
.cargo-template-card .card-meta {
  overflow: hidden;
  text-overflow: ellipsis;
}

.cargo-template-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.cargo-library-badge {
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  padding: 3px 7px;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.cargo-template-card.is-packed .cargo-library-badge {
  border-color: rgba(20, 125, 100, 0.22);
  background: rgba(20, 125, 100, 0.08);
  color: var(--accent-strong);
}

.cargo-template-card.is-unpacked .cargo-library-badge {
  border-color: rgba(193, 73, 62, 0.22);
  background: rgba(193, 73, 62, 0.07);
  color: var(--red);
}

.cargo-template-actions {
  justify-content: end;
}

.cargo-card-quantity {
  width: 58px;
  min-height: 28px;
  padding: 3px 6px;
  font-size: 12px;
  font-weight: 800;
}

.mini-button {
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--accent-strong);
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
}

.mini-button.is-danger {
  color: var(--red);
}

.plan-stage {
  min-height: 0;
  height: 100%;
}

.body-map {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 420px;
  border: 0;
  border-radius: 0;
  background: #f5f7f6;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.body-map.is-locked {
  cursor: default;
}

.body-map::before {
  content: none;
}

.body-map:focus {
  outline: none;
}

.body-scene-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

.body-map.is-space-rotate {
  cursor: grab;
  box-shadow: inset 0 0 0 3px rgba(242, 169, 0, 0.86);
}

.body-map:active,
.body-map.is-space-rotate:active,
.body-map.is-orbit-dragging {
  cursor: grabbing;
}

.body-map.is-space-rotate .body-scene-canvas {
  filter: saturate(1.08) contrast(1.02);
}

.body-map.is-space-rotate::after {
  content: "Режим вращения";
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 4;
  border: 1px solid rgba(180, 106, 19, 0.34);
  border-radius: 7px;
  background: rgba(255, 249, 231, 0.94);
  color: #7a3f05;
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 900;
  pointer-events: none;
}

.body-outline {
  position: absolute;
  border: 2px solid #33423e;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.72);
  pointer-events: none;
  z-index: 1;
}
.body-block {
  position: absolute;
  display: grid;
  place-items: center;
  min-width: 28px;
  min-height: 24px;
  border: 1px solid rgba(20, 99, 84, 0.6);
  border-radius: 6px;
  background: rgba(20, 125, 100, 0.84);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  overflow: hidden;
  padding: 2px;
  cursor: grab;
  z-index: 2;
  user-select: none;
}

.body-map.is-locked .body-block {
  cursor: default;
}

.body-block:active {
  cursor: grabbing;
}

.body-map.is-locked .body-block:active {
  cursor: default;
}

.body-block.is-selected {
  outline: 3px solid #f2a900;
  outline-offset: 2px;
}

.body-block.is-stacked {
  border-style: dashed;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.42);
}

.body-block:nth-child(3n) {
  background: rgba(36, 99, 166, 0.84);
  border-color: rgba(36, 99, 166, 0.62);
}

.body-block:nth-child(4n) {
  background: rgba(180, 106, 19, 0.84);
  border-color: rgba(180, 106, 19, 0.62);
}

.body-map-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
  pointer-events: none;
  text-align: center;
  z-index: 3;
}

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

.metric-grid div {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
  padding: 7px 8px;
}

.metric-grid strong {
  display: block;
  margin-top: 5px;
  font-size: 14px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.placement-hint {
  display: grid;
  align-items: center;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfdfc;
  color: var(--muted);
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 800;
}

.context-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8px;
}

.context-box {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.context-box[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.context-box > summary {
  min-height: 48px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 17px;
  font-weight: 900;
  line-height: 1.1;
  list-style: none;
}

.context-box > summary::-webkit-details-marker {
  display: none;
}

.task-detail {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}

.detail-head {
  display: grid;
  gap: 3px;
  padding: 10px 12px 9px;
  border-bottom: 1px solid var(--line);
  background: #fbfdfc;
}

.detail-body {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 10px;
  scrollbar-width: thin;
  scrollbar-color: #b9c8c3 transparent;
}

.item-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  min-height: 0;
  padding: 12px;
  overflow: visible;
  transition: border-color 120ms ease, background-color 120ms ease, box-shadow 120ms ease;
}

.item-row:hover {
  background: #fbfdfc;
  border-color: #bdcbc6;
}

.item-row.is-selected {
  border-color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.item-row.is-status-placed {
  border-left: 3px solid #14805f;
}

.item-row.is-status-unplaced {
  border-left: 3px solid #8a9894;
}

.item-row.is-status-warning {
  border-left: 3px solid #c8891a;
}

.item-row.is-status-error {
  border-left: 3px solid #c45126;
  background: #fffaf6;
}

.item-row.is-status-overload {
  border-left: 3px solid var(--red);
  background: #fff8f7;
}

.cargo-card-main {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding-right: 28px;
}

.cargo-card-topline {
  position: static;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.cargo-card-topline .card-title {
  max-width: 100%;
  min-width: 0;
  padding-right: 4px;
  font-size: 14px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.cargo-packaging-badge {
  border-color: #f0b7ae;
  background: #fff4f2;
  color: var(--red);
}

.cargo-status-badge {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 18px;
  border: 1px solid #cad7d3;
  border-radius: 999px;
  background: #f6faf8;
  color: #465550;
  padding: 0 6px;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.cargo-status-badge.is-placed {
  border-color: #b7ded1;
  background: #effaf5;
  color: #0f6f55;
}

.cargo-status-badge.is-unplaced {
  border-color: #d2dbd8;
  background: #f4f7f6;
  color: #5f6c68;
}

.cargo-status-badge.is-warning {
  border-color: #f0d79c;
  background: #fff8e7;
  color: #8a5a00;
}

.cargo-status-badge.is-error {
  border-color: #f1c5ad;
  background: #fff3ed;
  color: #9b3f18;
}

.cargo-status-badge.is-overload {
  border-color: #f0b7ae;
  background: #fff4f2;
  color: var(--red);
}

.cargo-status-badge.is-unpacked {
  border-color: #f0b7ae;
  background: #fff4f2;
  color: var(--red);
  text-transform: lowercase;
}

.cargo-card-subline,
.cargo-card-position {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.25;
}

.cargo-card-position {
  color: #465550;
}

.cargo-info-trigger {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--accent-strong);
  padding: 0;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  z-index: 3;
}

.cargo-info-trigger::after {
  content: "";
  position: absolute;
  top: 100%;
  right: -10px;
  width: 44px;
  height: 14px;
}

.cargo-info-trigger:hover,
.cargo-info-trigger:focus,
.cargo-info-trigger:focus-visible {
  border-color: var(--accent);
  background: #f2fbf7;
  outline: none;
}

.cargo-info-popover {
  position: absolute;
  top: 34px;
  right: 10px;
  z-index: 12;
  display: none;
  width: min(260px, calc(100% - 20px));
  border: 1px solid #cbd8d4;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 36px rgba(24, 42, 38, 0.16);
  padding: 10px;
  color: var(--ink);
  font-size: 11px;
  line-height: 1.35;
}

.item-row.is-popover-above .cargo-info-popover,
.sidebar-notice.is-popover-above .cargo-info-popover {
  top: auto;
  bottom: calc(100% - 6px);
}

.item-row.is-popover-above .cargo-info-trigger::after,
.sidebar-notice.is-popover-above .cargo-info-trigger::after {
  top: auto;
  bottom: 100%;
}

.cargo-info-trigger:hover + .cargo-info-popover,
.cargo-info-trigger:focus + .cargo-info-popover,
.cargo-info-trigger:focus-visible + .cargo-info-popover,
.cargo-info-popover:hover {
  display: grid;
  gap: 6px;
}

.cargo-info-popover div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.cargo-info-popover strong {
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

.cargo-info-popover span {
  text-align: right;
  overflow-wrap: anywhere;
}

.item-row .card-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  min-width: 0;
}

.item-row .mini-button {
  min-height: 30px;
  border-radius: 8px;
  padding: 5px 9px;
}

.icon-mini {
  width: 32px;
  padding: 0;
  font-size: 14px;
}

.place-mini {
  flex: 1 1 auto;
  min-width: 72px;
}

.sidebar-notice {
  position: relative;
  min-height: 34px;
  border: 1px solid #f1d6a7;
  border-radius: 8px;
  background: #fffaf1;
  color: #7a4300;
  padding: 8px 38px 8px 10px;
  font-size: 12px;
  font-weight: 800;
}

.sidebar-notice .notice-info-trigger {
  top: 7px;
  right: 9px;
}

.sidebar-notice .notice-popover {
  width: min(280px, calc(100% - 20px));
  color: #5f3b06;
}

.empty-state {
  display: grid;
  min-height: 120px;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.unplaced-banner {
  display: grid;
  gap: 4px;
  border: 1px solid #f1c27a;
  border-radius: 7px;
  background: #fff8ec;
  color: var(--amber);
  padding: 8px;
  font-size: 11px;
}

.unplaced-banner strong {
  color: #7a4300;
  font-size: 12px;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: min(420px, calc(100vw - 32px));
  min-height: 40px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
  z-index: 40;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.is-error {
  background: var(--red);
}

@media (max-width: 1180px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .context-panel {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto;
  }
}

@media (max-width: 760px) {
  .topbar,
  .action-strip,
  .bottom-strip,
  .context-panel {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .planner-toolbar.control-strip {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .toolbar-tools,
  .toolbar-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .topbar {
    display: grid;
  }

  .metric-grid,
  .compact-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .active-vehicle-strip {
    align-items: stretch;
    flex-wrap: wrap;
  }

  .active-vehicle-strip strong {
    flex-basis: 100%;
  }

  .vehicle-library-action {
    width: 100%;
  }

  .vehicle-library-layout,
  .vehicle-library-item {
    grid-template-columns: 1fr;
  }

  .vehicle-library-actions {
    justify-content: stretch;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cargo-library-tools,
  .place-cargo-form,
  .cargo-template-bottom {
    grid-template-columns: 1fr;
  }

  .cargo-template-actions {
    justify-content: stretch;
  }

  .cargo-card-quantity {
    width: 100%;
  }

  .dropdown-panel > form,
  .dropdown-panel > .dropdown-content,
  .directory-layout {
    position: static;
    width: 100%;
    margin-top: 8px;
  }

  .task-form,
  .form-grid,
  .item-form,
  .dimensions-row {
    grid-template-columns: 1fr;
  }
}
