/* ================================================================
   Energy Calculator — Design System
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --color-bg:           #F7F6F3;
  --color-surface:      #ffffff;
  --color-border:       #e2e8f0;
  --color-border-light: #e8eeff;

  --color-text:         #0f172a;
  --color-text-muted:   #5A6272;
  --color-text-subtle:  #686E7D;

  --color-primary:      #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-primary-soft: #eff6ff;

  /* Primary-action colour (Task #62) — the one colour that means "this moves
     you forward," consistent with the landing page. --color-primary above is
     kept as-is: it still drives text links, focus rings, selected tab/segmented
     states and other informational blue — only .btn-primary's fill changes. */
  --color-amber:        #E07B00;
  --color-amber-hover:  #C86D00;
  --color-amber-text:   #160F02;
  --color-amber-soft:   #FEF3E2;

  /* Selection states (tabs, segmented controls, preset pickers) — stays blue,
     deliberately not the same token as .btn-primary now uses. */
  --color-selected:     #2563eb;

  --color-success:      #16a34a;
  --color-success-soft: #f0fdf4;
  --color-danger:       #dc2626;
  --color-danger-soft:  #fef2f2;
  --color-warning:      #d97706;
  --color-warning-soft: #fffbeb;
  --color-info:         #0284c7;
  --color-info-soft:    #f0f9ff;

  --color-nav-bg:       #0f172a;
  --color-nav-text:     #94a3b8;
  --color-nav-active:   #ffffff;
  --color-nav-hover:    #cbd5e1;
  --color-nav-accent:   #3b82f6;

  --shadow-xs: 0 1px 2px rgba(15,23,42,0.05);
  --shadow-sm: 0 1px 3px rgba(15,23,42,0.08), 0 1px 2px rgba(15,23,42,0.04);
  --shadow-md: 0 4px 6px rgba(15,23,42,0.07), 0 2px 4px rgba(15,23,42,0.04);
  --shadow-lg: 0 10px 15px rgba(15,23,42,0.08), 0 4px 6px rgba(15,23,42,0.04);

  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;

  --motion-micro:    150ms;
  --motion-standard: 300ms;
  --motion-emphasis: 700ms;
  --ease-out:    cubic-bezier(0.0,  0.0, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4,  0.0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Dark mode ─────────────────────────────────────────────────
   Same 28 --color-* tokens, redefined. Two blocks, deliberately
   duplicated rather than shared via a preprocessor (none is used here):
   - The @media block applies dark values automatically when the OS
     prefers dark AND no explicit light override is set — the case for
     every new visitor who has never touched the toggle. Guarded with
     :not([data-theme="light"]) so a manual "light" choice still wins
     even on a dark-preferring OS.
   - The [data-theme="dark"] block applies when the toggle (base.html)
     has explicitly set it, regardless of OS preference.
   Both are driven by the theme resolved server-side in app.py and
   written into <html data-theme="..."> before first paint — see
   _resolve_theme()/toggle_theme() — so there is nothing here for
   JavaScript to correct after the fact, the same reasoning already
   applied to the count-up-animation and landing-page-meter flashes
   fixed earlier this app's history.
   Palette follows the Tailwind slate/blue scale this app's own
   existing dark elements (the navbar, --color-nav-accent) already use,
   for consistency rather than inventing a second dark language. Accent
   colours (primary/success/danger/warning/info) are shifted a step
   lighter than their light-mode values — a saturated blue/red/amber
   tuned for a white background reads muddy or low-contrast on a dark
   one; the standard dark-UI correction is to move up the scale, not
   reuse the light value as-is. --color-amber-text is intentionally
   NOT redefined: it's the near-black text drawn on top of the opaque
   amber button fill, correct regardless of what surrounds the button. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-bg:           #0f172a;
    --color-surface:      #1e293b;
    --color-border:       #334155;
    --color-border-light: #45536b;

    --color-text:         #f1f5f9;
    --color-text-muted:   #94a3b8;
    --color-text-subtle:  #64748b;

    --color-primary:      #3b82f6;
    --color-primary-dark: #60a5fa;
    --color-primary-soft: #1e2f4a;

    --color-amber:        #f59e0b;
    --color-amber-hover:  #fbbf24;
    --color-amber-soft:   #3a2a0f;

    --color-selected:     #3b82f6;

    --color-success:      #22c55e;
    --color-success-soft: #14291c;
    --color-danger:       #f87171;
    --color-danger-soft:  #3a1a1a;
    --color-warning:      #fbbf24;
    --color-warning-soft: #3a2e0f;
    --color-info:         #38bdf8;
    --color-info-soft:    #0f2937;

    --color-nav-bg:       #020617;
    --color-nav-text:     #94a3b8;
    --color-nav-active:   #ffffff;
    --color-nav-hover:    #cbd5e1;
    --color-nav-accent:   #3b82f6;
  }
}

:root[data-theme="dark"] {
  --color-bg:           #0f172a;
  --color-surface:      #1e293b;
  --color-border:       #334155;
  --color-border-light: #45536b;

  --color-text:         #f1f5f9;
  --color-text-muted:   #94a3b8;
  --color-text-subtle:  #64748b;

  --color-primary:      #3b82f6;
  --color-primary-dark: #60a5fa;
  --color-primary-soft: #1e2f4a;

  --color-amber:        #f59e0b;
  --color-amber-hover:  #fbbf24;
  --color-amber-soft:   #3a2a0f;

  --color-selected:     #3b82f6;

  --color-success:      #22c55e;
  --color-success-soft: #14291c;
  --color-danger:       #f87171;
  --color-danger-soft:  #3a1a1a;
  --color-warning:      #fbbf24;
  --color-warning-soft: #3a2e0f;
  --color-info:         #38bdf8;
  --color-info-soft:    #0f2937;

  --color-nav-bg:       #020617;
  --color-nav-text:     #94a3b8;
  --color-nav-active:   #ffffff;
  --color-nav-hover:    #cbd5e1;
  --color-nav-accent:   #3b82f6;
}

/* ── Base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font-sans);
  background-color: var(--color-bg);
  color: var(--color-text);
  font-size: 0.9375rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ─────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: 700;
  line-height: 1.25;
  color: var(--color-text);
}

.page-header {
  margin-bottom: 1.75rem;
}

.page-header h1 {
  font-size: 1.375rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.page-subtitle {
  color: var(--color-text-muted);
  font-size: 0.9375rem;
  font-style: italic;
  margin-bottom: 0;
}

.section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

/* ── Navbar ─────────────────────────────────────────────────── */
.navbar {
  background-color: var(--color-nav-bg) !important;
  box-shadow: 0 1px 0 rgba(255,255,255,0.06);
  padding-top: 0;
  padding-bottom: 0;
  min-height: 58px;
  position: sticky;
  top: 0;
  z-index: 1030;
}

.navbar-brand {
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff !important;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: -0.01em;
  padding-top: 0;
  padding-bottom: 0;
}

.navbar-brand .brand-icon {
  width: 28px;
  height: 28px;
  background: var(--color-nav-accent);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.navbar .nav-link {
  color: var(--color-nav-text) !important;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 1.125rem 0.75rem !important;
  transition: color 0.15s ease;
  border-bottom: 2px solid transparent;
  line-height: 1;
}

.navbar .nav-link:hover {
  color: var(--color-nav-hover) !important;
}

.navbar .nav-link.active,
.navbar .nav-link[aria-current="page"] {
  color: var(--color-nav-active) !important;
  border-bottom-color: var(--color-nav-accent);
}

.navbar-toggler {
  border: 1px solid rgba(255,255,255,0.15);
  padding: 0.375rem 0.625rem;
}

.navbar-toggler-icon {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(148,163,184,1)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

/* ── Page Wrapper ───────────────────────────────────────────── */
.page-wrapper {
  padding-top: 2rem;
  padding-bottom: 3rem;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.card-body {
  padding: 1.375rem 1.5rem;
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--color-border-light);
  padding: 1rem 1.5rem;
  font-weight: 600;
  font-size: 0.9375rem;
}

.card-header:first-child {
  border-radius: calc(var(--radius-lg) - 1px) calc(var(--radius-lg) - 1px) 0 0;
}

.card-footer {
  background: var(--color-border-light);
  border-top: 1px solid var(--color-border);
  padding: 0.875rem 1.5rem;
}

/* Card variants */
.card-elevated {
  box-shadow: var(--shadow-md);
}

.card-outlined {
  box-shadow: none;
  border: 1.5px solid var(--color-border);
}

.card-primary-outline {
  border: 2px solid var(--color-primary);
  box-shadow: 0 0 0 4px rgba(37,99,235,0.06);
}

.card-success-outline {
  border: 2px solid var(--color-success);
  box-shadow: 0 0 0 4px rgba(22,163,74,0.06);
}

/* ── Stat Cards ─────────────────────────────────────────────── */
.stat-card {
  text-align: center;
  padding: 1.5rem 1rem;
}

.stat-card-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1rem;
}

.stat-icon-circle {
  flex-shrink: 0;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  background: var(--color-primary-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
}

.stat-icon-circle svg {
  width: 22px;
  height: 22px;
  stroke: var(--color-primary);
}

.stat-card-row .stat-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 0.2rem;
}

.stat-card-row .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 0.1rem;
}

.stat-card-row .stat-meta {
  font-size: 0.8rem;
  color: var(--color-text-subtle);
}

.stat-card .stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 0.25rem;
}

.stat-card .stat-meta {
  font-size: 0.8125rem;
  color: var(--color-text-subtle);
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  letter-spacing: 0;
}

/* Task #62 — primary action colour is amber everywhere, matching the landing
   page exactly (see --color-amber / --color-amber-text above). Bootstrap
   5.1.3 has no CSS variable API for buttons, so :hover/:focus/:active are
   pinned explicitly
   here rather than relying on a single token swap — otherwise Bootstrap's own
   compiled :active/:focus states would still show its default blue. Focus
   box-shadow is deliberately left alone: the ring itself is allowed to stay
   blue (it's informational, not the button fill) and it's what keeps focus
   visible on an amber background. */
.btn-primary,
.btn-primary:disabled,
.btn-primary.disabled {
  background: var(--color-amber);
  border-color: var(--color-amber);
  color: var(--color-amber-text);
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary.focus {
  background: var(--color-amber-hover);
  border-color: var(--color-amber-hover);
  color: var(--color-amber-text);
}

.btn-primary:not(:disabled):not(.disabled):active,
.btn-primary:not(:disabled):not(.disabled).active {
  background: var(--color-amber-hover);
  border-color: var(--color-amber-hover);
  color: var(--color-amber-text);
}

/* Selection states (usage-preset pickers, etc.) that need a filled "selected"
   look without inheriting .btn-primary's new amber semantics — stays blue. */
.btn-selected,
.btn-selected:hover,
.btn-selected:focus {
  background: var(--color-selected);
  border-color: var(--color-selected);
  color: #fff;
}

.btn-selected:not(:disabled):not(.disabled):active {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  color: #fff;
}

/* Task #62 follow-up — a full-width amber button reads as a warning banner,
   not an action. Opt-in per screen (not a blanket .btn-primary rule) since
   small utility primary buttons elsewhere are already sized to content.
   Full-width below 576px (Bootstrap's sm breakpoint) is still the right
   mobile pattern; capped and left-aligned with the form above that. */
.btn-primary-cta {
  width: 100%;
}
@media (min-width: 576px) {
  .btn-primary-cta {
    max-width: 320px;
  }
}

.btn-lg {
  padding: 0.6875rem 1.5rem;
  font-size: 0.9375rem;
  border-radius: var(--radius-md);
}

.btn-sm {
  padding: 0.3125rem 0.875rem;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-control,
.form-select {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  padding: 0.5625rem 0.875rem;
  background-color: var(--color-surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
  outline: none;
}

.form-control-lg,
.form-select-lg {
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border-radius: var(--radius-md);
}

.form-label {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--color-text);
  margin-bottom: 0.375rem;
}

.form-text {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.input-group-text {
  background-color: var(--color-border-light);
  border: 1.5px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.9375rem;
}

/* .form-check-input's unchecked state hardcodes background-color:#fff and
   a dark rgba(0,0,0,.25) border (profile.html's toggle switches, login's
   "Remember me") - a stark white square/pill on a dark card otherwise.
   The checked state (blue fill, white check/dot) is untouched - it's
   already a solid colour, not a neutral surface, and reads fine
   unchanged in both themes. The switch's "off" knob is a flat colour
   baked into an embedded SVG background-image rather than a CSS colour
   property, so it needs its own re-encoded copy with a lighter fill
   rather than a plain override - same rgba opacity Bootstrap used,
   inverted for a dark track. */
[data-theme="dark"] .form-check-input {
  background-color: var(--color-surface);
  border-color: var(--color-border);
}
[data-theme="dark"] .form-switch .form-check-input {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%28255, 255, 255, 0.45%29'/%3e%3c/svg%3e");
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .form-check-input {
    background-color: var(--color-surface);
    border-color: var(--color-border);
  }
  html:not([data-theme="light"]) .form-switch .form-check-input {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%28255, 255, 255, 0.45%29'/%3e%3c/svg%3e");
  }
}

/* .form-range's track hardcodes background-color:#dee2e6 (the thumb
   itself is already a solid brand blue, fine unchanged) - a light grey
   bar across a dark card (add_appliance/edit_appliance's seasonal-months
   slider). */
[data-theme="dark"] .form-range::-webkit-slider-runnable-track { background-color: var(--color-border); }
[data-theme="dark"] .form-range::-moz-range-track { background-color: var(--color-border); }
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .form-range::-webkit-slider-runnable-track { background-color: var(--color-border); }
  html:not([data-theme="light"]) .form-range::-moz-range-track { background-color: var(--color-border); }
}

/* ── Alerts ─────────────────────────────────────────────────── */
/* Rectangular by default - the pill shape (border-radius:999px) used to be
   the default here, opted out of per-instance via .alert-callout-block.
   That meant every alert not explicitly updated (registration/login errors,
   /calculate, Scan & Compare, appliance forms, etc.) stayed a pill even
   after budget_planner.html/my_appliances.html were fixed - the opposite of
   "changed everywhere." Flipping the default is the actual site-wide fix;
   .alert-callout-block is now redundant (same values) but harmless where
   it's still applied, so it doesn't need removing from those templates. */
.alert {
  border-radius: var(--radius-sm) !important;
  border: none !important;
  padding: 0.875rem 1.25rem;
  font-size: 0.9rem;
  text-align: left;
}

.alert-info {
  background-color: var(--color-info-soft);
  color: #0c4a6e;
  border: 1.5px solid var(--color-info) !important;
}

.alert-success {
  background-color: var(--color-success-soft);
  color: #14532d;
  border: 1.5px solid var(--color-success) !important;
}

.alert-warning {
  background-color: var(--color-warning-soft);
  color: #78350f;
  border: 1.5px solid var(--color-warning) !important;
}

.alert-danger {
  background-color: var(--color-danger-soft);
  color: #7f1d1d;
  border: 1.5px solid var(--color-danger) !important;
}

/* Background/border above are already var(--color-*-soft)/var(--color-*),
   so they repaint for free under dark mode. The `color:` values are
   the one part that isn't token-driven - #0c4a6e etc. are dark, saturated
   text tuned to sit on a pale background, and read as barely-visible on
   this app's dark -soft tints. Reuse the same accent token already driving
   each alert's own border, rather than a fifth "alert text" token no other
   dark-mode override in this file needs. */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .alert-info    { color: var(--color-info); }
  html:not([data-theme="light"]) .alert-success { color: var(--color-success); }
  html:not([data-theme="light"]) .alert-warning { color: var(--color-warning); }
  html:not([data-theme="light"]) .alert-danger  { color: var(--color-danger); }
}

[data-theme="dark"] .alert-info    { color: var(--color-info); }
[data-theme="dark"] .alert-success { color: var(--color-success); }
[data-theme="dark"] .alert-warning { color: var(--color-warning); }
[data-theme="dark"] .alert-danger  { color: var(--color-danger); }

/* .alert-primary/.alert-light are never touched by the app's own .alert
   rule (border-radius/border/padding only) or by the four overrides
   above, so Bootstrap's own compiled versions
   (background-color:#cfe2ff/#fefefe, color:#084298/#636464) apply as-is -
   correctly, in light mode, where they were never a bug. Only dark mode
   needs a rule here, and only for these two: unlike the four above,
   these two get no *light*-mode rule to repaint automatically, so a dark
   override must replace both background and colour together, not colour
   alone. .alert-primary (trial.html's Ofgem-cap callout) gets the same
   primary/soft pairing as the other four; .alert-light
   (add_appliance/edit_appliance's seasonal-months hint) has no natural
   accent colour of its own, so it borrows the same neutral surface/border
   tokens already used for cards. */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .alert-primary {
    background-color: var(--color-primary-soft);
    color: var(--color-primary);
    border-color: var(--color-primary);
  }
  html:not([data-theme="light"]) .alert-light {
    background-color: var(--color-border-light);
    color: var(--color-text);
    border-color: var(--color-border);
  }
}
[data-theme="dark"] .alert-primary {
  background-color: var(--color-primary-soft);
  color: var(--color-primary);
  border-color: var(--color-primary);
}
[data-theme="dark"] .alert-light {
  background-color: var(--color-border-light);
  color: var(--color-text);
  border-color: var(--color-border);
}

/* ── Bootstrap utility classes ─────────────────────────────────
   .bg-light/.bg-white/.bg-secondary and .text-dark/.text-white are
   Bootstrap's own hardcoded colours, not this app's tokens - found by
   screenshotting the real dashboard/budget-planner pages in dark mode,
   not by grepping for hex codes (these aren't hex codes, they're class
   names, so the inline-style sweep elsewhere in this app's history
   could never have caught them). Left alone, a badge or panel using
   these renders as a stark white box on a dark page - not unreadable
   (dark-on-light text is still legible), but visibly broken. Fixed
   as a pair everywhere: the background moves to a dark-mode-aware
   token, and its usual .text-dark/.text-white partner moves with it so
   neither side is left mismatched against the other. */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .bg-light,
  html:not([data-theme="light"]) .bg-white     { background-color: var(--color-surface) !important; }
  html:not([data-theme="light"]) .bg-secondary { background-color: var(--color-border) !important; }
  html:not([data-theme="light"]) .text-dark    { color: var(--color-text) !important; }
  html:not([data-theme="light"]) .text-white   { color: var(--color-text) !important; }
}
[data-theme="dark"] .bg-light,
[data-theme="dark"] .bg-white     { background-color: var(--color-surface) !important; }
[data-theme="dark"] .bg-secondary { background-color: var(--color-border) !important; }
[data-theme="dark"] .text-dark    { color: var(--color-text) !important; }
[data-theme="dark"] .text-white   { color: var(--color-text) !important; }

/* ── List group (calculate.html's "Recommended Energy-Efficient
   Alternatives" cards) ──────────────────────────────────────────
   Same shape as .modal-content below: Bootstrap's compiled
   .list-group-item hardcodes background-color:#fff and color:#212529
   directly on the class (baked in at Bootstrap's own build time, not a
   CSS custom property), and .list-group-item-action hardcodes its own
   color plus hover/focus/active backgrounds on top of that - none of it
   themeable. Left alone, the card stays a white surface in dark mode
   while this app's own h1-h6{color:var(--color-text)} rule (a same-
   specificity element selector, which beats an ancestor's inherited
   colour regardless of the ancestor's higher specificity) pushes just
   the <h5> title light - a light title on a card that never goes dark,
   while the plain <p> tags have no such direct rule and just inherit
   Bootstrap's own hardcoded dark colour, staying readable, and
   .text-muted's dark-mode value (a light-medium grey, meant for a dark
   surface) reads as poor contrast against the still-white card. Fixing
   the container's background/text closes all of it at once, the same
   way .modal-content's fix did. */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .list-group-item {
    background-color: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border);
  }
  html:not([data-theme="light"]) .list-group-item-action { color: var(--color-text); }
  html:not([data-theme="light"]) .list-group-item-action:hover,
  html:not([data-theme="light"]) .list-group-item-action:focus {
    background-color: var(--color-border-light);
    color: var(--color-text);
  }
  html:not([data-theme="light"]) .list-group-item-action:active {
    background-color: var(--color-border);
    color: var(--color-text);
  }
}
[data-theme="dark"] .list-group-item {
  background-color: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}
[data-theme="dark"] .list-group-item-action { color: var(--color-text); }
[data-theme="dark"] .list-group-item-action:hover,
[data-theme="dark"] .list-group-item-action:focus {
  background-color: var(--color-border-light);
  color: var(--color-text);
}
[data-theme="dark"] .list-group-item-action:active {
  background-color: var(--color-border);
  color: var(--color-text);
}

/* The trial-page tariff callout wraps to 2-3 lines; the pill shape above
   (built for short one-liners) reads oddly with wrapped text, so it gets
   the same corner radius as the page's other cards instead. */
.alert.alert-callout-block {
  border-radius: var(--radius-sm) !important;
  text-align: left;
}

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  font-family: var(--font-sans);
  font-weight: 500;
  border-radius: 0.375rem;
  letter-spacing: 0.01em;
}

.energy-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 5px;
  font-weight: 700;
  font-size: 0.75rem;
  color: #fff;
  flex-shrink: 0;
}

.energy-badge-A { background: #16a34a; }
.energy-badge-B { background: #22c55e; }
.energy-badge-C { background: #ca8a04; }
.energy-badge-D { background: #f59e0b; }
.energy-badge-E { background: #f97316; }
.energy-badge-F { background: #ef4444; }
.energy-badge-G { background: #dc2626; }

/* ── Tables ─────────────────────────────────────────────────── */
/* Bootstrap's compiled .table rule hardcodes color:#212529 (baked in at
   Bootstrap's own build time, not a CSS custom property) - it wins over
   the inherited --color-text from body since it targets the element
   directly. Invisible in dark mode without this override: dark grey
   text on what becomes a dark card background. */
.table {
  font-size: 0.9rem;
  margin-bottom: 0;
  color: var(--color-text);
}

.table th {
  font-weight: 600;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  background: var(--color-border-light);
  border-bottom: 1px solid var(--color-border);
  padding: 0.75rem 1rem;
}

.table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--color-border-light);
  vertical-align: middle;
}

.table-hover tbody tr:hover {
  background-color: var(--color-border-light);
}

/* Bootstrap's .table-light sets --bs-table-bg:#f8f9fa and color:#000
   directly (hardcoded, not this app's tokens). A <thead class="table-light">
   is already fine in practice - .table th above beats it on both
   properties by specificity (0,1,1) vs .table-light's (0,1,0) - but this
   app also puts .table-light on a plain <tr> for one-off summary rows
   (dashboard's Budget Planner "Total planned" row), where the cells are
   <td> not <th>, so nothing else overrides it: a stark white row in an
   otherwise dark table. Rebinding the custom property flows through
   Bootstrap's own .table>:not(caption)>*>*{background-color:var(--bs-table-bg)}
   rule without needing to fight its specificity directly. */
[data-theme="dark"] .table-light {
  --bs-table-bg: var(--color-border-light);
  --bs-table-striped-bg: var(--color-border);
  --bs-table-hover-bg: var(--color-border);
  --bs-table-active-bg: var(--color-border);
  color: var(--color-text) !important;
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .table-light {
    --bs-table-bg: var(--color-border-light);
    --bs-table-striped-bg: var(--color-border);
    --bs-table-hover-bg: var(--color-border);
    --bs-table-active-bg: var(--color-border);
    color: var(--color-text) !important;
  }
}

/* ── Nav Tabs ───────────────────────────────────────────────── */
.nav-tabs {
  border-bottom: 2px solid var(--color-border);
  gap: 0.25rem;
}

.nav-tabs .nav-link {
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  margin-bottom: -2px;
  color: var(--color-text-muted);
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.625rem 1rem;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.nav-tabs .nav-link:hover {
  color: var(--color-text);
  border-bottom-color: var(--color-border);
}

.nav-tabs .nav-link.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  background: transparent;
}

/* ── Divider rows (appliance lists) ─────────────────────────── */
.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--color-border-light);
}

.list-row:last-child {
  border-bottom: none;
}

/* ── Utility classes ─────────────────────────────────────────── */
.cost-value    { color: var(--color-danger);  font-weight: 600; }
.saving-value  { color: var(--color-success); font-weight: 600; }

/* Count-up flash prevention: html.count-up-pending is set synchronously by
   an inline <head> script before first paint (base.html / shared_base.html)
   and removed by animateFinancialValues() in main.js the instant it primes
   these elements to zero, so the server-rendered value is never visible
   before the animation starts. visibility (not display) keeps layout
   stable while hidden. */
html.count-up-pending .stat-value,
html.count-up-pending .cost-value,
html.count-up-pending .saving-value,
html.count-up-pending [data-animate-value] {
    visibility: hidden;
}
.text-primary  { color: var(--color-primary) !important; }
.text-success  { color: var(--color-success) !important; }
.text-danger   { color: var(--color-danger)  !important; }
.text-warning  { color: var(--color-warning) !important; }
.text-muted    { color: var(--color-text-muted) !important; }
.text-subtle   { color: var(--color-text-subtle) !important; }
.bg-surface    { background: var(--color-surface); }
.bg-soft-blue  { background: var(--color-primary-soft); }
.bg-soft-green { background: var(--color-success-soft); }
.bg-soft-red   { background: var(--color-danger-soft); }

/* Divider with label */
.divider-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0;
  color: var(--color-text-subtle);
  font-size: 0.8125rem;
  font-weight: 500;
}

.divider-label::before,
.divider-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

/* Auth page layout */
.auth-page {
  min-height: calc(100vh - 58px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.auth-card {
  width: 100%;
  max-width: 420px;
}

.auth-brand {
  text-align: center;
  margin-bottom: 1.75rem;
}

.auth-brand .brand-mark {
  width: 48px;
  height: 48px;
  background: var(--color-primary);
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.375rem;
  margin-bottom: 0.75rem;
}

.auth-brand h1 {
  font-size: 1.375rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.auth-brand p {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin: 0;
}

/* ── Progress bar ───────────────────────────────────────────── */
.progress {
  background: var(--color-border);
  border-radius: 99px;
  height: 6px;
}

.progress-bar {
  border-radius: 99px;
}

/* ── Feather icon sizing helpers ─────────────────────────────── */
.icon-sm svg, [data-feather].icon-sm { width: 16px; height: 16px; }
.icon-md svg, [data-feather].icon-md { width: 20px; height: 20px; }
.icon-lg svg, [data-feather].icon-lg { width: 28px; height: 28px; }

/* ── Spinner ─────────────────────────────────────────────────── */
.spinner-border-sm {
  width: 1rem;
  height: 1rem;
  border-width: 2px;
}

/* ── Modal ───────────────────────────────────────────────────── */
/* Bootstrap's compiled .modal-content bakes in a hardcoded white
   background (5.1.3 predates its CSS-custom-property modal vars) - left
   alone, it stays white in dark mode while any text inside still follows
   --color-text (now light), the inverse of the soft-bg/dark-text bug
   elsewhere: light text on a permanently-white modal. */
.modal-content {
  border: none;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  background-color: var(--color-surface);
  color: var(--color-text);
}

/* .btn-close is a hardcoded black SVG (Bootstrap bakes the stroke colour
   into the icon's own data-URI, not a CSS property), so it goes near-
   invisible on any dark surface behind it - not just inside .modal. This
   app also uses .btn-close on the dismiss buttons of alert banners
   (dashboard's tariff/stale-appliance prompts, octopus/connect_form's
   flash messages) which are just as dark in dark mode as a modal is, so
   the fix applies to .btn-close everywhere, not only inside .modal.
   :not(.btn-close-white) excludes Bootstrap's own light-icon variant
   (octopus/connect_intro's banner close button) - it already inverts
   itself unconditionally in Bootstrap's own CSS, so applying this filter
   on top would invert it a second time and turn it back to black. */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .btn-close:not(.btn-close-white) { filter: invert(1) grayscale(100%) brightness(200%); }
}
[data-theme="dark"] .btn-close:not(.btn-close-white) { filter: invert(1) grayscale(100%) brightness(200%); }

.modal-header {
  border-bottom: 1px solid var(--color-border);
  padding: 1.125rem 1.5rem;
}

.modal-body {
  padding: 1.375rem 1.5rem;
}

.modal-footer {
  border-top: 1px solid var(--color-border);
  padding: 1rem 1.5rem;
}

/* ── Collapse / Accordion ────────────────────────────────────── */
.collapse-trigger {
  color: var(--color-text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
}

.collapse-trigger:hover {
  color: var(--color-text);
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .page-wrapper { padding-top: 1.25rem; padding-bottom: 2rem; }

  .card-body { padding: 1.125rem 1.25rem; }

  h1 { font-size: 1.375rem; }
  h2 { font-size: 1.25rem; }
  .page-header h1 { font-size: 1.25rem; }

  .stat-card .stat-value { font-size: 1.625rem; }

  .navbar .nav-link {
    padding: 0.625rem 0 !important;
    border-bottom: none;
    border-left: 3px solid transparent;
    padding-left: 0.75rem !important;
  }
  .navbar .nav-link.active {
    border-bottom-color: transparent;
    border-left-color: var(--color-nav-accent);
  }
}

/* ── Stat card — stacked layout on narrow mobile ─────────────── */
@media (max-width: 576px) {
  .stat-card-row {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 0.875rem 0.625rem;
    gap: 0.5rem;
  }

  .stat-card-row .stat-value {
    font-size: 1.375rem;
  }

  .stat-card-row .stat-label {
    font-size: 0.625rem;
  }

  .stat-icon-circle {
    width: 38px;
    height: 38px;
  }

  .stat-icon-circle svg {
    width: 18px;
    height: 18px;
  }
}

/* ── Motion System ───────────────────────────────────────────── */

/* Card entry */
.card-animate-ready {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity var(--motion-standard) var(--ease-out),
              transform var(--motion-standard) var(--ease-out);
}
.card-animate-ready.card-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Collapse panel fade + slide */
.collapse-fade {
  transition: opacity var(--motion-standard) var(--ease-in-out),
              transform var(--motion-standard) var(--ease-in-out);
}
.collapse-fade.collapsing-out {
  opacity: 0;
  transform: translateY(8px);
}
.collapse-fade.collapsing-in {
  opacity: 0;
  transform: translateY(10px);
}
.collapse-fade.shown-in {
  opacity: 1;
  transform: translateY(0);
}

/* Chevron rotation (managed by JS; CSS provides transition) */
.collapse-chevron {
  transition: transform var(--motion-standard) var(--ease-in-out);
}

/* Chevron rotation via aria-expanded (button-triggered collapses) */
button[aria-expanded="true"] .collapse-chevron {
  transform: rotate(180deg);
}

/* Better-option card */
.card-better-option {
  transform: scale(1.03);
  border: 2px solid var(--color-success) !important;
  box-shadow: 0 0 0 4px rgba(22,163,74,0.12),
              0 10px 20px rgba(15,23,42,0.10) !important;
  transition: transform var(--motion-standard) var(--ease-out),
              border-color var(--motion-standard) var(--ease-out),
              box-shadow var(--motion-standard) var(--ease-out);
}

/* Savings reveal (inside better-option card) */
.savings-reveal {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 250ms var(--ease-out),
              transform 250ms var(--ease-out);
}
.savings-reveal.savings-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Insight card entry */
.insight-card,
[data-insight] {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 350ms var(--ease-out),
              transform 350ms var(--ease-out);
}
.insight-card.insight-visible,
[data-insight].insight-visible {
  opacity: 1;
  transform: translateY(0);
}

/* Shimmer loading skeleton */
@keyframes shimmer-sweep {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.shimmer {
  background: linear-gradient(
    90deg,
    var(--color-border-light) 25%,
    #dde7ff 50%,
    var(--color-border-light) 75%
  );
  background-size: 800px 100%;
  animation: shimmer-sweep 600ms linear infinite;
}

/* Scan pulse */
@keyframes scan-pulse-kf {
  0%   { transform: scale(1);   opacity: 0.6; }
  50%  { transform: scale(1.1); opacity: 0.3; }
  100% { transform: scale(1);   opacity: 0; }
}
.scan-pulse {
  animation: scan-pulse-kf 200ms var(--ease-out) forwards;
}

/* High-cost pulse ring */
@keyframes cost-pulse-kf {
  0%   { box-shadow: 0 0 0 0   rgba(220,38,38,0.55); }
  60%  { box-shadow: 0 0 0 10px rgba(220,38,38,0); }
  100% { box-shadow: 0 0 0 0   rgba(220,38,38,0); }
}
.cost-pulse {
  animation: cost-pulse-kf 600ms var(--ease-out) forwards;
}

/* prefers-reduced-motion — collapse all durations to 1ms */
@media (prefers-reduced-motion: reduce) {
  .card-animate-ready,
  .collapse-fade,
  .collapse-chevron,
  .card-better-option,
  .savings-reveal,
  .insight-card,
  [data-insight],
  .shimmer,
  .scan-pulse,
  .cost-pulse {
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
  }

  /* Bootstrap collapse height animation */
  .collapsing {
    transition-duration: 1ms !important;
  }

  /* Any remaining inline CSS transitions on buttons / chevrons */
  .btn,
  .collapse-chevron {
    transition-duration: 1ms !important;
  }
}

/* ── Info popover (wyw-info-btn / wyw-info-popover) ─────────── */

.wyw-info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: none;
  border: 1.5px solid var(--color-text-subtle, #6b7280);
  color: var(--color-text-subtle, #6b7280);
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background var(--motion-micro, 120ms) var(--ease-out, ease-out),
              color      var(--motion-micro, 120ms) var(--ease-out, ease-out);
}
.wyw-info-btn:hover,
.wyw-info-btn:focus-visible {
  background: var(--color-text-subtle, #6b7280);
  color: #fff;
  outline: none;
}
/* Slightly larger when used standalone (e.g. under gauge) */
.wyw-info-btn.wyw-info-btn--lg {
  width: 18px;
  height: 18px;
  font-size: 0.7rem;
}

.wyw-info-popover {
  display: none;
  position: fixed; /* coordinates set by JS via getBoundingClientRect */
  z-index: 1060;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  font-size: 0.77rem;
  line-height: 1.55;
  max-width: 290px;
  min-width: 220px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.10);
  cursor: default;
}
.wyw-info-popover.is-open {
  display: block;
}
@media (prefers-reduced-motion: no-preference) {
  .wyw-info-popover.is-open {
    animation: popoverIn var(--motion-micro, 120ms) var(--ease-out, ease-out) both;
  }
  @keyframes popoverIn {
    from { opacity: 0; transform: scale(0.95) translateY(-3px); }
    to   { opacity: 1; transform: scale(1)    translateY(0);    }
  }
}

/* This app's own custom colours, not Bootstrap's - same bug shape as the
   Bootstrap sweep (c9d1b1a) though: hardcoded hex baked directly into
   this rule rather than a var(--color-*) token, so it never repaints
   under dark mode. Base rule (light) is untouched; dark gets its own
   background/border/text, and its own box-shadow rather than reusing
   --shadow-* - a soft light-mode shadow tuned to sit on a pale page
   reads as barely-there on an already-dark one, so this uses a stronger
   blue-tinted glow instead, which actually shows up against a dark
   surface the same way the light-mode blue tint shows against white. */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .wyw-info-popover {
    background: var(--color-primary-soft);
    border-color: var(--color-primary);
    color: var(--color-text);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  }
}
[data-theme="dark"] .wyw-info-popover {
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
  color: var(--color-text);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* ── Guided help tour (WYWTour, static/js/tour.js) ─────────────
   One JS component reused on every page that has a help tour
   (dashboard, budget planner, my-appliances, add/edit-appliance,
   appliance-detail, profile, compare-products, calculate) - every step
   on every page shares this one card, so fixing it here fixes all of
   them at once. Same bug shape as .wyw-info-popover above: custom hex
   colours set via inline style.cssText in tour.js, never touched by any
   CSS token. Moved out of the inline styles into these classes so dark
   mode can reach them; light-mode values below are unchanged from what
   tour.js used to set inline. The close "x" is a plain text glyph (not
   an SVG background-image like .btn-close), so a colour override is
   enough - no filter/invert needed. There's no arrow/caret/pointer in
   this markup - it's a plain fixed-position card, not a Bootstrap
   popover with a directional connector, so there's nothing to fix there.
   "Next"'s solid blue button is left alone, same as any other solid
   brand-coloured button - correct unchanged in both themes. */
.wyw-tour-card {
  background: #ffffff;
  border: 1.5px solid #bfdbfe;
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.18), 0 1px 4px rgba(0, 0, 0, 0.08);
}
.wyw-tour-badge {
  background: #eff6ff;
  color: #1d4ed8;
}
.wyw-tour-close {
  color: #94a3b8;
}
.wyw-tour-text {
  color: #1e293b;
}
.wyw-tour-divider {
  border-bottom: 1px solid #e2e8f0;
}
.wyw-tour-settings-link {
  color: #2563eb;
}
.wyw-tour-prev {
  border: 1.5px solid #bfdbfe;
  color: #2563eb;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .wyw-tour-card {
    background: var(--color-surface);
    border-color: var(--color-primary);
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.25), 0 2px 8px rgba(0, 0, 0, 0.45);
  }
  html:not([data-theme="light"]) .wyw-tour-badge {
    background: var(--color-primary-soft);
    color: var(--color-primary);
  }
  html:not([data-theme="light"]) .wyw-tour-close { color: var(--color-text-muted); }
  html:not([data-theme="light"]) .wyw-tour-text  { color: var(--color-text); }
  html:not([data-theme="light"]) .wyw-tour-divider { border-bottom-color: var(--color-border); }
  html:not([data-theme="light"]) .wyw-tour-settings-link { color: var(--color-primary); }
  html:not([data-theme="light"]) .wyw-tour-prev {
    border-color: var(--color-primary);
    color: var(--color-primary);
  }
}
[data-theme="dark"] .wyw-tour-card {
  background: var(--color-surface);
  border-color: var(--color-primary);
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.25), 0 2px 8px rgba(0, 0, 0, 0.45);
}
[data-theme="dark"] .wyw-tour-badge {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}
[data-theme="dark"] .wyw-tour-close { color: var(--color-text-muted); }
[data-theme="dark"] .wyw-tour-text  { color: var(--color-text); }
[data-theme="dark"] .wyw-tour-divider { border-bottom-color: var(--color-border); }
[data-theme="dark"] .wyw-tour-settings-link { color: var(--color-primary); }
[data-theme="dark"] .wyw-tour-prev {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

/* ── Swipe-back coach mark (shared_compare.html) ────────────────
   A once-per-session hint shown to a logged-in user on a shared
   comparison link, same hardcoded-white-panel shape as the two above. */
.wyw-swipe-hint-panel {
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .wyw-swipe-hint-panel {
    background: rgba(30, 41, 59, 0.92);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  }
}
[data-theme="dark"] .wyw-swipe-hint-panel {
  background: rgba(30, 41, 59, 0.92);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}

/* ── Collapse chevrons — visual only, parent row is the click target ── */
.collapse-chevron {
  pointer-events: none; /* clicks pass through to the parent trigger */
}

/* ── Compare page — clickable card header ────────────────────── */
.compare-jump-header {
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.compare-jump-header:hover {
  background: rgba(37, 99, 235, 0.06) !important;
  box-shadow: inset 0 -2px 0 rgba(37, 99, 235, 0.25);
}
/* Winner header hover keeps the green tint, just darkens slightly */
.compare-jump-header.compare-jump-winner:hover {
  background: #bbf7d0 !important;
  box-shadow: inset 0 -2px 0 #16a34a55;
}
.compare-jump-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #2563eb;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 20px;
  padding: 2px 9px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  pointer-events: none; /* header itself is the click target */
}
.compare-jump-header:hover .compare-jump-pill {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

/* ── Scroll-down arrow ───────────────────────────────────────── */
#scroll-arrow {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  border: 1.5px solid var(--color-border);
  color: var(--color-text-muted);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms ease, transform 250ms ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
#scroll-arrow.visible {
  opacity: 1;
  pointer-events: auto;
}
#scroll-arrow:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
  transform: translateX(-50%) translateY(2px);
}
@media (prefers-reduced-motion: reduce) {
  #scroll-arrow { transition: opacity 100ms linear; }
  #scroll-arrow:hover { transform: translateX(-50%); }
}

/* ── Quick Action cards (dashboard) ─────────────────────────── */
.quick-action-card {
  transition: box-shadow 0.15s ease, transform 0.15s ease, background-color 0.15s ease;
}
.quick-action-card:hover,
.quick-action-card:focus-visible {
  box-shadow: 0 4px 14px rgba(0,0,0,0.11);
  transform: translateY(-2px);
  background-color: #f0f7ff;
  outline: none;
  text-decoration: none;
}
.quick-action-card:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

/* ── Appliance register card links ──────────────────────────── */
.appliance-card-link {
  display: block;
  transition: box-shadow 0.18s ease, transform 0.18s ease, background-color 0.18s ease;
}
.appliance-card-link:hover,
.appliance-card-link:focus-visible {
  box-shadow: 0 6px 20px rgba(0,0,0,0.13);
  transform: translateY(-2px);
  background-color: #f0f7ff;
  outline: none;
  text-decoration: none;
}
.appliance-card-link:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  background-color: #e8f2ff;
}
.appliance-card-link .appliance-card-chevron {
  transition: transform 0.18s ease;
  flex-shrink: 0;
}
.appliance-card-link:hover .appliance-card-chevron,
.appliance-card-link:focus-visible .appliance-card-chevron {
  transform: translateX(5px);
}
@media (prefers-reduced-motion: reduce) {
  .appliance-card-link,
  .appliance-card-link .appliance-card-chevron { transition: box-shadow 100ms linear; }
  .appliance-card-link:hover,
  .appliance-card-link:focus-visible { transform: none; }
  .appliance-card-link:hover .appliance-card-chevron,
  .appliance-card-link:focus-visible .appliance-card-chevron { transform: none; }
}

/* ── PWA Install Prompts (iOS + Android) ─────────────────────── */
.wyw-install-prompt {
  display: none;
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: 1.5rem;
  max-width: 480px;
  margin: 0 auto;
  background: #0f172a;
  color: #f1f5f9;
  border-radius: 1rem;
  padding: 1rem 2.5rem 1rem 1.25rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
  box-shadow: 0 8px 32px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.2);
  z-index: 1060;
  font-size: 0.875rem;
}
.wyw-install-prompt--visible {
  display: block;
  animation: wyw-prompt-slidein 0.38s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes wyw-prompt-slidein {
  from { transform: translateY(120%); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}
.wyw-install-prompt-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.2rem;
  color: #ffffff;
}
.wyw-install-prompt-body {
  color: #94a3b8;
  font-size: 0.82rem;
  line-height: 1.45;
}
.wyw-install-prompt-body strong {
  color: #cbd5e1;
}
.wyw-install-prompt-close {
  position: absolute;
  top: 0.5rem;
  right: 0.625rem;
  background: none;
  border: none;
  color: #475569;
  font-size: 1.375rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem 0.375rem;
  border-radius: 0.375rem;
  transition: color 0.15s ease, background 0.15s ease;
}
.wyw-install-prompt-close:hover {
  color: #cbd5e1;
  background: rgba(255,255,255,0.08);
}
.wyw-install-prompt-btn {
  display: inline-block;
  background: #f97316;
  color: #fff;
  border: none;
  border-radius: 0.5rem;
  padding: 0.4375rem 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s ease;
}
.wyw-install-prompt-btn:hover { background: #ea6c0a; }
/* iOS — downward arrow pointing at the Safari toolbar */
#ios-install-prompt .wyw-install-prompt-arrow {
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 11px solid transparent;
  border-right: 11px solid transparent;
  border-top: 11px solid #0f172a;
}
@media (prefers-reduced-motion: reduce) {
  .wyw-install-prompt--visible { animation: none; }
}

/* ── Print ───────────────────────────────────────────────────── */
@media print {
  .navbar, .btn, .alert { display: none !important; }
  .card { box-shadow: none; border: 1px solid #ccc; }
  #scroll-arrow { display: none !important; }
}

/* ── Flash alert slide animations ───────────────────────────────────────── */
@keyframes flashSlideIn {
  from { opacity: 0; transform: translateY(-18px); }
  to   { opacity: 1; transform: translateY(0); }
}

  to   { opacity: 0; transform: translateY(-18px); max-height: 0;    margin-bottom: 0;    padding: 0; }
}
.flash-alert {
  animation: flashSlideIn 0.35s ease forwards;
  overflow: hidden;
}
.flash-alert-out { pointer-events: none; }

/* ── Link tap feedback (mobile) ─────────────────────────────── */
a:not(.btn):not(.appliance-card-link):not(.quick-action-card):not(.nav-link):not(.navbar-brand):not([class*="card"]):active {
  opacity: 0.45;
  color: #1d4ed8;
}

/* ── Page navigation loader ──────────────────────────────────── */
#page-loader {
  position: fixed;
  bottom: 18px;
  right: 18px;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  z-index: 9990;
}
#page-loader.page-loader--visible {
  opacity: 1;
  animation: loaderPulse 0.75s ease-in-out infinite;
}
@keyframes loaderPulse {
  0%, 100% { transform: scale(1);    opacity: 1;   }
  50%       { transform: scale(0.8); opacity: 0.5; }
}
