/* EnerTech-Analytics — all-black theme */
:root {
  --bg: #000;
  --surface: #0b0d10;
  --surface-2: #12161b;
  --line: #232a32;
  --text: #f2f4f6;
  --muted: #9aa4af;
  --accent: #4d94ff;      /* brighter cut of the logo blue #0046A2 for contrast on black */
  --brand: #0a56c9;
  --accent-ink: #ffffff;
  --amber: #ffb547;
  --red: #ff5d5d;
  --green: #3ddc84;
  --radius: 10px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  --display: "Space Grotesk", "Inter", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); }
body { min-height: 100vh; line-height: 1.5; }
a { color: var(--accent); }
h1 { font-family: var(--display); font-weight: 700; font-size: 1.6rem; margin: 0 0 .5rem; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* ---------- centered single-panel pages ---------- */
.page-center { display: flex; justify-content: center; padding: 40px 16px 64px; }
.panel { width: 100%; max-width: 440px; position: relative; }
.panel-wide { max-width: 760px; }
.logo { display: block; margin: 0 auto 24px; width: 220px; max-width: 70%; height: auto; }

.tagline {
  text-align: center; font-family: var(--display); font-weight: 700;
  font-size: clamp(1.5rem, 5vw, 2.1rem); margin: 0 0 32px;
}

/* ---------- forms ---------- */
.stack { display: flex; flex-direction: column; gap: 16px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 18px 20px; margin: 0;
           display: flex; flex-direction: column; gap: 14px; background: var(--surface); }
legend { padding: 0 8px; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: .875rem; font-weight: 600; color: #d6dbe0; }
.field em { font-style: normal; font-weight: 400; color: var(--muted); }
input[type=text], input[type=password], input[type=email], select {
  width: 100%; padding: 11px 12px; font: inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; outline: none;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(77, 148, 255, .18); }
select { appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
select option { background: var(--surface-2); color: var(--text); }
.has-error input, .has-error select { border-color: var(--red); }
.err { color: var(--red); font-size: .8rem; }
.hint { color: var(--muted); font-size: .8rem; margin-top: -6px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-name { display: grid; grid-template-columns: 1fr 110px 1fr; gap: 14px; }
.grid-address { display: grid; grid-template-columns: 1.4fr 1.2fr .8fr; gap: 14px; }

.checks { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }

.code-input { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 1.5rem !important;
              letter-spacing: .35em; text-align: center; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 20px;
       font: 600 .95rem var(--font); border-radius: 8px; border: 1px solid transparent; cursor: pointer;
       text-decoration: none; transition: background .15s, border-color .15s, color .15s; }
.btn-primary { background: var(--brand); color: var(--accent-ink); }
.btn-primary:hover { background: #1a6ae6; }
.btn-outline { border-color: var(--accent); color: var(--accent); background: transparent; }
.btn-outline:hover { background: rgba(77, 148, 255, .1); }
.btn-ghost { color: var(--muted); background: transparent; border-color: var(--line); }
.btn-ghost:hover { color: var(--text); border-color: #3a444f; }
.btn-small { padding: 6px 12px; font-size: .85rem; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: flex-end; margin-top: 8px; }
.actions form { margin: 0; }
.actions-left { justify-content: flex-start; }

.create-row { margin-top: 36px; padding-top: 24px; border-top: 1px solid var(--line); text-align: center; }
.create-row p { margin: 0 0 12px; color: var(--muted); }
.panel-login .btn-primary { width: 100%; }

/* ---------- messages ---------- */
.flash, .error-box, .warn-box, .note-box { border-radius: 8px; padding: 12px 14px; font-size: .9rem; margin: 0 0 16px; }
.flash { background: rgba(61, 220, 132, .1); border: 1px solid rgba(61, 220, 132, .4); color: #b9f5d2; }
.error-box { background: rgba(255, 93, 93, .1); border: 1px solid rgba(255, 93, 93, .45); color: #ffc4c4; margin: 0; }
.warn-box { background: rgba(255, 181, 71, .08); border: 1px solid rgba(255, 181, 71, .4); color: #ffe0b0; }
.note-box { background: var(--surface); border: 1px solid var(--line); color: var(--muted); margin-top: 20px; }

/* ---------- verification timer ---------- */
.timer { display: flex; justify-content: space-between; align-items: baseline; padding: 14px 16px; margin: 18px 0;
         border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.timer-label { color: var(--muted); font-size: .85rem; }
.timer-value { font: 700 1.6rem ui-monospace, Consolas, monospace; color: var(--accent); }
.timer.urgent .timer-value { color: var(--red); }

/* ---------- account summary ---------- */
.summary { margin: 20px 0 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.summary > div { display: grid; grid-template-columns: 190px 1fr; padding: 11px 16px; border-bottom: 1px solid var(--line); }
.summary > div:nth-child(odd) { background: var(--surface); }
.summary > div:last-child { border-bottom: 0; }
.summary dt { color: var(--muted); font-size: .875rem; }
.summary dd { margin: 0; word-break: break-word; }

/* ---------- toggle switch ---------- */
.panel-review { padding-bottom: 80px; }
.corner-switch { position: fixed; right: 24px; bottom: 20px; background: rgba(11, 13, 16, .92);
                 border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px; }
.inline-switch { display: flex; justify-content: flex-end; margin-top: 28px; }
.switch-wrap { margin: 0; display: flex; align-items: center; gap: 10px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.slider { width: 42px; height: 24px; border-radius: 999px; background: #2a323b; position: relative; transition: background .2s; flex: none; }
.slider::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
                 background: #cfd6dd; transition: transform .2s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::after { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px rgba(77, 148, 255, .35); }
.switch-label { font-size: .875rem; color: var(--muted); }

/* ---------- home: header / sidebar / main frame ---------- */
.app { display: flex; flex-direction: column; min-height: 100vh; }
.app-header { display: grid; grid-template-columns: 220px 1fr auto; align-items: center; gap: 20px;
              padding: 10px 24px; border-bottom: 1px solid var(--line); background: var(--bg);
              position: sticky; top: 0; z-index: 5; }
.header-logo img { display: block; height: 64px; width: auto; }
.header-user { display: flex; align-items: center; gap: 12px; font-size: .9rem; color: var(--muted); white-space: nowrap; }

.wx { display: flex; justify-content: center; align-items: center; gap: 22px; flex-wrap: wrap; min-height: 56px; }
.wx-loading { color: var(--muted); font-size: .9rem; }
.wx-main { display: flex; align-items: center; gap: 12px; }
.wx-temp { font: 700 2rem var(--display); color: var(--accent); }
.wx-place { font-size: .85rem; line-height: 1.25; }
.wx-place small { color: var(--muted); }
.wx-item { display: flex; flex-direction: column; line-height: 1.2; }
.wx-label { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.wx-value { font-weight: 600; font-size: .95rem; }

.app-body { display: flex; flex: 1; }
.sidebar { width: 220px; flex: none; border-right: 1px solid var(--line); padding: 18px 12px; background: var(--surface); }
.sidebar a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
             color: var(--text); text-decoration: none; font-weight: 500; }
.sidebar a:hover { background: var(--surface-2); }
.sidebar a.active { background: rgba(77, 148, 255, .12); color: var(--accent); }
.sidebar svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.main-frame { flex: 1; padding: 28px 32px; min-width: 0; max-width: 980px; }

/* ---------- admin ---------- */
.admin-header { display: flex; align-items: center; gap: 20px; padding: 12px 24px; border-bottom: 1px solid var(--line); }
.admin-header img { max-height: 44px; }
.admin-header h1 { font-size: 1.2rem; margin: 0; flex: 1; }
.admin-main { padding: 24px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.admin-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.admin-table th, .admin-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table th { color: var(--muted); font-weight: 600; background: var(--surface); white-space: nowrap; }
.admin-table form { margin: 0; }
.code-form { display: flex; gap: 6px; }
.code-form input { width: 130px; padding: 6px 8px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.tag-green { background: rgba(61, 220, 132, .14); color: var(--green); }
.tag-amber { background: rgba(255, 181, 71, .14); color: var(--amber); }
.tag-red { background: rgba(255, 93, 93, .14); color: var(--red); }

/* ---------- small screens ---------- */
@media (max-width: 720px) {
  .grid-2, .grid-name, .grid-address { grid-template-columns: 1fr; }
  .summary > div { grid-template-columns: 1fr; gap: 2px; }
  .app-header { grid-template-columns: 1fr auto; }
  .wx { grid-column: 1 / -1; order: 3; justify-content: flex-start; }
  .app-body { flex-direction: column; }
  .sidebar { width: auto; border-right: 0; border-bottom: 1px solid var(--line); display: flex; gap: 6px; }
  .main-frame { padding: 20px 16px; }
  .corner-switch { right: 12px; bottom: 12px; }
}

/* polish */
.tagline { white-space: nowrap; font-size: clamp(1.25rem, 5vw, 2.1rem); }
.grid-name em { display: none; }
.grid-name .field > span { white-space: nowrap; }

/* ===================== Phase 1: Dashboard Designer & buildings ===================== */
.btn-danger { background: transparent; color: var(--red); border-color: rgba(255, 93, 93, .45); }
.btn-danger:hover { background: rgba(255, 93, 93, .1); }
.crumbs { margin: 0 0 8px; font-size: .875rem; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.fine-print { font-size: .75rem; color: var(--muted); margin: 10px 0 0; line-height: 1.45; }
.page-note { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); }

/* sidebar groups */
.sidebar { overflow-y: auto; }
.sidebar a, .menu-group summary { line-height: 1.25; }
.menu-group { margin-top: 2px; }
.menu-group summary { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; cursor: pointer;
                      list-style: none; font-weight: 500; user-select: none; }
.menu-group summary::-webkit-details-marker { display: none; }
.menu-group summary::after { content: ""; margin-left: auto; width: 7px; height: 7px; border-right: 2px solid var(--muted);
                             border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; }
.menu-group[open] summary::after { transform: rotate(45deg); }
.menu-group summary:hover { background: var(--surface-2); }
.menu-group .count { font-size: .72rem; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 1px 7px; }
.menu-sub { padding: 2px 0 6px 10px; border-left: 1px solid var(--line); margin-left: 20px; }
.menu-sub a { padding: 7px 10px; font-size: .9rem; font-weight: 400; }
.menu-sub a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-empty { font-size: .8rem; color: var(--muted); margin: 6px 10px; }
.sidebar svg, .bicon, .bicon-lg, .bicon-xl { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.bicon { width: 18px; height: 18px; color: var(--accent); }
.bicon-lg { width: 30px; height: 30px; color: var(--accent); }
.bicon-xl { width: 64px; height: 64px; color: #3a4654; }
.name-with-icon { display: inline-flex; align-items: center; gap: 8px; }

/* stat banner */
.stat-banner { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1px; background: var(--line);
               border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 18px 0 28px; }
.stat { background: var(--surface); padding: 16px 14px; display: flex; flex-direction: column; gap: 4px; }
.stat-value { font: 700 1.75rem var(--display); color: var(--text); font-variant-numeric: tabular-nums; }
.stat-value small { font-size: .9rem; color: var(--muted); font-weight: 500; }
.stat-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* designer sections */
.main-frame { max-width: 1240px; }
.dd-section { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px 16px; margin-bottom: 18px; background: var(--bg); scroll-margin-top: 90px; }
.dd-section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.dd-section-head h2 { font: 700 1.1rem var(--display); margin: 0; }
.dd-num { width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: .8rem; font-weight: 700; flex: none; }
.dd-count { margin-left: auto; font-size: .8rem; color: var(--muted); }
.dd-buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.import-form { margin: 0; }
.import-form label.btn { position: relative; overflow: hidden; }
.import-form input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.import-form label.btn:focus-within { box-shadow: 0 0 0 3px rgba(77, 148, 255, .35); }
.auto-switch { margin: 0 0 14px; }
.auto-switch .switch-label { max-width: 640px; }
.dd-hint { color: var(--amber); font-size: .875rem; margin: 0 0 10px; }
.dd-table { margin-top: 4px; max-height: 360px; overflow-y: auto; }
.dd-table th { position: sticky; top: 0; z-index: 1; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }
.row-actions form { margin: 0; }

/* record form */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px 16px; }
.record-form { max-width: 980px; }
.img-preview { max-width: 240px; max-height: 160px; border-radius: 8px; border: 1px solid var(--line); object-fit: cover; }
input[type=number], input[type=file] { width: 100%; padding: 11px 12px; font: inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; }
input[type=file] { padding: 8px; }
input[readonly] { color: var(--muted); }

/* building page */
.bldg-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: -6px 0 18px; overflow-x: auto; }
.bldg-tab { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font: 500 .9rem var(--font);
            padding: 10px 14px; cursor: pointer; white-space: nowrap; }
.bldg-tab:hover { color: var(--text); }
.bldg-tab[aria-selected=true] { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { border: 1px dashed var(--line); border-radius: 8px; padding: 12px 16px; margin-bottom: 18px; }
.tab-panel p { margin: 0; }
.bldg-header { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(260px, 1.1fr) minmax(260px, 1.2fr); gap: 20px; align-items: stretch; }
.bldg-photo, .bldg-map { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; min-height: 240px; background: var(--surface); position: relative; }
.bldg-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-empty { height: 100%; min-height: 240px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; font-size: .85rem; }
.map-msg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: .875rem; padding: 16px; text-align: center; }
.map-note { position: absolute; left: 8px; bottom: 8px; z-index: 500; background: rgba(0,0,0,.75); color: #fff; font-size: .72rem; padding: 3px 8px; border-radius: 6px; }
.bldg-info { display: flex; flex-direction: column; gap: 8px; }
.bldg-info .muted { margin: 0; }
.bldg-title { display: flex; align-items: center; gap: 10px; }
.bldg-title h1 { margin: 0; font-size: 1.5rem; }
.bldg-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 6px 0; }
.bldg-facts div { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.bldg-facts dt { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.bldg-facts dd { margin: 2px 0 0; font: 700 1.2rem var(--display); }
.util-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: .75rem; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); }
.bldg-info .btn { align-self: flex-start; margin-top: auto; }
.coming { margin-top: 24px; border: 1px dashed var(--line); border-radius: var(--radius); padding: 18px 20px; }
.coming h2 { margin: 0 0 6px; font: 700 1.05rem var(--display); }
.coming p { margin: 0; }
.leaflet-container { background: #1b2027; font: inherit; }

/* admin additions */
.admin-nav { display: flex; gap: 4px; flex: 1; }
.admin-nav a { color: var(--muted); text-decoration: none; padding: 6px 12px; border-radius: 8px; font-size: .9rem; }
.admin-nav a:hover { color: var(--text); background: var(--surface-2); }
.admin-nav a.active { color: var(--accent); background: rgba(77, 148, 255, .12); }
.admin-header h1 { flex: none; }
.admin-h2 { font: 700 1.25rem var(--display); margin: 0 0 8px; }
.admin-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.create-table { max-width: 620px; }
.col-rows { display: flex; flex-direction: column; gap: 8px; }
.col-row { display: grid; grid-template-columns: 1fr 190px auto; gap: 8px; }
.danger-zone { margin-top: 28px; border: 1px solid rgba(255, 93, 93, .35); border-radius: var(--radius); padding: 12px 16px; max-width: 520px; }
.danger-zone summary { color: var(--red); cursor: pointer; font-weight: 600; }
.danger-zone form { margin-top: 12px; }
.admin-table a { color: var(--accent); }

@media (max-width: 1100px) {
  .stat-banner { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bldg-header { grid-template-columns: 1fr 1fr; }
  .bldg-info { grid-column: 1 / -1; order: -1; }
}
@media (max-width: 720px) {
  .stat-banner { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bldg-header { grid-template-columns: 1fr; }
  .sidebar { flex-direction: column; }
  .col-row { grid-template-columns: 1fr; }
  .dd-section { padding: 14px; }
}

/* wider sidebar for longer menu titles */
.sidebar { width: 260px; }
.app-header { grid-template-columns: 260px 1fr auto; }
@media (max-width: 720px) { .sidebar { width: auto; } .app-header { grid-template-columns: 1fr auto; } }

/* ===================== Phase 2: building analytics ===================== */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-top: 20px; background: var(--bg); }
.card h2 { font: 700 1.05rem var(--display); margin: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.empty-card p { margin: 8px 0 0; }
.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; margin-bottom: 14px; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: .75rem; color: var(--muted); }
.filters select, .region-form select { width: auto; padding: 7px 30px 7px 10px; font-size: .875rem; }
.chart-box { position: relative; height: 200px; }
.chart-box.tall { height: 340px; }
.chart-note { margin: 6px 0 0; min-height: 1em; }
.trend-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.trend { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; background: var(--surface); }
.trend-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: .9rem; }
.trend-head .peak { margin-left: auto; font-size: .75rem; color: var(--muted); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; flex: none; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.two-col .card { margin-top: 20px; }
.thresholds .pct { width: 96px; padding: 6px 8px; }
.thresholds input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.carbon-total { margin: 4px 0 12px; display: flex; align-items: baseline; gap: 8px; }
.carbon-total .stat-value { font-size: 2.2rem; }
.admin-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.region-form { margin: 0; }
.region-form label { display: flex; align-items: center; gap: 8px; }

/* flag light: green normal, red flashing alert, gray off */
.flag-light { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: #3a444f; flex: none; }
.flag-light.ok { background: var(--green); box-shadow: 0 0 8px rgba(61, 220, 132, .6); }
.flag-light.on { background: var(--red); box-shadow: 0 0 10px rgba(255, 93, 93, .9); animation: flag-flash 1s steps(2, jump-none) infinite; }
@keyframes flag-flash { 0% { opacity: 1; } 100% { opacity: .2; } }
@media (prefers-reduced-motion: reduce) { .flag-light.on { animation-duration: 2.4s; } }
.alert-banner { display: flex; gap: 14px; align-items: flex-start; border: 1px solid rgba(255, 93, 93, .5); background: rgba(255, 93, 93, .08);
                border-radius: var(--radius); padding: 14px 16px; margin-top: 20px; }
.alert-banner .flag-light { width: 16px; height: 16px; margin-top: 3px; }
.alert-banner ul { margin: 6px 0 0; padding-left: 18px; color: #ffd0d0; font-size: .9rem; }
.menu-sub a .flag-light { width: 9px; height: 9px; margin-left: auto; }

@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }
@media (max-width: 720px) { .trend-grid { grid-template-columns: 1fr; } .chart-box.tall { height: 280px; } }
.admin-table .num { white-space: nowrap; }

/* ===================== Phase 4: Weather ===================== */
.wx-menu .flag-light { width: 10px; height: 10px; margin-right: -2px; }
.wx-top h1 { margin: 0; }
.wx-search { display: flex; gap: 8px; align-items: center; }
.wx-search input { width: 240px; padding: 8px 10px; }
.wx-where { margin: 4px 0 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.wx-ok { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .875rem; margin: 14px 0 0; }
.wx-alerts details { margin-top: 8px; }
.wx-alerts summary { cursor: pointer; font-weight: 600; color: #ffd0d0; }
.wx-alerts .pre { white-space: pre-line; font-size: .85rem; color: var(--text); }
.wx-grid { display: grid; grid-template-columns: 1.15fr .85fr 1.6fr; gap: 20px; }
.wx-grid .card { margin-top: 20px; }
.wx-grid h2, .card > h2 { margin-bottom: 12px; }
.now-main { display: flex; align-items: center; gap: 16px; }
.now-temp { font: 700 3.4rem/1 var(--display); }
.now-temp span { font-size: 1.3rem; color: var(--muted); margin-left: 2px; vertical-align: top; }
.now-text { color: var(--text); margin-top: 6px; }
.now-gauges { display: flex; gap: 16px; align-items: center; margin-top: 18px; }
.ring { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: none; }
.ring svg { width: 96px; height: 96px; }
.ring span { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; flex: 1; }
.mini-stats div { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.mini-stats span { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.mini-stats strong { font-size: .95rem; }
.compass-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.compass { width: 100%; max-width: 210px; }
.needle { transform-origin: 50px 50px; transform: rotate(0deg); transition: transform 1.6s cubic-bezier(.3, 1.4, .5, 1); }
.needle.set { transform: rotate(var(--deg)); }
@media (prefers-reduced-motion: reduce) { .needle { transition: none; } }
.compass-text { display: flex; flex-direction: column; align-items: center; text-align: center; }
.compass-text strong { font-size: 1.05rem; }
.compass-text span { color: var(--text); }
.compass-text small { color: var(--muted); }
#radar-map { height: 330px; border-radius: 8px; overflow: hidden; position: relative; background: var(--surface); }
.forecast { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.fc-day { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 8px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.fc-name { font-weight: 600; font-size: .85rem; }
.fc-short { font-size: .75rem; color: var(--muted); min-height: 2.6em; line-height: 1.3; }
.fc-temps { display: flex; gap: 8px; font: 700 1.1rem var(--display); }
.fc-temps .lo { color: var(--muted); }
.fc-meta { display: flex; flex-direction: column; gap: 2px; font-size: .72rem; color: var(--muted); }
.fc-meta span { display: inline-flex; align-items: center; justify-content: center; gap: 3px; }
.drop { width: 11px; height: 11px; fill: #4d94ff; }
.dd-tiles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.dd-tile { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.dd-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.dd-pair { display: flex; gap: 12px; font-size: .8rem; color: var(--muted); }
.dd-pair b { font: 700 1.2rem var(--display); color: var(--text); margin-right: 2px; }
.dd-pair .hdd b { color: #f08a5d; }
.dd-pair .cdd b { color: #6aa8f0; }
.sub-h { font: 700 .95rem var(--display); margin: 20px 0 8px; }
@media (max-width: 1200px) { .wx-grid { grid-template-columns: 1fr 1fr; } .wx-radar { grid-column: 1 / -1; } .forecast { grid-template-columns: repeat(4, minmax(0, 1fr)); } .dd-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 720px) { .wx-grid { grid-template-columns: 1fr; } .forecast { grid-template-columns: repeat(2, minmax(0, 1fr)); } .dd-tiles { grid-template-columns: 1fr 1fr; } .wx-search input { width: 100%; } .wx-search { width: 100%; } }

/* ===================== Phase 5: Calculators ===================== */
.menu-scroll { max-height: 300px; overflow-y: auto; scrollbar-width: thin; }
.calc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 12px; }
.calc-tile { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius);
             background: var(--surface); color: var(--text); text-decoration: none; transition: border-color .15s; }
.calc-tile:hover { border-color: var(--accent); }
.calc-tile span { font-size: .8rem; color: var(--muted); line-height: 1.4; }
.calc-card { max-width: 980px; position: relative; }
.conv-row { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(200px, 1.6fr) auto minmax(200px, 1.6fr); gap: 12px; align-items: end; }
.conv-row.wrap { display: flex; flex-wrap: wrap; }
.conv-row.wrap .field { min-width: 180px; flex: 1; }
.conv-row .field.wide { flex: 3; min-width: 280px; }
.cat-pick { max-width: 280px; margin-bottom: 14px; }
.swap { height: 44px; padding: 0 14px; font-size: 1.1rem; }
#calc-out { margin-top: 18px; }
.calc-result { font: 700 1.35rem/1.35 var(--display); color: var(--text); word-break: break-word; margin: 0 0 10px; }
.calc-formula { display: flex; flex-direction: column; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.calc-formula span { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.calc-formula code { font: .85rem/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace; color: #cfe0ff; white-space: pre-wrap; word-break: break-word; }
.all-units { margin-top: 12px; }
.all-units summary { cursor: pointer; color: var(--accent); font-size: .875rem; margin-bottom: 8px; }
.all-units table, .color-table { max-width: 640px; }
.mono { font-family: ui-monospace, Consolas, monospace; word-break: break-all; }
.uni { font-size: 1.15rem; }
.swatches { display: flex; gap: 12px; flex-wrap: wrap; margin: 14px 0; }
.swatch-big { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.swatch-big span { width: 110px; height: 70px; border-radius: 8px; border: 1px solid var(--line); }
.swatch-big small { color: var(--muted); }
input[type=color] { width: 100%; height: 44px; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.calc-toast { position: absolute; right: 16px; bottom: 16px; background: #10241a; border: 1px solid rgba(61, 220, 132, .45); color: #b9f5d2; padding: 8px 12px; border-radius: 8px; font-size: .85rem; }
.report-item .card-head { justify-content: flex-start; }
.report-item .card-head form { margin-left: auto; }
.report-inputs { margin: 0 0 8px; padding-left: 18px; color: var(--muted); font-size: .9rem; }
.print-only { display: none; }
.ps-head { display: flex; align-items: center; gap: 16px; border-bottom: 2px solid #0a56c9; padding-bottom: 10px; margin-bottom: 14px; }
.ps-head img { height: 60px; }
.ps-head h2 { margin: 0; }
@media (max-width: 720px) { .conv-row { grid-template-columns: 1fr; } .swap { width: 100%; } }
@media print {
  body, html { background: #fff !important; color: #000 !important; }
  .app-header, .sidebar, .no-print, .flash, .crumbs, .main-frame > h1, .main-frame > p.muted, #calc { display: none !important; }
  .main-frame { padding: 0 !important; max-width: none; }
  .print-only { display: block !important; }
  .ps-head { display: flex !important; }
  #print-sheet h3 { font-size: 12pt; margin: 14px 0 4px; }
  .ps-formula { font-family: Consolas, monospace; font-size: 10pt; white-space: pre-wrap; }
  .ps-result { font-size: 14pt; font-weight: 700; }
  .ps-foot { margin-top: 24px; font-size: 9pt; color: #555; }
  .report-item { border: 1px solid #ccc !important; background: #fff !important; break-inside: avoid; }
  .report-item *, .calc-formula code { color: #000 !important; }
  .calc-formula { background: #f4f6f8 !important; border-color: #ccc !important; }
}

/* ===================== Phase 6: Psychrometric chart ===================== */
.psy-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 18px; }
.psy-tab { background: var(--surface); border: 1px solid var(--line); color: var(--muted); font: 500 .85rem var(--font); padding: 8px 14px; border-radius: 999px; cursor: pointer; }
.psy-tab:hover { color: var(--text); }
.psy-tab[aria-selected=true] { background: rgba(77, 148, 255, .14); border-color: var(--accent); color: var(--accent); }
.psy-controls { display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: flex-end; justify-content: space-between; }
.psy-inputs { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; flex: 1 1 520px; }
.unit-tag { font-style: normal; color: var(--muted); font-weight: 400; }
.psy-settings { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.psy-settings .field { min-width: 200px; }
.elev-box { display: flex; flex-direction: column; gap: 6px; min-width: 240px; }
#elev-opts { display: flex; gap: 8px; }
#elev-opts select { width: auto; padding: 7px 28px 7px 10px; font-size: .85rem; }
#elev-opts input { width: 100px; padding: 7px 10px; }
.psy-chart-card { padding: 12px 12px 8px; }
#psy-chart { width: 100%; height: auto; display: block; cursor: crosshair; user-select: none; }
#psy-chart .zone { fill: rgba(77, 148, 255, .035); }
#psy-chart .grid { stroke: #1c232b; stroke-width: 1; fill: none; }
#psy-chart .rh { stroke: #3a5a80; stroke-width: 1.2; fill: none; }
#psy-chart .sat { stroke: #8fb8f0; stroke-width: 2.2; fill: none; }
#psy-chart .wb { stroke: #2c3a48; stroke-width: 1; fill: none; }
#psy-chart .enth { stroke: #4a3a52; stroke-width: 1; fill: none; stroke-dasharray: 5 4; }
#psy-chart .vol { stroke: #31423a; stroke-width: 1; fill: none; }
#psy-chart .axis { stroke: #3a444f; stroke-width: 1.2; }
#psy-chart text { font-family: Inter, "Segoe UI", sans-serif; }
#psy-chart .axis-b { font-size: 12px; fill: #9aa4af; text-anchor: middle; }
#psy-chart .axis-r { font-size: 11px; fill: #9aa4af; }
#psy-chart .axis-title { font-size: 13px; fill: #c3c9d0; text-anchor: middle; }
#psy-chart .lab { font-size: 10.5px; fill: #7f8b97; }
#psy-chart .rh-lab { fill: #7ea6d8; }
#psy-chart .enth-lab { fill: #b48ac0; }
#psy-chart .press { font-size: 12px; fill: #9aa4af; }
#psy-chart .hl { fill: none; stroke-width: 2.4; }
#psy-chart .process { stroke: #f2f4f6; stroke-width: 2; stroke-dasharray: 6 5; fill: none; }
#psy-chart .dot { fill: #ff4d4d; stroke: #fff; stroke-width: 2.5; }
#psy-chart .dot-pulse { fill: rgba(255, 77, 77, .35); animation: psy-pulse 1.6s ease-out infinite; transform-origin: 0 0; }
#psy-chart .dot-label { font-size: 13px; font-weight: 700; fill: #fff; paint-order: stroke; stroke: #000; stroke-width: 3px; }
@keyframes psy-pulse { 0% { transform: scale(.5); opacity: 1; } 100% { transform: scale(1.6); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #psy-chart .dot-pulse { animation: none; } #psy-chart path { transition: none !important; } }
#psy-chart .hover-line { stroke: rgba(255, 255, 255, .35); stroke-dasharray: 3 3; }
#psy-chart .hover-box { fill: #151a20; stroke: #2a323b; }
#psy-chart .hover-text { font-size: 12px; fill: #e6eaee; }
.psy-results .psy-summary { font-size: 1.05rem; margin: 0 0 8px; }
.psy-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .8rem; color: var(--muted); margin-bottom: 12px; }
.psy-legend span { display: inline-flex; align-items: center; gap: 6px; }
.psy-legend i { width: 18px; height: 3px; border-radius: 2px; display: inline-block; }
.psy-table { max-width: 460px; }
.psy-table caption { text-align: left; font-weight: 700; padding: 0 0 6px; color: var(--text); }
.swatch.blank { background: transparent; }
.psy-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.psy-loads { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }
.psy-loads div { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; display: flex; flex-direction: column; }
.psy-loads span { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.psy-loads b { font: 700 1.15rem var(--display); }
.psy-loads small { color: var(--muted); }
@media (max-width: 900px) { .psy-loads { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ===================== Phase 7: Best Rates Calculator ===================== */
.rate-filters { display: flex; flex-wrap: wrap; gap: 12px 16px; margin: 16px 0; }
.rate-filters select { min-width: 180px; }
.report-options { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; margin-bottom: 20px; }
.report-options .actions { margin: 0 0 0 auto; }
.rate-report { background: #fff; color: #1f1f1d; border-radius: 10px; padding: 28px 32px; font-size: 13px; line-height: 1.45; max-width: 1400px; }
.rate-report a { color: #1c5cab; }
.rr-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; border-bottom: 3px solid #0a56c9; padding-bottom: 12px; margin-bottom: 16px; }
.rr-head img { height: 74px; }
.rr-head h2 { margin: 0; font: 700 1.8rem var(--display); color: #0d366b; text-align: center; }
.rr-date { text-align: right; color: #52514e; }
.rr-date strong { color: #1f1f1d; }
.rr-top { display: flex; gap: 20px; align-items: stretch; margin-bottom: 18px; min-height: 150px; }
.rr-img { flex: 0 0 220px; }
.rr-bldg { flex: 1 1 auto; min-width: 0; }
.rr-map { flex: 0 0 260px; }
.rr-img[hidden], .rr-map[hidden] { display: none; }
.rr-img img { width: 100%; height: 160px; object-fit: cover; border-radius: 6px; border: 1px solid #ddd; }
.rr-map { height: 160px; border-radius: 6px; border: 1px solid #ddd; overflow: hidden; }
.rr-bldg h3 { margin: 0 0 4px; font: 700 1.35rem var(--display); color: #1f1f1d; }
.rr-bldg p { margin: 2px 0; }
.rr-small { font-size: 11.5px; color: #52514e; }
.rate-report h4 { font: 700 1rem var(--display); margin: 8px 0 8px; color: #0d366b; }
.rr-scroll { overflow-x: auto; }
.rr-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.rr-table th { background: #eef3fa; color: #0d366b; text-align: left; padding: 6px; border-bottom: 2px solid #b7d3f6; white-space: nowrap; }
.rr-table td { padding: 6px; border-bottom: 1px solid #e7e6e2; vertical-align: top; }
.rr-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rr-table td:first-child { min-width: 170px; max-width: 260px; }
.rr-table th, .rr-table td { padding-left: 5px; padding-right: 5px; }
.rr-use td { color: #52514e; background: #fafaf8; }
.rr-actual td { background: #f3f3f0; }
.rr-best td { background: #eaf7f0; }
.rr-tag { display: inline-block; font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 999px; background: #e7eef8; color: #1c5cab; margin-left: 6px; }
.rr-tag.best { background: #d4f0e1; color: #0b6b3c; }
.rr-note { font-size: 10.5px; color: #6b6a66; margin-top: 2px; }
.rr-table .save { color: #0b6b3c; font-weight: 700; }
.rr-table .more { color: #a3312f; }
.rr-chart-box { position: relative; height: 320px; }
.rr-foot { margin-top: 18px; padding-top: 10px; border-top: 2px solid #0a56c9; font-size: 11.5px; font-weight: 600; color: #a3312f; text-align: center; }
.rate-report.pdf-mode { width: 1360px; max-width: none; border-radius: 0; }
.rate-report.pdf-mode .rr-scroll { overflow: visible; }
@media print {
  @page { size: letter landscape; margin: 0.4in; }
  .rate-report { padding: 0; border-radius: 0; max-width: none; font-size: 10.5px; }
  .rr-table { font-size: 8.5px; }
  .rr-scroll { overflow: visible; }
  .rr-table td:first-child { min-width: 130px; }
  .rr-table tr { break-inside: avoid; }
  .rr-chart { break-inside: avoid; }
  .rr-foot { position: static; }
  .rate-report * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
