:root {
    --surface: oklch(98% 0.006 210);
    --surface-2: oklch(94% 0.012 215);
    --panel: oklch(99% 0.005 210);
    --ink: oklch(24% 0.025 230);
    --muted: oklch(52% 0.026 230);
    --line: oklch(88% 0.016 220);
    --accent: oklch(50% 0.13 184);
    --accent-ink: oklch(24% 0.05 184);
    --danger: oklch(54% 0.18 30);
    --warning: oklch(70% 0.13 75);
    --success: oklch(55% 0.13 145);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--surface);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    font-size: 14px;
    letter-spacing: 0;
    overflow-x: hidden;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 264px minmax(0, 1fr);
}

.sidebar {
    background: var(--surface-2);
    border-right: 1px solid var(--line);
    padding: 18px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.mobile-menu-toggle,
.mobile-menu-close,
.mobile-menu-backdrop {
    display: none;
}

.brand-mark {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    margin: 4px 6px 18px;
}

.app-brand {
    align-items: flex-start;
    margin: 0 4px 18px;
}

.brand-logo {
    display: block;
    width: min(190px, 100%);
    height: auto;
}

.brand-symbol {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: inline-grid;
    place-items: center;
    background: oklch(88% 0.065 184);
    color: var(--accent-ink);
    font-size: 12px;
}

.nav-link {
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 7px;
    padding: 8px 10px;
    min-height: 36px;
    white-space: nowrap;
}

.nav-link:hover,
.nav-link:focus {
    color: var(--ink);
    background: oklch(91% 0.014 215);
}

.nav-link.active {
    color: var(--accent-ink);
    background: oklch(90% 0.04 184);
    font-weight: 650;
}

.nav-link-locked {
    color: color-mix(in oklch, var(--muted) 84%, var(--surface-2));
    cursor: not-allowed;
}

.nav-link-locked:hover,
.nav-link-locked:focus {
    background: transparent;
    color: color-mix(in oklch, var(--muted) 84%, var(--surface-2));
}

.nav-lock-icon {
    margin-left: auto;
    font-size: 11px;
}

.subscription-lock-notice {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.subscription-lock-notice i {
    color: var(--accent-ink);
    font-size: 18px;
}

.subscription-lock-notice h2 {
    font-size: 1rem;
    font-weight: 720;
    margin: 0 0 4px;
}

.subscription-lock-notice p {
    color: var(--muted);
    line-height: 1.45;
    margin: 0;
}

.nav-link i {
    width: 18px;
    text-align: center;
}

.nav-section {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    margin: 18px 10px 6px;
}

.content {
    min-width: 0;
}

.topbar {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 26px;
    border-bottom: 1px solid var(--line);
    background: color-mix(in oklch, var(--surface) 92%, var(--panel));
}

.topbar h1 {
    margin: 0;
    font-size: 1.35rem;
    line-height: 1.2;
    font-weight: 720;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    color: var(--muted);
}

.user-chip span {
    min-width: 0;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-body {
    padding: 24px 26px 42px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.metric-card,
.form-panel,
.table-shell {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.metric-card {
    padding: 14px 16px;
}

.metric-label {
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 6px;
}

.metric-value {
    font-size: 1.45rem;
    font-weight: 740;
}

.metric-sub {
    color: var(--muted);
    font-size: 12px;
    margin-top: 4px;
}

.form-panel {
    padding: 18px;
    margin-bottom: 18px;
}

.form-control,
.form-select {
    min-width: 0;
}

.search-control {
    position: relative;
    max-width: 560px;
}

.search-control i {
    position: absolute;
    top: 50%;
    left: 12px;
    color: var(--muted);
    pointer-events: none;
    transform: translateY(-50%);
}

.search-control .form-control {
    padding-left: 38px;
}

.certificate-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.certificate-summary > div {
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.certificate-summary span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 3px;
}

.certificate-summary strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 14px;
}

.panel-separator {
    border-color: var(--line);
    margin: 18px 0;
    opacity: 1;
}

.form-actions,
.download-actions,
.table-actions,
.toolbar-form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.form-actions {
    margin-top: 18px;
}

.form-hint {
    color: var(--muted);
    font-size: 12px;
    margin-top: 12px;
}

.fiscal-guidance {
    display: flex;
    align-items: baseline;
    gap: 8px 12px;
    flex-wrap: wrap;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--muted);
    font-size: 12px;
}

.fiscal-guidance strong {
    color: var(--ink);
    font-size: 13px;
}

.fee-autofill-feedback {
    color: var(--accent-ink);
    font-size: 12px;
    font-weight: 680;
}

.fee-value-control {
    position: relative;
}

.fee-value-control .form-control {
    padding-right: 42px;
}

.fee-value-control::after {
    align-items: center;
    bottom: 1px;
    color: var(--muted);
    content: attr(data-fee-unit);
    display: inline-flex;
    font-size: 12px;
    font-weight: 700;
    pointer-events: none;
    position: absolute;
    right: 10px;
    top: 1px;
}

.fee-value-control[data-fee-unit="%"]::after {
    color: var(--accent-ink);
}

.fee-autofill-pulse {
    animation: fee-autofill-pulse 1.1s ease-out;
}

@keyframes fee-autofill-pulse {
    0% {
        background: oklch(91% 0.055 184);
        border-color: var(--accent);
        box-shadow: 0 0 0 0 color-mix(in oklch, var(--accent) 32%, transparent);
    }

    45% {
        background: oklch(94% 0.04 184);
        border-color: var(--accent);
        box-shadow: 0 0 0 4px color-mix(in oklch, var(--accent) 18%, transparent);
    }

    100% {
        background: var(--panel);
        box-shadow: 0 0 0 0 transparent;
    }
}

.muted-text {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.inline-edit-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
}

.toolbar-form .form-select {
    width: min(320px, 100%);
}

.table-actions {
    flex-wrap: nowrap;
}

.table-action-col {
    width: 118px;
}

.user-table-action-col {
    width: 268px;
}

.action-check {
    color: var(--muted);
    margin-bottom: 0;
}

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

.data-table {
    font-size: 12px;
    line-height: 1.22;
    margin: 0;
    min-width: 960px;
}

.data-table th {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    border-bottom-color: var(--line);
    white-space: nowrap;
    padding: 7px 8px;
}

.data-table td {
    border-color: var(--line);
    max-width: 240px;
    overflow: hidden;
    padding: 7px 8px;
    text-overflow: ellipsis;
    vertical-align: middle;
    white-space: nowrap;
}

.profit-table td {
    vertical-align: top;
}

.profit-table td[data-label="Compra usada"] {
    white-space: normal;
}

.order-stack {
    display: grid;
    gap: 3px;
    min-width: 150px;
}

.order-stack span {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nfse-table td[data-label="Descricao"] {
    max-width: 360px;
}

.nfse-items-table.has-selection th:first-child,
.nfse-items-table.has-selection td:first-child {
    width: 86px;
    text-align: center;
}

.nfse-selection-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.nfse-queue-status {
    display: grid;
    gap: 14px;
}

.nfse-queue-status-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.nfse-queue-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    padding: 10px 12px;
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--muted);
    font-size: 13px;
}

.nfse-queue-facts strong {
    color: var(--ink);
}

.nfse-status-filter {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.nfse-status-filter .btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.nfse-status-filter .btn span {
    min-width: 20px;
    padding: 1px 6px;
    border-radius: 999px;
    background: color-mix(in oklch, currentColor 10%, transparent);
    font-size: 11px;
}

.nfse-history-table {
    min-width: 860px;
}

.nfse-history-table th:last-child,
.nfse-history-table td:last-child {
    position: sticky;
    right: 0;
    z-index: 1;
    min-width: 290px;
    max-width: none;
    border-left: 1px solid var(--line);
    background: var(--panel);
}

.nfse-history-table th:last-child {
    z-index: 2;
}

.nfse-history-table td[data-label="Arquivos"] {
    overflow: visible;
    white-space: normal;
}

.nfse-history-table td[data-label="Arquivos"] .table-actions {
    flex-wrap: wrap;
}

.nfse-description {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nfse-response-detail {
    max-width: 360px;
}

.nfse-response-detail summary {
    color: var(--accent);
    cursor: pointer;
    font-weight: 650;
}

.nfse-response-detail pre {
    max-height: 180px;
    margin: 8px 0 0;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 8px;
    font-size: 11px;
}

.empty-cell {
    color: var(--muted);
    text-align: center;
    padding: 28px !important;
}

.btn-primary {
    --bs-btn-bg: var(--accent);
    --bs-btn-border-color: var(--accent);
    --bs-btn-hover-bg: oklch(45% 0.13 184);
    --bs-btn-hover-border-color: oklch(45% 0.13 184);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 2px 8px;
    color: var(--muted);
    background: var(--surface);
    white-space: nowrap;
}

.progress-meter {
    min-width: 150px;
}

.progress-meter-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.25;
    margin-bottom: 5px;
}

.progress-meter-head strong {
    color: var(--ink);
    font-weight: 720;
}

.progress-track {
    height: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--line);
}

.progress-track span {
    display: block;
    height: 100%;
    min-width: 2px;
    border-radius: inherit;
    background: var(--accent);
    position: relative;
    transition: width 180ms ease-out;
}

.progress-meter-active .progress-track span {
    min-width: 22px;
    overflow: hidden;
}

.progress-meter-active .progress-track span::after {
    animation: progress-sheen 1.35s ease-out infinite;
    background: linear-gradient(90deg, transparent, color-mix(in oklch, var(--panel) 74%, transparent), transparent);
    content: "";
    inset: 0;
    position: absolute;
    transform: translateX(-100%);
}

.progress-meter-success .progress-track span {
    background: var(--success);
}

.progress-meter-failed .progress-track span {
    background: var(--danger);
}

.progress-meter-queued .progress-track span {
    background: var(--warning);
}

.progress-meter-memory .progress-detail {
    color: color-mix(in oklch, var(--muted) 78%, var(--accent));
}

.progress-detail {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.3;
    margin-top: 5px;
}

@keyframes progress-sheen {
    0% {
        transform: translateX(-100%);
    }

    65%,
    100% {
        transform: translateX(100%);
    }
}

.progress-status-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 16px;
}

.progress-status-item {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px;
    background: var(--surface);
}

.progress-status-title {
    color: var(--ink);
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 8px;
}

.report-toolbar {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.report-panel {
    margin-bottom: 22px;
}

.report-panel-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
}

.report-panel-head h2 {
    margin: 0;
    font-size: 1.04rem;
    font-weight: 740;
}

.report-kicker {
    color: var(--muted);
    font-size: 12px;
    font-weight: 680;
    margin-bottom: 3px;
}

.report-metric-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
}

.report-metric {
    min-width: 0;
    min-height: 78px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
}

.report-metric .metric-label {
    font-size: 11px;
    margin-bottom: 4px;
}

.report-metric .metric-value {
    font-size: 1.14rem;
    line-height: 1.12;
}

.report-metric .metric-sub {
    font-size: 11px;
    margin-top: 3px;
}

.report-result {
    background: color-mix(in oklch, var(--panel) 82%, oklch(91% 0.04 184));
}

.report-positive {
    color: var(--success);
}

.report-negative {
    color: var(--danger);
}

.login-screen {
    min-height: 100vh;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    align-items: center;
    justify-items: center;
    gap: 14px;
    padding: 20px;
    background:
        linear-gradient(135deg, oklch(95% 0.013 210), oklch(98% 0.006 190) 52%, oklch(92% 0.035 184));
}

.login-layout {
    width: min(980px, 100%);
    display: grid;
    grid-template-columns: minmax(0, 1.08fr) minmax(340px, 0.92fr);
    min-height: 560px;
    overflow: hidden;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 14px;
}

.login-brand-panel {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 48px;
    padding: 38px;
    color: oklch(27% 0.055 225);
    background: oklch(94% 0.024 198);
    border-right: 1px solid var(--line);
}

.login-logo {
    align-self: center;
    width: min(390px, 96%);
    height: auto;
}

.login-brand-panel h1 {
    max-width: 12ch;
    margin: 0 0 12px;
    font-size: 2.2rem;
    line-height: 1.05;
    font-weight: 760;
}

.login-brand-panel p,
.login-copy {
    color: var(--muted);
    line-height: 1.5;
    margin: 0;
}

.login-panel {
    width: 100%;
    align-self: center;
    background: var(--panel);
    border: 0;
    border-radius: 0;
    padding: 38px;
}

.login-screen > .login-panel {
    width: min(430px, 100%);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 30px;
}

.login-panel-logo {
    display: block;
    width: min(230px, 76%);
    height: auto;
    margin: 0 auto 22px;
}

.login-title {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 8px;
}

.login-copy {
    margin-bottom: 22px;
}

.login-links {
    display: flex;
    justify-content: center;
    margin-top: 16px;
    font-size: 13px;
}

.login-links a {
    color: var(--accent);
    text-decoration: none;
}

.login-links a:hover {
    text-decoration: underline;
}

.login-footer {
    width: 100%;
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
    text-align: center;
}

.dashboard-welcome,
.workflow-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.dashboard-welcome {
    padding: 24px;
    margin-bottom: 18px;
}

.dashboard-welcome h2 {
    max-width: 760px;
    margin: 0 0 8px;
    font-size: 1.45rem;
    font-weight: 760;
}

.dashboard-welcome p {
    max-width: 760px;
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.workflow-panel {
    padding: 20px;
}

.workflow-steps {
    display: grid;
    gap: 10px;
}

.workflow-step {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.workflow-step > span {
    width: 28px;
    height: 28px;
    display: inline-grid;
    place-items: center;
    border-radius: 50%;
    background: oklch(90% 0.055 184);
    color: var(--accent-ink);
    font-size: 12px;
    font-weight: 760;
}

.workflow-step h3 {
    margin: 0 0 4px;
    font-size: 0.98rem;
    font-weight: 720;
}

.workflow-step p {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.whatsapp-fab {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1050;
    width: 46px;
    height: 46px;
    display: inline-grid;
    place-items: center;
    border-radius: 50%;
    background: oklch(64% 0.16 154);
    color: oklch(98% 0.006 150);
    border: 1px solid oklch(58% 0.14 154);
    box-shadow: 0 10px 24px color-mix(in oklch, oklch(30% 0.04 154) 24%, transparent);
    text-decoration: none;
}

.whatsapp-fab:hover,
.whatsapp-fab:focus {
    color: oklch(98% 0.006 150);
    background: oklch(58% 0.15 154);
}

.whatsapp-fab i {
    font-size: 22px;
    line-height: 1;
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: sticky;
        z-index: 20;
        top: 0;
        height: auto;
        max-width: 100vw;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        padding: 10px 12px 12px;
    }

    .brand-mark {
        margin: 0 4px 10px;
    }

    .app-brand {
        margin: 0 4px 10px;
    }

    .brand-logo {
        width: 150px;
    }

    .sidebar .nav {
        flex-direction: row !important;
        gap: 6px;
        margin: 0 -12px;
        overflow-x: auto;
        padding: 0 12px 2px;
        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
    }

    .nav-section {
        display: none;
    }

    .nav-link {
        flex: 0 0 auto;
        min-height: 38px;
        padding: 8px 11px;
    }

    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .report-metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    body {
        font-size: 13px;
    }

    body.mobile-menu-open {
        overflow: hidden;
    }

    .sidebar {
        position: fixed;
        z-index: 1040;
        top: 0;
        bottom: 0;
        left: 0;
        width: min(304px, 86vw);
        height: 100dvh;
        max-width: none;
        padding: 16px 14px 18px;
        border-right: 1px solid var(--line);
        border-bottom: 0;
        box-shadow: 14px 0 34px color-mix(in oklch, var(--ink) 18%, transparent);
        transform: translateX(-105%);
        transition: transform 190ms ease-out;
        will-change: transform;
    }

    body.mobile-menu-open .sidebar {
        transform: translateX(0);
    }

    .mobile-menu-backdrop {
        position: fixed;
        z-index: 1035;
        inset: 0;
        display: block;
        background: color-mix(in oklch, var(--ink) 34%, transparent);
        opacity: 0;
        pointer-events: none;
        transition: opacity 160ms ease-out;
    }

    body.mobile-menu-open .mobile-menu-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .mobile-menu-close {
        position: absolute;
        top: 12px;
        right: 12px;
        width: 36px;
        height: 36px;
        display: inline-grid;
        place-items: center;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        background: var(--panel);
        color: var(--muted);
    }

    .app-brand {
        justify-content: flex-start;
        margin: 0 42px 16px 2px;
    }

    .brand-logo {
        width: 156px;
    }

    .sidebar .nav {
        flex-direction: column !important;
        gap: 2px;
        margin: 0;
        overflow: visible;
        padding: 0;
    }

    .nav-section {
        display: block;
    }

    .nav-link {
        width: 100%;
        min-height: 38px;
        border-radius: 7px;
        padding: 8px 10px;
    }

    .nav-link span {
        max-width: none;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .topbar {
        position: sticky;
        z-index: 1020;
        top: 0;
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        min-height: 0;
        padding: 14px 16px;
    }

    .topbar > div:first-of-type {
        min-width: 0;
    }

    .topbar h1 {
        font-size: 1.12rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        min-height: 38px;
        padding: 0 10px;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        background: var(--panel);
        color: var(--ink);
        font-weight: 650;
    }

    .user-chip {
        width: auto;
        justify-content: flex-end;
    }

    .user-chip span {
        max-width: calc(100vw - 96px);
    }

    .form-panel {
        padding: 14px;
    }

    .report-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .report-toolbar > div,
    .report-toolbar > .btn,
    .report-toolbar .download-actions {
        width: 100%;
    }

    .report-panel-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .form-actions:not(.table-actions),
    .download-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .form-actions:not(.table-actions) > .btn,
    .download-actions > .btn,
    .toolbar-form > .btn {
        width: 100%;
    }

    .toolbar-form .form-select {
        width: 100%;
    }

    .table-shell {
        overflow-x: visible;
        background: transparent;
        border: 0;
        border-radius: 0;
    }

    .data-table {
        display: block;
        font-size: 12px;
        min-width: 0;
        width: 100%;
        border-collapse: separate;
    }

    .data-table thead {
        display: none;
    }

    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block;
        width: 100%;
    }

    .data-table tr {
        margin-bottom: 8px;
        padding: 4px 8px;
        background: var(--panel);
        border: 1px solid var(--line);
        border-radius: var(--radius);
    }

    .data-table td {
        display: grid;
        grid-template-columns: minmax(92px, 34%) minmax(0, 1fr);
        gap: 10px;
        align-items: start;
        min-height: 30px;
        padding: 5px 0;
        border: 0;
        border-bottom: 1px solid var(--line);
        max-width: none;
        overflow: hidden;
        overflow-wrap: anywhere;
        text-overflow: clip;
        white-space: normal;
    }

    .data-table td:last-child {
        border-bottom: 0;
    }

    .data-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 11px;
        font-weight: 700;
        line-height: 1.25;
    }

    .data-table td.empty-cell {
        display: block;
        border: 1px solid var(--line);
        background: var(--panel);
    }

    .data-table td.empty-cell::before {
        content: "";
    }

    .table-actions {
        justify-content: flex-end;
        flex-wrap: wrap;
    }

    .data-table td[data-label="Acoes"] .table-actions {
        align-items: stretch;
        justify-content: stretch;
    }

    .data-table td[data-label="Arquivos"] .table-actions {
        align-items: stretch;
        justify-content: stretch;
    }

    .data-table td[data-label="Acoes"] .table-actions > * {
        flex: 1 1 120px;
    }

    .data-table td[data-label="Arquivos"] .table-actions > * {
        flex: 1 1 140px;
    }

    .data-table td[data-label="Acoes"] .btn {
        width: 100%;
    }

    .data-table td[data-label="Arquivos"] .btn {
        width: 100%;
    }

    .progress-status-grid {
        grid-template-columns: 1fr;
    }

    .certificate-summary {
        grid-template-columns: 1fr;
    }

    .nfse-description {
        white-space: normal;
    }

    .nfse-selection-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .nfse-queue-status-head {
        flex-direction: column;
    }

    .nfse-status-filter {
        width: 100%;
    }

    .nfse-status-filter .btn {
        flex: 1 1 140px;
        justify-content: center;
    }

    .nfse-history-table {
        min-width: 0;
    }

    .nfse-history-table th:last-child,
    .nfse-history-table td:last-child {
        position: static;
        min-width: 0;
        border-left: 0;
    }

    .data-table .form-control-sm,
    .data-table .form-select-sm {
        min-height: 36px;
    }

    .login-layout {
        grid-template-columns: 1fr;
        min-height: 0;
    }

    .login-brand-panel {
        padding: 26px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .login-brand-panel h1 {
        max-width: 100%;
        font-size: 1.65rem;
    }

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

@media (max-width: 560px) {
    body {
        background: var(--surface);
    }

    .sidebar {
        padding: 16px 14px 18px;
    }

    .app-brand {
        justify-content: flex-start;
        margin: 0 42px 16px 2px;
    }

    .topbar {
        align-items: center;
        min-height: 52px;
        padding: 10px 12px;
    }

    .topbar h1 {
        max-width: calc(100vw - 84px);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .user-chip {
        flex: 0 0 auto;
        gap: 6px;
        width: auto;
    }

    .user-chip > i,
    .user-chip span {
        display: none;
    }

    .user-chip .btn {
        width: 36px;
        height: 36px;
        display: inline-grid;
        place-items: center;
        padding: 0;
    }

    .page-body {
        padding: 12px 10px 82px;
    }

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

    .report-metric-grid {
        grid-template-columns: 1fr;
    }

    .brand-mark {
        font-size: 13px;
    }

    .brand-logo {
        width: 150px;
        margin: 0;
    }

    .brand-symbol {
        width: 30px;
        height: 30px;
    }

    .nav-link {
        border: 0;
        border-radius: 7px;
        background: transparent;
        gap: 7px;
        min-height: 38px;
        padding: 8px 10px;
    }

    .nav-link span {
        max-width: none;
        overflow: hidden;
        font-size: 12px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .nav-link.active {
        border-color: transparent;
    }

    .form-panel,
    .dashboard-welcome,
    .workflow-panel,
    .progress-status-item {
        padding: 13px;
    }

    .form-panel,
    .dashboard-welcome,
    .workflow-panel {
        margin-bottom: 12px;
    }

    .section-title {
        margin-bottom: 10px;
    }

    .dashboard-welcome h2 {
        font-size: 1.22rem;
    }

    .workflow-step {
        grid-template-columns: 30px minmax(0, 1fr);
        gap: 10px;
        padding: 10px;
    }

    .workflow-step > span {
        width: 26px;
        height: 26px;
    }

    .alert {
        padding: 10px 12px;
        font-size: 13px;
    }

    .form-control,
    .form-select,
    .btn {
        min-height: 42px;
    }

    .btn-sm {
        min-height: 36px;
    }

    .status-pill {
        min-height: 28px;
    }

    .progress-meter {
        min-width: 0;
        width: 100%;
    }

    .progress-meter-head {
        font-size: 11px;
    }

    .data-table tr {
        padding: 8px 10px;
    }

    .data-table td {
        grid-template-columns: minmax(82px, 32%) minmax(0, 1fr);
        min-height: 34px;
        padding: 7px 0;
    }

    .login-screen {
        padding: 12px;
    }

    .login-logo {
        width: 240px;
    }

    .login-panel {
        padding: 24px;
    }

    .login-panel-logo {
        width: 190px;
    }

    .whatsapp-fab {
        right: 14px;
        bottom: 14px;
        width: 44px;
        height: 44px;
    }
}

@media (max-width: 420px) {
    .brand-logo {
        width: 144px;
    }

    .sidebar .nav {
        gap: 5px;
        padding: 0;
    }

    .nav-link span {
        max-width: none;
    }

    .report-toolbar,
    .toolbar-form {
        gap: 8px;
    }

    .report-metric {
        min-height: 70px;
    }

    .data-table td {
        grid-template-columns: 1fr;
        gap: 3px;
    }

    .data-table td::before {
        font-size: 10px;
    }
}
