/* GOWASH – julkinen ja admin-tyylit */
:root {
    --green: #2e9e44;
    --gray: #9aa0a6;
    --yellow: #f2b705;
    --yellow-soft: #fff6da; /* vaalea keltainen, vain admin-puolen pill-buttonille/labelille */
    --bg: #0f1b2d;
    --card: #ffffff;
    --ink: #1a1a1a;
    --muted: #6b7280;
    --line: #e5e7eb;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--ink);
    background: #f4f6f9;
    line-height: 1.5;
}

.wrap { max-width: 1000px; margin: 0 auto; padding: 0 16px; }

.site-header {
    background: var(--bg);
    color: #fff;
    padding: 28px 0;
}
.site-header h1 { margin: 0; letter-spacing: 2px; }
.tagline { margin: 4px 0 0; color: #b9c4d4; }

main.wrap { padding-top: 24px; padding-bottom: 40px; }

/* Liikennevalot */
.dot {
    display: inline-block;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--gray);
    vertical-align: middle;
}
.dot--green { background: var(--green); box-shadow: 0 0 0 3px rgba(46,158,68,.18); }
.dot--gray { background: var(--gray); }
.dot--yellow { background: var(--yellow); box-shadow: 0 0 0 3px rgba(242,183,5,.18); }

.legend { color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.legend .dot { margin-left: 12px; }
.legend .dot:first-child { margin-left: 0; }

.locations {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 16px;
}
.location-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 18px 18px 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.location-card h2 { margin: 0 0 2px; font-size: 1.15rem; }
.address { margin: 0 0 12px; color: var(--muted); font-size: .9rem; }

/* Kortin otsikkorivi: silmä otsikon vieressä, kamera oikeassa yläkulmassa */
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.card-head h2 { margin: 0 0 2px; }
.eye, .cam {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    border-radius: 6px;
    line-height: 0;
}
/* Silmä heti otsikkotekstin oikealla puolella, pystysuunnassa keskitettynä */
.card-head h2 .eye { vertical-align: middle; margin-left: 6px; padding: 2px; }
/* Kamera kortin oikeassa yläkulmassa */
.cam { flex: none; padding: 4px; margin-top: -2px; }
.eye:hover, .cam:hover { background: #f0f2f5; color: var(--ink); }
.eye:focus-visible, .cam:focus-visible { outline: 2px solid var(--bg); outline-offset: 1px; }

/* Piilotetut-palkki */
.hidden-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}
.hidden-bar-label { color: var(--muted); font-size: .85rem; margin-right: 2px; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 5px 12px 5px 10px;
    cursor: pointer;
    font: inherit;
    font-size: .85rem;
    color: var(--muted);
}
.chip:hover { color: var(--ink); border-color: #cbd2da; }
.chip svg { flex: none; }
.chip:focus-visible { outline: 2px solid var(--bg); outline-offset: 1px; }

/* Pieni ilmoitus (esim. viimeistä ei voi piilottaa) */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    background: #1a1a1a;
    color: #fff;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: .9rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s, transform .25s;
    z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.lines { list-style: none; margin: 0; padding: 0; }
.line {
    display: grid;
    grid-template-columns: 18px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-top: 1px solid var(--line);
}
.line:first-child { border-top: none; }
.line-name { font-weight: 600; }
.badge {
    display: inline-block; font-size: .7rem; font-weight: 700;
    background: #eef2ff; color: #3730a3; border-radius: 6px; padding: 1px 6px; margin-left: 4px;
}
.badge--frost { background: #e0f0ff; color: #0b5cad; }
.line-status { font-size: .85rem; font-weight: 700; }
.status--green { color: var(--green); }
.status--gray { color: var(--gray); }
.status--yellow { color: #a87c00; }
.reason { grid-column: 2 / -1; font-size: .82rem; color: var(--muted); }

.empty { color: var(--muted); }

.site-footer { border-top: 1px solid var(--line); padding: 16px 0; background: #fff; }
.site-footer .wrap { display: flex; justify-content: space-between; align-items: center; }
.site-footer a { color: var(--bg); }
.updated { color: var(--muted); font-size: .82rem; }

/* ---- Admin ---- */
.admin-header { background: var(--bg); color: #fff; padding: 14px 0; }
.admin-header .wrap { display: flex; justify-content: space-between; align-items: center; }
.admin-header a { color: #cdd7e5; margin-left: 16px; text-decoration: none; }
.admin-header a:hover { color: #fff; }
.admin-nav { margin: 16px 0; display: flex; gap: 8px; flex-wrap: wrap; }
.admin-nav a {
    padding: 8px 14px; border-radius: 8px; background: #fff; border: 1px solid var(--line);
    text-decoration: none; color: var(--ink);
}
.admin-nav a.active { background: var(--bg); color: #fff; border-color: var(--bg); }
.frost-notice { padding: 6px 12px; border-radius: 8px; background: #e0f0ff; color: #0b5cad; font-size: .85rem; font-weight: 600; align-self: center; }

.panel {
    background: #fff; border: 1px solid var(--line); border-radius: 12px;
    padding: 20px; margin-bottom: 20px;
}
.panel h2 { margin-top: 0; }

.panel-title-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.panel-title-row h2 { margin: 0; }
.status-flag {
    font-weight: 700; font-size: 1.1rem; color: #000;
    display: inline-block; padding: 10px 20px; margin: 15px; border-radius: 999px;
}
.status-flag--warn {
    background: var(--yellow-soft);
    animation: status-flag-glow 2.5s ease-in-out infinite;
}
@keyframes status-flag-glow {
    0%, 100% { box-shadow: 0 0 0 rgba(255, 246, 218, 0); }
    50% { box-shadow: 0 0 14px 4px rgba(255, 246, 218, .9); }
}
@media (prefers-reduced-motion: reduce) {
    .status-flag--warn { animation: none; }
}

/* Tilannekuvan toimipistepaneelit: kapealla näytöllä "toggle" (checkbox-hack, ei JS:ää)
   pitkän sisällön lyhentämiseksi. Työpöydällä (>640px) tämä lohko ei koske taulukon
   display-ominaisuuteen mitenkään, joten työpöytänäkymä pysyy täysin ennallaan. */
.loc-summary h2 { display: inline; }
.loc-toggle { position: absolute; opacity: 0; width: 1px; height: 1px; overflow: hidden; }

@media (max-width: 640px) {
    .loc-panel > table.grid { display: none; margin-top: 14px; }
    .loc-toggle:checked ~ table.grid { display: block; }
    /* Laajenna klikkausalue koko paneelin kokoiseksi (negatiivinen margin kumoaa
       .panelin oman paddingin, jotta koko kortti on kosketettavissa auki/kiinni). */
    .loc-summary {
        cursor: pointer;
        display: block;
        margin: -20px -20px 0;
        padding: 20px;
    }
    .loc-summary--alert {
        background: var(--yellow-soft);
        border-radius: 12px;
    }
}

/* Työpöydällä otsikko ei saa näyttää klikattavalta - taulukkoon ei kosketa lainkaan. */
@media (min-width: 641px) {
    .loc-summary { cursor: default; pointer-events: none; }
}

table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.grid th { color: var(--muted); font-weight: 600; font-size: .85rem; }

/* Kapealla näytöllä taulukko pinotaan kortti-riveiksi, jotta esim. Hallinta-sarakkeen
   painikkeet mahtuvat näkyviin rivittyneenä sen sijaan että jäisivät piiloon. */
@media (max-width: 640px) {
    table.grid thead { display: none; }
    table.grid, table.grid tbody, table.grid tr, table.grid td { display: block; width: 100%; }
    table.grid tr {
        border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin-bottom: 10px;
    }
    table.grid td {
        border-bottom: none; padding: 6px 0;
        display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px;
    }
    table.grid td[data-label]::before {
        content: attr(data-label); flex-basis: 100%;
        font-weight: 600; font-size: .78rem; color: var(--muted);
    }
}

label { display: block; font-weight: 600; margin: 10px 0 4px; }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=number], select {
    width: 100%; max-width: 360px; padding: 8px 10px; border: 1px solid var(--line);
    border-radius: 8px; font: inherit;
}
.btn {
    display: inline-block; padding: 8px 16px; border-radius: 8px; border: none;
    background: var(--bg); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn--danger { background: #b3261e; }
.btn--ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn--sm { padding: 5px 10px; font-size: .85rem; }
form.inline { display: inline; }

/* Tilannekuvan hallintapainikkeet: näytä rivin tilan mukaan (admin-status.js vaihtaa data-statusin) */
.ctl-cancel, .ctl-set, .ctl-reason { display: none; }
tr[data-status="disruption"] .ctl-cancel { display: inline-flex; align-items: center; }
tr[data-status="disruption"] .ctl-reason { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
tr:not([data-status="disruption"]) .ctl-set { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.flash { background: #e7f6ec; border: 1px solid #b6e2c4; color: #1d6b34; padding: 10px 14px; border-radius: 8px; margin: 12px 0; }
.error { background: #fde8e8; border: 1px solid #f5c2c2; color: #9b1c1c; padding: 10px 14px; border-radius: 8px; margin: 12px 0; }

.login-box { max-width: 360px; margin: 60px auto; }

.pill { display:inline-block; padding:2px 8px; border-radius:999px; font-size:.78rem; font-weight:700; }
.pill--green { background:#e7f6ec; color:#1d6b34; }
.pill--gray { background:#eef0f3; color:#5f6368; }
.pill--yellow { background:#fff6da; color:#8a6400; }
.pill--blue { background:#e0f0ff; color:#0b5cad; }

.small-text {
    font-size: 14px;
}

.session-stats {
    font-size: 0.8rem;
    color: var(--muted);
    margin: 4px 0 0;
}