/* =========================================================================
   Honeywell Monitor — dashboard styles, v2
   Direction: "modern editorial with Nauvoo heritage". Bricolage Grotesque
   + Instrument Serif + JetBrains Mono. High-contrast, generous spacing,
   soft-rounded cards. Mobile-first.
   ========================================================================= */

:root {
    /* Surfaces */
    --bg:            #fbfaf6;           /* warm near-white */
    --surface:       #ffffff;
    --surface-2:     #f4f1e9;           /* inset, subtle warmth */
    --rule:          #e7e2d5;
    --rule-strong:   #d3cbb5;
    --ink:           #0d0d0c;           /* near-black */
    --ink-2:         #3d3b34;
    --ink-faint:     #6f6c61;

    /* Status — modernised, higher saturation, pairs light + darker tone */
    --heat:          #d64d16;
    --heat-tint:     #fbe4d6;
    --cool:          #0f67b5;
    --cool-tint:     #dceaf7;
    --fan:           #0f8a61;
    --fan-tint:      #d8efe3;
    --idle:          #5e5d55;
    --idle-tint:     #ecebe5;
    --offline:       #c41e1e;
    --offline-tint:  #f8d9d5;

    /* Brand — Nauvoo gold kept for logo/accents */
    --gold:          #b8925c;
    --gold-soft:     #e7d4b2;

    /* Motion + shape */
    --ease:          cubic-bezier(.22, .8, .26, 1);
    --radius-xs:     6px;
    --radius-sm:     10px;
    --radius-md:     14px;
    --radius-lg:     22px;
    --shadow-sm:     0 1px 2px rgba(14, 13, 12, 0.04), 0 1px 3px rgba(14, 13, 12, 0.06);
    --shadow-md:     0 4px 12px rgba(14, 13, 12, 0.06), 0 2px 4px rgba(14, 13, 12, 0.04);

    /* Spacing */
    --gutter:        16px;
    --stack:         18px;
}

@media (min-width: 768px) {
    :root { --gutter: 24px; --stack: 24px; }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    font-optical-sizing: auto;
    font-variation-settings: "opsz" 14, "wght" 420, "wdth" 100;
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
@media (min-width: 1024px) { html, body { font-size: 17px; } }

a {
    color: var(--ink);
    text-decoration: none;
    border-bottom: 1.5px solid var(--rule-strong);
    transition: border-color 140ms var(--ease);
}
a:hover { border-color: var(--ink); }

h1, h2, h3, h4 {
    font-family: "Instrument Serif", ui-serif, Georgia, serif;
    font-weight: 400;
    letter-spacing: -0.01em;
    color: var(--ink);
    margin: 0 0 0.3em;
    line-height: 1.15;
}
h1 { font-size: clamp(2rem, 4vw, 2.75rem); }
h2 { font-size: clamp(1.35rem, 2.5vw, 1.6rem); }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; font-weight: 500; font-family: "Bricolage Grotesque", sans-serif; letter-spacing: normal; }

p  { margin: 0.25em 0 0.5em; }

small {
    color: var(--ink-faint);
    font-size: 0.875rem;
}

button, .button {
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    padding: 11px 18px;
    background: var(--ink);
    color: var(--bg);
    border: 1px solid var(--ink);
    border-radius: 999px;
    cursor: pointer;
    min-height: 44px;
    transition: transform 120ms var(--ease), box-shadow 120ms var(--ease), background 120ms var(--ease);
    box-shadow: var(--shadow-sm);
}
button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow-md); }
button:active:not(:disabled) { transform: translateY(0); }
button:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

input[type="email"],
input[type="password"],
input[type="text"],
input[type="search"] {
    width: 100%;
    padding: 12px 14px;
    font-family: inherit;
    font-size: 1rem;
    background: var(--surface);
    color: var(--ink);
    border: 1.5px solid var(--rule);
    border-radius: var(--radius-sm);
    min-height: 46px;
    transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease);
}
input:focus {
    outline: none;
    border-color: var(--ink);
    box-shadow: 0 0 0 4px rgba(13, 13, 12, 0.06);
}

label {
    display: block;
    margin: 14px 0 6px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--ink-2);
}

hr {
    border: none;
    border-top: 1px solid var(--rule);
    margin: 24px 0;
}

pre {
    font-family: "JetBrains Mono", ui-monospace, monospace;
    font-size: 0.82rem;
    background: var(--surface-2);
    border: 1px solid var(--rule);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    overflow-x: auto;
    max-height: 280px;
}

/* ------------------------------------------------------------------ */
/* Shell + topbar                                                       */
/* ------------------------------------------------------------------ */

.shell { max-width: 1180px; margin: 0 auto; padding: 0 var(--gutter); }

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: color-mix(in oklab, var(--bg) 88%, transparent);
    -webkit-backdrop-filter: saturate(1.3) blur(8px);
    backdrop-filter: saturate(1.3) blur(8px);
    border-bottom: 1px solid var(--rule);
}
.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 0;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border: none;
    color: var(--ink);
}
.brand-logo {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    color: var(--ink);
}
.brand-mark {
    font-family: "Instrument Serif", serif;
    font-size: 1.35rem;
    font-weight: 400;
    letter-spacing: -0.01em;
    color: var(--ink);
    line-height: 1;
}
.brand-sub {
    display: none;
    font-size: 0.72rem;
    color: var(--ink-faint);
    letter-spacing: 0.01em;
    padding-left: 8px;
    border-left: 1px solid var(--rule-strong);
    margin-left: 2px;
}
@media (min-width: 720px) { .brand-sub { display: inline; } }

.topnav {
    display: flex;
    gap: 2px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.topnav::-webkit-scrollbar { display: none; }
.topnav a {
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--ink-2);
    padding: 8px 12px;
    border: none;
    white-space: nowrap;
    border-radius: 999px;
    transition: background 120ms var(--ease), color 120ms var(--ease);
}
.topnav a:hover { color: var(--ink); background: var(--surface-2); }
.topnav a[aria-current="page"] { color: var(--ink); background: var(--surface); box-shadow: var(--shadow-sm); }

main { padding: 28px 0 96px; }

.page-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin: 4px 0 24px;
}
.page-head .eyebrow {
    font-size: 0.85rem;
    color: var(--ink-faint);
    margin-bottom: 4px;
}
.breadcrumb {
    font-size: 0.95rem;
    color: var(--ink-faint);
    margin-bottom: 10px;
}
.breadcrumb a { border: none; color: var(--ink-2); }
.breadcrumb a:hover { color: var(--ink); text-decoration: underline; }
.breadcrumb-sep { margin: 0 8px; color: var(--rule-strong); }

/* Fade-in body on first paint (no layout thrash, just atmosphere). */
main { animation: pageFade 300ms var(--ease) both; }
@keyframes pageFade {
    from { opacity: 0; transform: translateY(3px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ------------------------------------------------------------------ */
/* Status strip                                                         */
/* ------------------------------------------------------------------ */

.status-strip {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 0 0 24px;
}
@media (min-width: 560px) { .status-strip { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .status-strip { grid-template-columns: repeat(6, 1fr); } }

.status-cell {
    position: relative;
    padding: 16px 18px 14px;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.status-cell::before {
    content: "";
    position: absolute;
    top: 12px; left: 18px;
    width: 10px; height: 10px;
    border-radius: 999px;
    background: var(--ink);
    box-shadow: 0 0 0 4px color-mix(in oklab, currentColor 14%, transparent);
}
.status-cell.total   { color: var(--ink); }
.status-cell.heat    { color: var(--heat); }
.status-cell.cool    { color: var(--cool); }
.status-cell.fan     { color: var(--fan); }
.status-cell.idle    { color: var(--idle); }
.status-cell.offline { color: var(--offline); }
.status-cell.heat::before    { background: var(--heat); }
.status-cell.cool::before    { background: var(--cool); }
.status-cell.fan::before     { background: var(--fan); }
.status-cell.idle::before    { background: var(--idle); }
.status-cell.offline::before { background: var(--offline); }

.status-cell .label {
    margin-top: 18px;
    font-size: 0.88rem;
    color: var(--ink-2);
}
.status-cell .value {
    font-family: "JetBrains Mono", monospace;
    font-size: clamp(1.75rem, 3.5vw, 2.1rem);
    font-weight: 500;
    color: var(--ink);
    line-height: 1.05;
    margin-top: 4px;
    font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------------ */
/* Filter + location rows                                               */
/* ------------------------------------------------------------------ */

.filter-row { display: flex; gap: 8px; margin: 0 0 14px; }
.filter-row input { max-width: 420px; border-radius: 999px; padding-left: 18px; }

.location-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.location-row {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: box-shadow 160ms var(--ease), border-color 160ms var(--ease);
}
.location-row[open] {
    box-shadow: var(--shadow-md);
    border-color: var(--rule-strong);
}

.location-row > summary {
    list-style: none;
    cursor: pointer;
    padding: 18px 18px;
    display: grid;
    grid-template-columns: 24px 1fr auto;
    column-gap: 12px;
    align-items: start;
    min-height: 72px;
    transition: background 120ms var(--ease);
}
@media (min-width: 640px) {
    .location-row > summary { padding: 20px 22px; align-items: center; column-gap: 16px; }
}
.location-row > summary::-webkit-details-marker { display: none; }
.location-row > summary:hover { background: var(--surface-2); }

.loc-chevron {
    width: 20px; height: 20px;
    color: var(--ink-faint);
    transition: transform 200ms var(--ease), color 140ms var(--ease);
    flex-shrink: 0;
}
.location-row[open] .loc-chevron { transform: rotate(90deg); color: var(--ink); }

.loc-meta { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.loc-name {
    font-family: "Instrument Serif", serif;
    font-size: 1.3rem;
    letter-spacing: -0.01em;
    color: var(--ink);
    line-height: 1.12;
    overflow-wrap: anywhere;
    word-break: normal;
}
@media (min-width: 640px) {
    .loc-name { font-size: 1.45rem; }
}
.loc-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--ink-faint);
    font-variant-numeric: tabular-nums;
}
.loc-summary .chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 11px;
    border-radius: 999px;
    font-weight: 500;
    background: var(--surface-2);
    color: var(--ink-2);
    min-height: 26px;
    font-size: 0.85rem;
}
.loc-summary .chip .dot {
    width: 6px; height: 6px; border-radius: 999px;
}
.loc-summary .chip.offline { background: var(--offline-tint); color: var(--offline); }
.loc-summary .chip.heat    { background: var(--heat-tint);    color: var(--heat); }
.loc-summary .chip.cool    { background: var(--cool-tint);    color: var(--cool); }
.loc-summary .chip.fan     { background: var(--fan-tint);     color: var(--fan); }
.loc-summary .chip.offline .dot { background: var(--offline); }
.loc-summary .chip.heat .dot    { background: var(--heat); }
.loc-summary .chip.cool .dot    { background: var(--cool); }
.loc-summary .chip.fan .dot     { background: var(--fan); }

.loc-count {
    font-family: "JetBrains Mono", monospace;
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    white-space: nowrap;
    padding-top: 2px;
}
.loc-count strong { font-weight: 500; font-size: 1.05rem; }
.loc-count small {
    font-size: 0.7rem;
    color: var(--ink-faint);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.loc-chevron { margin-top: 3px; }
@media (min-width: 640px) {
    .loc-chevron { margin-top: 0; }
    .loc-count { flex-direction: row; align-items: baseline; gap: 6px; padding-top: 0; }
    .loc-count small { text-transform: none; font-size: 0.78rem; }
}

.therm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    padding: 6px 14px 18px;
    animation: fadeUp 260ms var(--ease) both;
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}
@media (min-width: 640px) { .therm-grid { padding: 6px 20px 20px; } }

.therm-card {
    display: block;
    padding: 14px 14px 12px;
    border: 1px solid var(--rule);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--ink);
    text-decoration: none;
    position: relative;
    min-height: 110px;
    transition: transform 140ms var(--ease), box-shadow 140ms var(--ease), border-color 140ms var(--ease);
    box-shadow: var(--shadow-sm);
}
.therm-card::after {
    content: "";
    position: absolute;
    top: 14px; right: 14px;
    width: 8px; height: 8px;
    border-radius: 999px;
    background: var(--idle);
    box-shadow: 0 0 0 3px color-mix(in oklab, currentColor 18%, transparent);
}
.therm-card.heat    { color: var(--heat); }
.therm-card.heat::after    { background: var(--heat); }
.therm-card.cool    { color: var(--cool); }
.therm-card.cool::after    { background: var(--cool); }
.therm-card.fan     { color: var(--fan); }
.therm-card.fan::after     { background: var(--fan); }
.therm-card.offline { color: var(--offline); background: var(--offline-tint); border-color: var(--offline); }
.therm-card.offline::after { background: var(--offline); }

.therm-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--rule-strong); }

.therm-card .tname {
    font-family: "Bricolage Grotesque", sans-serif;
    font-weight: 500;
    font-size: 0.88rem;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border: none;
    max-width: calc(100% - 20px);
}
.therm-card .ttemp {
    font-family: "JetBrains Mono", monospace;
    font-size: 2rem;
    font-weight: 500;
    line-height: 1.1;
    margin: 8px 0 4px;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}
.therm-card .ttemp .deg { font-size: 0.95rem; opacity: 0.55; margin-left: 2px; }

.therm-card .trow {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    font-family: "JetBrains Mono", monospace;
    font-size: 0.82rem;
    color: var(--ink-2);
    font-variant-numeric: tabular-nums;
}
.therm-card .tstatus {
    font-family: "Bricolage Grotesque", sans-serif;
    font-size: 0.72rem;
    font-weight: 500;
    color: currentColor;
    text-transform: capitalize;
    letter-spacing: 0.01em;
}
.therm-card .tupdated {
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--ink-faint);
}

/* ------------------------------------------------------------------ */
/* Detail page                                                          */
/* ------------------------------------------------------------------ */

.current-reading {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 22px 24px;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin: 14px 0 24px;
    position: relative;
    overflow: hidden;
}
.current-reading::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--idle);
}
.current-reading.heat::before    { background: var(--heat); }
.current-reading.cool::before    { background: var(--cool); }
.current-reading.fan::before     { background: var(--fan); }
.current-reading.offline::before { background: var(--offline); }
.current-reading.heat    { background: linear-gradient(135deg, var(--heat-tint), var(--surface) 65%); }
.current-reading.cool    { background: linear-gradient(135deg, var(--cool-tint), var(--surface) 65%); }
.current-reading.fan     { background: linear-gradient(135deg, var(--fan-tint),  var(--surface) 65%); }
.current-reading.offline { background: linear-gradient(135deg, var(--offline-tint), var(--surface) 65%); }

.current-reading .huge {
    font-family: "JetBrains Mono", monospace;
    font-size: clamp(3rem, 8vw, 4.2rem);
    line-height: 1;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    color: var(--ink);
}
.current-reading .huge .deg { font-size: 0.4em; opacity: 0.55; margin-left: 4px; }

.current-reading .meta {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 16px;
    row-gap: 6px;
    align-items: baseline;
    font-size: 0.95rem;
    color: var(--ink-2);
    font-variant-numeric: tabular-nums;
}
.current-reading .meta .label {
    color: var(--ink-faint);
    font-size: 0.85rem;
    font-family: "Bricolage Grotesque", sans-serif;
}

@media (min-width: 640px) { .current-reading { grid-template-columns: auto 1fr; align-items: center; gap: 28px; } }

.range-selector {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
    margin: 16px 0 14px;
}
.range-btn {
    padding: 7px 14px;
    background: transparent;
    color: var(--ink-2);
    border: none;
    border-radius: 999px;
    min-height: 36px;
    font-size: 0.88rem;
    box-shadow: none;
}
.range-btn:hover:not(.active) { background: var(--surface-2); color: var(--ink); transform: none; }
.range-btn.active {
    background: var(--ink);
    color: var(--bg);
}

.chart-stack {
    display: grid;
    gap: 14px;
    grid-template-columns: 1fr;
}
@media (min-width: 900px) { .chart-stack { grid-template-columns: 1fr 1fr; gap: 18px; } }

.chart-panel {
    margin: 0;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.chart-panel > figcaption {
    padding: 14px 18px 8px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--ink-2);
    border-bottom: 1px solid var(--rule);
    background: var(--surface-2);
}
.chart-wrap {
    position: relative;
    height: 260px;
    padding: 12px;
}
@media (min-width: 900px) { .chart-wrap { height: 300px; } }

/* ------------------------------------------------------------------ */
/* Tables                                                               */
/* ------------------------------------------------------------------ */

figure {
    margin: 0 0 14px;
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}
thead th {
    text-align: left;
    font-weight: 500;
    font-size: 0.82rem;
    color: var(--ink-faint);
    background: var(--surface-2);
    padding: 12px 16px;
    border-bottom: 1px solid var(--rule);
}
tbody td {
    padding: 12px 16px;
    border-top: 1px solid var(--rule);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
tbody tr:first-child td { border-top: none; }
tbody tr:hover td { background: var(--surface-2); }

tbody tr.status-offline td { background: var(--offline-tint); }
tbody tr.status-offline:hover td { background: color-mix(in oklab, var(--offline-tint) 82%, var(--surface)); }

.run-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--ink-2);
}
.run-badge::before {
    content: "";
    width: 6px; height: 6px; border-radius: 999px;
    background: currentColor;
    display: inline-block;
}
.run-badge-success { color: var(--fan); }
.run-badge-partial { color: var(--heat); }
.run-badge-failed  { color: var(--offline); }
.run-badge-running { color: var(--cool); }

/* ------------------------------------------------------------------ */
/* Progress panel                                                       */
/* ------------------------------------------------------------------ */

.progress-panel {
    background: linear-gradient(135deg, var(--cool-tint), var(--surface) 70%);
    border: 1px solid var(--rule);
    border-left: 4px solid var(--cool);
    border-radius: var(--radius-md);
    padding: 18px 22px;
    margin: 12px 0 24px;
    box-shadow: var(--shadow-sm);
}
.progress-panel header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-weight: 500;
    color: var(--ink-2);
    font-size: 0.92rem;
}
.progress-panel progress {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    margin: 12px 0 8px;
    border: none;
    background: var(--rule);
    border-radius: 99px;
    overflow: hidden;
}
.progress-panel progress::-webkit-progress-bar  { background: var(--rule); border-radius: 99px; }
.progress-panel progress::-webkit-progress-value { background: var(--cool); border-radius: 99px; transition: width 300ms var(--ease); }
.progress-panel progress::-moz-progress-bar     { background: var(--cool); }
.progress-panel .current {
    font-family: "Instrument Serif", serif;
    font-size: 1.45rem;
    letter-spacing: -0.01em;
    color: var(--ink);
    line-height: 1.2;
}
.progress-panel .counts {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.92rem;
    color: var(--ink-2);
    font-variant-numeric: tabular-nums;
}
.progress-percent { float: right; color: var(--cool); font-weight: 500; }

/* ------------------------------------------------------------------ */
/* Cards, flashes, auth                                                 */
/* ------------------------------------------------------------------ */

.card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 22px 24px;
    margin: 0 0 18px;
}
.card h2 { margin-top: 0; }

.flash {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid currentColor;
    font-size: 0.95rem;
    margin: 10px 0;
    background: var(--surface);
}
.flash-success { color: var(--fan);     background: var(--fan-tint); }
.flash-error   { color: var(--offline); background: var(--offline-tint); }

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px var(--gutter);
    background:
        radial-gradient(60% 80% at 50% 0%, color-mix(in oklab, var(--gold-soft) 30%, transparent), transparent 70%),
        var(--bg);
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-md);
}
.auth-card .eyebrow {
    font-size: 0.82rem;
    color: var(--gold);
    font-weight: 500;
    margin-bottom: 4px;
}
.auth-card h1 {
    font-size: 2rem;
    margin: 0 0 20px;
}
.auth-card button { width: 100%; }

/* ------------------------------------------------------------------ */
/* Sparklines + print                                                   */
/* ------------------------------------------------------------------ */

canvas.sparkline { display: block; background: var(--surface); }

/* ------------------------------------------------------------------ */
/* Identifiers card (thermostat detail)                                 */
/* ------------------------------------------------------------------ */

.identifiers-card { padding: 18px 20px; }
.identifiers-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}
@media (min-width: 600px) {
    .identifiers-grid { grid-template-columns: 1fr 1fr; gap: 18px; }
}
.ident-field { margin: 0; }
.ident-field > span {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--ink-2);
    margin: 0 0 6px;
}
.ident-field input {
    font-family: "JetBrains Mono", ui-monospace, monospace;
    letter-spacing: 0.02em;
}
.ident-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 14px;
}
.ident-actions code {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.85em;
    background: var(--surface-2);
    padding: 1px 6px;
    border-radius: 4px;
    color: var(--ink);
}

/* ------------------------------------------------------------------ */
/* Route — companion stop (a 2nd filter at the same address)            */
/* ------------------------------------------------------------------ */

.route-stop-companion {
    background: linear-gradient(90deg, color-mix(in oklab, var(--gold-soft) 22%, transparent), transparent 60%);
}
.route-stop-companion .stop-num {
    color: var(--gold);
    font-weight: 500;
}
.companion-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--gold-soft);
    color: #6b4f2a;
    margin-left: 4px;
}

/* ------------------------------------------------------------------ */
/* Address line + filter card (thermostat detail page)                  */
/* ------------------------------------------------------------------ */

.address {
    color: var(--ink-2);
    font-size: 0.95rem;
    margin: 4px 0 6px;
    letter-spacing: 0.01em;
}

.filter-card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--rule-strong);
}
.filter-card.filter-ok        { border-left-color: var(--fan); }
.filter-card.filter-amber     { border-left-color: #c08a1e; background: #fdf6e7; }
.filter-card.filter-overdue   { border-left-color: var(--offline); background: var(--offline-tint); }
.filter-card.filter-never     { border-left-color: var(--idle); }
.filter-card.filter-none      { border-left-color: var(--rule-strong); color: var(--ink-faint); }

.filter-card-head {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 16px; flex-wrap: wrap;
}
.filter-name {
    font-family: "Instrument Serif", serif;
    font-size: 1.4rem;
    margin-bottom: 4px;
}
.filter-meta {
    display: flex; gap: 18px; flex-wrap: wrap;
    font-size: 0.92rem; color: var(--ink-2);
}
.filter-meta strong { color: var(--ink); font-weight: 500; }
.filter-notes {
    margin: 10px 0 0;
    font-size: 0.92rem;
    color: var(--ink-2);
    font-style: italic;
}
.filter-action {
    margin-top: 14px;
    display: flex; gap: 14px; align-items: center;
}
.filter-action small { color: var(--ink-faint); font-size: 0.88rem; }

.filter-status-pill {
    display: inline-flex; align-items: center;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.82rem; font-weight: 500;
    letter-spacing: 0.02em;
    background: var(--idle-tint); color: var(--idle);
    white-space: nowrap;
}
.filter-status-pill.filter-ok      { background: var(--fan-tint);     color: var(--fan); }
.filter-status-pill.filter-amber   { background: #fbecc1;             color: #815c10; }
.filter-status-pill.filter-overdue { background: var(--offline-tint); color: var(--offline); }
.filter-status-pill.filter-never   { background: var(--idle-tint);    color: var(--idle); }

.btn-primary, .btn-small {
    background: var(--ink);
    color: var(--bg);
    border: none;
    border-radius: var(--radius-sm);
    padding: 9px 18px;
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-block;
    text-decoration: none;
    transition: background 140ms var(--ease);
}
.btn-primary:hover, .btn-small:hover { background: var(--ink-2); }
.btn-small { padding: 6px 12px; font-size: 0.85rem; }

/* "Mark replaced" success state — set by filter-replace.js after an in-place
   (no-reload) save, so the user gets feedback without the page jumping. */
.btn-primary.is-done, .btn-small.is-done {
    background: var(--fan);
    cursor: default;
}
.btn-primary.is-done:hover, .btn-small.is-done:hover { background: var(--fan); }

/* Transient confirmation toast for in-place (no-reload) saves. */
.app-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%) translateY(8px);
    background: var(--ink);
    color: var(--bg);
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    opacity: 0;
    transition: opacity 240ms var(--ease), transform 240ms var(--ease);
    z-index: 1000;
    pointer-events: none;
}
.app-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

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

.filter-status-strip { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0 22px; }
.pill {
    padding: 5px 14px;
    border-radius: 999px;
    font-size: 0.88rem;
    font-weight: 500;
    background: var(--idle-tint);
    color: var(--idle);
}
.pill.pill-total { background: var(--surface-2); color: var(--ink); border: 1px solid var(--rule); }

.filters-table td, .filters-table th { vertical-align: top; }
.filters-table td { white-space: normal; }    /* override table base nowrap */
.filter-row.filter-overdue { background: rgba(196, 30, 30, 0.04); }
.filter-row.filter-amber   { background: rgba(192, 138, 30, 0.05); }
.filter-notes-inline {
    font-size: 0.82rem;
    color: var(--ink-faint);
    font-style: italic;
    margin-top: 2px;
}
.filter-shared-list {
    margin: 8px 0 0; padding-left: 18px;
    font-size: 0.9rem;
}
.filter-shared-list li { margin-bottom: 2px; }

.address-cell {
    color: var(--ink-2);
    font-size: 0.92rem;
}

/* --- Mobile: convert each row into a stacked card ------------------- */
@media (max-width: 720px) {
    .filters-table thead { display: none; }
    .filters-table,
    .filters-table tbody,
    .filters-table tr,
    .filters-table td { display: block; width: 100%; }

    /* Drop the figure's table styling shell */
    .filters-table tbody tr {
        background: var(--surface);
        border: 1px solid var(--rule);
        border-radius: var(--radius-md);
        margin-bottom: 12px;
        padding: 14px 16px 16px;
        box-shadow: var(--shadow-sm);
        display: grid;
        grid-template-columns: auto 1fr;
        column-gap: 14px;
        row-gap: 6px;
    }
    .filters-table tbody tr:hover td { background: transparent; }

    .filters-table td {
        padding: 0;
        border: none;
        font-size: 0.94rem;
    }

    /* Status pill — top-left, prominent */
    .filters-table td.col-status {
        grid-column: 1; grid-row: 1;
        align-self: center;
    }
    /* Filter name — top-right, large */
    .filters-table td.col-name {
        grid-column: 2; grid-row: 1;
        font-size: 1.05rem;
    }
    .filters-table td.col-name strong {
        font-family: "Instrument Serif", serif;
        font-size: 1.15rem;
        font-weight: 400;
    }

    /* Data rows — label : value pairs full width below */
    .filters-table td:not(.col-status):not(.col-name):not(.col-action) {
        grid-column: 1 / -1;
        display: flex;
        justify-content: space-between;
        gap: 14px;
        align-items: baseline;
        padding: 4px 0;
        border-top: 1px solid var(--rule);
    }
    .filters-table td:not(.col-status):not(.col-name):not(.col-action)::before {
        content: attr(data-label);
        font-size: 0.74rem;
        color: var(--ink-faint);
        text-transform: uppercase;
        letter-spacing: 0.06em;
        flex-shrink: 0;
        font-weight: 500;
    }

    /* Serves cell can wrap (details/list) — right-align label, stack content */
    .filters-table td.col-serves {
        flex-wrap: wrap;
    }
    .filters-table td.col-serves details {
        flex-basis: 100%;
        margin-top: 4px;
    }

    /* Mark replaced — full-width touch target */
    .filters-table td.col-action {
        grid-column: 1 / -1;
        margin-top: 10px;
    }
    .filters-table td.col-action form { width: 100%; }
    .filters-table td.col-action button {
        width: 100%;
        padding: 12px 16px;
        font-size: 0.95rem;
    }

    /* Tighten the page-head + status strip on mobile */
    .filter-status-strip { gap: 6px; margin: 6px 0 16px; }
    .filter-status-strip .pill { font-size: 0.82rem; padding: 4px 10px; }

    /* Drop the figure card around the table on mobile — each row is its own card */
    figure:has(.filters-table) {
        background: transparent;
        border: none;
        box-shadow: none;
        overflow: visible;
    }
}

/* ------------------------------------------------------------------ */
/* Routes page                                                          */
/* ------------------------------------------------------------------ */

.route-actions { display: flex; gap: 10px; align-items: center; }
.btn-link {
    color: var(--ink-2);
    text-decoration: underline;
    border: none;
    font-size: 0.9rem;
    background: none;
    cursor: pointer;
}

.route-filter {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    margin: 6px 0 24px;
    box-shadow: var(--shadow-sm);
}
.route-filter fieldset { border: none; padding: 0; margin: 0; }
.route-filter legend {
    font-size: 0.82rem;
    color: var(--ink-faint);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 10px;
}

.route-show-all {
    display: flex;
    align-items: center;
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--rule);
}
.toggle-all {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    font-size: 0.92rem;
    color: var(--ink-2);
    user-select: none;
}
.toggle-all input {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--ink);
}

.size-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 8px;
    margin-bottom: 14px;
}
.size-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border: 1.5px solid var(--rule-strong);
    border-radius: 999px;
    background: var(--surface-2);
    cursor: pointer;
    font-size: 0.92rem;
    user-select: none;
    transition: background 120ms var(--ease), border-color 120ms var(--ease);
}
.size-chip:hover { background: var(--surface); }
.size-chip input { position: absolute; opacity: 0; pointer-events: none; }
.size-chip.checked {
    background: var(--ink);
    color: var(--bg);
    border-color: var(--ink);
}
.size-chip.checked .chip-count { background: rgba(255,255,255,0.18); color: var(--bg); }
.chip-count {
    font-size: 0.78rem;
    background: var(--rule);
    color: var(--ink-2);
    border-radius: 999px;
    padding: 1px 8px;
    font-variant-numeric: tabular-nums;
}

.route-filter-actions { display: flex; gap: 14px; align-items: center; }

.route-section-head {
    margin: 22px 0 12px;
}
.route-group-head {
    font-family: "Instrument Serif", serif;
    font-size: 1.4rem;
    font-weight: 400;
    color: var(--ink-2);
    margin: 22px 0 10px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--rule);
}

/* Shopping list — "Filters needed for this route" */
.shopping-list {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-left: 4px solid var(--gold);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    margin: 6px 0 22px;
    box-shadow: var(--shadow-sm);
}
.shopping-list h2 { margin: 0 0 4px; font-size: 1.4rem; }
.shopping-list-sub {
    margin: 0 0 14px;
    font-size: 0.88rem;
    color: var(--ink-faint);
}
.shopping-list-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}
.shopping-item {
    display: flex;
    align-items: baseline;
    gap: 10px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-variant-numeric: tabular-nums;
}
.shopping-count {
    font-family: "Instrument Serif", serif;
    font-size: 1.6rem;
    color: var(--ink);
    line-height: 1;
}
.shopping-size {
    font-size: 0.95rem;
    color: var(--ink-2);
    font-family: "JetBrains Mono", ui-monospace, monospace;
}

/* Google Maps deep-links on every address. Tap to open the Maps app on
   phones, or web Google Maps in a new tab on desktop. */
.map-link {
    color: inherit;
    border-bottom: 1px dotted var(--rule-strong);
    text-decoration: none;
    transition: border-color 140ms var(--ease), color 140ms var(--ease);
}
.map-link:hover {
    color: var(--cool);
    border-bottom-color: var(--cool);
}

/* Cadence badge — flag any non-default replacement schedule (e.g. monthly for
   Brickyard kiln + Blacksmith Shop) */
.cadence-badge {
    display: inline-block;
    padding: 2px 9px;
    margin-left: 8px;
    background: var(--gold-soft);
    color: #6b4f1f;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    vertical-align: middle;
    font-family: "Bricolage Grotesque", sans-serif;
}

.route-list {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: stop-num;
}
.route-stop {
    display: grid;
    grid-template-columns: 56px 1fr auto;
    gap: 14px;
    align-items: stretch;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-left: 4px solid var(--rule-strong);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    padding: 14px 16px;
    box-shadow: var(--shadow-sm);
}
.route-stop.filter-overdue { border-left-color: var(--offline); }
.route-stop.filter-amber   { border-left-color: #c08a1e; }
.route-stop.filter-ok      { border-left-color: var(--fan); }
.route-stop.filter-never   { border-left-color: var(--idle); }

.stop-num {
    display: flex; align-items: center; justify-content: center;
    font-family: "Instrument Serif", serif;
    font-size: 1.8rem;
    color: var(--ink);
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    min-height: 44px;
    font-variant-numeric: tabular-nums;
}
.stop-num-empty { color: var(--ink-faint); font-size: 1.2rem; }

.stop-body { min-width: 0; }
.stop-head {
    display: flex; gap: 12px; align-items: baseline;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.stop-head strong {
    font-family: "Instrument Serif", serif;
    font-size: 1.15rem;
    font-weight: 400;
}
.stop-meta {
    display: flex; gap: 14px; flex-wrap: wrap;
    font-size: 0.9rem;
    color: var(--ink-2);
}
.stop-meta strong { color: var(--ink); font-weight: 500; }
.stop-notes {
    margin-top: 4px;
    font-size: 0.85rem;
    color: var(--ink-faint);
    font-style: italic;
}
.stop-action { display: flex; align-items: center; }

.route-empty {
    padding: 14px 18px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    color: var(--ink-2);
    font-size: 0.92rem;
}
.route-trailing {
    margin-top: 22px;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius-md);
    padding: 14px 16px;
}
.route-trailing > summary { cursor: pointer; color: var(--ink-2); }
.route-trailing[open] > summary { margin-bottom: 12px; }

/* Mobile — stack the stops */
@media (max-width: 720px) {
    .route-stop {
        grid-template-columns: 48px 1fr;
        grid-template-areas:
            "num body"
            "act act";
        gap: 12px;
    }
    .stop-num { grid-area: num; font-size: 1.5rem; min-height: 40px; }
    .stop-body { grid-area: body; }
    .stop-action { grid-area: act; margin-top: 6px; }
    .stop-action form, .stop-action button { width: 100%; }
    .stop-action button { padding: 10px 16px; }
    .stop-meta { gap: 8px 14px; font-size: 0.88rem; }

    .size-chips { gap: 6px; }
    .size-chip { padding: 8px 12px; font-size: 0.88rem; }
}

/* ------------------------------------------------------------------ */
/* Replacement report                                                   */
/* ------------------------------------------------------------------ */

.report-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 32px;
    align-items: flex-start;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    margin: 6px 0 24px;
    box-shadow: var(--shadow-sm);
}
.report-control-block { display: flex; flex-direction: column; gap: 9px; }
.report-control-legend {
    font-size: 0.78rem;
    color: var(--ink-faint);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.report-presets { display: flex; flex-wrap: wrap; gap: 8px; }
.preset {
    display: inline-flex;
    align-items: center;
    padding: 7px 14px;
    border: 1.5px solid var(--rule-strong);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--ink-2);
    font-size: 0.92rem;
    text-decoration: none;
    transition: background 120ms var(--ease), border-color 120ms var(--ease);
}
.preset:hover { background: var(--surface); }
.preset.is-active {
    background: var(--ink);
    color: var(--bg);
    border-color: var(--ink);
}
.report-pick-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.report-pick-sep { color: var(--ink-faint); }
.report-pick input[type="date"] {
    padding: 6px 10px;
    border: 1.5px solid var(--rule-strong);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    font: inherit;
    color: var(--ink);
}

.report-day { margin-bottom: 26px; }
.report-day-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin: 22px 0 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--rule);
}
.report-day-head h2 {
    font-family: "Instrument Serif", serif;
    font-size: 1.4rem;
    font-weight: 400;
    color: var(--ink-2);
    margin: 0;
}
.day-rel {
    font-family: "Bricolage Grotesque", sans-serif;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--fan);
}
.report-table .muted-note { margin-left: 8px; font-size: 0.8rem; opacity: 0.5; }

.report-empty {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius-md);
    padding: 28px;
    text-align: center;
    color: var(--ink-faint);
    box-shadow: var(--shadow-sm);
}
.report-empty a { color: var(--ink-2); }

@media print {
    .topbar, form, .range-selector, .no-print { display: none !important; }
    .therm-grid { grid-template-columns: repeat(4, 1fr); }
    .location-row[open] { break-inside: avoid; }

    /* Routes — print clean */
    body { background: #fff; font-size: 11pt; }
    .route-stop {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #999;
        margin-bottom: 6px;
        padding: 8px 10px;
    }
    .stop-num { background: #f0f0f0; font-size: 1.4rem; }
    .filter-status-pill { border: 1px solid currentColor; }

    /* Report — keep each day's block together on the page */
    .report-day { break-inside: avoid; }
    .report-day-head { border-bottom: 1px solid #999; }
}
