:root {
    --bg-1: #09131f;
    --bg-2: #10263e;
    --bg-3: #183b57;
    --ink: #eaf5ff;
    --muted: #b8d3e5;
    --card: rgba(255, 255, 255, 0.12);
    --card-strong: rgba(255, 255, 255, 0.2);
    --line: rgba(255, 255, 255, 0.24);
    --accent: #16c7c1;
    --accent-soft: rgba(22, 199, 193, 0.18);
    --warning: #ff6b7e;
    --ok: #54d0a5;
}

body[data-theme='gold'] {
    --bg-1: #1a1207;
    --bg-2: #2f1d0f;
    --bg-3: #51341a;
    --ink: #fff5de;
    --muted: #f2dcb8;
    --line: rgba(255, 226, 171, 0.3);
    --accent: #ffc56b;
    --accent-soft: rgba(255, 197, 107, 0.2);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Space Grotesk', sans-serif;
    color: var(--ink);
    background:
        radial-gradient(70rem 42rem at 8% -12%, rgba(48, 170, 255, 0.24), transparent 60%),
        radial-gradient(62rem 34rem at 106% -16%, rgba(40, 212, 191, 0.22), transparent 64%),
        linear-gradient(140deg, var(--bg-1) 0%, var(--bg-2) 54%, var(--bg-3) 100%);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

body::before,
body::after {
    content: '';
    position: fixed;
    width: 22rem;
    aspect-ratio: 1;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    filter: blur(1px);
}

body::before {
    left: -7rem;
    bottom: -7rem;
    background: radial-gradient(circle, rgba(22, 199, 193, 0.28) 0%, rgba(22, 199, 193, 0.03) 68%, transparent 78%);
}

body::after {
    right: -8rem;
    top: 4rem;
    background: radial-gradient(circle, rgba(111, 173, 255, 0.24) 0%, rgba(111, 173, 255, 0.03) 70%, transparent 78%);
}

h1,
h2,
h3 {
    font-family: 'Fraunces', serif;
    margin: 0;
}

.pill {
    display: inline-block;
    background: linear-gradient(120deg, rgba(22, 199, 193, 0.34), rgba(111, 173, 255, 0.28));
    color: #ebffff;
    padding: 0.28rem 0.78rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    margin: 0 0 0.4rem;
    border: 1px solid rgba(255, 255, 255, 0.28);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 1rem 1.4rem;
    margin: 1rem 1.5rem 0.4rem;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: linear-gradient(155deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.08));
    backdrop-filter: blur(18px) saturate(145%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.22),
        0 20px 44px rgba(1, 8, 16, 0.38);
    position: relative;
    z-index: 1;
}

.topbar-right {
    text-align: right;
}

.top-controls {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.45rem;
    margin-bottom: 0.35rem;
}

.top-control-label {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.top-select {
    min-width: 9.1rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    background: rgba(10, 27, 44, 0.55);
    color: var(--ink);
    padding: 0.44rem 0.55rem;
}

.clock {
    font-size: 1.45rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: 0.04em;
}

.date,
.muted {
    color: var(--muted);
    margin: 0.2rem 0;
}

.logout-link {
    color: var(--warning);
    text-decoration: none;
    font-weight: 700;
    transition: opacity 160ms ease;
}

.logout-link:hover {
    opacity: 0.78;
}

.grid {
    padding: 0.5rem 1.5rem 1.8rem;
    display: grid;
    gap: 0.9rem;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    position: relative;
    z-index: 1;
}

.flash {
    margin: 0.55rem 1.5rem 0;
    border-radius: 14px;
    padding: 0.62rem 0.9rem;
    border: 1px solid;
    font-weight: 500;
    backdrop-filter: blur(10px) saturate(130%);
    position: relative;
    z-index: 1;
}

.flash-success {
    border-color: rgba(84, 208, 165, 0.5);
    color: #cffde9;
    background: rgba(84, 208, 165, 0.12);
}

.flash-error {
    border-color: rgba(255, 107, 126, 0.5);
    color: #ffd8de;
    background: rgba(255, 107, 126, 0.14);
}

.card {
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.17), rgba(255, 255, 255, 0.08));
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 1rem;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.18),
        0 18px 36px rgba(3, 10, 19, 0.3);
    backdrop-filter: blur(16px) saturate(140%);
    animation: cardIn 620ms cubic-bezier(0.2, 0.78, 0.2, 1) both;
}

.card:nth-child(1) { animation-delay: 40ms; }
.card:nth-child(2) { animation-delay: 90ms; }
.card:nth-child(3) { animation-delay: 130ms; }
.card:nth-child(4) { animation-delay: 180ms; }
.card:nth-child(5) { animation-delay: 220ms; }
.card:nth-child(6) { animation-delay: 260ms; }
.card:nth-child(7) { animation-delay: 300ms; }

@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.card-mail { grid-column: span 6; }
.card-connectors { grid-column: span 6; }
.card-otp { grid-column: span 3; }
.card-weather { grid-column: span 3; }
.card-invoices { grid-column: span 6; }
.card-snelstart { grid-column: span 3; }
.card-assistant { grid-column: span 3; }

.connector-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.6rem;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.connector-row:last-child {
    border-bottom: 0;
}

.status-pill {
    border-radius: 999px;
    padding: 0.15rem 0.6rem;
    font-size: 0.8rem;
    font-weight: 700;
}

.status-pill.ok {
    color: #d4ffeb;
    background: rgba(84, 208, 165, 0.2);
    border: 1px solid rgba(84, 208, 165, 0.45);
}

.status-pill.off {
    color: #ffe8cf;
    background: rgba(245, 158, 11, 0.2);
    border: 1px solid rgba(245, 158, 11, 0.4);
}

.mini-btn {
    text-decoration: none;
    background: linear-gradient(145deg, #0fb6af, #1581d7);
    color: #fff;
    border-radius: 10px;
    padding: 0.38rem 0.62rem;
    font-size: 0.8rem;
    font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.24);
    box-shadow: 0 6px 16px rgba(8, 24, 43, 0.3);
}

.mini-btn.warn {
    background: linear-gradient(145deg, #dc3557, #b91c1c);
}

.kpis {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.8rem;
    margin-top: 0.8rem;
}

.kpis article {
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.08));
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 0.6rem;
}

.kpis h3 {
    color: var(--muted);
    font-size: 0.96rem;
}

.kpis strong {
    font-size: 1.4rem;
}

.automation-box {
    margin-top: 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 12px;
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.06));
    padding: 0.6rem 0.7rem;
}

.automation-box p {
    margin: 0.16rem 0;
}

.otp-source {
    margin: 0.8rem 0 0.4rem;
    color: var(--muted);
}

.otp-code {
    font-size: clamp(1.6rem, 3vw, 2.1rem);
    letter-spacing: 0.2rem;
    margin: 0;
}

.weather-temp {
    font-size: clamp(1.6rem, 3.1vw, 2.1rem);
    margin: 0.6rem 0;
}

.weather-scene {
    position: relative;
    height: 120px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    overflow: hidden;
    background: linear-gradient(180deg, rgba(135, 201, 255, 0.35), rgba(29, 67, 101, 0.35));
    margin-bottom: 0.7rem;
}

.weather-scene .sky-glow,
.weather-scene .sun,
.weather-scene .moon,
.weather-scene .cloud,
.weather-scene .rain {
    position: absolute;
}

.weather-scene .sky-glow {
    inset: 0;
    background: radial-gradient(circle at 78% 20%, rgba(255, 239, 170, 0.6), transparent 46%);
}

.weather-scene .sun,
.weather-scene .moon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    right: 16px;
    top: 12px;
}

.weather-scene .sun {
    background: radial-gradient(circle at 35% 35%, #fff7cf 0%, #ffe083 55%, #f8b84e 100%);
    box-shadow: 0 0 22px rgba(255, 214, 126, 0.62);
}

.weather-scene .moon {
    background: radial-gradient(circle at 35% 35%, #f8fbff 0%, #d0e3ff 65%, #9ab9e7 100%);
    box-shadow: 0 0 16px rgba(180, 207, 255, 0.56);
    opacity: 0;
}

.weather-scene .cloud {
    width: 68px;
    height: 26px;
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(238, 247, 255, 0.95), rgba(184, 208, 232, 0.95));
    top: 40px;
}

.weather-scene .cloud::before,
.weather-scene .cloud::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: inherit;
}

.weather-scene .cloud::before {
    width: 22px;
    height: 22px;
    left: 10px;
    top: -10px;
}

.weather-scene .cloud::after {
    width: 30px;
    height: 30px;
    right: 8px;
    top: -14px;
}

.weather-scene .cloud-front {
    left: 15px;
    animation: cloudDrift 7s ease-in-out infinite;
}

.weather-scene .cloud-back {
    left: 45px;
    top: 30px;
    transform: scale(0.8);
    opacity: 0.88;
    animation: cloudDrift 9s ease-in-out infinite reverse;
}

.weather-scene .rain {
    width: 2px;
    height: 12px;
    border-radius: 2px;
    background: linear-gradient(180deg, rgba(200, 233, 255, 0.9), rgba(104, 179, 255, 0.8));
    top: 72px;
    opacity: 0;
    animation: rainDrop 1s linear infinite;
}

.weather-scene .rain-a { left: 30px; }
.weather-scene .rain-b { left: 46px; animation-delay: 220ms; }
.weather-scene .rain-c { left: 62px; animation-delay: 380ms; }

@keyframes cloudDrift {
    0% { transform: translateX(0); }
    50% { transform: translateX(7px); }
    100% { transform: translateX(0); }
}

@keyframes rainDrop {
    0% { transform: translateY(0); opacity: 0; }
    35% { opacity: 1; }
    100% { transform: translateY(19px); opacity: 0; }
}

.weather-scene.state-day-clear .moon,
.weather-scene.state-day-sun-rain .moon,
.weather-scene.state-day-rain .moon,
.weather-scene.state-day-cloudy .moon,
.weather-scene.state-dusk .moon,
.weather-scene.state-dusk-rain .moon {
    opacity: 0;
}

.weather-scene.state-night-clear .sun,
.weather-scene.state-night-rain .sun {
    opacity: 0;
}

.weather-scene.state-night-clear .moon,
.weather-scene.state-night-rain .moon {
    opacity: 1;
}

.weather-scene.state-day-clear .cloud,
.weather-scene.state-night-clear .cloud,
.weather-scene.state-dusk .cloud {
    opacity: 0;
}

.weather-scene.state-day-rain .sun,
.weather-scene.state-night-rain .sun,
.weather-scene.state-dusk-rain .sun {
    opacity: 0;
}

.weather-scene.state-day-rain .rain,
.weather-scene.state-day-sun-rain .rain,
.weather-scene.state-night-rain .rain,
.weather-scene.state-dusk-rain .rain {
    opacity: 1;
}

.weather-scene.state-night-clear,
.weather-scene.state-night-rain {
    background: linear-gradient(180deg, rgba(35, 60, 99, 0.7), rgba(13, 29, 56, 0.68));
}

.weather-scene.state-dusk,
.weather-scene.state-dusk-rain {
    background: linear-gradient(180deg, rgba(248, 177, 122, 0.52), rgba(88, 66, 110, 0.56));
}

.weather-scene.state-dusk .sun,
.weather-scene.state-dusk-rain .sun {
    top: 18px;
    right: 14px;
    filter: saturate(0.9);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.8rem;
}

th,
td {
    text-align: left;
    padding: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

th {
    color: var(--muted);
    font-weight: 600;
}

.assistant-log {
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.04));
    border-radius: 10px;
    min-height: 120px;
    max-height: 240px;
    overflow-y: auto;
    padding: 0.6rem;
    margin: 0.8rem 0;
    font-size: 0.95rem;
}

.assistant-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
}

.ai-health {
    display: inline-block;
    margin: 0.2rem 0 0.5rem;
    padding: 0.28rem 0.56rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 0.8rem;
    font-weight: 700;
}

.ai-health.status-ok {
    color: #d4ffeb;
    background: rgba(84, 208, 165, 0.2);
    border-color: rgba(84, 208, 165, 0.42);
}

.ai-health.status-warning {
    color: #ffe8cf;
    background: rgba(245, 158, 11, 0.2);
    border-color: rgba(245, 158, 11, 0.42);
}

.ai-health.status-error {
    color: #ffd8de;
    background: rgba(255, 107, 126, 0.2);
    border-color: rgba(255, 107, 126, 0.42);
}

.settings-wrap {
    position: relative;
    z-index: 1;
    padding: 0.5rem 1.5rem 1.8rem;
}

.settings-card {
    max-width: 880px;
    margin: 0 auto;
}

.settings-form {
    display: grid;
    gap: 0.9rem;
    margin-top: 0.9rem;
}

.settings-form label {
    display: grid;
    gap: 0.45rem;
    font-weight: 500;
}

.check-row {
    display: flex !important;
    align-items: center;
    gap: 0.55rem;
}

textarea {
    font: inherit;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(10, 27, 44, 0.58);
    color: var(--ink);
    padding: 0.65rem 0.75rem;
    resize: vertical;
}

.settings-actions {
    display: flex;
    gap: 0.55rem;
    align-items: center;
}

.voice-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    margin: 0.6rem 0;
    flex-wrap: wrap;
}

.voice-buttons {
    display: flex;
    gap: 0.4rem;
}

#wake-status.listening {
    color: #b9ffe1;
    font-weight: 700;
}

input,
button {
    font: inherit;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    padding: 0.55rem 0.75rem;
}

button {
    background: linear-gradient(145deg, #0fb6af, #1581d7);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.28);
    cursor: pointer;
    font-weight: 700;
    box-shadow: 0 10px 22px rgba(8, 24, 43, 0.3);
    transition: transform 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 24px rgba(8, 24, 43, 0.35);
}

button:active {
    transform: translateY(0);
}

input {
    background: rgba(10, 27, 44, 0.58);
    color: var(--ink);
}

input::placeholder {
    color: rgba(213, 234, 247, 0.7);
}

.login-body {
    display: grid;
    place-items: center;
    padding: 1.4rem;
}

body[data-focus='compact'] .card-secondary {
    display: none;
}

.login-card {
    max-width: 460px;
    width: 100%;
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.08));
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 22px;
    padding: 1.3rem;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.18),
        0 20px 42px rgba(3, 10, 19, 0.36);
    backdrop-filter: blur(16px);
}

.login-form {
    display: grid;
    gap: 0.8rem;
    margin: 1rem 0;
}

.login-form label {
    display: grid;
    gap: 0.4rem;
    font-weight: 500;
}

.error-box {
    background: rgba(255, 107, 126, 0.18);
    border: 1px solid rgba(255, 107, 126, 0.42);
    color: #ffd9de;
    border-radius: 10px;
    padding: 0.6rem;
    margin: 0.8rem 0;
}

@media (max-width: 980px) {
    .topbar,
    .grid,
    .flash {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .topbar,
    .flash {
        margin-left: 1rem;
        margin-right: 1rem;
    }

    .topbar {
        flex-direction: column;
        gap: 0.8rem;
        padding: 0.9rem 1rem;
    }

    .topbar-right {
        text-align: left;
    }

    .top-controls {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .grid {
        gap: 0.75rem;
        padding-top: 0.7rem;
    }

    .card-mail,
    .card-connectors,
    .card-otp,
    .card-weather,
    .card-invoices,
    .card-snelstart,
    .card-assistant {
        grid-column: span 12;
    }

    .kpis {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    .kpis {
        grid-template-columns: 1fr;
    }

    .connector-row {
        grid-template-columns: 1fr;
        align-items: flex-start;
        gap: 0.4rem;
    }

    .assistant-form {
        grid-template-columns: 1fr;
    }

    .voice-buttons {
        width: 100%;
    }

    .voice-buttons button {
        flex: 1;
    }

    .top-select {
        min-width: 100%;
    }

    .otp-code {
        letter-spacing: 0.14rem;
    }

    .settings-wrap {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .settings-actions {
        flex-direction: column;
        align-items: stretch;
    }
}
