/* Shared by the Dashboard and Diagnostic views. */
:root {
    font: 15px/1.45 "Segoe UI", Tahoma, sans-serif;
    color: #203744;
    background: #f1f5f8;
    --navy: #18354a;
    --blue: #205777;
    --muted: #536a78;
    --line: #d6e0e6;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--blue); }
h1, h2, h3, p, dl, dd { margin: 0; }
h1, h2, h3 { color: var(--navy); line-height: 1.25; }
h1 { font-size: 30px; letter-spacing: -.7px; }
h2 { font-size: 19px; }
h3 { font-size: 17px; }
.wrap { width: min(100% - 56px, 1510px); margin-inline: auto; }
.masthead { position: relative; background: var(--navy); color: white; border-bottom: 4px solid #6a9ab6; }
.mast-inner::after {
    content: "";
    order: 1;
    flex: 0 0 152px;
    height: 48px;
    margin-inline-start: auto;
    background: url("../images/athena-logo-full.png") no-repeat left center / auto 100%;
    filter: brightness(0) invert(1);
    pointer-events: none;
}
.masthead .mast-inner { position: relative; }
.mast-inner, .page-heading, .section-heading, .actions, .filter-actions, footer {
    display: flex; align-items: center; gap: 12px;
}
.mast-inner { min-height: 108px; gap: 23px; }
.brand { display: grid; place-items: center; flex: none; width: 184px; height: 80px; padding: 6px; background: white; border-radius: 6px; }
.brand img { display: block; width: 100%; height: 100%; object-fit: contain; object-position: center; min-width: 0; min-height: 0; }
.identity { display: grid; gap: 2px; }
.identity span { font-size: 13px; color: #d6e5ee; }
.identity strong { font-size: 25px; letter-spacing: -.4px; }
summary { font-weight: 600; cursor: pointer; }
.portal-shell { display: flex; max-width: 1640px; margin-inline: auto; min-height: calc(100vh - 190px); }
.portal-content { flex: 1; min-width: 0; padding: 28px; }
.portal-nav { flex: 0 0 212px; background: white; border-right: 1px solid var(--line); }
.portal-links { padding: 26px 12px; position: sticky; top: 0; max-height: 100vh; overflow-y: auto; }
.nav-signature { display: grid; justify-items: center; gap: 6px; padding: 14px 6px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; text-align: center; overflow-wrap: anywhere; }
.nav-signature img { width: 150px; max-width: 100%; height: 50px; object-fit: contain; }
@media (min-width: 761px) {
    body:has(.portal-nav) .mast-inner {
        width: min(100%, 1640px);
        padding-inline: 14px 28px;
    }
    body:has(.portal-nav) .mast-inner .brand { margin-right: 19px; }
    .portal-links { display: flex; flex-direction: column; min-height: calc(100dvh - 112px); padding-bottom: 16px; }
    .portal-links > * { flex: none; }
    .nav-signature { margin-top: auto; }
    .portal-links > :nth-last-child(2) { margin-bottom: 20px; }
}
.portal-links h2 { padding: 5px 12px 10px; font-size: 13px; color: var(--muted); }
.portal-links h2:not(:first-child) { margin-top: 20px; }
.portal-links a, .portal-links summary { display: block; border-radius: 4px; padding: 10px 12px; color: var(--navy); text-decoration: none; }
.portal-links > a { font-weight: 600; }
.portal-links summary { display: list-item; }
.portal-links details a { margin-left: 15px; font-size: 14px; }
.portal-links a:hover, .portal-links summary:hover { background: #edf5fa; }
.portal-links a[aria-current] { background: #e6eef4; box-shadow: inset 3px 0 var(--blue); font-weight: 600; }
.phone-nav { display: none; }
.menu { position: relative; }
.account { order: 2; flex: none; }
.menu > summary { display: flex; align-items: center; gap: 10px; padding: 9px 12px; }
summary::marker { color: var(--blue); }
.menu summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: ""; border: solid currentColor; border-width: 0 1.5px 1.5px 0; padding: 3px; transform: rotate(45deg); margin-top: -3px; }
.account summary { border: 1px solid #83a0b3; border-radius: 4px; }
.menu > div { position: absolute; right: 0; top: 100%; z-index: 3; width: 230px; max-height: 55vh; overflow: auto; background: white; color: var(--navy); border: 1px solid var(--line); border-radius: 4px; padding: 5px; box-shadow: 0 6px 18px #18354a20; }
.menu a, .menu button { display: block; text-decoration: none; padding: 8px 10px; }
.menu a:hover { background: #edf5fa; }
.page-heading, .section-heading { justify-content: space-between; }
.page-heading { margin-bottom: 22px; }
.section-heading { margin-bottom: 12px; }
.section-heading > span, .updated, footer { font-size: 13px; color: var(--muted); }
button, input, select { font: inherit; color: inherit; }
button, .action { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 8px 15px; border: 1px solid #adbdc8; background: white; color: var(--blue); border-radius: 4px; text-decoration: none; font-weight: 600; cursor: pointer; }
button:hover, .action:hover { background: #e5edf3; }
.primary { color: white; background: var(--blue); border-color: var(--blue); }
.primary:hover { background: var(--navy); }
:focus-visible { outline: 3px solid #d99b20; outline-offset: 2px; }
.surface { background: white; border: 1px solid var(--line); border-radius: 5px; }
.subdivision-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 480px), 1fr)); gap: 16px; }
.subdivision h3 a { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; text-decoration: none; background: #e6eef4; border-radius: 4px 4px 0 0; }
.subdivision h3 a:hover { text-decoration: underline; }
.subdivision h3 span { font-size: 22px; line-height: 1; }
.monitor-grid { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 17px 0; }
.monitor-grid > div { padding: 0 13px; }
.monitor-grid > div + div { border-left: 1px solid var(--line); }
dt { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.state { display: flex; align-items: baseline; gap: 7px; font-size: 15px; font-weight: 600; color: var(--navy); }
.state::before { content: ""; flex: 0 0 8px; height: 8px; background: var(--signal, #768994); border-radius: 50%; }
.ok { --signal: #35715c; }
.warn { --signal: #b27719; }
.danger { --signal: #a33248; }
.info { --signal: #326f94; }
.updated { margin-top: 17px; }
.empty { padding: 20px; }
.filter-panel { margin-bottom: 18px; }
.filter-panel summary, .surface .section-heading { padding: 15px 18px; font-size: 17px; color: var(--navy); }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; padding: 0 18px; }
.filters label { display: grid; align-content: start; gap: 5px; font-size: 13px; font-weight: 600; }
[hidden] { display: none !important; }
.filters input, select { min-width: 0; width: 100%; height: 40px; border: 1px solid #acbdc9; border-radius: 4px; background: white; padding: 6px 9px; font-size: 14px; font-weight: 400; }
.filter-actions { flex-wrap: wrap; padding: 16px 18px; }
input[type=checkbox] { accent-color: var(--blue); }
#errMsg:not(:empty) { padding: 0 18px 12px; color: #882338; }
.results-grid { display: grid; grid-template-columns: minmax(200px, 245px) minmax(0, 1fr); align-items: start; gap: 16px; }
.surface .section-heading { margin: 0; background: #e6eef4; border-radius: 4px 4px 0 0; }
.surface .section-heading h2 { font-size: 16px; }
.sites .record-body { padding: 14px; font-size: 13px; line-height: 1.7; display: grid; gap: 8px; max-height: 500px; overflow-y: auto; }
.site-picker summary { padding: 15px 18px; background: #e6eef4; border-radius: 4px; color: var(--navy); }
.sites label { display: flex; align-items: baseline; gap: 6px; }
.sites .site-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.sites .site-actions button { padding-inline: 10px; }
.table-scroll { overflow: auto; }
.table-scroll table { border-collapse: collapse; width: 100%; }
.readings { font-size: 13px; font-variant-numeric: tabular-nums; }
.readings th, .readings td { padding: 10px; border-bottom: 1px solid var(--line); }
.readings th { background: #f5f8fa; color: var(--muted); font-weight: 600; }
.readings td { white-space: nowrap; }
.records, #chart-container { min-width: 0; }
#chart-container table { table-layout: fixed; }
footer { border-top: 1px solid var(--line); padding: 16px 0 24px; }
footer img { max-width: 85px; max-height: 38px; object-fit: contain; }
#loadingIco { visibility: hidden; position: fixed; left: calc(50% - 18px) !important; top: calc(50% - 18px) !important; z-index: 4; width: 36px; height: 36px; border-radius: 100%; border: 4px solid #d6e5ee; border-top-color: var(--blue); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 760px) {
    .mast-inner::after { flex-basis: 25px; height: 32px; }
    .mast-inner .identity { min-width: 0; overflow-wrap: anywhere; }
    .wrap { width: calc(100% - 32px); }
    .portal-shell { display: block; min-height: 0; }
    .portal-content { padding: 20px 16px; }
    .portal-nav { position: relative; border-right: 0; border-bottom: 1px solid var(--line); }
    .phone-nav { display: flex; align-items: center; gap: 18px; padding: 0 16px; }
    .phone-nav a { padding: 13px 0 10px; font-weight: 600; text-decoration: none; border-bottom: 3px solid transparent; }
    .phone-nav a[aria-current] { border-color: var(--blue); }
    .phone-nav button { margin-left: auto; border: 0; }
    .phone-nav button::after { content: ""; width: 6px; height: 6px; margin: -3px 0 0 8px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
    .portal-links { display: none; position: absolute; right: 12px; top: 100%; z-index: 3; width: min(280px, 92vw); max-height: 60vh; padding: 10px; background: white; border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 6px 18px #18354a20; }
    .portal-nav:has(button[aria-expanded="true"]) .portal-links { display: block; }
    .nav-signature { margin-top: 12px; padding-bottom: 4px; }
    .mast-inner { min-height: 84px; gap: 8px; }
    .brand { width: 84px; height: 56px; padding: 4px; }
    .identity strong { font-size: 20px; }
    .identity span { font-size: 12px; }
    .menu summary { padding-inline: 8px; }
    h1 { font-size: 25px; }
    .page-heading { flex-wrap: wrap; margin-bottom: 16px; }
    .results-grid { grid-template-columns: minmax(0, 1fr); }
    .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sites .record-body { max-height: 190px !important; }
    .monitor-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-flow: row; padding: 0; }
    .monitor-grid > div { padding: 12px 14px; }
    .monitor-grid > div:nth-child(odd) { border-left: 0; }
    .monitor-grid > div:nth-child(n+3) { border-top: 1px solid var(--line); }
    .section-heading { flex-wrap: wrap; }
}

/* Show independent rail alarms even when the map's combined icon prioritizes rail break. */
.site-rail-indicator { display: block; width: fit-content; margin-top: .3rem; padding: .15rem .4rem; border: 1px solid #cbd7df; border-radius: 4px; font-size: 12px; font-weight: 600; color: #405767; background: #f0f5f8; }
.site-rail-indicator[data-state="active"][data-kind="rail-break"] { color: #9d1515; background: #fce9e9; border-color: #e7bcbc; }
.site-rail-indicator[data-state="active"][data-kind="train-presence"] { color: #1251a3; background: #e8f1fd; border-color: #b7cfea; }
.site-rail-indicator[data-state="inactive"] { color: #226137; background: #edf7ef; border-color: #c3ddca; }
