:root {
    --bg: #f4f7fb;
    --surface: rgba(255, 255, 255, 0.72);
    --surface-strong: rgba(255, 255, 255, 0.88);
    --glass-border: rgba(255, 255, 255, 0.62);
    --text: #101827;
    --muted: #334155;
    --border: #d9e2ec;
    --primary: #0b63f3;
    --primary-contrast: #ffffff;
    --accent: #0ea5a4;
    --ok: #067647;
    --bad: #b42318;
    --neutral: #475467;
    --focus: #ff8a00;
    --shadow: 0 10px 30px rgba(8, 15, 34, 0.12);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
    margin: 0;
    font-family: "Atkinson Hyperlegible", "Segoe UI", sans-serif;
    color: var(--text);
    line-height: 1.45;
    background:
        radial-gradient(circle at 15% 10%, rgba(11, 99, 243, 0.16), transparent 30%),
        radial-gradient(circle at 85% 15%, rgba(14, 165, 164, 0.15), transparent 32%),
        var(--bg);
}

a { color: var(--text); text-decoration: none; }
h1, h2, h3 { margin-top: 0; letter-spacing: 0.2px; }
p, .muted { color: var(--muted); }

.guest-container {
    width: min(560px, 92%);
    margin: 5vh auto;
}

.app-shell {
    display: grid;
    grid-template-columns: 290px 1fr;
    gap: 1.2rem;
    width: min(1500px, 98%);
    margin: 1rem auto;
}

.sidebar {
    position: sticky;
    top: 1rem;
    height: calc(100vh - 2rem);
    padding: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.brand-block {
    padding: 0.9rem;
    border-radius: 16px;
    background: var(--surface-strong);
    border: 1px solid var(--glass-border);
}
.brand { font-size: 1.35rem; font-weight: 900; }
.role { color: var(--accent); font-weight: 700; }

.side-nav {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.side-nav a {
    padding: 0.8rem 0.9rem;
    border-radius: 12px;
    border: 1px solid transparent;
    font-weight: 700;
    color: #0f172a;
    background: rgba(255, 255, 255, 0.35);
    transition: all .2s ease;
}

.side-nav a:hover,
.side-nav a.active {
    border-color: #dbeafe;
    background: #ffffff;
    box-shadow: 0 8px 20px rgba(10, 46, 120, 0.12);
}

.side-nav a.logout {
    margin-top: 0.8rem;
    color: var(--bad);
    border-color: rgba(180, 35, 24, 0.25);
    background: rgba(255, 255, 255, 0.95);
}

.content-area {
    padding: 0.2rem;
}

.card {
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}

.glass {
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    background: var(--surface);
    border: 1px solid var(--glass-border);
}

.title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.7rem;
    flex-wrap: wrap;
}

.grid {
    display: grid;
    gap: 0.9rem;
}
.two-cols {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.full { grid-column: 1 / -1; }

label { display: grid; gap: 0.35rem; font-weight: 700; color: #0f172a; }

input, select, button, textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 0.8rem 0.9rem;
    font: inherit;
    color: #0f172a;
    background: rgba(255, 255, 255, 0.95);
}
textarea { resize: vertical; min-height: 90px; }

button, .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-height: 46px;
    padding: 0.8rem 1.15rem;
    border-radius: 12px;
    border: 1px solid transparent;
    background: linear-gradient(180deg, #1674ff 0%, #0b63f3 100%);
    color: var(--primary-contrast);
    font-weight: 800;
    letter-spacing: 0.2px;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(11, 99, 243, 0.28);
}

.btn.alt {
    background: #ffffff;
    color: #0f172a;
    border: 1px solid #cbd5e1;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}

.btn.small {
    min-height: 36px;
    padding: 0.5rem 0.8rem;
    font-size: 0.9rem;
}

.card-btn {
    width: 100%;
    min-height: 58px;
    border-radius: 14px;
    font-size: 1rem;
}

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

button:focus,
input:focus,
select:focus,
textarea:focus,
a:focus {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}
.kpis.spaced { margin-bottom: 1.2rem; }
.kpi {
    padding: 1rem;
    border-radius: 16px;
}
.kpi span { color: #1e293b; font-weight: 700; }
.kpi strong {
    display: block;
    margin-top: 0.25rem;
    font-size: clamp(1.7rem, 2vw, 2rem);
}

.quick-grid {
    display: grid;
    gap: 0.9rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    margin-top: 0.8rem;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 0.8rem;
    overflow: hidden;
}
th, td {
    border-bottom: 1px solid #dbe5f0;
    padding: 0.75rem 0.65rem;
    text-align: left;
    vertical-align: middle;
}
th {
    background: rgba(255, 255, 255, 0.84);
    color: #0b1f3b;
    font-size: 0.93rem;
}
tr:hover td { background: rgba(255, 255, 255, 0.82); }

.status {
    display: inline-block;
    padding: 0.28rem 0.65rem;
    border-radius: 10px;
    color: #fff;
    font-weight: 800;
    text-transform: capitalize;
}
.status.ok { background: var(--ok); }
.status.bad { background: var(--bad); }
.status.neutral { background: var(--neutral); }

.alert {
    border-radius: 12px;
    padding: 0.75rem 0.9rem;
    font-weight: 700;
    margin-bottom: 1rem;
}
.alert.ok {
    color: #065f46;
    background: #ecfdf3;
    border: 1px solid #84e1bc;
}
.alert.error {
    color: #912018;
    background: #fef3f2;
    border: 1px solid #fecdca;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem;
    align-items: end;
    margin-bottom: 1rem;
}

.modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 1000;
}
.modal[aria-hidden="false"] {
    display: flex;
}
.modal[hidden] {
    display: none !important;
}
.modal-card {
    position: relative;
    width: min(900px, 96vw);
    max-height: 90vh;
    overflow: auto;
    border-radius: 20px;
    padding: 1rem;
    box-shadow: 0 15px 35px rgba(2, 6, 23, 0.35);
}

.close-x {
    min-height: 36px;
    min-width: 36px;
    width: 36px;
    padding: 0;
    border-radius: 999px;
    font-size: 1.2rem;
    line-height: 1;
}

@media (max-width: 1080px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
    }

    .side-nav {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    }
}

@media (max-width: 760px) {
    .two-cols {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 1rem;
    }

    .side-nav {
        grid-template-columns: 1fr 1fr;
    }

    .actions {
        flex-direction: column;
        align-items: stretch;
    }

    .modal-card {
        width: 100%;
    }
}
