:root {
    --blue-900: #00498f;
    --blue-800: #0b5daf;
    --blue-700: #156fca;
    --blue-100: #eaf2ff;
    --green-600: #5fa52c;
    --green-500: #76bd3d;
    --green-300: #a8db74;
    --green-100: #edf8e4;
    --slate-950: #313647;
    --slate-900: #3f4558;
    --slate-850: #4e5366;
    --slate-100: #f4f7fd;
    --line: #d2dae8;
    --card: #ffffff;
    --surface: #f8fbff;
    --text: #162132;
    --muted: #5f6c80;
    --danger: #b63333;
    --shadow-soft: 0 14px 30px rgba(16, 28, 48, 0.16);
    --shadow-card: 0 8px 20px rgba(17, 44, 86, 0.08);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: "Space Grotesk", "Segoe UI", sans-serif;
    color: var(--text);
    background:
        linear-gradient(180deg, #136ec9 0 108px, #0859a9 108px 142px, var(--slate-850) 142px 100%),
        radial-gradient(circle at 14% 20%, rgba(118, 189, 61, 0.2) 0, transparent 36%),
        radial-gradient(circle at 88% 4%, rgba(168, 219, 116, 0.2) 0, transparent 30%),
        var(--slate-850);
}

.background-shape {
    position: fixed;
    z-index: 0;
    border-radius: 999px;
    filter: blur(4px);
    pointer-events: none;
}

.background-shape-1 {
    width: 420px;
    height: 420px;
    background: rgba(118, 189, 61, 0.32);
    top: 180px;
    right: -160px;
}

.background-shape-2 {
    width: 380px;
    height: 380px;
    background: rgba(21, 111, 202, 0.28);
    bottom: -120px;
    left: -120px;
}

.app-shell {
    position: relative;
    z-index: 2;
    max-width: 1280px;
    margin: 0 auto;
    padding: 16px 18px 30px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 4px 0 16px;
    padding: 14px 18px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 16px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.07));
    backdrop-filter: blur(3px);
    box-shadow: var(--shadow-soft);
}

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

.brand-copy {
    display: grid;
    gap: 2px;
}

.brand h1 {
    margin: 0;
    color: #fff;
    font-size: 1.6rem;
    letter-spacing: 0.01em;
}

.brand-subtitle {
    margin: 0;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.9);
}

.brand-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 7px 13px;
    border-radius: 12px;
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #153000;
    background: linear-gradient(150deg, var(--green-300), var(--green-500));
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35), 0 8px 20px rgba(80, 138, 36, 0.42);
}

.session-info {
    display: flex;
    gap: 12px;
    align-items: center;
    color: #eef5ff;
    font-size: 0.94rem;
}

.dashboard {
    animation: riseIn 260ms ease-out;
}

.quick-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.quick-card {
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 14px;
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.08));
    color: #e8f2ff;
    padding: 10px 12px;
    box-shadow: 0 8px 20px rgba(15, 30, 56, 0.2);
}

.quick-label {
    display: block;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.9;
}

.quick-card strong {
    font-size: 0.96rem;
    font-weight: 600;
}

.tabs {
    display: inline-flex;
    gap: 8px;
    margin-bottom: 10px;
    padding: 7px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 8px 18px rgba(20, 42, 76, 0.14);
}

.tab-button {
    border: none;
    background: transparent;
    color: #1c2f4e;
    padding: 10px 14px;
    border-radius: 999px;
    cursor: pointer;
    font-family: "Space Grotesk", sans-serif;
    font-weight: 700;
    transition: transform 140ms ease, background 140ms ease, color 140ms ease;
}

.tab-button:hover {
    transform: translateY(-1px);
    background: rgba(22, 111, 202, 0.1);
}

.tab-button.active {
    color: #fff;
    background: linear-gradient(145deg, var(--blue-800), var(--blue-700));
    box-shadow: 0 6px 16px rgba(11, 93, 175, 0.45);
}

.tab-panel {
    display: none;
    animation: riseIn 220ms ease-out;
}

.tab-panel.active {
    display: block;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow-card);
    padding: 18px;
    margin-bottom: 14px;
    position: relative;
}

.card::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 4px;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    background: linear-gradient(90deg, var(--blue-700), var(--green-500));
}

.auth-card {
    max-width: 520px;
    margin: 34px auto;
    color: #fff;
    border-color: rgba(255, 255, 255, 0.33);
    background: linear-gradient(160deg, rgba(9, 91, 168, 0.94), rgba(37, 132, 214, 0.88));
    box-shadow: var(--shadow-soft);
}

#passwordCard {
    max-width: 520px;
    margin: 0 0 14px auto;
}

.auth-card::before {
    background: linear-gradient(90deg, var(--green-300), #ffffff);
}

.auth-card .muted {
    color: rgba(236, 245, 255, 0.94);
}

.auth-card input,
.auth-card select {
    border-color: rgba(255, 255, 255, 0.36);
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

.auth-card input::placeholder {
    color: rgba(255, 255, 255, 0.76);
}

.auth-card label span {
    color: rgba(255, 255, 255, 0.95);
}

.card h2,
.card h3 {
    margin-top: 0;
    margin-bottom: 10px;
}

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

.form-grid {
    display: grid;
    gap: 13px;
}

label {
    display: grid;
    gap: 7px;
    font-size: 0.9rem;
    font-weight: 500;
}

input,
select {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    border-radius: 10px;
    padding: 10px 12px;
    font: inherit;
}

input:focus,
select:focus,
button:focus {
    outline: 2px solid rgba(21, 111, 202, 0.45);
    outline-offset: 1px;
}

.btn {
    border: none;
    border-radius: 10px;
    padding: 10px 14px;
    font-family: "Space Grotesk", sans-serif;
    font-weight: 700;
    cursor: pointer;
    transition: transform 120ms ease, filter 120ms ease, box-shadow 120ms ease;
}

.btn:hover {
    transform: translateY(-1px);
    filter: brightness(0.97);
}

.btn.primary {
    color: #17300a;
    background: linear-gradient(145deg, var(--green-500), var(--green-300));
    box-shadow: 0 8px 16px rgba(102, 171, 45, 0.32);
}

.btn.ghost {
    background: #eaf2ff;
    color: #154c8f;
    border: 1px solid #c8daff;
}

.btn.danger {
    background: linear-gradient(140deg, #c23f3f, #a92e2e);
    color: #fff;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.clientes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 12px;
}

.clientes-filter-grid {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 10px;
    margin-bottom: 12px;
}

.cliente-card {
    border: 1px solid #cfe0fb;
    border-radius: 14px;
    background: linear-gradient(160deg, #f8fbff, #edf4ff);
    padding: 12px;
    display: grid;
    gap: 6px;
    cursor: pointer;
    transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.cliente-card:hover {
    transform: translateY(-2px);
    border-color: #8db4ea;
    box-shadow: 0 10px 20px rgba(17, 56, 109, 0.16);
}

.cliente-card.active {
    border-color: #2d76cc;
    background: linear-gradient(155deg, #e3efff, #d8e9ff);
    box-shadow: inset 0 0 0 1px rgba(32, 98, 178, 0.3), 0 10px 20px rgba(12, 75, 149, 0.24);
}

.cliente-card h4 {
    margin: 0;
    font-size: 1.02rem;
    color: #143b6f;
}

.cliente-card p {
    margin: 0;
    font-size: 0.86rem;
    color: #4a5f80;
}

.cliente-card .mono {
    width: fit-content;
}

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

.selection-banner {
    border: 1px solid #d2e4ff;
    border-radius: 12px;
    background: linear-gradient(145deg, #f5f9ff, #eaf3ff);
    padding: 11px 12px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.selection-copy {
    display: grid;
    gap: 2px;
}

.selection-copy strong {
    color: #133a6e;
}

.selection-copy small {
    color: #4f6588;
    font-family: "IBM Plex Mono", monospace;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.results-context {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.context-chip {
    border: 1px solid #d8e7ff;
    border-radius: 12px;
    background: linear-gradient(160deg, #f8fbff, #edf5ff);
    padding: 10px 12px;
    display: grid;
    gap: 3px;
}

.context-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #5a6f91;
}

.context-chip strong {
    font-size: 0.95rem;
    color: #13345f;
    word-break: break-word;
}

.mono {
    font-family: "IBM Plex Mono", monospace;
    color: #3e4f66;
    font-size: 0.82rem;
    background: var(--blue-100);
    padding: 6px 8px;
    border-radius: 8px;
}

.table-wrap {
    overflow: auto;
    border: 1px solid #dbe7fb;
    border-radius: 12px;
    background: #fff;
}

.monthly-tax-section {
    margin-top: 16px;
    border-top: 1px solid #d9e7fb;
    padding-top: 14px;
}

.monthly-tax-legend {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.84rem;
    color: #35527d;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
    vertical-align: middle;
}

.legend-icms {
    background: #1263be;
}

.legend-pis {
    background: #2e9f27;
}

.legend-cofins {
    background: #d86a00;
}

.monthly-tax-chart-wrap {
    border: 1px solid #dbe7fb;
    border-radius: 12px;
    background: linear-gradient(180deg, #fbfdff, #f3f8ff);
    padding: 8px;
    min-height: 320px;
}

#monthlyTaxesChart {
    width: 100%;
    height: 300px;
    display: block;
}

.download-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.89rem;
    background: #fff;
}

th,
td {
    text-align: left;
    border-bottom: 1px solid #e8eef8;
    padding: 10px 8px;
    vertical-align: top;
}

th {
    color: #ecf4ff;
    font-weight: 600;
    background: linear-gradient(145deg, var(--blue-800), var(--blue-700));
    position: sticky;
    top: 0;
    z-index: 1;
}

tbody tr:hover {
    background: #f4fbeb;
}

.nfe-key-block {
    display: flex;
    align-items: center;
    max-width: 300px;
}

.nfe-key {
    display: inline-block;
    padding: 5px 7px;
    border-radius: 8px;
    border: 1px solid #d6e4fa;
    background: #f7fbff;
    color: #153f73;
    font-size: 0.76rem;
    font-family: "IBM Plex Mono", monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.copy-key-btn {
    padding: 6px 10px;
    font-size: 0.76rem;
    border-radius: 8px;
    white-space: nowrap;
}

.acoes-row {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.acao-btn {
    padding: 6px 10px;
    font-size: 0.76rem;
    border-radius: 8px;
    white-space: nowrap;
}

#selecionarPaginaCheckbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.linha-selecao {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.admin-empresa-selecao {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.admin-row-selected {
    background: #eef8e2;
}

#adminSelecionarEmpresasCheckbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.form-inline {
    display: flex;
    gap: 10px;
    align-items: end;
    flex-wrap: wrap;
}

.output {
    margin-top: 14px;
    background: #0f1e31;
    color: #d8eeff;
    border-radius: 12px;
    padding: 12px;
    min-height: 120px;
    max-height: 280px;
    overflow: auto;
    border: 1px solid rgba(136, 181, 245, 0.35);
    font-family: "IBM Plex Mono", monospace;
    font-size: 0.82rem;
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 30;
    background: linear-gradient(145deg, #134f92, #0f6fc8);
    color: #fff;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: var(--shadow-soft);
    max-width: 360px;
}

.hidden {
    display: none !important;
}

@keyframes riseIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1080px) {
    .filters-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .quick-strip {
        grid-template-columns: 1fr;
    }

    .results-context {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .app-shell {
        padding: 10px 12px 22px;
    }

    .topbar {
        align-items: start;
        flex-direction: column;
        gap: 10px;
    }

    .brand {
        align-items: start;
        flex-direction: column;
        gap: 8px;
    }

    .tabs {
        display: flex;
        width: 100%;
        overflow: auto;
        white-space: nowrap;
    }

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

    .form-inline {
        flex-direction: column;
        align-items: stretch;
    }

    .selection-banner {
        flex-direction: column;
        align-items: stretch;
    }

    .clientes-filter-grid {
        grid-template-columns: 1fr;
    }
}
