@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  /* CORES ATUALIZADAS PARA PADRÃO ANANINDEUA MOTORS (PRETO, VERMELHO, CINZA/PRATA) */
  --bg-body: #f4f4f5;
  --bg-surface: #ffffff;
  --bg-sidebar: #000000; /* Preto sólido */
  
  --text-primary: #18181b;
  --text-secondary: #52525b;
  --text-tertiary: #a1a1aa;
  --text-sidebar: #d4d4d8;
  --text-inverse: #ffffff;
  
  --color-primary: #e60000; /* Vermelho Ananindeua */
  --color-primary-hover: #cc0000;
  --color-primary-light: #fee2e2;
  
  --color-success: #10b981;
  --color-success-bg: #ecfdf5;
  --color-success-border: #a7f3d0;
  
  --color-danger: #e60000;
  --color-danger-bg: #fee2e2;
  --color-danger-border: #fca5a5;
  
  --color-warning: #f59e0b;
  --color-warning-bg: #fffbeb;
  --color-warning-border: #fde68a;
  
  --color-purple: #71717a; /* Substituído roxo por cinza */
  --color-purple-bg: #f4f4f5;
  
  --border-light: #e4e4e7;
  --border-medium: #d4d4d8;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-modal: 0 25px 50px -12px rgb(0 0 0 / 0.25);
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --font-family: 'Inter', system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  font-family: var(--font-family);
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
  flex-direction: column;
}

/* ========================================= */
/* LOGO CUSTOMIZADA ANANINDEUA MOTORS        */
/* ========================================= */
.sidebar { width: 280px; background: var(--bg-sidebar); display: flex; flex-direction: column; padding: 1.5rem 1rem; border-right: 1px solid #27272a; flex-shrink: 0; z-index: 10; }
.brand { display: flex; align-items: center; justify-content: center; padding: 0 0.5rem 1.5rem 0.5rem; border-bottom: 1px solid #27272a; }
.system-logo { display: block; width: min(100%, 220px); height: 62px; object-fit: contain; background: #fff; border-radius: 8px; padding: 5px 10px; }

.custom-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}
.logo-top {
  color: #e4e4e7; /* Prata/Cinza claro */
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.logo-bottom {
  color: var(--color-primary); /* Vermelho */
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-style: italic;
  margin-top: -2px;
}

/* ========================================= */

.nav-menu { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 1.5rem; flex-grow: 1; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 0.75rem 1rem; border-radius: var(--radius-md); border: none; background: transparent; color: var(--text-sidebar); font-size: 0.95rem; cursor: pointer; transition: all var(--transition-fast); text-align: left; }
.nav-item .icon { width: 20px; height: 20px; opacity: 0.7; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,0.08); color: var(--text-inverse); }
.nav-item.active { background: var(--color-primary); color: var(--text-inverse); }
.sidebar-footer { padding-top: 1rem; border-top: 1px solid #27272a; }
.user-profile { display: flex; align-items: center; gap: 12px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #27272a; color: white; display: flex; align-items: center; justify-content: center; font-weight: 600; flex-shrink: 0; border: 1px solid #3f3f46; }
.user-info { display: flex; flex-direction: column; overflow: hidden; }
.user-name { color: var(--text-inverse); font-size: 0.875rem; font-weight: 600; white-space: nowrap; text-overflow: ellipsis; }
.user-role { color: #a1a1aa; font-size: 0.75rem; white-space: nowrap; text-overflow: ellipsis; }

/* Main Area Base */
.main-content {
  flex-grow: 1;
  padding: 2rem;
  overflow-y: auto;
  overflow-x: hidden;
  height: 100vh;
  height: 100dvh;
  min-width: 0; 
}
.topbar { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 2rem; flex-wrap: wrap; gap: 1rem; }
.page-title h1 { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.25rem; }
.page-title p { color: var(--text-secondary); font-size: 0.95rem; }
.date-badge { display: flex; align-items: center; gap: 8px; background: var(--bg-surface); padding: 0.6rem 1.2rem; border-radius: 20px; border: 1px solid var(--border-light); font-size: 0.875rem; font-weight: 600; }

/* Cards & Grid Defaults */
.card, .panel, .form-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  min-width: 0; 
}
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.5rem; margin-bottom: 2rem; }
.stat-card { padding: 1.5rem; display: flex; justify-content: space-between; position: relative; overflow: hidden; }
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: var(--border-light); }
.stat-card:nth-child(1)::before { background: var(--color-primary); }
.stat-card:nth-child(2)::before { background: var(--color-warning); }
.stat-card:nth-child(3)::before { background: var(--color-success); }
.stat-card:nth-child(4)::before { background: #71717a; }
.stat-card.interactive { cursor: pointer; transition: all var(--transition-normal); }
.stat-card.interactive:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--color-primary-light); }
.card-hover-indicator { position: absolute; bottom: 0.75rem; left: 1.5rem; font-size: 0.75rem; color: var(--color-primary); opacity: 0; transition: all var(--transition-normal); }
.stat-card.interactive:hover .card-hover-indicator { opacity: 1; }
.stat-label { font-size: 0.875rem; color: var(--text-secondary); font-weight: 500; display: block; margin-bottom: 0.5rem; }
.stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.text-amber { color: var(--color-warning); }
.text-green { color: var(--color-success); }
.text-gray { color: #52525b; }
.stat-icon-wrapper { width: 48px; height: 48px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon-wrapper.red { background: var(--color-primary-light); color: var(--color-primary); }
.stat-icon-wrapper.amber { background: var(--color-warning-bg); color: var(--color-warning); }
.stat-icon-wrapper.green { background: var(--color-success-bg); color: var(--color-success); }
.stat-icon-wrapper.gray { background: #f4f4f5; color: #71717a; }

/* Panels & Tables Base */
.panel { padding: 1.5rem; }
.dashboard-panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; }
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border-light); flex-wrap: wrap; gap: 1rem; }
.panel-header h3 { font-size: 1.125rem; font-weight: 600; margin: 0; }
.title-with-icon { display: flex; align-items: center; gap: 10px; }
.indicator-dot { width: 10px; height: 10px; border-radius: 50%; }
.indicator-dot.amber { background: var(--color-warning); box-shadow: 0 0 8px var(--color-warning); }

.table-responsive-wrapper {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
  background: #fff;
}
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.data-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 0.9rem; min-width: 650px; }
.data-table th { padding: 1rem; background: #f8fafc; color: var(--text-secondary); font-weight: 600; text-transform: uppercase; font-size: 0.75rem; border-bottom: 2px solid var(--border-light); white-space: nowrap; }
.data-table td { padding: 1rem; border-bottom: 1px solid var(--border-light); vertical-align: middle; white-space: nowrap; }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody tr.installment-overdue,
.data-table tbody tr.installment-overdue:hover { background: #fff1f2; }
.text-right { text-align: right !important; }

/* Badges */
.status-badge { padding: 0.35rem 0.75rem; border-radius: 20px; font-size: 0.75rem; font-weight: 600; display: inline-flex; align-items: center; white-space: nowrap; }
.status-badge.open { background: #e0f2fe; color: #0284c7; } /* Azul para aberto normal */
.status-badge.closed { background: #f4f4f5; color: var(--text-secondary); }
.status-badge.today { background: var(--color-warning-bg); color: #b45309; border: 1px solid var(--color-warning-border); animation: pulse-warning 2s infinite; }
.status-badge.late { background: var(--color-danger-bg); color: #b91c1c; border: 1px solid var(--color-danger-border); animation: pulse-danger 2s infinite; }

@keyframes pulse-warning { 0% { box-shadow: 0 0 0 0 rgba(245,158,11,0.4); } 70% { box-shadow: 0 0 0 6px rgba(245,158,11,0); } 100% { box-shadow: 0 0 0 0 rgba(245,158,11,0); } }
@keyframes pulse-danger { 0% { box-shadow: 0 0 0 0 rgba(230,0,0,0.4); } 70% { box-shadow: 0 0 0 6px rgba(230,0,0,0); } 100% { box-shadow: 0 0 0 0 rgba(230,0,0,0); } }

.type-badge { padding: 0.25rem 0.6rem; border-radius: var(--radius-sm); font-weight: 600; font-size: 0.75rem; display: inline-block; white-space: nowrap; }
.type-badge.income { background: var(--color-success-bg); color: #047857; }
.type-badge.expense { background: var(--color-danger-bg); color: #b91c1c; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.6rem 1.2rem; border-radius: var(--radius-md); font-weight: 600; font-size: 0.875rem; cursor: pointer; border: 1px solid transparent; transition: all var(--transition-fast); white-space: nowrap; outline: none; }
.btn-primary { background: var(--color-primary); color: white; box-shadow: 0 2px 4px rgba(230,0,0,0.2); }
.btn-primary:hover { background: var(--color-primary-hover); transform: translateY(-1px); }
.btn-secondary { background: #f4f4f5; color: var(--text-primary); border-color: var(--border-medium); }
.btn-secondary:hover { background: #e4e4e7; }
.btn-outline { background: transparent; border-color: var(--border-medium); color: var(--text-secondary); }
.btn-outline:hover { background: #f8fafc; color: var(--text-primary); border-color: var(--text-secondary); }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.75rem; border-radius: var(--radius-sm); }
.btn-action-edit { background: #f4f4f5; color: #0284c7; } /* Azul para editar */
.btn-action-edit:hover { background: #e0f2fe; }
.btn-action-success { background: var(--color-success-bg); color: #047857; }
.btn-action-success:hover { background: #d1fae5; }
.btn-action-delete { background: var(--color-danger-bg); color: #b91c1c; }
.btn-action-delete:hover { background: #fecaca; }
.btn-action-wa { background-color: #dcfce7; color: #16a34a; padding: 0.4rem 0.6rem; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius-sm); transition: all var(--transition-fast); text-decoration: none; }
.btn-action-wa:hover { background-color: #bbf7d0; color: #15803d; }
.full-width { width: 100%; }
.section-actions-bar { margin-bottom: 1.5rem; display: flex; justify-content: flex-end; }

/* Forms Base */
.form-card { padding: 1.5rem; }
.form-section-title { font-size: 0.85rem; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; border-bottom: 1px solid var(--border-light); padding-bottom: 0.5rem; margin-bottom: 1rem; }
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 0.4rem; }
.form-input { width: 100%; padding: 0.6rem 0.8rem; background: #f8fafc; border: 1px solid var(--border-medium); border-radius: var(--radius-md); font-size: 0.9rem; outline: none; transition: all var(--transition-fast); font-family: inherit; }
.form-input:focus { background: white; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(230,0,0,0.15); }
.form-row { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.flex-1 { flex: 1; min-width: 0; } 
.input-with-prefix { position: relative; display: flex; align-items: center; }
.input-with-prefix .prefix { position: absolute; left: 0.8rem; color: var(--text-secondary); font-weight: 500; }
.input-with-prefix .form-input { padding-left: 2.5rem; }
.select-wrapper { position: relative; }
.form-select { appearance: none; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") no-repeat right 0.8rem center; padding-right: 2.5rem; }
.radio-toggle-group { display: flex; gap: 0.75rem; background: #f4f4f5; padding: 0.3rem; border-radius: var(--radius-md); border: 1px solid var(--border-light); }
.radio-pill { flex: 1; text-align: center; padding: 0.5rem; cursor: pointer; font-weight: 600; font-size: 0.85rem; border-radius: var(--radius-sm); color: var(--text-secondary); transition: all var(--transition-fast); }
.radio-pill input { display: none; }
.radio-pill.income-pill:has(input:checked) { background: var(--bg-surface); color: #047857; box-shadow: var(--shadow-sm); }
.radio-pill.expense-pill:has(input:checked) { background: var(--bg-surface); color: #b91c1c; box-shadow: var(--shadow-sm); }

.alert { padding: 0.75rem 1rem; border-radius: var(--radius-md); font-size: 0.85rem; display: flex; gap: 0.5rem; align-items: flex-start; line-height: 1.4; }
.alert-info { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }
.alert-info svg { flex-shrink: 0; margin-top: 2px; }
.mt-2 { margin-top: 0.5rem; } .mt-4 { margin-top: 1rem; }

/* Layouts Específicos */
.cashflow-grid { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.report-filters { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.cashflow-month-filter-wrap { flex: 0 0 190px; min-width: 160px; margin: 0; }
.flex-wrap { flex-wrap: wrap; }
.filter-item { display: flex; flex-direction: column; gap: 0.25rem; min-width: 140px; flex: 1; }
.filter-item label { font-size: 0.75rem; color: var(--text-secondary); font-weight: 600; }
.report-summary-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.summary-box { padding: 1.25rem; border-radius: var(--radius-md); display: flex; align-items: center; gap: 1rem; border: 1px solid transparent; min-width: 0; }
.summary-icon { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.5); font-weight: bold; font-size: 1.2rem; flex-shrink: 0; }
.summary-data { display: flex; flex-direction: column; overflow: hidden;}
.summary-data span { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; opacity: 0.8; white-space: nowrap; }
.summary-data strong { font-size: 1.4rem; line-height: 1.2; word-break: break-word; }
.green-box { background: var(--color-success-bg); color: #047857; border-color: var(--color-success-border); }
.red-box { background: var(--color-danger-bg); color: #b91c1c; border-color: var(--color-danger-border); }
.balance-box { background: #f4f4f5; color: #52525b; border-color: #e4e4e7; }

.content-section { display: none; animation: fadeIn var(--transition-normal); }
.content-section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* Modais Base */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(4px); display: none; justify-content: center; align-items: center; z-index: 9999; padding: 1rem; opacity: 0; transition: opacity var(--transition-normal); }
.modal-backdrop.open { display: flex; opacity: 1; }
.modal-dialog { background: var(--bg-surface); border-radius: var(--radius-lg); width: 100%; max-width: 640px; box-shadow: var(--shadow-modal); transform: scale(0.95) translateY(10px); transition: transform var(--transition-normal); display: flex; flex-direction: column; max-height: 90vh; min-height: 0; }
#rental-modal .modal-dialog { height: min(90dvh, 60rem); max-height: 90dvh; }
#rental-form { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; overflow: hidden; }
.modal-backdrop.open .modal-dialog { transform: scale(1) translateY(0); }
.modal-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border-light); display: flex; justify-content: space-between; align-items: center; flex: 0 0 auto; }
.modal-header h3 { font-size: 1.25rem; font-weight: 600; margin: 0; }
.btn-close { background: transparent; border: none; cursor: pointer; color: var(--text-secondary); padding: 0.25rem; border-radius: var(--radius-sm); }
.btn-close:hover { background: #f4f4f5; color: var(--color-danger); }
.modal-body { padding: 1.5rem; overflow-y: auto; -webkit-overflow-scrolling: touch; flex: 1 1 auto; min-height: 0; overscroll-behavior: contain; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border-light); display: flex; justify-content: flex-end; gap: 0.75rem; background: #fafafa; border-radius: 0 0 var(--radius-lg) var(--radius-lg); flex-wrap: wrap; flex: 0 0 auto; }
.installment-fields { margin-top: 1.25rem; }
.installment-help { margin: -0.4rem 0 1rem; font-size: 0.82rem; color: var(--text-secondary); }
.installment-row { padding: 1rem; margin-bottom: 0.75rem; border: 1px solid var(--border-light); border-radius: var(--radius-md); background: #fafafa; }
.installment-title { margin-bottom: 0.8rem; font-weight: 700; color: var(--text-primary); }
.installment-row .form-group { margin-bottom: 0.75rem; }
.table-empty { text-align: center; color: var(--text-tertiary); padding: 2rem !important; }
.print-report-heading { display: none; }


/* ========================================================================= */
/* ====== RESPONSIVIDADE MOBILE & TABLET (MEDIA QUERIES) ====== */
/* ========================================================================= */

@media (min-width: 769px) {
  .app-container { flex-direction: row; height: 100vh; height: 100dvh; overflow: hidden; }
  .main-content { min-height: 0; overscroll-behavior-y: contain; }
}

@media (max-width: 992px) {
  .cashflow-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 768px) {
  
  /* Layout Geral no Mobile */
  body { font-size: 14px; }
  .app-container { flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }
  .main-content { padding: 1rem; flex-grow: 1; overflow-y: auto; overflow-x: hidden; height: auto; }
  
  /* Topbar */
  .topbar { flex-direction: column; gap: 1rem; align-items: flex-start; margin-bottom: 1.5rem; }
  
  /* Sidebar Navbar no topo */
  .sidebar { 
    width: 100%; 
    padding: 0; 
    border-right: none; 
    border-bottom: 1px solid #27272a;
    background: var(--bg-sidebar);
    order: -1;
  }
  .brand { 
    padding: 1rem; 
    border: none; 
    margin: 0; 
    justify-content: flex-start;
  }
  .logo-top { font-size: 1.1rem; }
  .logo-bottom { font-size: 1.25rem; }
  
  .sidebar-footer { display: none; }
  
  .nav-menu { 
    flex-direction: row; 
    margin: 0; 
    padding: 0 1rem 1rem 1rem;
    gap: 0.5rem; 
    overflow-x: auto; 
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }
  .nav-menu::-webkit-scrollbar { display: none; }
  
  .nav-item { 
    padding: 0.6rem 0.8rem; 
    white-space: nowrap; 
    font-size: 0.85rem; 
    border-radius: var(--radius-sm);
  }

  /* Cards em Grid Unica */
  .metrics-grid { grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem; }
  .stat-card { padding: 1rem; }
  .stat-value { font-size: 1.4rem; }
  
  /* Ajuste no padding do Panel */
  .panel { padding: 1rem; }
  .dashboard-panels { grid-template-columns: minmax(0, 1fr); gap: 1rem; }
  .panel-header { flex-direction: column; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
  .panel-header .filters, .panel-header .form-select { width: 100%; }
  .cashflow-month-filter-wrap { width: 100%; flex: 1 1 auto; }
  
  /* ==================================================================== */
  /* NOVO CSS: TRANSFORMAR TABELAS EM CARDS EMPILHADOS NO MOBILE */
  /* ==================================================================== */
  
  .scroll-indicator { display: none !important; }
  .table-responsive-wrapper { border: none; background: transparent; padding: 0; }
  .table-responsive { overflow: visible; }
  
  .data-table { min-width: 100%; border: none; }
  .data-table thead { display: none; }
  
  .data-table tbody tr {
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    padding: 0.5rem 1rem;
    box-shadow: var(--shadow-sm);
  }
  
  .data-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px dashed var(--border-light);
    text-align: right;
    white-space: normal;
  }
  
  .data-table td:last-child {
    border-bottom: none;
    flex-direction: column;
    align-items: stretch;
    padding-top: 1rem;
    margin-top: 0.25rem;
  }
  
  .data-table td:last-child > div {
    display: flex;
    width: 100%;
    gap: 0.5rem !important;
  }
  .data-table td:last-child > div > .btn, 
  .data-table td:last-child > div > a {
    flex: 1; 
    justify-content: center;
  }
  
  /* Injeção de Rótulos via CSS */
  .data-table td::before {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-right: 1rem;
    text-align: left;
  }

  /* Rótulos */
  #dash-installments-table-body td:nth-child(1)::before { content: 'Cliente'; }
  #dash-installments-table-body td:nth-child(2)::before { content: 'Boleto'; }
  #dash-installments-table-body td:nth-child(3)::before { content: 'Vencimento'; }
  #dash-installments-table-body td:nth-child(4)::before { content: 'Valor'; }
  #dash-installments-table-body td:nth-child(5)::before { display: none; }
  #dash-week-returns-table-body td:nth-child(1)::before { content: 'Cliente'; }
  #dash-week-returns-table-body td:nth-child(2)::before { content: 'Veículo'; }
  #dash-week-returns-table-body td:nth-child(3)::before { content: 'Retorno'; }
  #dash-week-returns-table-body td:nth-child(4)::before { display: none; }

  #rentals-table-body td:nth-child(1)::before { content: 'Cliente'; }
  #rentals-table-body td:nth-child(2)::before { content: 'Veículo'; }
  #rentals-table-body td:nth-child(3)::before { content: 'Km'; }
  #rentals-table-body td:nth-child(4)::before { content: 'Saída'; }
  #rentals-table-body td:nth-child(5)::before { content: 'Retorno'; }
  #rentals-table-body td:nth-child(6)::before { content: 'Valor'; }
  #rentals-table-body td:nth-child(7)::before { content: 'Pagto'; }
  #rentals-table-body td:nth-child(8)::before { content: 'Status'; }
  #rentals-table-body td:nth-child(9)::before { display: none; }

  #cashflow-table-body td:nth-child(1)::before, #report-table-body td:nth-child(1)::before { content: 'Data'; }
  #cashflow-table-body td:nth-child(2)::before, #report-table-body td:nth-child(2)::before { content: 'Descrição'; }
  #cashflow-table-body td:nth-child(3)::before, #report-table-body td:nth-child(3)::before { content: 'Tipo'; }
  #cashflow-table-body td:nth-child(4)::before, #report-table-body td:nth-child(4)::before { content: 'Valor'; }
  #cashflow-table-body td:nth-child(5)::before, #report-table-body td:nth-child(5)::before { display: none; }

  /* ==================================================================== */

  .form-row { flex-direction: column; gap: 1rem; width: 100%; }
  .form-group { margin-bottom: 1rem; width: 100%; }
  .flex-1 { width: 100%; min-width: 0; }
  
  .section-actions-bar { justify-content: stretch; }
  .section-actions-bar .btn { width: 100%; justify-content: center; }
  
  .report-filters { flex-direction: column; align-items: stretch; gap: 0.75rem; width: 100%; }
  .report-filters .filter-item { width: 100%; min-width: 0; }
  .report-filters .btn { width: 100%; justify-content: center; }
  .report-summary-cards { grid-template-columns: 1fr; gap: 0.75rem; margin-top: 1rem; }
  
  .modal-dialog { margin: 0; border-radius: var(--radius-md) var(--radius-md) 0 0; height: min(95vh, 52rem); height: min(95dvh, 52rem); max-height: calc(100dvh - env(safe-area-inset-top)); align-self: flex-end; width: 100%; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal-body { padding: 1.25rem 1rem; }
  .modal-footer { padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom)); justify-content: space-between; border-radius: 0; }
  .modal-footer .btn { flex: 1; justify-content: center; padding: 0.8rem; }
}

@media print {
  @page { size: auto; margin: 14mm; }
  body { background: #fff !important; color: #18181b !important; font-size: 10pt; }
  body * { visibility: hidden !important; }
  .app-container, .main-content { height: auto !important; min-height: 0 !important; overflow: visible !important; position: static !important; }
  .sidebar, .topbar { display: none !important; }
  #section-reports, #section-reports * { visibility: visible !important; }
  #section-reports { display: block !important; position: absolute; inset: 0; width: 100%; animation: none; }
  #section-reports > .panel { padding: 0 !important; border: 0 !important; box-shadow: none !important; }
  .print-report-heading { display: block !important; margin: 0 0 18px; padding-bottom: 12px; border-bottom: 2px solid #18181b; }
  .print-report-heading h1 { font-size: 18pt; }
  .print-report-heading h2 { margin-top: 6px; font-size: 14pt; }
  .print-report-heading p { margin-top: 5px; color: #52525b; }
  #section-reports .panel-header { display: none !important; }
  .report-summary-cards { grid-template-columns: repeat(3, 1fr) !important; margin: 0 0 18px !important; }
  .summary-box { padding: 10px !important; border: 1px solid #bbb !important; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .summary-data strong { font-size: 12pt; }
  .table-responsive-wrapper, .table-responsive { overflow: visible !important; border: 0 !important; }
  #report-table { display: table !important; min-width: 0 !important; width: 100% !important; border-collapse: collapse !important; }
  #report-table thead { display: table-header-group !important; }
  #report-table tbody { display: table-row-group !important; }
  #report-table tr { display: table-row !important; break-inside: avoid; }
  #report-table th, #report-table td { display: table-cell !important; white-space: normal !important; padding: 8px !important; border: 1px solid #d4d4d8 !important; text-align: left !important; }
  #report-table th { background: #f4f4f5 !important; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  #report-table td::before { display: none !important; }
  .type-badge.income, #report-table td[style*="--color-success"] { color: #047857 !important; }
  .type-badge.expense, #report-table td[style*="--color-danger"] { color: #b91c1c !important; }
}

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

/* Refinos visuais e estados de conexão */
:root { color-scheme: light; }
body { background: #f3f5f8; }
.sidebar { box-shadow: 4px 0 24px rgba(15, 23, 42, 0.08); }
.brand { min-height: 88px; }
.nav-item { transition: background-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast); }
.nav-item:hover { transform: translateX(2px); }
.card, .panel, .form-card { box-shadow: 0 5px 20px rgba(15, 23, 42, 0.045); }
.data-table tbody tr { transition: background-color var(--transition-fast); }
.form-input { color: var(--text-primary); }
.form-input::placeholder { color: #94a3b8; }
.btn:focus-visible, .nav-item:focus-visible, .form-input:focus-visible { outline: 3px solid rgba(230, 0, 0, 0.3); outline-offset: 2px; }
.server-error { margin: 0 0 1.25rem; padding: 1rem 1.25rem; border: 1px solid #fca5a5; border-radius: var(--radius-md); background: #fef2f2; color: #991b1b; line-height: 1.5; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

[hidden] { display: none !important; }
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 1.25rem; background: radial-gradient(circle at top left, #fee2e2 0, transparent 34%), #f3f5f8; }
.login-card { width: min(100%, 420px); padding: 2.25rem; display: grid; gap: 0.8rem; background: var(--bg-surface); border: 1px solid var(--border-light); border-radius: var(--radius-lg); box-shadow: 0 24px 70px rgba(15, 23, 42, 0.14); }
.login-logo { justify-self: center; width: min(100%, 250px); height: 76px; margin: 0 auto 0.7rem; text-align: center; }
.login-card h1 { margin: 0; text-align: center; font-size: 1.5rem; }
.login-card > p:not(.login-error) { margin: 0 0 0.6rem; text-align: center; color: var(--text-secondary); }
.login-card label { margin-top: 0.25rem; font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }
.login-card .form-input { padding: 0.75rem 0.85rem; background: #fff; }
.login-error { min-height: 1.25rem; margin: 0; color: #b91c1c; font-size: 0.85rem; }
.login-card .btn { padding: 0.8rem 1rem; }
.topbar-actions { display: flex; align-items: center; gap: 0.75rem; }
@media (max-width: 480px) { .login-card { padding: 1.5rem; } .topbar-actions { width: 100%; justify-content: space-between; } }

/* Contrato em tela cheia no celular, com formulário rolável e ações fixas. */
@media (max-width: 768px) {
  #rental-modal .modal-dialog { height: 100vh; height: 100dvh; max-height: none; }

  .modal-backdrop.open {
    align-items: stretch;
    padding: 0;
    overflow: hidden;
  }

  .modal-dialog {
    width: 100%;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    min-height: 0;
    margin: 0;
    overflow: hidden;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    transform: none;
  }

  .modal-backdrop.open .modal-dialog {
    transform: none;
  }

  .modal-header {
    padding: 0.9rem 1rem;
    flex: 0 0 auto;
  }

  #rental-form {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
  }

  .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 1rem;
  }

  .modal-footer {
    flex: 0 0 auto;
    padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
    gap: 0.5rem;
    flex-wrap: nowrap;
  }

  .modal-footer .btn {
    min-width: 0;
    flex: 1 1 0;
    white-space: normal;
  }
}
