:root {
    --bg: #f4f6f7;
    --panel: #ffffff;
    --text: #1f2933;
    --muted: #647381;
    --line: #d8e0e6;
    --primary: #057fbe;
    --primary-dark: #045f91;
    --success: #0798c9;
    --warning: #8a6500;
    --danger: #a43e3e;
    --shadow: 0 8px 22px rgba(31, 41, 51, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
    margin: 0;
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
}

.topbar {
    align-items: center;
    background: #fff;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    min-height: 58px;
    padding: 0 30px;
}

.brand {
    color: var(--text);
    font-weight: 700;
}

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

.logout-form {
    margin: 0;
}

.logout-form button {
    background: transparent;
    border: 0;
    color: var(--primary);
    cursor: pointer;
    font: inherit;
    padding: 0;
}

.container {
    margin: 0 auto;
    max-width: 1220px;
    padding: 28px 20px 46px;
}

.page-title {
    align-items: center;
    display: flex;
    gap: 18px;
    justify-content: space-between;
    margin-bottom: 20px;
}

.page-title h1 {
    font-size: 28px;
    margin: 0 0 6px;
}

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

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 20px;
}

.error-panel {
    max-width: 680px;
}

.error-panel h1 {
    margin-top: 0;
}

.occurrence-code {
    background: #f6f8fa;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
}

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

.filters {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.history-panel .filters {
    margin-left: 10px;
    margin-top: 15px;
}

.filter-link {
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--muted);
    font-size: 13px;
    padding: 7px 11px;
}

.filter-link.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

table {
    border-collapse: collapse;
    width: 100%;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 12px 10px;
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

td small {
    color: var(--muted);
    display: block;
    font-size: 12px;
    line-height: 1.35;
    margin-top: 5px;
    max-width: 360px;
    overflow-wrap: anywhere;
}

.button {
    align-items: center;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    justify-content: center;
    min-height: 38px;
    padding: 8px 14px;
}

.button.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

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

.button.success {
    background: #06aee5;
    border-color: #06aee5;
    color: #fff;
}

.button.success:hover {
    background: #058bbb;
    border-color: #058bbb;
}

.button.small {
    font-size: 13px;
    min-height: 32px;
    padding: 6px 10px;
}

.button:disabled {
    background: #eef2f4;
    color: #8a98a5;
    cursor: not-allowed;
}

.actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.actions form {
    margin: 0;
}

.availability-list {
    display: grid;
    gap: 8px;
}

.availability-list form {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
}

.badge {
    background: #eef2f4;
    border: 1px solid #d3dde5;
    border-radius: 999px;
    color: #51606d;
    display: inline-block;
    font-size: 12px;
    padding: 5px 9px;
    white-space: nowrap;
}

.badge.ready {
    background: #e3f4e9;
    border-color: #b9dec6;
    color: var(--success);
}

.badge.waiting {
    background: #fff4d7;
    border-color: #ead28e;
    color: var(--warning);
}

.badge.error {
    background: #fdeaea;
    border-color: #efbbbb;
    color: var(--danger);
}

.badge.muted {
    background: #eef2f4;
    color: #667685;
}

.messages {
    margin-bottom: 18px;
}

.message {
    border-radius: 6px;
    margin-bottom: 8px;
    padding: 10px 12px;
}

.message.success {
    background: #e3f4e9;
    color: var(--success);
}

.message.warning {
    background: #fff4d7;
    color: var(--warning);
}

.message.error {
    background: #fdeaea;
    color: var(--danger);
}

.empty,
.empty-row {
    color: var(--muted);
    padding: 28px;
    text-align: center;
}

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

.form-grid label {
    color: var(--muted);
    display: flex;
    flex-direction: column;
    font-size: 13px;
    gap: 7px;
}

.form-grid .full {
    grid-column: 1 / -1;
}

input,
select,
textarea {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    min-height: 38px;
    padding: 8px 10px;
    width: 100%;
}

textarea {
    resize: vertical;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
}

.filter {
    align-items: center;
    display: flex;
    gap: 8px;
}

.legend {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: -4px 0 18px;
}

.legend span {
    align-items: center;
    color: var(--muted);
    display: inline-flex;
    font-size: 13px;
    gap: 6px;
}

.legend i {
    border: 1px solid rgba(31, 41, 51, 0.12);
    border-radius: 4px;
    display: inline-block;
    height: 14px;
    width: 18px;
}

.history-panel {
    padding: 0;
}

.history-wrap {
    border-radius: 8px;
    max-height: 70vh;
}

.history-table {
    min-width: 1360px;
}

.history-table th {
    background: #fff;
    position: sticky;
    top: 0;
    z-index: 3;
}

.sticky {
    background: #fff;
    position: sticky;
    z-index: 2;
}

.history-table th.sticky {
    z-index: 4;
}

.cnpj-col {
    left: 0;
    min-width: 150px;
}

.company-col {
    left: 150px;
    min-width: 260px;
}

.month {
    font-size: 13px;
    min-width: 110px;
    text-align: center;
}

.sent {
    background: #d9efdf;
}

.ready {
    background: #e3f4e9;
}

.history {
    background: #e8eef3;
}

.waiting {
    background: #fff4d7;
}

.error {
    background: #fdeaea;
}

.pending {
    background: #eef5ce;
}

.empty {
    background: #f6f8fa;
}

.pdf-name {
    display: inline-block;
    max-width: 220px;
    overflow-wrap: anywhere;
}

.login-page {
    background: linear-gradient(180deg, #ffffff 0%, #eef4f8 100%);
    min-height: 100vh;
}

.login-shell {
    align-items: center;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.login-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    max-width: 390px;
    padding: 30px;
    width: 100%;
}

.login-logo {
    display: block;
    height: 42px;
    margin: 0 auto 26px;
    object-fit: contain;
    width: auto;
}

.login-card h1 {
    font-size: 24px;
    margin: 0 0 22px;
}

.login-form {
    display: grid;
    gap: 16px;
}

.login-form label {
    color: var(--muted);
    display: grid;
    font-size: 13px;
    gap: 7px;
}

@media (max-width: 820px) {
    .topbar,
    .page-title {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar {
        padding: 16px 20px;
    }

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

.footer {
    align-items: center;
    background: var(--panel);
    border-top: 1px solid var(--line);
    color: var(--muted);
    display: flex;
    gap: 18px;
    justify-content: center;
    min-height: 88px;
    padding: 18px 28px;
    text-align: center;
}

.footer img {
    height: 34px;
    object-fit: contain;
    width: auto;
}

.footer p {
    margin: 0;
}

.queue-badge {
    display: block;
    margin-top: 7px;
    width: fit-content;
}
