/* ===========================================================================
   Inergy Monitor — design tokens + app shell.
   Phone-first dashboard; the centred column stays phone-width on desktop.
   =========================================================================== */
:root {
    /* Eco-forward palette: green = conservation/primary, Inergy orange = brand/solar.
       Derived from the Inergy Systems logo (orange + charcoal) with natural greens. */
    --bg:          #EFF3EC;   /* soft natural paper */
    --surface:     #FFFFFF;
    --surface-2:   #F3F7F0;
    --line:        #E1E8DD;

    --ink:         #1C2622;   /* deep charcoal-green */
    --ink-2:       #45544C;
    --muted:       #5F6E64;   /* darkened to meet WCAG AA (~4.8:1) on the light surfaces */

    --brand:       #F26522;   /* Inergy orange (logo) */

    --accent:      #15815A;   /* eco green — demand / primary data */
    --accent-weak: #DAEEE3;
    --usage:       #2F6FA8;   /* kWh usage (blue) */
    --solar:       #F26522;   /* solar = brand orange */

    --ok:          #2E9E6B;
    --warn:        #E0A100;
    --alert:       #D6453D;
    --alert-weak:  #FBEAE8;

    /* theme-sensitive surfaces (overridden under [data-theme="dark"]) */
    --accent-strong: #0F6A49;            /* primary-button hover */
    --bar-bg:     rgba(255,255,255,.86); /* frosted app/tab bars */
    --solar-weak: #FDE7DB;               /* solar pill / solar flow node bg */
    --solar-ink:  #B2440F;               /* solar pill text */
    --grid-weak:  #E7EEF6;               /* grid flow node bg */
    --battery:      #2A9D8F;             /* battery flow colour (teal) */
    --battery-weak: #D8EFEC;             /* battery flow node bg */
    --desktop-bg: #E6ECE2;               /* page gutter on wide screens */
    --scrim:      rgba(16,26,36,.18);    /* modal/sheet backdrop */

    /* schedule periods by time of day (night → dawn/dusk → midday → dusk → night) */
    --per-night: #3A4A6B;                /* periods 1 & 5 — night */
    --per-edge:  #E08A3C;                /* periods 2 & 4 — morning / evening */
    --per-day:   #3E9FD0;                /* period 3 — daytime */
    --frost:     rgba(243, 247, 240, .6); /* frosted overlay (e.g. shed thermostat) */
    color-scheme: light;

    --r:   16px;
    --r-sm: 11px;
    --shadow: 0 1px 2px rgba(16,26,36,.06), 0 8px 24px rgba(16,26,36,.05);

    --font-body:    'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    --font-display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
}

/* --- dark theme (preference persisted to localStorage; see index.html boot) --- */
[data-theme="dark"] {
    color-scheme: dark;

    --bg:          #0F1714;
    --surface:     #18211D;
    --surface-2:   #1F2A25;
    --line:        #2C3833;

    --ink:         #ECF1ED;
    --ink-2:       #B4C2BA;
    --muted:       #889A91;

    --brand:       #FF7A3C;

    --accent:        #2DBE86;
    --accent-weak:   #133A2B;
    --accent-strong: #25A874;
    --usage:         #5AA0DA;
    --solar:         #FF7A3C;

    --ok:          #34B97E;
    --warn:        #E8B526;
    --alert:       #F26B62;
    --alert-weak:  #3A1F1D;

    --bar-bg:     rgba(18,25,22,.82);
    --solar-weak: #3A2417;
    --solar-ink:  #FF9A6B;
    --grid-weak:  #15242F;
    --battery:      #3FC4B4;
    --battery-weak: #123230;
    --desktop-bg: #0A100E;
    --scrim:      rgba(0,0,0,.45);

    --per-night: #47588A;                /* lifted so night reads on the dark strip */
    --per-edge:  #E89A50;
    --per-day:   #52ACDD;
    --frost:     rgba(24, 33, 29, .6);

    --shadow: 0 1px 2px rgba(0,0,0,.30), 0 8px 24px rgba(0,0,0,.36);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

#app { display: block; min-height: 100%; }

.boot { padding: 64px 20px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; color: var(--muted); }

/* --- shell ---------------------------------------------------------------- */
.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;      /* fallback */
    height: 100dvh;
    max-width: 560px;
    margin: 0 auto;
    background: var(--bg);
    position: relative;
}

.app-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
    background: var(--bar-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; }
.brand-logo { height: 24px; width: auto; display: block; }
.brand-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -.01em;
}

.app-bar-loc { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.loc-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.loc-time { font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); animation: pulse 2.4s ease-out infinite; }

.app-main {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px 16px calc(env(safe-area-inset-bottom) + 88px);
}

.tab-bar {
    position: sticky;
    bottom: 0;
    z-index: 10;
    display: flex;
    background: var(--bar-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
    padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px);
}
.tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 7px 0;
    color: var(--muted);
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
    border-radius: 12px;
    transition: color .15s ease;
}
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--accent); }

/* --- cards & primitives --------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 16px;
    box-shadow: var(--shadow);
}
.card-head { margin-bottom: 10px; }
.eyebrow {
    font-family: var(--font-display);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
}
.muted { color: var(--muted); font-size: 13px; margin: 0; }
.notice { color: var(--alert); border-color: var(--alert); background: var(--alert-weak); }
.skeleton { color: var(--muted); text-align: center; padding: 28px 16px; }

.page-title {
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 2px 2px -4px;
}

.status-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid transparent;
}
.pill-off   { background: var(--accent-weak); color: var(--accent); }
.pill-peak  { background: var(--alert-weak);  color: var(--alert); }
.pill-solar { background: var(--solar-weak);  color: var(--solar-ink); }

/* --- gauge (signature) ---------------------------------------------------- */
.gauge-card { display: flex; flex-direction: column; align-items: center; padding: 18px 16px 14px; }
.gauge-wrap { width: 100%; max-width: 340px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.gauge { width: 100%; height: auto; display: block; }

.g-seg { fill: none; stroke-linecap: round; stroke-width: 14; }
.g-track { stroke: var(--line); }
.g-ok    { stroke: var(--ok); }
.g-warn  { stroke: var(--warn); }
.g-alert { stroke: var(--alert); }
.g-limit { stroke: var(--ink); stroke-width: 2.5; stroke-linecap: round; }
.g-limit-label { fill: var(--muted); font-family: var(--font-display); font-size: 9px; font-weight: 700; letter-spacing: .14em; }
.g-needle { stroke: var(--ink); stroke-width: 3.5; stroke-linecap: round; }
.g-hub { fill: var(--ink); }
.g-value { fill: var(--ink); font-family: var(--font-display); font-size: 34px; font-weight: 700; letter-spacing: -.02em; }
.g-unit { fill: var(--muted); font-family: var(--font-display); font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.g-end { fill: var(--muted); font-family: var(--font-display); font-size: 10px; }

.gauge-meta { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; }
.gm-limit { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.gm-flag { font-size: 12px; font-weight: 700; color: #fff; background: var(--alert); padding: 4px 11px; border-radius: 999px; animation: flash 1.1s ease-in-out infinite; }
.is-exceeded .g-value { fill: var(--alert); }

/* --- stat grid ------------------------------------------------------------ */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    box-shadow: var(--shadow);
}
.stat-label { font-size: 11px; color: var(--muted); font-weight: 600; }
.stat-value {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -.01em;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    display: flex;
    align-items: baseline;
    gap: 4px;
}
.stat-unit { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat-sub { font-size: 11px; color: var(--muted); }
.stat.is-accent .stat-value { color: var(--accent); }
.stat.is-solar  .stat-value { color: var(--solar); }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat-ico { flex: none; color: var(--muted); opacity: .85; }
.stat-ico svg { width: 18px; height: 18px; display: block; }
.stat.is-accent .stat-ico { color: var(--accent); opacity: 1; }
.stat.is-solar  .stat-ico { color: var(--solar); opacity: 1; }

/* --- major loads ---------------------------------------------------------- */
.loads { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.load { display: grid; grid-template-columns: 92px 1fr auto; align-items: center; gap: 10px; }
.load-name { font-size: 13px; color: var(--ink-2); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.load-track { height: 8px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.load-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--ok)); border-radius: 999px; min-width: 2px; transition: width .4s ease; }
.load-fill.is-mid  { background: var(--warn); }
.load-fill.is-high { background: var(--alert); }
.load-val { font-family: var(--font-display); font-size: 13px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.u { color: var(--muted); font-weight: 600; font-size: 11px; margin-left: 2px; }

/* --- notifications -------------------------------------------------------- */
.empty-note { color: var(--muted); text-align: center; padding: 18px 8px; margin: 0; }
.notif-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.notif {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px;
    align-items: start;
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 3px solid var(--line);
    border-radius: var(--r-sm);
    padding: 11px 13px;
    box-shadow: var(--shadow);
}
.notif.is-warning { border-left-color: var(--warn); }
.notif.is-alert   { border-left-color: var(--alert); }
.notif-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; background: var(--usage); }
.notif.is-warning .notif-dot { background: var(--warn); }
.notif.is-alert   .notif-dot { background: var(--alert); }
/* Colour-by-type: off-peak (green), on-peak / shedding (orange), demand & limit (red). */
.notif.kind-offpeak  { border-left-color: var(--ok); }
.notif.kind-offpeak  .notif-dot { background: var(--ok); }
.notif.kind-onpeak   { border-left-color: var(--solar); }
.notif.kind-onpeak   .notif-dot { background: var(--solar); }
.notif.kind-shedding { border-left-color: var(--solar); }
.notif.kind-shedding .notif-dot { background: var(--solar); }
.notif.kind-alert    { border-left-color: var(--alert); }
.notif.kind-alert    .notif-dot { background: var(--alert); }
.notif-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif-msg { font-size: 13px; color: var(--ink); line-height: 1.4; overflow-wrap: anywhere; }
.notif-time { font-size: 11px; color: var(--muted); }

/* --- billing -------------------------------------------------------------- */
.section-eyebrow { display: block; margin: 6px 2px 0; }
.load-fill.is-usage { background: var(--usage); }
.cost-total {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
    padding-top: 9px;
    border-top: 1px solid var(--line);
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--ink);
}

/* --- energy-flow diagram (panel-centric) ---------------------------------- */
.flow-diagram svg { width: 100%; height: auto; display: block; }
.flow-line { fill: none; stroke-linecap: butt; stroke-dasharray: 5 6; animation: flow-move .9s linear infinite; }
.flow-line.is-solar   { stroke: var(--solar); }
.flow-line.is-grid    { stroke: var(--usage); }
.flow-line.is-battery { stroke: var(--battery); }
.flow-line.is-home    { stroke: var(--accent); }
.flow-line.is-idle    { animation: none; opacity: .3; }   /* no flow: static, faint */
.flow-line.is-missing { display: none; }                  /* source not installed: no connector */
.node-bg { stroke-width: 2; }
.flow-icon { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.flow-node.is-solar   .node-bg { fill: var(--solar-weak); stroke: var(--solar); }
.flow-node.is-solar   .flow-icon { stroke: var(--solar); }
.flow-node.is-grid    .node-bg { fill: var(--grid-weak); stroke: var(--usage); }
.flow-node.is-grid    .flow-icon { stroke: var(--usage); }
.flow-node.is-battery .node-bg { fill: var(--battery-weak); stroke: var(--battery); }
.flow-node.is-battery .flow-icon { stroke: var(--battery); }
.flow-node.is-home    .node-bg { fill: var(--accent-weak); stroke: var(--accent); }
.flow-node.is-home    .flow-icon { stroke: var(--accent); }
.flow-node.is-panel   .node-bg { fill: var(--surface-2); stroke: var(--ink-2); }
.flow-node.is-panel   .flow-icon { stroke: var(--ink-2); }
/* source not installed: greyed-out node */
.flow-node.is-missing .node-bg { fill: var(--surface-2); stroke: var(--line); }
.flow-node.is-missing .flow-icon { stroke: var(--muted); opacity: .5; }
.flow-node.is-missing .flow-batt-fill { display: none; }
.flow-batt-fill { fill: var(--battery); stroke: none; }
.flow-node-label { font-family: var(--font-display); font-size: 12px; font-weight: 700; fill: var(--ink); }
/* the hub label sits over its connector — knock it out with a surface-coloured halo */
.flow-node-label.is-hub { paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.flow-node-value { font-family: var(--font-display); font-size: 11px; font-weight: 700; fill: var(--ink-2); }
.flow-node-value.is-muted { fill: var(--muted); font-weight: 600; }
.flow-node-state { font-family: var(--font-body); font-size: 9.5px; font-weight: 600; fill: var(--muted); }
/* edge label + home total — used by the Solar page's grid/solar/home diagram */
.flow-edge-label { font-family: var(--font-display); font-size: 11px; font-weight: 700; fill: var(--ink-2); }
.flow-node-total { font-family: var(--font-display); font-size: 11px; font-weight: 700; fill: var(--muted); }
@keyframes flow-move { to { stroke-dashoffset: -11; } }

/* --- lifetime savings hero (Now) ------------------------------------------ */
.savings-card { display: flex; align-items: center; gap: 14px; background: var(--accent-weak); border-color: var(--accent); }
.savings-ico { flex: none; width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; color: var(--accent); background: var(--surface); border-radius: 50%; box-shadow: var(--shadow); }
.savings-ico svg { width: 26px; height: 26px; }
.savings-label { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.savings-sub { font-size: 11px; font-weight: 500; color: var(--muted); }
.savings-value { flex: none; font-family: var(--font-display); font-size: 30px; font-weight: 700; color: var(--accent); line-height: 1; letter-spacing: -.01em; }

/* --- upcoming weather strip (solar) --------------------------------------- */
.weather { display: flex; gap: 8px; justify-content: space-between; }
.wx {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
}
.wx-day { font-size: 12px; font-weight: 700; color: var(--ink); }
.wx-cond { font-size: 10px; color: var(--muted); text-align: center; }
.wx-temp { font-family: var(--font-display); font-size: 14px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.wx-lo { color: var(--muted); font-weight: 500; margin-left: 4px; }

/* --- segmented control ---------------------------------------------------- */
.segmented { display: inline-flex; width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg {
    flex: 1;
    border: none;
    background: transparent;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-2);
    padding: 8px 6px;
    border-radius: 9px;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}
.seg.is-active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }

/* --- charts --------------------------------------------------------------- */
.chart-card { padding: 14px; }
.chart { width: 100%; height: 330px; }
.chart-note { font-size: 11px; color: var(--muted); margin: 10px 2px 0; line-height: 1.4; }

/* full-screen chart (full-viewport overlay + a button to return) */
.chart-fs-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chart-fs-btn { width: 30px; height: 30px; }
.chart-fs-btn svg { width: 17px; height: 17px; }
.chart-fs.is-full {
    position: fixed;
    inset: 0;
    z-index: 60;
    margin: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    padding: calc(env(safe-area-inset-top) + 12px) 14px calc(env(safe-area-inset-bottom) + 14px);
}
.chart-fs.is-full .chart { flex: 1; height: auto; min-height: 0; }
.apexcharts-text, .apexcharts-legend-text { font-family: var(--font-body) !important; }
.apexcharts-yaxis-title-text, .apexcharts-xaxis-title-text { font-family: var(--font-display) !important; }

/* custom chart tooltip (thermal range + mean) */
.apx-tt { padding: 7px 10px; font-size: 12px; font-family: var(--font-body); color: var(--ink); }
.apx-tt-hdr { color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.apx-tt-row { display: flex; align-items: center; gap: 6px; line-height: 1.7; }
.apx-tt-mark { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.apx-tt-name { color: var(--ink-2); }
.apx-tt-row b { font-variant-numeric: tabular-nums; }

/* --- auth / login --------------------------------------------------------- */
.auth-shell {
    min-height: 100vh;      /* fallback */
    min-height: 100dvh;
    max-width: 560px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 18px calc(env(safe-area-inset-bottom) + 24px);
}
.auth-main { width: 100%; max-width: 380px; }
.auth-card { display: flex; flex-direction: column; gap: 2px; padding: 24px 22px; }
/* secondary action under an auth form ("Forgot your password?", "Resend code") */
.auth-alt-link { display: block; width: 100%; margin-top: 12px; padding: 4px; background: none; border: none; text-align: center; font-size: 13px; font-weight: 600; color: var(--accent); text-decoration: none; cursor: pointer; }
.auth-alt-link:hover { text-decoration: underline; }
.auth-alt-link:disabled { opacity: .5; cursor: default; }
.settings-support { text-align: center; font-size: 13px; color: var(--muted); margin: 18px 2px 8px; line-height: 1.45; }
.settings-support a { color: var(--accent); font-weight: 600; }

/* controller-offline gate: device ⟍ broken dashed link ⟍ cloud */
.offline-art { display: flex; justify-content: center; margin: 4px 0 10px; }
.offline-art svg { width: 210px; height: auto; }
.offline-device { fill: var(--surface-2); stroke: var(--ink-2); stroke-width: 1; }
.offline-device-detail { fill: none; stroke: var(--ink-2); stroke-width: 1; stroke-linecap: round; }
.offline-cloud { fill: var(--surface-2); stroke: var(--muted); stroke-width: .9; stroke-linejoin: round; }
.offline-link { fill: none; stroke: var(--muted); stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 2 7; opacity: .8; }
.offline-alert-bg { fill: var(--warn); }
.offline-alert-mark { fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; }
.offline-alert-dot { fill: #fff; }

/* subscription-expired gate (reuses the auth-card shell) */
.gate-help { text-align: center; font-size: 12px; color: var(--muted); margin: 14px 0 0; line-height: 1.45; }
.gate-help a { color: var(--accent); font-weight: 600; }
.gate-icon { display: flex; justify-content: center; color: var(--warn); margin: 2px 0 6px; }
.gate-icon svg { width: 40px; height: 40px; }
.gate-msg { margin-bottom: 6px; }
.gate-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
a.btn-primary { display: block; text-align: center; text-decoration: none; box-sizing: border-box; }
.gate-signout { background: none; border: none; color: var(--muted); font-size: 13px; cursor: pointer; padding: 6px; }
.gate-signout:hover { color: var(--ink-2); text-decoration: underline; }
.auth-brand { display: flex; justify-content: center; margin-bottom: 14px; }
.auth-logo { height: 48px; width: auto; display: block; }

/* Theme-aware logo swap: the dark-theme wordmark has light text. Rules sit after
   .brand-logo/.auth-logo so the default-hide wins by source order. */
.logo-dark { display: none; }
[data-theme="dark"] .logo-light { display: none; }
[data-theme="dark"] .logo-dark { display: block; }
.auth-title { font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: -.01em; margin: 4px 0 0; text-align: center; }
.auth-sub { color: var(--muted); font-size: 13px; margin: 0 0 14px; text-align: center; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.input {
    font-family: var(--font-body);
    font-size: 15px;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface-2);
    color: var(--ink);
    width: 100%;
}
.input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.input:disabled { opacity: .6; }

.auth-error {
    background: var(--alert-weak);
    color: var(--alert);
    border: 1px solid var(--alert);
    border-radius: var(--r-sm);
    padding: 9px 12px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 12px;
}

.btn-primary {
    width: 100%;
    border: none;
    background: var(--accent);
    color: #fff;
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 600;
    padding: 12px 16px;
    border-radius: var(--r-sm);
    cursor: pointer;
    margin-top: 2px;
    transition: background .15s ease, opacity .15s ease;
}
.btn-primary:hover { background: var(--accent-strong); }
.btn-primary:disabled { opacity: .55; cursor: default; }
.btn-primary.btn-danger { background: var(--alert); }
.btn-primary.btn-danger:hover { background: var(--alert); filter: brightness(.94); }
.btn-secondary {
    width: 100%;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 600;
    padding: 12px 16px;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: border-color .15s ease, color .15s ease;
}
.btn-secondary:hover { border-color: var(--ink-2); }

/* --- modal / confirmation dialog ------------------------------------------ */
.modal-backdrop { position: fixed; inset: 0; z-index: 39; background: var(--scrim); }
.modal {
    position: fixed;
    z-index: 40;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(92%, 440px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: 0 14px 44px rgba(16,26,36,.28);
    padding: 20px 18px 16px;
}
.modal:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.modal-title { font-family: var(--font-display); font-size: 18px; font-weight: 700; color: var(--ink); margin: 0 0 8px; }
.modal-body { font-size: 14px; color: var(--ink-2); line-height: 1.5; margin-bottom: 18px; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-actions.single { grid-template-columns: 1fr; }

/* logout affordance in the app bar */
.app-bar-right { display: flex; align-items: center; gap: 10px; }
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px; height: 34px;
    flex: none;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-2);
    border-radius: 10px;
    cursor: pointer;
    transition: color .15s ease, border-color .15s ease;
}
.icon-btn:hover { color: var(--alert); border-color: var(--alert); }
.icon-btn-plain:hover { color: var(--accent); border-color: var(--accent); }
.icon-btn svg { width: 18px; height: 18px; }

/* non-blocking "reconnecting" hint (stale data on screen, last refresh failed) */
.reconnect {
    background: var(--warn);
    color: #3a2c00;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    padding: 6px 14px;
}

/* brief "Refreshing…" hint shown when the app refreshes on returning to the foreground */
.refreshing {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    background: var(--accent-weak);
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    padding: 6px 14px;
}
.refreshing-dot {
    width: 9px;
    height: 9px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: ptr-spin .7s linear infinite;
}

/* --- control -------------------------------------------------------------- */
.readonly-note { color: var(--ink-2); font-size: 13px; background: var(--surface-2); }
.ctl-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.ctl-row:first-of-type { border-top: none; }
.ctl-label { font-size: 13px; color: var(--ink-2); font-weight: 600; }
.ctl-select { width: auto; min-width: 132px; max-width: 60%; }

.tstat { display: flex; flex-direction: column; gap: 10px; position: relative; overflow: hidden; }
.tstat-head { display: flex; align-items: baseline; justify-content: space-between; }
.tstat-name { font-weight: 700; font-size: 15px; display: inline-flex; align-items: center; gap: 7px; }
.tstat-now { font-size: 13px; color: var(--muted); }
.tstat-now b { font-family: var(--font-display); font-size: 20px; color: var(--ink); font-weight: 700; }
.tstat-edit { display: flex; flex-direction: column; gap: 12px; }
.tstat-shed {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    padding: 16px;
    background: var(--frost);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}
.tstat-shed svg { width: 26px; height: 26px; color: var(--warn); }
.tstat-shed-text { font-size: 13px; font-weight: 500; color: var(--ink); max-width: 34ch; margin: 0; }
.link-btn {
    align-self: flex-start;
    background: none;
    border: none;
    padding: 4px 2px;
    color: var(--accent);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }
.link-btn:disabled { opacity: .5; cursor: default; text-decoration: none; }
.tstat-update { margin-top: 4px; }
.ctl-ico { width: 18px; height: 18px; flex: none; color: var(--accent); }
.tstat-mode { font-size: 12px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
.tstat-temps { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.tstat-cur { display: flex; align-items: baseline; gap: 5px; }
.tstat-cur-val { font-family: var(--font-display); font-size: 30px; font-weight: 700; color: var(--ink); }
.tstat-cur-unit { font-size: 12px; color: var(--muted); }
.tstat-set { display: flex; flex-direction: column; gap: 2px; text-align: right; }
.tstat-set-item { font-size: 13px; color: var(--ink-2); }

.badge-row { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.badge.is-shed { background: var(--alert-weak); color: var(--alert); }
.badge.is-override { background: var(--accent-weak); color: var(--accent); }

.switch-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.switch-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 11px 13px; box-shadow: var(--shadow); }
.switch-info { display: flex; align-items: center; gap: 8px; min-width: 0; }
.switch-name { font-size: 14px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.switch-load { font-family: var(--font-display); font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* read-only on/off toggle */
.toggle { display: inline-block; position: relative; width: 38px; height: 22px; border-radius: 999px; background: var(--line); flex: none; transition: background .15s ease; }
.toggle.is-on { background: var(--accent); }
.toggle-knob { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(16,26,36,.25); transition: left .15s ease; }
.toggle.is-on .toggle-knob { left: 19px; }
/* interactive variant of the on/off toggle (button role="switch") */
.toggle-btn { border: none; padding: 0; cursor: pointer; }
.toggle-btn:disabled { opacity: .5; cursor: default; }
.ctl-switch { display: inline-flex; align-items: center; gap: 10px; }
.ctl-state { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.ctl-help { font-size: 12px; color: var(--muted); margin: 6px 2px 0; line-height: 1.4; }

/* --- bottom-nav "More" overflow ------------------------------------------- */
button.tab { background: none; border: none; cursor: pointer; font-family: inherit; }
.more-backdrop { position: fixed; inset: 0; z-index: 19; background: var(--scrim); }
.more-sheet {
    position: fixed;
    z-index: 20;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(env(safe-area-inset-bottom) + 64px);
    width: min(92%, 520px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: 0 10px 34px rgba(16,26,36,.20);
    padding: 6px;
    display: flex;
    flex-direction: column;
}
.more-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; color: var(--ink); text-decoration: none; font-weight: 600; font-size: 14px; border-radius: 11px; }
.more-item svg { width: 22px; height: 22px; color: var(--muted); }
.more-item:hover { background: var(--surface-2); }
.more-item.active { color: var(--accent); }
.more-item.active svg { color: var(--accent); }

/* --- settings + demand profile -------------------------------------------- */
.back-link { display: inline-block; font-size: 13px; font-weight: 600; color: var(--accent); text-decoration: none; margin: 0 2px 2px; }
.back-link:hover { text-decoration: underline; }

.settings-list { display: flex; flex-direction: column; gap: 8px; }
.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 14px 16px;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--ink);
}
.settings-item:hover { background: var(--surface-2); }
.settings-item-title { display: block; font-weight: 600; font-size: 15px; }
.settings-item-sub { font-size: 12px; color: var(--muted); }
.settings-item svg { width: 18px; height: 18px; flex: none; color: var(--muted); }

.dp-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.dp-grid { display: grid; gap: 7px 8px; align-items: center; min-width: min-content; }
.dp-head { font-size: 11px; font-weight: 600; color: var(--muted); text-align: center; }
.dp-corner { text-align: left; }
.dp-month { font-size: 13px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.dp-input {
    width: 100%;
    min-width: 0;
    padding: 8px 6px;
    text-align: center;
    font-family: var(--font-body);
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 9px;
}
.dp-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.dp-na { text-align: center; color: var(--muted); }
.save-ok { color: var(--accent); border-color: var(--accent); background: var(--accent-weak); }

/* live profile chart */
.dp-chart-svg { width: 100%; height: auto; display: block; }
.dp-grid-line { stroke: var(--line); stroke-width: 1; }
.dp-ln { fill: none; stroke: var(--dp-color); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.dp-dot { fill: var(--dp-color); stroke: var(--surface); stroke-width: 1; }
.dp-c0 { --dp-color: var(--usage); }
.dp-c1 { --dp-color: var(--accent); }
.dp-c2 { --dp-color: var(--muted); }
.dp-c3 { --dp-color: var(--brand); }
.dp-xticks { display: flex; justify-content: space-between; padding: 2px 2.6% 0; }
.dp-xticks span { font-size: 9px; font-weight: 600; color: var(--muted); }
.dp-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; justify-content: center; margin-top: 10px; }
.dp-leg { display: inline-flex; align-items: center; font-size: 11px; color: var(--ink-2); }
.dp-leg::before { content: ""; width: 14px; height: 3px; border-radius: 2px; background: var(--dp-color); margin-right: 6px; }

/* demand priorities */
.prio-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.prio-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 13px; box-shadow: var(--shadow); }
.prio-info { display: flex; align-items: center; gap: 9px; min-width: 0; }
.prio-name { font-size: 14px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prio-type { font-size: 10px; font-weight: 700; letter-spacing: .05em; color: var(--muted); text-transform: uppercase; flex: none; }
.prio-input { width: 60px; flex: none; text-align: center; padding: 8px 6px; font-family: var(--font-body); font-size: 15px; font-variant-numeric: tabular-nums; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; }
.prio-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

.ladder { display: flex; flex-direction: column; gap: 8px; }
.ladder-tier { display: flex; align-items: center; gap: 10px; }
.ladder-rank { flex: none; width: 26px; height: 26px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 700; font-size: 13px; background: var(--accent-weak); color: var(--accent); }
.ladder-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ladder-chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12px; font-weight: 600; color: var(--ink-2); }
.ladder-chip svg { width: 14px; height: 14px; flex: none; }
.ladder-chip.is-tstat svg { color: var(--accent); }
.ladder-chip.is-switch svg { color: var(--usage); }

/* --- error ui ------------------------------------------------------------- */
#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 1000;
    padding: 12px 16px calc(env(safe-area-inset-bottom) + 12px);
    background: #1F2A33;
    color: #fff;
    font-size: 13px;
    box-shadow: 0 -2px 16px rgba(0,0,0,.25);
}
#blazor-error-ui .reload { color: #fff; text-decoration: underline; }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }

/* --- motion: page entrance + gauge reveal --------------------------------- */
@media (prefers-reduced-motion: no-preference) {
    .app-main > * { animation: rise .5s cubic-bezier(.22, 1, .36, 1) both; }
    .app-main > *:nth-child(2) { animation-delay: .05s; }
    .app-main > *:nth-child(3) { animation-delay: .10s; }
    .app-main > *:nth-child(4) { animation-delay: .15s; }
    .app-main > *:nth-child(5) { animation-delay: .20s; }
    .app-main > *:nth-child(6) { animation-delay: .25s; }
    .app-main > *:nth-child(n+7) { animation-delay: .30s; }

    /* the colored arcs "draw" in clockwise; needle + readout fade in after */
    .gauge .g-ok, .gauge .g-warn, .gauge .g-alert {
        stroke-dasharray: 100 100;
        animation: gauge-draw .9s cubic-bezier(.4, 0, .2, 1) both;
    }
    .gauge .g-warn { animation-delay: .12s; }
    .gauge .g-alert { animation-delay: .24s; }
    .gauge .g-needle, .gauge .g-hub, .gauge .g-value, .gauge .g-unit {
        animation: fade-in .5s ease-out .5s both;
    }
}

@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes gauge-draw { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* signature: red glow on the demand readout when the limit is exceeded */
.is-exceeded .g-value { filter: drop-shadow(0 0 5px rgba(214, 69, 61, .55)); }

/* screen-reader-only text (visually hidden, still announced) */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --- focus + motion ------------------------------------------------------- */
a:focus-visible, button:focus-visible, .tab:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 8px;
}

@keyframes flash { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(46,158,107,.5); }
    70%  { box-shadow: 0 0 0 5px rgba(46,158,107,0); }
    100% { box-shadow: 0 0 0 0 rgba(46,158,107,0); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}

@media (min-width: 600px) {
    body { background: var(--desktop-bg); }
    .app-shell { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

/* --- ambient energy backdrop (fills the wide-screen gutters) -------------- */
.app-backdrop { display: none; }

@media (min-width: 760px) {
    #app { position: relative; z-index: 1; }   /* float the app column above the backdrop */
    .app-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 0;
        pointer-events: none;
        overflow: hidden;
    }
    .app-backdrop svg { display: block; width: 100%; height: 100%; }
}

.bd-stream {
    fill: none;
    stroke: var(--accent);
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-opacity: .13;
    stroke-dasharray: 2 16;          /* sparse pulses travelling the line */
    animation: bd-flow 9s linear infinite;
}
.bd-stream.bd-solar { stroke: var(--solar); stroke-opacity: .15; }
.bd-stream:nth-of-type(2n)   { animation-duration: 12s; animation-direction: reverse; }
.bd-stream:nth-of-type(3n)   { animation-duration: 10.5s; stroke-opacity: .09; }
.bd-stream:nth-of-type(4n+1) { animation-duration: 13.5s; }

.bd-node {
    fill: var(--accent);
    opacity: .35;
    animation: bd-pulse 6s ease-in-out infinite;
}
.bd-node.bd-solar { fill: var(--solar); }
.bd-node:nth-of-type(2n) { animation-duration: 7.5s; animation-delay: -2s; }
.bd-node:nth-of-type(3n) { animation-duration: 9s; animation-delay: -4s; }

/* dark theme reads better a touch brighter (gives a subtle glow) */
[data-theme="dark"] .bd-stream { stroke-opacity: .2; }
[data-theme="dark"] .bd-stream.bd-solar { stroke-opacity: .24; }
[data-theme="dark"] .bd-node { opacity: .5; }

/* seamless loop: offset is a whole number of dash periods (18) */
@keyframes bd-flow { to { stroke-dashoffset: -180; } }
@keyframes bd-pulse { 0%, 100% { opacity: .2; } 50% { opacity: .55; } }

/* --- pull to refresh ------------------------------------------------------ */
.ptr { position: relative; }
.ptr-content { display: flex; flex-direction: column; gap: 14px; }
.ptr-indicator {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    pointer-events: none;
}
.ptr-spinner { width: 24px; height: 24px; opacity: .55; transition: opacity .15s ease, transform .2s ease; }
.ptr.ptr-armed .ptr-spinner { opacity: 1; color: var(--accent); transform: rotate(180deg); }
.ptr.ptr-refreshing .ptr-spinner { opacity: 1; color: var(--accent); animation: ptr-spin .8s linear infinite; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }

/* refresh affordance for keyboard / desktop (no touch gesture) */
.ctl-refresh-row { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin: -2px 2px 0; }
.ctl-updated { font-size: 12px; color: var(--muted); }
.ctl-updated.is-error { color: var(--alert); }
.ctl-refresh-btn.is-spinning svg { animation: ptr-spin .8s linear infinite; transform-origin: center; }

/* --- settings ------------------------------------------------------------- */
.setting-desc { font-size: 13px; color: var(--ink-2); margin: 0 2px 12px; line-height: 1.45; }
.setting-desc.is-error { color: var(--alert); }
.setting-note { font-size: 13px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; line-height: 1.45; margin: 0 0 2px; }

/* per-category push opt-ins, shown under the master toggle */
.setting-subgroup { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.setting-grouplabel { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 0 2px 4px; }
.ctl-label-stack { display: flex; flex-direction: column; gap: 2px; }
.ctl-label-stack .ctl-sub { font-size: 12px; font-weight: 400; color: var(--muted); }

/* --- thermostat schedule -------------------------------------------------- */
.zone-name { font-family: var(--font-display); font-weight: 600; font-size: 15px; color: var(--ink); margin: 0 2px 12px; }
.changed-note { font-size: 12px; color: var(--muted); margin: 10px 2px 0; }

/* generic field used by the schedule editor (label + control) */
.field-label { font-size: 12px; font-weight: 600; color: var(--ink-2); display: block; margin-bottom: 5px; }
.field-input {
    width: 100%;
    box-sizing: border-box;
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 10px 12px;
}
.field-input.is-locked { color: var(--muted); background: var(--surface-2); }
select.field-input { appearance: none; }

/* mode colour map (shared by timeline segments and the mode buttons) */
.mode-cool { --m: var(--usage); }
.mode-heat { --m: var(--brand); }
.mode-auto { --m: var(--accent); }
.mode-off  { --m: var(--muted); }

/* timeline strip */
.tl {
    position: relative;
    width: 100%;
    height: 16px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--surface-2);
}
.tl.is-interactive { height: 44px; border-radius: 9px; touch-action: none; }
.tl-seg {
    position: absolute;
    top: 0;
    bottom: 0;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
}
.tl-seg.per-night { background: var(--per-night); }
.tl-seg.per-edge  { background: var(--per-edge); }
.tl-seg.per-day   { background: var(--per-day); }
.tl-seg + .tl-seg { box-shadow: inset 1px 0 0 rgba(255,255,255,.45); }
.tl.is-interactive .tl-seg.is-sel { box-shadow: inset 0 0 0 2px var(--ink); }
.tl-seg-num { font-size: 12px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.45); }
.tl-handle { position: absolute; top: 0; bottom: 0; width: 0; pointer-events: none; }
.tl-handle-grip {
    position: absolute;
    top: 50%;
    left: 0;
    width: 4px;
    height: 22px;
    transform: translate(-50%, -50%);
    background: var(--surface);
    border-radius: 3px;
    box-shadow: 0 0 0 1px rgba(16,26,36,.25);
}
.tl-axis { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); margin: 3px 2px 0; }

/* day accordion */
.sched-accordion { display: flex; flex-direction: column; gap: 8px; }
.day-row { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.day-head {
    display: grid;
    grid-template-columns: 84px 1fr 20px;
    align-items: center;
    gap: 10px;
    width: 100%;
    border: none;
    background: transparent;
    padding: 12px 14px;
    cursor: pointer;
    text-align: left;
}
.day-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--r); }
.day-name { font-weight: 600; font-size: 14px; color: var(--ink); }
.day-mini { min-width: 0; }
.chev { width: 20px; height: 20px; color: var(--muted); transition: transform .15s ease; }
.chev.is-open { transform: rotate(180deg); }
.day-body { padding: 4px 14px 16px; border-top: 1px solid var(--line); }
.day-row.is-open .day-mini { display: none; }
.day-row.is-open .day-head { grid-template-columns: 1fr 20px; }

/* period editor */
.period-edit { margin-top: 14px; display: flex; flex-direction: column; gap: 14px; }
.pe-head { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.pe-times { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pe-setpoints { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.setpoint { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; }
.setpoint.sp-cool { color: var(--usage); }
.setpoint.sp-heat { color: var(--brand); }
.sp-label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 8px; }
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stepper button {
    width: 34px; height: 34px;
    border: 1px solid currentColor;
    background: var(--surface);
    color: inherit;
    border-radius: 50%;
    font-size: 20px; line-height: 1;
    cursor: pointer;
}
.sp-value { font-family: var(--font-display); font-weight: 700; font-size: 22px; color: var(--ink); font-variant-numeric: tabular-nums; }
.pe-mode { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.mode-btn {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-2);
    font-family: var(--font-body);
    font-size: 12px; font-weight: 700;
    padding: 8px 4px;
    border-radius: 9px;
    cursor: pointer;
}
.mode-btn.is-on { background: var(--m); border-color: var(--m); color: #fff; }
.pe-copy { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pe-copy-label { font-size: 12px; color: var(--muted); width: 100%; }
.chip-btn {
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--ink-2);
    font-family: var(--font-body);
    font-size: 13px; font-weight: 600;
    padding: 7px 12px;
    border-radius: 999px;
    cursor: pointer;
}
.chip-btn:hover { border-color: var(--accent); color: var(--accent); }
