/* The source an row came from is the thing you look for first on every page, so it always looks
   the same: MTR blue, portal amber. */
.source-mtr { --source-colour: #0d6efd; }
.source-portal { --source-colour: #fd7e14; }

.badge-source {
    background: var(--source-colour);
    color: #fff;
}

.source-border { border-left: 4px solid var(--source-colour); }

.table-compact td,
.table-compact th {
    padding: .35rem .5rem;
    font-size: .875rem;
    vertical-align: middle;
}

/* The yard: one tile per area, laid out by sector, within one application.
   The two applications share only the place; inside it each keeps its own rows, so tiles are
   never merged and a tile always belongs to exactly one of them. */
.sector-row {
    display: grid;
    grid-template-columns: 4.5rem 1fr;
    gap: .5rem;
    align-items: start;
    padding: .3rem 0;
    border-top: 1px solid #f1f3f5;
}

.sector-row:first-child { border-top: 0; }

.sector-head {
    display: flex;
    justify-content: space-between;
    gap: .25rem;
    font-size: .8125rem;
    padding-top: .3rem;
}

.block-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
}

.block {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-width: 3.8rem;
    height: 2.6rem;
    padding: .1rem .3rem .15rem;
    border: 1px solid #dee2e6;
    border-radius: .25rem;
    background: #fff;
    color: #495057;
    font-size: .7rem;
    font-weight: 600;
    text-decoration: none;
    overflow: hidden;
}

a.block:hover { border-color: #212529; color: #212529; }

/* How full the area is, rising from the bottom of the tile. Relative to the fullest area in the
   same place: an area holds dozens of cars and the range in a name like "B1-9" is not a capacity,
   so there is no absolute scale to draw against. */
.block-fill {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--source-colour, #6c757d);
    opacity: .22;
}

.block.is-occupied .block-fill { opacity: .35; }

.block-name,
.block-count {
    position: relative;
    line-height: 1.1;
    white-space: nowrap;
}

.block-count {
    position: absolute;
    top: .2rem;
    right: .3rem;
    font-size: .6rem;
    font-weight: 700;
    color: var(--source-colour, #6c757d);
}

/* ---- Places ---------------------------------------------------------------------------------- */

.place-thumb {
    position: relative;
    display: block;
    height: 150px;
    overflow: hidden;
    background: #e9ecef;
}

.place-thumb img { width: 100%; height: 100%; object-fit: cover; }

.place-thumb-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .25rem;
    height: 100%;
    color: #adb5bd;
    font-size: 1.5rem;
}

.place-thumb-empty .small { font-size: .75rem; }

/* How full the place is, over its picture. */
.place-badge {
    position: absolute;
    right: .5rem;
    bottom: .5rem;
    padding: .1rem .45rem;
    border-radius: .25rem;
    background: rgba(33, 37, 41, .82);
    color: #fff;
    font-size: .75rem;
    font-weight: 600;
}

.place-card:hover .place-thumb img { transform: scale(1.03); transition: transform .2s; }

.legend-chip {
    display: inline-block;
    width: .9rem;
    height: .9rem;
    border: 1px solid #dee2e6;
    border-radius: .2rem;
    background: #fff;
    vertical-align: -2px;
}

.legend-chip.is-occupied { background: #f8f9fa; border-color: #adb5bd; box-shadow: inset 0 .25rem 0 #0d6efd; }

.stat-tile {
    border-left: 4px solid var(--source-colour, #6c757d);
}

.stat-tile .value {
    font-size: 1.75rem;
    font-weight: 600;
    line-height: 1.1;
}

.stale {
    color: #dc3545;
    font-weight: 600;
}

/* ---- Yard maps ------------------------------------------------------------------------------ */

/* The image sets the height through a padding ratio, so markers sit correctly before it loads. */
.map-canvas {
    position: relative;
    width: 100%;
    height: 0;
    overflow: hidden;
    background: #e9ecef;
}

.map-canvas > img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    user-select: none;
}

.map-canvas.is-editing { cursor: crosshair; }

.map-spot {
    position: absolute;
    transform: translate(-50%, -50%);
    min-width: 1.6rem;
    height: 1.6rem;
    padding: 0 .3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: .3rem;
    border: 2px solid #fff;
    background: rgba(108, 117, 125, .85);
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .45);
    white-space: nowrap;
}

.map-spot.occupied { background: var(--source-colour); }
.map-spot.is-selected { outline: 3px solid #212529; z-index: 3; }
.map-spot:hover { z-index: 4; transform: translate(-50%, -50%) scale(1.25); }
.map-canvas.is-editing .map-spot { cursor: grab; touch-action: none; }

.map-legend {
    display: inline-block;
    width: .9rem;
    height: .9rem;
    border-radius: .2rem;
    border: 2px solid #fff;
    background: rgba(108, 117, 125, .85);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
    vertical-align: -2px;
}

.map-legend.occupied { background: var(--source-colour); }

.map-thumb {
    display: block;
    height: 150px;
    overflow: hidden;
    background: #e9ecef;
}

.map-thumb img { width: 100%; height: 100%; object-fit: cover; }

.map-spot-list { max-height: 60vh; overflow-y: auto; }

.map-list-heading {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #6c757d;
    margin: .5rem 0 .25rem;
}

.map-list-group { display: flex; flex-wrap: wrap; gap: .2rem; }

.map-list-spot {
    min-width: 2.4rem;
    padding: .15rem .3rem;
    border-radius: .25rem;
    border: 1px solid var(--source-colour, #dee2e6);
    background: #fff;
    color: var(--source-colour, #495057);
    font-size: .7rem;
    font-weight: 600;
}

.map-list-spot.is-placed { opacity: .45; }
.map-list-spot.is-selected { background: var(--source-colour); color: #fff; }

/* ---- Overview -------------------------------------------------------------------------------- */

/* One strip for the whole yard, split by the application that owns the taken spots. What is left
   over is free, so free space needs no colour of its own. */
.occupancy-bar {
    display: flex;
    height: .5rem;
    border-radius: .25rem;
    overflow: hidden;
    background: #e9ecef;
}

.occupancy-bar > span { background: var(--source-colour, #6c757d); }

.legend-dot {
    display: inline-block;
    width: .5rem;
    height: .5rem;
    border-radius: 50%;
    background: var(--source-colour, #6c757d);
    vertical-align: 1px;
}

/* A label, a bar and a number on one line. Used for status, partner and location counts, which are
   all "how does this one compare with the biggest" questions rather than exact readings. */
.bar-row {
    display: grid;
    grid-template-columns: minmax(0, 8rem) 1fr auto;
    align-items: center;
    gap: .5rem;
    padding: .2rem 0;
    font-size: .8125rem;
    color: inherit;
    text-decoration: none;
}

.bar-row:hover { background: #f8f9fa; }
.bar-row:hover .bar-fill { filter: brightness(.9); }

.bar-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #495057;
}

.bar-track {
    height: .75rem;
    border-radius: .25rem;
    background: #e9ecef;
    overflow: hidden;
}

.bar-fill {
    display: block;
    height: 100%;
    border-radius: .25rem;
    background: var(--source-colour, #6c757d);
    /* A bar for a count of one next to a bar for a count of nine thousand is otherwise invisible. */
    min-width: 2px;
}

.bar-fill.is-full { background: #dc3545; }

.bar-value {
    font-variant-numeric: tabular-nums;
    color: #212529;
    font-weight: 600;
}


/* How full a placed area is, rising inside its marker — the same measure as on the place page,
   drawn against the fullest area on this plan. */
.map-spot { overflow: hidden; }

.map-spot-fill {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    opacity: .3;
    pointer-events: none;
}

.map-spot-label { position: relative; }
