:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #f7fafc;
    --surface-elevated: #ffffff;
    --border: #d9e2ec;
    --text: #162033;
    --muted: #66758a;
    --accent: #1f6c5a;
    --accent-strong: #165244;
    --success: #2f6f4f;
    --danger: #b54848;
    --page-glow: rgba(68, 160, 141, 0.16);
    --page-gradient-start: #eef4f8;
    --page-gradient-end: #eef3f7;
    --card-bg: rgba(255, 255, 255, 0.9);
    --card-border: rgba(217, 226, 236, 0.75);
    --input-bg: #ffffff;
    --hover-soft: rgba(19, 49, 74, 0.05);
    --hover-soft-strong: rgba(19, 49, 74, 0.09);
    --alert-danger-bg: #fdeeee;
    --alert-danger-border: #f4caca;
    --alert-success-bg: #ebf7ef;
    --alert-success-border: #cfe7d6;
    --debug-bg: #f7f9fc;
    --modal-backdrop: rgba(15, 23, 42, 0.42);
    --modal-surface: #ffffff;
    --modal-header-bg: rgba(255, 255, 255, 0.96);
    --chart-tick: #66758a;
    --chart-grid: rgba(102, 117, 138, 0.12);
    --chart-legend: #415266;
    --chart-empty-range: #d7e0e7;
    --chart-pie-border: #ffffff;
    --shadow: 0 18px 55px rgba(19, 35, 61, 0.08);
    --radius: 20px;
}

:root[data-theme="dark"] {
    --bg: #0b1420;
    --surface: #111c29;
    --surface-soft: #172434;
    --surface-elevated: #1b2b3f;
    --border: #2d4054;
    --text: #e5edf6;
    --muted: #9eb0c3;
    --accent: #3aa28b;
    --accent-strong: #63c4a8;
    --success: #6db989;
    --danger: #e47b7b;
    --page-glow: rgba(58, 162, 139, 0.18);
    --page-gradient-start: #08111b;
    --page-gradient-end: #0d1826;
    --card-bg: rgba(14, 24, 37, 0.9);
    --card-border: rgba(76, 98, 122, 0.45);
    --input-bg: #132131;
    --hover-soft: rgba(158, 176, 195, 0.1);
    --hover-soft-strong: rgba(158, 176, 195, 0.16);
    --alert-danger-bg: rgba(180, 72, 72, 0.16);
    --alert-danger-border: rgba(228, 123, 123, 0.34);
    --alert-success-bg: rgba(47, 111, 79, 0.2);
    --alert-success-border: rgba(99, 196, 168, 0.26);
    --debug-bg: #0d1724;
    --modal-backdrop: rgba(2, 8, 16, 0.68);
    --modal-surface: #122030;
    --modal-header-bg: rgba(18, 32, 48, 0.96);
    --chart-tick: #9eb0c3;
    --chart-grid: rgba(158, 176, 195, 0.16);
    --chart-legend: #d2deea;
    --chart-empty-range: #31465d;
    --chart-pie-border: #111c29;
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.34);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

.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;
}

.muted-text {
    color: var(--muted);
}

.admin-text-danger {
    color: var(--danger);
    font-weight: 600;
}

.measurement-results-list {
    min-height: 10.75rem;
    max-height: 10.75rem;
    overflow-y: auto;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-soft);
}

.measurement-results-list__header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    padding: 0 0 0.55rem;
    margin-bottom: 0.2rem;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.measurement-results-list__item {
    padding: 0.45rem 0;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 72%, transparent 28%);
    font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.92rem;
    color: var(--text);
    word-break: break-word;
}

.measurement-results-list__item:last-child {
    border-bottom: 0;
}

.measurement-results-list__item--preview {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
}

.measurement-results-list__name {
    min-width: 0;
    word-break: break-word;
}

.measurement-results-list__value {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2rem;
    padding: 0.2rem 0.7rem;
    border-radius: 999px;
    border: 1px solid rgba(31, 108, 90, 0.18);
    background: rgba(31, 108, 90, 0.1);
    color: #1f6c5a;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

.measurement-results-list__empty {
    color: var(--muted);
    font-size: 0.95rem;
}

.checkbox-field {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    color: var(--text);
}

.export-form {
    gap: 18px;
}

.export-form__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.export-form__fieldset {
    margin: 0;
}

.export-meter-option {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    padding: 0.85rem 0.95rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-soft);
}

.export-meter-option span {
    display: grid;
    gap: 0.18rem;
}

.export-meter-option small {
    color: var(--muted);
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top right, var(--page-glow), transparent 30%),
        linear-gradient(180deg, var(--page-gradient-start) 0%, var(--bg) 55%, var(--page-gradient-end) 100%);
}

body {
    min-height: 100vh;
    background-color: var(--bg);
}

body.has-info-modal {
    overflow: hidden;
}

html.theme-dark,
body.theme-dark {
    color: var(--text);
    background-color: var(--bg);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select {
    font: inherit;
}

.eyebrow {
    display: inline-block;
    margin-bottom: 0.6rem;
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.button-primary,
.button-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid transparent;
    padding: 0.9rem 1.2rem;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.button-primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
    color: #fff;
    box-shadow: 0 14px 28px rgba(31, 108, 90, 0.24);
}

.button-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}

.button-primary:hover,
.button-secondary:hover,
.range-switch__button:hover {
    transform: translateY(-1px);
}

.login-page {
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-shell {
    width: min(460px, 100%);
}

.login-card,
.sidebar,
.dashboard-header,
.widget-card,
.empty-state,
.error-box {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.login-card {
    padding: 36px;
}

.login-card h2,
.dashboard-header h2,
.empty-state h3 {
    margin: 0 0 0.8rem;
}

.login-card p,
.widget-card__header p,
.dashboard-header p,
.empty-state p {
    color: var(--muted);
    line-height: 1.6;
}

.stack-form {
    display: grid;
    gap: 18px;
    margin-top: 24px;
}

.login-card__actions {
    margin-top: 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.text-link {
    color: var(--accent-strong);
    font-weight: 600;
}

.text-link:hover {
    color: var(--accent);
}

.form-field {
    display: grid;
    gap: 8px;
}

.form-field span {
    font-weight: 600;
}

.form-field input,
.tenant-switch select {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--input-bg);
    border-radius: 14px;
    padding: 0.9rem 1rem;
    color: var(--text);
}

.form-field input[type="color"] {
    width: 52px;
    min-width: 52px;
    height: 52px;
    padding: 6px;
    border-radius: 14px;
}

.form-note {
    padding: 14px 16px;
    border-radius: 14px;
    background: #f5f9fb;
    border: 1px solid #dce7ee;
    color: var(--muted);
    line-height: 1.6;
    font-size: 0.94rem;
}

.form-field--color {
    align-items: start;
}

.color-input-row {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--input-bg);
    width: fit-content;
    box-shadow: 0 8px 18px rgba(19, 35, 61, 0.05);
}

.copy-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
}

.copy-field--compact {
    margin-top: 8px;
    grid-template-columns: minmax(0, 1fr) auto;
}

.copy-field--compact input {
    padding: 0.7rem 0.85rem;
    font-size: 0.9rem;
}

.copy-field--compact .button-secondary {
    padding: 0.65rem 0.9rem;
    font-size: 0.88rem;
    border-radius: 12px;
    color: var(--muted);
    background: var(--surface-soft);
    border-color: var(--border);
    box-shadow: none;
}

.copy-field input {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--input-bg);
    border-radius: 14px;
    padding: 0.9rem 1rem;
    color: var(--text);
}

.display-config-box {
    display: grid;
    gap: 14px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 86%, white 14%) 0%, color-mix(in srgb, var(--surface-soft) 88%, var(--surface) 12%) 100%);
}

.alert {
    border-radius: 14px;
    padding: 14px 16px;
    margin-top: 20px;
}

.alert-error {
    background: var(--alert-danger-bg);
    color: var(--danger);
    border: 1px solid var(--alert-danger-border);
}

.alert-success {
    background: var(--alert-success-bg);
    color: var(--accent-strong);
    border: 1px solid var(--alert-success-border);
}

.dashboard-page {
    padding: 22px;
}

.display-page {
    padding: 18px;
}

.app-shell {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 24px;
    min-height: calc(100vh - 44px);
}

.display-shell {
    display: grid;
    gap: 22px;
    min-height: calc(100vh - 36px);
}

.display-content {
    display: grid;
}

.display-header {
    margin: 0;
}

.display-auth-shell {
    min-height: calc(100vh - 36px);
    display: grid;
    place-items: center;
}

.display-auth-card {
    width: min(520px, 100%);
    padding: 36px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.display-auth-card h1 {
    margin-top: 0;
    margin-bottom: 0.9rem;
}

.display-auth-card p {
    color: var(--muted);
    line-height: 1.6;
}

.display-code-panel {
    display: grid;
    gap: 10px;
    margin-top: 24px;
    padding: 24px;
    border-radius: 20px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--surface-soft) 92%, white 8%) 0%, color-mix(in srgb, var(--surface-soft) 72%, var(--surface) 28%) 100%);
    border: 1px solid var(--border);
}

.display-code-panel__label {
    color: var(--muted);
    font-size: 0.92rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.display-code-panel__code {
    font-size: clamp(2.4rem, 7vw, 4.6rem);
    line-height: 1;
    font-weight: 800;
    letter-spacing: 0.14em;
    color: var(--accent-strong);
}

.display-code-panel__countdown {
    color: var(--muted);
    font-size: 1rem;
}

.display-code-panel__countdown strong {
    color: var(--text);
}

.sidebar {
    padding: 24px;
    display: grid;
    gap: 28px;
    align-content: start;
}

.sidebar__brand h1 {
    margin: 0;
    font-size: 1.35rem;
}

.sidebar__label {
    display: inline-block;
    margin-bottom: 10px;
    font-size: 0.85rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sidebar__tenant-name {
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
}

.sidebar__nav {
    display: grid;
    gap: 10px;
}

.nav-link {
    display: grid;
    gap: 4px;
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid transparent;
    transition: background 0.18s ease, border-color 0.18s ease;
}

.nav-link small {
    color: var(--muted);
    line-height: 1.45;
}

.nav-link.is-active {
    background: linear-gradient(135deg, rgba(31, 108, 90, 0.12) 0%, rgba(31, 108, 90, 0.06) 100%);
    border-color: rgba(31, 108, 90, 0.22);
}

.nav-link:hover {
    background: color-mix(in srgb, var(--surface-soft) 90%, var(--surface) 10%);
    border-color: var(--border);
}

.dashboard-content {
    display: grid;
    gap: 22px;
    align-content: start;
}

.dashboard-header {
    padding: 28px 30px;
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: center;
}

.dashboard-header__meta {
    display: flex;
    justify-content: flex-end;
}

.meta-pill {
    display: grid;
    gap: 4px;
    padding: 14px 18px;
    border-radius: 18px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
}

.meta-pill > span {
    color: var(--muted);
    font-size: 0.92rem;
}

.header-preferences {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.theme-switch {
    display: flex;
    align-items: center;
}

.info-switch {
    display: flex;
    align-items: center;
}

.theme-switch__button {
    padding: 0;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.theme-switch__button:hover {
    color: var(--text);
}

.theme-switch__button:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--accent) 56%, white 44%);
    outline-offset: 2px;
}

.theme-switch__button.is-active {
    opacity: 1;
}

.theme-switch__icon {
    font-size: 0.95rem;
    line-height: 1;
    color: inherit;
}

.info-switch__button {
    padding: 0;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.92rem;
    font-family: Georgia, "Times New Roman", serif;
}

.info-switch__button:hover {
    color: var(--text);
}

.info-switch__button:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--accent) 56%, white 44%);
    outline-offset: 2px;
}

.info-switch__icon {
    line-height: 1;
    color: inherit;
}

.info-modal {
    position: fixed;
    inset: 0;
    z-index: 1250;
    display: grid;
    place-items: center;
    padding: 24px;
}

.info-modal__backdrop {
    position: absolute;
    inset: 0;
    background: var(--modal-backdrop);
    backdrop-filter: blur(3px);
}

.info-modal__dialog {
    position: relative;
    width: min(520px, 100%);
    border-radius: 24px;
    border: 1px solid var(--border);
    background: var(--modal-surface);
    box-shadow: 0 28px 60px rgba(15, 23, 42, 0.22);
    overflow: hidden;
    display: grid;
}

.info-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--modal-header-bg);
}

.info-modal__header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.info-modal__close {
    white-space: nowrap;
}

.info-modal__body {
    padding: 24px;
    display: grid;
    gap: 22px;
}

.info-modal__section {
    display: grid;
    gap: 10px;
}

.info-modal__section p {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.info-modal__version {
    font-size: 1.45rem;
    line-height: 1.1;
}

.info-modal__link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0.95rem 1rem;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--surface-soft);
    transition: transform 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}

.info-modal__link::after {
    content: "↗";
    color: var(--muted);
    font-size: 0.92rem;
}

.info-modal__link:hover {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--accent) 26%, var(--border) 74%);
    background: color-mix(in srgb, var(--surface-soft) 84%, var(--surface) 16%);
}

.legal-page {
    padding: 22px;
}

.legal-shell {
    width: min(920px, 100%);
    margin: 0 auto;
    display: grid;
    gap: 22px;
}

.legal-card {
    padding: 28px 30px;
}

.legal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
}

.legal-header h1,
.legal-section h2 {
    margin: 0 0 0.8rem;
}

.legal-header p,
.legal-section p,
.legal-section li,
.legal-empty {
    color: var(--muted);
    line-height: 1.65;
}

.legal-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.legal-content {
    display: grid;
    gap: 18px;
}

.legal-section {
    padding: 20px 22px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface-soft) 82%, var(--surface) 18%);
}

.legal-definition-list {
    margin: 0;
    display: grid;
    gap: 16px;
}

.legal-definition-list dt {
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.legal-definition-list dd {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.legal-empty {
    margin: 0;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--alert-danger-border);
    background: var(--alert-danger-bg);
    color: var(--danger);
}

.legal-list {
    margin: 0;
    padding-left: 1.2rem;
}

.locale-switch {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 0;
}

.locale-switch__options {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.locale-switch__option {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: var(--hover-soft);
    border: 1px solid transparent;
    text-decoration: none;
    font-size: 0.95rem;
    opacity: 0.68;
    transition: opacity 0.18s ease, transform 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}

.locale-switch__option:hover {
    opacity: 1;
    transform: translateY(-1px);
}

.locale-switch__option.is-active {
    opacity: 1;
    border-color: color-mix(in srgb, var(--text) 18%, transparent 82%);
    background: var(--hover-soft-strong);
}

.widget-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 22px;
}

.widget-card {
    min-height: calc(120px + (var(--tile-rows, 2) * 92px));
    padding: 22px;
    display: grid;
    gap: 16px;
    transition: box-shadow 0.18s ease, opacity 0.18s ease;
}

.widget-card.span-2 {
    grid-column: span 2;
}

.widget-card.span-3 {
    grid-column: span 3;
}

.widget-card.span-4 {
    grid-column: span 4;
}

.widget-card.span-5 {
    grid-column: span 5;
}

.widget-card__header {
    display: flex;
    gap: 18px;
    justify-content: space-between;
    align-items: flex-start;
}

.widget-card__header h3 {
    margin: 0 0 6px;
    font-size: 1.1rem;
}

.widget-card__header p {
    margin: 0;
}

.widget-card__body {
    display: grid;
    gap: 14px;
    align-content: start;
    min-height: 0;
}

.widget-status {
    color: var(--muted);
    font-size: 0.95rem;
}

.widget-card.is-loading {
    opacity: 0.92;
}

.widget-render {
    display: grid;
    gap: 16px;
    min-height: 72px;
}

.widget-chart-frame {
    position: relative;
    width: 100%;
    height: var(--chart-height, 280px);
    min-height: 220px;
    max-height: 360px;
}

.widget-canvas {
    display: block;
    width: 100% !important;
    max-width: 100%;
    height: 100% !important;
    min-height: 0;
    max-height: none;
}

.range-switch {
    display: inline-flex;
    gap: 8px;
    flex-wrap: wrap;
}

.range-switch__button {
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text);
    border-radius: 999px;
    padding: 0.45rem 0.8rem;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.range-switch__button.is-active {
    background: rgba(31, 108, 90, 0.12);
    color: var(--accent-strong);
    border-color: rgba(31, 108, 90, 0.24);
}

.stat-kpi {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.stat-kpi__value {
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 700;
    line-height: 1;
}

.stat-kpi__unit {
    color: var(--muted);
    font-size: 1.05rem;
}

.stat-meta-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
}

.stat-meta-inline__timestamp {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 0.82rem;
}

.stat-meta-inline__timestamp span {
    color: var(--muted);
}

.stat-meta-inline__timestamp strong {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 600;
}

.stat-meta,
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
}

.stat-meta__item,
.summary-item {
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--surface-soft);
    padding: 12px 14px;
    display: grid;
    gap: 4px;
}

.stat-meta__item span,
.summary-item span {
    color: var(--muted);
    font-size: 0.85rem;
}

.wallbox-status-widget {
    display: grid;
    gap: 14px;
}

.wallbox-status-widget__state {
    display: flex;
    align-items: center;
}

.wallbox-status-widget__state .wallbox-occupancy {
    font-size: 1.1rem;
    padding: 9px 16px;
    gap: 10px;
}

.wallbox-status-widget__state .wallbox-occupancy::before {
    width: 10px;
    height: 10px;
}

.wallbox-status-widget__name {
    font-size: clamp(1.35rem, 2.2vw, 1.9rem);
    font-weight: 700;
    line-height: 1.15;
    color: var(--text);
}

.wallbox-status-widget__tenant {
    color: var(--muted);
    font-size: 0.95rem;
}

.flow-widget {
    display: grid;
    gap: 16px;
}

.flow-widget__meta {
    display: flex;
    justify-content: flex-end;
    min-height: 1.4rem;
}

.flow-widget__timestamp {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    color: var(--muted);
    font-size: 0.8rem;
}

.flow-widget__timestamp strong {
    color: var(--text);
    font-weight: 600;
}

.flow-widget__empty {
    display: grid;
    gap: 16px;
    align-items: center;
    justify-items: center;
    text-align: center;
    min-height: 280px;
    padding: 28px 20px;
    border-radius: 22px;
    border: 1px dashed color-mix(in srgb, var(--border) 80%, transparent 20%);
    background:
        radial-gradient(circle at top, rgba(212, 139, 28, 0.12), transparent 32%),
        linear-gradient(180deg, color-mix(in srgb, var(--surface-soft) 88%, transparent 12%), var(--surface));
}

.flow-widget__empty-icon {
    width: 56px;
    height: 56px;
    display: grid;
    place-items: center;
    border-radius: 18px;
    background: rgba(31, 108, 90, 0.1);
    color: var(--accent);
}

.flow-widget__empty-icon svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

.flow-widget__empty strong {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 1.05rem;
}

.flow-widget__empty p {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.flow-graph {
    position: relative;
    min-height: 360px;
    aspect-ratio: 1 / 0.9;
    border-radius: 26px;
    overflow: hidden;
    background:
        radial-gradient(circle at top, rgba(212, 139, 28, 0.12), transparent 28%),
        radial-gradient(circle at left, rgba(47, 127, 213, 0.08), transparent 24%),
        radial-gradient(circle at right, rgba(35, 161, 135, 0.08), transparent 24%),
        linear-gradient(180deg, color-mix(in srgb, var(--surface-soft) 88%, white 12%), var(--surface));
    border: 1px solid color-mix(in srgb, var(--border) 82%, transparent 18%);
}

.flow-graph__svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.flow-graph__wire {
    fill: none;
    stroke: color-mix(in srgb, var(--border) 75%, transparent 25%);
    stroke-width: 1.2;
    stroke-linecap: round;
}

.flow-graph__flow {
    fill: none;
    stroke: color-mix(in srgb, var(--border) 74%, var(--flow-color, var(--accent)) 26%);
    stroke-width: 0.92;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.48;
}

.flow-graph__pulse {
    fill: var(--flow-color, var(--accent));
    opacity: 0.82;
    filter: drop-shadow(0 0 2px color-mix(in srgb, var(--flow-color, var(--accent)) 22%, transparent 78%));
}

.flow-hub {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 56px;
    height: 56px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 1px solid color-mix(in srgb, var(--border) 72%, transparent 28%);
    background:
        radial-gradient(circle, rgba(31, 108, 90, 0.12), color-mix(in srgb, var(--surface-elevated) 92%, white 8%));
    box-shadow: inset 0 0 0 8px color-mix(in srgb, var(--surface-elevated) 65%, transparent 35%);
}

.flow-node {
    position: absolute;
    width: min(28%, 172px);
    min-width: 102px;
    padding: 11px 11px 10px;
    border-radius: 22px;
    border: 1px solid color-mix(in srgb, var(--border) 80%, transparent 20%);
    background: color-mix(in srgb, var(--surface-elevated) 92%, white 8%);
    box-shadow: 0 14px 28px rgba(15, 37, 64, 0.08);
    text-align: center;
    display: grid;
    gap: 5px;
    transform: translate(-50%, -50%);
    z-index: 2;
}

.flow-node--pv {
    z-index: 3;
}

.flow-node--grid {
    z-index: 3;
}

.flow-node--battery {
    z-index: 3;
}

.flow-node--home {
    z-index: 3;
}

.flow-node--extra {
    width: min(19%, 122px);
    min-width: 78px;
    padding: 8px 8px 7px;
    border-radius: 18px;
    gap: 4px;
}

.flow-node__icon {
    width: 40px;
    height: 40px;
    margin: 0 auto;
    border-radius: 14px;
    display: grid;
    place-items: center;
    color: var(--accent);
    background: rgba(31, 108, 90, 0.1);
}

.flow-node--pv .flow-node__icon {
    color: #d48b1c;
    background: rgba(212, 139, 28, 0.12);
}

.flow-node--grid .flow-node__icon {
    color: #2f7fd5;
    background: rgba(47, 127, 213, 0.12);
}

.flow-node--battery .flow-node__icon {
    color: #23a187;
    background: rgba(35, 161, 135, 0.12);
}

.flow-node--producer .flow-node__icon {
    color: #d48b1c;
    background: rgba(212, 139, 28, 0.1);
}

.flow-node--consumer .flow-node__icon {
    color: #1f6c5a;
    background: rgba(31, 108, 90, 0.1);
}

.flow-node__icon svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.flow-node--extra .flow-node__icon {
    width: 30px;
    height: 30px;
    border-radius: 12px;
}

.flow-node--extra .flow-node__icon svg {
    width: 16px;
    height: 16px;
}

.flow-node__label {
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--muted);
}

.flow-node__value {
    font-size: clamp(0.98rem, 1.35vw, 1.14rem);
    font-weight: 700;
    color: var(--text);
}

.flow-node--extra .flow-node__value {
    font-size: clamp(0.82rem, 1.05vw, 0.94rem);
}

.flow-node--extra .flow-node__label {
    font-size: 0.69rem;
}

.flow-graph--extended {
    min-height: 382px;
}

.flow-graph--dense {
    min-height: 404px;
}

.flow-widget--dense .flow-node {
    width: min(26%, 160px);
    min-width: 96px;
    padding: 10px 10px 9px;
}

.flow-widget--dense .flow-node--extra {
    width: min(18%, 112px);
    min-width: 74px;
}

.flow-widget--dense .flow-hub {
    width: 50px;
    height: 50px;
}

.flow-node--extra .flow-node__state,
.flow-node--extra .flow-node__note,
.flow-node--extra .flow-node__soc {
    font-size: 0.68rem;
}

.flow-node__state,
.flow-node__soc,
.flow-node__note {
    font-size: 0.76rem;
    color: var(--muted);
}

.flow-node__soc strong {
    color: var(--text);
    font-weight: 700;
}

.flow-node__note {
    font-style: italic;
}

.flow-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.flow-summary__item {
    border-radius: 18px;
    border: 1px solid var(--border);
    background: var(--surface-soft);
    padding: 13px 14px;
    display: grid;
    gap: 4px;
}

.flow-summary__item span {
    color: var(--muted);
    font-size: 0.84rem;
}

.flow-summary__item strong {
    font-size: 1.05rem;
    color: var(--text);
}

.summary-item strong {
    font-size: 1.05rem;
}

.form-grid {
    display: grid;
    gap: 14px;
}

.form-grid--triple {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.summary-item small {
    display: block;
}

.summary-item small + small {
    margin-top: 4px;
}

.distribution-summary-note {
    margin-top: 14px;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 999px;
    width: fit-content;
    font-size: 0.85rem;
    color: #173224;
    background: rgba(31, 108, 90, 0.12);
}

.pill::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: currentColor;
    opacity: 0.75;
}

.empty-state,
.error-box {
    padding: 32px;
}

.error-page {
    display: grid;
    place-items: center;
    padding: 24px;
}

.error-debug {
    margin-top: 18px;
    padding: 16px;
    background: var(--debug-bg);
    border-radius: 14px;
    overflow: auto;
}

.admin-content {
    align-content: start;
}

.admin-grid {
    display: grid;
    gap: 22px;
}

.admin-grid--cards {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.admin-grid--two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-grid--three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.admin-form,
.admin-inline-form {
    display: grid;
    gap: 16px;
}

.admin-inline-form {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
}

.admin-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.form-row {
    display: grid;
    gap: 16px;
}

.form-row--triple {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-row--double {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.check-field {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
}

.check-field.is-disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.check-field input {
    width: 18px;
    height: 18px;
}

.form-field textarea,
.form-field select {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--input-bg);
    border-radius: 14px;
    padding: 0.9rem 1rem;
    color: var(--text);
}

.field-help {
    color: var(--muted);
    font-size: 0.85rem;
}

.inline-info-box {
    display: grid;
    gap: 4px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: color-mix(in srgb, var(--surface) 80%, white 20%);
}

.admin-table-wrap {
    overflow: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.admin-table th {
    color: var(--muted);
    font-size: 0.84rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.admin-table td input[type="number"] {
    max-width: 110px;
}

.admin-table td input[type="text"],
.admin-table td select {
    width: 100%;
    min-width: 0;
}

.meter-table td strong {
    display: inline-block;
    margin-bottom: 2px;
}

.admin-table-section-row td {
    padding: 14px 10px 10px;
    background: color-mix(in srgb, var(--surface-soft) 78%, white 22%);
    border-bottom: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.masterdata-row--meter td:first-child,
.masterdata-row--wallbox td:first-child {
    border-left: 3px solid transparent;
}

.masterdata-row--meter td:first-child {
    border-left-color: color-mix(in srgb, var(--success) 70%, white 30%);
}

.masterdata-row--wallbox td:first-child {
    border-left-color: color-mix(in srgb, var(--accent) 75%, white 25%);
}

.wallbox-occupancy {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 0.84rem;
    font-weight: 600;
    line-height: 1;
    border: 1px solid transparent;
}

.wallbox-occupancy::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: currentColor;
}

.wallbox-occupancy--occupied {
    color: #b6542f;
    background: rgba(217, 108, 66, 0.12);
    border-color: rgba(217, 108, 66, 0.18);
}

.wallbox-occupancy--free {
    color: #2f6f4f;
    background: rgba(47, 111, 79, 0.12);
    border-color: rgba(47, 111, 79, 0.18);
}

.wallbox-occupancy--unknown {
    color: var(--muted);
    background: color-mix(in srgb, var(--surface-soft) 85%, white 15%);
    border-color: var(--border);
}


.widget-card__header--compact {
    margin-bottom: 12px;
}

.meter-management {
    display: grid;
    gap: 22px;
}

.meter-management__tabs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.meter-management__tab.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.meter-management__section.is-hidden {
    display: none;
}

.meter-management__detail-card {
    margin-top: 22px;
}

.meter-management__detail-hint {
    margin-top: 22px;
}

.meter-management__modal {
    display: grid;
    gap: 22px;
}

.meter-management__history {
    display: grid;
    gap: 12px;
}

.meter-management__detail-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.meter-management__panel {
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: color-mix(in srgb, var(--surface) 84%, white 16%);
}

.meter-management__panel--full {
    grid-column: 1 / -1;
}

.meter-management__panel h4 {
    margin: 0 0 8px;
}

.meter-management__clickable-row {
    cursor: pointer;
}

.meter-management__clickable-row:hover td,
.meter-management__clickable-row:focus td {
    background: color-mix(in srgb, var(--accent) 9%, white 91%);
}

.meter-management__row.is-selected td:first-child {
    border-left: 3px solid color-mix(in srgb, var(--accent) 75%, white 25%);
}

.meter-management__process-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 16px;
}

.meter-management__process-image-wrap {
    display: grid;
    gap: 14px;
}

.meter-management__process-image {
    display: block;
    width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface-soft) 80%, white 20%);
}

.meter-management__retire-button {
    background: #a44f39;
    border-color: #a44f39;
}

.meter-management__audit-list {
    display: grid;
    gap: 14px;
}

@media (max-width: 960px) {
    .meter-management__detail-grid {
        grid-template-columns: 1fr;
    }

    .meter-management__process-grid {
        grid-template-columns: 1fr;
    }
}

.meter-audit-card {
    border: 1px solid var(--border);
    border-radius: 18px;
    background: color-mix(in srgb, var(--surface) 84%, white 16%);
    padding: 16px 18px;
    display: grid;
    gap: 12px;
}

.meter-audit-card__header,
.meter-audit-card__meta {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.meter-audit-card__meta {
    color: var(--muted);
    font-size: 0.92rem;
}

.meter-audit-card__payloads {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.meter-audit-card__payloads pre {
    margin: 0;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface-soft) 84%, white 16%);
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.admin-header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.user-rfid-editor {
    width: 100%;
}

.user-rfid-editor .admin-table td {
    min-width: 120px;
}

.user-rfid-editor .admin-table td:last-child {
    min-width: 110px;
}

.rfid-matrix-wrap {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: color-mix(in srgb, var(--surface) 86%, white 14%);
}

.rfid-matrix {
    min-width: max-content;
}

.rfid-matrix-table {
    border-collapse: separate;
    border-spacing: 0;
}

.rfid-matrix-table thead th {
    position: sticky;
    top: 0;
    z-index: 4;
    background: color-mix(in srgb, var(--surface) 92%, white 8%);
    box-shadow: inset 0 -1px 0 var(--border);
}

.rfid-matrix-corner,
.rfid-matrix-wallbox {
    position: sticky;
    left: 0;
    z-index: 5;
    background: color-mix(in srgb, var(--surface-soft) 88%, white 12%);
}

.rfid-matrix-corner {
    min-width: 220px;
}

.rfid-matrix-wallbox {
    font-size: 0.92rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text);
}

.rfid-matrix-user-head,
.rfid-matrix-card-head {
    min-width: 240px;
    vertical-align: top;
}

.rfid-matrix-user-head__body {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 12px;
}

.rfid-matrix-user-head__body strong,
.rfid-matrix-card__summary strong {
    display: block;
    color: var(--text);
}

.rfid-matrix-user-head__body small,
.rfid-matrix-card__summary small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: none;
    letter-spacing: 0;
}

.rfid-matrix-card {
    display: grid;
    gap: 12px;
}

.rfid-matrix-card--empty {
    min-height: 92px;
    align-content: center;
}

.rfid-matrix-card__summary,
.rfid-matrix-card__actions {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 8px;
}

.rfid-matrix-card__actions {
    justify-content: end;
    flex-wrap: wrap;
}

.rfid-matrix-card__fields {
    display: grid;
    gap: 10px;
    padding: 12px;
    border-radius: 14px;
    background: color-mix(in srgb, var(--surface-soft) 88%, white 12%);
    border: 1px solid var(--border);
}

.rfid-matrix-card__fields .form-field {
    margin: 0;
}

.rfid-matrix-card__fields input[type="number"],
.rfid-matrix-card__fields input[type="text"] {
    width: 100%;
}

.rfid-matrix-cell {
    min-width: 120px;
    text-align: center;
    vertical-align: middle;
}

.rfid-matrix-cell--empty {
    color: var(--muted);
    font-weight: 600;
}

.rfid-matrix-cell__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 48px;
}

.rfid-matrix-cell__toggle span {
    font-size: 0.78rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.rfid-wallbox-list {
    display: grid;
    gap: 6px;
    max-height: 150px;
    overflow-y: auto;
    padding-right: 4px;
}

.rfid-wallbox-option {
    align-items: flex-start;
}

.rfid-wallbox-option span {
    line-height: 1.25;
}

.admin-row-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.button-danger {
    border-color: rgba(185, 80, 58, 0.18);
    color: #b9503a;
}

.report-delivery-form {
    gap: 22px;
}

.report-delivery-recipients {
    display: grid;
    gap: 14px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: color-mix(in srgb, var(--surface-soft) 72%, white 28%);
}

.report-delivery-section__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.report-delivery-section__header p {
    margin: 6px 0 0;
    color: var(--muted);
}

.report-delivery-recipient-list {
    display: grid;
    gap: 10px;
}

.report-delivery-recipient-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
}

.report-delivery-report-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.report-delivery-option {
    display: grid;
    gap: 14px;
    padding: 18px;
    border-radius: 18px;
    border: 1px solid var(--border);
    background: var(--surface-soft);
}

.report-delivery-option.is-disabled {
    opacity: 0.7;
}

.report-delivery-rule-grid {
    display: grid;
    gap: 16px;
}

.report-delivery-card {
    display: grid;
    gap: 16px;
    padding: 22px;
    border-radius: 22px;
    border: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 86%, white 14%);
}

.report-delivery-card__header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
}

.report-delivery-card__header h3 {
    margin: 0 0 6px;
}

.report-delivery-card__header p {
    margin: 0;
    color: var(--muted);
}

.report-delivery-card__body {
    display: grid;
    gap: 14px;
}

.report-delivery-badge {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 0.84rem;
    font-weight: 700;
    white-space: nowrap;
}

.report-delivery-badge.is-active {
    color: #2f6f4f;
    background: rgba(47, 111, 79, 0.12);
    border-color: rgba(47, 111, 79, 0.18);
}

.report-delivery-badge.is-paused {
    color: var(--muted);
    background: color-mix(in srgb, var(--surface-soft) 84%, white 16%);
    border-color: var(--border);
}

.report-delivery-pill-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.report-delivery-pill {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(31, 108, 90, 0.1);
    color: #1f6c5a;
    border: 1px solid rgba(31, 108, 90, 0.16);
    font-size: 0.85rem;
    font-weight: 600;
}

.report-delivery-recipient-summary strong {
    display: inline-block;
    margin-bottom: 8px;
}

.report-delivery-recipient-summary ul {
    margin: 0;
    padding-left: 18px;
}

.report-delivery-recipient-summary li {
    margin-bottom: 4px;
}

@media (max-width: 900px) {
    .report-delivery-report-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .report-delivery-section__header,
    .report-delivery-card__header,
    .report-delivery-recipient-row {
        grid-template-columns: 1fr;
        display: grid;
    }
}

.admin-row-actions form {
    margin: 0;
}

.admin-note {
    min-width: 0;
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    color: var(--muted);
}

.admin-note pre {
    margin: 10px 0 0;
    max-width: 100%;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 82%, var(--surface-soft) 18%);
    overflow-x: auto;
}

.admin-note code {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.simple-list {
    margin: 10px 0 0;
    padding-left: 18px;
}

.simple-list li + li {
    margin-top: 6px;
}

.code-block {
    margin: 10px 0 0;
    padding: 12px 14px;
    border-radius: 14px;
    background: color-mix(in srgb, var(--surface) 28%, #08111b 72%);
    color: #f2f6fb;
    font-size: 0.84rem;
    line-height: 1.5;
    overflow-x: auto;
    white-space: pre;
}

.admin-tabs {
    display: flex;
    gap: 10px;
    padding: 10px;
    border-radius: 18px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.admin-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 14px;
    color: var(--muted);
    text-decoration: none;
    font-weight: 600;
    transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.admin-tab:hover {
    color: var(--text);
    background: color-mix(in srgb, var(--surface) 72%, transparent 28%);
}

.admin-tab.is-active {
    background: var(--surface-elevated);
    color: var(--text);
    box-shadow: 0 8px 20px rgba(22, 32, 51, 0.08);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

.status-badge__dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    flex: 0 0 10px;
    box-shadow: 0 0 0 3px rgba(22, 32, 51, 0.05);
}

.status-badge.is-active .status-badge__dot {
    background: #2f6f4f;
}

.status-badge.is-inactive .status-badge__dot {
    background: #d96c42;
}

.status-badge.is-pending .status-badge__dot {
    background: #d5a038;
}

.status-badge.is-active {
    color: #2f6f4f;
}

.status-badge.is-inactive {
    color: #b6542f;
}

.status-badge.is-pending {
    color: #a66f14;
}

.admin-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: grid;
    place-items: center;
    padding: 24px;
}

.admin-modal[data-critical-confirm-modal] {
    z-index: 1300;
}

.admin-modal__backdrop {
    position: absolute;
    inset: 0;
    background: var(--modal-backdrop);
    backdrop-filter: blur(3px);
}

.admin-modal__dialog {
    position: relative;
    width: min(760px, 100%);
    height: min(720px, calc(100vh - 48px));
    max-height: calc(100vh - 48px);
    overflow: hidden;
    border-radius: 24px;
    border: 1px solid var(--border);
    background: var(--modal-surface);
    box-shadow: 0 28px 60px rgba(15, 23, 42, 0.22);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
}

.admin-modal__header {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: var(--modal-header-bg);
    backdrop-filter: blur(8px);
}

.admin-modal__header h3 {
    margin: 0;
    font-size: 1.15rem;
}

.admin-modal__body {
    padding: 24px;
    min-height: 0;
    overflow-y: auto;
}

.password-feedback {
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--surface-soft);
    display: grid;
    gap: 10px;
}

.password-feedback.is-valid {
    border-color: rgba(47, 111, 79, 0.35);
    background: rgba(110, 169, 122, 0.12);
}

.password-feedback.is-invalid {
    border-color: rgba(217, 108, 66, 0.35);
    background: rgba(217, 108, 66, 0.08);
}

.password-rules {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 8px;
}

.password-rules li {
    position: relative;
    padding-left: 24px;
    color: var(--muted);
    transition: color 0.18s ease;
}

.password-rules li::before {
    content: "○";
    position: absolute;
    left: 0;
    top: 0;
    font-weight: 700;
    transition: color 0.18s ease, transform 0.18s ease;
}

.password-rules li.is-valid {
    color: #2f6f4f;
    font-weight: 600;
}

.password-rules li.is-valid::before {
    content: "✓";
    color: #2f6f4f;
    transform: scale(1.05);
}

.password-rules li.is-invalid {
    color: #d96c42;
    font-weight: 600;
}

.password-rules li.is-invalid::before {
    content: "✕";
    color: #d96c42;
}

.password-feedback__message {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.password-feedback.is-valid .password-feedback__message {
    color: #2f6f4f;
}

.password-feedback.is-invalid .password-feedback__message {
    color: #d96c42;
}

.two-factor-qr-card {
    display: grid;
    gap: 12px;
    justify-items: center;
    text-align: center;
    margin-bottom: 18px;
}

.two-factor-qr-card__image {
    width: min(260px, 100%);
    padding: 14px;
    border-radius: 18px;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
}

.two-factor-qr-card__image svg {
    display: block;
    width: 100%;
    height: auto;
}

.two-factor-qr-card__image img {
    display: block;
    width: 100%;
    height: auto;
}

.two-factor-setup {
    margin-bottom: 20px;
    display: grid;
    gap: 18px;
}

.two-factor-setup p {
    margin: 0;
}

.two-factor-setup__meta {
    display: grid;
    gap: 14px;
}

.two-factor-setup__row {
    display: grid;
    gap: 8px;
}

.two-factor-setup__label {
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.sortable-pages {
    display: grid;
    gap: 12px;
}

.sortable-page-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    gap: 14px;
    align-items: center;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface-elevated);
    cursor: grab;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.sortable-page-card:hover {
    border-color: rgba(47, 111, 79, 0.3);
}

.sortable-page-card.is-dragging {
    opacity: 0.72;
    transform: scale(0.995);
    box-shadow: 0 12px 32px rgba(22, 32, 51, 0.12);
}

.sortable-page-card.is-drop-target {
    border-color: rgba(47, 111, 79, 0.45);
    box-shadow: 0 10px 24px rgba(47, 111, 79, 0.12);
}

.sortable-page-card__handle {
    color: var(--muted);
    font-size: 1.2rem;
    line-height: 1;
    letter-spacing: 0.08em;
    user-select: none;
}

.sortable-page-card__content {
    display: grid;
    gap: 4px;
}

.sortable-page-card__content small {
    color: var(--muted);
}

.sortable-page-card__visibility {
    justify-self: start;
}

.sortable-page-card__meta {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-self: end;
}

.sortable-page-card__position {
    color: var(--muted);
    font-size: 0.9rem;
    white-space: nowrap;
}

.widget-board {
    display: grid;
    grid-template-columns: 1fr;
    gap: 22px;
    align-items: start;
}

.widget-board__column {
    display: grid;
    gap: 14px;
    padding: 18px 18px 20px;
    border: 1px solid color-mix(in srgb, var(--accent) 26%, var(--border) 74%);
    border-left: 6px solid var(--success);
    border-radius: 24px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 92%, white 8%) 0%, color-mix(in srgb, var(--surface-soft) 82%, var(--surface) 18%) 100%);
    box-shadow: 0 16px 36px rgba(22, 32, 51, 0.06);
}

.widget-board__header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    padding-bottom: 14px;
    border-bottom: 1px solid color-mix(in srgb, var(--accent) 24%, var(--border) 76%);
}

.widget-board__headline {
    display: grid;
    gap: 4px;
}

.widget-board__eyebrow {
    color: var(--success);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.widget-board__header h4 {
    margin: 0;
    font-size: 1.08rem;
}

.widget-board__header p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.widget-board__sort-hint {
    margin-top: 10px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(31, 108, 90, 0.08);
    color: var(--accent-strong);
    font-size: 0.88rem;
    font-weight: 600;
}

.widget-board__separator {
    margin: 0 8px;
    color: rgba(47, 111, 79, 0.35);
}

.widget-board__list {
    display: grid;
    gap: 12px;
    min-height: 170px;
    padding: 8px;
    border-radius: 20px;
    background: color-mix(in srgb, var(--surface) 76%, transparent 24%);
    border: 1px dashed color-mix(in srgb, var(--accent) 26%, var(--border) 74%);
    transition: box-shadow 0.18s ease, border-color 0.18s ease;
}

.widget-board__list.is-drop-target {
    border-color: rgba(47, 111, 79, 0.38);
    box-shadow: inset 0 0 0 2px rgba(47, 111, 79, 0.18);
}

.widget-board__empty {
    margin: 0;
    padding: 18px 14px;
    border: 1px dashed rgba(47, 111, 79, 0.25);
    border-radius: 16px;
    background: color-mix(in srgb, var(--surface) 82%, transparent 18%);
    color: var(--muted);
    font-size: 0.94rem;
    text-align: center;
}

.widget-board__status {
    min-height: 1.4rem;
    color: var(--muted);
    font-size: 0.92rem;
}

.widget-board__status.is-saving {
    color: var(--accent-strong);
}

.widget-board__status.is-success {
    color: var(--accent-strong);
}

.widget-board__status.is-error {
    color: var(--danger);
}

.widget-sort-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface-elevated);
    cursor: grab;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.widget-sort-card:hover {
    border-color: rgba(47, 111, 79, 0.3);
}

.widget-sort-card.is-dragging {
    opacity: 0.74;
    transform: scale(0.995);
    box-shadow: 0 12px 32px rgba(22, 32, 51, 0.12);
}

.widget-sort-card.is-drop-target {
    border-color: rgba(47, 111, 79, 0.45);
    box-shadow: 0 10px 24px rgba(47, 111, 79, 0.12);
}

.widget-sort-card__handle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    align-self: start;
    padding: 8px 10px;
    border-radius: 14px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    color: var(--muted);
    line-height: 1;
    user-select: none;
    cursor: grab;
}

.widget-sort-card__handle-dots {
    font-size: 1.2rem;
    letter-spacing: 0.08em;
}

.widget-sort-card__handle-label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.widget-sort-card__content {
    display: grid;
    gap: 6px;
}

.widget-sort-card__content strong {
    display: block;
}

.widget-sort-card__content small {
    color: var(--muted);
    word-break: break-word;
}

.widget-sort-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    color: var(--muted);
    font-size: 0.88rem;
}

.widget-sort-card__meta span {
    padding: 4px 8px;
    border-radius: 999px;
    background: #f3f5f2;
}

.widget-sort-card__status,
.widget-sort-card__actions {
    grid-column: 1 / -1;
}

.widget-sort-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.widget-sort-card__position {
    color: var(--muted);
    font-size: 0.9rem;
    margin-right: auto;
}

.admin-thresholds {
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 18px;
    display: grid;
    gap: 14px;
}

.admin-option-group {
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 18px;
    display: grid;
    gap: 14px;
}

.admin-option-group legend {
    padding: 0 8px;
    font-weight: 700;
}

.admin-check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.admin-thresholds legend {
    padding: 0 8px;
    font-weight: 700;
}

.admin-thresholds__hint,
.admin-thresholds__empty,
.admin-option-group__hint {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.admin-thresholds__list {
    display: grid;
    gap: 12px;
}

.admin-threshold-row {
    align-items: end;
    padding: 14px;
    border-radius: 16px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
}

.admin-threshold-row__actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 14px;
    min-width: 0;
}

.flow-summary-config__row {
    align-items: end;
}

.flow-summary-config__headline {
    display: grid;
    gap: 4px;
    align-content: start;
    color: var(--muted);
    font-size: 0.9rem;
}

.flow-summary-config__headline strong {
    color: var(--text);
    font-size: 0.98rem;
}

.flow-summary-config__headline small {
    color: inherit;
}

.flow-summary-config__actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, max-content));
    justify-content: end;
    align-content: start;
    gap: 10px 14px;
    min-width: 0;
}

.flow-summary-config__actions .check-field {
    min-width: 0;
    white-space: nowrap;
}

.flow-summary-config__actions .button-secondary {
    justify-self: end;
}

.form-field--icon-picker {
    position: relative;
}

.flow-icon-picker__trigger {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.8rem 0.95rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--input-bg);
    color: var(--text);
    text-align: left;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.flow-icon-picker__trigger:hover {
    border-color: color-mix(in srgb, var(--accent) 28%, var(--border) 72%);
    background: color-mix(in srgb, var(--input-bg) 92%, var(--accent) 8%);
}

.flow-icon-picker__trigger:focus-visible {
    outline: none;
    border-color: color-mix(in srgb, var(--accent) 52%, var(--border) 48%);
    box-shadow: 0 0 0 3px rgba(31, 108, 90, 0.12);
}

.flow-icon-picker__trigger::after {
    content: "▾";
    margin-left: auto;
    color: var(--muted);
    font-size: 0.9rem;
}

.flow-icon-picker__trigger[aria-expanded="true"]::after {
    content: "▴";
}

.flow-icon-picker__preview,
.flow-icon-picker__option-icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 12px;
    border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border) 82%);
    background:
        radial-gradient(circle at top, rgba(255, 255, 255, 0.7), transparent 70%),
        color-mix(in srgb, var(--surface-soft) 82%, var(--accent) 18%);
    color: var(--accent);
}

.flow-icon-picker__preview svg,
.flow-icon-picker__option-icon svg {
    width: 1.25rem;
    height: 1.25rem;
    fill: currentColor;
}

.flow-icon-picker__text {
    min-width: 0;
    font-weight: 600;
}

.flow-icon-picker__panel {
    position: absolute;
    inset: calc(100% + 8px) 0 auto;
    z-index: 40;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 12px;
    border: 1px solid color-mix(in srgb, var(--border) 82%, var(--accent) 18%);
    border-radius: 16px;
    background: color-mix(in srgb, var(--surface) 94%, white 6%);
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.14);
    max-height: calc((3 * 3rem) + (2 * 8px) + 24px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.flow-icon-picker__option {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 3rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-soft);
    color: var(--text);
    text-align: left;
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.flow-icon-picker__option:hover {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--accent) 30%, var(--border) 70%);
    background: color-mix(in srgb, var(--surface-soft) 80%, var(--accent) 20%);
}

.flow-icon-picker__option:focus-visible {
    outline: none;
    border-color: color-mix(in srgb, var(--accent) 52%, var(--border) 48%);
    box-shadow: 0 0 0 3px rgba(31, 108, 90, 0.12);
}

.flow-icon-picker__option.is-selected {
    border-color: color-mix(in srgb, var(--accent) 48%, var(--border) 52%);
    background: color-mix(in srgb, var(--surface-soft) 74%, var(--accent) 26%);
    box-shadow: inset 0 0 0 1px rgba(31, 108, 90, 0.16);
}

.flow-icon-picker__option span:last-child {
    min-width: 0;
    font-weight: 600;
    word-break: break-word;
}

.flow-node-config__soc {
    transition: opacity 0.2s ease;
}

.gauge-readout {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 10px;
    text-align: center;
}

.gauge-readout__value {
    font-size: clamp(2rem, 4vw, 3.25rem);
    font-weight: 700;
    letter-spacing: -0.04em;
    color: var(--text);
}

.gauge-readout__unit {
    font-size: 1rem;
    font-weight: 600;
    color: var(--muted);
}

.gauge-scale {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    color: var(--muted);
    font-size: 0.92rem;
    padding: 0 4px;
}

.admin-sidebar .sidebar__nav {
    align-content: start;
}

.sidebar__logout {
    display: grid;
    gap: 10px;
}

@media (max-width: 1080px) {
    .login-shell,
    .app-shell {
        grid-template-columns: 1fr;
    }

    .widget-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .widget-card.span-4,
    .widget-card.span-5 {
        grid-column: span 3;
    }

    .admin-grid--two,
    .admin-grid--three,
    .meter-management__detail-grid,
    .meter-audit-card__payloads {
        grid-template-columns: 1fr;
    }

    .flow-icon-picker__panel {
        position: static;
        margin-top: 8px;
    }

    .flow-summary-config__actions {
        grid-template-columns: 1fr;
        justify-content: stretch;
    }

    .flow-summary-config__actions .button-secondary {
        justify-self: start;
    }
}

@media (max-width: 720px) {
    .admin-modal {
        padding: 12px;
    }

    .info-modal {
        padding: 12px;
    }

    .admin-modal__dialog {
        width: 100%;
        max-height: calc(100vh - 24px);
        border-radius: 20px;
    }

    .info-modal__dialog {
        width: 100%;
        border-radius: 20px;
    }

    .admin-modal__header,
    .admin-modal__body {
        padding: 18px;
    }

    .info-modal__header,
    .info-modal__body {
        padding: 18px;
    }

    .form-row--double,
    .form-row--triple {
        grid-template-columns: 1fr;
    }

    .admin-modal__header {
        align-items: flex-start;
        flex-direction: column;
    }

    .info-modal__header,
    .legal-header {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (max-width: 720px) {
    .login-page,
    .dashboard-page,
    .legal-page {
        padding: 16px;
    }

    .widget-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .widget-card.span-2,
    .widget-card.span-3,
    .widget-card.span-4,
    .widget-card.span-5 {
        grid-column: span 2;
    }

    .dashboard-header,
    .widget-card__header {
        flex-direction: column;
        align-items: stretch;
    }

    .admin-inline-form {
        grid-template-columns: 1fr;
    }

    .admin-note pre {
        white-space: pre-wrap;
        word-break: break-word;
    }

    .admin-header-actions,
    .rfid-matrix-user-head__body,
    .rfid-matrix-card__summary,
    .rfid-matrix-card__actions {
        flex-direction: column;
        align-items: stretch;
    }

    .sortable-page-card {
        grid-template-columns: auto 1fr;
    }

    .sortable-page-card__visibility,
    .sortable-page-card__meta {
        grid-column: 1 / -1;
    }

    .sortable-page-card__meta {
        justify-self: stretch;
        justify-content: space-between;
    }

    .widget-board__header,
    .widget-sort-card__actions {
        flex-direction: column;
        align-items: stretch;
    }

    .widget-sort-card__position {
        margin-right: 0;
    }

    .flow-graph {
        min-height: 330px;
    }

    .flow-graph--extended {
        min-height: 350px;
    }

    .flow-graph--dense {
        min-height: 372px;
    }

    .flow-node {
        width: min(32%, 148px);
        min-width: 92px;
        padding: 10px 9px 9px;
    }

    .flow-node--extra {
        width: min(21%, 106px);
        min-width: 72px;
    }
}

@media (max-width: 560px) {
    .widget-grid {
        grid-template-columns: 1fr;
    }

    .widget-card.span-2,
    .widget-card.span-3,
    .widget-card.span-4,
    .widget-card.span-5 {
        grid-column: span 1;
    }

    .flow-graph {
        min-height: 300px;
        aspect-ratio: 1 / 1.02;
    }

    .flow-graph--extended {
        min-height: 326px;
    }

    .flow-graph--dense {
        min-height: 346px;
    }

    .flow-node {
        width: min(37%, 128px);
        min-width: 82px;
        border-radius: 17px;
        gap: 4px;
    }

    .flow-node--extra {
        width: min(19%, 92px);
        min-width: 66px;
        border-radius: 15px;
    }

    .flow-node__icon {
        width: 34px;
        height: 34px;
    }

    .flow-node__icon svg {
        width: 18px;
        height: 18px;
    }

    .flow-hub {
        width: 40px;
        height: 40px;
    }
}
