:root {
    color-scheme: dark;
    --background-top: #1b2b44;
    --background-bottom: #111c2f;
    --glass-border: rgba(214, 228, 247, 0.12);
    --text: #edf3fb;
    --text-soft: #bdcce0;
    --text-muted: #91a5c0;
    --primary-start: #526f9f;
    --primary-end: #405d8b;
    --danger-start: #a66569;
    --danger-end: #884f57;
    --permanent-start: #568b79;
    --permanent-end: #39685b;
    --blocked-bg: rgba(137, 75, 81, 0.48);
    --blocked-border: rgba(223, 157, 162, 0.31);
    --blocked-text: #f5d9dc;
    --allowed-bg: rgba(65, 126, 108, 0.47);
    --allowed-border: rgba(143, 205, 181, 0.3);
    --allowed-text: #d5eee5;
    --warning-bg: rgba(142, 109, 65, 0.46);
    --warning-border: rgba(225, 193, 137, 0.3);
    --warning-text: #f2e4c9;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system,
        BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    color: var(--text);
    background:
        radial-gradient(ellipse 72rem 44rem at -12% -18%, rgba(103, 137, 191, 0.28), transparent 68%),
        radial-gradient(ellipse 54rem 42rem at 108% 8%, rgba(93, 153, 160, 0.17), transparent 68%),
        radial-gradient(ellipse 58rem 38rem at 52% 112%, rgba(83, 106, 158, 0.18), transparent 72%),
        linear-gradient(145deg, var(--background-top), var(--background-bottom));
    background-attachment: fixed;
}

body::before,
body::after {
    position: fixed;
    z-index: -1;
    border-radius: 50%;
    content: "";
    pointer-events: none;
}

body::before {
    top: 10%;
    left: 18%;
    width: 24rem;
    height: 24rem;
    background: rgba(126, 161, 218, 0.1);
    filter: blur(110px);
}

body::after {
    right: 6%;
    bottom: 4%;
    width: 20rem;
    height: 20rem;
    background: rgba(90, 164, 145, 0.08);
    filter: blur(100px);
}

header,
main,
footer {
    width: min(100%, 1120px);
    margin: 0 auto;
    padding-right: 30px;
    padding-left: 30px;
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding-top: 46px;
    padding-bottom: 28px;
}

header h1 {
    margin: 0;
    color: #f5f8fc;
    font-size: clamp(2.1rem, 4vw, 3.15rem);
    font-weight: 750;
    letter-spacing: -0.05em;
    line-height: 1;
    text-shadow: 0 3px 20px rgba(4, 13, 27, 0.28);
}

header p {
    margin: 10px 0 0 51px;
    color: var(--text-soft);
    font-size: 1.05rem;
    letter-spacing: 0.01em;
}

/* L’icône est sur la même ligne que le titre. */
.brand {
    min-width: 0;
}

.brand-title-row {
    display: flex;
    align-items: center;
    gap: 13px;
}

.brand-icon {
    display: block;
    flex: 0 0 auto;
    width: 70px;
    height: 70px;
    border-radius: 10px;
    object-fit: cover;
}

header a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 17px;
    border: 1px solid rgba(205, 221, 244, 0.2);
    border-radius: 12px;
    background: rgba(77, 101, 139, 0.2);
    color: #e2ebfa;
    font-weight: 650;
    text-decoration: none;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 10px 30px rgba(5, 15, 31, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    transition: background 180ms ease, border-color 180ms ease, transform 180ms ease;
}

header a:hover {
    border-color: rgba(205, 221, 244, 0.35);
    background: rgba(97, 126, 170, 0.3);
    transform: translateY(-1px);
}

main {
    display: grid;
    gap: 22px;
    padding-top: 10px;
    padding-bottom: 28px;
}

.card {
    position: relative;
    overflow: hidden;
    padding: 30px;
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    background: linear-gradient(135deg, rgba(64, 84, 116, 0.28), rgba(29, 44, 69, 0.52));
    backdrop-filter: blur(18px) saturate(108%);
    -webkit-backdrop-filter: blur(18px) saturate(108%);
    box-shadow: 0 25px 60px rgba(4, 12, 27, 0.22), 0 4px 12px rgba(4, 12, 27, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.065);
    transition: transform 220ms ease, background 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
}

.card::before {
    position: absolute;
    top: -90px;
    right: -100px;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(172, 199, 239, 0.075), transparent 70%);
    content: "";
    pointer-events: none;
}

.card:hover {
    border-color: rgba(211, 224, 243, 0.2);
    background: linear-gradient(135deg, rgba(72, 95, 130, 0.35), rgba(33, 50, 78, 0.61));
    box-shadow: 0 30px 70px rgba(4, 12, 27, 0.28), 0 5px 16px rgba(4, 12, 27, 0.11), inset 0 1px 0 rgba(255, 255, 255, 0.09);
    transform: translateY(-2px);
}

.title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
}

.title h2 {
    margin: 0;
    color: #f5f8fc;
    font-size: clamp(1.7rem, 3vw, 2.15rem);
    font-weight: 720;
    letter-spacing: -0.035em;
}

.title b {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 224px;
    min-width: 224px;
    min-height: 48px;
    padding: 10px 17px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 0.94rem;
    font-weight: 750;
    line-height: 1.15;
    text-align: center;
    white-space: nowrap;
    box-shadow: 0 10px 24px rgba(6, 15, 28, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.block {
    border-color: var(--blocked-border);
    background: linear-gradient(135deg, rgba(174, 96, 104, 0.68), var(--blocked-bg));
    color: var(--blocked-text);
}

.allow {
    border-color: var(--allowed-border);
    background: linear-gradient(135deg, rgba(83, 151, 129, 0.65), var(--allowed-bg));
    color: var(--allowed-text);
}

.warn {
    border-color: var(--warning-border);
    background: linear-gradient(135deg, rgba(172, 132, 73, 0.65), var(--warning-bg));
    color: var(--warning-text);
}

.card > p {
    margin: 26px 0 23px;
    color: var(--text-soft);
    font-size: 1.02rem;
    line-height: 1.55;
}

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

.buttons form {
    margin: 0;
}

.buttons .wide,
.buttons .permanent-form {
    grid-column: 1 / -1;
}

button {
    width: 100%;
    min-height: 48px;
    padding: 11px 12px;
    border: 1px solid rgba(206, 220, 244, 0.13);
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary-start), var(--primary-end));
    color: #f8fbff;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(10, 21, 43, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.13);
    transition: transform 160ms ease, filter 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

button:hover {
    border-color: rgba(221, 231, 248, 0.26);
    filter: brightness(1.08) saturate(1.05);
    box-shadow: 0 13px 28px rgba(10, 21, 43, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.18);
    transform: translateY(-1px);
}

button:active {
    filter: brightness(0.98);
    transform: translateY(0);
}

button.danger {
    border-color: rgba(248, 211, 215, 0.14);
    background: linear-gradient(135deg, var(--danger-start), var(--danger-end));
    box-shadow: 0 10px 22px rgba(44, 13, 18, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.11);
}

button.danger:hover {
    box-shadow: 0 13px 28px rgba(44, 13, 18, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.17);
}

button.permanent {
    border-color: rgba(173, 222, 203, 0.22);
    background: linear-gradient(135deg, var(--permanent-start), var(--permanent-end));
    color: #f2fffa;
    box-shadow: 0 10px 22px rgba(18, 66, 52, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.13);
}

button.permanent:hover {
    border-color: rgba(207, 242, 226, 0.36);
    background: linear-gradient(135deg, #63a18d, #43786a);
    box-shadow: 0 13px 28px rgba(18, 66, 52, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.error,
.ok {
    margin: 0;
    padding: 15px 18px;
    border: 1px solid transparent;
    border-radius: 14px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    line-height: 1.45;
}

.error {
    border-color: rgba(232, 151, 158, 0.31);
    background: rgba(126, 55, 63, 0.52);
    color: #f9dfe2;
}

.ok {
    border-color: rgba(131, 205, 178, 0.28);
    background: rgba(48, 111, 93, 0.5);
    color: #daf2e9;
}

.login {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

.login .card {
    width: min(435px, 100%);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 13px;
    margin-bottom: 24px;
}

.login-brand-icon {
    display: block;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 11px;
    object-fit: cover;
}

.login-brand h1 {
    margin: 0;
    font-size: 2rem;
    letter-spacing: -0.04em;
}

.login-brand p {
    margin: 7px 0 0;
    color: var(--text-soft);
}

label {
    display: block;
    margin-bottom: 8px;
    color: #e1eafa;
    font-weight: 650;
}

input {
    width: 100%;
    min-height: 48px;
    margin: 0 0 17px;
    padding: 11px 13px;
    border: 1px solid rgba(178, 198, 229, 0.22);
    border-radius: 12px;
    outline: none;
    background: rgba(12, 23, 42, 0.42);
    color: #ffffff;
    font: inherit;
    box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.13);
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:focus {
    border-color: rgba(151, 186, 240, 0.7);
    background: rgba(14, 28, 51, 0.6);
    box-shadow: 0 0 0 3px rgba(115, 157, 221, 0.17), inset 0 1px 4px rgba(0, 0, 0, 0.12);
}

footer {
    padding-bottom: 38px;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.55;
}

.loading-overlay {
    position: fixed;
    z-index: 9999;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 22px;
    opacity: 0;
    visibility: hidden;
    background: rgba(8, 15, 28, 0.48);
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
    transition: opacity 180ms ease, visibility 180ms ease;
}

.loading-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

.loading-dialog {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: min(340px, 100%);
    padding: 29px 27px;
    border: 1px solid rgba(216, 228, 246, 0.16);
    border-radius: 22px;
    background: linear-gradient(145deg, rgba(63, 83, 115, 0.86), rgba(28, 43, 68, 0.91));
    color: #eef4fd;
    text-align: center;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.loading-dialog strong {
    margin-top: 17px;
    font-size: 1.08rem;
}

.loading-dialog span {
    margin-top: 7px;
    color: #bfcee4;
    font-size: 0.91rem;
    line-height: 1.45;
}

.spinner {
    width: 42px;
    height: 42px;
    border: 4px solid rgba(214, 228, 248, 0.2);
    border-top-color: #cbdcff;
    border-radius: 50%;
    animation: pihole-panel-spin 780ms linear infinite;
}

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

button:disabled {
    cursor: wait;
    filter: saturate(0.65);
    opacity: 0.7;
}

@media (max-width: 850px) {
    .buttons {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 620px) {
    header {
        align-items: flex-start;
        flex-direction: column;
        gap: 18px;
        padding-top: 31px;
    }

    .brand-title-row {
        gap: 10px;
    }

    .brand-icon {
        width: 32px;
        height: 32px;
        border-radius: 8px;
    }

    header p {
        margin-top: 8px;
        margin-left: 42px;
    }

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

    .title b {
        width: 100%;
        min-width: 0;
    }

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

    header,
    main,
    footer {
        padding-right: 17px;
        padding-left: 17px;
    }

    .card {
        padding: 21px;
        border-radius: 19px;
    }
}

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