:root {
    --card: #f5f5f4;
    --ring: #6366f1;
    --input: #d6d3d1;
    --muted: #e7e5e4;
    --accent: #f3e5f5;
    --border: #d6d3d1;
    --radius: 1.25rem;
    --chart-1: #6366f1;
    --chart-2: #4f46e5;
    --chart-3: #4338ca;
    --chart-4: #3730a3;
    --chart-5: #312e81;
    --popover: #f5f5f4;
    --primary: #6366f1;
    --sidebar: #d6d3d1;
    --font-mono: Roboto Mono, monospace;
    --font-sans: Plus Jakarta Sans, sans-serif;
    --secondary: #d6d3d1;
    --background: #e7e5e4;
    --font-serif: Lora, serif;
    --foreground: #1e293b;
    --destructive: #ef4444;
    --shadow-blur: 10px;
    --shadow-color: hsl(240 4% 60%);
    --sidebar-ring: #6366f1;
    --shadow-spread: 4px;
    --shadow-opacity: 0.18;
    --sidebar-accent: #f3e5f5;
    --sidebar-border: #d6d3d1;
    --card-foreground: #1e293b;
    --shadow-offset-x: 2px;
    --shadow-offset-y: 2px;
    --sidebar-primary: #6366f1;
    --muted-foreground: #6b7280;
    --accent-foreground: #374151;
    --popover-foreground: #1e293b;
    --primary-foreground: #ffffff;
    --sidebar-foreground: #1e293b;
    --secondary-foreground: #4b5563;
    --destructive-foreground: #ffffff;
    --sidebar-accent-foreground: #374151;
    --sidebar-primary-foreground: #ffffff;
}

.dark {
    --card: #2c2825;
    --ring: #818cf8;
    --input: #3a3633;
    --muted: #2c2825;
    --accent: #484441;
    --border: #3a3633;
    --radius: 1.25rem;
    --chart-1: #818cf8;
    --chart-2: #6366f1;
    --chart-3: #4f46e5;
    --chart-4: #4338ca;
    --chart-5: #3730a3;
    --popover: #2c2825;
    --primary: #818cf8;
    --sidebar: #3a3633;
    --secondary: #3a3633;
    --background: #1e1b18;
    --foreground: #e2e8f0;
    --destructive: #ef4444;
    --shadow-color: hsl(0 0% 0%);
    --sidebar-ring: #818cf8;
    --sidebar-accent: #484441;
    --sidebar-border: #3a3633;
    --card-foreground: #e2e8f0;
    --sidebar-primary: #818cf8;
    --muted-foreground: #9ca3af;
    --accent-foreground: #d1d5db;
    --popover-foreground: #e2e8f0;
    --primary-foreground: #1e1b18;
    --sidebar-foreground: #e2e8f0;
    --secondary-foreground: #d1d5db;
    --destructive-foreground: #1e1b18;
    --sidebar-accent-foreground: #d1d5db;
    --sidebar-primary-foreground: #1e1b18;
}

/* Utility Classes based on Theme */
.theme-card {
    background-color: var(--card);
    color: var(--card-foreground);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-offset-x) var(--shadow-offset-y) var(--shadow-blur) var(--shadow-spread) var(--shadow-color);
}

.theme-btn-primary {
    background-color: var(--primary);
    color: var(--primary-foreground);
    border-radius: var(--radius);
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    font-family: var(--font-sans);
    font-weight: 600;
    transition: filter 0.2s;
}

.theme-btn-primary:hover {
    filter: brightness(1.1);
}

.theme-input {
    background-color: var(--input);
    color: var(--foreground);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
}

.theme-header {
    font-family: var(--font-serif);
    color: var(--foreground);
}

/* --- FULL SCREEN LAYOUT FIXES --- */
#main-app-container {
    padding: 0 !important;
    max-width: none !important;
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
    height: 100vh;
    overflow-y: auto;
    background-color: var(--background) !important;
    position: relative;
}

/* Wrapper que envolve cada tela (injetado via index.html) */
.app-view-wrapper {
    flex: 1 0 auto !important;
    /* Força crescimento, mas permite scroll se ultrapassar */
    display: none;
    flex-direction: column !important;
    background-color: var(--card) !important;
    border-top-left-radius: 20px;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.02);
    min-height: calc(100vh - 80px);
    /* Garante que preencha quase tudo independente do conteúdo */
}

/* Regra mestre: Se o JS setou display block ou flex (qualquer coisa que não seja none), aplicamos Flex e Crescimento */
.app-view-wrapper:not([style*="display: none"]) {
    display: flex !important;
}

.section {
    padding: 20px;
    /* Padding padrão para respiro lateral */
    width: 100%;
    box-sizing: border-box;
    flex: 1 !important;
    display: none;
    background-color: transparent !important;
    overflow-x: hidden;
}

.section.active {
    display: flex !important;
    flex-direction: column !important;
}

/* Garante que o card principal dentro da seção preencha o espaço */
.section>.card:first-of-type {
    flex: 1 !important;
    display: flex;
    flex-direction: column;
    margin-bottom: 0 !important;
    /* Remove margem inferior que causa gap */
}


/* --- LIST OVERFLOW FIX (Remove white bar overlay) --- */
.lotes-grid,
#cards-container-disponiveis,
#grid-lotes-corretor {
    /* Padding aumentado considerando a área segura do iPhone (barra preta inferior) */
    padding-bottom: calc(120px + env(safe-area-inset-bottom)) !important;
    position: relative;
    z-index: 1;
    background: transparent !important;
    /* Garante que o container não tenha fundo branco */
}

/* Remove pseudo-elementos que causam overlays */
.lotes-grid::after,
#cards-container-disponiveis::after,
#grid-lotes-corretor::after,
.section::after {
    display: none !important;
    content: none !important;
    height: 0 !important;
    background: none !important;
    opacity: 0 !important;
}

/* --- BADGES & STATS IMPROVEMENTS --- */
.badge-status {
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.75em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-block;
}

.badge-success {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

/* Verde Moderno */
.badge-warning {
    background: #fef9c3;
    color: #a16207;
    border: 1px solid #fde047;
}

/* Amarelo Moderno */
.badge-danger {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

/* Vermelho Moderno */
.badge-info {
    background: #dbeafe;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

/* Azul Moderno */
.badge-neutral {
    background: #f3f4f6;
    color: #4b5563;
    border: 1px solid #e5e7eb;
}

/* Cinza Moderno */

/* Dashboard Stat Cards */
.stat-card-icon-bg {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8em;
    margin-right: 15px;
    transition: transform 0.2s;
}

.stat-card:hover .stat-card-icon-bg {
    transform: scale(1.1) rotate(5deg);
}

.stat-card-number {
    font-size: 2.2em !important;
    font-weight: 800 !important;
    color: #111827;
    line-height: 1;
    margin-top: 5px;
}

.stat-card-label {
    /* Título do card */
    font-size: 0.9em;
    color: #6b7280;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}