:root {
    --brand-primary: #2563eb;
    --brand-primary-dark: #1d4ed8;
    --brand-navy: #0f172a;
    --brand-navy-light: #1e293b;
    --brand-emerald: #059669;
    --sidebar-width: 268px;
    --sidebar-collapsed-width: 78px;
    --surface-bg: #f1f5f9;
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    --text-main: #0f172a;
    --text-muted-custom: #64748b;
}

[data-bs-theme="dark"] {
    --surface-bg: #0b1120;
    --card-bg: #111827;
    --card-border: #1f2937;
    --text-main: #f8fafc;
    --text-muted-custom: #94a3b8;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--surface-bg);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Layout Mestre com Sidebar Retrátil */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    color: #f8fafc;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease, transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.15);
}

body.sidebar-collapsed .app-sidebar {
    width: var(--sidebar-collapsed-width);
}

.sidebar-brand {
    height: 68px;
    padding: 0 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    text-decoration: none;
    color: #ffffff;
}

.sidebar-brand-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #3b82f6 0%, #10b981 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: #fff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.35);
}

body.sidebar-collapsed .sidebar-text,
body.sidebar-collapsed .sidebar-section-label {
    display: none !important;
}

.sidebar-nav {
    padding: 1rem 0.75rem;
    flex: 1;
    overflow-y: auto;
}

.sidebar-section-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #94a3b8;
    font-weight: 700;
    padding: 0.75rem 0.75rem 0.35rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.68rem 0.9rem;
    border-radius: 10px;
    color: #cbd5e1;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.92rem;
    margin-bottom: 0.25rem;
    transition: all 0.18s ease;
    white-space: nowrap;
}

.sidebar-link i {
    font-size: 1.15rem;
    min-width: 22px;
    text-align: center;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.sidebar-link.active {
    background: linear-gradient(90deg, #2563eb 0%, #3b82f6 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}

.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left 0.25s ease;
}

body.sidebar-collapsed .app-main {
    margin-left: var(--sidebar-collapsed-width);
}

.app-topbar {
    height: 68px;
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--card-border);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.app-content {
    padding: 1.5rem;
    flex: 1;
}

/* Cards Modernos */
.erp-card {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.04);
}

.kpi-card {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 1.25rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.child-avatar {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* Matriz Semanal de Revisão do Pai */
.matrix-table th,
.matrix-table td {
    vertical-align: middle;
}

.matrix-toggle-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 2px solid var(--card-border);
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    color: var(--text-muted-custom);
}

.matrix-toggle-btn:hover {
    border-color: #2563eb;
    transform: scale(1.06);
}

.matrix-toggle-btn.done {
    background-color: #10b981;
    border-color: #10b981;
    color: #ffffff;
    box-shadow: 0 3px 10px rgba(16, 185, 129, 0.3);
}

.matrix-toggle-btn.done-parent {
    background-color: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}

/* Portal Criptografado do Filho */
.kid-hero {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 55%, #059669 100%);
    border-radius: 24px;
    color: #ffffff;
    padding: 1.75rem;
    box-shadow: 0 12px 32px rgba(37, 99, 235, 0.25);
}

.kid-task-card {
    background-color: var(--card-bg);
    border: 2px solid var(--card-border);
    border-radius: 16px;
    padding: 1rem 1.15rem;
    transition: all 0.2s ease;
    cursor: pointer;
    user-select: none;
}

.kid-task-card:hover {
    border-color: #3b82f6;
}

.kid-task-card.completed {
    border-color: #10b981;
    background-color: rgba(16, 185, 129, 0.06);
}

.kid-task-card.completed .kid-task-title {
    text-decoration: line-through;
    opacity: 0.72;
}

.kid-check-circle {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 50%;
    border: 2.5px solid #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.2s ease;
}

.kid-task-card.completed .kid-check-circle {
    background-color: #10b981;
    border-color: #10b981;
    color: #ffffff;
    transform: scale(1.06);
}

/* QR Code Container */
.pix-qr-box {
    background: #ffffff;
    padding: 16px;
    border-radius: 16px;
    display: inline-block;
    border: 1px solid #e2e8f0;
}

/* Global Loading Overlay */
#global-loader {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
}

#global-loader.show {
    display: flex;
}

/* Responsividade Mobile */
@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
    }
    body.sidebar-mobile-open .app-sidebar {
        transform: translateX(0);
    }
    .app-main,
    body.sidebar-collapsed .app-main {
        margin-left: 0;
    }
}

