:root {
    --nav: #0f1b2d;
    --nav-hover: #19283d;
    --primary: #3e5fe7;
    --primary-hover: #314fd0;
    --background: #f5f7fb;
    --surface: #ffffff;
    --border: #dde4ee;
    --text: #182230;
    --muted: #667085;
    --success: #18875b;
    --danger: #c43b3b;
    --radius: 14px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    color: var(--text);
    background: var(--background);
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.hidden {
    display: none !important;
}


/* LOGIN */

.login-page {
    min-height: 100vh;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 30px;

    background:
        radial-gradient(
            circle at top left,
            #edf4ff,
            transparent 45%
        ),
        #f5f7fb;
}

.login-card {
    width: 100%;
    max-width: 430px;

    padding: 36px;

    background: #fff;

    border:
        1px solid var(--border);

    border-radius: 20px;

    box-shadow:
        0 20px 60px
        rgba(15, 23, 42, 0.10);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;

    margin-bottom: 34px;
}

.brand-mark {
    width: 48px;
    height: 48px;

    display: flex;
    align-items: center;
    justify-content: center;

    flex: 0 0 auto;

    border-radius: 14px;

    background: var(--primary);

    color: #fff;

    font-size: 24px;
    font-weight: 800;
}

.brand-mark.small {
    width: 38px;
    height: 38px;

    border-radius: 11px;

    font-size: 18px;
}

.login-brand strong {
    display: block;

    font-size: 21px;
}

.login-brand span {
    display: block;

    margin-top: 3px;

    color: var(--muted);

    font-size: 13px;
}

.login-copy h1 {
    margin:
        0
        0
        8px;

    font-size: 25px;
}

.login-copy p {
    margin:
        0
        0
        28px;

    color: var(--muted);

    font-size: 14px;
    line-height: 1.5;
}

#login-form {
    display: flex;
    flex-direction: column;
}

#login-form label {
    margin:
        0
        0
        7px;

    font-size: 13px;
    font-weight: 650;
}

#login-form input {
    width: 100%;
    height: 45px;

    margin-bottom: 17px;

    padding:
        0
        13px;

    border:
        1px solid #d3dbe7;

    border-radius: 9px;

    outline: none;
}

#login-form input:focus {
    border-color: #6d8aed;

    box-shadow:
        0 0 0 3px
        rgba(62, 95, 231, 0.10);
}

.primary-button {
    border: 0;

    border-radius: 9px;

    background: var(--primary);

    color: #fff;

    font-weight: 700;
}

.primary-button:hover {
    background: var(--primary-hover);
}

.login-button {
    min-height: 45px;

    margin-top: 6px;
}

.login-button:disabled {
    opacity: .65;
    cursor: wait;
}

.login-error {
    margin-bottom: 14px;

    padding:
        10px
        12px;

    border:
        1px solid #efb8b8;

    border-radius: 8px;

    background: #fff2f2;

    color: #a82c2c;

    font-size: 13px;
}


/* APP */

.app-layout {
    min-height: 100vh;

    display: grid;

    grid-template-columns:
        220px
        minmax(0, 1fr);
}

.sidebar {
    position: fixed;

    inset:
        0
        auto
        0
        0;

    width: 220px;

    display: flex;
    flex-direction: column;

    padding: 18px 14px;

    background: var(--nav);

    color: #fff;

    z-index: 1000;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 11px;

    padding:
        2px
        4px
        20px;
}

.sidebar-brand-copy strong {
    display: block;

    font-size: 18px;
}

.sidebar-brand-copy span {
    display: block;

    margin-top: 2px;

    color: #98a5b8;

    font-size: 11px;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.nav-item {
    width: 100%;
    min-height: 44px;

    display: flex;
    align-items: center;
    gap: 12px;

    padding:
        0
        13px;

    border: 0;
    border-radius: 9px;

    background: transparent;

    color: #ccd4df;

    text-align: left;
}

.nav-item:hover {
    background: var(--nav-hover);
}

.nav-item.active {
    background: var(--primary);

    color: #fff;
}

.nav-icon {
    width: 18px;

    text-align: center;
}

.sidebar-bottom {
    margin-top: auto;

    padding:
        16px
        5px
        3px;

    border-top:
        1px solid
        rgba(255,255,255,.08);
}

.sidebar-user-name {
    color: #fff;

    font-size: 13px;
    font-weight: 650;
}

.sidebar-user-email {
    margin-top: 3px;

    color: #98a5b8;

    font-size: 11px;

    overflow: hidden;

    text-overflow: ellipsis;
}

.logout-button {
    margin-top: 14px;

    padding: 0;

    border: 0;

    background: none;

    color: #b9c3d1;
}

.logout-button:hover {
    color: #fff;
}


/* CONTEÚDO */

.main-content {
    grid-column: 2;

    min-width: 0;

    padding:
        0
        22px
        32px;
}

.topbar {
    min-height: 88px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 20px;
}

.topbar h1 {
    margin: 0;

    font-size: 24px;
}

.topbar p {
    margin:
        4px
        0
        0;

    color: var(--muted);

    font-size: 13px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 18px;
}

.company-field label {
    display: block;

    margin-bottom: 4px;

    color: var(--muted);

    font-size: 10px;
    font-weight: 700;

    text-transform: uppercase;
}

.company-field select {
    min-width: 190px;

    height: 38px;

    padding:
        0
        10px;

    border:
        1px solid var(--border);

    border-radius: 8px;

    background: #fff;
}

.topbar-user {
    text-align: right;
}

.topbar-user strong {
    display: block;

    font-size: 13px;
}

.topbar-user span {
    display: block;

    margin-top: 3px;

    color: var(--muted);

    font-size: 11px;
}

.page-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.welcome-panel,
.panel {
    background: var(--surface);

    border:
        1px solid var(--border);

    border-radius: var(--radius);
}

.welcome-panel {
    padding:
        25px
        28px;
}

.eyebrow {
    display: block;

    margin-bottom: 5px;

    color: var(--primary);

    font-size: 10px;
    font-weight: 800;

    letter-spacing: .08em;
}

.welcome-panel h2,
.panel h2 {
    margin:
        0
        0
        6px;

    font-size: 20px;
}

.welcome-panel p,
.panel-header p {
    margin: 0;

    color: var(--muted);

    font-size: 13px;
}

.metric-grid {
    display: grid;

    grid-template-columns:
        repeat(
            3,
            minmax(0, 1fr)
        );

    gap: 12px;
}

.metric-card {
    padding: 18px;

    border:
        1px solid var(--border);

    border-radius: 12px;

    background: var(--surface);
}

.metric-card span {
    display: block;

    color: var(--muted);

    font-size: 11px;
}

.metric-card strong {
    display: block;

    margin:
        6px
        0
        3px;

    font-size: 24px;
}

.metric-card small {
    color: #8b97a8;

    font-size: 10px;
}

.panel {
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 20px;

    padding:
        20px
        22px;

    border-bottom:
        1px solid #edf0f5;
}

.history-controls {
    display: flex;
    gap: 8px;
}

.history-controls input,
.history-controls select {
    height: 38px;

    border:
        1px solid var(--border);

    border-radius: 8px;

    background: #fff;

    padding:
        0
        10px;
}

.history-controls input {
    width: 260px;
}

.empty-state {
    padding:
        55px
        25px;

    color: var(--muted);

    text-align: center;

    font-size: 13px;
}


/* MOBILE */

@media (max-width: 900px) {

    .app-layout {
        display: block;
    }

    .sidebar {
        position: static;

        width: 100%;
        height: auto;

        flex-direction: row;
        align-items: center;

        overflow-x: auto;
    }

    .sidebar-brand-copy,
    .sidebar-bottom {
        display: none;
    }

    .sidebar nav {
        flex-direction: row;
    }

    .nav-item {
        width: auto;

        white-space: nowrap;
    }

    .main-content {
        padding:
            0
            14px
            25px;
    }

    .topbar,
    .panel-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .metric-grid {
        grid-template-columns: 1fr;
    }

    .history-controls {
        width: 100%;

        flex-direction: column;
    }

    .history-controls input,
    .history-controls select {
        width: 100%;
    }
}


/* =========================================================
   RESULTADOS
   ========================================================= */

.results-controls {
    display: flex;
    gap: 8px;
}

.results-controls input,
.results-controls select {
    height: 38px;

    padding:
        0
        10px;

    border:
        1px solid var(--border);

    border-radius: 8px;

    background: #fff;
}

.results-controls input {
    width: 260px;
}

.results-table-area {
    width: 100%;
    overflow-x: auto;
}

.results-table {
    width: 100%;

    border-collapse: collapse;

    font-size: 12px;
}

.results-table th {
    padding:
        11px
        14px;

    background: #f5f7fb;

    color: #526071;

    font-size: 10px;
    font-weight: 800;

    text-align: left;

    white-space: nowrap;
}

.results-table td {
    padding:
        13px
        14px;

    border-top:
        1px solid #edf0f5;

    vertical-align: middle;
}

.results-table tbody tr:hover {
    background: #fafbfe;
}

.result-name {
    display: block;

    color: var(--text);

    font-weight: 700;
}

.result-id {
    display: block;

    margin-top: 3px;

    color: #8a96a7;

    font-size: 10px;
}

.result-date {
    white-space: nowrap;
}

.status-chip {
    display: inline-flex;
    align-items: center;

    padding:
        4px
        8px;

    border-radius: 999px;

    background: #eaf8f1;

    color: #16794f;

    font-size: 10px;
    font-weight: 750;
}

.history-chip {
    display: inline-flex;

    padding:
        4px
        8px;

    border-radius: 999px;

    font-size: 10px;
    font-weight: 700;
}

.history-chip.complete {
    background: #eaf8f1;
    color: #16794f;
}

.history-chip.partial {
    background: #fff5df;
    color: #9a6712;
}

.history-chip.legacy {
    background: #f0f2f5;
    color: #697586;
}

.result-open-button,
.secondary-action {
    min-height: 34px;

    padding:
        0
        11px;

    border:
        1px solid var(--border);

    border-radius: 8px;

    background: #fff;

    color: var(--text);

    font-size: 11px;
    font-weight: 700;
}

.result-open-button:hover,
.secondary-action:hover:not(:disabled) {
    border-color: #91a4e9;

    color: var(--primary);
}

.secondary-action:disabled {
    opacity: .45;

    cursor: default;
}

.results-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 15px;

    padding:
        14px
        18px;

    border-top:
        1px solid #edf0f5;

    color: var(--muted);

    font-size: 11px;
}


/* =========================================================
   MODAL RESULTADO
   ========================================================= */

.modal-backdrop {
    position: fixed;

    inset: 0;

    z-index: 3000;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 24px;

    background:
        rgba(15, 27, 45, .55);
}

.result-detail-modal {
    width:
        min(
            1500px,
            96vw
        );

    max-height: 90vh;

    display: flex;
    flex-direction: column;

    overflow: hidden;

    border-radius: 16px;

    background: #fff;

    box-shadow:
        0 30px 80px
        rgba(15, 23, 42, .24);
}

.result-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;

    gap: 20px;

    padding:
        21px
        24px;

    border-bottom:
        1px solid var(--border);
}

.result-detail-header h2 {
    margin:
        0
        0
        4px;

    font-size: 20px;
}

.result-detail-header p {
    margin: 0;

    color: var(--muted);

    font-size: 12px;
}

.modal-close {
    width: 36px;
    height: 36px;

    border:
        1px solid var(--border);

    border-radius: 9px;

    background: #fff;

    color: #5a6676;

    font-size: 22px;
}

.result-detail-kpis {
    display: grid;

    grid-template-columns:
        repeat(
            4,
            minmax(0, 1fr)
        );

    gap: 10px;

    padding:
        15px
        20px;

    background: #f8fafc;
}

.result-detail-kpi {
    padding:
        12px
        14px;

    border:
        1px solid var(--border);

    border-radius: 10px;

    background: #fff;
}

.result-detail-kpi span {
    display: block;

    color: var(--muted);

    font-size: 10px;
}

.result-detail-kpi strong {
    display: block;

    margin-top: 4px;

    font-size: 17px;
}

.result-detail-table-wrap {
    overflow: auto;
}

.result-detail-table {
    width: 100%;

    border-collapse: collapse;

    font-size: 11px;
}

.result-detail-table th {
    position: sticky;

    top: 0;

    z-index: 2;

    padding:
        10px
        12px;

    background: #eef2f7;

    color: #445266;

    text-align: left;

    white-space: nowrap;
}

.result-detail-table td {
    padding:
        10px
        12px;

    border-top:
        1px solid #edf0f5;

    white-space: nowrap;
}

.result-detail-table td:nth-child(3) {
    min-width: 260px;

    white-space: normal;
}


@media (max-width: 900px) {

    .results-controls {
        width: 100%;

        flex-direction: column;
    }

    .results-controls input,
    .results-controls select {
        width: 100%;
    }

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