:root {
    --bg-body: #f3f4f6;
    --bg-card: #ffffff;
    --primary: #2563eb;
    --primary-soft: #dbeafe;
    --primary-text: #1e40af;
    --accent: #22c55e;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border-subtle: #e5e7eb;
    --radius-xl: 1rem;
    --shadow-soft: 0 25px 50px rgba(15, 23, 42, 0.08);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top left, #e0f2fe, #f9fafb);
    color: var(--text-main);
}

/* Layout */

.page-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    backdrop-filter: blur(12px);
    background: rgba(255, 255, 255, 0.85);
    border-bottom: 1px solid rgba(229, 231, 235, 0.8);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-inner {
    max-width: 960px;
    margin: 0 auto;
    padding: 0.8rem 1.2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    color: var(--primary-text);
    letter-spacing: 0.04em;
}

.brand-badge {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.9rem;
}

.nav {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 0.9rem;
}

.nav a {
    text-decoration: none;
    color: var(--text-muted);
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
}

.nav a.active,
.nav a:hover {
    background: var(--primary-soft);
    color: var(--primary-text);
}

.main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1.2rem 3rem;
}

.main-inner {
    width: 100%;
    max-width: 960px;
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1.5fr);
    gap: 1.8rem;
}

@media (max-width: 768px) {
    .main-inner {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* Cards & Typography */

.card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-soft);
    padding: 1.6rem 1.8rem;
    border: 1px solid rgba(229, 231, 235, 0.7);
}

.card-title {
    margin: 0 0 0.6rem;
    font-size: 1.3rem;
}

.card-subtitle {
    margin: 0 0 1.4rem;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-text);
    font-size: 0.75rem;
    font-weight: 600;
}

/* Formulare & Buttons */

label {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
    color: var(--text-muted);
}

.input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border-radius: 0.7rem;
    border: 1px solid var(--border-subtle);
    background: #f9fafb;
    font-size: 0.95rem;
    margin-bottom: 0.8rem;
}

.input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary-soft);
    background: #ffffff;
}

.button-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.75rem 1.6rem;
    border-radius: 999px;
    border: none;
    font-size: 0.98rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary), #1d4ed8);
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 12px 30px rgba(37, 99, 235, 0.35);
}

.button-primary:hover {
    filter: brightness(1.03);
}

.button-ghost {
    border-radius: 999px;
    border: 1px solid var(--border-subtle);
    background: #ffffff;
    padding: 0.4rem 0.9rem;
    font-size: 0.85rem;
    cursor: pointer;
}

.button-ghost:hover {
    background: #f3f4f6;
}

/* Statusanzeige */

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.85rem;
    border-radius: 999px;
    font-size: 0.82rem;
    border: 1px solid var(--border-subtle);
    background: #f9fafb;
    margin-bottom: 0.6rem;
}

.status-dot {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: #9ca3af;
}

.status-dot.live {
    background: #22c55e;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.25);
}

.status-text-main {
    font-weight: 600;
}

.status-text-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Hilfstexte */

.text-small {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.text-right {
    text-align: right;
}

.mt-s { margin-top: 0.6rem; }
.mt-m { margin-top: 1rem; }
.mt-l { margin-top: 1.6rem; }

/* Footer */

.footer {
    text-align: center;
    font-size: 0.78rem;
    padding: 0.9rem 1rem 1.4rem;
    color: #9ca3af;
}

.footer a {
    color: #6b7280;
    text-decoration: none;
    margin: 0 0.4rem;
}

.footer a:hover {
    text-decoration: underline;
}

/* ============================
   Türsteuerung – Buttons & Status
   ============================ */

/* Container für Tür-Buttons */
.door-button-group {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 1.2rem;
}

/* Basis-Türbutton: etwas massiver als Standard-CTA */
.button-door {
    width: 100%;
    justify-content: flex-start;
    gap: 0.6rem;
    border-radius: 0.9rem;
    font-weight: 600;
    box-shadow: 0 10px 20px rgba(15, 23, 42, 0.18);
}

.button-door span.label-main {
    flex: 1;
    text-align: left;
}

.button-door span.label-sub {
    font-size: 0.78rem;
    opacity: 0.85;
}

/* Aktiver Zustand (Relais aktuell geschaltet) */
.button-door.is-active {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    box-shadow: 0 16px 30px rgba(22, 163, 74, 0.45);
}

/* Während Relais aktiv: Button optisch „busy“ */
.button-door.is-active,
.button-door.is-active:disabled {
    cursor: default;
}

/* Pending-Status: Button wurde gedrückt, wartet auf Bestätigung vom Pi */
.button-door.pending {
    background: linear-gradient(135deg, #facc15, #eab308);
    box-shadow: 0 16px 30px rgba(234, 179, 8, 0.4);
}

/* Heartbeat / Online-Status oben in der Karte */
.status-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.82rem;
    margin-bottom: 0.4rem;
    color: var(--text-muted);
}

.heartbeat-dot {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: #9ca3af;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    transition: all 0.18s ease-out;
}

.heartbeat-dot.online {
    background: #22c55e;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.25);
}

.heartbeat-dot.offline {
    background: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.18);
}

.heartbeat-text {
    font-weight: 500;
}

.badge.live {
    background: rgba(34, 197, 94, 0.1);
    color: #15803d;
}

