/* Haul plans and storage map share the portal's navigation and controls. */
.planning-page { min-width: 0; }
.planning-page .back-link { display: inline-block; margin-bottom: 18px; color: #a9dbe8; text-decoration: none; }
.planning-page h1 { font-size: clamp(25px, 3vw, 36px); }
.planning-page h2 { font-size: 21px; margin-bottom: 16px; }
.planning-page h3 { font-size: 18px; }
.planning-page .muted, .planning-page small { color: #aec5d4; }
.planning-page [hidden] { display: none !important; }
.plan-actions, .map-tools, .map-edit-tools, .map-save-actions, .map-nudge { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.plan-fields { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; }
.plan-full { grid-column: 1 / -1; }
.haul-event-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 18px; }
.haul-event-card h3 { font-size: 24px; margin: 16px 0 6px; text-transform: capitalize; }
.plan-metrics { display: flex; flex-wrap: wrap; gap: 22px 36px; margin: 20px 0; }
.plan-metrics > div { display: grid; gap: 3px; }
.plan-metrics strong { font-size: 22px; color: #f0f7fc; font-variant-numeric: tabular-nums; }
.plan-metrics span { font-size: 13px; color: #aec5d4; }
.past-plans a { display: flex; gap: 16px; justify-content: space-between; padding: 16px 0; border-top: 1px solid #29475b; color: #def2fc; text-decoration: none; }
.planning-page .empty-state { padding: 36px; text-align: center; }
.plan-add { display: grid; grid-template-columns: 1fr 1.5fr auto; gap: 16px; align-items: end; }
.queue-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px; margin: 12px 0 18px; }
.queue-heading h2, .map-heading h2 { margin: 0; }
.queue-heading p { margin: 8px 0 0; font-size: 14px; }
.season-choice { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.season-choice .form-select { width: auto; min-width: 150px; max-width: 100%; }
.haul-queue { display: grid; gap: 12px; }
.haul-booking { display: grid; grid-template-columns: 28px 75px minmax(0, 1fr) minmax(120px, auto) 96px; gap: 10px 16px; align-items: center; padding: 18px; background: #102738; border: 1px solid #2a4254; border-radius: 14px; }
.haul-booking.dragging { opacity: .6; border-color: #63dcf8; }
.drag-handle { cursor: grab; font-size: 26px; color: #92b7c8; background: none; border: 0; padding: 0; min-height: 44px; }
.queue-time { display: grid; font-variant-numeric: tabular-nums; }
.queue-time strong { font-size: 23px; color: #82e7f9; }
.queue-time span, .queue-time small { font-size: 12px; color: #aec5d4; }
.queue-boat h3 { margin: 0 0 4px; overflow-wrap: anywhere; }
.queue-boat p { margin: 0 0 2px; font-size: 14px; overflow-wrap: anywhere; }
.queue-boat small { font-size: 12px; }
.queue-placement { display: grid; gap: 10px; justify-items: start; }
.placement-link { font-size: 13px; color: #85deef; text-decoration: none; }
.queue-move { display: flex; gap: 6px; }
.queue-move .btn { width: 44px; padding: 4px; }
.booking-edit { grid-column: 2 / -1; border-top: 1px solid #294052; margin-top: 4px; }
.booking-edit > summary { min-height: 36px; font-weight: 400; font-size: 13px; }
.booking-status { display: grid; grid-template-columns: 150px 1fr auto; gap: 12px; align-items: end; padding: 12px 0 0; }
.queue-save { position: sticky; z-index: 5; top: 80px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 16px; border: 1px solid #68dff1; background: #173b4a; border-radius: 12px; margin-bottom: 16px; box-shadow: 0 8px 30px #0005; }
.queue-save span { flex: 1; min-width: 160px; }
.season-toolbar { display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: start; justify-content: space-between; }
.new-season { min-width: min(100%, 280px); }
.new-season form { max-width: 350px; }
.new-season input[type=checkbox] { flex-shrink: 0; width: 18px; height: 18px; margin-top: 3px; }
.planning-hint { display: grid; gap: 6px; background: #173c46; border-left: 4px solid #6fe5eb; padding: 18px; margin-bottom: 20px; border-radius: 10px; }
.placement-queue { display: flex; gap: 10px; overflow-x: auto; padding: 12px 2px 6px; }
.placement-queue-item { display: grid; gap: 4px; min-width: 180px; max-width: 240px; border: 1px solid #36566a; background: #0c2130; color: #e6f6fc; padding: 12px; border-radius: 10px; text-decoration: none; }
.placement-queue-item strong, .placement-queue-item span { overflow-wrap: anywhere; }
.placement-queue-item span { font-size: 12px; color: #b6cdd8; }
.placement-queue-item.selected { border-color: #71dff3; background: #163c49; }
.storage-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 20px; align-items: start; }
.storage-sidebar { display: grid; gap: 16px; min-width: 0; position: sticky; top: 88px; max-height: calc(100vh - 108px); overflow-y: auto; padding: 2px; }
.portal .map-panel { padding: 18px; }
.map-heading { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.map-tools .btn { padding: 5px 12px; }
.map-tools output { font-size: 13px; font-variant-numeric: tabular-nums; width: 50px; text-align: center; }
.map-instructions { font-size: 13px; color: #bdd1dc; margin: 12px 0; }
.map-viewport { max-height: 76vh; min-height: 240px; overflow: auto; border: 1px solid #3b586c; border-radius: 10px; background: #fff; overscroll-behavior: contain; }
.storage-map { position: relative; width: 100%; overflow: hidden; background: #fff; }
.storage-map > img { display: block; width: 100%; height: auto; max-width: none; user-select: none; }
.storage-map.placing { cursor: crosshair; outline: 3px solid #70e9f4; outline-offset: -3px; }
.storage-spot { position: absolute; display: flex; justify-content: center; align-items: center; border: 1px solid #182a34; border-radius: 3px; padding: 0; min-width: 0; min-height: 0; font: 700 clamp(8px, 1vw, 13px) system-ui; line-height: 1; color: #10212c; cursor: grab; transform-origin: center; touch-action: none; box-shadow: 0 1px 4px #0007; }
.storage-spot.free, .storage-legend.free { background: #8ed6ab; }
.storage-spot.planned, .storage-legend.planned { background: #ffce70; }
.storage-spot.occupied, .storage-legend.occupied { background: #8ecbff; }
.storage-spot.has-deviation, .storage-legend.deviation { background: #ff8d83; border-color: #8e2520; color: #34120f; }
.storage-spot.has-deviation { border-width: 2px; }
.position-deviation { flex-shrink: 0; }
.storage-spot.selected, .storage-spot:focus-visible { outline: 3px solid #9e12e3; outline-offset: 2px; z-index: 2; }
.storage-legend { display: inline-block; color: #10212c; padding: .25rem .5rem; border-radius: 5px; font-size: 12px; }
.map-legend { display: flex; gap: 8px; margin: 14px 0 10px; }
.geometry-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.geometry-fields label { font-size: 12px; }
.map-edit-tools .btn { flex-grow: 1; }
.map-nudge { margin-top: 8px; }
.map-nudge .btn { flex: 1; }
.map-save-actions .btn-gbf { flex: 1; }
.map-save-actions { position: sticky; bottom: -1px; background: #102738; padding: 12px 0 0; }
.map-warning { color: #ffdc9f; background: #4d3820; padding: 12px; border-radius: 8px; font-size: 13px; }
.unsaved { background: #5b4520; color: #ffe2a6; }
#map-edit-status { font-size: 13px; }
.position-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 310px), 1fr)); gap: 10px; }
.position-list-item { display: flex; align-items: center; gap: 12px; text-align: left; padding: 14px; color: #e2eff6; background: #0b2030; border: 1px solid #2c4b5e; border-radius: 10px; }
.position-list-item > strong { min-width: 35px; font-size: 18px; }
.position-list-item > span:nth-child(2) { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 14px; }
.position-list-item small { display: block; font-size: 12px; }
.position-list-item.selected { border-color: #7ddcec; }
@media (max-width: 1000px) {
    .plan-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .storage-workspace { grid-template-columns: minmax(0, 1fr); }
    .storage-sidebar { position: static; max-height: none; overflow: visible; }
    .storage-sidebar > .panel { max-width: none; }
    .map-viewport { max-height: 65vh; }
    .haul-booking { grid-template-columns: 24px 68px minmax(0, 1fr) 96px; }
    .queue-placement { grid-column: 3; grid-row: 2; display: flex; align-items: center; flex-wrap: wrap; }
    .queue-move { grid-column: 4; grid-row: 1 / 3; }
    .booking-edit { grid-row: 3; }
}
@media (max-width: 600px) {
    .planning-page .page-heading { display: grid; gap: 16px; }
    .plan-actions > * { flex: 1; }
    .plan-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .plan-add, .booking-status { grid-template-columns: minmax(0, 1fr); }
    .plan-metrics { gap: 16px 24px; }
    .plan-metrics > div { min-width: 100px; }
    .plan-metrics strong { font-size: 20px; }
    .haul-booking { padding: 14px 12px; grid-template-columns: 62px minmax(0, 1fr) 44px; gap: 8px 10px; }
    .drag-handle { display: none; }
    .queue-time { grid-column: 1; grid-row: 1; }
    .queue-time strong { font-size: 20px; }
    .queue-boat { grid-column: 2; grid-row: 1; }
    .queue-boat h3 { font-size: 16px; }
    .queue-placement { grid-column: 1 / 3; grid-row: 2; }
    .queue-move { grid-column: 3; grid-row: 1 / 3; flex-direction: column; }
    .booking-edit { grid-column: 1 / -1; }
    .queue-heading { align-items: stretch; }
    .season-choice { width: 100%; }
    .season-choice .form-select { flex: 1; width: 100px; min-width: 100px; }
    .season-toolbar > *, .new-season form { width: 100%; max-width: none; }
    .portal .map-panel { padding: 12px; }
    .map-tools { gap: 5px; }
    .map-tools .btn { padding: 5px 10px; }
    .map-viewport { max-height: 62vh; }
    .storage-spot { font-size: 8px; }
    .past-plans a { flex-wrap: wrap; gap: 6px; }
}


/* Metric plans preserve one isotropic metre scale on both axes. */
.storage-schematic { display: block; width: 100%; height: auto; pointer-events: none; }
.storage-spot { flex-direction: column; gap: 2px; }
.bow-facing-access .storage-spot::after { content: ""; position: absolute; right: 4%; top: 30%; width: 10%; height: 40%; background: #10212c; clip-path: polygon(0 0,100% 50%,0 100%); pointer-events: none; }

.calibration-canvas { position: relative; }
.calibration-canvas > img { display: block; width: 100%; height: auto; }
.calibration-canvas > svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* SVG zones share the exact calibrated aspect used by draggable positions. */
.storage-zoned-map { display:block; width:100%; height:auto; }
.storage-generation-map { max-height:80vh; overflow:auto; background:#e5e9eb; }
.storage-generation-map > svg { display:block; width:100%; min-width:650px; height:auto; }

.trailer-fields { padding:16px; border:1px solid #466071; border-radius:10px; min-width:0; }
.trailer-fields legend { float:none; width:auto; padding:0 8px; font-size:1.15rem; }
.trailer-row { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)) auto; gap:12px; align-items:end; margin-bottom:12px; }
.trailer-row label { min-width:0; font-size:.9rem; }
.trailer-row input { margin-top:5px; }
@media(max-width:600px) { .trailer-row { grid-template-columns:1fr; padding-bottom:14px; border-bottom:1px solid #466071; } .trailer-row button { justify-self:start; } }

/* Waiting boats retain editor data but reserve no pixels in the map. */
.storage-spot[hidden] { display: none !important; }

/* The label has its own bounded SVG viewport, independent of boat rotation. */
.storage-label-frame { position:absolute; left:4%; right:16%; top:6%; bottom:6%; overflow:hidden; pointer-events:none; }
.storage-spot-label { display:block; overflow:hidden; pointer-events:none; }
