:root {
    --primary: #164e63;
    --primary-dark: #0f3a4a;
    --primary-soft: #e9f3f6;
    --accent: #d39b3d;

    --background: #f3f6f8;
    --surface: #ffffff;
    --surface-soft: #f8fafb;

    --text: #17212b;
    --muted: #65717d;
    --border: #dce3e8;

    --success-bg: #dcfce7;
    --success-text: #166534;
    --error-bg: #fee2e2;
    --error-text: #991b1b;
    --warning-bg: #fef3c7;
    --warning-text: #92400e;

    --shadow-sm: 0 4px 16px rgba(15, 58, 74, 0.06);
    --shadow-lg: 0 22px 60px rgba(15, 58, 74, 0.15);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--background);
    color: var(--text);
    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Arial,
        Helvetica,
        sans-serif;
    line-height: 1.5;
}

button,
input,
textarea,
select {
    font: inherit;
}

/* =========================================================
   MARCA
   ========================================================= */

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    flex-shrink: 0;

    background: linear-gradient(
        145deg,
        #ffffff,
        #dceef3
    );

    color: var(--primary-dark);
    font-size: 15px;
    font-weight: 900;
    letter-spacing: 0.7px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-text strong {
    font-size: 18px;
    letter-spacing: 0.2px;
}

.brand-text span {
    margin-top: 3px;
    color: rgba(255, 255, 255, 0.72);
    font-size: 12px;
}

/* =========================================================
   CABEÇALHO
   ========================================================= */

.topbar {
    min-height: 76px;
    padding: 12px 28px;

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

    background:
        linear-gradient(
            115deg,
            var(--primary-dark),
            var(--primary)
        );

    color: #ffffff;
    box-shadow: 0 4px 18px rgba(15, 58, 74, 0.18);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 14px;
}

.user-greeting {
    color: rgba(255, 255, 255, 0.9);
}

.logout-form {
    margin: 0;
}

.logout-form button {
    min-height: auto;
    padding: 8px 14px;

    background: transparent;
    color: #ffffff;

    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 8px;
}

.logout-form button:hover {
    background: rgba(255, 255, 255, 0.12);
}

/* =========================================================
   ESTRUTURA PRINCIPAL
   ========================================================= */

.container {
    width: min(1120px, calc(100% - 32px));
    margin: 32px auto 56px;
}

.card {
    padding: 24px;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.page-header h1,
.page-header h2 {
    margin: 0 0 8px;
    color: var(--primary-dark);
}

.page-header p {
    margin: 0;
    color: var(--muted);
}

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

.summary-card {
    padding: 20px;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

.summary-card small {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
}

.summary-card strong {
    color: var(--primary-dark);
    font-size: 21px;
}

/* =========================================================
   FORMULÁRIOS
   ========================================================= */

label {
    display: block;
    margin: 18px 0 7px;
    color: var(--text);
    font-weight: 700;
}

input,
textarea,
select {
    width: 100%;
    min-height: 46px;
    padding: 10px 13px;

    background: #ffffff;
    color: var(--text);

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

    font-size: 16px;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

textarea {
    min-height: 110px;
    resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(22, 78, 99, 0.14);
}

button,
.button {
    min-height: 42px;
    padding: 10px 18px;

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

    background: var(--primary);
    color: #ffffff;

    border: 0;
    border-radius: 8px;

    font-weight: 700;
    text-decoration: none;
    cursor: pointer;

    transition:
        background 0.2s ease,
        transform 0.2s ease;
}

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

button:active,
.button:active {
    transform: translateY(1px);
}

.button-disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* =========================================================
   ALERTAS
   ========================================================= */

.alert {
    margin: 18px 0;
    padding: 12px 14px;
    border-radius: 8px;
}

.alert-error {
    background: var(--error-bg);
    color: var(--error-text);
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
}

.muted {
    color: var(--muted);
}

/* =========================================================
   TABELAS E STATUS
   ========================================================= */

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    margin-top: 14px;
    border-collapse: collapse;
}

th,
td {
    padding: 13px 11px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}

th {
    background: var(--surface-soft);
    color: #46515c;
    font-size: 12px;
    letter-spacing: 0.35px;
    text-transform: uppercase;
}

tbody tr:hover {
    background: #fafcfd;
}

.status {
    display: inline-block;
    padding: 5px 9px;

    background: var(--warning-bg);
    color: var(--warning-text);

    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

/* =========================================================
   LOGIN
   ========================================================= */

.auth-body {
    background:
        radial-gradient(
            circle at top left,
            rgba(211, 155, 61, 0.18),
            transparent 30%
        ),
        linear-gradient(
            135deg,
            #0b3442,
            #164e63 58%,
            #1e6378
        );
}

.login-page {
    min-height: 100vh;
    padding: 32px;

    display: grid;
    place-items: center;
}

.login-shell {
    width: min(940px, 100%);
    min-height: 560px;

    display: grid;
    grid-template-columns: 1.05fr 0.95fr;

    overflow: hidden;
    background: var(--surface);

    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 22px;
    box-shadow: var(--shadow-lg);
}

.login-brand-panel {
    position: relative;
    padding: 52px;

    display: flex;
    flex-direction: column;
    justify-content: space-between;

    background:
        linear-gradient(
            145deg,
            rgba(15, 58, 74, 0.98),
            rgba(22, 78, 99, 0.94)
        );

    color: #ffffff;
}

.login-brand-panel::after {
    content: "";
    position: absolute;
    right: -90px;
    bottom: -110px;

    width: 280px;
    height: 280px;

    border: 46px solid rgba(255, 255, 255, 0.06);
    border-radius: 50%;
}

.login-brand-panel .brand-mark {
    width: 58px;
    height: 58px;
    font-size: 18px;
}

.login-brand-panel h1 {
    max-width: 420px;
    margin: 42px 0 16px;

    font-size: clamp(30px, 4vw, 43px);
    line-height: 1.08;
}

.login-brand-panel p {
    max-width: 440px;
    margin: 0;

    color: rgba(255, 255, 255, 0.74);
    font-size: 16px;
}

.login-brand-footer {
    position: relative;
    z-index: 1;
    margin-top: 40px;

    color: rgba(255, 255, 255, 0.62);
    font-size: 12px;
}

.login-form-panel {
    padding: 52px;

    display: flex;
    align-items: center;
    background: #ffffff;
}

.login-card {
    width: 100%;
}

.login-title {
    margin: 0 0 8px;
    color: var(--primary-dark);
    font-size: 28px;
}

.login-subtitle {
    margin: 0 0 28px;
    color: var(--muted);
}

.login-button {
    width: 100%;
    min-height: 48px;
    margin-top: 24px;
    font-size: 16px;
}

/* =========================================================
   PÁGINAS DE ERRO
   ========================================================= */

.error-page {
    min-height: 100vh;
    padding: 24px;

    display: grid;
    place-items: center;
}

.error-card {
    width: min(520px, 100%);
    padding: 48px 38px;

    background: var(--surface);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);

    text-align: center;
}

.error-code {
    margin-bottom: 12px;

    color: var(--accent);
    font-size: 64px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: -2px;
}

.error-card h1 {
    margin: 0 0 14px;

    color: var(--primary-dark);
    font-size: 28px;
    line-height: 1.2;
}

.error-card p {
    max-width: 420px;
    margin: 0 auto 28px;

    color: var(--muted);
    font-size: 16px;
}

.error-card .button {
    min-width: 180px;
}

.error-signature {
    margin-top: 34px;

    color: var(--muted);
    font-size: 12px;
}

@media (max-width: 480px) {
    .error-card {
        padding: 38px 22px;
    }

    .error-code {
        font-size: 54px;
    }

    .error-card h1 {
        font-size: 24px;
    }
}

/* =========================================================
   RESPONSIVIDADE
   ========================================================= */

@media (max-width: 760px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        padding: 16px;
    }

    .topbar-user {
        width: 100%;
        justify-content: space-between;
    }

    .page-header {
        flex-direction: column;
    }

    .login-page {
        padding: 18px;
    }

    .login-shell {
        min-height: auto;
        grid-template-columns: 1fr;
    }

    .login-brand-panel {
        padding: 30px;
    }

    .login-brand-panel h1 {
        margin-top: 28px;
        font-size: 30px;
    }

    .login-brand-footer {
        display: none;
    }

    .login-form-panel {
        padding: 32px 26px;
    }
}

@media (max-width: 480px) {
    .container {
        width: min(100% - 22px, 1120px);
        margin-top: 20px;
    }

    .card {
        padding: 18px;
    }

    .brand-text strong {
        font-size: 16px;
    }

    .brand-text span {
        display: none;
    }

    .user-greeting {
        max-width: 170px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}