/* PRECIFICA — Modern Dark/Slate UI Design System (Mobile-First) */
:root {
    --bg-main: #090d16;
    --bg-surface: #0f172a;
    --bg-card: #1e293b;
    --bg-card-hover: #263349;
    --bg-input: #0b1120;
    --border-subtle: #334155;
    --border-focus: #38bdf8;
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    
    --accent-primary: #10b981; /* Lucro / Saudável */
    --accent-primary-hover: #059669;
    --accent-sky: #0ea5e9;
    --accent-indigo: #6366f1;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5);
    
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-family);
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Layout Geral */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Top Navbar */
.navbar {
    background-color: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0.75rem 1.25rem;
}

.nav-wrapper {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-main);
    font-size: 1.15rem;
    font-weight: 700;
}

.brand-logo {
    height: 32px;
    width: auto;
    max-width: 130px;
    object-fit: contain;
    display: block;
}

.brand-divider {
    color: var(--text-dim);
    font-size: 1.1rem;
    line-height: 1;
    user-select: none;
}

.brand-module {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: -0.2px;
}

.brand-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #10b981, #0ea5e9);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: #fff;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    list-style: none;
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.92rem;
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.nav-link:hover, .nav-link.active {
    color: var(--text-main);
    background-color: var(--bg-card);
}

.nav-link.active {
    color: #38bdf8;
    font-weight: 600;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.tenant-badge {
    background: rgba(56, 189, 248, 0.1);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.25);
    padding: 0.3rem 0.7rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 600;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Conteúdo Principal */
.main-content {
    flex: 1;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 5rem 1.25rem;
}

/* Bottom Bar (Especialmente para Mobile) */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-subtle);
    z-index: 1000;
    padding: 0.4rem 0.5rem;
}

.mobile-bottom-nav ul {
    display: flex;
    justify-content: space-around;
    list-style: none;
    margin: 0;
    padding: 0;
}

.mobile-bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.72rem;
    font-weight: 500;
    padding: 0.35rem 0.5rem;
    border-radius: var(--radius-sm);
}

.mobile-bottom-nav a.active {
    color: #38bdf8;
}

.mobile-bottom-nav svg {
    width: 20px;
    height: 20px;
}

/* Cabeçalho de Páginas */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.page-title-group h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-main);
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 0.92rem;
    margin-top: 0.2rem;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

/* Botões */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.1rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

.btn-primary {
    background-color: var(--accent-primary);
    color: #064e3b;
    font-weight: 700;
}

.btn-primary:hover {
    background-color: var(--accent-primary-hover);
    color: #ffffff;
}

.btn-sky {
    background-color: var(--accent-sky);
    color: #ffffff;
}

.btn-sky:hover {
    background-color: #0284c7;
}

.btn-secondary {
    background-color: var(--bg-card);
    border-color: var(--border-subtle);
    color: var(--text-main);
}

.btn-secondary:hover {
    background-color: var(--bg-card-hover);
    border-color: var(--text-dim);
}

.btn-danger {
    background-color: rgba(244, 63, 94, 0.15);
    color: #fda4af;
    border-color: rgba(244, 63, 94, 0.3);
}

.btn-danger:hover {
    background-color: var(--accent-rose);
    color: #ffffff;
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.82rem;
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 0.85rem 1.5rem;
    font-size: 1rem;
}

.btn-block {
    width: 100%;
}

/* Cards & Grades */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}

.kpi-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.kpi-card:hover {
    border-color: var(--text-dim);
}

.kpi-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.kpi-title {
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.kpi-value {
    font-size: 1.85rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-main);
}

.kpi-desc {
    font-size: 0.82rem;
    color: var(--text-dim);
    margin-top: 0.35rem;
}

.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
}

.card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Badges de Status */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.badge-healthy {
    background-color: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-warning {
    background-color: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-critical {
    background-color: rgba(244, 63, 94, 0.15);
    color: #fb7185;
    border: 1px solid rgba(244, 63, 94, 0.3);
}

.badge-sub {
    background-color: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.badge-muted {
    background-color: rgba(148, 163, 184, 0.1);
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
}

/* Formulários */
.form-group {
    margin-bottom: 1.25rem;
}

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

.form-control {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-main);
    padding: 0.65rem 0.9rem;
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.2);
}

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

.form-help {
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-top: 0.35rem;
}

/* Tabelas Elegantes e Responsivas */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.table th {
    background-color: var(--bg-card);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
}

.table td {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid rgba(51, 65, 85, 0.4);
    font-size: 0.92rem;
    vertical-align: middle;
}

.table tr:hover td {
    background-color: rgba(30, 41, 59, 0.5);
}

/* Alertas & Toasts */
.alert {
    padding: 0.9rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.92rem;
    font-weight: 500;
}

.alert-success {
    background-color: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #34d399;
}

.alert-error {
    background-color: rgba(244, 63, 94, 0.15);
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: #fb7185;
}

/* Modal / Dialog */
dialog {
    background-color: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 1.75rem;
    box-shadow: var(--shadow-lg);
    max-width: 520px;
    width: 90%;
    margin: auto;
}

dialog::backdrop {
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
}

/* Caixa de Scanner e Câmera Mobile */
.scanner-box {
    border: 2px dashed var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 2.5rem 1.5rem;
    text-align: center;
    background: rgba(15, 23, 42, 0.6);
    transition: border-color 0.2s;
    cursor: pointer;
}

.scanner-box:hover, .scanner-box.dragover {
    border-color: #38bdf8;
    background: rgba(56, 189, 248, 0.05);
}

.scanner-preview {
    max-width: 100%;
    max-height: 320px;
    border-radius: var(--radius-lg);
    margin: 1rem auto;
    display: block;
    box-shadow: var(--shadow-md);
}

/* Simulador Interativo */
.simulator-box {
    background: linear-gradient(145deg, #1e293b, #0f172a);
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
}

.range-slider {
    width: 100%;
    accent-color: #0ea5e9;
    height: 6px;
    margin: 1rem 0;
}

/* Responsividade Mobile */
@media (max-width: 768px) {
    .nav-links {
        display: none;
    }
    
    .mobile-bottom-nav {
        display: block;
    }

    .main-content {
        padding-bottom: 5.5rem;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .page-actions {
        width: 100%;
    }
    
    .page-actions .btn {
        flex: 1;
    }

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

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

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