/*  Vessel plan (vpl-) — VesselPlanView + the quick-setup screen + the fleet create form
    (VS-3, stowage-plan concept §5/§6). Feature layer: mds tokens only, linked after mds.css.
    The plan is a schematic of CSS-grid cells — width weights map 1:1 to fr units — that
    scrolls horizontally in its own container on narrow screens, never the page. */

/* ---- the plan ---------------------------------------------------------- */

.vpl-plan {
    overflow-x: auto;
    padding: var(--mds-space-4) 0;
}

.vpl-board {
    display: grid;
    grid-template-columns: 88px minmax(360px, 640px) 88px;
    grid-template-areas:
        ".    bow  ."
        "port hull stbd";
    gap: var(--mds-space-2) var(--mds-space-3);
    justify-content: center;
    min-width: 560px;
}

.vpl-bow {
    grid-area: bow;
    height: 36px;
    border: 1px solid var(--mds-line);
    border-bottom: none;
    border-radius: 50% 50% 0 0 / 100% 100% 0 0;
    background: var(--mds-canvas);
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.vpl-bow__label {
    font-size: var(--mds-text-xs);
    letter-spacing: 2px;
    color: var(--mds-muted);
    padding-bottom: var(--mds-space-1);
}

.vpl-hull {
    grid-area: hull;
    display: flex;
    flex-direction: column;
    gap: var(--mds-space-1);
}

.vpl-lane--port { grid-area: port; }
.vpl-lane--starboard { grid-area: stbd; }

.vpl-lane {
    display: flex;
    flex-direction: column;
    gap: var(--mds-space-1);
}

.vpl-lane .vpl-tank { min-height: 48px; }

/* Row-number gutter beside each hull row — names survive row shifts, indexes don't lie. */
.vpl-hullrow {
    display: flex;
    align-items: stretch;
    gap: var(--mds-space-1);
}

.vpl-rownum {
    flex: 0 0 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--mds-text-xs);
    color: var(--mds-muted);
}

/* NO grid gap: a fixed gap is inserted (cells−1) times, so rows with different cell counts
   lose different total width to gaps and identical cumulative weights stop lining up across
   rows. Gap-free tracks are exact weight fractions; the visual joint between cells comes
   from the cells' own horizontal margin instead (track edges stay mathematically aligned). */
.vpl-row {
    flex: 1;
    display: grid;               /* grid-template-columns set inline from the width weights */
    gap: 0;
}

/* The grid item is a positioning WRAPPER around the cell button (VS-7): it carries the
   in-track margin (the visual joint — margins inside the track keep the track edges exact
   weight fractions) and hosts the "+" insert buttons as siblings of the cell button. */
.vpl-cell {
    position: relative;
    display: flex;
    margin: 0 2px;
    min-width: 0;
}

.vpl-cell .vpl-tank { flex: 1; min-width: 0; }

/* Degenerate data gap (a RowIndex no cell carries) — modeled voids are cofferdam cells. */
.vpl-row--void {
    height: 14px;
    border: 1px dashed var(--mds-line);
    border-radius: var(--mds-radius-sm);
    background: var(--mds-canvas);
}

.vpl-tank {
    position: relative;
    min-height: 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--mds-space-0-5);
    padding: var(--mds-space-1);
    border: 1px solid var(--mds-line);
    border-radius: var(--mds-radius);
    font-family: var(--mds-font);
    cursor: pointer;
    overflow: hidden;
}

.vpl-tank__name {
    font-weight: 600;
    font-size: var(--mds-text-sm);
    color: var(--mds-title);
}

.vpl-tank__vol {
    font-size: var(--mds-text-xs);
    color: var(--mds-muted);
}

/* Coating tints — the three global coatings (concept §3). */
.vpl-tank--epoxy { background: var(--mds-tint); }
.vpl-tank--stainless { background: var(--mds-gray-100); }
.vpl-tank--zinc { background: color-mix(in srgb, var(--mds-warning) 10%, var(--mds-surface)); }

/* A cofferdam cell (VS-5): hatched space, like on a GA plan. Inside a row the grid
   stretches it to its siblings' height; a transverse cofferdam (sole cell in its row)
   stays a slim full-width band. */
.vpl-tank--cofferdam {
    min-height: 28px;
    /* Thin diagonal lines in the hairline color — canvas-on-gray-100 was invisible. */
    background: repeating-linear-gradient(
        45deg,
        var(--mds-canvas) 0 5px,
        var(--mds-line) 5px 7px);
}

/* A row of nothing but cofferdam cells (VS-6) is a transverse boundary — slim like the
   old void band; real transverse cofferdams are narrow. Cosmetic only. */
.vpl-row--slim .vpl-tank--cofferdam { min-height: 14px; }

/* An extension cell (VS-6): a body part of its tank — the mother's coating tint comes from
   the coating class, the "≙ name" label reads as a pointer, not as an own identity. */
.vpl-tank--extension .vpl-tank__name {
    font-weight: 500;
    color: var(--mds-muted);
}

/* The open tank's cell (VS-4) — THE tank being worked on. Unmistakably dominant (Robert
   2026-07-07): thick ink ring + inner tint glow + bold name. Drawn on ::after, NOT on the
   button: the clicked cell holds mouse focus, and mds.css's a11y rule
   (:focus:not(:focus-visible) { outline/box-shadow: none !important }) erases those
   properties on the focused element itself — the pseudo-element is immune. */
.vpl-tank--selected::after {
    content: "";
    position: absolute;
    inset: 0;
    border: 3px solid var(--mds-accent-ink);
    border-radius: inherit;
    box-shadow: inset 0 0 0 5px var(--mds-tint);
    pointer-events: none;
}

.vpl-tank--selected .vpl-tank__name { font-weight: 800; }

/* "+" insert buttons of the selected cell — real buttons, siblings of the cell button
   inside .vpl-cell, centered ON the joints (outside the cell, with a little air — Robert
   2026-07-07). z-index lifts them over the neighbor cells they overlap. */
.vpl-tank__insert {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--mds-accent-ink);
    color: var(--mds-tint);
    font-size: var(--mds-text-sm);
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    z-index: 3;
}

.vpl-tank__insert--left { left: -12px; }
.vpl-tank__insert--right { right: -12px; }

/* "+ Add row" at the stern (VS-7): a slim full-width dashed affordance below the last
   hull row — same visual family as the void band, clearly an invitation, not a cell. */
.vpl-addrow {
    flex: 1;
    min-height: 22px;
    border: 1px dashed var(--mds-line);
    border-radius: var(--mds-radius-sm);
    background: var(--mds-canvas);
    color: var(--mds-muted);
    font-family: var(--mds-font);
    font-size: var(--mds-text-xs);
    cursor: pointer;
}

.vpl-addrow:hover {
    color: var(--mds-title);
    border-color: var(--mds-accent);
}

/* Effective neighbors of the selected tank (server-computed adjacency): a quiet dashed
   hint, clearly subordinate to the selection. Same ::after technique. */
.vpl-tank--neighbor::after {
    content: "";
    position: absolute;
    inset: 2px;
    border: 1px dashed var(--mds-accent);
    border-radius: inherit;
    pointer-events: none;
}

/* ---- seamless composites (VS-8) ----------------------------------------- */

/* Member edges: the server marks the sides on which a cell directly touches another member
   of the SAME composite tank (TankDto.MemberEdgeXxx) — never derived client-side. On such
   a side the cell drops its border and the adjoining corner radii, so the members fuse
   into one shape (both cells of a seam drop their facing border — no doubled line). */
.vpl-tank--m-fore { border-top: none; border-top-left-radius: 0; border-top-right-radius: 0; }
.vpl-tank--m-aft { border-bottom: none; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.vpl-tank--m-port { border-left: none; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.vpl-tank--m-starboard { border-right: none; border-top-right-radius: 0; border-bottom-right-radius: 0; }

/* The wrapper's share of a horizontal seam: no joint margin between side-by-side members —
   the buttons meet exactly on the track edge (margins move, track sizes NEVER, so track
   edges stay exact weight fractions). */
.vpl-cell--m-port { margin-left: 0; }
.vpl-cell--m-starboard { margin-right: 0; }

/* A vertical seam (fore/aft member edge) crosses the hull rows' flex gap: bridge it with a
   connector strip on the UPPER cell's wrapper — full cell width, the coating tint, side
   borders continuing the cell's own. An approximation that is exact whenever the joined
   cells share their horizontal extent (the normal case); row gaps and grid mechanics stay
   untouched. */
.vpl-cell--m-aft::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: var(--mds-space-1); /* = .vpl-hull's row gap */
    background: var(--vpl-member-tint, var(--mds-tint));
    border-left: 1px solid var(--mds-line);
    border-right: 1px solid var(--mds-line);
    pointer-events: none;
}

/* The strip's tint — the wrapper can't inherit it from the button, so the view repeats the
   coating on the wrapper. Values mirror the .vpl-tank coating classes above. */
.vpl-cell--epoxy { --vpl-member-tint: var(--mds-tint); }
.vpl-cell--stainless { --vpl-member-tint: var(--mds-gray-100); }
.vpl-cell--zinc { --vpl-member-tint: color-mix(in srgb, var(--mds-warning) 10%, var(--mds-surface)); }

/* Ring overlays follow the same edges: suppress the ::after ring border per member edge
   (its radius already inherits the zeroed corners), so the selected/neighbor ring wraps
   the UNION outline instead of ringing every member cell. Order matters — these sit after
   the ring definitions. */
.vpl-tank--m-fore::after { border-top: none; }
.vpl-tank--m-aft::after { border-bottom: none; }
.vpl-tank--m-port::after { border-left: none; }
.vpl-tank--m-starboard::after { border-right: none; }

/* The selection's inset tint glow would paint a seam at suppressed edges — drop it on any
   member-edged cell (every member of a contiguous composite has one, so the whole union
   loses it uniformly; the 3px ring alone stays unmistakably dominant). */
.vpl-tank--selected:is(.vpl-tank--m-fore, .vpl-tank--m-aft, .vpl-tank--m-port, .vpl-tank--m-starboard)::after {
    box-shadow: none;
}

/* Carry the rings across the connector strip, so the union ring reads closed at a
   vertical seam. */
.vpl-cell--m-aft:has(> .vpl-tank--selected)::after {
    border-left: 3px solid var(--mds-accent-ink);
    border-right: 3px solid var(--mds-accent-ink);
}

.vpl-cell--m-aft:has(> .vpl-tank--neighbor)::after {
    border-left: 1px dashed var(--mds-accent);
    border-right: 1px dashed var(--mds-accent);
}

/* ---- tank side panel (VS-4) --------------------------------------------- */

.vpl-panel {
    margin-top: var(--mds-space-4);
}

.vpl-panel__close {
    margin-left: auto;
    font-size: var(--mds-text-lg);
    line-height: 1;
}

/* Panel content in side-by-side columns (facts · edit fields · cargo history) so the
   Tank tab stays about as tall as the Layout tab — no page-height jump on switch. */
.vpl-panel__body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--mds-space-4);
    align-items: start;
}

.vpl-panel__col {
    display: flex;
    flex-direction: column;
    gap: var(--mds-space-3);
    min-width: 0;
}

/* The small edit fields pair up two per line inside their column. */
.vpl-panel__fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--mds-space-2) var(--mds-space-3);
}

.vpl-panel__field {
    display: flex;
    flex-direction: column;
    gap: var(--mds-space-1);
    min-width: 0;
}

/* Save + delete/confirm-arm side by side under the edit fields. */
.vpl-panel__actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--mds-space-2);
}

/* Read-only placement/adjacency facts at the top of the panel. */
.vpl-panel__where {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: var(--mds-text-sm);
}

.vpl-panel__adj { display: block; }
.vpl-panel__adj b { font-weight: 600; }

.vpl-panel__label {
    font-size: var(--mds-text-xs);
    color: var(--mds-muted);
}

.vpl-panel__cargo {
    display: flex;
    flex-direction: column;
    gap: var(--mds-space-2);
}

.vpl-panel__heading {
    margin: 0;
    font-size: var(--mds-text-sm);
    font-weight: 600;
    color: var(--mds-title);
}

.vpl-panel__history td { font-size: var(--mds-text-sm); }

.vpl-panel__hint {
    font-size: var(--mds-text-xs);
    color: var(--mds-muted);
}

.vpl-panel__addcargo {
    display: flex;
    flex-wrap: wrap;
    gap: var(--mds-space-2);
    align-items: center;
}

/* ---- workspace: plan beside its controls when there is room --------------- */

.vpl-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 400px);
    gap: var(--mds-space-4);
    align-items: start;
}

.vpl-workspace__plan,
.vpl-workspace__aside { min-width: 0; }

@media (max-width: 1100px) {
    .vpl-workspace { grid-template-columns: minmax(0, 1fr); }
}

/* Disable-all wrapper for in-flight layout ops; layout-neutral. */
.vpl-fieldset { display: contents; border: 0; margin: 0; padding: 0; }

/* ---- tabbed detail region beside/under the plan (Layout | Tank) ----------- */

.vpl-tabs { padding: 0; margin-top: 0; }
.vpl-tabs .mds-tab:disabled { color: var(--mds-muted); opacity: .45; cursor: default; }

/* ---- row operations toolbar (VS-4) -------------------------------------- */

.vpl-rowops {
    margin-top: var(--mds-space-4);
}

.vpl-rowops__body {
    display: flex;
    flex-direction: column;
}

/* Table-like row list: rows follow each other directly, ONE hairline between them. */
.vpl-rowops__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--mds-space-3);
    padding: var(--mds-space-1-5) 0;
}

.vpl-rowops__row + .vpl-rowops__row { border-top: 1px solid var(--mds-line); }

.vpl-rowops__row--deck .vpl-rowops__label { color: var(--mds-muted); }

.vpl-rowops__label { font-size: var(--mds-text-sm); color: var(--mds-text); }

.vpl-rowops__actions {
    display: inline-flex;
    align-items: center;
    gap: var(--mds-space-2);
}

.vpl-rowops__addend { align-self: flex-start; margin-top: var(--mds-space-2); }

/* Destructive action — same red-outline shape as the account devices table. */
.vpl-danger { border-color: var(--mds-danger); color: var(--mds-danger); }

.vpl-fleet__actions { text-align: right; width: 88px; }

/* ---- quick setup ------------------------------------------------------- */

.vpl-setup {
    display: grid;
    gap: var(--mds-space-6);
    align-items: start;
    margin-top: var(--mds-space-4);
}

@media (min-width: 1024px) {
    .vpl-setup { grid-template-columns: 340px minmax(0, 1fr); }
}

.vpl-setup__form {
    display: flex;
    flex-direction: column;
    gap: var(--mds-space-3);
}

.vpl-setup__heading {
    margin: 0;
    font-size: var(--mds-text-lg);
    color: var(--mds-title);
}

.vpl-setup__intro {
    margin: 0;
    font-size: var(--mds-text-sm);
    color: var(--mds-muted);
}

.vpl-setup__hint {
    font-size: var(--mds-text-xs);
    color: var(--mds-danger);
}

.vpl-fieldrow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--mds-space-3);
}

.vpl-fieldrow--sub { padding-left: var(--mds-space-4); }

.vpl-fieldrow__label {
    font-size: var(--mds-text-sm);
    color: var(--mds-text);
}

.vpl-stepper {
    display: inline-flex;
    align-items: center;
    gap: var(--mds-space-2);
}

.vpl-stepper__btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--mds-line);
    border-radius: var(--mds-radius);
    background: var(--mds-surface);
    color: var(--mds-title);
    font-size: var(--mds-text-lg);
    line-height: 1;
    cursor: pointer;
}

.vpl-stepper__btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.vpl-stepper__val {
    min-width: 24px;
    text-align: center;
    font-weight: 600;
}

.vpl-naming__input { width: 100%; }

/* ---- shared form bits (create form + naming table) --------------------- */

.vpl-input {
    padding: var(--mds-space-1-5) var(--mds-space-2);
    border: 1px solid var(--mds-line);
    border-radius: var(--mds-radius);
    font-family: var(--mds-font);
    font-size: var(--mds-text-sm);
    color: var(--mds-text);
    background: var(--mds-surface);
}

.vpl-input:disabled {
    background: var(--mds-canvas);
    color: var(--mds-muted);
}

.vpl-input--invalid { border-color: var(--mds-danger); }

.vpl-create {
    display: flex;
    flex-direction: column;
    gap: var(--mds-space-2);
    padding: var(--mds-space-3);
    border: 1px solid var(--mds-line);
    border-radius: var(--mds-radius);
    background: var(--mds-canvas);
    margin-bottom: var(--mds-space-4);
}

.vpl-create__row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--mds-space-3);
}

.vpl-create__field {
    display: flex;
    flex-direction: column;
    gap: var(--mds-space-1);
}

.vpl-create__label {
    font-size: var(--mds-text-xs);
    color: var(--mds-muted);
}

.vpl-create__hint {
    font-size: var(--mds-text-xs);
    color: var(--mds-muted);
}
