:root {
    --bg: #f3f6fb;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --text: #0f172a;
    --text-muted: #475569;
    --brand-900: #0f3a68;
    --brand-700: #1d4f86;
    --brand-500: #2f6fb5;
    --accent: #0ea5e9;
    --success-bg: #dcfce7;
    --success-text: #166534;
    --warning-bg: #fef9c3;
    --warning-text: #854d0e;
    --danger-bg: #fee2e2;
    --danger-text: #991b1b;
    --border: #dbe3ef;
    --focus: #0ea5e9;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.08);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --space-1: 8px;
    --space-2: 16px;
    --space-3: 24px;
    --space-4: 32px;
    --space-5: 40px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-width: 320px;
    font-family: "Inter", "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

body {
    line-height: 1.5;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto auto 1fr;
}

.topbar {
    background: linear-gradient(90deg, var(--brand-900), var(--brand-700));
    color: #fff;
    padding: var(--space-2) var(--space-3);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    box-shadow: var(--shadow-md);
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.brand img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.brand h1 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.layout-nav {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3) var(--space-2);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.layout-nav a {
    text-decoration: none;
    color: var(--text-muted);
    background: var(--surface-muted);
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 10px var(--space-2);
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.layout-nav a:hover {
    color: var(--brand-700);
    border-color: #cfe0f5;
    transform: translateY(-1px);
}

.layout-nav a.is-active {
    background: #dbeafe;
    color: var(--brand-700);
    border-color: #bfdbfe;
}

.page-wrap {
    max-width: 1360px;
    margin: 0 auto;
    width: 100%;
    padding: var(--space-2) var(--space-3) var(--space-4);
}

.breadcrumbs {
    margin-bottom: var(--space-2);
}

.breadcrumbs ol {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    color: var(--text-muted);
    font-size: 0.875rem;
}

.breadcrumbs li + li::before {
    content: "/";
    margin-right: var(--space-1);
    color: #94a3b8;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.page-title {
    margin: 0;
    font-size: clamp(1.25rem, 2vw, 1.75rem);
    font-weight: 700;
}

.page-subtitle {
    margin: var(--space-1) 0 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.content-grid {
    display: grid;
    gap: var(--space-3);
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: var(--space-2);
}

.card,
.metric-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card {
    padding: var(--space-3);
}

.metric-card {
    padding: var(--space-2);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    min-height: 120px;
}

.metric-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.metric-value {
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 700;
    color: var(--brand-700);
}

.metric-trend {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.col-4 {
    grid-column: span 4;
}

.col-8 {
    grid-column: span 8;
}

.col-12 {
    grid-column: span 12;
}

label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 6px;
    display: block;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
    min-height: 44px;
    padding: 10px 12px;
    font-size: 0.95rem;
    color: var(--text);
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:hover,
select:hover,
textarea:hover {
    border-color: #94a3b8;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.3);
    border-color: var(--focus);
}

.grid-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 5px 10px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.st-aguardando {
    background: var(--warning-bg);
    color: var(--warning-text);
}

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

.st-reprovado {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.st-assinado {
    background: #dbeafe;
    color: #1d4ed8;
}

.table-container {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: #fff;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 880px;
}

th,
td {
    padding: 14px var(--space-2);
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: middle;
    font-size: 0.9rem;
}

th {
    background: #f8fafc;
    color: #334155;
    font-weight: 700;
}

tbody tr {
    transition: background-color 0.2s ease;
}

tbody tr:hover {
    background: #f8fafc;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
}

.inline-form {
    display: inline-flex;
}

.btn-primary,
.btn-danger,
.btn-info,
.btn-xls,
.btn-secondary {
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    min-height: 40px;
    padding: 0 14px;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.2s ease;
}

.btn-primary {
    background: var(--brand-700);
    color: #fff;
}

.btn-primary:hover {
    background: var(--brand-500);
    transform: translateY(-1px);
}

.btn-danger {
    background: #dc2626;
    color: #fff;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-info {
    background: #0284c7;
    color: #fff;
}

.btn-info:hover {
    background: #0369a1;
}

.btn-xls {
    background: #166534;
    color: #fff;
    margin-bottom: var(--space-2);
}

.btn-xls:hover {
    background: #14532d;
}

.btn-secondary {
    background: #fff;
    color: #1e293b;
    border-color: #cbd5e1;
}

.btn-secondary:hover {
    background: #f8fafc;
}

.flash {
    border-radius: var(--radius-sm);
    padding: 12px var(--space-2);
    margin-bottom: var(--space-2);
    border: 1px solid transparent;
    font-size: 0.9rem;
}

.flash-success {
    background: #ecfdf5;
    color: #166534;
    border-color: #bbf7d0;
}

.flash-error {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

.flow-stack {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.flow-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #dbe3ef;
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    background: #f8fafc;
    font-size: 0.8rem;
    color: #334155;
}

.hero-banner {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: var(--space-2);
    align-items: center;
}

.hero-banner img {
    width: 100%;
    max-height: 160px;
    object-fit: contain;
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: var(--space-3);
    background:
        radial-gradient(circle at 12% 18%, rgba(47, 111, 181, 0.18), transparent 34%),
        radial-gradient(circle at 88% 84%, rgba(14, 165, 233, 0.16), transparent 36%),
        var(--bg);
}

.auth-card {
    width: min(1080px, 100%);
    padding: 0;
    overflow: hidden;
}

.auth-layout {
    display: grid;
    grid-template-columns: 1fr 1.05fr;
}

.auth-visual {
    background: linear-gradient(160deg, var(--brand-900), var(--brand-700));
    color: #fff;
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: var(--space-3);
}

.auth-visual h2 {
    margin: 0 0 var(--space-1);
    font-size: 1.5rem;
    line-height: 1.3;
}

.auth-visual p {
    margin: 0;
    color: rgba(255, 255, 255, 0.88);
}

.auth-visual img {
    width: min(340px, 100%);
}

.auth-badge-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.auth-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    width: fit-content;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 0.82rem;
    font-weight: 600;
}

.auth-form-panel {
    padding: var(--space-4);
}

.auth-form-panel .brand {
    margin-bottom: var(--space-2);
}

.auth-form-panel .brand h1 {
    font-size: 1.25rem;
    color: var(--brand-900);
}

.auth-form {
    display: grid;
    gap: var(--space-2);
}

.form-field {
    display: grid;
    gap: 6px;
}

.input-wrap {
    position: relative;
}

.input-wrap input {
    padding-right: 46px;
}

.input-action {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: 6px;
    min-height: 30px;
    padding: 0 8px;
}

.auth-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-1);
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.remember-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.remember-check input {
    min-height: auto;
    width: 16px;
    height: 16px;
    margin: 0;
}

.auth-link {
    color: var(--brand-700);
    text-decoration: none;
    font-weight: 600;
}

.auth-link:hover {
    text-decoration: underline;
}

.auth-footer {
    margin-top: var(--space-2);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.auth-footer a {
    color: var(--brand-700);
    font-weight: 600;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

@media (max-width: 1024px) {
    .page-wrap {
        padding: var(--space-2);
    }

    .col-4,
    .col-8 {
        grid-column: span 12;
    }

    .hero-banner {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .topbar {
        padding: var(--space-2);
    }

    .layout-nav {
        padding: var(--space-1) var(--space-2) var(--space-2);
    }

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

    .auth-layout {
        grid-template-columns: 1fr;
    }

    .auth-visual {
        padding: var(--space-3);
    }

    .auth-form-panel {
        padding: var(--space-3);
    }
}

@media (max-width: 420px) {
    .brand h1 {
        font-size: 0.95rem;
    }

    .page-title {
        font-size: 1.1rem;
    }

    th,
    td {
        padding: 10px 12px;
    }
}
