:root {
    color-scheme: dark;
    font-family: "Helvetica Neue", Arial, sans-serif;
    --app-surface: var(--acuity-card);
    --app-surface-alt: rgba(255, 255, 255, 0.05);
    --app-surface-muted: rgba(255, 255, 255, 0.02);
    --app-border: var(--acuity-border);
    --app-border-strong: var(--acuity-border-strong);
    --app-text: var(--acuity-text);
    --app-text-muted: var(--acuity-text-muted);
    --app-heading: #ffffff;
    --app-primary: var(--acuity-blue);
    --app-accent: var(--acuity-clean-green);
    --app-warning: var(--acuity-yellow);
    --app-danger: var(--acuity-red);
    --app-success: var(--acuity-clean-green);
    --app-shadow: 0 22px 42px rgba(0, 0, 0, 0.45);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background-color: var(--acuity-bg);
    color: var(--app-text);
    font-family: "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--app-accent);
    text-decoration: underline;
}

a:hover,
a:focus {
    color: #00c987;
    text-decoration: underline;
}

#blazor-error-ui {
    display: none !important;
}

h1,
h2,
h3,
h4 {
    margin: 0;
    font-weight: 600;
    color: var(--app-heading);
    letter-spacing: 0.04em;
}

p {
    margin: 0;
}

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    color: inherit;
}

.container {
    width: 100%;
    margin: 0 auto;
    padding: 0 24px;
}

.page-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding: 0 0 4rem;
}

.login-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    padding: 1rem;
}

.login-card {
    width: 40vw;
    max-width: 520px;
    min-width: 280px;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: var(--app-shadow);
}

.login-card .login-body {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 1.75rem;
}

.login-card .login-body label {
    margin-top: 20px;
    display: block;
}

.login-submit {
    width: 100%;
    margin-top: 20px;
}

.login-support {
    margin-top: 20px;
    text-align: center;
    font-size: 0.9rem;
}

.login-progress {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-top: 20px;
}

.login-progress-inner {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.9rem;
    letter-spacing: 0.04em;
}

.login-progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 999px;
    overflow: hidden;
}

.login-progress-meter {
    display: block;
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, rgba(0, 177, 118, 0.6), rgba(0, 177, 118, 1));
    animation: login-progress 1.2s ease-in-out infinite;
}

.login-spinner {
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-top-color: rgba(255, 255, 255, 0.9);
    animation: login-spin 0.8s linear infinite;
}

@keyframes login-progress {
    0% {
        width: 0%;
        margin-left: 0%;
    }

    50% {
        width: 70%;
        margin-left: 15%;
    }

    100% {
        width: 0%;
        margin-left: 100%;
    }
}

@keyframes login-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Welcome Screen */
.welcome-screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--acuity-bg);
    color: var(--acuity-text);
    text-align: center;
    padding: 2rem;
}

.welcome-logo {
    height: 56px;
    margin-bottom: 1.5rem;
}

.welcome-title {
    font-size: 1.5rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 4px;
    color: var(--acuity-text-muted);
    margin: 0 0 0.75rem 0;
}

.welcome-version {
    font-size: 0.9rem;
    color: var(--acuity-text-muted);
    margin-bottom: 2.5rem;
}

.welcome-version a {
    color: inherit;
    text-decoration: underline;
}

.welcome-version a:hover {
    color: var(--acuity-clean-green);
}

.signin-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 2.5rem;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--acuity-clean-green);
    background: transparent;
    border: 2px solid var(--acuity-clean-green);
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.signin-button:hover,
.signin-button:focus-visible {
    background: var(--acuity-clean-green);
    color: #ffffff;
    box-shadow: 0 12px 28px rgba(0, 177, 118, 0.4);
    transform: translateY(-1px);
    outline: none;
}

.alert {
    background: var(--app-surface-alt);
    border: 1px solid var(--app-border);
    border-radius: 14px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--app-text);
    line-height: 1.45;
    overflow: hidden;
    max-height: 200px;
}

.alert-error {
    background: rgba(225, 82, 62, 0.22);
    border-color: rgba(225, 82, 62, 0.45);
    color: var(--app-danger);
}

.alert-success {
    background: rgba(0, 177, 118, 0.22);
    border-color: rgba(0, 177, 118, 0.45);
    color: var(--app-success);
    animation: alert-fade-out 5s ease-in-out forwards;
}

.alert-error {
    animation: alert-fade-out 5s ease-in-out forwards;
}

@keyframes alert-fade-out {
    0% {
        opacity: 1;
        max-height: 200px;
        padding: 1rem 1.25rem;
        margin-bottom: 1.5rem;
    }

    70% {
        opacity: 1;
        max-height: 200px;
        padding: 1rem 1.25rem;
        margin-bottom: 1.5rem;
    }

    100% {
        opacity: 0;
        max-height: 0;
        padding: 0 1.25rem;
        margin-bottom: 0;
        border-width: 0;
        pointer-events: none;
    }
}

.card {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 24px;
    box-shadow: var(--app-shadow);
    margin-bottom: 0;
    color: var(--app-text);
    overflow: visible;
    backdrop-filter: blur(6px);
}

.card:last-of-type {
    margin-bottom: 0;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.35rem 1.75rem;
    background: var(--app-surface-alt);
    border-bottom: 1px solid var(--app-border-strong);
    color: var(--app-heading);
}

/* Accordion (Clickable Card Header) Pattern */
.card-header.clickable {
    cursor: pointer;
    transition: background 0.2s ease;
}

.card-header.clickable:hover {
    background: rgba(255, 255, 255, 0.06);
}

.card-header .collapse-toggle {
    font-size: 1.3rem;
    color: var(--app-text-muted);
    margin-left: 0.75rem;
    transition: color 0.2s ease;
}

.card-header.clickable:hover .collapse-toggle {
    color: var(--app-accent);
}

.card-header .item-count,
.card-header .register-count {
    font-size: 0.9rem;
    color: var(--app-text-muted);
    margin-right: 0.5rem;
}

.card-header h2 {
    font-size: 1.05rem;
    text-transform: uppercase;
}

.card-body {
    padding: 1.75rem;
}

button.card-header.collapsible {
    width: 100%;
    background: transparent;
    border: none;
    padding: 1.35rem 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    cursor: pointer;
    color: inherit;
    font: inherit;
    text-align: left;
    border-bottom: 1px solid var(--app-border-strong);
    transition: background 0.25s ease, border-color 0.25s ease;
}

button.card-header.collapsible .header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

button.card-header.collapsible .header-actions {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
}

button.card-header.collapsible .actions-divider {
    color: var(--app-text-muted);
    font-weight: 600;
}

button.card-header.collapsible .collapse-icon {
    font-size: 1.6rem;
    line-height: 1;
    color: var(--app-text-muted);
    transition: transform 0.2s ease, color 0.2s ease;
}

button.card-header.collapsible:hover,
button.card-header.collapsible:focus-visible {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--app-border);
    outline: none;
}

button.card-header.collapsible:hover .collapse-icon,
button.card-header.collapsible:focus-visible .collapse-icon {
    color: var(--app-accent);
}

.collapsible-body {
    padding: 0;
    border-top: 1px solid var(--app-border);
    transition: max-height 0.25s ease, opacity 0.25s ease;
    max-height: none;
    opacity: 1;
    overflow: visible;
}

.collapsible-body.collapsed {
    max-height: 0;
    opacity: 0;
    border-top-color: transparent;
    overflow: hidden;
}

.status-card .card-body,
.control-card .card-body,
.settings-card .card-body {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.control-card .card-body {
    padding: 20px;
}

.meter-config-section {
    overflow: visible;
}

.subsection-body {
    overflow: visible;
}

.reload-banner {
    padding: 0.75rem 1rem;
    margin: 0 1.35rem 0.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    text-align: center;
}

.reload-banner-success {
    color: var(--app-success);
    background: rgba(0, 200, 130, 0.15);
}

.reload-banner-error {
    color: var(--app-danger);
    background: rgba(255, 122, 99, 0.14);
}

.force-progress {
    margin: 0 1.35rem 0.5rem;
    height: 4px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    overflow: hidden;
}

.force-progress-bar {
    width: 100%;
    height: 100%;
    background: var(--app-accent);
    animation: force-progress-slide 1.2s linear infinite;
    transform: translateX(-100%);
}

@keyframes force-progress-slide {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: rgba(0, 177, 118, 0.22);
    color: var(--app-success);
}

.status-pill.processing {
    background: rgba(15, 135, 220, 0.24);
    color: var(--app-primary);
}

.status-pill.waiting {
    background: rgba(255, 199, 25, 0.24);
    color: var(--app-warning);
}

.status-link {
    margin-left: auto;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #5bc0ff;
}

.status-link:hover,
.status-link:focus-visible {
    color: #8ad5ff;
    text-decoration: underline;
}

/* Switch / Toggle Component */
.toggle-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
}

.toggle-switch input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.toggle-track {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    background-color: var(--app-surface-muted);
    border: 1px solid var(--app-border-strong);
    border-radius: 24px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.toggle-track:after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background-color: var(--app-text-muted);
    border-radius: 50%;
    transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28), background-color 0.3s ease;
}

.toggle-switch:hover .toggle-track {
    border-color: var(--app-border);
    background-color: rgba(255, 255, 255, 0.08);
}

.toggle-switch input:checked~.toggle-track {
    background-color: rgba(0, 177, 118, 0.2);
    border-color: var(--app-success);
}

.toggle-switch input:checked~.toggle-track:after {
    transform: translateX(20px);
    background-color: var(--app-success);
    box-shadow: 0 0 10px rgba(0, 177, 118, 0.4);
}

.toggle-label {
    font-size: 0.9rem;
    color: var(--app-text);
}

.toggle-switch input:checked~.toggle-label {
    color: var(--app-success);
}

.countdown-row {
    display: grid;
    grid-template-columns: minmax(120px, 160px) 1fr minmax(90px, 140px);
    gap: 1.1rem;
    align-items: center;
    font-size: 0.95rem;
}

.countdown-label {
    font-weight: 600;
    color: var(--app-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.progress {
    display: block;
    position: relative;
    height: 10px;
    background: var(--app-surface-muted);
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(0, 177, 118, 0.65), rgba(0, 201, 135, 1));
    transition: width 0.35s ease;
}

.countdown-time {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--app-heading);
}

.status-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem 1.5rem;
    margin: 0;
}

.status-meta dt {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--app-text-muted);
}

.status-meta dd {
    margin: 0;
    font-size: 0.95rem;
    color: var(--app-text);
}

.status-note {
    color: var(--app-text-muted);
    font-size: 0.9rem;
    background: var(--app-surface-alt);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    border: 1px solid var(--app-border);
}

.status-error {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    background: rgba(225, 82, 62, 0.15);
    border: 1px solid rgba(225, 82, 62, 0.4);
    color: var(--app-danger);
    transition: opacity 0.6s ease;
}

.status-error.fade-out {
    opacity: 0;
}

.data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem 1.5rem;
    margin: 0;
}

.data-grid dt {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--app-text-muted);
}

.data-grid dd {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--app-heading);
}

.history-card .card-header {
    align-items: flex-end;
}

.history-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.history-controls input[type="date"] {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--app-border);
    border-radius: 12px;
    padding: 0.55rem 0.75rem;
    color: var(--app-text);
    font-size: 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.history-controls input[type="date"]:focus {
    outline: none;
    border-color: var(--app-primary);
    box-shadow: 0 0 0 0.2rem rgba(15, 135, 220, 0.35);
}

.history-body {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.history-chart-wrapper {
    background: var(--app-surface-alt);
    border: 1px solid var(--app-border);
    border-radius: 18px;
    padding: 1rem;
}

.history-chart-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 10 / 3;
}

.history-chart-stage canvas {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    border-radius: 12px;
}

.history-chart-skeleton {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1.25rem;
    border: 1px dashed var(--app-border);
    border-radius: 16px;
    background: var(--app-surface-muted);
    color: var(--app-text-muted);
}

.history-chart-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    background: var(--app-surface);
}

.skeleton-line {
    height: 14px;
    border-radius: 7px;
    background: linear-gradient(90deg, rgba(30, 139, 247, 0.2) 0%, rgba(30, 139, 247, 0.5) 50%, rgba(30, 139, 247, 0.2) 100%);
    background-size: 220% 100%;
    animation: skeleton-shimmer 1.6s ease-in-out infinite;
}

.skeleton-short {
    max-width: 160px;
}

.skeleton-medium {
    max-width: 240px;
}

.skeleton-chart-placeholder {
    display: grid;
    grid-template-columns: repeat(12, minmax(20px, 1fr));
    align-items: end;
    gap: 0.5rem;
    height: 200px;
    padding: 0.5rem 0;
}

.skeleton-bar {
    width: 100%;
    border-radius: 6px 6px 0 0;
    background: linear-gradient(90deg, rgba(30, 139, 247, 0.15) 0%, rgba(30, 139, 247, 0.4) 50%, rgba(30, 139, 247, 0.15) 100%);
    background-size: 220% 100%;
    animation: skeleton-shimmer 1.6s ease-in-out infinite;
}

@keyframes skeleton-shimmer {
    0% {
        background-position: 220% 0;
    }

    100% {
        background-position: -220% 0;
    }
}

.skeleton-loading-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--app-text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.skeleton-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(30, 139, 247, 0.3);
    border-top-color: var(--acuity-clearsky-blue);
    border-radius: 50%;
    animation: skeleton-spin 0.8s linear infinite;
}

@keyframes skeleton-spin {
    to {
        transform: rotate(360deg);
    }
}

button.primary,
button.secondary,
a.secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}

button.primary {
    background: linear-gradient(135deg, rgba(0, 177, 118, 0.85), rgba(0, 201, 135, 1));
    border: none;
    border-radius: 999px;
    color: #ffffff;
    padding: 0.65rem 1.8rem;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    box-shadow: 0 16px 30px rgba(0, 177, 118, 0.35);
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

button.primary:hover,
button.primary:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 20px 38px rgba(0, 177, 118, 0.45);
    outline: none;
}

button.primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    background: rgba(0, 177, 118, 0.2);
    color: var(--app-text-muted);
}

button.secondary,
a.secondary {
    background: transparent;
    border: 1px solid var(--app-border);
    border-radius: 999px;
    color: var(--app-text-muted);
    padding: 0.55rem 1.15rem;
    font-size: 0.9rem;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    text-decoration: none;
}

button.secondary:hover,
button.secondary:focus-visible,
a.secondary:hover,
a.secondary:focus-visible {
    border-color: var(--app-success);
    color: var(--app-heading);
    background: rgba(0, 177, 118, 0.16);
    outline: none;
}

button.secondary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    background: transparent;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.storage-grid {
    grid-template-columns: 1fr 1fr;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.text-input,
.select-input,
.number-input {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border-radius: 12px;
    border: 1px solid var(--app-border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--app-text);
    font-size: 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    appearance: none;
}

.text-input::placeholder,
.number-input::placeholder {
    color: rgba(245, 245, 245, 0.55);
}

.text-input:focus,
.select-input:focus,
.number-input:focus {
    outline: none;
    border-color: var(--app-primary);
    box-shadow: 0 0 0 0.2rem rgba(15, 135, 220, 0.35);
    background: rgba(255, 255, 255, 0.08);
}

.text-input:disabled,
.select-input:disabled,
.number-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Compact form variants */
.form-group.compact label {
    font-size: 0.8rem;
}

.form-grid.compact {
    gap: 0.75rem 1rem;
}

.form-grid.compact .form-group {
    gap: 0.35rem;
}

.text-input.compact,
.select-input.compact,
.number-input.compact {
    padding: 0.45rem 0.65rem;
    font-size: 0.85rem;
    border-radius: 8px;
}

.compact-section .text-input,
.compact-section .select-input,
.compact-section .number-input {
    padding: 0.45rem 0.65rem;
    font-size: 0.85rem;
    border-radius: 8px;
}

.compact-section .form-grid {
    gap: 0.75rem 1rem;
}

.compact-section .form-group {
    gap: 0.35rem;
}

.compact-section h4 {
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.hint,
.form-hint {
    font-size: 0.8rem;
    color: var(--app-text-muted);
}

.control-alert {
    background: rgba(255, 199, 25, 0.12);
    border: 1px solid rgba(255, 199, 25, 0.4);
    border-radius: 14px;
    padding: 1rem 1.25rem;
    color: var(--app-warning);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.poll-rate-control {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    max-width: 240px;
}

.poll-rate-control label {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--app-text-muted);
}

.dispatch-mode-control {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.mode-switch {
    position: relative;
    width: 48px;
    height: 24px;
    display: inline-flex;
}

.mode-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.mode-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    transition: background 0.2s ease;
}

.mode-slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: var(--app-surface);
    border-radius: 50%;
    transition: transform 0.2s ease;
}

.mode-switch input:checked+.mode-slider {
    background: rgba(0, 200, 130, 0.5);
}

.mode-switch input:checked+.mode-slider::before {
    transform: translateX(24px);
}

.dispatch-mode-caption {
    font-size: 0.8rem;
    color: var(--app-text-muted);
}

.manual-command-links {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.inverter-section {
    margin-top: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.inverter-section header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.inverter-section h3 {
    font-size: 1rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--app-heading);
}

.link-button {
    background: none;
    border: none;
    color: var(--app-accent);
    cursor: pointer;
    padding: 0;
    font: inherit;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.link-button:hover,
.link-button:focus-visible {
    color: #00c987;
    outline: none;
}

.link-button.link-edit {
    color: #fb923c;
}

.link-button.link-edit:hover,
.link-button.link-edit:focus-visible {
    color: #fdba74;
}

.link-button.link-remove {
    color: var(--app-danger);
}

.link-button.link-remove:hover,
.link-button.link-remove:focus-visible {
    color: #ff7a63;
}

.log-copy-button {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.log-copy-icon {
    display: inline-flex;
    align-items: center;
    width: 1em;
    height: 1em;
}

.log-copy-icon-diagnostics {
    color: var(--app-success);
}

.register-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--app-border);
    border-radius: 16px;
    overflow: hidden;
    font-size: 0.95rem;
    background: var(--app-surface);
}

.register-table th,
.register-table td {
    padding: 0.75rem 0.9rem;
    border-bottom: 1px solid var(--app-border);
    text-align: left;
}

.register-table th {
    background: var(--app-surface-alt);
    color: var(--app-text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.8rem;
}

.register-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.register-table tbody tr:hover {
    background: rgba(15, 135, 220, 0.12);
}

.register-table.compact {
    font-size: 0.85rem;
    border-radius: 10px;
}

.register-table.compact th,
.register-table.compact td {
    padding: 0.25rem 0.5rem;
}

.register-table.compact th {
    font-size: 0.7rem;
}

.register-action-cell {
    white-space: nowrap;
}

.register-list-compact {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.85rem 1.5rem;
    border-top: 1px solid var(--app-border);
    background: var(--app-surface-muted);
    color: var(--app-text-muted);
    font-size: 0.88rem;
}

.register-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    background: rgba(15, 135, 220, 0.16);
    border: 1px solid rgba(15, 135, 220, 0.4);
    color: var(--app-primary);
    font-variant-numeric: tabular-nums;
}

.reporting-body {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.reporting-toggle {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.25rem;
}

.reporting-run-time {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 140px;
}

.reporting-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.reporting-section-header {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.reporting-recipient-input {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.recipient-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.recipient-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--app-border);
    background: var(--app-surface-alt);
    font-size: 0.85rem;
}

.recipient-badge button {
    background: none;
    border: none;
    color: var(--app-danger);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

.reporting-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem 1.5rem;
}

.reporting-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;
}

.reporting-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--app-border);
}

.reporting-table th,
.reporting-table td {
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--app-border);
    text-align: left;
}

.reporting-table th {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.75rem;
    color: var(--app-text-muted);
    background: var(--app-surface-alt);
}

.reporting-actions-cell {
    text-align: right;
    white-space: nowrap;
}

.reporting-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
}

.reporting-col {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.reporting-settings {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem 1.25rem;
}

.smtp-summary {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.reporting-divider {
    height: 1px;
    background: var(--app-border);
    margin: 1.25rem 0;
    opacity: 0.6;
}

button.compact-button {
    padding: 0.5rem 1.25rem;
}

.recipient-badges.sky .recipient-badge {
    background: rgba(91, 192, 255, 0.2);
    border-color: rgba(91, 192, 255, 0.5);
    color: #e0f4ff;
}

.sky-link {
    color: #5bc0ff;
}

.sky-link:hover,
.sky-link:focus-visible {
    color: #8ad5ff;
}

.badge-clean-green {
    background: rgba(0, 177, 118, 0.2);
    color: var(--app-success);
}

.badge-bumblebee {
    background: rgba(255, 199, 25, 0.25);
    color: #ffc719;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.status-badge.success {
    background: rgba(0, 177, 118, 0.22);
    color: var(--app-success);
}

.status-badge.failure {
    background: rgba(225, 82, 62, 0.22);
    color: var(--app-danger);
}

.status-badge.queued {
    background: rgba(91, 192, 255, 0.18);
    color: #5bc0ff;
}

.status-badge.idle {
    background: rgba(255, 255, 255, 0.12);
    color: var(--app-text-muted);
}

.status-badge.badge-clean-green {
    border: 1px solid rgba(0, 177, 118, 0.4);
    background: rgba(0, 177, 118, 0.1);
    color: var(--app-success);
}

.status-badge.badge-bumblebee {
    border: 1px solid rgba(255, 199, 25, 0.4);
    background: rgba(255, 199, 25, 0.1);
    color: #ffc719;
}

.badge-amber {
    background: rgba(255, 166, 0, 0.2);
    color: #ffa600;
}

.status-badge.badge-amber {
    border: 1px solid rgba(255, 166, 0, 0.4);
    background: rgba(255, 166, 0, 0.1);
    color: #ffa600;
}

.status-badge.badge-blue {
    border: 1px solid rgba(100, 160, 255, 0.4);
    background: rgba(100, 160, 255, 0.1);
    color: #64a0ff;
}

.status-badge.badge-error {
    border: 1px solid rgba(225, 82, 62, 0.4);
    background: rgba(225, 82, 62, 0.1);
    color: var(--app-danger);
}

.host-summary {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    padding: 20px;
}

.host-summary-meta {
    font-size: 0.85rem;
    color: var(--app-text-muted);
}

.manual-summary-links {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.host-summary-card {
    border: 1px solid var(--app-border);
    border-radius: 16px;
    background: var(--app-surface-alt);
    padding: 1rem 1.25rem;
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.35);
}

.host-summary-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.host-summary-title {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.host-summary-sub {
    font-size: 0.8rem;
    color: var(--app-text-muted);
}

.host-summary-body {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    color: var(--app-text);
    font-size: 0.92rem;
}

.host-summary-condition {
    font-weight: 600;
}

.host-summary-condition.positive {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    background: rgba(0, 177, 118, 0.2);
    color: var(--app-success);
}

.host-summary-condition.negative {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    background: rgba(225, 82, 62, 0.2);
    color: var(--app-danger);
}

.host-summary-condition.neutral {
    color: var(--app-text-muted);
}

.host-summary-command {
    line-height: 1.35;
    color: var(--app-text-muted);
}

.host-summary-sent {
    font-size: 0.78rem;
    color: var(--app-text-muted);
}

.host-summary-sent.stale {
    font-weight: 600;
    color: var(--app-danger);
}

.host-summary-sent-warning {
    display: inline-flex;
    align-items: center;
    margin-left: 0.4rem;
    font-size: 0.72rem;
    color: var(--app-danger);
}

.host-grid {
    display: grid;
    grid-template-columns: minmax(220px, 2fr) minmax(240px, 2fr) minmax(120px, 1fr) minmax(120px, 1fr) auto;
    gap: 1rem 1.25rem;
    align-items: end;
}

.host-grid>div:not(.host-add-button) {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.host-add-button {
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 0.5rem;
}

.host-add-button .link-button {
    white-space: nowrap;
}

.register-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem 1.5rem;
}

.register-type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.register-type-card {
    padding: 1rem 1.25rem;
    border: 1px solid var(--app-border);
    border-radius: 14px;
    background: var(--app-surface-alt);
    color: var(--app-text);
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.register-type-card h4 {
    margin: 0 0 0.4rem 0;
    font-size: 1rem;
    color: var(--app-heading);
}

.register-type-card p {
    margin: 0;
    font-size: 0.88rem;
    color: var(--app-text-muted);
}

.register-type-card:hover,
.register-type-card:focus-visible {
    border-color: var(--app-primary);
    box-shadow: 0 14px 28px rgba(15, 135, 220, 0.28);
    transform: translateY(-2px);
    outline: none;
}

.register-type-card.selected {
    border-color: var(--app-accent);
    box-shadow: 0 16px 30px rgba(0, 177, 118, 0.35);
    background: rgba(0, 177, 118, 0.12);
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.form-field label {
    font-weight: 600;
    font-size: 0.88rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--app-text-muted);
}

.form-field.readonly span {
    padding: 0.7rem 0.9rem;
    border-radius: 12px;
    background: var(--app-surface-alt);
    color: var(--app-text);
    font-size: 0.95rem;
    border: 1px solid var(--app-border);
}

.modal-dialog {
    width: min(720px, 92vw);
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    background: var(--app-surface);
    border-radius: 20px;
    border: 1px solid var(--app-border);
    box-shadow: var(--app-shadow);
    pointer-events: auto;
    overflow: hidden;
    color: var(--app-text);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.35rem 1.75rem 1rem;
    border-bottom: 1px solid var(--app-border-strong);
    background: var(--app-surface-alt);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--app-heading);
}

.modal-close {
    background: none;
    border: none;
    color: var(--app-text-muted);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
}

.modal-close:hover,
.modal-close:focus-visible {
    color: var(--app-accent);
    transform: scale(1.05);
    outline: none;
}

.modal-body {
    padding: 1.5rem 1.75rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.logs-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.logs-control p {
    margin: 0;
    font-size: 0.95rem;
    color: var(--app-text-muted);
}

.log-output {
    border-radius: 16px;
    border: 1px solid var(--app-border);
    background: var(--app-surface-alt);
    font-family: "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 0.9rem;
    padding: 1rem;
    max-height: 52vh;
    overflow: auto;
    color: var(--app-text);
    white-space: pre-wrap;
}

.log-output pre {
    margin: 0;
    font-family: inherit;
    color: inherit;
    white-space: inherit;
}

.modal-footer {
    padding: 1rem 1.75rem 1.5rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    border-top: 1px solid var(--app-border-strong);
}

.modal-error {
    margin: 0;
    padding: 0.8rem 1rem;
    border-radius: 10px;
    background: rgba(225, 82, 62, 0.16);
    border: 1px solid rgba(225, 82, 62, 0.4);
    color: var(--app-danger);
    font-size: 0.9rem;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 900px) {
    .host-grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }

    .host-add-button {
        justify-content: flex-start;
    }
}

@media (max-width: 720px) {
    .container {
        padding: 0 18px;
    }

    .card {
        border-radius: 18px;
    }

    .card-header,
    button.card-header.collapsible {
        padding: 1.1rem 1.25rem;
    }

    .card-body {
        padding: 1.25rem;
    }

    .countdown-row {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .history-controls input[type="date"] {
        width: 100%;
    }

    .host-add-button {
        justify-self: stretch;
    }

    .host-add-button .link-button {
        width: 100%;
    }
}

@media (max-width: 540px) {
    .history-controls {
        width: 100%;
    }

    .form-actions {
        justify-content: stretch;
    }

    button.primary,
    button.secondary {
        width: 100%;
    }
}

.watchdog-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font: inherit;
    font-size: inherit;
}

.watchdog-indicator.healthy .watchdog-label {
    color: var(--app-success);
}

.watchdog-indicator.watchdog-alert .watchdog-label {
    color: var(--acuity-terra-red);
}

.watchdog-indicator.watchdog-alert .watchdog.text-muted {
    color: var(--acuity-ash) !important;
}

/* Battery Visualization */
.battery-viz-wrapper {
    position: relative;
    width: 100px;
    /* Width of the rotated container (height of battery) */
    height: 220px;
    /* Height of the rotated container (width of battery) */
    display: flex;
    align-items: center;
    justify-content: center;
    /* margin: 0 auto; Removed to allow flex alignment */
    margin-top: 30px;
    /* Move Viz Down 30px */
}

.battery-viz-rotated {
    transform: rotate(-90deg);
    width: 200px;
    /* Length of the battery */
    height: 100px;
    /* Thickness of the battery */
    position: relative;
    display: flex;
    align-items: center;
}

.battery-icon {
    width: 100%;
    height: auto;
    fill: none;
    stroke: var(--acuity-text-muted);
    stroke-width: 2;
    position: relative;
    z-index: 2;
}

.battery-fill {
    position: absolute;
    background-color: var(--acuity-clearsky-blue);
    height: 96px;
    top: 50%;
    transform: translateY(-50%);
    left: 1%;
    border-top-left-radius: 10px;
    border-bottom-left-radius: 10px;
    z-index: 1;
    border: 4px solid #141414;
}

.soc-line {
    position: absolute;
    top: -10px;
    /* Extend slightly outside */
    bottom: -10px;
    width: 0;
    border-left: 3px dashed;
    z-index: 10;
    transition: left 0.3s ease;
}

.power-bar-container {
    position: absolute;
    top: -80px;
    /* Move 50px left (was -30px) */
    /* 100px height + 50px margin */
    left: 0;
    width: 200px;
    height: 16px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
}

.power-bar-zero {
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: rgba(255, 255, 255, 0.3);
    transform: translateX(-50%);
    z-index: 1;
}

.power-bar-fill {
    position: absolute;
    top: 0;
    bottom: 0;
    transition: all 0.3s ease;
}

.soc-line.min-soc {
    border-color: var(--acuity-terra-red);
}

.soc-line.max-soc {
    border-color: var(--acuity-yellow);
}

.soc-label {
    position: absolute;
    transform-origin: 0 0;
    transform: rotate(90deg) translateX(0);
    left: 11px;
    /* Moved 3px up (was 8px) */
    top: 130px;
    /* Moved 20px right (was 110px) */
    font-weight: bold;
    font-size: 14px;
    white-space: nowrap;
}

/* Power bar limit lines for demand reduction indicators */
.power-bar-limit-line {
    position: absolute;
    left: -8px;
    right: -8px;
    height: 0;
    border-top: 2px dashed var(--acuity-orange);
    z-index: 20;
    pointer-events: none;
}

.power-bar-limit-label {
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    font-weight: bold;
    color: var(--acuity-orange);
    white-space: nowrap;
}

/* Microgrid Visualization Headers */
.viz-header {
    /* Using relative positioning for grid layout */
    position: relative;
    white-space: nowrap;
    font-weight: bold;
    font-size: 14px;
    color: var(--acuity-text);
    text-align: center;
}

/* Legacy storage header styling - deprecated */
.viz-header-storage {
    /* Using relative positioning for grid layout */
}

.viz-label-charge {
    /* Using relative positioning for grid layout */
    position: relative;
    text-align: center;
    font-weight: bold;
    font-size: 14px;
    color: var(--acuity-text);
    white-space: nowrap;
}

.viz-label-power {
    /* Using relative positioning for grid layout */
    position: relative;
    text-align: center;
    font-weight: bold;
    font-size: 14px;
    color: var(--acuity-text);
    white-space: nowrap;
}

/* Microgrid Visualization Bars */
.microgrid-viz-bar {
    /* Using relative positioning for flex layout */
    position: relative;
    width: auto;
    height: auto;
}

/* These left values are deprecated - using flex layout now */
.viz-utility,
.viz-load,
.viz-pv {
    /* No longer using absolute positioning */
}

.viz-label-utility,
.viz-label-load,
.viz-label-pv {
    /* Now using relative positioning within flex containers */
    position: relative;
    white-space: nowrap;
    font-weight: bold;
    font-size: 14px;
    color: var(--acuity-text);
    text-align: center;
}

/* Reuse power-bar-track and power-bar-fill from existing styles, 
   but ensure they work within the new containers */
.microgrid-viz-bar .power-bar-track {
    position: relative;
    width: 100%;
    height: 100%;
    background-color: #333;
    border-radius: 8px;
    overflow: hidden;
}

.microgrid-viz-bar .power-bar-fill {
    position: absolute;
    width: 100%;
    left: 0;
    transition: height 0.3s ease, top 0.3s ease;
}

.microgrid-viz-bar .power-bar-center-line {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%);
    z-index: 10;
}

.min-soc .soc-label {
    color: var(--acuity-terra-red);
}

.max-soc .soc-label {
    color: var(--acuity-yellow);
}

.watchdog-icon {
    font-size: 1.5rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.watchdog-indicator.healthy .watchdog-icon {
    color: var(--app-success);
    animation: heartbeat 0.9s ease-in-out infinite;
}

.watchdog-indicator.watchdog-alert .watchdog-icon {
    color: var(--acuity-terra-red);
    animation: none;
}

.watchdog-label {
    font-size: inherit;
    text-transform: none;
    letter-spacing: normal;
}

@keyframes heartbeat {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.3);
    }
}

/* ─── Alarm Level Animations ─────────────────────── */
@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.15);
    }
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.2;
    }
}

@keyframes flash {

    0%,
    50%,
    100% {
        opacity: 1;
    }

    25%,
    75% {
        opacity: 0;
    }
}

/* Meter Status Styles */
.meter-status-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 0.75rem;
    padding: 20px;
}

.meter-status-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    background: var(--app-surface-alt);
    border: 1px solid var(--app-border);
    border-radius: 12px;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.meter-status-chip.badge-clean-green {
    border-color: rgba(0, 177, 118, 0.4);
    background: rgba(0, 177, 118, 0.1);
}

.meter-status-chip.badge-bumblebee {
    border-color: rgba(255, 199, 25, 0.4);
    background: rgba(255, 199, 25, 0.1);
}

.meter-status-chip.badge-error {
    border-color: rgba(225, 82, 62, 0.4);
    background: rgba(225, 82, 62, 0.1);
}

.meter-status-chip.badge-muted,
.meter-status-chip.badge-sky {
    border-color: var(--app-border);
    background: var(--app-surface-alt);
    opacity: 0.8;
}

.meter-status-chip.badge-clearsky {
    border-color: rgba(30, 139, 247, 0.4);
    background: rgba(30, 139, 247, 0.1);
}

.meter-status-chip.badge-terra {
    border-color: rgba(183, 65, 14, 0.4);
    background: rgba(183, 65, 14, 0.1);
}

.meter-status-chip.badge-disabled {
    border-color: rgba(128, 128, 128, 0.4);
    background: rgba(128, 128, 128, 0.1);
}

.meter-name {
    font-weight: 600;
    color: var(--app-heading);
    margin-right: auto;
}

.meter-value {
    font-family: "JetBrains Mono", monospace;
    color: var(--app-text);
    margin-right: 1rem;
    font-weight: 600;
}

.meter-response {
    font-size: 0.8rem;
    color: var(--app-text-muted);
    min-width: 45px;
    text-align: right;
}

/* Tab Navigation */
.tab-navigation {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--app-border);
    padding-bottom: 0.5rem;
}

.tabs-header {
    display: flex;
    gap: 1.5rem;
}

.tab-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: transparent;
    border: none;
    color: var(--app-text-muted);
    font-size: 0.95rem;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    transition: all 0.2s ease;
}

.tab-button:hover,
.tab-button:focus-visible {
    color: var(--app-text);
    background: rgba(255, 255, 255, 0.05);
    outline: none;
}

.tab-button.active {
    color: var(--app-accent);
    background: rgba(0, 177, 118, 0.1);
    font-weight: 600;
}

.ems-tab-content {
    margin-top: 1.5rem;
}

/* BESS Status Badge Colors */
.status-badge.badge-blue {
    border: 1px solid rgba(30, 139, 247, 0.5);
    background: rgba(30, 139, 247, 0.15);
    color: var(--acuity-clearsky-blue);
}

.status-badge.badge-purple {
    border: 1px solid rgba(109, 74, 255, 0.5);
    background: rgba(109, 74, 255, 0.15);
    color: var(--acuity-purple);
}

.status-badge.badge-red {
    border: 1px solid rgba(225, 82, 62, 0.5);
    background: rgba(225, 82, 62, 0.15);
    color: var(--acuity-red);
}

.status-badge.badge-gray {
    border: 1px solid rgba(160, 160, 160, 0.4);
    background: rgba(160, 160, 160, 0.12);
    color: #a0a0a0;
}

/* BESS Status Section Layout */
.bess-status-section {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-width: 200px;
    padding-right: 2rem;
}

.bess-status-group {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.bess-status-heading {
    font-size: 0.85rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--acuity-text);
    margin-bottom: 3px;
}

.bess-status-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: flex-start;
    padding-left: 10px;
}

.bess-status-row .status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.75rem;
    font-size: 0.75rem;
    white-space: nowrap;
}

.bess-status-row .status-badge i {
    font-size: 0.85rem;
}

.energy-storage-layout {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

/* MICROGRID Card Collapsed Layout */
/* 6-Column Grid Layout for MICROGRID card */
.microgrid-grid-layout {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1rem;
    width: 100%;
    padding: 20px;
    /* 20px buffer on all sides */
    box-sizing: border-box;
    min-height: 320px;
}

/* Each grid column - top and center justified */
.grid-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    /* Top justified */
}

/* Headers - uniform styling */
.microgrid-grid-layout .viz-header {
    font-weight: bold;
    font-size: 14px;
    color: var(--acuity-text);
    text-align: center;
    margin-bottom: 8px;
    white-space: nowrap;
}

/* Vertical power bars - uniform size */
.microgrid-grid-layout .power-bar-track {
    width: 16px;
    height: 200px;
    background-color: #333;
    border-radius: 8px;
    overflow: visible;
    position: relative;
}

/* Power bar fill - visible color in the track */
.microgrid-grid-layout .power-bar-fill {
    position: absolute;
    left: 0;
    width: 100%;
    border-radius: 4px;
    transition: all 0.3s ease;
}

/* Power bar center line */
.microgrid-grid-layout .power-bar-center-line {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%);
}

/* Bottom labels - uniform styling */
.microgrid-grid-layout .viz-label {
    font-weight: bold;
    font-size: 14px;
    color: var(--acuity-text);
    text-align: center;
    margin-top: 8px;
    white-space: nowrap;
}

/* Energy Storage power bar container (horizontal bar) */
.power-bar-container-vertical {
    width: 16px;
    height: 200px;
    background-color: #333;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

/* Battery column - aligned with power bar columns */
.grid-col-battery {
    min-width: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 25px;
}

/* 
 * Battery wrapper inside grid - overrides base .battery-viz-wrapper styles
 * Height set to 200px to match power bar track height, so label stacks naturally below
 */
.grid-col-battery .battery-viz-wrapper {
    height: 200px;
    width: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 0;
    /* No extra margin - wrapper height handles positioning */
}

/* Battery rotation preserved, no extra margins needed */
.grid-col-battery .battery-viz-rotated {
    /* Inherits base rotation styles */
}

/* kWh label stacks naturally below the wrapper */
.grid-col-battery .viz-label-charge {
    font-weight: bold;
    font-size: 14px;
    color: var(--acuity-text);
    text-align: center;
    padding-top: 10px;
}

/* Badges column */
.grid-col-badges {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.bess-compact .bess-status-group {
    gap: 0.35rem;
}

.bess-compact .bess-status-heading {
    font-size: 0.75rem;
    margin-bottom: 0.15rem;
}

.bess-compact .bess-status-row {
    margin-bottom: 0.05rem;
}

/* Compact badge styles */
.status-badge.badge-compact {
    padding: 0.2rem 0.5rem;
    font-size: 0.5rem;
    border-radius: 6px;
    width: 120px;
    text-align: left;
    padding-left: 10px;
}

.status-badge.badge-compact i {
    font-size: 0.75rem;
}

/* Toggle Switch */
.toggle-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
}

.toggle-switch input {
    display: none;
}

.toggle-slider {
    position: relative;
    width: 44px;
    height: 24px;
    background-color: #3a3b3c;
    /* Darker background for off state */
    border: 1px solid var(--app-border);
    border-radius: 999px;
    transition: background-color 0.2s, border-color 0.2s;
    flex-shrink: 0;
}

.toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background-color: var(--app-text-muted);
    border-radius: 50%;
    transition: transform 0.2s, background-color 0.2s;
}

.toggle-switch input:checked+.toggle-slider {
    background-color: rgba(0, 177, 118, 0.22);
    border-color: rgba(0, 177, 118, 0.45);
}

.toggle-switch input:checked+.toggle-slider::after {
    transform: translateX(20px);
    background-color: var(--app-success);
}

.toggle-label-text {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--app-text-muted);
    min-width: 180px;
    /* Ensure consistent width for labels */
    text-align: right;
}

.toggle-switch input:checked~.toggle-label-text {
    color: var(--app-success);
}

/* Segmented Control Styles */
.segmented-control {
    display: flex;
    border: 1px solid var(--app-border);
    border-radius: 6px;
    overflow: hidden;
    height: 36px;
}

.segmented-control.compact {
    height: 28px;
}

.segmented-control button {
    flex: 1;
    border: none;
    border-right: 1px solid var(--app-border);
    background: transparent;
    color: var(--app-text);
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    padding: 0;
}

.segmented-control.compact button {
    font-size: 0.75rem;
}

.segmented-control button:last-child {
    border-right: none;
}

.segmented-control button.active {
    background: var(--app-accent);
    color: white;
}

/* Compact Table Override */
.register-table.compact th,
.register-table.compact td {
    padding: 0.25rem 0.5rem;
}

/* Strict Compact Sizes */
.register-table.compact .select-input.compact,
.register-table.compact .number-input.compact {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    height: 28px;
    line-height: 1;
}

.register-table.compact .toggle-switch.compact {
    transform: scale(0.8);
    transform-origin: left center;
}

.register-table.compact td {
    vertical-align: middle;
}

/* Force nowrap on segmented buttons */
.segmented-control button {
    white-space: nowrap;
}

/* Input with Suffix Decoration */
.input-suffix-group {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.input-suffix-group input {
    padding-right: 2.25rem !important;
    /* Make room for suffix, override compact padding if needed */
}

.input-suffix-group .suffix {
    position: absolute;
    right: 0.65rem;
    color: var(--app-text-muted);
    font-size: 0.8rem;
    pointer-events: none;
    user-select: none;
}

.btn-bumblebee {
    background: transparent;
    border: 1px solid var(--acuity-yellow);
    color: var(--acuity-yellow);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-bumblebee:hover:not(:disabled) {
    background: var(--acuity-yellow);
    color: var(--acuity-midnight);
    box-shadow: 0 0 10px rgba(255, 199, 25, 0.4);
}

.btn-bumblebee:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    border-color: var(--app-text-muted);
    color: var(--app-text-muted);
}

/* Sync Status Indicator */
.sync-indicator {
    position: absolute;
    top: -6px;
    right: -6px;
    font-size: 0.9rem;
    z-index: 10;
}

.sync-indicator.synced {
    color: var(--acuity-clean-green);
}

.sync-indicator.dirty {
    color: var(--acuity-yellow);
}

/* Control wrapper for indicator positioning */
.control-with-indicator {
    position: relative;
    display: inline-block;
}

/* Commit Button - Full Width */
.btn-commit {
    width: 100%;
    background: transparent;
    border: 2px solid var(--acuity-yellow);
    color: var(--acuity-yellow);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
}

.btn-commit:hover:not(:disabled) {
    background: var(--acuity-yellow);
    color: var(--acuity-midnight);
    box-shadow: 0 0 15px rgba(255, 199, 25, 0.5);
}

.btn-commit:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: var(--app-text-muted);
    color: var(--app-text-muted);
}

/* Mode-specific action buttons (Standby, System Reset, Soft Shutdown, Hard Shutdown) */
.mode-action-btn {
    width: 100%;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    background: transparent;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.mode-action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Standby - Yellow */
.mode-btn-standby {
    border: 2px solid var(--acuity-yellow);
    color: var(--acuity-yellow);
}

.mode-btn-standby:hover:not(:disabled) {
    background: var(--acuity-yellow);
    color: #000000;
    box-shadow: 0 0 15px rgba(255, 199, 25, 0.4);
}

/* System Reset - Blue */
.mode-btn-reset {
    border: 2px solid var(--acuity-clearsky-blue);
    color: var(--acuity-clearsky-blue);
}

.mode-btn-reset:hover:not(:disabled) {
    background: var(--acuity-clearsky-blue);
    color: #ffffff;
    box-shadow: 0 0 15px rgba(30, 139, 247, 0.4);
}

/* Soft Shutdown - Orange */
.mode-btn-soft-shutdown {
    border: 2px solid var(--acuity-orange);
    color: var(--acuity-orange);
}

.mode-btn-soft-shutdown:hover:not(:disabled) {
    background: var(--acuity-orange);
    color: #000000;
    box-shadow: 0 0 15px rgba(247, 138, 30, 0.4);
}

/* Hard Shutdown - Red */
.mode-btn-hard-shutdown {
    border: 2px solid var(--acuity-terra-red);
    color: var(--acuity-terra-red);
}

.mode-btn-hard-shutdown:hover:not(:disabled) {
    background: var(--acuity-terra-red);
    color: #ffffff;
    box-shadow: 0 0 15px rgba(183, 65, 14, 0.4);
}

/* Header User Section - inline with version */
.header-user-section {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: 0.25rem;
}

.header-separator {
    color: var(--app-text-muted);
    margin: 0 0.25rem;
}

.header-user-pip {
    color: var(--acuity-clean-green);
    font-size: 0.4rem;
}

.header-username {
    font-weight: 600;
    letter-spacing: 0.05em;
    color: var(--acuity-clean-green);
}

.header-logout-btn {
    background: transparent;
    border: none;
    color: var(--app-text-muted);
    padding: 0.2rem 0.3rem;
    cursor: pointer;
    transition: color 0.2s ease;
    display: inline-flex;
    align-items: center;
    margin-left: 0.25rem;
}

.header-logout-btn:hover {
    color: var(--app-text);
}

.header-logout-btn i {
    font-size: 0.85rem;
}

/* Vertical 2-Position Switch for Control Modes */
.vertical-switch {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
}

.vertical-switch-option {
    position: relative;
    padding: 1rem 1.25rem;
    background: var(--app-surface-alt);
    border: 1px solid var(--app-border);
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.vertical-switch-option:first-child {
    border-radius: 12px 12px 0 0;
    border-bottom: none;
}

.vertical-switch-option:last-child {
    border-radius: 0 0 12px 12px;
}

.vertical-switch-option:hover {
    background: rgba(255, 255, 255, 0.04);
}

.vertical-switch-option.active {
    background: linear-gradient(135deg, rgba(0, 177, 118, 0.12), rgba(0, 177, 118, 0.05));
    border-color: rgba(0, 177, 118, 0.4);
}

.vertical-switch-option.active:first-child {
    border-bottom: none;
}

.vertical-switch-option.active+.vertical-switch-option {
    border-top-color: rgba(0, 177, 118, 0.4);
}

.vertical-switch-indicator {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--app-border);
    background: var(--app-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.25s ease;
}

.vertical-switch-option.active .vertical-switch-indicator {
    border-color: var(--app-success);
    background: transparent;
}

.vertical-switch-option.active .vertical-switch-indicator::after {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--app-success);
}

.vertical-switch-content {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.vertical-switch-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--app-text);
    transition: color 0.25s ease;
}

.vertical-switch-option.active .vertical-switch-title {
    color: var(--app-success);
}

.vertical-switch-description {
    font-size: 0.8rem;
    color: var(--app-text-muted);
    line-height: 1.3;
}

.vertical-switch-option.disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.vertical-switch-option.disabled .vertical-switch-indicator {
    border-color: var(--app-border);
}

.vertical-switch-option.disabled .vertical-switch-title {
    color: var(--app-text-muted);
}

.vertical-switch-badge {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: rgba(255, 199, 25, 0.15);
    color: var(--app-warning);
    margin-left: 0.5rem;
}

/* Input prefix (for currency inputs) */
.input-suffix-group .prefix {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--app-text-muted);
    pointer-events: none;
    font-size: 0.9rem;
}

.input-suffix-group:has(.prefix) input {
    padding-left: 1.75rem;
}

/* Dialog/Modal Styles */
/* z-index 1040: below Aderis.Common's .aderis-modal-overlay (1050) so library dialogs
   (e.g. IDialogService.ShowPromptAsync/ShowModalAsync) always render above these legacy,
   not-yet-converted overlays — the correct order for the remainder of the dialog migration.
   Still above every non-dialog stacking context in this stylesheet (dropdowns, sticky
   headers, table frozen columns, etc. all sit well under 1000). */
.dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1040;
    padding: 1rem;
    animation: fadeIn 0.15s ease;
}

/* Higher z-index for dialogs that open above other dialogs */
.dialog-overlay-top {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1200;
    padding: 1rem;
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.dialog {
    width: 90vw;
    max-width: 480px;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 20px;
    box-shadow: 0 32px 64px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    animation: dialogSlideIn 0.2s ease;
}

.dialog-panel {
    width: 90vw;
    max-width: 640px;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 20px;
    box-shadow: 0 32px 64px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    animation: dialogSlideIn 0.2s ease;
}

@keyframes dialogSlideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    background: var(--app-surface-alt);
    border-bottom: 1px solid var(--app-border);
}

.dialog-header h3 {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.dialog-body {
    padding: 1.5rem;
}

.dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    background: var(--app-surface-alt);
    border-top: 1px solid var(--app-border);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

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

.compact-button {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
}

.compact-section {
    margin-bottom: 0.75rem;
}

/* Link-style buttons */
.link-button {
    background: none;
    border: none;
    color: var(--app-accent);
    cursor: pointer;
    font-size: inherit;
    padding: 0;
    transition: color 0.2s ease;
}

.link-button:hover {
    color: #00c987;
    text-decoration: underline;
}

.link-button.link-remove {
    color: var(--app-danger);
}

.link-button.link-remove:hover {
    color: #ff7a63;
}

/* ─── Clone Wizard ───────────────────────────────────────────────────── */

.clone-wizard {
    max-width: 700px !important;
}

.clone-section-group {
    margin-bottom: 0.25rem;
}

.clone-label {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--app-text-muted);
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.3rem;
}

.clone-parent-toggle {
    display: inline-flex;
    border: 1px solid var(--app-border);
    border-radius: 6px;
    overflow: hidden;
}

.clone-parent-toggle button {
    border: none;
    background: transparent;
    color: var(--app-text-muted);
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.clone-parent-toggle button:first-child {
    border-right: 1px solid var(--app-border);
}

.clone-parent-toggle button.active {
    background: var(--app-accent);
    color: white;
}

.clone-variable {
    padding: 0.45rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.clone-variable:last-of-type {
    border-bottom: none;
}

.clone-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

.clone-toggle input[type="checkbox"] {
    accent-color: var(--app-accent);
    width: 16px;
    height: 16px;
}

.clone-field-body {
    margin-top: 0.35rem;
    padding-left: 1.6rem;
}

.clone-inline-fields {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.clone-inline-fields label {
    font-size: 0.72rem;
    color: var(--app-text-muted);
    margin-bottom: 0.15rem;
}

.clone-ai-btn {
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    border: none;
    color: #fff;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
    box-shadow: 0 2px 10px rgba(124, 58, 237, 0.3);
}

.clone-ai-btn i,
.clone-ai-btn .bi {
    color: #fff;
}

.clone-ai-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #6d28d9, #9333ea);
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.5);
    transform: translateY(-1px);
}

.clone-ai-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.clone-name-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.4rem;
}

.clone-chip {
    display: inline-flex;
    align-items: center;
    background: var(--app-surface-alt);
    border: 1px solid var(--app-border);
    border-radius: 4px;
    overflow: hidden;
}

.clone-chip input {
    background: transparent;
    border: none;
    color: var(--app-text);
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
    font-family: monospace;
    width: auto;
    min-width: 60px;
    max-width: 140px;
}

.clone-chip input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.04);
}

.chip-remove {
    background: transparent;
    border: none;
    border-left: 1px solid var(--app-border);
    color: var(--app-text-muted);
    cursor: pointer;
    padding: 0.2rem 0.35rem;
    font-size: 0.75rem;
    transition: color 0.15s;
}

.chip-remove:hover {
    color: var(--app-danger);
}

.clone-error {
    font-size: 0.78rem;
    color: var(--app-danger);
    margin: 0.2rem 0;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.clone-preview-table {
    border: 1px solid var(--app-border);
    border-radius: 6px;
    overflow: hidden;
    font-size: 0.75rem;
}

.clone-preview-header {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 0;
    background: var(--app-surface-alt);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--app-text-muted);
}

.clone-preview-header span:first-child {
    max-width: 35px;
    text-align: center;
}

.clone-preview-header span {
    padding: 0.35rem 0.5rem;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
}

.clone-preview-header span:last-child {
    border-right: none;
}

.clone-preview-row {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.clone-preview-row span:first-child {
    max-width: 35px;
    text-align: center;
    color: var(--app-text-muted);
}

.clone-preview-row span {
    padding: 0.3rem 0.5rem;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
    font-family: monospace;
}

.clone-preview-row span:last-child {
    border-right: none;
}

.clone-preview-row .preview-name {
    font-family: inherit;
    font-weight: 500;
}

.spinner-sm {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: #c9a0ff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* CSV Download Button — blue translucent */
.btn-csv {
    background: rgba(30, 139, 247, 0.15) !important;
    border: 1px solid rgba(30, 139, 247, 0.4) !important;
    color: #5db8ff !important;
}

.btn-csv:hover {
    background: rgba(30, 139, 247, 0.3) !important;
    box-shadow: 0 0 8px rgba(30, 139, 247, 0.3);
}

/* Expand/Collapse Tree Chevron */
.tree-chevron {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s ease;
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.7rem;
    margin-right: 0.25rem;
}

.tree-chevron.collapsed {
    transform: rotate(-90deg);
}

.tree-chevron:hover {
    color: rgba(255, 255, 255, 0.8);
}

/* Child count badge (shown when collapsed) */
.child-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.68rem;
    font-weight: 600;
    margin-left: 0.4rem;
}

/* Nuke button */
.link-nuke {
    color: var(--app-danger) !important;
    font-weight: 600;
}

.link-nuke:hover {
    text-shadow: 0 0 8px rgba(183, 65, 14, 0.6);
}

/* Reactivate link */
.link-reactivate {
    color: #4ecf7a !important;
}

/* Clone link */
.link-button.link-clone {
    color: var(--app-accent);
}

.link-button.link-clone:hover,
.link-button.link-clone:focus-visible {
    color: #00c987;
}

/* ═══════════════════════════════════════════════════════════════════════
   KPI Manager
   ═══════════════════════════════════════════════════════════════════════ */

/* Main layout: floating sidebar + editor panel */
.kpi-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 2rem;
    min-height: 500px;
    transition: grid-template-columns 0.3s ease;
}

.kpi-layout.sidebar-collapsed {
    grid-template-columns: 48px 1fr;
}

/* ─── Shared sidebar classes (mirror ConfigureFacility pattern) ────── */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.sidebar-field {
    margin-bottom: 1rem;
}

.sidebar-field .text-label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--app-text-muted);
}

.text-label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--app-text-muted);
    font-weight: 600;
}

.sidebar-toggle {
    background: none;
    border: 1px solid var(--app-border);
    border-radius: 6px;
    color: var(--app-text-muted);
    cursor: pointer;
    padding: 0.35rem 0.45rem;
    font-size: 0.85rem;
    transition: color 0.15s, border-color 0.15s;
    line-height: 1;
}

.sidebar-toggle:hover {
    color: var(--app-text);
    border-color: var(--app-text-muted);
}

/* ─── KPI Sidebar (floating card style) ────────────────────────────── */
.kpi-sidebar {
    background: var(--app-surface-alt);
    border: 1px solid var(--app-border);
    border-radius: 12px;
    padding: 1.25rem;
    transition: padding 0.3s ease, opacity 0.25s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.kpi-sidebar.collapsed {
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-direction: column;
}

.kpi-list {
    flex: 1;
    overflow-y: auto;
    margin: 0 -1.25rem;
    padding: 0.5rem 0;
}

.kpi-list-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--app-text-muted);
    font-size: 0.85rem;
}

/* Groups */
.kpi-group {
    margin-bottom: 0.1rem;
}

.kpi-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.35rem 1.25rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--app-text-muted);
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}

.kpi-group-header:hover {
    color: #2196F3;
}

.kpi-group-count {
    margin-left: auto;
    background: rgba(33, 150, 243, 0.15);
    color: #2196F3;
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
}

/* List items */
.kpi-list-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.5rem 1.25rem 0.5rem 2.25rem;
    cursor: pointer;
    transition: background 0.15s;
    border-left: 3px solid transparent;
}

.kpi-list-item:hover {
    background: rgba(33, 150, 243, 0.08);
}

.kpi-list-item.selected {
    background: rgba(33, 150, 243, 0.15);
    border-left-color: #2196F3;
}

.kpi-list-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--app-heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-list-key {
    font-size: 0.72rem;
    color: var(--app-text-muted);
    font-family: monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── Main Editor Area ─────────────────────────────────────────────── */
.kpi-main {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.kpi-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 1rem;
    color: var(--app-text-muted);
    padding: 3rem;
}

.kpi-empty-state i {
    font-size: 3rem;
    opacity: 0.3;
}

.kpi-empty-state p {
    font-size: 0.95rem;
}

/* Editor header bar (title + actions) */
.kpi-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.kpi-editor-header h3 {
    font-size: 1.1rem;
    flex: 1;
    margin: 0;
}

.kpi-editor-scroll {
    flex: 1;
    overflow-y: auto;
}

/* ─── Collapsible Properties Card ──────────────────────────────────── */
.kpi-meta-card {
    border: 1px solid var(--app-border);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    background: var(--app-surface-alt);
    overflow: hidden;
}

.kpi-meta-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    cursor: pointer;
    user-select: none;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--app-text-muted);
    transition: color 0.15s;
}

.kpi-meta-card-header:hover {
    color: var(--app-text);
}

.kpi-meta-card-body {
    padding: 0 1rem 1rem;
}

/* ─── Graph Section ────────────────────────────────────────────────── */
.kpi-graph-section {
    border: 1px solid var(--app-border);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    background: var(--app-surface-alt);
    overflow: hidden;
}

.kpi-graph-stage {
    position: relative;
    min-height: 400px;
    margin-bottom: 1rem;
    overflow: hidden;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.15);
    cursor: grab;
}

.kpi-graph-stage:active {
    cursor: grabbing;
}

/* Graph-paper grid background */
.kpi-graph-grid {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: auto;
    background:
        linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
    background-size: 24px 24px;
}

/* Toolbar helpers */
.toolbar-divider {
    display: inline-block;
    width: 1px;
    height: 20px;
    background: rgba(255,255,255,0.12);
    margin: 0 0.15rem;
}

.compact-button.icon-only {
    padding: 0.3rem 0.45rem;
    min-width: 0;
}

.kpi-graph-wires {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 1;
}

.kpi-graph-nodes {
    position: relative;
    z-index: 2;
    min-height: 400px;
}

/* ─── Node Elements (rendered by JS interop) ──────────────────────── */
.kpi-node {
    position: absolute;
    min-width: 180px;
    max-width: 260px;
    border-radius: 10px;
    background: rgba(30, 35, 50, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    cursor: grab;
    user-select: none;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.kpi-node:hover {
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.kpi-node.selected {
    border-color: var(--app-accent);
    box-shadow: 0 0 0 2px rgba(0, 177, 118, 0.3), 0 8px 24px rgba(0, 0, 0, 0.4);
}

.kpi-node-header {
    padding: 0.35rem 0.6rem;
    border-radius: 9px 9px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.kpi-node-kind {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.9);
}

.kpi-node-delete {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 1rem;
    cursor: pointer;
    padding: 0 0.2rem;
    line-height: 1;
}

.kpi-node-delete:hover {
    color: var(--app-danger);
}

.kpi-node-body {
    padding: 0.3rem 0.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 60px;
}

.kpi-node-label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--app-heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpi-node-config-summary {
    font-size: 0.7rem;
    color: var(--app-text-muted);
    margin-top: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── Node content: inputs | body | outputs ── */
.kpi-node-content {
    display: flex;
    align-items: stretch;
}

.kpi-node-inputs,
.kpi-node-outputs {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: 0.3rem 0;
}

.kpi-node-inputs {
    padding-left: 0;
}

.kpi-node-outputs {
    padding-right: 0;
}

.kpi-port-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 1px 0;
}

.kpi-port-row--in {
    padding-left: 0;
}

.kpi-port-row--out {
    padding-right: 0;
}

.kpi-port-label {
    font-size: 0.55rem;
    font-weight: 600;
    font-family: monospace;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

/* ─── Port dots ─── */
.kpi-node-port {
    display: block;
    width: 10px;
    height: 10px;
    min-width: 10px;
    min-height: 10px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(30, 35, 50, 0.95);
    cursor: crosshair;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    flex-shrink: 0;
    box-sizing: border-box;
}

.kpi-node-port--in {
    border-color: #2196F3;
}

.kpi-node-port--out {
    border-color: #4CAF50;
}

.kpi-node-port:hover {
    transform: scale(1.4);
    background: #fff;
}

/* Available port glow during wire drawing */
.kpi-node-port.kpi-port-available {
    border-color: #2196F3;
    box-shadow: 0 0 6px rgba(33, 150, 243, 0.6);
    animation: port-pulse 1s ease-in-out infinite;
}


@keyframes port-pulse {
    0%, 100% { box-shadow: 0 0 4px rgba(33, 150, 243, 0.4); }
    50% { box-shadow: 0 0 10px rgba(33, 150, 243, 0.8); }
}

/* ─── Wire styling ─── */
.kpi-wire {
    stroke: #f1c40f;
    stroke-width: 2;
    fill: none;
    transition: stroke 0.2s;
}

.kpi-wire:hover {
    stroke: #f9e547;
    stroke-width: 2.5;
}

.kpi-wire-pending {
    pointer-events: none;
}

/* ─── Config Modal ─── */
.kpi-config-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(2px);
}

.kpi-config-modal {
    background: var(--app-card-bg, #1e2235);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    width: 380px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.kpi-config-header {
    padding: 0.6rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: rgba(255, 255, 255, 0.9);
}

.kpi-config-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 0.2rem;
    line-height: 1;
}

.kpi-config-close:hover {
    color: #fff;
}

.kpi-config-body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.kpi-config-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.kpi-config-field label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--app-text-muted);
}

.kpi-config-field--checkbox label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    text-transform: none;
}

.kpi-config-footer {
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* ─── Test Value field with AI button ─── */
.kpi-config-field--testvalue {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.kpi-testvalue-row {
    display: flex;
    align-items: stretch;
    gap: 0.35rem;
}

.kpi-testvalue-input {
    flex: 1;
    resize: vertical;
    min-height: 1.8rem;
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--acuity-purple, #c9a0ff);
    padding: 0.3rem 0.5rem;
}

.kpi-config-ai-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: linear-gradient(135deg, #7c3aed, #a855f7);
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 0.25rem 0.55rem;
    border-radius: 6px;
    font-size: 0.68rem;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
    flex-shrink: 0;
    align-self: flex-start;
}

.kpi-config-ai-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #6d28d9, #9333ea);
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.5);
    transform: translateY(-1px);
}

.kpi-config-ai-btn:disabled {
    opacity: 0.4;
    cursor: wait;
    box-shadow: none;
}

.kpi-config-ai-btn .ai-icon {
    font-size: 0.75rem;
    color: #fff;
}

.kpi-config-ai-btn .ai-label {
    letter-spacing: 0.04em;
    color: #fff;
}

.kpi-config-ai-btn .ai-spinner {
    display: inline-block;
    width: 11px;
    height: 11px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ─── Simulation timing indicators ─────────────────────────────────── */
.sim-timing {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    font-family: monospace;
    font-size: 0.65rem;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    margin-left: 0.4rem;
    white-space: nowrap;
    text-transform: none;
}
.sim-timing--fast {
    color: #2ecc71;
    background: rgba(46, 204, 113, 0.1);
}
.sim-timing--medium {
    color: #f39c12;
    background: rgba(243, 156, 18, 0.1);
}
.sim-timing--slow {
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
}

/* ─── Simulation result type badges ────────────────────────────────── */
.sim-result-badge {
    display: inline-block;
    font-family: monospace;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    border: none;
    color: #d4aaff;
    background: rgba(160, 100, 255, 0.18);
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}
.sim-result-badge:hover {
    background: rgba(160, 100, 255, 0.32);
    transform: scale(1.04);
}

/* ─── Simulation result viewer pre block ───────────────────────────── */
.sim-result-pre {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.78rem;
    line-height: 1.45;
    color: #c9a0ff;
    background: rgba(20, 18, 30, 0.6);
    margin: 0;
    padding: 1rem 1.25rem;
    white-space: pre;
    tab-size: 2;
    overflow-x: auto;
}

/* ─── KPI Result Kind Badges ────────────────────────────────────── */
.kpi-result-kind-badge {
    display: inline-block;
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.12rem 0.4rem;
    border-radius: 4px;
    white-space: nowrap;
}
.kpi-result-kind--scalar { background: rgba(46, 204, 113, 0.18); color: #2ecc71; }
.kpi-result-kind--array { background: rgba(52, 152, 219, 0.18); color: #3498db; }
.kpi-result-kind--json { background: rgba(155, 89, 182, 0.18); color: #c9a0ff; }

/* ─── Description Tab ───────────────────────────────────────────── */
.kpi-desc-group {
    border: 1px solid var(--app-border, rgba(255,255,255,0.08));
    border-radius: 6px;
    margin-bottom: 0.5rem;
    overflow: hidden;
}
.kpi-desc-group .kpi-meta-card-header {
    background: rgba(255,255,255,0.02);
}
.kpi-desc-group .register-table {
    border-top: 1px solid var(--app-border, rgba(255,255,255,0.08));
}

/* ─── Export segmented button (green hover/active) ──────────────── */
.kpi-export-seg button {
    padding: 0.25rem 0.65rem !important;
    gap: 0.4rem;
}
.kpi-export-seg button:hover {
    background: rgba(46, 204, 113, 0.15) !important;
    color: #2ecc71 !important;
    border-color: rgba(46, 204, 113, 0.3) !important;
}
.kpi-export-seg button:active {
    background: rgba(46, 204, 113, 0.25) !important;
    color: #27ae60 !important;
}

/* ─── Clickable dependency badges ───────────────────────────────── */
.kpi-dep-link {
    cursor: pointer;
    border: none;
    font-family: 'Outfit', sans-serif;
    transition: filter 0.15s ease;
}
.kpi-dep-link:hover {
    filter: brightness(1.4);
}

/* ─── Inline dep graph & active row ─────────────────────────────── */
.dep-row-active {
    background: rgba(46, 204, 113, 0.04);
}
.dep-net-active {
    color: #2ecc71 !important;
}
.dep-inline-graph {
    background: rgba(0, 0, 0, 0.15);
}
.register-table tbody tr:has(.kpi-graph-stage),
.register-table tbody tr:has(.kpi-export-seg) {
    background: transparent !important;
}
/* KPI Explorer table: top-align rows, padding, and line spacing */
.kpi-dep-tab .register-table td {
    vertical-align: top;
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
    line-height: 1.5;
}

/* ═══════════════════════════════════════════════════════════════════════
   Alarm Event Triggers
   ═══════════════════════════════════════════════════════════════════════ */

.trigger-section {
    border: 1px solid var(--app-border);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    background: var(--app-surface-alt);
    overflow: hidden;
}

.trigger-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}

.trigger-table th {
    text-align: left;
    padding: 0.4rem 0.5rem;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--app-text-muted);
    border-bottom: 1px solid var(--app-border);
    white-space: nowrap;
}

.trigger-table td {
    padding: 0.45rem 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    vertical-align: middle;
}

.trigger-table tr:last-child td {
    border-bottom: none;
}

.trigger-table tr.trigger-disabled td {
    opacity: 0.35;
}

.trigger-table tr.trigger-disabled td:first-child {
    opacity: 1;
}

/* Drag handle */
.trigger-drag-handle {
    cursor: grab;
    color: var(--app-text-muted);
    font-size: 0.85rem;
    padding: 0 0.25rem;
    user-select: none;
    opacity: 0.5;
    transition: opacity 0.15s, color 0.15s;
}

.trigger-drag-handle:hover {
    opacity: 1;
    color: var(--app-text);
}

.trigger-row.dragging {
    opacity: 0.4;
    background: rgba(33, 150, 243, 0.08);
}

.trigger-row.drag-over {
    border-top: 2px solid var(--app-accent) !important;
}

/* Inline content wrapper inside table cells */
.trigger-inline-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    white-space: nowrap;
}

/* Label text matching "View controls:" style */
.trigger-label {
    color: var(--app-text-muted);
    font-size: 0.68rem;
    white-space: nowrap;
}

/* Alarm icon preview next to select */
.trigger-alarm-icon {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

/* Rising / Falling edge character icons */
.trigger-edge-icon {
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
}

.trigger-edge-rise {
    color: var(--acuity-clearsky-blue, #3b82f6);
}

.trigger-edge-fall {
    color: var(--acuity-terra-red, #ef4444);
}

/* Toggle switch */
.trigger-toggle {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 18px;
    flex-shrink: 0;
}

.trigger-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.trigger-toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 9px;
    transition: background 0.2s;
}

.trigger-toggle-slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    left: 2px;
    bottom: 2px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}

.trigger-toggle input:checked + .trigger-toggle-slider {
    background: var(--app-accent, #00b176);
}

.trigger-toggle input:checked + .trigger-toggle-slider::before {
    transform: translateX(14px);
}

.trigger-toggle input:disabled + .trigger-toggle-slider {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Condition badge for boolean rows */
.trigger-condition-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    font-family: monospace;
    letter-spacing: 0.04em;
    padding: 0.15rem 0.55rem;
    border-radius: 4px;
    white-space: nowrap;
}

.trigger-condition-badge--true {
    background: rgba(46, 204, 113, 0.12);
    color: #2ecc71;
}

.trigger-condition-badge--false {
    background: rgba(231, 76, 60, 0.12);
    color: #e74c3c;
}

/* Compact numeric input */
.trigger-delay-input {
    width: 60px;
    text-align: center;
    font-family: monospace;
    font-size: 0.75rem;
    padding: 0.2rem 0.3rem;
}

/* Description text input */
.trigger-desc-input {
    width: 100%;
    min-width: 120px;
    font-size: 0.75rem;
    padding: 0.2rem 0.4rem;
}

.trigger-value-input {
    width: 80px;
    text-align: center;
    font-family: monospace;
    font-size: 0.75rem;
    padding: 0.2rem 0.3rem;
}

.trigger-condition-select {
    width: 60px;
    font-family: monospace;
    font-size: 0.75rem;
    text-align: center;
    padding: 0.2rem 0.15rem;
}

.trigger-alarm-select {
    min-width: 60px;
    max-width: 140px;
    font-size: 0.75rem;
    padding: 0.2rem 0.3rem;
    text-align: center;
}

/* Footer row with add button */
.trigger-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

/* AI Suggestions dialog */
.ai-suggestion-card {
    border: 1px solid rgba(124, 58, 237, 0.3);
    border-radius: 8px;
    background: rgba(124, 58, 237, 0.06);
    padding: 0.75rem;
    margin-bottom: 0.5rem;
}

.ai-suggestion-card h5 {
    font-size: 0.78rem;
    font-weight: 700;
    color: #a855f7;
    margin: 0 0 0.5rem;
}

.ai-suggestion-card p {
    font-size: 0.8rem;
    color: var(--app-text);
    margin: 0 0 0.5rem;
    line-height: 1.5;
}

/* ─── Toast host (global error/info notifications) ───────────────── */
.toast-host {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10050;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    max-width: 480px;
}
.toast-item {
    pointer-events: auto;
    padding: 12px 14px;
    border-radius: 8px;
    background: rgba(20, 24, 32, 0.96);
    color: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border-left: 4px solid var(--app-accent, #3898ec);
    animation: toast-in 0.22s ease-out, toast-out 0.4s ease-in 4.55s forwards;
    font-size: 0.88rem;
    line-height: 1.4;
}
.toast-item .bi {
    font-size: 1.05rem;
    line-height: 1.3;
    flex-shrink: 0;
}
.toast-item--error {
    border-left-color: var(--app-danger, #e74c3c);
}
.toast-item--error .bi {
    color: var(--app-danger, #e74c3c);
}
.toast-item--info {
    border-left-color: var(--app-primary, #3898ec);
}
.toast-item--info .bi {
    color: var(--app-primary, #3898ec);
}
.toast-text {
    word-break: break-word;
}
@keyframes toast-in {
    from { transform: translateX(110%); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}
@keyframes toast-out {
    from { opacity: 1; }
    to   { opacity: 0; transform: translateX(40%); }
}

/* ─── Blazor circuit / error-ui overlays ─────────────────────────── */
/* Class state is flipped by Blazor's runtime on the modal element to show
   the appropriate paragraph based on reconnect state (show / failed /
   rejected). #blazor-error-ui is the unrecoverable-error banner. */
#blazor-error-ui {
    background: #ffefc7;
    color: #1c1c1c;
    bottom: 0;
    left: 0;
    width: 100%;
    box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.25);
    display: none;
    padding: 0.7rem 1.25rem;
    position: fixed;
    z-index: 10060;
    font-size: 0.9rem;
}
#blazor-error-ui .reload {
    color: #1c1c1c;
    text-decoration: underline;
    margin-left: 0.5rem;
}
#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.9rem;
    top: 0.55rem;
    color: #1c1c1c;
}

#components-reconnect-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 10055;
    align-items: center;
    justify-content: center;
}
#components-reconnect-modal .components-reconnect-content {
    background: var(--app-surface, #181c24);
    color: var(--app-text, #fff);
    padding: 24px 32px;
    border-radius: 10px;
    border: 1px solid var(--app-border, rgba(255,255,255,0.1));
    max-width: 420px;
    text-align: center;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}
#components-reconnect-modal p { margin: 0; }
#components-reconnect-modal .components-reconnect-show-text,
#components-reconnect-modal .components-reconnect-failed-text,
#components-reconnect-modal .components-reconnect-rejected-text {
    display: none;
}
#components-reconnect-modal a {
    color: var(--app-primary, #3898ec);
    text-decoration: underline;
    cursor: pointer;
}
.components-reconnect-show #components-reconnect-modal,
#components-reconnect-modal.components-reconnect-show {
    display: flex;
}
.components-reconnect-show #components-reconnect-modal .components-reconnect-show-text,
#components-reconnect-modal.components-reconnect-show .components-reconnect-show-text {
    display: block;
}
.components-reconnect-failed #components-reconnect-modal,
#components-reconnect-modal.components-reconnect-failed {
    display: flex;
}
.components-reconnect-failed #components-reconnect-modal .components-reconnect-failed-text,
#components-reconnect-modal.components-reconnect-failed .components-reconnect-failed-text {
    display: block;
}
.components-reconnect-rejected #components-reconnect-modal,
#components-reconnect-modal.components-reconnect-rejected {
    display: flex;
}
.components-reconnect-rejected #components-reconnect-modal .components-reconnect-rejected-text,
#components-reconnect-modal.components-reconnect-rejected .components-reconnect-rejected-text {
    display: block;
}