:root {
    --navy: #0e1e3b;
    --blue: #153f78;
    --orange: #f47721;
    --cream: #f4f6f9;
    --ink: #172033;
    --muted: #687488;
    --line: #dfe4eb;
    --danger: #b42318;
    --success: #167b55;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--cream);
    font-family: Inter, Arial, sans-serif;
    line-height: 1.5;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input {
    font: inherit;
}

button,
a.button {
    touch-action: manipulation;
}

.portal-shell {
    display: grid;
    min-height: 100vh;
    grid-template-columns: 250px 1fr;
}

.portal-sidebar {
    display: flex;
    position: sticky;
    top: 0;
    height: 100vh;
    flex-direction: column;
    padding: 28px 22px;
    color: white;
    background: linear-gradient(180deg, var(--navy), #173c6e);
}

.portal-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: Montserrat, Arial, sans-serif;
    font-weight: 900;
}

.portal-brand-badge {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 12px;
    background: var(--orange);
    font-size: 1.4rem;
}

.portal-nav {
    display: grid;
    gap: 6px;
    margin-top: 45px;
}

.portal-nav a {
    padding: 12px 14px;
    border-radius: 10px;
    color: #cfdaea;
    font-size: .9rem;
    font-weight: 700;
}

.portal-nav a:hover,
.portal-nav a.active {
    color: white;
    background: rgba(255, 255, 255, .1);
}

.sidebar-footer {
    margin-top: auto;
    color: #acbad0;
    font-size: .77rem;
}

.portal-main {
    min-width: 0;
    padding: 42px clamp(20px, 4vw, 56px);
}

.portal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 32px;
}

.portal-header h1 {
    margin: 0;
    color: var(--navy);
    font-family: Montserrat, Arial, sans-serif;
    font-size: clamp(1.7rem, 3vw, 2.5rem);
}

.portal-header p {
    margin: 6px 0 0;
    color: var(--muted);
}

.card {
    margin-bottom: 24px;
    padding: clamp(22px, 4vw, 34px);
    border: 1px solid var(--line);
    border-radius: 18px;
    background: white;
    box-shadow: 0 14px 42px rgba(14, 30, 59, .06);
}

.card h2 {
    margin: 0 0 20px;
    color: var(--navy);
    font-family: Montserrat, Arial, sans-serif;
    font-size: 1.25rem;
}

.field {
    margin-bottom: 19px;
}

.field label {
    display: block;
    margin-bottom: 8px;
    color: #354055;
    font-size: .82rem;
    font-weight: 800;
}

.field small {
    display: block;
    margin-top: 7px;
    color: var(--muted);
}

.input {
    width: 100%;
    min-height: 48px;
    border: 1px solid #cbd3de;
    border-radius: 11px;
    padding: 12px 14px;
    outline: 0;
    background: white;
}

.input:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(244, 119, 33, .12);
}

.file-drop {
    display: block;
    padding: 25px;
    border: 2px dashed #cbd3de;
    border-radius: 14px;
    text-align: center;
    background: #f9fafc;
    cursor: pointer;
}

.file-drop input {
    display: block;
    width: 100%;
    margin-top: 15px;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 9px;
    background: white;
}

.button {
    display: inline-flex;
    min-height: 46px;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 11px;
    padding: 11px 19px;
    cursor: pointer;
    color: white;
    background: var(--orange);
    font-weight: 800;
}

.button.blue {
    background: var(--blue);
}

.button.ghost {
    color: var(--navy);
    border: 1px solid var(--line);
    background: white;
}

.button.danger {
    color: var(--danger);
    border: 1px solid #f0b9b5;
    background: #fff5f4;
}

.alert {
    margin-bottom: 24px;
    border: 1px solid #b8dfcf;
    border-radius: 12px;
    padding: 13px 15px;
    color: #115e43;
    background: #effaf5;
}

.alert.error {
    border-color: #efb8b4;
    color: #8f241c;
    background: #fff3f2;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat {
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 15px;
    background: white;
}

.stat strong {
    display: block;
    color: var(--navy);
    font-family: Montserrat, Arial, sans-serif;
    font-size: 1.6rem;
}

.stat span {
    color: var(--muted);
    font-size: .78rem;
    font-weight: 700;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}

th,
td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: .72rem;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.receipt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
    gap: 22px;
}

.receipt-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 17px;
    background: white;
    box-shadow: 0 10px 30px rgba(14, 30, 59, .07);
}

.receipt-images {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 5px;
    padding: 5px;
    background: #e9edf2;
}

.receipt-image {
    position: relative;
    display: block;
    min-width: 0;
    overflow: hidden;
    border-radius: 10px;
}

.receipt-card img {
    width: 100%;
    height: 230px;
    object-fit: contain;
    background: #dfe4eb;
}

.receipt-image span {
    position: absolute;
    right: 7px;
    bottom: 7px;
    border-radius: 999px;
    padding: 4px 8px;
    color: white;
    background: rgba(14, 30, 59, .82);
    font-size: .7rem;
    font-weight: 800;
}

.receipt-card-copy {
    padding: 19px;
}

.receipt-card h3 {
    margin: 0 0 5px;
    color: var(--navy);
}

.receipt-card p {
    margin: 0 0 15px;
    color: var(--muted);
    font-size: .82rem;
}

.receipt-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
}

.receipt-actions .button {
    flex: 1 1 130px;
}

.table-detail {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: .7rem;
}

.table-actions {
    white-space: nowrap;
}

.table-actions .button {
    min-height: 36px;
    padding: 7px 11px;
}

.search-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
}

.empty {
    padding: 38px 20px;
    color: var(--muted);
    text-align: center;
}

.auth-page {
    display: grid;
    min-height: 100vh;
    grid-template-columns: 1.1fr .9fr;
    background: white;
}

.auth-visual {
    position: relative;
    display: flex;
    overflow: hidden;
    flex-direction: column;
    justify-content: flex-end;
    padding: clamp(35px, 7vw, 80px);
    color: white;
    background: var(--navy);
}

.auth-visual::before {
    content: "";
    position: absolute;
    inset: 0;
    opacity: .27;
    background: url('../images/hero-frota.jpg') center / cover;
}

.auth-visual > * {
    position: relative;
}

.auth-visual h1 {
    margin: 0;
    max-width: 560px;
    font-family: Montserrat, Arial, sans-serif;
    font-size: clamp(2rem, 5vw, 4rem);
    line-height: 1.04;
}

.auth-visual p {
    max-width: 520px;
    color: #d4deeb;
}

.auth-form-wrap {
    display: grid;
    place-items: center;
    padding: 30px;
}

.auth-form {
    width: min(420px, 100%);
}

.auth-form h2 {
    margin: 0;
    color: var(--navy);
    font-family: Montserrat, Arial, sans-serif;
    font-size: 1.8rem;
}

.auth-form > p {
    margin: 8px 0 28px;
    color: var(--muted);
}

.back-link {
    display: inline-block;
    margin-bottom: 35px;
    color: var(--muted);
    font-size: .85rem;
    font-weight: 700;
}

.example-box {
    margin: 16px 0 22px;
    padding: 15px;
    border-radius: 12px;
    color: #47536a;
    background: #f4f6f9;
    font-size: .83rem;
}

@media (max-width: 800px) {
    .portal-shell {
        grid-template-columns: 1fr;
    }

    .portal-sidebar {
        position: static;
        height: auto;
        padding: 18px;
    }

    .portal-nav {
        display: flex;
        margin-top: 18px;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .portal-nav::-webkit-scrollbar {
        display: none;
    }

    .portal-nav a {
        flex: 0 0 auto;
    }

    .sidebar-footer {
        display: none;
    }

    .portal-main {
        padding: 28px 16px;
    }

    .portal-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .stats-grid {
        grid-template-columns: repeat(3, minmax(155px, 1fr));
        overflow-x: auto;
        padding-bottom: 4px;
        scroll-snap-type: x proximity;
    }

    .stat {
        scroll-snap-align: start;
    }

    .auth-page {
        grid-template-columns: 1fr;
    }

    .auth-visual {
        display: none;
    }

    .table-wrap {
        margin-inline: -10px;
        overflow: visible;
    }

    table,
    tbody,
    tr,
    td {
        display: block;
        width: 100%;
    }

    thead {
        display: none;
    }

    tbody {
        display: grid;
        gap: 14px;
    }

    tr {
        overflow: hidden;
        border: 1px solid var(--line);
        border-radius: 14px;
        background: white;
    }

    td {
        display: grid;
        grid-template-columns: 104px minmax(0, 1fr);
        gap: 10px;
        padding: 11px 13px;
        border-bottom: 1px solid #edf0f4;
    }

    td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: .68rem;
        font-weight: 800;
        letter-spacing: .04em;
        text-transform: uppercase;
    }

    td:last-child {
        border-bottom: 0;
    }

    .table-actions {
        display: flex;
        grid-template-columns: none;
        flex-wrap: wrap;
        white-space: normal;
    }

    .table-actions::before {
        width: 100%;
    }
}

@media (max-width: 520px) {
    .portal-sidebar {
        padding: 15px 14px;
    }

    .portal-brand {
        font-size: .86rem;
    }

    .portal-brand-badge {
        width: 38px;
        height: 38px;
    }

    .portal-main {
        padding: 24px 12px;
    }

    .card {
        padding: 20px 16px;
        border-radius: 15px;
    }

    .portal-header .button {
        width: 100%;
    }

    .portal-header form {
        width: 100%;
    }

    .search-form {
        grid-template-columns: 1fr;
    }

    .search-form .button,
    .file-drop + small + .button {
        width: 100%;
    }

    .receipt-images {
        grid-template-columns: 1fr 1fr;
    }

    .receipt-image:only-child {
        grid-column: 1 / -1;
    }

    .receipt-card img {
        height: 190px;
    }

    .receipt-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .auth-form-wrap {
        align-items: start;
        padding: 26px 18px;
    }
}
