/* Hotspot Monitor. The palette is the alert e-mail's (FireWatch AlertHtml), and the five band
   colours are the SP_Hotspot_01A ladder, so the site and the e-mails look like one product.
   There are no inline styles anywhere: the Content Security Policy is style-src 'self'. */

:root {
    --ink: #1f2421;
    --muted: #5f6b63;
    --line: #e2e7e3;
    --page: #f4f6f4;
    --card: #ffffff;
    --brand: #1b5e20;
    --brand-strong: #154a19;
    --brand-2: #2e7d32;
    --brand-muted: #c8e6c9;
    --brand-soft: #e8f5e9;

    --inside: #ff0000;  --inside-text: #c62828;  --inside-tint: #fdf3f2;
    --km2: #ffff00;     --km2-text: #7a6d00;     --km2-tint: #fffef0;
    --km5: #ffc000;     --km5-text: #9a6e00;     --km5-tint: #fffaf0;
    --km10: #0070c0;    --km10-text: #0059a0;    --km10-tint: #f1f7fc;
    --beyond: #afabab;  --beyond-text: #6b6767;  --beyond-tint: #f7f7f7;

    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 4px 16px rgba(16, 24, 20, .05);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html { font-size: 15px; }

body {
    font-family: var(--font);
    color: var(--ink);
    background: var(--page);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--brand-2); }
a:hover { color: var(--brand); }

.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 1rem; top: .5rem; z-index: 2000; background: #fff; padding: .5rem 1rem; border-radius: 6px; }

.muted { color: var(--muted); }
.small { font-size: .82rem; }

/* App bar ------------------------------------------------------------------------------------ */

.appbar {
    background: var(--brand);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 1100;
    box-shadow: 0 1px 0 rgba(0, 0, 0, .12);
}

.appbar-inner {
    max-width: 1600px;
    margin: 0 auto;
    padding: .55rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; min-width: 0; }
.brand:hover { color: #fff; }
.brand-mark { width: 26px; height: 26px; fill: var(--km5); flex: none; }
.brand-name { font-weight: 650; letter-spacing: .01em; white-space: nowrap; }
.brand-project {
    color: var(--brand-muted);
    font-size: .9rem;
    border-left: 1px solid rgba(255, 255, 255, .3);
    padding-left: .6rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.appbar-nav { margin-left: auto; display: flex; align-items: center; gap: .25rem; }
.appbar-link { color: #fff; text-decoration: none; padding: .35rem .7rem; border-radius: 6px; font-size: .92rem; }
.appbar-link:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.appbar-user {
    background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(255, 255, 255, .28);
    color: #fff;
    border-radius: 999px;
    padding: .28rem .8rem;
    font-size: .86rem;
    max-width: 16rem;
    overflow: hidden;
    text-overflow: ellipsis;
}
.appbar-user:hover, .appbar-user:focus { background: rgba(255, 255, 255, .18); }

/* Page ----------------------------------------------------------------------------------------- */

.page { width: 100%; max-width: 1200px; margin: 1.25rem auto 1.5rem; padding: 0 1.25rem; flex: 1; }
.page-wide { max-width: 1600px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.page-title { font-size: 1.35rem; font-weight: 650; margin: 0 0 .5rem; }
.site-foot { text-align: center; color: var(--muted); font-size: .8rem; padding: .75rem 1.25rem 1.5rem; }

.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
}
.panel.narrow { max-width: 640px; margin-left: auto; margin-right: auto; }
.panel-head { display: flex; align-items: baseline; gap: .75rem; margin-bottom: .6rem; flex-wrap: wrap; }
.panel-head h2 { font-size: 1rem; font-weight: 650; margin: 0; }

.btn-brand { background: var(--brand); border: 1px solid var(--brand); color: #fff; }
.btn-brand:hover, .btn-brand:focus { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }
.btn-outline-brand { border: 1px solid var(--brand); color: var(--brand); background: #fff; }
.btn-outline-brand:hover, .btn-outline-brand:focus { background: var(--brand-soft); color: var(--brand); }

/* Filters ---------------------------------------------------------------------------------------- */

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: .75rem 1rem;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: .85rem 1rem;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}
.field { display: flex; flex-direction: column; gap: .2rem; min-width: 8.5rem; margin: 0; }
.field-wide { min-width: 16rem; flex: 1 1 16rem; max-width: 26rem; }
.field-label { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.field-check { display: flex; align-items: center; gap: .45rem; font-size: .9rem; padding-bottom: .35rem; margin: 0; }
.field-check .form-check-input { margin: 0; }
.quick-ranges { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: .8rem; font-size: .85rem; }
.quick-ranges a { text-decoration: none; }
.quick-ranges a:hover { text-decoration: underline; }

/* Summary tiles ----------------------------------------------------------------------------------- */

.summary { display: grid; grid-template-columns: 1.5fr repeat(5, 1fr); gap: .75rem; margin-bottom: .75rem; }
.tile {
    background: var(--card);
    border: 1px solid var(--line);
    border-top: 4px solid var(--line);
    border-radius: var(--radius);
    padding: .75rem .95rem;
    box-shadow: var(--shadow);
}
.tile-value { font-size: 1.9rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-label { color: var(--muted); font-size: .85rem; margin-top: .15rem; }
.tile-sub { color: var(--muted); font-size: .78rem; margin-top: .35rem; }
.tile-total { border-top-color: var(--brand); }
.tile-inside { border-top-color: var(--inside); }
.tile-inside .tile-value { color: var(--inside-text); }
.tile-km2 { border-top-color: var(--km2); }
.tile-km2 .tile-value { color: var(--km2-text); }
.tile-km5 { border-top-color: var(--km5); }
.tile-km5 .tile-value { color: var(--km5-text); }
.tile-km10 { border-top-color: var(--km10); }
.tile-km10 .tile-value { color: var(--km10-text); }
.tile-beyond { border-top-color: var(--beyond); }
.tile-beyond .tile-value { color: var(--beyond-text); }

.gate-note { font-size: .9rem; color: var(--muted); margin: 0 0 1rem; }
.badge-alert {
    display: inline-block;
    background: var(--inside-tint);
    color: var(--inside-text);
    border: 1px solid #f3c7c3;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 650;
    padding: .06rem .5rem;
    margin: 0 .35rem;
    vertical-align: middle;
    letter-spacing: .02em;
}

/* Map and side panels ------------------------------------------------------------------------------ */

.layout { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(300px, 1fr); gap: 1rem; align-items: start; }
.map { height: 560px; border-radius: 8px; border: 1px solid var(--line); background: #dfe6e1; z-index: 0; }
.map-status { font-size: .85rem; color: var(--muted); min-height: 1.25rem; margin-top: .35rem; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .82rem; margin-top: .25rem; align-items: center; }
.legend-item { display: inline-flex; align-items: center; gap: .35rem; }
.legend-note { color: var(--muted); }
.swatch { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .35); display: inline-block; }
.swatch-inside { background: var(--inside); }
.swatch-km2 { background: var(--km2); }
.swatch-km5 { background: var(--km5); }
.swatch-km10 { background: var(--km10); }
.swatch-beyond { background: var(--beyond); }

.table-compact { font-size: .88rem; margin: 0; }
.table-compact th { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.text-inside { color: var(--inside-text); font-weight: 650; }
.text-km2 { color: var(--km2-text); font-weight: 650; }

.daily-chart { width: 100%; height: auto; display: block; }
.daily-chart .axis { stroke: #b9c2bc; stroke-width: 1; }
.daily-chart .grid { stroke: #e7ece8; stroke-width: 1; stroke-dasharray: 3 3; }
.daily-chart .tick { font-size: 9px; fill: var(--muted); font-family: var(--font); }
.daily-chart .bar { stroke: rgba(31, 36, 33, .22); stroke-width: .4; }
.daily-chart .bar-empty { fill: #d7ddd9; }

/* Hotspot list --------------------------------------------------------------------------------------- */

.hotspots { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: .7rem; }
.hotspot {
    border: 1px solid var(--line);
    border-left: 5px solid var(--beyond);
    border-radius: 8px;
    padding: .65rem .8rem .55rem;
    background: var(--beyond-tint);
}
.hotspot.band-inside { border-left-color: var(--inside); background: var(--inside-tint); }
.hotspot.band-km2 { border-left-color: var(--km2); background: var(--km2-tint); }
.hotspot.band-km5 { border-left-color: var(--km5); background: var(--km5-tint); }
.hotspot.band-km10 { border-left-color: var(--km10); background: var(--km10-tint); }
.hotspot-top { display: flex; justify-content: space-between; gap: .75rem; align-items: baseline; }
.hotspot-status { font-weight: 700; font-size: .8rem; letter-spacing: .02em; color: var(--beyond-text); white-space: nowrap; flex: none; }
.band-inside .hotspot-status, .band-inside.popup .popup-status { color: var(--inside-text); }
.band-km2 .hotspot-status, .band-km2.popup .popup-status { color: var(--km2-text); }
.band-km5 .hotspot-status, .band-km5.popup .popup-status { color: var(--km5-text); }
.band-km10 .hotspot-status, .band-km10.popup .popup-status { color: var(--km10-text); }
.hotspot-meta { font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; text-align: right; }
.nowrap { white-space: nowrap; }
.hotspot-headline { font-weight: 650; margin-top: .2rem; }
.hotspot-detail { font-size: .84rem; color: var(--muted); margin-top: .1rem; }
.link-button { background: none; border: 0; padding: 0; color: var(--brand-2); font-size: .82rem; margin-top: .3rem; cursor: pointer; }
.link-button:hover { text-decoration: underline; }
.empty { color: var(--muted); padding: 1rem 0; margin: 0; }
.list-more { margin: .75rem 0 0; }

/* Map popups and labels ---------------------------------------------------------------------------- */

.popup-status { font-weight: 700; font-size: .78rem; letter-spacing: .02em; color: var(--beyond-text); }
.popup-headline { font-weight: 650; margin: .15rem 0 .4rem; font-size: .95rem; }
.popup .badge-alert { margin: 0 0 .45rem; }
.popup-facts { display: grid; grid-template-columns: auto 1fr; gap: .15rem .6rem; margin: 0; font-size: .82rem; }
.popup-facts dt { color: var(--muted); font-weight: 500; }
.popup-facts dd { margin: 0; }
.leaflet-tooltip.company-label {
    background: rgba(27, 94, 32, .88);
    color: #fff;
    border: 0;
    box-shadow: none;
    font-weight: 650;
    font-size: .74rem;
    padding: .08rem .4rem;
}
.leaflet-tooltip.company-label::before { display: none; }

/* Sign-in ------------------------------------------------------------------------------------------ */

.auth-body { background: radial-gradient(circle at 20% 10%, #2e7d32 0%, #1b5e20 45%, #0f3d14 100%); }
.auth-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 14px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); padding: 1.75rem; }
.auth-brand { display: flex; gap: .8rem; align-items: center; margin-bottom: 1.25rem; }
.auth-mark { width: 42px; height: 42px; fill: var(--km5); background: var(--brand); border-radius: 10px; padding: 7px; flex: none; }
.auth-title { font-weight: 700; font-size: 1.2rem; }
.auth-sub { color: var(--muted); font-size: .85rem; }
.auth-form { display: grid; gap: .35rem; }
.auth-form .form-label { margin: .35rem 0 0; font-size: .88rem; font-weight: 600; }
.auth-form .btn { margin-top: .9rem; }
.auth-remember { display: flex; align-items: center; gap: .45rem; font-size: .88rem; margin-top: .5rem; }
.auth-remember .form-check-input { margin: 0; }
.form-errors {
    background: var(--inside-tint);
    border: 1px solid #f3c7c3;
    border-radius: 8px;
    color: var(--inside-text);
    font-size: .88rem;
    padding: .5rem .75rem;
    margin-bottom: .5rem;
}
.form-errors ul { margin: 0; padding-left: 1.1rem; }
.auth-foot { color: var(--muted); font-size: .8rem; margin: 1rem 0 0; }
.auth-body .site-foot { color: rgba(255, 255, 255, .75); }

/* Admin -------------------------------------------------------------------------------------------- */

.stack-form { display: grid; gap: .4rem; max-width: 520px; }
.stack-form .btn { justify-self: start; margin-top: .6rem; }
.stack-form .form-label { margin: .3rem 0 0; font-size: .88rem; font-weight: 600; }
.stack-fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .8rem .8rem; margin: .6rem 0; }
.stack-fieldset legend { font-size: .92rem; font-weight: 650; float: none; width: auto; padding: 0 .3rem; margin: 0; }
.grant-picker { display: grid; gap: .35rem; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.subhead { font-size: .95rem; font-weight: 650; margin: 1rem 0 .25rem; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: .25rem 1rem; font-size: .9rem; }
.facts dt { color: var(--muted); font-weight: 500; }
.facts dd { margin: 0; }
.button-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.pill { display: inline-block; border: 1px solid var(--line); background: #f7f9f7; border-radius: 999px; padding: .1rem .55rem; font-size: .78rem; margin: .1rem .2rem .1rem 0; }
.pill-admin { background: var(--brand-soft); border-color: #b9dcbb; color: var(--brand); font-weight: 600; }
.pill-ok { background: #edf7ee; border-color: #cfe8d1; color: #1e6b25; }
.pill-stale { background: var(--inside-tint); border-color: #f3c7c3; color: var(--inside-text); }
.status-code { font-size: 3rem; font-weight: 800; color: var(--brand-muted); margin: 0; line-height: 1; }

/* Responsive and print ------------------------------------------------------------------------------ */

@media (max-width: 1100px) {
    .summary { grid-template-columns: repeat(3, 1fr); }
    .layout, .admin-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .summary { grid-template-columns: repeat(2, 1fr); }
    .map { height: 420px; }
    .brand-name, .appbar-link-home { display: none; }
    .brand-project { border-left: 0; padding-left: 0; max-width: 34vw; }
    .appbar-user { max-width: 44vw; }
    .appbar-inner { padding: .5rem .75rem; }
    .page { padding: 0 .75rem; }
    .field, .field-wide { min-width: calc(50% - .5rem); }
}

@media print {
    .appbar, .filters, .link-button, .site-foot { display: none; }
    .panel, .tile { box-shadow: none; }
}
