:root {
    color-scheme: dark;
    --background: #141817;
    --surface: #1d2320;
    --surface-soft: #272f2b;
    --ink: #e7ece9;
    --muted: #a5b1aa;
    --line: #36413b;
    --accent: #88d7b3;
    --input-border: #4a5750;
    --solar: #e9c052;
    --load: #e890ad;
    --grid: #7dbbe8;
    --battery: #77cda5;
    --success: #88d7b3;
    --danger: #f298b0;
    --warning: #ebc66d;
    --info: #8ec7ec;
    --secondary: #c4b3df;
    --notice-bg: #342d1c;
    --notice-text: #efd38e;
    --notice-border: #b99a43;
    --selected-bg: #253e31;
    --selected-text: #a4e1be;
    --selected-border: #527661;
    --primary: #276c52;
    --primary-hover: #327d60;
}
:root[data-theme="light"] {
    color-scheme: light;
    --background: #f6f8f7;
    --surface: #fff;
    --surface-soft: #eef3f0;
    --ink: #202526;
    --muted: #646d70;
    --line: #dfe4e3;
    --accent: #167456;
    --input-border: #cdd5d1;
    --solar: #a47b03;
    --load: #b75070;
    --grid: #367bb4;
    --battery: #248766;
    --success: #166146;
    --danger: #a02d50;
    --warning: #7b5800;
    --info: #195e83;
    --secondary: #695379;
    --notice-bg: #fff4da;
    --notice-text: #674800;
    --notice-border: #bd8a11;
    --selected-bg: #e1efe7;
    --selected-text: #18593d;
    --selected-border: #a3c3b2;
    --primary: #21654f;
    --primary-hover: #184d3c;
}
* {
    box-sizing: border-box;
    letter-spacing: 0 !important;
}
body {
    margin: 0;
    background: var(--background);
    color: var(--ink);
    font:
        14px/1.5 "Segoe UI",
        Arial,
        sans-serif;
}
button,
input,
select {
    font: inherit;
}
button,
a {
    touch-action: manipulation;
}
button {
    cursor: pointer;
}
button:disabled {
    cursor: wait;
    opacity: 0.5;
}
:is(button, a, input, select, summary):focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}
h1,
h2,
h3,
p,
dl,
dd {
    margin: 0;
}
h1 {
    font-size: 20px;
    line-height: 1.25;
    font-weight: 650;
}
h2 {
    font-size: 20px;
    font-weight: 650;
}
h3 {
    font-size: 15px;
    font-weight: 650;
}
p {
    overflow-wrap: anywhere;
}
.hidden,
[hidden] {
    display: none !important;
}
svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    stroke-width: 1.8;
}
a {
    color: inherit;
    text-decoration: none;
}
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 18px max(24px, calc((100% - 1440px) / 2));
    min-height: 84px;
}
.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    min-width: 0;
}
.brand > svg {
    width: 34px;
    height: 34px;
    color: var(--solar);
}
.brand span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-top: 3px;
}
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.view-tabs {
    display: flex;
    gap: 24px;
    padding: 0 max(24px, calc((100% - 1440px) / 2));
    border-bottom: 1px solid var(--line);
    background: var(--surface);
    overflow-x: auto;
}
.view-tabs button {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    flex-shrink: 0;
    border: 0;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    background: none;
    color: var(--muted);
    min-height: 54px;
    padding: 0 2px;
    font-weight: 600;
}
.view-tabs button[aria-selected="true"] {
    color: var(--accent);
    border-bottom-color: var(--accent);
}
.workspace {
    max-width: 1488px;
    margin: auto;
    padding: 0 24px 48px;
}
.login-workspace {
    max-width: 400px;
    padding: 0 24px;
    margin: 64px auto;
}
.login-form {
    display: grid;
    gap: 10px;
    margin-top: 24px;
}
.login-form label {
    font-size: 13px;
    color: var(--muted);
}
.login-form input {
    width: 100%;
    margin-bottom: 8px;
}
.login-form .primary-button {
    margin-top: 12px;
}
.login-form .notice {
    margin-top: 0;
}
.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 24px 0 18px;
    flex-wrap: wrap;
}
.section-heading p {
    font-size: 12px;
    color: var(--muted);
    margin-top: 5px;
}
.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink);
}
.icon-button:hover {
    background: var(--surface-soft);
    border-color: var(--input-border);
}
.status-pill {
    display: inline-flex;
    padding: 3px 8px;
    font-size: 12px;
    line-height: 1.5;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface-soft);
    color: var(--muted);
    vertical-align: middle;
}
.section-heading .status-pill {
    margin-left: 8px;
}
.notice {
    margin: 18px 0 0;
    padding: 12px 16px;
    border-left: 3px solid var(--notice-border);
    background: var(--notice-bg);
    color: var(--notice-text);
    overflow-wrap: anywhere;
    font-size: 13px;
}
.energy-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}
.energy-metric {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    padding: 18px 20px 15px;
    border-top: 3px solid var(--metric-color);
}
.solar {
    --metric-color: var(--solar);
}
.load {
    --metric-color: var(--load);
}
.energy-metric.grid {
    --metric-color: var(--grid);
    display: block;
}
.battery {
    --metric-color: var(--battery);
}
.metric-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}
.metric-label svg {
    color: var(--metric-color);
}
.metric-value {
    font-size: 32px;
    font-weight: 650;
    line-height: 1.3;
    margin: 12px 0 16px;
    font-variant-numeric: tabular-nums;
}
.metric-unit {
    font-size: 21px;
    margin-left: 4px;
    color: var(--muted);
}
.metric-foot {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
    margin-top: 6px;
}
.metric-foot strong,
.metric-foot span {
    color: var(--ink);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}
.decision-band {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(210px, 300px);
    gap: 20px 32px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    margin-top: 26px;
    padding: 22px 0;
}
.eyebrow {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 650;
    margin-bottom: 8px;
}
.decision-main h2 {
    font-size: 22px;
    margin-bottom: 5px;
}
.decision-main p {
    color: var(--muted);
    font-size: 13px;
    max-width: 850px;
}
.decision-evidence {
    border-left: 1px solid var(--line);
    padding-left: 24px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    font-size: 12px;
    color: var(--muted);
    overflow-wrap: anywhere;
}
.decision-evidence strong {
    font-size: 15px;
}
.decision-note {
    margin-top: 10px;
    font-size: 12px;
    color: var(--muted);
}
.threshold-strip {
    grid-column: 1/-1;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 24px;
    font-size: 12px;
    color: var(--muted);
}
.threshold-strip span {
    display: flex;
    gap: 8px;
    align-items: center;
}
.threshold-strip span:before {
    content: "";
    width: 5px;
    height: 5px;
    background: #6e8f81;
    border-radius: 50%;
    flex-shrink: 0;
}
.section-band {
    border-bottom: 1px solid var(--line);
    padding-bottom: 22px;
}
.toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 28px;
}
.chart-grid h3 {
    font-size: 13px;
    color: var(--muted);
    margin: 0 0 10px;
}
.chart-grid > div {
    min-width: 0;
}
.chart-frame {
    height: 290px;
    position: relative;
    min-width: 0;
    width: 100%;
    overflow: hidden;
}
.technical-details {
    padding: 20px 0;
    border-bottom: 1px solid var(--line);
}
summary {
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}
.details-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 28px;
    margin-top: 20px;
}
dl > div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin: 8px 0;
    font-size: 12px;
}
dt {
    color: var(--muted);
}
dd {
    font-variant-numeric: tabular-nums;
    text-align: right;
}
.settings-section {
    border-bottom: 1px solid var(--line);
    padding: 24px 0;
}
.settings-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}
.rule-note {
    font-size: 12px;
    color: var(--muted);
    margin-top: 5px;
}
.field-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin: 12px 0;
}
.field-grid label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
}
input:not([type="checkbox"]):not([type="range"]),
select {
    min-height: 38px;
    border: 1px solid var(--input-border);
    border-radius: 5px;
    background: var(--surface);
    color: var(--ink);
    padding: 7px 10px;
    max-width: 100%;
    min-width: 0;
}
input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    flex-shrink: 0;
}
input[type="range"] {
    accent-color: var(--accent);
}
.check-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    cursor: pointer;
}
.toggle-row {
    display: flex;
    gap: 12px 24px;
    flex-wrap: wrap;
    margin: 8px 0 18px;
}
fieldset {
    padding: 24px 0 0;
    border: 0;
    border-top: 1px solid var(--line);
    margin: 24px 0 0;
}
legend {
    font-size: 14px;
    font-weight: 600;
    padding: 0 14px 0 0;
}
.form-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 20px;
    font-size: 12px;
    color: var(--muted);
}
.primary-button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    white-space: nowrap;
    background: var(--primary);
    color: white;
    border: 1px solid var(--primary);
    padding: 8px 14px;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 600;
}
.primary-button:hover {
    background: var(--primary-hover);
}
.muted {
    color: var(--muted);
    font-size: 12px;
}
.inline-stats {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.inline-stats > div {
    gap: 10px;
}
.segmented-control {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.segmented-control button,
.suggestions button {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--muted);
    border-radius: 5px;
    padding: 6px 10px;
    font-size: 12px;
}
.segmented-control button[aria-pressed="true"] {
    background: var(--selected-bg);
    color: var(--selected-text);
    border-color: var(--selected-border);
}
.conversation {
    min-height: 280px;
    max-height: 55vh;
    overflow-y: auto;
    margin: 20px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    padding: 16px 0;
}
.composer {
    display: flex;
    gap: 8px;
}
.composer input {
    flex: 1;
}
.suggestions {
    margin: 12px 0 24px;
}
#toasts {
    position: fixed;
    bottom: 18px;
    right: 18px;
    z-index: 60;
    display: grid;
    gap: 8px;
    max-width: min(400px, calc(100% - 36px));
}
#toasts > div {
    background: var(--surface);
    box-shadow: 0 4px 18px #0002;
}
#device-groups > section {
    padding: 24px 0;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: none;
    border-radius: 0;
}
#rule-list {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}
#execution-log > article {
    margin-bottom: 6px;
}
/* Dynamic components use the same theme tokens as the static template. */
body [class*="bg-slate-9"],
body [class*="bg-slate-8"] {
    background-color: var(--surface);
}
body [class*="border-slate-"] {
    border-color: var(--line);
}
body [class*="text-slate-1"],
body [class*="text-slate-2"],
body [class*="text-slate-3"],
body .text-white {
    color: var(--ink);
}
body [class*="text-slate-4"],
body [class*="text-slate-5"],
body [class*="text-slate-6"] {
    color: var(--muted);
}
body [class*="text-emerald-"] {
    color: var(--success);
}
body [class*="text-rose-"],
body [class*="text-pink-"] {
    color: var(--danger);
}
body [class*="text-amber-"],
body [class*="text-yellow-"] {
    color: var(--warning);
}
body [class*="text-sky-"],
body [class*="text-cyan-"] {
    color: var(--info);
}
body [class*="text-violet-"],
body [class*="text-fuchsia-"] {
    color: var(--secondary);
}
body .rounded-full {
    border-radius: 4px;
}
#policy-agent-status {
    max-width: 680px;
}
#policy-external-correction {
    border: 0;
    padding: 0;
    background: none;
}
#policy-confidence-score {
    font-weight: 400;
}
#health-pill {
    max-width: 330px;
    border-radius: 4px;
    padding: 5px 9px;
    font-size: 12px;
}
#metric-status {
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 11px;
}
#policy-target-confidence {
    border-radius: 4px;
}
.device-command-on {
    background: var(--selected-bg) !important;
    color: var(--selected-text) !important;
}
.device-command-off {
    background: var(--surface-soft) !important;
    color: var(--ink) !important;
}
@media (min-width: 1500px) {
    .chart-frame {
        height: 330px;
    }
}
@media (max-width: 1000px) {
    .field-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .energy-grid {
        gap: 10px;
    }
    .energy-metric {
        padding: 15px 14px;
    }
    .metric-value {
        font-size: 28px;
    }
    .metric-foot {
        flex-wrap: wrap;
    }
    .chart-grid {
        gap: 18px;
    }
}
@media (max-width: 760px) {
    .app-header {
        padding: 14px 16px;
        gap: 8px;
        flex-wrap: wrap;
    }
    .header-actions {
        margin-left: auto;
    }
    .brand span {
        font-size: 11px;
    }
    .brand > svg {
        width: 28px;
    }
    .header-actions #health-pill {
        max-width: 220px;
    }
    .view-tabs {
        padding: 0 16px;
        gap: 20px;
    }
    .workspace {
        padding: 0 16px 32px;
    }
    .energy-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .decision-band {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .decision-evidence {
        border-left: 0;
        padding: 14px 0 0;
        border-top: 1px solid var(--line);
    }
    .chart-grid,
    .details-grid {
        grid-template-columns: minmax(0, 1fr);
    }
    .chart-frame {
        height: 260px;
    }
    .field-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .section-heading {
        padding-top: 20px;
        gap: 12px;
    }
    .settings-heading {
        align-items: flex-start;
    }
    .section-heading #policy-agent-status {
        margin-left: 0;
    }
    .form-footer {
        align-items: flex-start;
    }
    .threshold-strip {
        gap: 8px 16px;
    }
}
@media (max-width: 440px) {
    .app-header {
        align-items: flex-start;
    }
    .header-actions {
        width: 100%;
        justify-content: flex-end;
    }
    .header-actions #health-pill {
        margin-right: auto;
    }
    .field-grid {
        grid-template-columns: 1fr;
    }
    .metric-value {
        font-size: 27px;
    }
    .energy-metric {
        padding: 12px;
    }
    .metric-foot {
        font-size: 11px;
    }
    .chart-frame {
        height: 240px;
    }
    .form-footer {
        flex-wrap: wrap;
    }
    .form-footer > span {
        flex-basis: 100%;
    }
    .section-heading h2 {
        font-size: 19px;
    }
    .view-tabs {
        gap: 18px;
    }
    .view-tabs button {
        font-size: 13px;
    }
    .toolbar input[type="datetime-local"] {
        flex-basis: 100%;
    }
    .decision-main h2 {
        font-size: 20px;
    }
}
