@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=Manrope:wght@400;500;600;700&display=swap');

:root {
    --bg: #0b0b0f;
    --bg-grad1: rgba(225, 181, 92, 0.08);
    --bg-grad2: rgba(247, 212, 131, 0.08);
    --surface: #13131a;
    --card: #191922;
    --gold: #e1b55c;
    --gold-strong: #f7d483;
    --text: #f6f6f6;
    --muted: #a3a5b0;
    --border: rgba(255, 255, 255, 0.08);
    --danger: #ff6b6b;
    --success: #7bd88f;
    --hero-highlight: rgba(225, 181, 92, 0.12);
    --hero-overlay: rgba(19, 19, 26, 0.8);
}

:root[data-theme="light"] {
    --bg: #f5f6fb;
    --bg-grad1: rgba(215, 169, 76, 0.12);
    --bg-grad2: rgba(234, 196, 107, 0.12);
    --surface: #ffffff;
    /*--card: #f0f1f7;*/
    --card: #fefcfa;
    --text: #0f0f12;
    --muted: #5b5e6a;
    --border: rgba(0, 0, 0, 0.08);
    --gold: #d7a94c;
    --gold-strong: #eac46b;
    --danger: #d04242;
    --success: #2f9e5b;
    --hero-highlight: rgba(215, 169, 76, 0.15);
    --hero-overlay: rgba(255, 255, 255, 0.92);
}

.text-success {
    color: #2f9e5b !important;
}

.text-danger {
    color: var(--danger) !important;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: radial-gradient(circle at 20% 20%, var(--bg-grad1), transparent 25%), radial-gradient(circle at 80% 0%, var(--bg-grad2), transparent 20%), var(--bg);
    color: var(--text);
    font-family: 'Manrope', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

.shell {
    padding: 0 24px 40px;
}

.shell-blank,
.login-shell {
    display: grid;
    place-items: center;
    min-height: 100vh;
    background: linear-gradient(145deg, #0e0e14, #09090d);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    margin: 12px 0 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    backdrop-filter: blur(8px);
}

.nav-toggle {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text);
    font-weight: 700;
    cursor: pointer;
}

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

.brand-mark {
    background: linear-gradient(135deg, var(--gold), var(--gold-strong));
    color: #000;
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: 700;
    letter-spacing: 1px;
    font-family: 'Playfair Display', serif;
}

.brand-mark.large {
    padding: 14px 18px;
    font-size: 22px;
}

.brand-name {
    font-weight: 700;
    font-family: 'Playfair Display', serif;
    letter-spacing: 0.6px;
}

.brand-sub {
    color: var(--muted);
    font-size: 12px;
}

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

.nav-links a {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid transparent;
    color: var(--muted);
    transition: all 0.2s ease;
}

.nav-links a:hover {
    color: var(--text);
    border-color: var(--border);
    background: rgba(255, 255, 255, 0.04);
}

.nav-links a.active {
    color: var(--text);
    border-color: var(--border);
    background: rgba(255, 255, 255, 0.08);
    font-weight: 700;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--card);
    border: 1px solid var(--border);
    font-size: 13px;
    white-space: nowrap;
    width: fit-content;
    justify-self: end;
}

.chip-action {
    color: var(--gold);
    font-weight: 600;
}

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

.content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.flash {
    display: grid;
    gap: 10px;
}

.flash-item {
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card);
}

.flash-item.success {
    border-color: var(--success);
    color: var(--success);
}

.flash-item.error {
    border-color: var(--danger);
    color: var(--danger);
}

.hero {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 18px;
    align-items: center;
    padding: 20px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: linear-gradient(135deg, var(--hero-highlight), var(--hero-overlay));
}

.hero h1 {
    margin: 8px 0;
    font-size: 28px;
    letter-spacing: -0.5px;
}

.hero-card {
    padding: 16px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border);
}

.hero-card-title {
    font-weight: 700;
    margin-bottom: 10px;
}

.hero-list {
    padding-left: 16px;
    color: var(--muted);
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}

.stat-card {
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
}

.stat-card.compact {
    min-width: 0;
    height: 100%;
}

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

.stat-value {
    font-size: 24px;
    font-weight: 700;
    display: block;
    margin-top: 6px;
}

.stat-sub {
    color: var(--muted);
    font-size: 11px;
}

.delta {
    margin-top: 6px;
    font-weight: 700;
    font-size: 13px;
}

.delta.up {
    color: var(--success);
}

.delta.down {
    color: var(--danger);
}

.panels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.panel {
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--card, #fff);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.panel.soft {
    background: var(--card, #fff);
}

.panel.compact,
.card,
.sale-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card, #fff);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.panel.compact {
    padding: 12px 14px;
}

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

.panel-actions {
    display: inline-flex;
    align-items: flex-start;
    gap: 10px;
}

.filter-grid-desktop {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin: 6px 0 12px;
    align-items: end;
}

.filter-grid-desktop label {
    display: grid;
    gap: 4px;
}

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

@media (max-width: 768px) {
    .panel-head.stack-on-mobile {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .filter-mobile {
        width: 100%;
    }

    .filter-grid-mobile {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
        width: 100%;
    }

    .filter-grid-mobile label {
        display: grid;
        gap: 4px;
        width: 100%;
    }

    .filter-actions-mobile {
        display: flex;
        gap: 8px;
        justify-content: flex-start;
        width: 100%;
    }

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

.panel-actions-column {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-end;
    text-align: right;
}

.total-count {
    color: var(--muted);
    font-size: 12px;
}

.list {
    display: grid;
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.list-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
}

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

.sale-row {
    align-items: flex-start;
}

.sale-info {
    display: grid;
    gap: 4px;
}

.meta-line {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    flex-wrap: wrap;
}

.meta-label {
    color: var(--muted);
    font-weight: 700;
}

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

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

.birthdays-list {
    gap: 8px;
}

.birthday-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
}

.birthday-info {
    display: grid;
    gap: 6px;
}

.birthday-meta {
    display: grid;
    gap: 4px;
    align-items: start;
}

.birthday-actions {
    display: grid;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.birthday-status-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.birthday-badge {
    display: grid;

}

.birthday-row .message-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4px 10px;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 6px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 12px;
    min-width: 75px;
    text-align: center;
}

.stock-badge {
    display: inline-flex;
    justify-content: center;
}

.badge.danger {
    color: var(--danger);
    border-color: var(--danger);
}

.badge.dark {
    background: var(--surface);
}

.badge.success {
    color: var(--success);
    border-color: var(--success);
    text-align: center !important;
}

.badge.warning {
    color: #e1b55c;
    border-color: #e1b55c;
}

.btn {
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    padding: 10px 14px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.btn.edit-btn {
    background: linear-gradient(135deg, var(--gold), var(--gold-strong));
    color: #000;
    border-color: transparent;
}

.btn.cancel-btn {
    border-color: var(--danger);
    color: var(--danger);
    background: rgba(220, 38, 38, 0.08);
}

.btn.cancel-btn:hover {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

.btn.receipt-btn {
    border-color: rgba(148, 163, 184, 0.7);
    color: var(--muted);
    background: #fff;
}

.btn.receipt-btn:hover {
    background: rgba(148, 163, 184, 0.12);
    border-color: rgba(148, 163, 184, 0.9);
}

.table-actions .btn[data-action="editar"] {
    background: linear-gradient(135deg, var(--gold), var(--gold-strong));
    color: #000;
    border-color: transparent;
}

.table-actions .btn[data-action="cancelar"] {
    background: linear-gradient(135deg, var(--gold), var(--gold-strong));
    color: #000;
    border-color: transparent;
}

.table-actions .btn[data-action="cancelar"]:hover {
    background: linear-gradient(135deg, var(--gold), var(--gold-strong));
    color: #000;
}

.table-actions .btn[data-action="upload"] {
    background: linear-gradient(135deg, var(--gold), var(--gold-strong));
    color: #000;
    border-color: transparent;
}

.table-actions .btn[data-action="upload"]:hover {
    background: linear-gradient(135deg, var(--gold), var(--gold-strong));
    color: #000;
}

.btn.primary {
    background: linear-gradient(135deg, var(--gold), var(--gold-strong));
    color: #000;
    border: none;
}

.btn.ghost {
    background: rgba(255, 255, 255, 0.04);
}

.filters-row .btn {
    padding: 7px 12px;
}

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

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 11px;
    color: var(--gold);
    margin: 0;
}

.lede {
    color: var(--muted);
    margin: 4px 0 0;
}

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

.section-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.receipt-installments {
    margin-left: auto;
    margin-right: auto;
    width: 90%;
    background: #fafafa;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    padding: 12px 14px;
    margin-top: 10px;
    margin-bottom: 20px;
}

.installment-line {
    display: grid;
    grid-template-columns: auto auto auto;
    column-gap: 4px;
    font-size: 12px;
    line-height: 1.3;
    padding: 2px 0;
    border-bottom: 1px dotted #ddd;
}

.installment-line:last-child {
    border-bottom: none;
}

.installment-number {
    font-weight: 600;
    white-space: nowrap;
}

.installment-date,
.installment-amount {
    white-space: nowrap;
    color: #333;
}

.installment-amount {
    font-weight: 500;
}

.chip {
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--gold);
}

.two-col {
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    gap: 16px;
}

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

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
}

input,
select,
textarea {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    font-family: 'Manrope', system-ui, -apple-system, sans-serif;
}

textarea {
    min-height: 90px;
    resize: vertical;
}

.sale-form option,
.sale-form select option,
.modal select option {
    background: var(--card);
    color: var(--text);
}

.filter select option {
    background: var(--card);
    color: var(--text);
}

.filter select {
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
}

.helper {
    color: var(--muted);
    font-size: 12px;
    margin: 0;
}

.table {
    /* border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;*/
    padding: 3px;
}

.table-head,
.table-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    padding: 10px 12px;
    align-items: center;
}

.table-head {
    background: rgba(255, 255, 255, 0.04);
    font-weight: 600;
}

.table-head.faint {
    background: transparent;
    color: var(--muted);
}

.table-row:not(:last-child) {
    border-top: 1px solid var(--border);
}

.table-customers .table-head,
.table-customers .table-row {
    grid-template-columns: 1.15fr 1.05fr 0.95fr 0.9fr 0.9fr 0.85fr 0.9fr 0.85fr 0.75fr;
}

.table-customers .table-row {
    border-top: 1px solid var(--border);
}

.table-products .table-head,
.table-products .table-row {
    grid-template-columns: 0.9fr 2fr 0.9fr 0.9fr 0.85fr 0.85fr 0.9fr 0.9fr 0.8fr;
    gap: 8px;
    min-height: 44px;
    align-items: center;
}

.table-products .table-head span,
.table-products .table-row span {
    text-align: left;
    justify-self: flex-start;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-products .table-head span:nth-child(2),
.table-products .table-row span:nth-child(2) {
    white-space: normal;
    word-break: break-word;
}

.table-products .table-row {
    border-top: 1px solid var(--border);
}

.auto-expenses-section {
    /* border: 1px solid var(--border);*/
    border-radius: 12px;
    /*padding: 12px;*/
    background: rgba(255, 255, 255, 0.02);
    display: grid;
    gap: 10px;
}

.auto-expenses-section .section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.auto-expenses-section .table-head,
.auto-expenses-section .table-row {
    display: grid;
    grid-template-columns: 0.9fr 1.3fr 0.75fr 0.6fr 0.85fr;
    align-items: center;
    gap: 6px;
}

.auto-expenses-section .table-head span,
.auto-expenses-section .table-row span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.auto-expenses-section .table-row span:nth-child(2) {
    white-space: normal;
    word-break: break-word;
}

.auto-expenses-section .table-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: nowrap;
}

.toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    grid-column: 1 / -1;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    justify-content: flex-start;
}

.toggle-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--gold);
}

.toggle-row span {
    line-height: 1.4;
}

.table-actions {
    display: flex;
    justify-content: flex-start;
}

.table-products .table-head span:last-child {
    text-align: left;
}

.table-despesas .table-head,
.table-despesas .table-row {
    grid-template-columns: 1.3fr 1fr 2fr 1fr 0.9fr 0.8fr 1fr 1fr;
    gap: 8px;
    min-height: 48px;
    align-items: center;
}

.table-despesas .table-head span,
.table-despesas .table-row span {
    text-align: left;
    justify-self: left;
    white-space: normal;
    overflow: visible;
    text-overflow: ellipsis;
}

.type-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.type-icon {
    font-size: 18px;
}

.status-pill {
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 12px;
    font-weight: 600;
}

.status-pill.ativo {
    color: var(--success);
    border-color: rgba(0, 0, 0, 0.2);
    background: rgba(88, 216, 150, 0.12);
}

.status-pill.cancelado {
    color: var(--danger);
    border-color: rgba(0, 0, 0, 0.2);
    background: rgba(255, 107, 107, 0.15);
}

.comprovante-link {
    color: var(--gold);
    font-weight: 600;
}

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

.despesa-pagination .pagination-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.visually-hidden {
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    height: 1px;
    width: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
}

@media (max-width: 900px) {

    .table-despesas .table-head,
    .table-despesas .table-row {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }
}

.table-customers .table-head span:last-child {
    text-align: left;
}

.table-payments .table-head,
.table-payments .table-row {
    grid-template-columns: 1.2fr 0.7fr 1.2fr 0.8fr 0.9fr 0.8fr 0.9fr 0.7fr 0.9fr 0.9fr 0.9fr;
    align-items: center;
}

.ranking-table .table-head,
.ranking-table .table-row {
    grid-template-columns: 1fr 0.6fr 0.8fr;
    align-items: start;
    justify-items: start;
}

.ranking-table .table-head span,
.ranking-table .table-row span {
    text-align: left;
    justify-self: start;
    white-space: normal;
}

.ranking-table .table-head span:nth-child(2),
.ranking-table .table-head span:nth-child(3),
.ranking-table .table-row span:nth-child(2),
.ranking-table .table-row span:nth-child(3) {
    justify-self: start;
    text-align: left;
}

.ranking-table .table-head {
    border-bottom: none;
}

.ranking-table .table-row {
    border-bottom: 1px solid var(--border);
}

.ranking-table .table-row:first-of-type {
    border-top: 1px solid var(--border);
}

.ranking-table .table-row:last-child {
    border-bottom: none;
}

.btn.small {
    padding: 8px 10px;
    font-size: 13px;
}

.sale-form select,
.sale-form input {
    background: var(--card);
}

/* Evita zoom automático em inputs no iOS (fonte >=16px) */
@media (max-width: 640px) {

    input,
    select,
    textarea {
        font-size: 16px;
    }
}

#dateFields input[type="date"] {
    width: 90%;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card);
    font-size: 16px;
}

.sale-stack {
    display: grid;
    gap: 12px;
    margin-top: -8px;
}

.sale-card {
    display: grid;
    gap: 8px;
}

.sale-card.compact {
    padding: 10px;
}

.sale-card .panel-head {
    margin-bottom: 6px;
}

.compact-field span {
    font-size: 13px;
}

.form-alert {
    color: var(--danger);
    font-size: 13px;
    margin: 2px 0 0;
}

.modal-backdrop .modal .form-alert {
    margin: 0 0 8px;
}

.form-alert.warning {
    color: var(--gold);
}

.badge.warning {
    color: var(--gold);
    border-color: var(--gold);
}

.table-products .badge {
    padding: 4px 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 22px;
}

.customer-meta-badge {
    margin-left: auto;
    justify-self: flex-end;
    margin-left: 12px;
    margin-right: 0;
}

.helper#customerMeta {
    display: none;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    justify-content: space-between;
}

.customer-meta-info {
    flex: 1;
    min-width: 0;
}

.modal-center {
    max-width: 520px;
    margin: 0 auto;
}

.form-alert-strong {
    font-size: 15px;
    font-weight: 600;
}

.installments-field,
.pix-field {
    display: block;
}

.pix-field {
    display: none;
}

.item-head {
    display: grid;
    grid-template-columns: 2fr 0.75fr 0.95fr 0.85fr 0.85fr 1fr 0.75fr 0.7fr 0.6fr;
    gap: 8px;
    padding: 10px 0px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    font-weight: 600;
    color: var(--muted);
}

.item-list {
    display: grid;
    gap: 10px;
}

.item-row {
    display: grid;
    grid-template-columns: 2fr 0.75fr 0.95fr 0.85fr 0.85fr 1fr 0.75fr 0.7fr 0.6fr;
    gap: 8px;
    align-items: center;
    padding: 10px 0;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.product-cell {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-start;
    min-width: 0;
}

.product-cell select {
    flex: 1 1 auto;
    min-width: 0;
}

.stock-cell {
    display: flex;
    align-items: center;
    justify-content: center;
}

.stock-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-start;
    text-align: left;
}

.product-cell .stock-badge,
.stock-actions .stock-badge {
    flex: 0 0 auto;
    white-space: nowrap;
    align-self: center;
    margin-left: 0;
}

.item-row select,
.item-row input,
.item-row .discount-cell input {
    padding: 10px 12px;
    background: var(--surface);
}

.item-row .col-qtd input {
    max-width: 90px;
    width: 100%;
    justify-self: start;
}

.discount-value-cell {
    display: block;
}

.discount-value-text {
    font-size: 0.95rem;
}

.discount-cell {
    display: block;
}

.item-price,
.item-subtotal {
    text-align: left;
    font-weight: 600;
}

@media (min-width: 901px) {

    .item-price .label,
    .item-subtotal .label {
        display: none;
    }

    .item-price,
    .item-subtotal {
        display: block;
    }
}

.item-summary {
    margin-top: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    font-weight: 600;
}

.stock-badge {
    white-space: nowrap;
    font-size: 12px;
}

.stock-ok {
    color: var(--success);
    border-color: var(--success);
}

.stock-low {
    color: var(--gold);
    border-color: var(--gold);
}

.stock-zero {
    color: var(--danger);
    border-color: var(--danger);
}

.sale-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
}

.top-actions {
    justify-content: flex-end;
    margin-top: -4px;
}

.receipt {
    max-width: 960px;
    margin: 0 auto;
}

.receipt-paper {
    width: 300px;
    max-width: 300px;
    margin: 0 auto;
    padding: 14px;
    border-radius: 12px;
    line-height: 1.2;
}

.receipt-head {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    margin-bottom: 8px;
}

.receipt-head h1 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.2;
}

.print-btn {
    align-self: flex-end;
}

.receipt-head-info {
    text-align: center;
    width: 100%;
}

.receipt-meta {
    display: grid;
    gap: 6px;
    margin: 8px 0;
}

.receipt-title {
    font-weight: 600;
    font-size: 1rem;
    margin: 0;
    text-align: center;
}

.receipt-subtitle {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
}

.receipt-line {
    font-size: 0.88rem;
    font-weight: 400;
    line-height: 1.2;
}

.receipt-line-small {
    font-size: 0.75rem;
    font-weight: 400;
    color: #777;
    line-height: 1.2;
}

.receipt-total-label {
    font-size: 0.95rem;
    font-weight: 700;
}

.receipt-total-value {
    font-size: 1rem;
    font-weight: 700;
}

.receipt-customer strong {
    font-size: 0.95rem;
}

.receipt-items {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.02);
    display: grid;
    gap: 8px;
    margin-top: 8px;
}

.receipt-items-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
}

.receipt-item-row {
    display: grid;
    gap: 4px;
    padding-top: 6px;
    border-top: 1px dashed var(--border);
    margin-bottom: 6px;
}

.receipt-item-row:first-of-type {
    border-top: none;
    padding-top: 0;
}

.receipt-item-left {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 0.75rem;
    color: #777;
}

.receipt-item-name {
    font-weight: 500;
    font-size: 0.88rem;
    width: 100%;
    margin: 0;
}

.receipt-item-detail,
.receipt-item-discount-left {
    font-size: 0.75rem;
    color: #777;
}

.receipt-item-discount-left {
    font-weight: 500;
}

.receipt-item-discount-left.receipt-discount-positive {
    color: #16a34a;
    font-weight: 600;
}

.receipt-item-discount-right {
    font-size: 0.75rem;
    color: #777;
}

.receipt-item-total {
    white-space: nowrap;
    font-weight: 600;
    font-size: 0.88rem;
    text-align: right;
}


.receipt-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.receipt-totals {
    margin: 12px 0 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.02);
    display: grid;
    gap: 6px;
}

.totals-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.88rem;
}

.totals-line span:last-child {
    font-weight: 700;
}

.receipt-discount-positive {
    color: #16a34a;
    font-weight: 700;
}

.totals-separator {
    height: 1px;
    border-top: 1px solid #eee;
    margin: 6px 0 4px;
}

.totals-strong {
    font-weight: 700;
    font-size: 0.95rem;
}

.totals-strong span:last-child {
    font-size: 1rem;
    font-weight: 700;
}

.receipt-summary {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

/* Versão mais estreita para impressão térmica / parcelamento longo */
@media print {
    body {
        background: #fff;
    }

    .shell {
        padding: 0;
    }

    .panel.receipt {
        box-shadow: none;
        border: none;
    }

    .receipt,
    .receipt-paper {
        width: 300px;
        max-width: 300px;
        padding: 0;
        margin: 0 auto;
        font-size: 12px;
    }

    .receipt-head button,
    .topbar,
    .nav-links,
    .user-chip,
    .chip,
    .panel-actions,
    .panel-head .helper,
    .btn,
    .flash {
        display: none !important;
    }

    .receipt-items,
    .receipt-totals {
        border-radius: 0;
        padding: 8px;
    }

    .receipt-items-head,
    .receipt-item-row {
        font-size: 12px;
    }

    .totals-line,
    .totals-strong {
        font-size: 12px;
    }

    .totals-strong span:last-child {
        font-size: 14px;
    }

    .qr.receipt-qr img {
        max-width: 140px;
        height: auto;
    }
}

.receipt-summary .total {
    padding: 12px 14px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
}

.qr {
    margin-top: 14px;
    padding: 12px;
    border-radius: 12px;
    border: 1px dashed var(--border);
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    max-width: 100%;
}

.qr img {
    background: #fff;
    padding: 6px;
    border-radius: 8px;
    width: 150px;
    height: 150px;
    flex-shrink: 0;
    object-fit: contain;
    display: block;
}

.qr div {
    flex: 1;
    min-width: 0;
}

.qr.qr-vertical {
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.qr-vertical .pix-qr-box {
    width: 180px;
    height: 180px;
    max-width: 100%;
    margin: 8px auto 0;
}

.qr-vertical .pix-qr-box canvas,
.qr-vertical .pix-qr-box img {
    width: 180px !important;
    height: 180px !important;
}

.pix-qr-box canvas {
    width: 150px !important;
    height: 150px !important;
}

.pix-qr-box {
    padding: 12px;
    display: flex;
    justify-content: center;
}

.pix-qr-box img,
.pix-qr-box canvas {
    max-width: 170px;
    width: 100%;
    height: auto;
}

.pix-code-box {
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
    font-size: 0.75rem;
    max-width: 100%;
    overflow-wrap: anywhere;
}

.qr .eyebrow {
    color: var(--text);
    font-size: 12px;
}

.qr h3 {
    color: var(--text);
    font-size: 18px;
    margin: 0 0 6px;
}

.login-card {
    width: min(440px, 92vw);
    padding: 24px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--surface);
    display: grid;
    gap: 12px;
}

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

.hero-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.list-row .btn {
    padding: 8px 10px;
}

.list-row .badge {
    background: rgba(225, 181, 92, 0.1);
    white-space: nowrap;
    flex-shrink: 0;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 32px 20px;
    z-index: 30;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
}

.modal-backdrop.show,
.modal-backdrop.open {
    display: flex;
}

#overdueModal {
    align-items: center;
}

.modal {
    width: min(820px, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
}

.modal .modal-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 80vh;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 0;
}

.modal,
.modal .modal-content {
    max-width: 100%;
}

.modal .form-grid input,
.modal .form-grid select,
.modal .form-grid textarea {
    width: 100%;
}

.modal .form-grid input[type="date"],
.modal .form-grid input[type="datetime-local"] {
    font-size: 16px;
    line-height: 1.2;
    padding: 12px 14px;
}

body.modal-open {
    overflow: hidden;
    overscroll-behavior: none;
}

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

#customerModal .form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px 16px;
}

#customerModal .form-grid .modal-actions {
    grid-column: 1 / -1;
}

.modal-actions {
    justify-content: flex-end;
    gap: 10px;
    margin-top: 12px;
}

.modal-actions.right {
    justify-content: flex-end;
}

.sale-summary-box {
    margin-top: 14px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card);
}

.sale-summary-title {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
    color: #222;
}

.sale-summary-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 8px;
}

.summary-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.summary-block-totals {
    border-top: 1px solid #eee;
    padding-top: 16px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    line-height: 1.3;
}

.summary-row span {
    font-size: 13px;
    font-weight: 500;
    color: #555;
}

.summary-row .summary-value {
    width: 130px;
    min-width: 110px;
    text-align: right;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
}

.discount-items-row .summary-value,
.extra-discount-row .summary-value,
#modalEntradaRow .summary-value {
    color: #16a34a;
}

.summary-final-value {
    font-size: 15px;
    font-weight: 700;
    color: #111;
}

.summary-final-row span {
    font-size: 15px;
    font-weight: 600;
}

.summary-final-row .summary-value {
    font-size: 17px;
    font-weight: 800;
    color: #111;
}

.period-hidden {
    display: none !important;
}

.summary-total-value {
    font-size: 12px;
    font-weight: 600;
    color: #777;
}

.valor-positivo {
    color: #2e7d32;
    font-weight: 600;
}

.resumo-desconto,
.summary-value.resumo-desconto {
    color: #16a34a;
    font-weight: 600;
}

.summary-total-final {
    margin-top: 8px;
}

.summary-total-final span {
    font-size: 15px;
    font-weight: 600;
}

.summary-total-final .summary-value {
    font-size: 16px;
    font-weight: 700;
}

#alertModal {
    align-items: center;
    padding: 0 16px;
}

#alertModal .modal {
    width: min(420px, 92vw);
    text-align: left;
    font-family: 'Manrope', system-ui, -apple-system, sans-serif;
    border-width: 1px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
    background: var(--surface);
}

#alertModal .alert-text {
    font-size: 15px;
    color: var(--text);
    line-height: 1.5;
    margin: 4px 0 2px;
}

#alertModal[data-status="error"] .modal {
    border-color: rgba(255, 107, 107, 0.7);
    box-shadow: 0 20px 60px rgba(255, 107, 107, 0.18);
    background: linear-gradient(180deg, var(--surface) 0%, var(--card) 100%);
}

#alertModal[data-status="success"] .modal {
    border-color: rgba(123, 216, 143, 0.7);
    box-shadow: 0 20px 60px rgba(123, 216, 143, 0.18);
    background: linear-gradient(180deg, var(--surface) 0%, var(--card) 100%);
}

#alertModal[data-status="warning"] .modal {
    border-color: rgba(225, 181, 92, 0.7);
    box-shadow: 0 20px 60px rgba(225, 181, 92, 0.18);
    background: linear-gradient(180deg, var(--surface) 0%, var(--card) 100%);
}

#birthdayConfirmModal {
    align-items: center;
    padding: 0 16px;
}

#birthdayConfirmModal .modal {
    width: min(420px, 92vw);
}

#birthdayConfirmModal[data-status="warning"] .modal {
    border-color: rgba(225, 181, 92, 0.7);
    box-shadow: 0 20px 60px rgba(225, 181, 92, 0.18);
    background: linear-gradient(180deg, var(--surface) 0%, var(--card) 100%);
}

#confirmModal {
    align-items: center;
    padding: 0 16px;
}

#productModal .modal {
    max-height: 90vh;
}

#productModal .form-grid {
    overflow-y: auto;
    max-height: calc(90vh - 140px);
    padding-right: 6px;
}

#confirmModal .modal {
    width: min(420px, 92vw);
}

#confirmModal[data-status="warning"] .modal {
    border-color: rgba(225, 181, 92, 0.7);
    box-shadow: 0 20px 60px rgba(225, 181, 92, 0.18);
    background: linear-gradient(180deg, var(--surface) 0%, var(--card) 100%);
}

#errorModal {
    align-items: center;
    padding: 0 16px;
}

#errorModal .modal {
    width: min(520px, 94vw);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 22px 60px rgba(0, 0, 0, 0.55);
}

#errorModal[data-status="error"] .modal {
    border-color: rgba(255, 107, 107, 0.7);
    box-shadow: 0 22px 60px rgba(255, 107, 107, 0.18);
}

#errorModal[data-status="success"] .modal {
    border-color: rgba(123, 216, 143, 0.7);
    box-shadow: 0 22px 60px rgba(123, 216, 143, 0.18);
}

#overdueModal[data-status="warning"] .modal {
    border-color: rgba(225, 181, 92, 0.7);
    box-shadow: 0 22px 60px rgba(225, 181, 92, 0.18);
}

#errorModal .modal-head h2 {
    margin: 0;
    letter-spacing: -0.2px;
}

#errorModal .form-alert-strong {
    color: var(--text);
    margin: 6px 0 0;
}

#errorModal[data-status="error"] .form-alert-strong {
    color: var(--danger);
}

#errorModal[data-status="success"] .form-alert-strong {
    color: var(--success);
}

#alertModal .modal-head h3 {
    font-size: 18px;
    margin: 0;
    letter-spacing: -0.2px;
}

@media (max-width: 900px) {
    .shell {
        padding: 0 16px 32px;
    }

    .topbar {
        grid-template-columns: 1fr auto;
        align-items: center;
        gap: 10px;
    }

    .nav-toggle {
        display: inline-flex;
        justify-self: end;
    }

    .nav-links {
        grid-column: 1 / -1;
        width: 100%;
        display: none;
        flex-direction: column;
        align-items: stretch;
        border: 1px solid var(--border);
        border-radius: 12px;
        padding: 10px;
        background: var(--card);
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    }

    .nav-links.open {
        display: flex;
    }

    .nav-links a {
        padding: 12px;
        border: 1px solid var(--border);
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.02);
    }

    .user-chip {
        grid-column: 1 / -1;
        justify-self: end;
        align-self: center;
        padding: 5px 9px;
    }

    .hero {
        padding: 16px;
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .hero h1 {
        font-size: 24px;
    }

    .grid-3 {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }

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

    .two-col {
        grid-template-columns: 1fr;
    }

    .section-head {
        flex-direction: column;
        gap: 8px;
        margin: 10px;
    }

    .qr {
        flex-direction: column;
        align-items: flex-start;
    }

    .list-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .sale-row {
        gap: 10px;
    }

    .birthday-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .list-meta {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .birthday-actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        display: contents;

    }

    .sale-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .stock-badge {
        width: 100%;
    }

    .birthday-status-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .birthday-status-actions .badge,
    .birthday-status-actions .btn {
        width: 100%;
        justify-content: center;
        text-align: center;
    }

    .table-customers .table-head {
        display: none;
    }

    .table-customers .table-row {
        display: flex;
        flex-direction: column;
        gap: 6px;
        align-items: flex-start;
        padding: 14px;
        border: 1px solid var(--border);
        border-radius: 12px;
        background: var(--surface);
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
        margin-bottom: 12px;
    }

    .table-customers .table-row span {
        display: block;
    }

    .table-customers .table-row span::before {
        content: attr(data-label);
        display: inline-block;
        margin-right: 6px;
        color: var(--muted);
        font-weight: 700;
    }

    .table-customers .table-row .table-actions {
        width: 100%;
        margin-top: 6px;
        justify-content: flex-end;
        align-self: flex-end;
        gap: 6px;
    }

    .table-products .table-head {
        display: none;
    }

    .table-products .table-head {
        display: none;
    }

    .table-products .table-row {
        display: flex;
        flex-direction: column;
        gap: 6px;
        align-items: flex-start;
        padding: 14px;
        border: 1px solid var(--border);
        background: var(--surface);
        border-radius: 12px;
        margin-bottom: 12px;
    }

    .table-products .table-row span {
        display: block;
        width: 100%;
        white-space: normal;
    }

    /* Centraliza badges nos cards de estoque no mobile */
    .table-products .table-row .badge {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
    }

    .table-products .table-row span::before {
        content: attr(data-label);
        display: inline-block;
        margin-right: 6px;
        color: var(--muted);
        font-weight: 700;
    }

    .table-products .table-row .table-actions {
        width: 100%;
        margin-top: 6px;
        justify-content: flex-end;
        align-self: flex-end;
        gap: 6px;
    }

    .auto-expenses-table .table-head {
        display: none;
    }

    .auto-expenses-table .table-row {
        display: flex;
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
        padding: 12px;
        border: 1px solid var(--border);
        background: var(--surface);
        border-radius: 12px;
        margin: 10px;
    }

    .auto-expenses-table .table-row span {
        display: flex;
        justify-content: space-between;
        gap: 8px;
        width: 100%;
        white-space: normal;
        min-width: 0;
    }

    .auto-expenses-table .table-row span::before {
        content: attr(data-label);
        display: inline-block;
        margin-right: 6px;
        color: var(--muted);
        font-weight: 700;
        flex: 0 0 auto;
    }

    .auto-expenses-table .table-row .table-actions {
        grid-column: 1 / -1;
        display: flex;
        justify-content: flex-start;
        gap: 10px;
        margin-top: 4px;
    }

    #btn-add-auto-expense {
        width: 100%;
        display: block;
        text-align: center;
        margin-bottom: 10px;
    }

    .table-payments .table-head {
        display: none;
    }

    .table-payments .table-row {
        display: flex;
        flex-direction: column;
        gap: 6px;
        align-items: flex-start;
        padding: 14px;
        border: 1px solid var(--border);
        background: var(--surface);
        border-radius: 12px;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
        margin-bottom: 12px;
    }

    .table-payments .table-row span {
        display: block;
        width: 100%;
        white-space: normal;
    }

    .table-payments .table-row span::before {
        content: attr(data-label);
        display: inline-block;
        margin-right: 6px;
        color: var(--muted);
        font-weight: 700;
    }

    .table-payments .table-row .table-actions {
        width: 100%;
        margin-top: 6px;
        justify-content: flex-end;
        align-self: flex-end;
        gap: 6px;
    }

    .table-customers .table-row>span::before,
    .table-products .table-row>span::before,
    .table-expenses .table-row>span::before,
    .despesas-table .table-row>span::before,
    .table-despesas .table-row>span::before,
    .table-payments .table-row>span::before,
    .auto-expenses-table .table-row>span::before {
        content: attr(data-label) ": ";
    }



    .table-expenses .table-head,
    .despesas-table .table-head {
        display: none;
    }

    .table-expenses .table-row,
    .despesas-table .table-row {
        display: flex;
        flex-direction: column;
        gap: 6px;
        align-items: flex-start;
        padding: 14px;
        border: 1px solid var(--border);
        background: var(--surface);
        border-radius: 12px;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
        margin-bottom: 12px;
    }

    .table-expenses .table-row span,
    .despesas-table .table-row span {
        display: block;
        width: 100%;
        white-space: normal;
    }

    .table-expenses .table-row>span::before,
    .despesas-table .table-row>span::before {
        content: attr(data-label) ": ";
        display: inline-block;
        margin-right: 6px;
        color: var(--muted);
        font-weight: 700;
    }

    .table-expenses .table-row .table-actions,
    .despesas-table .table-row .table-actions {
        width: 100%;
        margin-top: 6px;
        justify-content: flex-end;
        align-self: flex-end;
        gap: 6px;
    }

    .table-products .table-head,
    .table-products .table-row {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }

    .sale-stack {
        gap: 10px;
    }

    .item-head,
    .item-row {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 901px) {

    .item-head,
    .item-row {
        display: grid;
        grid-template-columns: 2fr 0.75fr 0.95fr 0.85fr 0.85fr 1fr 0.75fr 0.7fr 0.6fr;
    }

    .item-head>*,
    .item-row>* {
        min-width: 0;
        overflow: hidden;
        align-items: center;
    }

    .product-cell,
    .discount-cell,
    .discount-value-cell {
        display: block;
        min-width: 0;
        overflow: hidden;
    }

    .product-cell select,
    .item-row input,
    .discount-cell input {
        width: 100%;
        margin-right: 22px;

    }
}

@media (max-width: 768px) {
    .brand-mark {
        padding: 8px 10px;
    }

    .brand-name {
        font-size: 16px;
    }

    .brand-sub {
        font-size: 11px;
    }

    .hero-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .list-row .btn,
    .birthday-row .btn {
        width: 100%;
        justify-content: center;
    }

    .filters,
    .filter-grid,
    .filters-row {
        width: 100%;
        grid-template-columns: 1fr;
    }

    .filter-inline {
        flex-direction: row;
        align-items: center;
        gap: 12px;
        flex-wrap: wrap;
    }

    .filter-inline .date-fields {
        grid-template-columns: 1fr;
    }

    .filter-inline .btn.primary {
        width: auto;
        flex: 0 0 auto;
        align-self: center;
        padding: 10px 14px;
        font-size: 15px;
    }

    .user-chip {
        width: auto;
        justify-content: flex-end;
        padding: 5px 9px;
    }

    .modal {
        padding: 16px;
    }

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

    .table {
        font-size: 14px;
    }

    .badge,
    .badge.warning,
    .badge.danger,
    .badge.product {
        width: 100%;
        min-width: 0;
        padding: 2px 8px;
        text-align: center;
        display: inline-flex;
        justify-content: center;
        align-items: center;
    }

    .sale-stack {
        gap: 12px;
    }

    .sale-card.compact {
        padding: 12px 14px;
        border: 1px solid var(--border);
        border-radius: 12px;
        background: var(--surface);
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
        gap: 10px;
    }

    .item-head {
        display: none;
    }

    .item-list {
        gap: 12px;
        display: flex;
        flex-direction: column;
    }

    .panel,
    .panel.compact,
    .card,
    .sale-card {
        border: 1px solid var(--border);
        border-radius: 12px;
        background: var(--card, #fff);
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    }

    .item-list table,
    .item-list tbody {
        display: block;
        width: 100%;
    }

    .item-row {
        display: grid;
        gap: 10px;
        grid-template-columns: 1fr 1fr 1fr;
        grid-template-areas:
            "produto produto produto"
            "qtd desconto brinde"
            "preco desconto_valor subtotal"
            "estoque estoque remover";
        align-items: start;
        padding: 14px;
        border: 1px solid var(--border);
        border-radius: 12px;
        background: var(--card);
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    }

    .item-row:not(:last-child) {
        margin-bottom: 12px;
    }

    .item-row .product-cell {
        grid-area: produto;
    }

    .product-cell select {
        width: 100%;
        font-weight: 700;
        font-size: 15px;
    }

    .item-row td {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .item-row td::before {
        content: attr(data-label);
        font-size: 12px;
        color: var(--muted);
        font-weight: 700;
    }

    .item-row .item-qtd,
    .item-row .col-qtd {
        grid-area: qtd;
        max-width: 120px;
        width: 100%;
    }

    .col-qtd input {
        max-width: 70px;
        text-align: center;
    }

    .item-row .item-desconto-percent,
    .item-row .col-desc-pct {
        grid-area: desconto;
        justify-self: start;
        max-width: 140px;
        width: 100%;
    }

    .col-desc-pct input {
        max-width: 80px;
        text-align: center;
    }

    .item-row select,
    .item-row input {
        width: 100%;
        background: var(--surface);
    }

    .item-row .discount-cell,
    .item-row .discount-value-cell {
        display: flex;
        flex-direction: column;
        gap: 4px;
        width: 100%;
    }

    .item-row .item-preco,
    .item-row .col-unit,
    .item-row .col-preco {
        grid-area: preco;
    }

    .item-row .item-desconto,
    .item-row .item-desconto-rs,
    .item-row .col-desc-rs {
        grid-area: desconto_valor;
        padding: 0;
        border: none;
        background: transparent;
    }

    .item-row .item-subtotal,
    .item-row .col-subtotal {
        grid-area: subtotal;
    }

    .item-row .item-estoque,
    .item-row .col-estoque {
        grid-area: estoque;
    }

    .item-row .item-remover,
    .item-row .col-acoes {
        grid-area: remover;
    }

    .item-discount-rs {
        display: flex;
        flex-direction: column;
        gap: 4px;
        border: none;
        background: transparent;
    }

    .item-discount-rs label {
        font-size: 12px;
        font-weight: 700;
        color: var(--muted);
    }

    .discount-value-text {
        font-weight: 700;
        padding: 0;
        background: transparent;
        border: none;
    }

    .col-subtotal {
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-radius: 10px;
        background: var(--card);
        font-weight: 800;
    }

    .item-price,
    .item-subtotal {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        gap: 6px;
        text-align: left;
        font-weight: 600;
    }

    .item-row td {
        text-align: left;
        align-items: flex-start;
    }

    .stock-badge {
        margin-left: 0;
        align-self: flex-start;
    }

    .col-actions {
        justify-self: flex-start;
        margin-top: 2px;
    }

}

@media print {

    .topbar,
    .nav-links,
    .user-chip,
    .chip,
    .panel-actions,
    .panel-head .helper,
    .btn,
    .flash {
        display: none !important;
    }

    body {
        background: #fff;
        color: #000;
    }

    .shell {
        padding: 0;
    }

    .receipt {
        box-shadow: none;
        border: none;
        background: #fff;
    }
}

/* Recibo - alinhar itens em 3 colunas */
.table.receipt-items .table-head,
.table.receipt-items .table-row {
    grid-template-columns: 1.3fr 0.9fr 0.9fr;
    align-items: center;
}

.table.receipt-items .table-row span:nth-child(2),
.table.receipt-items .table-row span:nth-child(3),
.table.receipt-items .table-head span:nth-child(2),
.table.receipt-items .table-head span:nth-child(3) {
    white-space: nowrap;
}

.table.receipt-items .table-row span:first-child {
    white-space: normal;
}

.filters-bar {
    display: flex;
    align-items: left;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.filters {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 280px;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    align-items: end;
}

.filters-row {
    margin-top: 8px;
    margin-bottom: 0px;
}

.filters-card {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 14px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card, #fff);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.filters-card-head h3 {
    margin: 4px 0;
}

.filters-inline {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    align-items: end;
}

.filters-with-summary {
    display: grid;
    grid-template-columns: minmax(420px, 2fr) minmax(260px, 1fr);
    align-items: flex-start;
    gap: 16px;
}

.filters-with-summary form.filters {
    width: 100%;
    margin-bottom: 0;
}

.filters-with-summary .summary-card {
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
}

.filters-with-summary .summary-card h3 {
    margin: 4px 0 6px;
}

.filters-with-summary .summary-card .helper {
    margin: 0;
}

.filters-inline .date-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(140px, 1fr));
    gap: 8px;
}

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

.filters-with-summary .summary-card {
    width: 100%;
    margin-top: 4px;
    margin-bottom: 12px;
}

.filters-inline-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

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

.filters .full-row {
    width: 100%;
}

.filter-inline {
    display: flex;
    gap: 10px;
    align-items: center;
    width: 100%;
}

.filter-inline select {
    flex: 0 1 260px;
    max-width: 320px;
}

.filter-inline .date-fields {
    flex: 1.8;
    display: grid;
    grid-template-columns: repeat(2, minmax(140px, 1fr));
    gap: 8px;
}

.filter-inline .date-fields.hidden {
    display: none;
}

.filter-inline .btn.primary {
    flex: 0 0 auto;
    text-align: center;
    padding-left: 16px;
    padding-right: 16px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.date-fields.hidden {
    display: none;
}

.filters .btn.primary {
    width: auto;
    align-self: flex-start;
    padding: 10px 16px;
}

.metrics-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    align-items: stretch;
}

@media (max-width: 640px) {

    .table-head,
    .table-row {
        grid-template-columns: 1fr 0.6fr 0.8fr;
        align-items: start;
    }

    .table-head span,
    .table-row span {
        white-space: normal;
        word-break: break-word;
    }

    .table-row span:nth-child(2),
    .table-row span:nth-child(3) {
        justify-self: end;
        text-align: left;
    }
}


/* ============================
   ALINHAMENTO PERFEITO DESKTOP
   ============================ */
@media (min-width: 901px) {

    /* Força table head e body a terem a mesma grid */
    .items-table .item-head,
    .items-table .item-row {
        display: grid !important;
        grid-template-columns:
            2fr
            /* Produto */
            0.3fr
            /* Qtd */
            0.3fr
            /* Unitário */
            0.3fr
            /* Desc % */
            0.40fr
            /* Desc R$ */
            0.4fr
            /* Subtotal */
            0.4fr 0.6 fr
            /* Estoque */
            0.6fr;
        /* Ações      */
        gap: 8px;
        align-items: center;
    }

    /* Remove qualquer padding/largura que bagunça */
    .items-table td,
    .items-table th {
        padding: 0 !important;
        margin: 0 !important;
        min-width: 0 !important;
        overflow: hidden !important;
        display: flex;
        align-items: center;
    }

    /* Descontos */
    .discount-cell,
    .discount-value-cell {
        width: 100% !important;
        display: flex !important;
        align-items: center;
    }

    /* Alinha textos */
    .discount-value-text,
    .item-price .value,
    .item-subtotal .value {
        display: block;
        width: 100%;
        text-align: left !important;
    }

    /* Produto */
    .product-cell {
        display: flex !important;
        align-items: center;
        width: 100%;
    }

    .product-cell select {
        width: 100% !important;
    }

    /* Estoque */
    .stock-cell,
    .stock-badge {
        justify-content: center !important;
        text-align: center !important;
    }

    /* Botão remover */
    .stock-actions {
        justify-content: flex-start !important;
        width: 100%;
    }

}

/* Print-friendly receipt layout */
@media print {

    /* remove botão */
    .btn,
    button {
        display: none !important;
    }

    /* forçar centralização */
    body {
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
    }

    .receipt-paper {
        width: 360px !important;
        /* largura cupom */
        max-width: 360px !important;
        margin: 0 auto !important;
        padding: 0 !important;
        box-shadow: none !important;
        border-radius: 0 !important;
    }

    .receipt-head,
    .receipt-meta,
    .receipt-items,
    .receipt-totals,
    .receipt-qr {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* garantir que tudo fique alinhado corretamente */
    .receipt-head h1,
    .receipt-head p,
    .receipt-title {
        text-align: center !important;
    }

    .print-btn {
        display: none !important;
    }

    .receipt-head {
        align-items: center !important;
        text-align: center !important;
    }

    .receipt-head-info {
        text-align: center !important;
    }

    .receipt-installments {
        width: 100%;
        margin-left: 0;
        margin-right: 0;
        font-size: 11.5px;
        padding: 8px 10px;
    }

    .installment-line {
        padding: 2px 0;
        font-size: 11.5px;
        grid-template-columns: auto auto auto;
        column-gap: 4px;
    }
}

@media (max-width: 600px) {
    .chart-card {
        min-height: 320px;
        height: auto;
    }

    .chart-card canvas {
        width: 100% !important;
        height: 240px !important;
        max-height: 240px !important;
    }
}

@media (min-width: 601px) {
    .chart-card {
        min-height: auto;
        height: auto;
    }

    .chart-card canvas {
        width: 100% !important;
        height: 260px;
        max-height: 320px;
    }
}
