:root {
    --br-green: #1A7A52;
    --br-gold: #C4A035;
    --br-yellow: #C4A035;
    --us-navy: #1E3A5F;
    --us-crimson: #9B3049;
    --us-blue: #1E3A5F;
    --us-red: #9B3049;
    --primary: #1A7A52;
    --secondary: #1E3A5F;
    --accent-soft: #E8F0EB;
    --sidebar-text: #B8C5D6;
    --sidebar-active-bg: rgba(255, 255, 255, .12);
    --ink: #14181f;
    --muted: #667085;
    --line: #e6e9ef;
    --bg: #f5f7fb;
    --card: #ffffff;
    --radius: 14px;
    --shadow: 0 6px 24px rgba(16, 24, 40, 0.08);
    --shadow-sm: 0 2px 8px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.55;
}

a { color: var(--secondary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }

h1, h2, h3, h4 { line-height: 1.2; margin: 0 0 .5em; }

.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.container-sm { max-width: 720px; margin: 0 auto; padding: 0 20px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 11px 20px; border-radius: 10px; border: 1px solid transparent;
    font-weight: 600; font-size: 15px; cursor: pointer; transition: .15s;
    background: var(--primary); color: #fff; text-decoration: none;
}
.btn:hover { filter: brightness(.95); text-decoration: none; }
.btn-secondary { background: var(--secondary); }
.btn-outline { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-outline:hover { background: #f0f2f7; }
.btn-danger { background: var(--us-crimson); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-sm { padding: 7px 13px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-green { background: #e6f7ee; color: #067647; }
.badge-yellow { background: #fef7e0; color: #a15c07; }
.badge-red { background: #fde8ec; color: var(--us-crimson); }
.badge-blue { background: #e7edf9; color: var(--us-navy); }
.badge-gray { background: #eef1f6; color: #475467; }
.badge-lime { background: #ecfccb; color: #3f6212; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 22px; }
.card + .card { margin-top: 18px; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat .value { font-size: 30px; font-weight: 800; margin-top: 6px; }
.stat .sub { color: var(--muted); font-size: 13px; }

/* Dashboard stats — opt-in, não afeta .grid-4 global */
.grid-stats { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
    .grid-stats { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .grid-stats .stat { padding: 14px 16px; }
    .grid-stats .stat .label { font-size: 11px; }
    .grid-stats .stat .value { font-size: 22px; margin-top: 4px; }
    .grid-stats .stat .sub { font-size: 12px; }
}

@media (max-width: 480px) {
    .grid-stats { gap: 10px; }
    .grid-stats .stat { padding: 12px 14px; }
    .grid-stats .stat .value { font-size: 20px; }
}

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number],
input[type=date], input[type=url], select, textarea {
    width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px;
    font-size: 15px; font-family: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,122,82,.12); }
textarea { min-height: 92px; resize: vertical; }
.hint { color: var(--muted); font-size: 13px; margin-top: 4px; }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row > * { flex: 1; min-width: 160px; }

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; background: #fff; }
.table th, .table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.table th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; background: #fafbfd; }
.table tbody tr:hover { background: #fafbfd; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }

.item-meta-mobile { display: none; }
.item-upc-desktop { display: block; font-size: 12px; margin-top: 2px; }

@media (max-width: 640px) {
    .table-wrap--cards {
        overflow: visible;
        border: none;
        border-radius: 0;
    }
    .table-cards thead { display: none; }
    .table-cards tbody tr {
        display: block;
        background: #fff;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        padding: 12px 14px;
        margin-bottom: 10px;
    }
    .table-cards tbody tr:last-child { margin-bottom: 0; }
    .table-cards tbody tr:hover { background: #fafbfd; }
    .table-cards td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 6px 0;
        border-bottom: none;
        font-size: 14px;
    }
    .table-cards td::before {
        content: attr(data-label);
        flex-shrink: 0;
        color: var(--muted);
        font-size: 12px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: .03em;
    }
    .table-cards td.num { justify-content: space-between; }
    .table-cards td.num,
    .table-cards td:last-child { text-align: right; }
    .table-cards td > * { min-width: 0; word-break: break-word; text-align: right; }
    .table-cards td .item-thumb { flex-shrink: 0; }
    .table-cards td[data-label="Descrição"] { align-items: flex-start; }
    .table-cards td[data-label="Descrição"] > * { text-align: right; }
    .totals { max-width: 100%; }
    .flex.gap > input[readonly] { min-width: 0; flex: 1; }

    .table-wrap--compact {
        overflow: visible;
        border: none;
        border-radius: 0;
    }
    .invoice-items-compact thead { display: none; }
    .invoice-items-compact tbody tr {
        display: flex;
        align-items: flex-start;
        gap: 10px;
        padding: 10px 0;
        border-bottom: 1px solid var(--line);
        background: transparent;
    }
    .invoice-items-compact tbody tr:hover { background: transparent; }
    .invoice-items-compact td {
        padding: 0;
        border-bottom: none;
    }
    .invoice-items-compact .col-idx {
        flex-shrink: 0;
        width: 22px;
        height: 22px;
        line-height: 22px;
        text-align: center;
        font-size: 11px;
        font-weight: 700;
        color: var(--primary);
        background: #f0f2f7;
        border-radius: 999px;
    }
    .invoice-items-compact .col-photo { flex-shrink: 0; }
    .invoice-items-compact .col-photo .item-thumb { width: 40px; height: 40px; }
    .invoice-items-compact .col-desc {
        flex: 1;
        min-width: 0;
        font-size: 14px;
        line-height: 1.35;
    }
    .invoice-items-compact .col-desc .item-desc-text {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    .invoice-items-compact .item-meta-mobile {
        display: block;
        font-size: 12px;
        color: var(--muted);
        margin-top: 2px;
    }
    .invoice-items-compact .item-upc-desktop { font-size: 11px; }
    .invoice-items-compact .col-qty,
    .invoice-items-compact .col-unit { display: none; }
    .invoice-items-compact .col-total {
        flex-shrink: 0;
        font-weight: 700;
        font-size: 14px;
        text-align: right;
        white-space: nowrap;
        padding-top: 2px;
    }

    /* invoice form — editable item cards (mobile) */
    .invoice-items-head {
        flex-direction: column;
        align-items: stretch;
    }
    .invoice-items-actions {
        flex-direction: column;
        width: 100%;
    }
    .invoice-items-actions .btn {
        width: 100%;
        justify-content: center;
        min-height: 44px;
        font-size: 15px;
    }
    .invoice-items-form .field-label {
        display: block;
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: .03em;
        color: var(--muted);
        margin-bottom: 4px;
    }
    .invoice-items-form thead { display: none; }
    .invoice-items-form tbody tr.item-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px 12px;
        position: relative;
        background: #fff;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        padding: 14px 44px 14px 14px;
        margin-bottom: 12px;
    }
    .invoice-items-form tbody tr.item-row:last-child { margin-bottom: 0; }
    .invoice-items-form tbody tr.item-row:hover { background: #fafbfd; }
    .invoice-items-form tbody tr.item-row td {
        display: block;
        padding: 0;
        border-bottom: none;
    }
    .invoice-items-form .col-photo,
    .invoice-items-form .col-desc,
    .invoice-items-form .col-total {
        grid-column: 1 / -1;
    }
    .invoice-items-form .col-actions {
        position: absolute;
        top: 8px;
        right: 8px;
        padding: 0;
    }
    .invoice-items-form .col-actions .removeRow {
        min-width: 36px;
        min-height: 36px;
        padding: 0;
        font-size: 16px;
    }
    .invoice-items-form .item-photo-cell {
        display: flex;
        align-items: center;
        gap: 12px;
        flex-wrap: wrap;
    }
    .invoice-items-form .item-photo-cell .item-thumb {
        width: 56px;
        height: 56px;
        flex-shrink: 0;
    }
    .invoice-items-form .item-photo {
        flex: 1;
        min-width: 0;
        font-size: 13px;
        padding: 8px 0;
    }
    .invoice-items-form .col-desc input,
    .invoice-items-form .col-qty input,
    .invoice-items-form .col-price input {
        font-size: 16px;
    }
    .invoice-items-form .col-total {
        display: flex;
        align-items: center;
        justify-content: space-between;
        background: #f0f2f7;
        border-radius: 8px;
        padding: 10px 12px;
        margin-top: 2px;
    }
    .invoice-items-form .col-total .field-label {
        margin-bottom: 0;
    }
    .invoice-items-form .line-total {
        font-weight: 700;
        font-size: 15px;
        font-variant-numeric: tabular-nums;
    }
    #invoiceForm input[type=text],
    #invoiceForm input[type=number],
    #invoiceForm input[type=date],
    #invoiceForm input[type=email],
    #invoiceForm input[type=tel],
    #invoiceForm select,
    #invoiceForm textarea {
        font-size: 16px;
    }
    #invoiceForm .invoice-submit-btn {
        width: 100%;
        justify-content: center;
        min-height: 48px;
    }
    #invoiceForm > .card:last-child {
        padding-bottom: 72px;
    }
    .invoice-scan-fab {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }
    .modal-backdrop--scan {
        padding: 0;
        align-items: flex-end;
    }
    .modal-backdrop--scan.open {
        align-items: flex-end;
    }
    .modal-backdrop--scan.open .modal-scan {
        animation: sheetSlideUp 0.28s ease-out;
    }
    .modal-scan {
        max-width: 100%;
        max-height: 92vh;
        border-radius: 16px 16px 0 0;
        display: flex;
        flex-direction: column;
    }
    .modal-scan__handle {
        display: block;
        width: 36px;
        height: 4px;
        margin: 10px auto 0;
        background: #d0d5dd;
        border-radius: 999px;
        flex-shrink: 0;
    }
    .modal-scan .head {
        padding-top: 8px;
    }
    .modal-scan__body {
        overflow-y: auto;
        padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
    }
    .modal-scan #reader,
    .modal-scan #barcodeReader {
        min-height: 240px;
    }
    .modal-scan__manual {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }
    .modal-scan__manual input {
        width: 100%;
        font-size: 16px;
    }
    .modal-scan__manual .btn {
        width: 100%;
        justify-content: center;
        min-height: 44px;
    }
}

/* ---------- Flash ---------- */
.flash { padding: 13px 16px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; }
.flash-success { background: #e6f7ee; color: #067647; border: 1px solid #a6e5c4; }
.flash-error { background: #fde8ec; color: var(--us-crimson); border: 1px solid #f5b5c3; }
.flash-info { background: #e7edf9; color: var(--us-navy); border: 1px solid #b9caea; }

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 250px;
    background: linear-gradient(180deg, var(--secondary) 0%, #172E4A 100%);
    color: #fff;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar .brand { padding: 20px 22px; font-weight: 800; font-size: 20px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid rgba(255,255,255,.12); }
.sidebar nav { padding: 14px 12px; flex: 1; overflow-y: auto; }
.sidebar nav a {
    display: flex; align-items: center; gap: 11px; color: var(--sidebar-text); padding: 11px 14px;
    border-radius: 9px; font-weight: 500; font-size: 15px; margin-bottom: 3px;
    border-left: 3px solid transparent;
    transition: background .15s, color .15s, border-color .15s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.sidebar nav a.active {
    background: var(--sidebar-active-bg);
    color: #fff;
    border-left-color: var(--primary);
}
.sidebar .foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.12); font-size: 13px; color: #b9c4d8; }
.sidebar .logout-link { color: var(--br-gold); opacity: .85; text-decoration: none; }
.sidebar .logout-link:hover { color: #fff; opacity: 1; text-decoration: none; }
.flag-strip {
    height: 3px;
    background: linear-gradient(90deg,
        var(--br-green) 0%,
        var(--br-gold) 28%,
        var(--us-navy) 72%,
        var(--us-crimson) 100%
    );
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: #fff; border-bottom: 1px solid var(--line); padding: 14px 26px; display: flex; align-items: center; justify-content: space-between; }
.topbar h1 { font-size: 20px; margin: 0; }
.content { padding: 26px; flex: 1; }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 22px; }

@media (max-width: 820px) {
    .sidebar { position: fixed; left: -260px; z-index: 50; transition: .2s; }
    .sidebar.open { left: 0; }
    .menu-toggle { display: inline-flex !important; }
    .content { padding: 16px; }
    .card-pad { padding: 16px; }
}
.menu-toggle { display: none; }

/* ---------- Public / landing ---------- */
.public-nav { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.public-nav .inner { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; }
.logo { font-weight: 800; font-size: 22px; display: flex; align-items: center; gap: 10px; color: var(--ink); }
.logo .dot { width: 12px; height: 12px; border-radius: 50%; background: linear-gradient(135deg, var(--br-green), var(--us-navy)); }
.brand-logo { max-height: 36px; max-width: 180px; object-fit: contain; }
.sidebar .brand-logo { max-height: 32px; }
.auth-box .brand-logo { max-height: 64px; margin: 0 auto 8px; display: block; }
.public-nav .links a { margin-left: 22px; color: var(--ink); font-weight: 500; }

.hero { background: linear-gradient(135deg, #172E4A 0%, #1A4D3A 100%); color: #fff; padding: 80px 0; position: relative; overflow: hidden; }
.hero:after { content:''; position:absolute; inset:0; background: radial-gradient(circle at 80% 20%, rgba(196,160,53,.12), transparent 40%); }
.hero .inner { position: relative; z-index: 2; max-width: 720px; }
.hero h1 { font-size: 46px; font-weight: 800; }
.hero p { font-size: 19px; color: #cdd7e6; margin: 18px 0 28px; }
.hero .cta { display: flex; gap: 14px; flex-wrap: wrap; }
.eyebrow { display: inline-block; background: rgba(255,255,255,.12); padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; margin-bottom: 18px; }

.section { padding: 70px 0; }
.section h2 { font-size: 32px; text-align: center; }
.section .lead { text-align: center; color: var(--muted); max-width: 640px; margin: 0 auto 44px; font-size: 17px; }

.feature { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow-sm); }
.feature .ic { width: 46px; height: 46px; border-radius: 12px; background: #e6f7ee; color: var(--br-green); display: flex; align-items: center; justify-content: center; font-size: 22px; margin-bottom: 14px; }
.feature h3 { font-size: 18px; }
.feature p { color: var(--muted); font-size: 15px; margin: 0; }

.pricing-card { text-align: center; border: 2px solid var(--line); border-radius: 18px; padding: 34px; background: #fff; }
.pricing-card.highlight { border-color: var(--primary); box-shadow: var(--shadow); }
.pricing-card .price { font-size: 44px; font-weight: 800; margin: 10px 0; }
.pricing-card .price small { font-size: 16px; color: var(--muted); font-weight: 500; }
.pricing-card ul { list-style: none; padding: 0; margin: 20px 0; text-align: left; }
.pricing-card li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.pricing-card li:before { content: '✓'; color: var(--br-green); font-weight: 800; margin-right: 8px; }

.footer { background: #172E4A; color: #b9c4d8; padding: 40px 0; text-align: center; }

/* auth box */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: linear-gradient(135deg, #172E4A, #1A4D3A); }
.auth-box { background: #fff; border-radius: 18px; padding: 38px; width: 100%; max-width: 420px; box-shadow: var(--shadow); }
.auth-box .logo { justify-content: center; margin-bottom: 8px; }
.auth-box h1 { text-align: center; font-size: 22px; }
.auth-box .sub { text-align: center; color: var(--muted); margin-bottom: 24px; }

.text-muted { color: var(--muted); }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; } .gap { gap: 12px; }
.flex-wrap { flex-wrap: wrap; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .ic { font-size: 40px; margin-bottom: 10px; }

/* invoice item rows */
.item-row td { vertical-align: top; }
.item-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.item-thumb-empty { display: inline-flex; align-items: center; justify-content: center; font-size: 20px; background: var(--bg, #f5f5f5); color: var(--muted, #999); }
.totals { max-width: 340px; margin-left: auto; }
.totals .line { display: flex; justify-content: space-between; padding: 8px 0; }
.totals .line.total { border-top: 2px solid var(--ink); font-size: 20px; font-weight: 800; margin-top: 6px; padding-top: 12px; }

/* invoice form — items toolbar & editable rows */
.invoice-items-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}
.invoice-items-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.invoice-items-form .field-label { display: none; }
.invoice-items-form .col-total .line-total { font-variant-numeric: tabular-nums; }
.item-photo-cell { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.invoice-items-form .item-photo {
    max-width: 140px;
    font-size: 12px;
}

/* FAB scan (mobile only — shown via media query) */
.invoice-scan-fab {
    display: none;
    position: fixed;
    bottom: max(16px, env(safe-area-inset-bottom, 16px));
    right: 16px;
    z-index: 90;
    padding: 12px 20px;
    min-height: 48px;
    border: none;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .22);
}
.invoice-scan-fab:hover { filter: brightness(.95); }

/* barcode scanner modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: none; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal-backdrop.open { display: flex; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 480px; overflow: hidden; }
.modal .head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal .body { padding: 20px; }
#reader,
#barcodeReader { width: 100%; border-radius: 10px; overflow: hidden; }

.modal-scan__handle { display: none; }
.modal-scan__manual {
    display: flex;
    gap: 12px;
    align-items: stretch;
}
.modal-scan__manual input { flex: 1; min-width: 0; }

/* conversation thread (chat) */
.conv-thread {
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 12px;
    background: #fafbfc;
}
.conv-day-sep {
    text-align: center;
    margin: 8px 0 10px;
}
.conv-day-sep span {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    background: #eef0f3;
    padding: 3px 10px;
    border-radius: 999px;
}
.conv-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
}
.conv-row--start { align-items: flex-start; }
.conv-row--end { align-items: flex-end; }
.conv-bubble {
    max-width: 92%;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.45;
    word-break: break-word;
}
.conv-bubble--staff { background: #e7edf9; color: var(--us-navy); }
.conv-bubble--client { background: #e6f7ee; color: #067647; }
.conv-meta {
    font-size: 11px;
    color: var(--muted);
    margin-top: 3px;
}
.conv-panel {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}
.conv-panel__title {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 8px;
}
.conv-reply {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
}
.conv-panel .conv-reply {
    border-top: none;
    padding-top: 0;
}
.conv-panel:not(:has(.conv-thread)) .conv-reply {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}
.modal-conversation {
    max-width: 560px;
}
.card[id^="item-"] { scroll-margin-top: 16px; }

/* body scroll lock when modal open */
body.modal-open { overflow: hidden; }

/* chat overlay — modal (desktop) / bottom sheet (mobile) */
.modal-backdrop--chat.open {
    align-items: center;
}
.modal-chat {
    max-width: 560px;
    display: flex;
    flex-direction: column;
    max-height: min(640px, 90vh);
}
.modal-chat .head {
    flex-shrink: 0;
    gap: 12px;
}
.modal-chat__titles {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.modal-chat__titles strong {
    font-size: 15px;
    line-height: 1.3;
}
.modal-chat__subtitle {
    font-size: 12px;
    line-height: 1.3;
}
.modal-chat__handle {
    display: none;
}
.modal-chat__body {
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    flex: 1;
    min-height: 0;
    max-height: min(560px, 72vh);
}
.modal-chat__thread {
    flex: 1;
    overflow: hidden;
    padding: 16px 20px;
    min-height: 120px;
}
.modal-chat__thread .conv-thread {
    height: 100%;
    max-height: 420px;
    margin-bottom: 0;
    border: none;
    border-radius: 10px;
    background: #fafbfc;
}
.modal-chat__empty {
    margin: 0;
    padding: 24px 0;
    text-align: center;
    font-size: 14px;
}
.modal-chat__reply {
    flex-shrink: 0;
    padding: 12px 20px 20px;
    border-top: 1px solid var(--line);
    background: #fff;
    margin-top: 0;
}
.modal-chat__reply.conv-reply {
    border-top: 1px solid var(--line);
    padding-top: 12px;
}

/* badge de contagem no botao Ver conversa */
.conv-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: 4px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    color: #fff;
    background: var(--primary, #1A7A52);
    border-radius: 999px;
    vertical-align: middle;
}
.conv-preview {
    font-size: 12px;
    margin-top: 6px;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}
.conv-preview__time {
    opacity: 0.85;
}

/* ---------- Compra Assistida (Painel PS) ---------- */
.usd-rate-badge--default {
    padding: 12px 16px;
    background: linear-gradient(135deg, #172E4A 0%, #1A4D3A 100%);
    color: #fff;
    border: none;
}
.usd-rate-badge__label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--br-gold, #C4A035);
    font-weight: 700;
}
.usd-rate-badge--default .usd-rate-badge__rate {
    font-size: 22px;
    font-weight: 800;
    margin-top: 2px;
}
.usd-rate-badge--default .usd-rate-badge__mode {
    font-size: 12px;
    color: #cdd7e6;
    text-align: right;
}
.usd-rate-badge--toolbar {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, #172E4A 0%, #1A4D3A 100%);
    color: #fff;
}
.usd-rate-badge--toolbar .usd-rate-badge__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
}
.usd-rate-badge--toolbar .usd-rate-badge__label {
    font-size: 10px;
}
.usd-rate-badge--toolbar .usd-rate-badge__rate {
    font-size: 16px;
    font-weight: 800;
    margin-top: 2px;
    line-height: 1.2;
}
.usd-rate-badge--toolbar .usd-rate-badge__mode {
    font-size: 11px;
    color: #cdd7e6;
    text-align: right;
    flex-shrink: 0;
}
.assisted-toolbar__filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.assisted-toolbar__search {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.assisted-toolbar__search input[type="text"] {
    flex: 1 1 200px;
    min-width: 0;
}
.assisted-client-group__add {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px dashed var(--line);
}
.assisted-client-group {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.assisted-client-group:hover {
    box-shadow: var(--shadow);
    border-color: #d5dbe6;
}
.assisted-client-group[open] {
    border-color: #b8dfc8;
    box-shadow: 0 8px 28px rgba(26, 122, 82, 0.1);
}
.assisted-client-group__summary {
    cursor: pointer;
    list-style: none;
    user-select: none;
}
.assisted-client-group__summary::-webkit-details-marker,
.assisted-client-group__summary::marker {
    display: none;
    content: '';
}
.assisted-client-group__box {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0 14px;
    padding: 18px 18px 18px 20px;
    align-items: start;
}
.assisted-client-group__accent {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, var(--us-navy) 0%, var(--br-green) 100%);
    opacity: 0.55;
    transition: opacity 0.2s ease, width 0.2s ease;
}
.assisted-client-group[open] .assisted-client-group__accent {
    opacity: 1;
    width: 5px;
}
.assisted-client-group__toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-top: 4px;
    border-radius: 10px;
    background: #f3f5f9;
    border: 1px solid var(--line);
    transition: background 0.15s ease, transform 0.15s ease;
}
.assisted-client-group:hover .assisted-client-group__toggle {
    background: #e8edf5;
}
.assisted-client-group[open] .assisted-client-group__toggle {
    background: #e6f7ee;
    border-color: #b8dfc8;
}
.assisted-client-group__chevron {
    display: block;
    width: 8px;
    height: 8px;
    border-right: 2px solid #475467;
    border-bottom: 2px solid #475467;
    transform: rotate(-45deg);
    margin-top: -2px;
    transition: transform 0.2s ease, border-color 0.2s ease;
}
.assisted-client-group[open] .assisted-client-group__chevron {
    transform: rotate(45deg);
    margin-top: 2px;
    border-color: var(--br-green);
}
.assisted-client-group__content {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.assisted-client-group__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.assisted-client-group__identity {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.assisted-client-group__name {
    font-weight: 700;
    font-size: 16px;
    color: var(--ink);
    text-decoration: none;
    line-height: 1.3;
}
a.assisted-client-group__name:hover {
    color: var(--br-green);
    text-decoration: none;
}
.assisted-client-group__suite {
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.assisted-client-group__count {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    padding: 6px 10px;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid var(--line);
    flex-shrink: 0;
}
.assisted-client-group__count-num {
    font-size: 20px;
    font-weight: 800;
    line-height: 1;
    color: var(--us-navy);
}
.assisted-client-group__count-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-top: 2px;
}
.assisted-client-group__contact {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.assisted-client-group__chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    background: #f3f5f9;
    border: 1px solid var(--line);
    font-size: 12px;
    color: #344054;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.assisted-client-group__chip-ic {
    font-size: 11px;
    opacity: 0.75;
    flex-shrink: 0;
}
.assisted-client-group__profile-link {
    font-size: 12px;
    font-weight: 600;
    color: var(--us-navy);
    text-decoration: none;
    margin-left: auto;
}
.assisted-client-group__profile-link:hover {
    color: var(--br-green);
    text-decoration: underline;
}
.assisted-client-group__footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px dashed var(--line);
}
.assisted-client-group__statuses {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.assisted-client-group__status {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}
.assisted-client-group__status--novo { background: #eef1f6; color: #475467; }
.assisted-client-group__status--cotado { background: #ecfccb; color: #3f6212; }
.assisted-client-group__status--comprado { background: #e6f7ee; color: #067647; }
.assisted-client-group__status--cancelado { background: #fde8ec; color: var(--us-crimson); }
.assisted-client-group__pending {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--us-crimson);
}
.assisted-client-group__hint {
    font-size: 12px;
    color: var(--muted);
    font-style: italic;
}
.assisted-client-group__body {
    padding: 14px 16px 16px;
    background: linear-gradient(180deg, #f8fafc 0%, #f5f7fb 100%);
    border-top: 1px solid var(--line);
}
.assisted-client-group__body .assisted-card {
    border-color: #dfe3eb;
    box-shadow: 0 1px 4px rgba(16, 24, 40, 0.04);
}
.assisted-client-group__body .assisted-card:last-child {
    margin-bottom: 0;
}
.assisted-card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
}
.assisted-card__identity {
    flex: 1;
    min-width: 0;
}
.assisted-card__pills {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    margin-left: auto;
}
.assisted-card__invoice-pill {
    text-decoration: none;
}
.assisted-card__invoice-pill:hover {
    opacity: 0.88;
}
.assisted-card__thumb-wrap {
    position: relative;
    cursor: pointer;
    flex: 0 0 auto;
    display: inline-block;
}
.assisted-card__thumb {
    width: 64px;
    height: 64px;
}
.assisted-card__thumb.item-thumb-empty {
    font-size: 24px;
}
.assisted-card__photo-btn {
    position: absolute;
    right: -6px;
    bottom: -6px;
    background: var(--primary, #1A7A52);
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}
.assisted-card__info {
    flex: 1;
    min-width: 0;
}
.assisted-card__pricing {
    align-items: flex-end;
    margin-bottom: 12px;
}
.assisted-card__field {
    display: flex;
    flex-direction: column;
}
.assisted-card__label {
    font-size: 11px;
    color: #667085;
    margin-bottom: 2px;
}
.assisted-card__static {
    display: block;
    font-size: 12px;
    padding: 5px 6px;
    background: #f3f4f6;
    border-radius: 8px;
    border: 1px solid var(--line);
    text-align: center;
    line-height: 1.35;
    box-sizing: border-box;
}
.assisted-card__static.assisted-input--rate {
    padding: 9px 6px;
}
.assisted-card__actions {
    align-items: center;
}
.assisted-card__chat-btn {
    position: relative;
}
.assisted-input--cost { width: 108px; box-sizing: border-box; }
.assisted-input--profit { width: 108px; box-sizing: border-box; }
.assisted-input--sale { width: 116px; box-sizing: border-box; }
.assisted-input--rate { width: 72px; }
.assisted-input--status { width: 120px; box-sizing: border-box; }

/* notification dots on Ver conversa */
.conv-notify {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 10px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    border-radius: 999px;
    border: 2px solid #fff;
    box-sizing: border-box;
}
.conv-notify--alert {
    color: #fff;
    background: #e53935;
}
.conv-notify--ok {
    width: 10px;
    height: 10px;
    min-width: 10px;
    padding: 0;
    top: -3px;
    right: -3px;
    background: #98a2b3;
    border-width: 2px;
}

/* messenger-style chat (staff modal) */
.conv-thread--messenger {
    background: #f0f2f5;
    border: none;
    padding: 12px 10px;
}
.conv-thread--messenger .conv-day-sep span {
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.conv-thread--messenger .conv-bubble {
    max-width: 75%;
    border-radius: 18px;
    padding: 8px 12px 18px;
    position: relative;
}
.conv-thread--messenger .conv-bubble--in {
    background: #fff;
    color: #111;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
}
.conv-thread--messenger .conv-bubble--out {
    background: #0b93f6;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.conv-thread--messenger .conv-bubble__time {
    position: absolute;
    right: 10px;
    bottom: 4px;
    font-size: 10px;
    opacity: 0.72;
    line-height: 1;
}
.modal-chat__thread .conv-thread--messenger {
    background: #f0f2f5;
    border-radius: 10px;
}

@media (max-width: 640px) {
    .usd-rate-badge--toolbar {
        padding: 8px 12px;
    }
    .usd-rate-badge--toolbar .usd-rate-badge__rate {
        font-size: 14px;
    }
    .usd-rate-badge--toolbar .usd-rate-badge__label {
        font-size: 9px;
    }
    .usd-rate-badge--toolbar .usd-rate-badge__mode {
        font-size: 10px;
    }
    .assisted-client-group__add {
        justify-content: stretch;
    }
    .assisted-client-group__add-btn {
        width: 100%;
        min-height: 44px;
    }
    .assisted-client-group__box {
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
        padding: 14px 14px 14px 16px;
    }
    .assisted-client-group__toggle {
        margin-top: 0;
    }
    .assisted-client-group__status {
        padding: 2px 7px;
        font-size: 10px;
    }
    .assisted-client-group__count-num {
        font-size: 17px;
    }
    .assisted-client-group__count {
        min-width: 44px;
        padding: 4px 8px;
    }
    .assisted-client-group__content {
        width: 100%;
        flex: 1 1 100%;
    }
    .assisted-client-group__top {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .assisted-client-group__count {
        margin-left: auto;
    }
    .assisted-client-group__chip {
        max-width: calc(100% - 4px);
    }
    .assisted-client-group__profile-link {
        margin-left: 0;
    }
    .assisted-client-group__footer {
        flex-direction: column;
        align-items: flex-start;
    }
    .assisted-card__header {
        flex-direction: column;
        gap: 10px;
    }
    .assisted-card__pills {
        width: 100%;
        justify-content: flex-end;
        margin-left: 0;
    }
    .assisted-card__identity {
        width: 100%;
    }
    .assisted-card__pricing {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        width: 100%;
    }
    .assisted-card__field {
        min-width: 0;
    }
    .assisted-input--cost,
    .assisted-input--profit,
    .assisted-input--sale,
    .assisted-input--rate,
    .assisted-input--status,
    .assisted-card__static {
        width: 100%;
    }
    .assisted-card__actions {
        width: 100%;
    }
    .assisted-card__actions .btn {
        flex: 1 1 auto;
        min-height: 44px;
        justify-content: center;
    }
    .assisted-card__chat-btn {
        flex: 1 1 100%;
    }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 640px) {
    .modal-backdrop--chat {
        padding: 0;
        align-items: flex-end;
    }
    .modal-backdrop--chat.open {
        align-items: flex-end;
    }
    .modal-backdrop--chat.open .modal-chat {
        animation: sheetSlideUp 0.28s ease-out;
    }
    .modal-chat {
        max-width: 100%;
        max-height: 88vh;
        border-radius: 16px 16px 0 0;
    }
    .modal-chat__handle {
        display: block;
        width: 36px;
        height: 4px;
        margin: 10px auto 0;
        background: #d0d5dd;
        border-radius: 999px;
        flex-shrink: 0;
    }
    .modal-chat .head {
        padding-top: 8px;
    }
    .modal-chat__body {
        max-height: calc(88vh - 56px);
    }
    .modal-chat__thread .conv-thread {
        max-height: none;
    }
    .modal-chat__reply {
        position: sticky;
        bottom: 0;
        padding-bottom: max(20px, env(safe-area-inset-bottom, 0px));
    }
}

@keyframes sheetSlideUp {
    from {
        transform: translateY(100%);
        opacity: 0.6;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}
