:root {
    --bg: #07111f;
    --bg-soft: #0b1728;
    --card: rgba(15, 23, 38, 0.94);
    --card-strong: #111c2f;
    --card-elevated: #162338;
    --border: rgba(110, 130, 160, 0.18);
    --border-strong: rgba(130, 155, 190, 0.28);
    --text: #d8e1ee;
    --heading: #f2f6fc;
    --muted: #8fa1bb;
    --primary: #395d92;
    --primary-dark: #2b476f;
    --primary-glow: rgba(63, 104, 162, 0.22);
    --secondary-bg: #252f3f;
    --secondary-bg-hover: #2f3c51;
    --secondary-text: #d8e1ee;
    --danger-bg: rgba(239, 68, 68, 0.14);
    --danger-text: #ff9a9a;
    --success-bg: rgba(34, 197, 94, 0.12);
    --success-text: #77e3a1;
    --pill-bg: rgba(130, 155, 190, 0.12);
    --shadow-soft: 0 14px 30px rgba(1, 8, 20, 0.38);
    --shadow-card: 0 20px 42px rgba(1, 8, 20, 0.46);
    --glow-soft: 0 0 0 1px rgba(76, 115, 173, 0.10), 0 0 24px rgba(52, 86, 136, 0.14);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background:
        radial-gradient(circle at top left, rgba(61, 92, 143, 0.18), transparent 24%),
        radial-gradient(circle at top right, rgba(28, 55, 92, 0.18), transparent 20%),
        linear-gradient(180deg, #08111d 0%, #07101b 100%);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

body {
    line-height: 1.45;
}

.page-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.dashboard-shell {
    min-height: auto;
    display: grid;
    gap: 18px;
    padding: 18px;
}

.card,
.card-wide,
.site-card {
    background: linear-gradient(180deg, rgba(18, 29, 46, 0.96), rgba(12, 22, 37, 0.96));
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow-card), var(--glow-soft);
    backdrop-filter: blur(12px);
}

.card {
    width: 100%;
    max-width: 640px;
    padding: 28px;
}

.card-wide {
    width: 100%;
    padding: 20px;
}

.login-card {
    max-width: 420px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    margin-bottom: 12px;
    flex-wrap: nowrap;
    padding: 18px 22px;
    background: linear-gradient(180deg, rgba(18, 29, 46, 0.96), rgba(12, 22, 37, 0.96));
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow-card), var(--glow-soft);
}

.topbar h1 {
    margin: 0 0 6px;
    color: var(--heading);
}

.topbar p {
    margin: 0;
    font-size: 12px;
    line-height: 1.25;
    color: var(--muted);
}

.topbar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
}

.toolbar {
    margin-bottom: 20px;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 18px;
}

.site-card {
    padding: 20px;
}

.site-card-top {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 14px;
}

.site-action-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 14px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: var(--pill-bg);
    border: 1px solid rgba(130, 155, 190, 0.14);
    color: var(--text);
}

.status-offline {
    background: rgba(239, 68, 68, 0.12);
    color: #ff9a9a;
    border-color: rgba(239, 68, 68, 0.24);
}

.status-online {
    background: rgba(34, 197, 94, 0.12);
    color: #77e3a1;
    border-color: rgba(34, 197, 94, 0.24);
}

.empty-state {
    text-align: center;
    color: var(--muted);
}

.users-list {
    display: grid;
    gap: 18px;
}

.user-row-card {
    display: grid;
    gap: 18px;
}

.user-row-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.user-row-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.inline-form-card,
.command-history-row,
.site-assignment-list {
    background: linear-gradient(180deg, rgba(23, 34, 52, 0.96), rgba(18, 28, 43, 0.96));
    border: 1px solid rgba(110, 130, 160, 0.14);
    border-radius: 16px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.inline-form-card {
    padding: 16px;
}

.command-card,
.command-history-card {
    margin-top: 14px;
}

.command-history-list {
    display: grid;
    gap: 8px;
}

.command-history-row {
    display: grid;
    gap: 4px;
    padding: 10px 12px;
}

.site-assignment-list {
    display: grid;
    gap: 8px;
    max-height: 260px;
    overflow: auto;
    padding: 10px;
}

.site-assignment-row {
    align-items: flex-start;
    font-weight: 500;
}

.checkbox-row {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
}

.checkbox-row input {
    width: auto;
    margin: 0;
    flex: 0 0 auto;
}

h1 {
    margin: 0 0 18px;
    font-size: 28px;
    color: var(--heading);
}

h3 {
    margin: 0 0 10px;
    font-size: 20px;
    color: var(--heading);
}

p {
    color: var(--muted);
}

form {
    display: grid;
    gap: 12px;
}

label {
    font-size: 14px;
    font-weight: 700;
    color: var(--heading);
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border-strong);
    border-radius: 14px;
    font-size: 14px;
    background: rgba(10, 18, 30, 0.95);
    color: var(--text);
    outline: none;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.22);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input::placeholder,
textarea::placeholder {
    color: #7284a0;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(96, 133, 189, 0.48);
    box-shadow: 0 0 0 4px rgba(63, 104, 162, 0.16), 0 0 18px rgba(52, 86, 136, 0.16);
    background: rgba(12, 21, 34, 0.98);
}

button,
.button-link,
.button-link-secondary,
.dashboard-filter-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

button,
.button-link {
    margin-top: 8px;
    padding: 12px 16px;
    border: 1px solid rgba(98, 132, 186, 0.30);
    background: linear-gradient(180deg, #32415a, #273246);
    color: #eef4ff;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(6, 15, 30, 0.32), 0 0 18px rgba(52, 86, 136, 0.18);
}

button:hover,
.button-link:hover {
    background: linear-gradient(180deg, #3a4d6d, #2c3b54);
    box-shadow: 0 14px 28px rgba(5, 12, 24, 0.34), 0 0 22px rgba(63, 104, 162, 0.24);
    border-color: rgba(108, 145, 202, 0.34);
    transform: translateY(-1px);
}

.button-link-secondary {
    margin-top: 0;
    padding: 10px 15px;
    border: 1px solid rgba(130, 155, 190, 0.18);
    background: linear-gradient(180deg, #252f3f, #212a38);
    color: var(--secondary-text);
    font-size: 13px;
    line-height: 1.1;
    white-space: nowrap;
    box-shadow: 0 8px 20px rgba(5, 12, 24, 0.28), 0 0 16px rgba(52, 86, 136, 0.10);
}

.button-link-secondary:hover {
    background: linear-gradient(180deg, #2d394d, #263244);
    border-color: rgba(108, 145, 202, 0.26);
    box-shadow: 0 12px 24px rgba(5, 12, 24, 0.30), 0 0 18px rgba(63, 104, 162, 0.14);
    transform: translateY(-1px);
}

.topbar-actions .button-link,
.topbar-actions .button-link-secondary {
    margin-top: 0;
    padding: 10px 15px;
    border-radius: 999px;
    font-size: 13px;
    line-height: 1.1;
}

.alert {
    margin-bottom: 14px;
    padding: 12px 14px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 700;
    border: 1px solid transparent;
}

.alert-error {
    background: var(--danger-bg);
    color: var(--danger-text);
    border-color: rgba(239, 68, 68, 0.22);
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: rgba(34, 197, 94, 0.22);
}

.form-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.helper-text {
    margin: -4px 0 4px;
    font-size: 13px;
    color: var(--muted);
}

.helper-text a,
a {
    color: #9cb9e9;
    text-decoration: none;
}

.helper-text a:hover,
a:hover {
    color: #c7dbff;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    flex: 1 1 auto;
}

.dashboard-logo {
    width: 320px;
    height: 92px;
    display: block;
    object-fit: contain;
    object-position: left center;
    flex: 0 0 auto;
    margin-left: 0;
    filter: drop-shadow(0 8px 22px rgba(32, 54, 90, 0.32));
}

.logo-placeholder {
    width: 180px;
    height: 54px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed rgba(100, 116, 139, 0.55);
    border-radius: 14px;
    background: rgba(148, 163, 184, 0.08);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    flex: 0 0 auto;
}

.topbar-meta {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.dashboard-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(15, 24, 38, 0.94), rgba(12, 20, 32, 0.94));
    box-shadow: var(--shadow-soft), var(--glow-soft);
    backdrop-filter: blur(10px);
}

.dashboard-searchbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 340px;
}

.dashboard-searchbar input {
    width: min(520px, 100%);
}

.dashboard-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.dashboard-filter-btn {
    padding: 9px 13px;
    border: 1px solid rgba(130, 155, 190, 0.18);
    background: linear-gradient(180deg, #222c3b, #1d2633);
    color: var(--muted);
    font-size: 12px;
    cursor: pointer;
    margin: 0;
    box-shadow: 0 8px 18px rgba(5, 12, 24, 0.24);
}

.dashboard-filter-btn:hover {
    transform: translateY(-1px);
}

.dashboard-filter-btn.active {
    background: linear-gradient(180deg, #32476a, #273754);
    border-color: rgba(108, 145, 202, 0.34);
    color: #edf4ff;
    box-shadow: 0 0 0 3px rgba(63, 104, 162, 0.14), 0 0 18px rgba(63, 104, 162, 0.18);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    align-items: start;
}

.site-details {
    border: 1px solid var(--border);
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(16, 26, 41, 0.98), rgba(12, 20, 32, 0.98));
    box-shadow: var(--shadow-soft);
    overflow: hidden;
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.site-details:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 36px rgba(1, 8, 20, 0.42), 0 0 22px rgba(52, 86, 136, 0.12);
    border-color: rgba(96, 133, 189, 0.24);
}

.site-details.panel-ok {
    background: linear-gradient(180deg, rgba(15, 29, 35, 0.98), rgba(12, 24, 29, 0.98));
    border-color: rgba(34, 197, 94, 0.28);
    box-shadow: 0 14px 28px rgba(1, 8, 20, 0.40), 0 0 18px rgba(34, 197, 94, 0.08);
}

.site-details.panel-alarm {
    background: linear-gradient(180deg, rgba(34, 17, 22, 0.98), rgba(25, 13, 17, 0.98));
    border-color: rgba(239, 68, 68, 0.32);
    box-shadow:
        0 0 14px rgba(239, 68, 68, 0.18),
        0 0 28px rgba(239, 68, 68, 0.12),
        0 16px 34px rgba(1, 8, 20, 0.42);
    animation: sitePanelAlarmPulse 0.95s infinite ease-in-out;
}

@keyframes sitePanelAlarmPulse {
    0% {
        transform: scale(1);
        box-shadow:
            0 0 14px rgba(239, 68, 68, 0.18),
            0 0 28px rgba(239, 68, 68, 0.12),
            0 16px 34px rgba(1, 8, 20, 0.42);
    }
    50% {
        transform: scale(1.012);
        box-shadow:
            0 0 20px rgba(239, 68, 68, 0.28),
            0 0 38px rgba(239, 68, 68, 0.18),
            0 18px 38px rgba(1, 8, 20, 0.48);
    }
    100% {
        transform: scale(1);
        box-shadow:
            0 0 14px rgba(239, 68, 68, 0.18),
            0 0 28px rgba(239, 68, 68, 0.12),
            0 16px 34px rgba(1, 8, 20, 0.42);
    }
}

.site-details[open] {
    box-shadow: 0 22px 42px rgba(1, 8, 20, 0.46), 0 0 22px rgba(52, 86, 136, 0.12);
}

.site-summary {
    list-style: none;
    cursor: pointer;
    display: grid;
    gap: 12px;
    padding: 18px;
}

.site-summary::-webkit-details-marker {
    display: none;
}

.site-summary-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.site-aufschalt {
    margin: 0;
    font-size: 19px;
    font-weight: 800;
    letter-spacing: 0.01em;
    color: var(--heading);
}

.site-summary-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.site-customer {
    margin: 0;
    padding: 8px 12px;
    border-radius: 999px;
    color: #c7d4e7;
    font-size: 13px;
    font-weight: 700;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: rgba(104, 124, 154, 0.10);
    border: 1px solid rgba(130, 155, 190, 0.12);
}

.site-status-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.site-online-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 88px;
    padding: 7px 11px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border: 1px solid transparent;
    white-space: nowrap;
}

.site-online-badge.online {
    background: rgba(34, 197, 94, 0.12);
    color: #5ee68e;
    border-color: rgba(34, 197, 94, 0.28);
}

.site-online-badge.offline {
    background: rgba(239, 68, 68, 0.12);
    color: #ff8b8b;
    border-color: rgba(239, 68, 68, 0.24);
}

.alarm-led-wrap {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
}

.alarm-led {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #55657d;
    box-shadow: 0 0 0 rgba(239, 68, 68, 0);
    flex: 0 0 auto;
}

.alarm-led.active {
    background: #ef4444;
    box-shadow:
        0 0 10px rgba(239, 68, 68, 0.95),
        0 0 22px rgba(239, 68, 68, 0.55),
        0 0 34px rgba(239, 68, 68, 0.30);
    animation: alarmPulse 0.9s infinite ease-in-out;
}

@keyframes alarmPulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.24);
        opacity: 0.68;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.site-expand-hint {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 11px;
    color: #dfe8f7;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: rgba(63, 104, 162, 0.16);
    border: 1px solid rgba(96, 133, 189, 0.20);
    box-shadow: 0 0 14px rgba(52, 86, 136, 0.10);
}

.site-panel-body {
    display: grid;
    gap: 14px;
    padding: 0 18px 18px 18px;
    border-top: 1px solid rgba(130, 155, 190, 0.10);
    background: rgba(9, 16, 27, 0.76);
}

.site-info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding-top: 16px;
}

.site-info-item {
    padding: 12px 13px;
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(23, 34, 52, 0.98), rgba(18, 28, 43, 0.98));
    border: 1px solid rgba(110, 130, 160, 0.14);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.site-info-label {
    display: block;
    margin-bottom: 4px;
    color: #7f94b1;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.site-info-value {
    display: block;
    color: var(--heading);
    font-size: 14px;
    line-height: 1.45;
    word-break: break-word;
}

.dashboard-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 13px;
}

.site-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.dashboard-empty-state {
    padding: 34px;
    text-align: center;
    color: var(--muted);
    border: 1px dashed rgba(110, 130, 160, 0.24);
    border-radius: 22px;
    background: linear-gradient(180deg, rgba(15, 24, 38, 0.94), rgba(12, 20, 32, 0.94));
    box-shadow: var(--shadow-soft), var(--glow-soft);
}

@media (max-width: 1400px) {
    .dashboard-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 1100px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .topbar {
        padding: 16px 18px;
    }

    .dashboard-logo {
        width: 250px;
        height: 74px;
    }
}

@media (max-width: 900px) {
    .dashboard-toolbar {
        align-items: stretch;
    }

    .dashboard-searchbar {
        flex: 1 1 100%;
    }
}

@media (max-width: 760px) {
    .topbar {
        flex-wrap: wrap;
        align-items: flex-start;
        padding: 14px;
    }

    .topbar-brand,
    .topbar-actions {
        width: 100%;
    }

    .topbar-actions {
        justify-content: flex-start;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-shell {
        padding: 12px;
    }

    .dashboard-logo {
        width: 190px;
        height: 58px;
    }

    .site-info-grid,
    .user-row-actions-grid {
        grid-template-columns: 1fr;
    }
}