:root {
    --bg: #f6f7f2;
    --panel: #ffffff;
    --text: #1c2320;
    --muted: #64706a;
    --line: #dfe5dd;
    --primary: #16745f;
    --primary-dark: #0d5c4b;
    --accent: #c44834;
    --warning: #b7791f;
    --danger: #b42318;
    --shadow: 0 18px 45px rgba(32, 44, 38, .10);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.45;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
svg { width: 20px; height: 20px; flex: 0 0 auto; }

.auth-page {
    min-height: 100vh;
    background:
        linear-gradient(135deg, rgba(22, 116, 95, .92), rgba(196, 72, 52, .82)),
        url("../img/store-pattern.svg") center/420px;
}
.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.auth-panel {
    width: min(440px, 100%);
    background: rgba(255,255,255,.96);
    border: 1px solid rgba(255,255,255,.65);
    border-radius: 8px;
    padding: 28px;
    box-shadow: var(--shadow);
}
.brand-mark {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: #fff;
    background: var(--primary);
    margin-bottom: 18px;
}
.auth-panel h1 { margin: 0 0 8px; font-size: 1.8rem; }
.auth-panel p { margin: 0 0 22px; color: var(--muted); }
.app-footer {
    margin-top: 26px;
    padding: 16px 0 0;
    color: var(--muted);
    font-size: .86rem;
    text-align: center;
}
.auth-footer {
    border-top: 1px solid var(--line);
}
.desktop-footer {
    display: none;
}

.app-shell { min-height: 100vh; }
.sidebar {
    display: none;
    position: fixed;
    inset: 0 auto 0 0;
    width: 260px;
    padding: 22px;
    background: #fcfdf9;
    border-right: 1px solid var(--line);
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.1rem;
    margin-bottom: 28px;
}
.brand svg { color: var(--primary); }
.brand-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
    border-radius: 6px;
}
.sidebar nav { display: grid; gap: 8px; }
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #34423b;
}
.sidebar nav a:hover { background: #eef4ee; color: var(--primary-dark); }
.nav-with-badge { position: relative; }
.billing-badge {
    min-width: 22px;
    height: 22px;
    display: inline-grid;
    place-items: center;
    margin-left: auto;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--warning);
    color: #fff;
    font-size: .72rem;
    font-style: normal;
    line-height: 1;
}
.billing-badge.danger { background: var(--danger); }
.content {
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 18px 14px 148px;
}
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}
.topbar h1 { margin: 2px 0 0; font-size: clamp(1.35rem, 2.8vw, 2.2rem); }
.eyebrow {
    display: inline-block;
    color: var(--primary-dark);
    font-weight: 800;
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: 0;
}
.hero {
    display: grid;
    gap: 18px;
    background: linear-gradient(135deg, #0f6b59, #2b8a67 52%, #c44834);
    color: #fff;
    border-radius: 8px;
    padding: clamp(22px, 5vw, 38px);
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}
.hero .eyebrow { color: rgba(255,255,255,.82); }
.hero h2 { margin: 4px 0 8px; font-size: clamp(1.8rem, 5vw, 3.2rem); }
.hero p { max-width: 620px; margin: 0; color: rgba(255,255,255,.9); }
.hero-actions, .action-row, .form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.panel, .metric {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(25, 34, 30, .06);
}
.panel { padding: 16px; margin-bottom: 16px; }
.narrow { max-width: 760px; }
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.metric {
    padding: 16px;
    display: grid;
    gap: 8px;
    min-height: 128px;
}
.metric svg { color: var(--primary); }
.metric span { color: var(--muted); font-size: .92rem; }
.metric strong { font-size: clamp(1.35rem, 3vw, 1.9rem); }
.metric.danger svg, .metric.danger strong { color: var(--danger); }
.metric.warning svg, .metric.warning strong { color: var(--warning); }
.compact .metric { min-height: 96px; }
.two-columns { display: grid; gap: 16px; }
.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.section-title h2 { margin: 0; font-size: 1.1rem; }
.section-title a, .section-title span { color: var(--muted); font-size: .92rem; }

.button, .icon-button {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    border-radius: 8px;
    min-height: 44px;
    padding: 10px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 750;
}
.button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.button.primary:hover { background: var(--primary-dark); }
.button.light { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.42); color: #fff; }
.button.danger { color: var(--danger); border-color: #f0c8c4; }
.button.small { min-height: 36px; padding: 7px 10px; font-size: .9rem; }
.icon-button { width: 44px; padding: 0; }
.link { color: var(--primary-dark); font-weight: 750; }

.form-stack, .form-grid, .filter-bar { display: grid; gap: 14px; }
.form-grid { grid-template-columns: 1fr; }
.filter-bar {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    align-items: end;
    margin-bottom: 14px;
}
.inline-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    align-items: end;
    margin-bottom: 16px;
}
label { display: grid; gap: 6px; color: #3c4943; font-weight: 720; }
label small { color: var(--muted); font-weight: 500; }
input, textarea, select {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    padding: 10px 12px;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus {
    outline: 3px solid rgba(22, 116, 95, .18);
    border-color: var(--primary);
}
.password-field {
    position: relative;
    display: block;
}
.password-field input {
    padding-right: 52px;
}
.password-toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}
.password-toggle:hover,
.password-toggle:focus-visible {
    background: #eef4ee;
    color: var(--primary-dark);
}
.password-toggle:focus-visible {
    outline: 3px solid rgba(22, 116, 95, .18);
}
.check-row { display: flex; align-items: center; gap: 10px; }
.check-row input { width: 18px; min-height: 18px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: 0; }
td small { display: block; color: var(--muted); margin-top: 2px; }
.actions { text-align: right; white-space: nowrap; }
.category-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.list { display: grid; gap: 8px; }
.list-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.list-row:hover { border-color: var(--primary); }
.client-head {
    display: grid;
    gap: 16px;
    align-items: start;
}
.client-head h2 { margin: 0 0 4px; font-size: 1.7rem; }
.client-head p { margin: 2px 0; color: var(--muted); }
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    align-items: start;
}
.logo-settings {
    display: grid;
    gap: 16px;
}
.logo-preview {
    width: 132px;
    height: 132px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcf8;
    overflow: hidden;
}
.logo-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 10px;
}
.logo-preview svg {
    width: 46px;
    height: 46px;
    color: var(--primary);
}
.toast-region {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 80;
    display: grid;
    gap: 10px;
    width: min(420px, calc(100vw - 28px));
    pointer-events: none;
}
.toast {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 34px;
    gap: 12px;
    align-items: start;
    padding: 14px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--primary);
    border-radius: 8px;
    background: rgba(255,255,255,.98);
    color: var(--text);
    box-shadow: var(--shadow);
    pointer-events: auto;
    animation: toast-in .2s ease-out;
}
.toast.is-leaving {
    animation: toast-out .18s ease-in forwards;
}
.toast-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #eef4ee;
    color: var(--primary-dark);
}
.toast-content {
    display: grid;
    gap: 4px;
    min-width: 0;
}
.toast-content strong {
    font-size: .96rem;
}
.toast-content p {
    margin: 0;
    color: var(--muted);
    font-size: .92rem;
}
.toast-close {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
}
.toast-close:hover,
.toast-close:focus-visible {
    background: #f1f4f0;
    color: var(--text);
}
.toast-success { border-left-color: var(--primary); }
.toast-error { border-left-color: var(--danger); }
.toast-error .toast-icon { background: #fff1ef; color: var(--danger); }
.toast-warning,
.toast-confirm { border-left-color: var(--warning); }
.toast-warning .toast-icon,
.toast-confirm .toast-icon { background: #fff7e6; color: var(--warning); }
.toast-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}
.toast-action {
    min-height: 36px;
    padding: 7px 12px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font-weight: 750;
}
.toast-action.danger {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}
@keyframes toast-in {
    from { opacity: 0; transform: translateY(-8px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toast-out {
    to { opacity: 0; transform: translateY(-6px) scale(.98); }
}
.empty-state, .empty-inline {
    display: grid;
    place-items: center;
    text-align: center;
    gap: 8px;
    padding: 28px 16px;
    color: var(--muted);
}
.empty-state svg { width: 42px; height: 42px; color: var(--primary); }
.empty-state h2 { color: var(--text); margin: 0; }
.empty-state p { margin: 0; }

.bottom-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: block;
    padding: 8px max(8px, env(safe-area-inset-left)) calc(8px + env(safe-area-inset-bottom));
    background: rgba(252,253,249,.96);
    border-top: 1px solid var(--line);
    box-shadow: 0 -14px 30px rgba(25, 34, 30, .08);
}
.bottom-links {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 2px;
}
.bottom-links a {
    position: relative;
    min-height: 58px;
    display: grid;
    place-items: center;
    gap: 3px;
    border-radius: 8px;
    color: #3f4d46;
    font-size: .68rem;
    font-weight: 760;
}
.bottom-links .billing-badge {
    position: absolute;
    top: 1px;
    right: calc(50% - 22px);
    margin: 0;
}
.bottom-links a:hover { background: #eef4ee; color: var(--primary-dark); }
.bottom-credit {
    display: block;
    padding: 5px 8px 2px;
    color: var(--muted);
    font-size: .78rem;
    text-align: center;
    line-height: 1.2;
}
.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    margin-left: 8px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 800;
    vertical-align: middle;
}
.status-badge.overdue {
    background: #fff1ef;
    color: var(--danger);
}
.import-preview {
    max-width: 980px;
}
.validation-list {
    display: grid;
    gap: 6px;
    margin-bottom: 16px;
    padding: 14px;
    border: 1px solid var(--line);
    border-left: 4px solid var(--warning);
    border-radius: 8px;
}
.validation-list p {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin: 0;
    color: var(--muted);
}
.validation-list p svg {
    width: 18px;
    height: 18px;
    margin-top: 1px;
}
.error-list {
    border-left-color: var(--danger);
    background: #fff8f7;
}
.error-list p svg { color: var(--danger); }
.warning-list {
    background: #fffbf2;
}
.warning-list p svg { color: var(--warning); }
.import-client-data {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
    padding: 4px 0 18px;
    border-bottom: 1px solid var(--line);
}
.import-client-data div {
    display: grid;
    gap: 3px;
}
.import-client-data span {
    color: var(--muted);
    font-size: .82rem;
}
.import-confirm {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    margin-top: 18px;
}
.import-confirm p {
    margin: 0;
    color: var(--muted);
}
.billing-disabled,
.billing-alert {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}
.billing-disabled svg,
.billing-alert svg {
    width: 30px;
    height: 30px;
    color: var(--primary);
}
.billing-disabled h2,
.billing-alert p { margin: 0; }
.billing-disabled p { margin: 4px 0 0; color: var(--muted); }
.billing-alert {
    margin-bottom: 16px;
    padding: 14px;
    border: 1px solid #f0c8c4;
    border-left: 4px solid var(--danger);
    border-radius: 8px;
    background: #fff8f7;
}
.billing-alert svg { color: var(--danger); }
.billing-alert p { color: var(--muted); }
.billing-options {
    display: grid;
    gap: 12px;
}
.billing-option {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.billing-option > svg { color: var(--primary); }
.billing-option h3,
.billing-option p { margin: 0; }
.billing-option p { margin-top: 3px; color: var(--muted); }
.billing-option form {
    grid-column: 1 / -1;
}
.invoice-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    align-items: end;
}
.invoice-summary div { display: grid; gap: 3px; }
.invoice-summary span,
.muted-copy { color: var(--muted); }
.pix-payment {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 12px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}
.pix-qr-code {
    width: min(220px, 100%);
    aspect-ratio: 1;
    object-fit: contain;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}
.pix-copy-field {
    display: grid;
    flex: 1 1 320px;
    gap: 6px;
}
.pix-copy-field textarea {
    width: 100%;
    resize: vertical;
    overflow-wrap: anywhere;
}
.blocked-screen {
    min-height: 62vh;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 12px;
    text-align: center;
}
.blocked-screen h2,
.blocked-screen p { margin: 0; }
.blocked-screen p { color: var(--muted); }
.blocked-icon {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #fff1ef;
    color: var(--danger);
}
.blocked-icon svg { width: 30px; height: 30px; }

@media (min-width: 760px) {
    .content { padding: 24px 24px 148px; }
    .hero { grid-template-columns: 1fr auto; align-items: end; }
    .two-columns { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .client-head { grid-template-columns: 1fr auto; }
}

@media (max-width: 759px) {
    .responsive-table {
        overflow: visible;
    }
    .responsive-table table,
    .responsive-table tbody,
    .responsive-table tr,
    .responsive-table td {
        display: block;
        width: 100%;
        min-width: 0;
    }
    .responsive-table table {
        min-width: 0;
    }
    .responsive-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
    .responsive-table tbody {
        display: grid;
        gap: 10px;
    }
    .responsive-table tr {
        padding: 6px 12px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: #fff;
    }
    .responsive-table td {
        display: grid;
        grid-template-columns: minmax(92px, 38%) minmax(0, 1fr);
        gap: 12px;
        align-items: start;
        padding: 8px 0;
        border-bottom: 1px solid var(--line);
        text-align: right;
        overflow-wrap: anywhere;
    }
    .responsive-table td:last-child {
        border-bottom: 0;
    }
    .responsive-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: .76rem;
        font-weight: 800;
        text-align: left;
        text-transform: uppercase;
    }
}

@media (min-width: 900px) {
    .sidebar { display: block; }
    .content { margin-left: 260px; width: calc(100% - 260px); max-width: 1240px; padding: 28px 32px 40px; }
    .desktop-footer { display: block; }
    .bottom-bar { display: none; }
}

@media print {
    .sidebar, .bottom-bar, .topbar, .button, .filter-bar { display: none !important; }
    .content { margin: 0; width: 100%; padding: 0; }
    .panel { box-shadow: none; break-inside: avoid; }
}
