/* Electronic Traffic Counts - road-sign family shared with Manual Traffic Counts.
   Green = direction-sign green (valid / primary), red = error, amber = warning. */
:root {
    --sign-green: #00703c;
    --sign-green-dark: #00552d;
    --sign-white: #ffffff;
    --tar: #2b302d;
    --ink: #1f2522;
    --ink-soft: #56605a;
    --line: #d5d9d6;
    --page: #f2f3f1;
    --panel: #ffffff;
    --bad: #b8322a;
    --bad-bg: #fbecea;
    --warn: #8a5a00;
    --warn-bg: #fff4d6;
    --ok-bg: #e7f3ec;
    --focus: #1a5fb4;
    --radius: 6px;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
    font-family: "IBM Plex Sans", "Segoe UI", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--page);
}

/* ------------------------------------------------------------------ header: a direction sign */

.sign-header {
    background: var(--tar);
    padding: 14px 24px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 24px;
}

a.sign-plate { text-decoration: none; }
a.sign-plate:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }

/* ------------------------------------------------------------------ signed-in user */

.user-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 18px;
    color: #e6e9e7;
    font-size: 14px;
}

.user-bar .user-name { font-weight: 600; color: #fff; }
.user-bar a { color: #e6e9e7; }
.user-bar a:hover { color: #fff; }
.logout-form { margin: 0; }

.user-bar button {
    font: inherit;
    padding: 5px 12px;
    border: 1px solid #8d968f;
    border-radius: 4px;
    background: transparent;
    color: #fff;
    cursor: pointer;
}

.user-bar button:hover { background: rgba(255, 255, 255, 0.1); }
.user-bar a:focus-visible, .user-bar button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

.sign-plate {
    display: inline-flex;
    flex-direction: column;
    background: var(--sign-green);
    color: var(--sign-white);
    border: 3px solid var(--sign-white);
    outline: 3px solid var(--sign-green);
    border-radius: 8px;
    padding: 6px 18px 8px;
}

.sign-title {
    font-family: Oswald, "Arial Narrow", sans-serif;
    font-weight: 600;
    font-size: 26px;
    line-height: 1.15;
}

.sign-sub { font-size: 14px; opacity: 0.9; }

/* ------------------------------------------------------------------ layout */

.layout {
    display: grid;
    grid-template-columns: minmax(360px, 520px) 1fr;
    gap: 20px;
    padding: 20px 24px 40px;
    align-items: start;
}

.steps { display: flex; flex-direction: column; gap: 16px; }

.step {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px 18px;
}

.step h2 {
    font-family: Oswald, "Arial Narrow", sans-serif;
    font-weight: 500;
    font-size: 20px;
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.step-no {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--sign-green);
    color: var(--sign-white);
    font-size: 15px;
}

.hint { color: var(--ink-soft); margin: 8px 0 0; font-size: 14px; }
.step h2 + .hint { margin: 0 0 12px; }

/* ------------------------------------------------------------------ fields */

.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 14px;
}

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

.field label { font-weight: 500; font-size: 14px; }

.field input,
.field select {
    font: inherit;
    padding: 7px 9px;
    border: 1px solid #b9bfbb;
    border-radius: 4px;
    background: #fff;
    color: var(--ink);
    width: 100%;
}

.field input.missing { border: 2px solid #d99a00; background: var(--warn-bg); }

.field-note { color: var(--ink-soft); font-size: 13px; }
.field-note.bad { color: var(--bad); font-weight: 500; }

input:focus-visible,
select:focus-visible,
button:focus-visible,
.file-pick input:focus-visible + .file-pick-btn {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

/* ------------------------------------------------------------------ file pickers */

.file-pick {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    cursor: pointer;
}

.file-pick input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.file-pick-btn {
    flex: none;
    padding: 7px 14px;
    border: 2px solid var(--sign-green);
    border-radius: 4px;
    color: var(--sign-green-dark);
    font-weight: 600;
    background: #fff;
}

.file-pick:hover .file-pick-btn { background: var(--ok-bg); }

.file-pick-name {
    color: var(--ink-soft);
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ------------------------------------------------------------------ save */

.checklist { list-style: none; margin: 0 0 14px; padding: 0; columns: 2; column-gap: 16px; font-size: 14px; }
.checklist li { padding-left: 22px; position: relative; margin-bottom: 4px; break-inside: avoid; }
.checklist li::before { content: ""; position: absolute; left: 0; top: 4px; width: 12px; height: 12px; border-radius: 50%; border: 2px solid #9aa39e; }
.checklist li.done::before { background: var(--sign-green); border-color: var(--sign-green); }
.checklist li.todo { color: var(--ink-soft); }

.btn-save {
    font: inherit;
    font-weight: 600;
    font-size: 16px;
    width: 100%;
    padding: 11px;
    border: 0;
    border-radius: 4px;
    background: var(--sign-green);
    color: var(--sign-white);
    cursor: pointer;
}

.btn-save:hover:not(:disabled) { background: var(--sign-green-dark); }
.btn-save:disabled { background: #a8b0ab; cursor: not-allowed; }

.result { margin-top: 14px; padding: 12px 14px; border-radius: 4px; font-size: 14px; }
.result p { margin: 0 0 6px; font-weight: 600; }
.result ul { margin: 0; padding-left: 18px; }
.result.ok { background: var(--ok-bg); border-left: 4px solid var(--sign-green); }
.result.bad { background: var(--bad-bg); border-left: 4px solid var(--bad); }
.result .warnings { margin-top: 8px; }
.result li.warn { color: var(--warn); }

.btn-again {
    font: inherit;
    margin-top: 12px;
    padding: 6px 12px;
    border: 2px solid var(--sign-green);
    border-radius: 4px;
    background: #fff;
    color: var(--sign-green-dark);
    font-weight: 600;
    cursor: pointer;
}

/* ------------------------------------------------------------------ map + road plate */

.map-panel {
    position: sticky;
    top: 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

#map { height: calc(100vh - 290px); min-height: 380px; }

.road-readout {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 14px 22px;
    padding: 14px 18px;
    border-top: 1px solid var(--line);
}

/* The road number as a route plate: green when the sheet matches the map, red when it doesn't. */
.road-plate {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 132px;
    padding: 6px 14px 8px;
    border-radius: 8px;
    border: 3px solid var(--sign-white);
    outline: 3px solid #9aa39e;
    background: #9aa39e;
    color: var(--sign-white);
    transition: background-color 0.2s, outline-color 0.2s;
}

.road-plate.ok { background: var(--sign-green); outline-color: var(--sign-green); }
.road-plate.bad { background: var(--bad); outline-color: var(--bad); }
.road-plate.checking { opacity: 0.7; }

.road-plate-no { font-family: Oswald, "Arial Narrow", sans-serif; font-weight: 600; font-size: 30px; line-height: 1.1; }
.road-plate-km { font-size: 13px; }

.road-facts { display: flex; gap: 22px; margin: 4px 0 0; }
.road-facts dt { font-size: 13px; color: var(--ink-soft); }
.road-facts dd { margin: 0; font-weight: 600; }

.road-errors { flex-basis: 100%; list-style: none; margin: 0; padding: 0; }
.road-errors li { color: var(--bad); font-weight: 500; padding: 2px 0; }

/* ------------------------------------------------------------------ sign-in pages */

.auth-page { display: flex; justify-content: center; padding: 48px 16px; }

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px 26px 22px;
}

.auth-card h1 {
    font-family: Oswald, "Arial Narrow", sans-serif;
    font-weight: 500;
    font-size: 24px;
    margin: 0 0 14px;
}

.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card .hint { margin-top: 16px; }

.form-error, .form-ok {
    margin: 0 0 14px;
    padding: 10px 12px;
    border-radius: 4px;
    font-size: 14px;
}

.form-error { background: var(--bad-bg); border-left: 4px solid var(--bad); color: #7a1f19; }
.form-ok { background: var(--ok-bg); border-left: 4px solid var(--sign-green); }

/* ------------------------------------------------------------------ users page */

.users-page { max-width: 1100px; margin: 0 auto; padding: 20px 24px 40px; display: flex; flex-direction: column; gap: 16px; }
.users-page > .form-ok, .users-page > .form-error { margin: 0; }

.table-wrap { overflow-x: auto; }

.users-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.users-table th { text-align: left; font-weight: 600; padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
.users-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.users-table tr.inactive td { color: var(--ink-soft); }

.inline-form { display: flex; gap: 6px; margin: 0; }
.inline-form input { font: inherit; padding: 5px 8px; border: 1px solid #b9bfbb; border-radius: 4px; min-width: 140px; }

.btn-small {
    font: inherit;
    font-weight: 600;
    padding: 5px 12px;
    border: 2px solid var(--sign-green);
    border-radius: 4px;
    background: #fff;
    color: var(--sign-green-dark);
    cursor: pointer;
    white-space: nowrap;
}

.btn-small:hover { background: var(--ok-bg); }
.btn-small.btn-danger { border-color: var(--bad); color: var(--bad); }
.btn-small.btn-danger:hover { background: var(--bad-bg); }

.check { display: flex; align-items: center; gap: 8px; margin: 14px 0; font-size: 14px; }
.btn-save.btn-inline { width: auto; padding: 9px 22px; }

/* ------------------------------------------------------------------ road search on the map */

.map-search {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    max-width: 360px;
    padding: 8px;
    background: var(--panel);
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    font: 14px "IBM Plex Sans", "Segoe UI", Arial, sans-serif;
}

.map-search input {
    flex: 1 1 170px;
    min-width: 0;
    font: inherit;
    padding: 6px 8px;
    border: 1px solid #b9bfbb;
    border-radius: 4px;
}

.map-search button {
    font: inherit;
    font-weight: 600;
    padding: 6px 12px;
    border: 0;
    border-radius: 4px;
    background: var(--sign-green);
    color: var(--sign-white);
    cursor: pointer;
}

.map-search button:hover { background: var(--sign-green-dark); }

.map-search .map-search-clear {
    padding: 4px 10px;
    background: #fff;
    color: var(--ink-soft);
    border: 1px solid #b9bfbb;
    font-size: 18px;
    line-height: 1;
}

.map-search .map-search-clear:hover { background: var(--page); }

.map-search-status { flex-basis: 100%; color: var(--ink-soft); font-size: 13px; }
.map-search-status:empty { display: none; }

.segment-popup { font: 14px "IBM Plex Sans", "Segoe UI", Arial, sans-serif; }
.segment-popup button {
    margin-top: 8px;
    font: inherit;
    font-weight: 600;
    padding: 5px 10px;
    border: 0;
    border-radius: 4px;
    background: var(--sign-green);
    color: var(--sign-white);
    cursor: pointer;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ------------------------------------------------------------------ small screens */

@media (max-width: 960px) {
    .layout { grid-template-columns: 1fr; padding: 14px; }
    .map-panel { position: static; order: -1; }
    #map { height: 360px; }
}

@media (max-width: 480px) {
    .grid { grid-template-columns: 1fr; }
    .checklist { columns: 1; }
    .sign-title { font-size: 21px; }
}

@media (prefers-reduced-motion: reduce) {
    .road-plate { transition: none; }
}
