Add dark mode toggle in the sidebar

Adds a persistent dark/light theme toggle (localStorage +
data-bs-theme on <html>) so it applies globally, including the
circuit editor route which has no visible sidebar. An inline
beforeInteractive script sets the theme before hydration to avoid a
flash of the wrong theme.

Bootstrap components pick up data-bs-theme automatically; the custom
circuit-grid CSS previously used ~150 hardcoded hex colors, all
converted to semantic tokens in globals.css with light/dark values.

Verified with a headless-browser pass across the project list, project
detail page, circuit editor, project-device drawer and a settings
modal in both themes; no console errors.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Julian Appel 2026-08-06 21:56:21 +02:00
parent a99980c47b
commit 64ccd1f829
4 changed files with 395 additions and 127 deletions

View file

@ -3,7 +3,13 @@
Bootstrap bleibt Basis für Formulare/Tabellen/Modals; wir tönen die
vorhandenen Bootstrap-Komponenten über deren eigene --bs-btn-*-Variablen
um (globals.css lädt nach bootstrap.min.css, gleiche Spezifität gewinnt
per Ladereihenfolge) statt Bootstrap zu ersetzen. */
per Ladereihenfolge) statt Bootstrap zu ersetzen.
Dark mode: Bootstrap schaltet seine eigenen Komponenten (Formulare,
Modals, Cards, Alerts, ...) automatisch um, sobald `data-bs-theme="dark"`
auf <html> steht (gesetzt von ThemeToggle.tsx, persistiert in
localStorage). Der custom Stromkreis-Grid nutzt dafür dieselben
Tokens unten, per `:root[data-bs-theme="dark"]` überschrieben. */
:root {
--color-primary: #1c3f52; /* Petrol */
--color-primary-dark: #0f2733; /* Petrol Dark */
@ -33,6 +39,105 @@
--space-xl: 40px;
--radius: 12px;
/* ── Grid/Editor-Tokens (hell) ──────────────────────────────────────── */
--panel-bg: #ffffff;
--panel-bg-subtle: #f8fafc;
--panel-border: #d9dee8;
--panel-border-strong: #c4cddc;
--input-border: #9fb6e0;
--text-strong: #1f2937;
--text-muted: #4b5563;
--text-faint: #6b7280;
--text-subtle: #475569;
--accent-blue: #2563eb;
--accent-blue-soft-bg: #eff6ff;
--accent-blue-border: #bfdbfe;
--accent-blue-strong-border: #4c7dd9;
--accent-blue-drop-border: #2b6cb0;
--accent-blue-marker: #1d4ed8;
--surface-selected: #eaf1ff;
--surface-header-row: #e8eef8;
--surface-component-header: #e2e8f0;
--surface-component-group: #f8fafc;
--surface-component-footer: #f1f5f9;
--surface-hover: #f3f4f6;
--grid-warn: #d97706;
--grid-warn-bg: #fff7ed;
--grid-warn-strong: #9a3412;
--grid-danger: #c2410c;
--notice-info-bg: #ebf3ff;
--notice-info-border: #bad1f7;
--notice-error-bg: #fdecec;
--notice-error-border: #f5b5b5;
--notice-warning-bg: #fff7ed;
--notice-warning-border: #fdba74;
--notice-muted-bg: #f6f6f6;
--notice-muted-border: #e4e4e4;
--shadow-soft: rgba(15, 39, 51, 0.07);
--shadow-strong: rgba(15, 39, 51, 0.28);
--shadow-menu: rgba(0, 0, 0, 0.12);
--shadow-drawer: rgba(31, 41, 55, 0.22);
}
:root[data-bs-theme="dark"] {
--color-ink: #e6ecef;
--color-ink-soft: #9db0b8;
--color-bg: #141b20;
--color-surface: #0f1519;
--color-border: #2a3941;
--color-danger: #e2664f;
--color-danger-bg: #33201c;
--color-warn: #e0983f;
/* ── Grid/Editor-Tokens (dunkel) ────────────────────────────────────── */
--panel-bg: #182229;
--panel-bg-subtle: #1c2830;
--panel-border: #2c3c45;
--panel-border-strong: #374a54;
--input-border: #3c5568;
--text-strong: #e6ecef;
--text-muted: #aebdc4;
--text-faint: #8798a0;
--text-subtle: #9db0b8;
--accent-blue: #6fa2f7;
--accent-blue-soft-bg: #17253a;
--accent-blue-border: #2c4a72;
--accent-blue-strong-border: #6fa2f7;
--accent-blue-drop-border: #4f84d6;
--accent-blue-marker: #6fa2f7;
--surface-selected: #17253a;
--surface-header-row: #1a262f;
--surface-component-header: #202e37;
--surface-component-group: #1a262f;
--surface-component-footer: #182229;
--surface-hover: #1f2b33;
--grid-warn: #e0983f;
--grid-warn-bg: #2e2214;
--grid-warn-strong: #f0b880;
--grid-danger: #e2825f;
--notice-info-bg: #182839;
--notice-info-border: #2c4a72;
--notice-error-bg: #33201c;
--notice-error-border: #5c332c;
--notice-warning-bg: #2e2214;
--notice-warning-border: #6b4a1c;
--notice-muted-bg: #1b2226;
--notice-muted-border: #2a3338;
--shadow-soft: rgba(0, 0, 0, 0.35);
--shadow-strong: rgba(0, 0, 0, 0.55);
--shadow-menu: rgba(0, 0, 0, 0.45);
--shadow-drawer: rgba(0, 0, 0, 0.55);
}
html {
@ -109,6 +214,12 @@ a {
--bs-alert-border-color: #b6e2ce;
}
:root[data-bs-theme="dark"] .alert-success {
--bs-alert-color: #7fd6a7;
--bs-alert-bg: #16291f;
--bs-alert-border-color: #205a38;
}
/* ── App-Shell / Seitenleiste (nur auf der Projektseite) ────────────────── */
.app-shell {
@ -165,6 +276,7 @@ a {
flex-direction: column;
gap: 2px;
padding: 12px;
flex: 1;
}
.sidebar-section-label {
@ -210,6 +322,32 @@ a {
justify-content: center;
}
.sidebar-footer {
padding: 12px;
border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.sidebar-theme-toggle {
display: flex;
align-items: center;
gap: 10px;
padding: 10px 14px;
border-radius: 8px;
color: #c7d6e0;
font-size: 0.92rem;
font-weight: 500;
border: 1px solid rgba(255, 255, 255, 0.16);
background: rgba(255, 255, 255, 0.06);
width: 100%;
text-align: left;
cursor: pointer;
}
.sidebar-theme-toggle:hover {
background: rgba(255, 255, 255, 0.14);
color: #fff;
}
.app-shell-content {
width: 100%;
min-width: 0;
@ -230,6 +368,10 @@ a {
color: var(--color-primary);
}
:root[data-bs-theme="dark"] .page-header h1 {
color: var(--color-accent-pale);
}
.kicker {
font-size: 0.72rem;
letter-spacing: 0.12em;
@ -262,7 +404,7 @@ a {
a.kpi:hover {
color: inherit;
text-decoration: none;
box-shadow: 0 3px 8px rgba(15, 39, 51, 0.07), 0 16px 32px -14px rgba(15, 39, 51, 0.28);
box-shadow: 0 3px 8px var(--shadow-soft), 0 16px 32px -14px var(--shadow-strong);
transform: translateY(-1px);
}
@ -285,12 +427,16 @@ a.kpi:hover {
color: var(--color-primary);
}
:root[data-bs-theme="dark"] .kpi-value {
color: var(--color-accent-pale);
}
.card {
border-radius: var(--radius);
border-top: 3px solid var(--color-primary);
box-shadow:
0 1px 2px rgba(15, 39, 51, 0.05),
0 10px 24px -14px rgba(15, 39, 51, 0.22);
0 1px 2px var(--shadow-soft),
0 10px 24px -14px var(--shadow-strong);
}
.card-header {
@ -300,6 +446,10 @@ a.kpi:hover {
border-bottom: 1px solid var(--color-border);
}
:root[data-bs-theme="dark"] .card-header {
color: var(--color-accent-pale);
}
.table td input.form-control-sm,
.table td select.form-select-sm {
min-width: 8rem;
@ -320,13 +470,14 @@ a.kpi:hover {
top: 0;
z-index: 12;
padding: 0.35rem 0;
background: #fff;
box-shadow: 0 1px 0 rgba(196, 205, 220, 0.8);
background: var(--panel-bg);
box-shadow: 0 1px 0 var(--panel-border-strong);
}
.editor-toolbar button {
border: 1px solid #c4cddc;
background: #fff;
border: 1px solid var(--panel-border-strong);
background: var(--panel-bg);
color: var(--text-strong);
padding: 0.28rem 0.6rem;
border-radius: 4px;
font-size: 0.82rem;
@ -337,8 +488,8 @@ a.kpi:hover {
}
.editor-toolbar .project-device-drawer-toggle {
border-color: #2563eb;
background: #2563eb;
border-color: var(--accent-blue);
background: var(--accent-blue);
color: #fff;
font-weight: 600;
}
@ -349,10 +500,10 @@ a.kpi:hover {
align-items: center;
gap: 0.35rem;
padding: 0.4rem 0.5rem;
border: 1px solid #bfdbfe;
border: 1px solid var(--accent-blue-border);
border-radius: 5px;
background: #eff6ff;
color: #1e3a5f;
background: var(--accent-blue-soft-bg);
color: var(--text-subtle);
font-size: 0.78rem;
}
@ -362,10 +513,10 @@ a.kpi:hover {
.active-view-chip,
.active-view-reset {
border: 1px solid #93b4df;
border: 1px solid var(--accent-blue-border);
border-radius: 999px;
background: #fff;
color: #1e3a5f;
background: var(--panel-bg);
color: var(--text-subtle);
padding: 0.18rem 0.48rem;
font-size: 0.76rem;
cursor: pointer;
@ -373,7 +524,7 @@ a.kpi:hover {
.active-view-chip:hover,
.active-view-reset:hover {
border-color: #2563eb;
border-color: var(--accent-blue);
}
.active-view-reset {
@ -386,9 +537,9 @@ a.kpi:hover {
grid-template-columns: repeat(3, minmax(12rem, 1fr));
gap: 0.5rem;
padding: 0.55rem;
border: 1px solid #cbd5e1;
border: 1px solid var(--panel-border);
border-radius: 5px;
background: #f8fafc;
background: var(--panel-bg-subtle);
}
.distribution-power-summary > div {
@ -398,13 +549,13 @@ a.kpi:hover {
}
.distribution-power-summary span {
color: #475569;
color: var(--text-subtle);
font-size: 0.74rem;
line-height: 1.2;
}
.distribution-power-summary strong {
color: #172033;
color: var(--text-strong);
font-size: 0.95rem;
}
@ -418,13 +569,13 @@ a.kpi:hover {
position: absolute;
z-index: 9;
margin-top: 2rem;
border: 1px solid #cfd7e5;
background: #fff;
border: 1px solid var(--panel-border);
background: var(--panel-bg);
border-radius: 5px;
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
box-shadow: 0 6px 16px var(--shadow-menu);
padding: 0.55rem;
width: 340px;
color: #1f2937;
color: var(--text-strong);
text-align: left;
}
@ -444,7 +595,7 @@ a.kpi:hover {
.column-settings-close {
border: 0 !important;
background: transparent !important;
color: #4b5563;
color: var(--text-muted);
padding: 0.05rem 0.2rem !important;
font-size: 1rem !important;
line-height: 1;
@ -453,7 +604,7 @@ a.kpi:hover {
.column-settings-explanation {
margin-bottom: 0.4rem;
color: #4b5563;
color: var(--text-muted);
font-size: 0.72rem;
line-height: 1.3;
}
@ -461,9 +612,11 @@ a.kpi:hover {
.column-settings-search {
width: 100%;
margin-bottom: 0.4rem;
border: 1px solid #c4cddc;
border: 1px solid var(--panel-border-strong);
border-radius: 4px;
padding: 0.3rem 0.4rem;
background: var(--panel-bg);
color: var(--text-strong);
font-size: 0.76rem;
}
@ -473,7 +626,7 @@ a.kpi:hover {
gap: 0.15rem;
max-height: 300px;
overflow: auto;
border: 1px solid #e1e6ef;
border: 1px solid var(--panel-border);
border-radius: 4px;
padding: 0.25rem;
}
@ -489,8 +642,8 @@ a.kpi:hover {
}
.column-settings-item.selected {
border-color: #bfdbfe;
background: #eff6ff;
border-color: var(--accent-blue-border);
background: var(--accent-blue-soft-bg);
}
.column-settings-item.dragging {
@ -498,12 +651,12 @@ a.kpi:hover {
}
.column-settings-item.drop-target {
border-color: #2b6cb0;
background: #ebf4ff;
border-color: var(--accent-blue-drop-border);
background: var(--accent-blue-soft-bg);
}
.column-settings-item.locked {
background: #f7fafc;
background: var(--panel-bg-subtle);
}
.column-visibility-button {
@ -530,7 +683,7 @@ a.kpi:hover {
flex: 0 0 1rem;
align-items: center;
justify-content: center;
color: #1d4ed8;
color: var(--accent-blue-marker);
font-weight: 700;
}
@ -540,8 +693,9 @@ a.kpi:hover {
}
.column-settings-order button {
border: 1px solid #c4cddc;
background: #fff;
border: 1px solid var(--panel-border-strong);
background: var(--panel-bg);
color: var(--text-strong);
border-radius: 3px;
font-size: 0.72rem;
padding: 0.08rem 0.28rem;
@ -549,8 +703,8 @@ a.kpi:hover {
.tree-grid-wrap {
overflow: auto;
border: 1px solid #d9dee8;
background: #fff;
border: 1px solid var(--panel-border);
background: var(--panel-bg);
width: 100%;
max-width: 100%;
min-width: 0;
@ -560,7 +714,7 @@ a.kpi:hover {
.column-settings-empty {
padding: 0.55rem 0.35rem;
color: #6b7280;
color: var(--text-faint);
font-size: 0.76rem;
}
@ -570,8 +724,8 @@ a.kpi:hover {
}
.column-settings-footer button.primary {
border-color: #2563eb;
background: #2563eb;
border-color: var(--accent-blue);
background: var(--accent-blue);
color: #fff;
}
@ -583,8 +737,8 @@ a.kpi:hover {
}
.project-device-sidebar {
border: 1px solid #d9dee8;
background: #fff;
border: 1px solid var(--panel-border);
background: var(--panel-bg);
padding: 0.6rem;
display: flex;
flex-direction: column;
@ -594,14 +748,17 @@ a.kpi:hover {
.project-device-sidebar h3 {
margin: 0;
font-size: 1rem;
color: var(--text-strong);
}
.project-device-sidebar input,
.project-device-sidebar select {
width: 100%;
border: 1px solid #cfd7e5;
border: 1px solid var(--panel-border-strong);
border-radius: 4px;
padding: 0.25rem 0.35rem;
background: var(--panel-bg);
color: var(--text-strong);
}
.project-device-list {
@ -613,8 +770,9 @@ a.kpi:hover {
}
.project-device-item {
border: 1px solid #d5ddec;
background: #f8faff;
border: 1px solid var(--panel-border-strong);
background: var(--panel-bg-subtle);
color: var(--text-strong);
text-align: left;
padding: 0.4rem;
border-radius: 4px;
@ -625,8 +783,8 @@ a.kpi:hover {
}
.project-device-item.selected {
border-color: #4c7dd9;
background: #edf3ff;
border-color: var(--accent-blue-strong-border);
background: var(--accent-blue-soft-bg);
}
.project-device-item.dragging {
@ -645,11 +803,13 @@ a.kpi:hover {
flex-direction: column;
gap: 0.2rem;
font-size: 0.82rem;
color: var(--text-strong);
}
.sidebar-actions button {
border: 1px solid #c4cddc;
background: #fff;
border: 1px solid var(--panel-border-strong);
background: var(--panel-bg);
color: var(--text-strong);
border-radius: 4px;
padding: 0.3rem 0.45rem;
font-size: 0.82rem;
@ -660,18 +820,19 @@ a.kpi:hover {
min-width: 0;
border-collapse: collapse;
font-size: 0.9rem;
color: var(--text-strong);
}
.tree-grid th,
.tree-grid td {
border: 1px solid #e4e9f2;
border: 1px solid var(--panel-border);
padding: 0.35rem 0.4rem;
vertical-align: middle;
}
.tree-grid th {
width: 1px;
background: #f4f7fb;
background: var(--panel-bg-subtle);
position: sticky;
top: 0;
z-index: 2;
@ -694,8 +855,9 @@ a.kpi:hover {
.tree-grid .header-filter-btn {
display: block;
width: 100%;
border: 1px solid #c4cddc;
background: #fff;
border: 1px solid var(--panel-border-strong);
background: var(--panel-bg);
color: var(--text-strong);
border-radius: 3px;
font-size: 0.75rem;
padding: 0.15rem 0.35rem;
@ -712,7 +874,7 @@ a.kpi:hover {
border: 0;
background: transparent;
padding: 0;
color: #1f2937;
color: var(--text-strong);
font: inherit;
font-size: 0.78rem;
font-weight: 600;
@ -733,7 +895,7 @@ a.kpi:hover {
max-height: calc(100vh - 7rem);
overflow: auto;
border-radius: 0.5rem;
box-shadow: 0 0.75rem 2rem rgba(31, 41, 55, 0.22);
box-shadow: 0 0.75rem 2rem var(--shadow-drawer);
}
.project-device-drawer-header {
@ -744,13 +906,14 @@ a.kpi:hover {
}
.project-device-drawer-header span {
color: #6b7280;
color: var(--text-faint);
font-size: 0.75rem;
}
.project-device-drawer-header button {
border: 1px solid #c4cddc;
background: #fff;
border: 1px solid var(--panel-border-strong);
background: var(--panel-bg);
color: var(--text-strong);
border-radius: 4px;
padding: 0.25rem 0.4rem;
font-size: 0.78rem;
@ -762,23 +925,24 @@ a.kpi:hover {
}
.tree-grid .sort-indicator {
color: #2563eb;
color: var(--accent-blue);
font-size: 0.85rem;
}
.tree-grid .header-filter-btn.active {
border-color: #2563eb;
color: #2563eb;
background: #eff6ff;
border-color: var(--accent-blue);
color: var(--accent-blue);
background: var(--accent-blue-soft-bg);
}
.tree-grid .header-filter-menu {
position: absolute;
z-index: 7;
margin-top: 0.2rem;
border: 1px solid #cfd7e5;
background: #fff;
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
border: 1px solid var(--panel-border);
background: var(--panel-bg);
color: var(--text-strong);
box-shadow: 0 6px 16px var(--shadow-menu);
width: 300px;
padding: 0.55rem;
text-align: left;
@ -802,7 +966,7 @@ a.kpi:hover {
.tree-grid .header-filter-close {
border: 0;
background: transparent;
color: #4b5563;
color: var(--text-muted);
padding: 0.05rem 0.2rem;
font-size: 1rem;
line-height: 1;
@ -817,13 +981,14 @@ a.kpi:hover {
.tree-grid .header-filter-selection-actions span {
margin-left: auto;
color: #4b5563;
color: var(--text-muted);
}
.tree-grid .header-filter-selection-actions button,
.tree-grid .header-filter-footer button {
border: 1px solid #c4cddc;
background: #fff;
border: 1px solid var(--panel-border-strong);
background: var(--panel-bg);
color: var(--text-strong);
border-radius: 3px;
padding: 0.18rem 0.35rem;
font-size: 0.72rem;
@ -832,7 +997,7 @@ a.kpi:hover {
.tree-grid .header-filter-explanation {
margin-bottom: 0.4rem;
color: #4b5563;
color: var(--text-muted);
font-size: 0.72rem;
line-height: 1.3;
white-space: normal;
@ -840,9 +1005,11 @@ a.kpi:hover {
.tree-grid .header-filter-search {
width: 100%;
border: 1px solid #c4cddc;
border: 1px solid var(--panel-border-strong);
border-radius: 4px;
padding: 0.3rem 0.4rem;
background: var(--panel-bg);
color: var(--text-strong);
font-size: 0.76rem;
}
@ -852,7 +1019,7 @@ a.kpi:hover {
gap: 0.15rem;
max-height: 210px;
overflow: auto;
border: 1px solid #e1e6ef;
border: 1px solid var(--panel-border);
border-radius: 4px;
padding: 0.25rem;
}
@ -866,7 +1033,7 @@ a.kpi:hover {
border-radius: 3px;
background: transparent;
padding: 0.25rem 0.3rem;
color: #1f2937;
color: var(--text-strong);
font-weight: 400;
font-size: 0.75rem;
text-align: left;
@ -874,17 +1041,17 @@ a.kpi:hover {
}
.tree-grid .header-filter-item:hover {
background: #f3f4f6;
background: var(--surface-hover);
}
.tree-grid .header-filter-item.selected {
border-color: #bfdbfe;
background: #eff6ff;
border-color: var(--accent-blue-border);
background: var(--accent-blue-soft-bg);
}
.tree-grid .header-filter-empty {
padding: 0.45rem 0.25rem;
color: #6b7280;
color: var(--text-faint);
font-size: 0.74rem;
}
@ -897,8 +1064,8 @@ a.kpi:hover {
}
.tree-grid .header-filter-footer button.primary {
border-color: #2563eb;
background: #2563eb;
border-color: var(--accent-blue);
background: var(--accent-blue);
color: #fff;
}
@ -908,7 +1075,7 @@ a.kpi:hover {
}
.tree-grid .header-filter-warning {
color: #9a3412;
color: var(--grid-warn-strong);
font-size: 0.7rem;
white-space: normal;
}
@ -918,25 +1085,25 @@ a.kpi:hover {
}
.tree-grid .section-row td {
background: #e8eef8;
background: var(--surface-header-row);
font-weight: 600;
}
.tree-grid .structure-component-row td {
padding: 0.38rem 0.6rem;
border-bottom-color: #d8dee9;
border-bottom-color: var(--panel-border);
}
.tree-grid .structure-component-row.headerComponent td {
background: #e2e8f0;
background: var(--surface-component-header);
}
.tree-grid .structure-component-row.groupComponent td {
background: #f8fafc;
background: var(--surface-component-group);
}
.tree-grid .structure-component-row.footerComponent td {
background: #f1f5f9;
background: var(--surface-component-footer);
}
.tree-grid .structure-component-content {
@ -952,7 +1119,7 @@ a.kpi:hover {
}
.tree-grid .structure-component-protection {
color: #475569;
color: var(--text-subtle);
font-size: 0.78rem;
}
@ -969,7 +1136,7 @@ a.kpi:hover {
}
.tree-grid .structure-component-fixed {
color: #64748b;
color: var(--text-faint);
font-size: 0.75rem;
}
@ -990,32 +1157,33 @@ a.kpi:hover {
}
.tree-grid .section-actions button {
border: 1px solid #c4cddc;
background: #fff;
border: 1px solid var(--panel-border-strong);
background: var(--panel-bg);
color: var(--text-strong);
padding: 0.2rem 0.45rem;
border-radius: 3px;
font-size: 0.78rem;
}
.tree-grid .summary-row td {
background: #f3f7fd;
background: var(--panel-bg-subtle);
}
.tree-grid .device-row td:first-child {
color: #6b7280;
color: var(--text-faint);
}
.tree-grid .empty-circuit-row td {
background: #f8fbff;
background: var(--panel-bg-subtle);
}
.tree-grid tr.row-selected td {
background: #eaf1ff;
background: var(--surface-selected);
}
.tree-grid .placeholder-row td {
background: #f7f7f7;
color: #6b7280;
background: var(--panel-bg-subtle);
color: var(--text-faint);
font-style: italic;
}
@ -1032,8 +1200,12 @@ a.kpi:hover {
box-shadow 0.12s ease;
}
:root[data-bs-theme="dark"] .tree-grid .cell-protection-trigger {
color: var(--color-accent-pale);
}
.tree-grid .cell-protection-trigger:hover {
background: #eaf6f0;
background: rgba(63, 166, 107, 0.15);
box-shadow: inset 0 0 0 1px var(--color-signal);
}
@ -1054,7 +1226,7 @@ a.kpi:hover {
}
.tree-grid .cell-selected {
outline: 2px solid #4c7dd9;
outline: 2px solid var(--accent-blue-strong-border);
outline-offset: -2px;
}
@ -1065,28 +1237,30 @@ a.kpi:hover {
}
.tree-grid .section-title span {
color: #475569;
color: var(--text-subtle);
font-size: 0.78rem;
font-weight: 500;
}
.tree-grid .cell-invalid {
outline: 2px solid #c2410c;
outline: 2px solid var(--grid-danger);
outline-offset: -2px;
background: #fff7ed !important;
background: var(--grid-warn-bg) !important;
}
.tree-grid .cell-invalid input {
border-color: #c2410c;
border-color: var(--grid-danger);
}
.tree-grid input,
.tree-grid select {
width: 100%;
min-width: 5rem;
border: 1px solid #9fb6e0;
border: 1px solid var(--input-border);
border-radius: 2px;
padding: 0.2rem 0.3rem;
background: var(--panel-bg);
color: var(--text-strong);
}
.tree-grid .action-cell {
@ -1095,26 +1269,27 @@ a.kpi:hover {
}
.tree-grid .action-cell button {
border: 1px solid #c4cddc;
background: #fff;
border: 1px solid var(--panel-border-strong);
background: var(--panel-bg);
color: var(--text-strong);
padding: 0.2rem 0.45rem;
border-radius: 3px;
font-size: 0.78rem;
}
.tree-grid .drop-target-active {
box-shadow: inset 0 0 0 2px #4c7dd9;
background: #eef4ff !important;
box-shadow: inset 0 0 0 2px var(--accent-blue-strong-border);
background: var(--accent-blue-soft-bg) !important;
}
.tree-grid .drop-target-invalid {
box-shadow: inset 0 0 0 2px #d97706;
background: #fff7ed !important;
box-shadow: inset 0 0 0 2px var(--grid-warn);
background: var(--grid-warn-bg) !important;
}
.tree-grid .drop-target-confirm {
box-shadow: inset 0 0 0 2px #d97706;
background: #fffbeb !important;
box-shadow: inset 0 0 0 2px var(--grid-warn);
background: var(--grid-warn-bg) !important;
}
.tree-grid tr.circuit-insert-before td,
@ -1128,7 +1303,7 @@ a.kpi:hover {
left: -1px;
right: -1px;
top: -2px;
border-top: 4px solid #2563eb;
border-top: 4px solid var(--accent-blue);
pointer-events: none;
}
@ -1141,7 +1316,7 @@ a.kpi:hover {
height: 0;
border-top: 7px solid transparent;
border-bottom: 7px solid transparent;
border-left: 10px solid #2563eb;
border-left: 10px solid var(--accent-blue);
pointer-events: none;
}
@ -1151,7 +1326,7 @@ a.kpi:hover {
left: -1px;
right: -1px;
bottom: -2px;
border-bottom: 4px solid #2563eb;
border-bottom: 4px solid var(--accent-blue);
pointer-events: none;
}
@ -1164,13 +1339,13 @@ a.kpi:hover {
height: 0;
border-top: 7px solid transparent;
border-bottom: 7px solid transparent;
border-left: 10px solid #2563eb;
border-left: 10px solid var(--accent-blue);
pointer-events: none;
}
.drop-hint {
font-size: 0.75rem;
color: #1f4ea3;
color: var(--accent-blue-marker);
font-weight: 600;
}
@ -1178,21 +1353,22 @@ a.kpi:hover {
padding: 0.5rem 0.75rem;
border-radius: 4px;
border: 1px solid transparent;
color: var(--text-strong);
}
.notice.info {
background: #ebf3ff;
border-color: #bad1f7;
background: var(--notice-info-bg);
border-color: var(--notice-info-border);
}
.notice.error {
background: #fdecec;
border-color: #f5b5b5;
background: var(--notice-error-bg);
border-color: var(--notice-error-border);
}
.notice.warning {
background: #fff7ed;
border-color: #fdba74;
background: var(--notice-warning-bg);
border-color: var(--notice-warning-border);
}
.editor-error-notice {
@ -1203,12 +1379,13 @@ a.kpi:hover {
}
.notice.muted {
background: #f6f6f6;
border-color: #e4e4e4;
background: var(--notice-muted-bg);
border-color: var(--notice-muted-border);
color: var(--text-muted);
}
.todo-hint {
color: #6b7280;
color: var(--text-faint);
font-size: 0.8rem;
margin: 0;
}

View file

@ -1,4 +1,5 @@
import type { Metadata } from "next";
import Script from "next/script";
import "bootstrap/dist/css/bootstrap.min.css";
import "./globals.css";
import { AppShell } from "../frontend/components/AppShell";
@ -8,10 +9,33 @@ export const metadata: Metadata = {
description: "Leistungsbilanz für elektrische Verbraucher und Stromkreislisten",
};
// Keep this key literal in sync with THEME_STORAGE_KEY in ThemeToggle.tsx.
// It must stay inline (not imported) so it runs before hydration and never
// flashes the wrong theme on load.
const THEME_INIT_SCRIPT = `
(function () {
try {
var stored = localStorage.getItem("leistungsbilanz:theme");
var theme =
stored === "dark" || stored === "light"
? stored
: window.matchMedia("(prefers-color-scheme: dark)").matches
? "dark"
: "light";
document.documentElement.setAttribute("data-bs-theme", theme);
} catch (error) {
// Storage/matchMedia unavailable: fall back to the default light theme.
}
})();
`;
export default function RootLayout({ children }: Readonly<{ children: React.ReactNode }>) {
return (
<html lang="de">
<html lang="de" suppressHydrationWarning>
<body>
<Script id="theme-init" strategy="beforeInteractive">
{THEME_INIT_SCRIPT}
</Script>
<AppShell>{children}</AppShell>
</body>
</html>