:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #a5b4fc;
    --success: #10b981;
    --success-dark: #059669;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-dark: #d97706;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-dark: #dc2626;
    --danger-light: #fee2e2;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --sidebar-width: 260px;
    --bottom-nav-height: 64px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Reset & Base ─── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
    /* Impede overflow horizontal da página sem bloquear rolagem interna de wrappers */
    width: 100%;
    overflow-x: hidden;
}

/* ═══════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════ */

.sidebar {
    width: var(--sidebar-width);
    max-width: 85vw;
    background: linear-gradient(180deg, #1e1b4b 0%, #312e81 50%, #3730a3 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transition: var(--transition);
}

.sidebar-header {
    padding: 28px 24px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header .logo {
    font-size: 2rem;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.sidebar-brand {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    white-space: nowrap;
    line-height: 1.3;
}

.farm-name {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 170px;
    line-height: 1.3;
    display: none;
}

.farm-name.visible {
    display: block;
}

.nav-links {
    list-style: none;
    padding: 16px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-links li {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.7);
}

.nav-links li:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.nav-links li.active {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--primary-light);
}

.nav-links li i {
    width: 22px;
    text-align: center;
    font-size: 1.05rem;
}

.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.8rem;
}

/* ─── Mobile Menu Button ─── */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 1100;
    background: var(--primary);
    color: #fff;
    border: none;
    width: 46px;
    height: 46px;
    border-radius: var(--radius-sm);
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    align-items: center;
    justify-content: center;
}

.mobile-menu-btn:hover {
    background: var(--primary-dark);
}

/* ─── Sidebar overlay (mobile) ─── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 999;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
}

/* ─── Bottom Navigation (mobile only) ─── */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
    z-index: 900;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.bottom-nav::-webkit-scrollbar {
    display: none;
}

.bottom-nav-inner {
    display: flex;
    align-items: stretch;
    height: 100%;
    min-width: max-content;
    padding: 0 4px;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 14px;
    cursor: pointer;
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 600;
    font-family: inherit;
    transition: var(--transition);
    white-space: nowrap;
    min-width: 60px;
    border-top: 3px solid transparent;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

.bottom-nav-item i {
    font-size: 1.2rem;
    transition: var(--transition);
}

.bottom-nav-item.active {
    color: var(--primary);
    border-top-color: var(--primary);
}

.bottom-nav-item.active i {
    transform: translateY(-2px);
}

/* ═══════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════ */

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 32px 40px;
    min-height: 100vh;
    transition: var(--transition);
    /* Permite que filhos com table-wrapper rolem horizontalmente */
    overflow: visible;
    min-width: 0;
}

/* ─── Page Header ─── */
.page-header {
    margin-bottom: 32px;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 12px;
    letter-spacing: -0.02em;
}

.page-header h1 i {
    color: var(--primary);
    font-size: 1.5rem;
}

.page-header .subtitle {
    margin-top: 6px;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ─── Tab Content ─── */
.tab-content {
    display: none;
    animation: fadeIn 0.35s ease-out;
}

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

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

/* ═══════════════════════════════════════════
   STOCK DISPLAY (Estoque)
   ═══════════════════════════════════════════ */

.stock-display {
    margin-bottom: 32px;
}

.stock-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 40px;
    display: flex;
    align-items: center;
    gap: 28px;
    box-shadow: var(--shadow-md);
    border: 2px solid var(--border);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stock-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--border);
    transition: var(--transition);
}

.stock-card.status-high::before { background: linear-gradient(90deg, var(--success), #34d399); }
.stock-card.status-high { border-color: var(--success-light); }
.stock-card.status-medium::before { background: linear-gradient(90deg, var(--warning), #fbbf24); }
.stock-card.status-medium { border-color: var(--warning-light); }
.stock-card.status-low::before { background: linear-gradient(90deg, var(--danger), #f87171); }
.stock-card.status-low { border-color: var(--danger-light); }

.stock-icon {
    font-size: 3.5rem;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.stock-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.stock-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stock-value {
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.stock-unit {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stock-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.indicator-text {
    font-weight: 600;
    font-size: 1rem;
    padding: 8px 16px;
    border-radius: 50px;
    background: var(--bg);
}

.status-high .indicator-text { background: var(--success-light); color: var(--success-dark); }
.status-medium .indicator-text { background: var(--warning-light); color: var(--warning-dark); }
.status-low .indicator-text { background: var(--danger-light); color: var(--danger-dark); }

/* ═══════════════════════════════════════════
   STATS GRID
   ═══════════════════════════════════════════ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(220px, 45vw), 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 18px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.stat-icon.entrada { background: var(--success-light); color: var(--success-dark); }
.stat-icon.saida { background: var(--danger-light); color: var(--danger-dark); }
.stat-icon.quebrado { background: #fce7f3; color: #be185d; }
.stat-icon.faturamento { background: #ede9fe; color: #7c3aed; }
.stat-icon.despesa { background: #fff7ed; color: #c2410c; }
.stat-icon.lucro { background: #ecfdf5; color: #059669; }
.stat-icon.preco { background: #e0f2fe; color: #0284c7; }
.stat-icon.consumo { background: #ffedd5; color: #ea580c; } /* Laranja / Orange */

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.stat-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.last-update {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 12px;
}

/* ═══════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════ */

.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    position: relative;
}

/* ─── Card Help Button ─── */
.card-help-btn {
    all: unset;
    box-sizing: border-box;
    position: absolute;
    top: 8px;
    right: 8px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.card-help-btn:hover,
.card-help-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.stat-card {
    position: relative;
}

.card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card h3 i {
    color: var(--primary);
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 28px;
}

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-header-row h3 {
    margin-bottom: 0;
}

/* ═══════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════ */

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.total-input {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary);
    padding: 16px;
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    text-align: center;
    letter-spacing: -0.02em;
    transition: all 0.2s;
    cursor: pointer;
}

.total-input:hover {
    background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
    border-color: var(--primary);
}

.total-input:focus {
    background: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    outline: none;
}

.stock-info-bar {
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    color: var(--success-dark);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.stock-info-bar-danger {
    background: linear-gradient(135deg, #fce7f3, #fbcfe8);
    color: #be185d;
}

.quebrados-total-bar {
    background: linear-gradient(135deg, #fce7f3, #fbcfe8);
    color: #be185d;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.despesas-total-bar {
    background: linear-gradient(135deg, #fff7ed, #fed7aa);
    color: #c2410c;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-undo {
    background: none;
    border: 1.5px solid var(--border);
    color: var(--text-secondary);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    min-height: 40px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn-undo:hover {
    background: var(--danger-light);
    color: var(--danger-dark);
    border-color: var(--danger);
}

.btn-undo:active {
    transform: scale(0.95);
    background: var(--danger-light);
    color: var(--danger-dark);
    border-color: var(--danger);
}

/* ─── Current Price Display ─── */
.current-price-display {
    text-align: center;
    padding: 24px;
    margin-bottom: 24px;
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border-radius: var(--radius);
    border: 2px solid #fbbf24;
}

.price-label {
    display: block;
    font-size: 0.85rem;
    color: var(--warning-dark);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.price-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: #92400e;
    letter-spacing: -0.02em;
}

/* ═══════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 4px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-success {
    background: var(--success);
    color: #fff;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
}
.btn-success:hover { background: var(--success-dark); }

.btn-warning {
    background: var(--warning);
    color: #fff;
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.3);
}
.btn-warning:hover { background: var(--warning-dark); }

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

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    background: var(--bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.btn-icon:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

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

.month-label {
    min-width: 100px;
    text-align: center;
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text);
}

.day-total {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--success);
    padding: 8px 16px;
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    border-radius: var(--radius-sm);
}

.day-section {
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.day-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f9fafb, #f3f4f6);
    border-bottom: 1px solid var(--border);
}

.day-date {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
    text-transform: capitalize;
}

.day-section .table-wrapper {
    border-radius: 0;
}

.month-total-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    margin-top: 1rem;
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    border-radius: var(--radius-md);
    font-size: 1.1rem;
}

.month-total-card strong {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--primary);
}

.table-wrapper {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-sm);
    /* Garante que a tabela nunca cause overflow na página */
    max-width: 100%;
    width: 100%;
    touch-action: pan-x pan-y;
}

.table-wrapper > table {
    width: max-content;
    min-width: 100%;
}

table {
    width: 100%;
    border-collapse: collapse;
    /* Remove min-width fixo — deixa a tabela rolar dentro do wrapper */
}

thead th {
    background: var(--bg);
    padding: 12px 16px;
    text-align: left;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border);
}

tbody td {
    padding: 14px 16px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text);
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: #f8fafc;
}

tbody tr.total-row {
    background: linear-gradient(135deg, #fef9f3, #fef3e2);
    border-top: 2px solid var(--warning);
    font-weight: 600;
}

tbody tr.total-row:hover {
    background: linear-gradient(135deg, #fef5e7, #feebc8);
}

tbody tr.total-row td {
    padding: 16px;
    color: var(--text);
    border-bottom: none;
    font-size: 0.95rem;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: 32px 16px !important;
}

/* ─── Badges ─── */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-success {
    background: var(--success-light);
    color: var(--success-dark);
}

.badge-inactive {
    background: var(--bg);
    color: var(--text-muted);
}

/* ═══════════════════════════════════════════
   REPORTS & CHARTS
   ═══════════════════════════════════════════ */

.report-filters {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 28px;
    padding: 24px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.filter-group select {
    padding: 10px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text);
    background: var(--surface);
    cursor: pointer;
    min-width: 140px;
    transition: var(--transition);
}

.filter-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-top: 24px;
}

.chart-card {
    padding: 24px;
}

.chart-card h3 {
    margin-bottom: 16px;
}

.chart-card-small {
    grid-column: 1 / -1;
    max-width: 500px;
    margin: 0 auto;
    width: 100%;
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

.chart-container-pie {
    height: 280px;
    max-width: 350px;
    margin: 0 auto;
}

/* ═══════════════════════════════════════════
   TOAST NOTIFICATIONS
   ═══════════════════════════════════════════ */

#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    color: #fff;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 380px;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-success {
    background: linear-gradient(135deg, #059669, #10b981);
}

.toast-error {
    background: linear-gradient(135deg, #dc2626, #ef4444);
}

.toast-info {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}

.toast i {
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════
   LOADING SPINNER
   ═══════════════════════════════════════════ */

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════
   SCROLLBAR
   ═══════════════════════════════════════════ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ═══════════════════════════════════════════
   RESPONSIVE DESIGN
   ═══════════════════════════════════════════ */

@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr;
    }

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

    .chart-card-small {
        max-width: 100%;
    }

    .main-content {
        padding: 24px 20px;
    }
}

/* ─── Tablet ─── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
    }

    .mobile-menu-btn {
        display: flex;
    }

    .bottom-nav {
        display: block;
        padding-bottom: env(safe-area-inset-bottom, 0px);
        height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    }

    .main-content {
        margin-left: 0;
        padding: 70px 14px calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px) + 20px);
        min-width: 0;
        overflow: visible;
    }

    /* ─── Stock card ─── */
    .stock-card {
        flex-direction: row;
        align-items: center;
        padding: 16px 14px;
        gap: 12px;
    }

    .stock-icon {
        font-size: 2.2rem;
        flex-shrink: 0;
    }

    .stock-value {
        font-size: 2rem;
    }

    .stock-indicator {
        flex-direction: column;
        align-items: flex-end;
    }

    /* ─── Stats grid ─── */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        margin-bottom: 18px;
    }

    .stat-card {
        padding: 14px 12px;
        gap: 10px;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 0.95rem;
        flex-shrink: 0;
    }

    .stat-value {
        font-size: 1.05rem;
    }

    .stat-label {
        font-size: 0.75rem;
    }

    /* ─── Page header ─── */
    .page-header {
        margin-bottom: 18px;
    }

    .page-header h1 {
        font-size: 1.25rem;
    }

    .page-header .subtitle {
        font-size: 0.85rem;
    }

    /* ─── Cards ─── */
    .card {
        padding: 18px 14px;
    }

    /* ─── Forms ─── */
    .total-input {
        font-size: 1.4rem;
        padding: 12px;
    }

    .price-value {
        font-size: 1.8rem;
    }

    /* ─── Tables ─── */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 100%;
    }

    tbody td {
        padding: 11px 10px;
        font-size: 0.82rem;
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    thead th {
        padding: 10px;
        font-size: 0.73rem;
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    /* ─── Content grid ─── */
    .content-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    /* ─── Report filters ─── */
    .report-filters {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 16px;
    }

    /* ─── Toast (acima da bottom nav) ─── */
    #toast-container {
        left: 12px;
        right: 12px;
        bottom: calc(var(--bottom-nav-height) + 12px);
    }

    .toast {
        max-width: 100%;
    }

    /* ─── Btn undo: icon-only circle ─── */
    .btn-undo {
        padding: 10px 12px;
        min-height: 44px;
        min-width: 44px;
        justify-content: center;
        border-radius: 50%;
        font-size: 0.95rem;
    }

    .btn-undo .btn-undo-label {
        display: none;
    }

    /* ─── Login ─── */
    .login-card {
        padding: 32px 22px;
    }

    .login-logo {
        font-size: 3rem;
    }

    .login-header h1 {
        font-size: 1.5rem;
    }

    /* ─── Modal ─── */
    .modal-card {
        padding: 24px 18px;
        margin: 10px;
        max-width: calc(100vw - 20px);
    }

    .modal-actions {
        flex-direction: column;
    }

    .modal-actions .btn,
    .modal-actions .btn-icon-text {
        width: 100%;
        justify-content: center;
    }

    /* ─── Export buttons ─── */
    .export-buttons {
        width: 100%;
        flex-wrap: wrap;
    }

    .btn-export {
        flex: 1;
        min-width: 100px;
        justify-content: center;
        padding: 10px;
    }

    /* ─── Clientes search ─── */
    .clientes-search-input {
        width: 150px;
    }

    .wa-label {
        display: none;
    }
}

/* ─── Small phones ─── */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .main-content {
        padding-left: 10px;
        padding-right: 10px;
    }

    .stock-card {
        padding: 14px 12px;
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }

    .stock-icon {
        font-size: 2rem;
    }

    .stock-value {
        font-size: 2rem;
    }

    .stock-indicator {
        align-items: center;
    }

    .login-card {
        margin: 10px;
        padding: 26px 18px;
    }

    table {
        min-width: 100%;
    }

    /* Bottom nav: só ícone */
    .bottom-nav-item {
        min-width: 48px;
        padding: 6px 8px;
    }

    .bottom-nav-item span {
        display: none;
    }

    .bottom-nav-item i {
        font-size: 1.35rem;
    }

    .card {
        padding: 14px 12px;
        border-radius: var(--radius-sm);
    }

    .export-buttons {
        flex-direction: column;
    }

    .btn-export {
        width: 100%;
    }
}

/* ═══════════════════════════════════════════
   TELA DE LOGIN
   ═══════════════════════════════════════════ */

.login-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 40%, #4338ca 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 16px;
}

.login-overlay.hidden {
    display: none;
}

.login-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    animation: loginSlideUp 0.4s ease-out;
}

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

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo {
    font-size: 3.5rem;
    display: block;
    margin-bottom: 8px;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.15));
}

.login-header h1 {
    font-size: 1.75rem;
    color: var(--text);
    font-weight: 800;
    letter-spacing: -0.03em;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 4px;
}

.login-card .form-group {
    margin-bottom: 18px;
}

.login-card label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.login-card label i {
    margin-right: 4px;
    color: var(--primary);
}

.login-card input[type="text"],
.login-card input[type="password"] {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--bg);
}

.login-card input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.password-wrapper {
    position: relative;
}

.password-wrapper input {
    padding-right: 44px !important;
}

.btn-toggle-password {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    font-size: 1rem;
    transition: var(--transition);
    border-radius: 50%;
    min-width: 36px;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-toggle-password:hover {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.08);
}

.login-error {
    background: var(--danger-light);
    color: var(--danger-dark);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

.btn-login {
    width: 100%;
    padding: 14px;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    margin-top: 8px;
    min-height: 48px;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.login-footer strong {
    color: var(--primary);
}

/* ═══════════════════════════════════════════
   MODAL ALTERAR SENHA
   ═══════════════════════════════════════════ */

.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 16px;
    backdrop-filter: blur(4px);
}

.modal-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 32px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    animation: loginSlideUp 0.3s ease-out;
}

.modal-card h3 {
    font-size: 1.2rem;
    color: var(--text);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-card h3 i {
    color: var(--warning);
}

.modal-card .form-group {
    margin-bottom: 16px;
}

.modal-card label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.modal-card input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    background: var(--bg);
    transition: var(--transition);
}

.modal-card input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

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

.btn-icon-text {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon-text:hover {
    border-color: var(--danger);
    color: var(--danger);
    background: var(--danger-light);
}

/* ═══════════════════════════════════════════
   MODAL DE CONFIRMAÇÃO CUSTOMIZADO
   ═══════════════════════════════════════════ */

.modal-confirm-card {
    text-align: center;
    max-width: 400px;
}

.modal-confirm-card h3 {
    justify-content: center;
}

.modal-confirm-card .modal-actions {
    justify-content: center;
}

.confirm-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: var(--warning-light);
    display: flex;
    align-items: center;
    justify-content: center;
}

.confirm-icon i {
    font-size: 1.5rem;
    color: var(--warning);
}

.confirm-message {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 8px;
}

/* ═══════════════════════════════════════════
   SIDEBAR — SEÇÃO USUÁRIO
   ═══════════════════════════════════════════ */

.sidebar-user {
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.88rem;
    font-weight: 500;
    min-width: 0;
}

.user-info i {
    font-size: 1.3rem;
    color: var(--primary-light);
    flex-shrink: 0;
}

.user-info span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.btn-sidebar-action {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: rgba(255, 255, 255, 0.65);
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.85rem;
}

.btn-sidebar-action:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

.btn-sidebar-action.btn-logout:hover {
    background: rgba(239, 68, 68, 0.35);
    color: #fca5a5;
}

/* ═══════════════════════════════════════════
   BOTÕES DE EXPORTAÇÃO
   ═══════════════════════════════════════════ */

.export-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-export {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-export:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-export i {
    font-size: 1rem;
}

.btn-export-excel {
    border-color: #059669;
    color: #059669;
}

.btn-export-excel:hover {
    background: #d1fae5;
    border-color: #10b981;
}

.btn-export-pdf {
    border-color: #dc2626;
    color: #dc2626;
}

.btn-export-pdf:hover {
    background: #fee2e2;
    border-color: #ef4444;
}

.btn-export-anual {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-export-anual:hover {
    background: #e0e7ff;
    border-color: var(--primary-dark);
}

/* ═══════════════════════════════════════════
   PAINEL ADMIN
   ═══════════════════════════════════════════ */

.badge-admin {
    background: linear-gradient(135deg, #7c3aed, #6366f1);
    color: #fff;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.badge-user {
    background: var(--bg);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid var(--border);
    white-space: nowrap;
}

.admin-actions {
    display: flex;
    gap: 6px;
}

.btn-admin-action {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition);
}

.btn-admin-reset {
    background: var(--warning-light);
    color: var(--warning-dark);
}

.btn-admin-reset:hover {
    background: var(--warning);
    color: #fff;
}

.btn-admin-delete {
    background: var(--danger-light);
    color: var(--danger-dark);
}

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

.btn-admin-delete:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.form-hint {
    display: block;
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-top: 4px;
}

/* User badge nos logs de tabela */
.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 500;
    border: 1px solid var(--border);
    white-space: nowrap;
}

/* Código de username na tabela admin */
.admin-users-list code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.82rem;
    color: var(--primary-dark);
}

/* ═══════════════════════════════════════════
   MOBILE UX ENHANCEMENTS
   ═══════════════════════════════════════════ */

/* Smooth touch scrolling everywhere */
.tab-content, .table-wrapper, .main-content {
    -webkit-overflow-scrolling: touch;
}

/* Better tap targets — minimum 44px for all interactive elements */
@media (pointer: coarse) {
    input, select, button, .nav-links li {
        min-height: 44px;
    }

    .btn {
        min-height: 44px;
        padding: 12px 20px;
    }

    select {
        padding: 10px 12px;
    }
}

/* Pull-to-refresh prevention */
body {
    overscroll-behavior-y: contain;
}

/* Safe area insets para iPhones com notch */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .sidebar {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .login-overlay {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Desabilitar seleção de texto em elementos interativos */
.btn, .btn-undo, .btn-export, .btn-sidebar-action, .nav-links li {
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

@keyframes shimmer {
    0% { background-position: -1000px 0; }
    100% { background-position: 1000px 0; }
}

.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 0px,
        #f8f8f8 40px,
        #f0f0f0 80px
    );
    background-size: 1000px 100%;
    animation: shimmer 1.5s infinite linear;
    border-radius: var(--radius-sm);
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
    border-radius: 4px;
}

.skeleton-text.large {
    height: 28px;
    width: 60%;
}

.skeleton-text.small {
    height: 14px;
    width: 80%;
}

.skeleton-stat-card {
    display: flex;
    gap: 16px;
    align-items: center;
    padding: 20px;
}

.skeleton-stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
}

.skeleton-stat-info {
    flex: 1;
}

.skeleton-table-row {
    display: flex;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.skeleton-table-cell {
    height: 20px;
    flex: 1;
}

.skeleton-chart {
    width: 100%;
    height: 300px;
    border-radius: var(--radius);
}

.loading-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 10;
    border-radius: var(--radius);
    padding: 28px;
}

.loading-overlay.active {
    display: block;
}

.skeleton-price-card {
    padding: 20px;
    text-align: center;
}

.skeleton-price-value {
    height: 48px;
    width: 150px;
    margin: 0 auto 12px;
}

.skeleton-price-label {
    height: 16px;
    width: 100px;
    margin: 0 auto;
}

/* Add smooth transitions */
.stats-grid,
.charts-grid,
.table-wrapper {
    transition: opacity 0.3s ease;
}

.stat-value,
.price-value {
    min-width: 60px;
    display: inline-block;
    transition: color 0.2s ease;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.stat-value:empty::before,
.price-value:empty::before {
    content: '...';
    color: var(--text-muted);
    animation: pulse 1.5s ease-in-out infinite;
}

tbody.loading {
    opacity: 0.6;
    pointer-events: none;
}

.admin-config-card {
    grid-column: 1 / -1;
}

.admin-config-card .form-group label i {
    color: var(--primary);
    width: 18px;
    text-align: center;
    margin-right: 4px;
}

.admin-config-card select {
    appearance: auto;
}

@media (min-width: 768px) {
    .admin-config-card form {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0 24px;
    }
    .admin-config-card form button[type="submit"] {
        grid-column: 1 / -1;
    }
}

.modal-changelog {
    max-width: 800px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
}

.btn-close-changelog {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border);
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 1;
}

.btn-close-changelog:hover {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
    transform: rotate(90deg);
}

.changelog-header {
    text-align: center;
    padding-bottom: 24px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 24px;
}

.changelog-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 12px;
    animation: bounce 1s ease-in-out;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.changelog-header h2 {
    color: var(--primary);
    margin: 0 0 8px;
    font-size: 28px;
}

.changelog-version {
    color: var(--text-secondary);
    font-size: 14px;
}

#changelog-current-version {
    font-weight: 600;
    color: var(--primary);
}

.changelog-content {
    padding: 0 4px;
}

.changelog-loading {
    text-align: center;
    padding: 40px 0;
    color: var(--text-secondary);
}

.changelog-loading .spinner {
    margin: 0 auto 16px;
}

.version-block {
    margin-bottom: 32px;
    padding: 20px;
    background: var(--bg);
    border-radius: var(--radius);
    border-left: 4px solid var(--primary);
}

.version-block:last-child {
    margin-bottom: 0;
}

.version-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.version-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
}

.version-date {
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--surface);
    padding: 4px 12px;
    border-radius: 20px;
}

.version-section {
    margin-bottom: 16px;
}

.version-section:last-child {
    margin-bottom: 0;
}

.version-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.version-section h4 i {
    width: 16px;
}

.version-section.features h4 { color: var(--success); }
.version-section.improvements h4 { color: var(--primary); }
.version-section.fixes h4 { color: var(--danger); }

.version-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.version-list li {
    padding: 8px 0 8px 24px;
    position: relative;
    color: var(--text);
    line-height: 1.5;
}

.version-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 14px;
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
}

.version-section.features .version-list li::before { background: var(--success); }
.version-section.improvements .version-list li::before { background: var(--primary); }
.version-section.fixes .version-list li::before { background: var(--danger); }

@media (max-width: 640px) {
    .modal-changelog {
        max-height: 90vh;
        margin: 20px;
    }

    .changelog-header h2 {
        font-size: 24px;
    }

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

    .version-block {
        padding: 16px;
    }
}

/* ═══════════════════════════════════════════
   CLIENTES
═══════════════════════════════════════════ */

/* Painel de busca */
.clientes-list-card .card-header-row {
    flex-wrap: wrap;
    gap: 10px;
}

.clientes-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.clientes-search-icon {
    position: absolute;
    left: 10px;
    color: var(--text-muted);
    font-size: 13px;
    pointer-events: none;
}

.clientes-search-input {
    padding: 7px 12px 7px 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--bg);
    color: var(--text);
    width: 200px;
    transition: var(--transition);
}

.clientes-search-input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
}

/* Barra de contagem */
.clientes-count-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: var(--bg);
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-secondary);
    border-radius: 0 0 var(--radius) var(--radius);
}

.inativo-count {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--danger-dark);
    font-weight: 600;
}

/* Badges de inatividade */
.inatividade-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.inatividade-hoje {
    background: var(--success-light);
    color: var(--success-dark);
}

.inatividade-ok {
    background: #e0f2fe;
    color: #0369a1;
}

.inatividade-alerta {
    background: var(--danger-light);
    color: var(--danger-dark);
}

.inatividade-nunca {
    background: var(--warning-light);
    color: var(--warning-dark);
}

/* Linha de cliente inativo destacada */
tr.cliente-inativo td {
    background: #fff8f8;
}

/* Badge de cliente nas vendas */
.cliente-badge {
    display: inline-block;
    padding: 2px 9px;
    background: linear-gradient(135deg, #ede9fe, #ddd6fe);
    color: #5b21b6;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

/* Número de telefone */
.numero-tel {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: var(--text);
    letter-spacing: 0.5px;
}

/* Botão WhatsApp */
.btn-whatsapp {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: #25D366;
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
}

.btn-whatsapp:hover:not(:disabled) {
    background: #128C7E;
    transform: translateY(-1px);
}

.btn-whatsapp:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.7;
}

.btn-whatsapp .fab {
    font-size: 14px;
}

/* Botão editar pequeno */
.btn-edit-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: var(--primary-light);
    color: var(--primary-dark);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
}

.btn-edit-small:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-1px);
}

.action-btns {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* Label opcional nos forms */
.optional-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
}

.required-mark {
    color: var(--danger);
    font-weight: 700;
}

/* Text muted helper */
.text-muted {
    color: var(--text-muted);
}

/* Select de cliente no form de venda */
#venda-cliente {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--text);
    font-size: 14px;
    transition: var(--transition);
    appearance: auto;
}

#venda-cliente:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

@media (max-width: 640px) {
    .clientes-search-input {
        width: 150px;
    }
    .wa-label {
        display: none;
    }
}

/* ═══════════════════════════════════════════
   CARD HELP — TOOLTIP (desktop) & SHEET (mobile)
═══════════════════════════════════════════ */

/* ── Desktop: tooltip posicionado ── */
#card-help-tooltip {
    position: fixed;
    display: none;
    background: #1e293b;
    color: #f1f5f9;
    font-size: 0.82rem;
    line-height: 1.55;
    padding: 11px 15px;
    border-radius: 10px;
    width: 270px;
    max-width: calc(100vw - 20px);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.25);
    z-index: 9999;
    pointer-events: none;
    font-weight: 400;
    animation: helpFadeIn 0.15s ease;
}

#card-help-tooltip::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 14px;
    width: 12px;
    height: 7px;
    background: #1e293b;
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

#card-help-tooltip.above::before {
    top: auto;
    bottom: -6px;
    clip-path: polygon(0% 0%, 100% 0%, 50% 100%);
}

/* ── Mobile: backdrop ── */
#card-help-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 9998;
    display: none;
    -webkit-tap-highlight-color: transparent;
}

/* ── Mobile: bottom sheet ── */
#card-help-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #1e293b;
    color: #f1f5f9;
    padding: 18px 20px calc(20px + env(safe-area-inset-bottom, 0px));
    border-radius: 16px 16px 0 0;
    z-index: 9999;
    font-size: 0.9rem;
    line-height: 1.65;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.35);
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

#card-help-sheet.visible {
    transform: translateY(0);
}

#card-help-sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

#card-help-sheet-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #94a3b8;
}

#card-help-sheet-close {
    all: unset;
    box-sizing: border-box;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.12);
    color: #f1f5f9;
    cursor: pointer;
    font-size: 0.8rem;
    -webkit-tap-highlight-color: transparent;
}

#card-help-sheet-close:active {
    background: rgba(255, 255, 255, 0.25);
}

@keyframes helpFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
