/* ── Full-screen layout ──────────────────────────────────────── */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ── Header ──────────────────────────────────────────────────── */
#page-header {
    background: var(--c-primary);
    color: #fff;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 0 0 auto;
}

#header-row1 {
    display: flex;
    align-items: center;
    gap: 8px;
}

#header-row2 {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

#back-btn {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 1.4rem;
    line-height: 1;
    flex: 0 0 auto;
}
#back-btn:hover { color: #fff; }

#page-title {
    font-size: var(--fs-base);
    font-weight: 700;
    flex: 1;
}

#road-select {
    padding: 4px 8px;
    border-radius: 6px;
    border: none;
    font-size: var(--fs-sm);
    background: rgba(255,255,255,0.92);
    color: var(--c-text);
    cursor: pointer;
    flex: 0 0 auto;
}

#dir-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    flex: 0 0 auto;
}

.dir-btn {
    padding: 4px 10px;
    border: 1.5px solid rgba(255,255,255,0.55);
    border-radius: 6px;
    background: transparent;
    color: #fff;
    cursor: pointer;
    font-size: var(--fs-sm);
    line-height: 1.4;
}

.dir-btn.active {
    background: rgba(255,255,255,0.22);
    border-color: #fff;
    font-weight: 600;
}

#locate-btn {
    padding: 4px 9px;
    border: 1.5px solid rgba(255,255,255,0.55);
    border-radius: 6px;
    background: transparent;
    color: #fff;
    cursor: pointer;
    font-size: var(--fs-base);
    line-height: 1;
    flex: 0 0 auto;
}
#locate-btn:active { background: rgba(255,255,255,0.18); }

#table-link {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    font-size: var(--fs-sm);
    font-weight: 600;
    border: 1.5px solid rgba(255,255,255,0.45);
    border-radius: 6px;
    padding: 4px 9px;
    line-height: 1.4;
    flex: 0 0 auto;
    white-space: nowrap;
}
#table-link:hover { color: #fff; border-color: #fff; }

#refresh-btn {
    padding: 4px 9px;
    border: 1.5px solid rgba(255,255,255,0.55);
    border-radius: 6px;
    background: transparent;
    color: #fff;
    cursor: pointer;
    font-size: var(--fs-base);
    line-height: 1;
    flex: 0 0 auto;
}
#refresh-btn:active { background: rgba(255,255,255,0.18); }

@keyframes fw-spin { to { transform: rotate(360deg); } }
#refresh-btn.loading { animation: fw-spin 0.75s linear infinite; opacity: 0.65; }

#countdown {
    font-size: var(--fs-xs);
    color: rgba(255,255,255,0.75);
    flex: 0 0 auto;
}

/* ── Status overlay ──────────────────────────────────────────── */
#status {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    background: rgba(255,255,255,0.92);
    padding: 10px 18px;
    border-radius: 8px;
    font-size: var(--fs-sm);
    color: var(--c-muted);
    pointer-events: none;
    display: none;
}
#status:not(:empty) { display: block; }

/* ── Map ─────────────────────────────────────────────────────── */
#map-wrap {
    flex: 1;
    position: relative;
    min-height: 0;
}

#map {
    width: 100%;
    height: 100%;
}

/* ── Legend ──────────────────────────────────────────────────── */
.map-legend {
    background: rgba(255,255,255,0.92);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.72rem;
    line-height: 1.8;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.map-legend .lg-row {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.map-legend .lg-line {
    display: inline-block;
    width: 22px;
    height: 4px;
    border-radius: 2px;
    flex: 0 0 auto;
}

/* ── CCTV camera marker ──────────────────────────────────────── */
.map-cctv-icon {
    font-size: 16px;
    line-height: 22px;
    text-align: center;
    cursor: pointer;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}

.cctv-popup { font-size: 0.8rem; line-height: 1.6; }
.cctv-popup a { color: var(--c-primary-dk, #15803d); }

/* ── CMS marker ──────────────────────────────────────────────── */
.map-cms-icon {
    font-size: 16px;
    line-height: 22px;
    text-align: center;
    cursor: pointer;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.4));
}

.cms-popup { font-size: 0.8rem; line-height: 1.6; min-width: 120px; }
.cms-popup strong { display: block; margin-bottom: 3px; }
.cms-msg { padding: 2px 0; }
.cms-msg.cms-empty { color: var(--c-muted, #64748b); font-style: italic; }

/* ── VD tap popup ────────────────────────────────────────────── */
.vd-popup { font-size: 0.8rem; line-height: 1.6; min-width: 110px; }
.vd-popup strong { display: block; }

.vd-lanes {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 5px;
}

.map-chip {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 600;
    min-width: 28px;
    text-align: center;
}
