:root {
    --ac-color: #f8f9fa;
    --pcd-color: #d1e7dd;
    --ppp-color: #cff4fc;
    --pin-color: #fff3cd;
    --pqu-color: #e2e3e5;
    --transf-color: #f8d7da;
    --none-color: #f1f3f5;
    --ink: #17212b;
    --text: var(--ink);
    --muted: #64748b;
    --line: rgba(23, 33, 43, 0.12);
    --border: var(--line);
    --panel: rgba(255, 255, 255, 0.92);
    --primary: #0f766e;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    padding: 28px;
    color: var(--ink);
    background:
        radial-gradient(circle at top left, rgba(15, 118, 110, 0.16), transparent 34rem),
        linear-gradient(135deg, #eef5f2 0%, #f8fafc 48%, #eef2f7 100%);
    font-family: 'Aptos', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.container {
    max-width: 1360px;
    margin: 0 auto;
    padding: 28px;
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.82);
    border-radius: 24px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.12);
    backdrop-filter: blur(16px);
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    margin: -12px -12px 24px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.78);
    border-radius: 20px;
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(18px);
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    color: var(--ink);
    font-size: clamp(2rem, 4vw, 3.2rem);
    line-height: 0.95;
    letter-spacing: -0.05em;
    text-align: left;
}

.app-subtitle,
.subtitle {
    max-width: 720px;
    margin: 12px 0 0;
    color: var(--muted);
    font-size: 1rem;
    text-align: left;
}

.app-nav {
    display: flex;
    gap: 8px;
    padding: 6px;
    background: rgba(15, 23, 42, 0.06);
    border: 1px solid var(--line);
    border-radius: 999px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.72);
    white-space: nowrap;
}

.nav-link {
    padding: 10px 16px;
    color: #334155;
    border-radius: 999px;
    font-size: 0.95rem;
    font-weight: 800;
    text-decoration: none;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.nav-link:hover {
    background: rgba(255,255,255,0.82);
    transform: translateY(-1px);
}

.nav-link.active {
    color: #fff;
    background: var(--ink);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.16);
}

.controls,
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
    padding: 16px;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}

.control-field {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.controls label,
.toolbar label {
    color: #334155;
    font-size: 0.95rem;
    font-weight: 800;
}

.controls input,
.toolbar input[type="text"] {
    padding: 11px 12px;
    color: var(--ink);
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.06);
    font-size: 1rem;
}

.controls input {
    width: 120px;
    font-weight: 800;
    text-align: center;
}

.controls input[type="text"] {
    width: min(320px, 100%);
    min-width: min(260px, 100%);
    font-weight: 700;
    text-align: left;
}

.toolbar input[type="text"] {
    min-width: min(320px, 100%);
}

.controls button,
.toolbar button,
.button-primary {
    padding: 12px 24px;
    color: white;
    background: linear-gradient(135deg, var(--primary), #0f4f49);
    border: none;
    border-radius: 999px;
    box-shadow: 0 14px 26px rgba(15, 118, 110, 0.24);
    cursor: pointer;
    font-size: 0.98rem;
    font-weight: 900;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.controls button:hover,
.toolbar button:hover,
.button-primary:hover {
    box-shadow: 0 18px 34px rgba(15, 118, 110, 0.28);
    transform: translateY(-1px);
}

.dashboard,
.summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 15px;
    margin-bottom: 24px;
}

.card {
    min-width: 0;
    padding: 16px;
    overflow: hidden;
    text-align: center;
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.1);
    border-radius: 18px;
    box-shadow: 0 12px 26px rgba(15, 23, 42, 0.07);
    font-weight: 800;
}

.card.total { background: linear-gradient(135deg, #e0f2fe, #f8fafc); }
.card.ac { background-color: var(--ac-color); }
.card.pcd { background-color: var(--pcd-color); }
.card.ppp { background-color: var(--ppp-color); }
.card.pin { background-color: var(--pin-color); }
.card.pqu { background-color: var(--pqu-color); }

.card span {
    display: block;
    margin-top: 8px;
    color: var(--ink);
    font-size: 2.2rem;
    letter-spacing: -0.04em;
}

.card small {
    display: block;
    margin-top: 4px;
    color: #475569;
    font-size: 0.85em;
    font-weight: 700;
}

.table-shell {
    max-height: calc(100vh - 32px);
    overflow: auto;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.08);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
}

th,
td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

th {
    position: sticky;
    top: 0;
    z-index: 1;
    color: white;
    background: #17212b;
    font-size: 0.82rem;
    letter-spacing: 0.02em;
}

.status {
    margin: 0 0 16px;
    padding: 12px 14px;
    color: var(--muted);
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.small {
    color: var(--muted);
    font-size: 0.88rem;
}

.section-heading {
    margin: 28px 0 12px;
}

.section-heading h2 {
    margin: 0;
    color: var(--ink);
    font-size: 1.15rem;
    letter-spacing: -0.02em;
}

.section-heading p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.row-desistente {
    opacity: 0.58;
}

.row-desistente td {
    text-decoration: line-through;
    text-decoration-thickness: 1.5px;
}

.row-substituto {
    box-shadow: inset 4px 0 0 rgba(15, 118, 110, 0.55);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 8px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 900;
    vertical-align: middle;
}

.status-badge.desistente {
    color: #7f1d1d;
    background: #fee2e2;
    border: 1px solid #fecaca;
}

.status-badge.substituto {
    color: #065f46;
    background: #d1fae5;
    border: 1px solid #a7f3d0;
}

.check-cell {
    width: 92px;
    text-align: center;
}

.check-desistente {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.app-loader {
    position: fixed;
    inset: 0;
    z-index: 999;
    display: grid;
    place-items: center;
    background: rgba(248, 250, 252, 0.68);
    backdrop-filter: blur(8px);
}

.app-loader[hidden] {
    display: none;
}

.loader-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.18);
    font-weight: 900;
}

.loader-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid rgba(15, 118, 110, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

@media (max-width: 760px) {
    body {
        padding: 14px;
    }

    .container {
        padding: 18px;
        border-radius: 18px;
    }

    .app-header,
    .controls,
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .app-nav {
        justify-content: center;
        width: 100%;
    }

    .nav-link {
        flex: 1;
        text-align: center;
    }

    .controls button,
    .toolbar button,
    .button-primary {
        width: 100%;
    }
}
