:root {
    --dc-primary: #1268b3;
    --dc-primary-dark: #0f4f86;
    --dc-orange: #f28c28;
    --dc-bg: #f4f7fb;
    --dc-text: #1f2937;
    --dc-muted: #6b7280;
    --dc-border: #e5e9f0;
    --dc-sidebar-w: 260px;
    --dc-sidebar-collapsed-w: 76px;
    --dc-sidebar-bg: #0d284a;
}

body {
    background: var(--dc-bg);
    color: var(--dc-text);
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

/* ==========================================================
   TELA DE LOGIN
   ========================================================== */
.login-bg {
    background:
        radial-gradient(circle at top left, rgba(18,104,179,.22), transparent 35%),
        linear-gradient(135deg, #0f4f86 0%, #1268b3 48%, #16385c 100%);
}

.login-panel {
    background: rgba(255,255,255,.98);
    border-radius: 22px;
    padding: 32px;
    border: 1px solid rgba(255,255,255,.45);
}

.login-brand-logo {
    display: block;
    width: min(100%, 320px);
    height: auto;
    margin-left: auto;
    margin-right: auto;
    object-fit: contain;
}

.login-brand-caption {
    color: var(--dc-muted);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: .01em;
}

.security-box {
    padding: 12px 14px;
    border-radius: 12px;
    background: #f5f8fb;
    color: #5e6875;
    font-size: 13px;
}

/* ==========================================================
   ESTRUTURA SHELL & MENU LATERAL EXPANSIVO
   ========================================================== */
.app-shell {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* Sidebar Desktop Fixa */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--dc-sidebar-w);
    height: 100vh;
    min-height: 100vh;
    z-index: 1040;
    background: linear-gradient(180deg, #0d284a 0%, #07172b 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    box-shadow: 2px 0 16px rgba(10, 25, 47, 0.14);
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-brand {
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    min-height: 72px;
    flex-shrink: 0;
}

.sidebar-brand-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    text-decoration: none;
}

.sidebar-brand-logo-full {
    display: block;
    width: 100%;
    max-width: 185px;
    height: auto;
    max-height: 46px;
    object-fit: contain;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.25));
    transition: opacity 0.2s ease;
}

.sidebar-brand-logo-mini {
    display: none;
    width: 38px;
    height: 38px;
    object-fit: contain;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.25));
}

.sidebar-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 14px 12px;
    gap: 4px;
    display: flex;
    flex-direction: column;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.sidebar-nav::-webkit-scrollbar {
    width: 5px;
}
.sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 999px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.35);
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.78);
    font-weight: 500;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.15s ease;
}

.sidebar-nav .nav-link i {
    font-size: 18px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.85);
}

.sidebar-nav .nav-link .nav-label {
    white-space: nowrap;
    transition: opacity 0.2s;
}

.sidebar-nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    transform: translateX(2px);
}

.sidebar-nav .nav-link.active {
    background: linear-gradient(135deg, #1268b3 0%, #0d5494 100%);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(18, 104, 179, 0.35);
}

.sidebar-footer {
    margin-top: auto;
    padding: 14px 14px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.15);
    width: 100%;
    flex-shrink: 0;
}

.session-safe {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.55);
    letter-spacing: 0.02em;
}

.btn-sidebar-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 9px 16px;
    border-radius: 10px;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-sidebar-logout:hover {
    background: #dc2626;
    border-color: #dc2626;
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.35);
    transform: translateY(-1px);
}

/* ==========================================================
   ESTADO RECOLHIDO / COMPACTO (EXPANSIVO NO PAINEL CENTRAL)
   ========================================================== */
body.sidebar-collapsed .sidebar,
html.sidebar-init-collapsed body .sidebar {
    width: var(--dc-sidebar-collapsed-w) !important;
}

body.sidebar-collapsed .sidebar-brand-logo-full,
html.sidebar-init-collapsed body .sidebar-brand-logo-full {
    display: none !important;
}

body.sidebar-collapsed .sidebar-brand-logo-mini,
html.sidebar-init-collapsed body .sidebar-brand-logo-mini {
    display: block !important;
}

body.sidebar-collapsed .sidebar-nav .nav-link,
html.sidebar-init-collapsed body .sidebar-nav .nav-link {
    justify-content: center;
    padding: 12px 8px;
    gap: 0;
}

body.sidebar-collapsed .sidebar-nav .nav-link .nav-label,
html.sidebar-init-collapsed body .sidebar-nav .nav-link .nav-label {
    display: none !important;
}

body.sidebar-collapsed .sidebar-footer,
html.sidebar-init-collapsed body .sidebar-footer {
    padding: 12px 8px;
}

body.sidebar-collapsed .sidebar-footer .session-safe,
html.sidebar-init-collapsed body .sidebar-footer .session-safe {
    display: none !important;
}

body.sidebar-collapsed .btn-sidebar-logout,
html.sidebar-init-collapsed body .btn-sidebar-logout {
    width: 44px;
    height: 44px;
    padding: 0;
    margin: 0 auto;
    border-radius: 50%;
    justify-content: center;
}

body.sidebar-collapsed .btn-sidebar-logout span,
html.sidebar-init-collapsed body .btn-sidebar-logout span {
    display: none !important;
}

/* ==========================================================
   PAINEL PRINCIPAL
   ========================================================== */
.main-content {
    margin-left: var(--dc-sidebar-w);
    width: calc(100% - var(--dc-sidebar-w));
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1), width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--dc-bg);
}

body.sidebar-collapsed .main-content,
html.sidebar-init-collapsed body .main-content {
    margin-left: var(--dc-sidebar-collapsed-w) !important;
    width: calc(100% - var(--dc-sidebar-collapsed-w)) !important;
}

.navbar {
    min-height: 72px;
}

.btn-toggle-sidebar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: #4b5563;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    transition: all 0.15s ease;
}

.btn-toggle-sidebar:hover {
    background: #eef2f6;
    color: var(--dc-primary);
    border-color: #cbd5e1;
}

.navbar-page-title {
    font-weight: 700;
    line-height: 1.2;
    font-size: 1.15rem;
}

.navbar-page-subtitle {
    color: var(--dc-muted);
    font-size: 12px;
}

.user-menu-button {
    border: 1px solid var(--dc-border);
    padding: 6px 12px;
    border-radius: 12px;
    background: #fff;
    transition: all 0.15s ease;
}

.user-menu-button:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: #eaf2fb;
    color: var(--dc-primary);
    font-weight: 700;
}

.user-dropdown {
    border-radius: 14px;
    min-width: 220px;
    padding: 8px 0;
}

.content-wrapper {
    flex: 1 0 auto;
    padding: 26px 30px;
}

/* ==========================================================
   MOBILE & TABLET OFFCANVAS SIDEBAR
   ========================================================== */
.mobile-sidebar-drawer {
    background: linear-gradient(180deg, #0d284a 0%, #07172b 100%) !important;
    color: #fff !important;
    width: 290px !important;
    border-right: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.mobile-brand-logo {
    max-width: 170px;
    height: auto;
    object-fit: contain;
}

.mobile-sidebar-drawer .sidebar-nav .nav-link {
    color: rgba(255, 255, 255, 0.8);
    padding: 11px 14px;
}

.mobile-sidebar-drawer .sidebar-nav .nav-link:hover,
.mobile-sidebar-drawer .sidebar-nav .nav-link.active {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

@media (max-width: 991.98px) {
    .sidebar {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .content-wrapper {
        padding: 18px 16px;
    }
}

/* ==========================================================
   CARDS, PAINÉIS E COMPONENTES
   ========================================================== */
.metric-card,
.panel-card {
    background: #fff;
    border: 1px solid var(--dc-border);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(20, 39, 61, .04);
}

.metric-card {
    padding: 20px;
    height: 100%;
}

.metric-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 20px;
    margin-bottom: 16px;
}

.soft-primary {
    background: #e9f2fb;
    color: var(--dc-primary);
}

.soft-success {
    background: #eaf7ee;
    color: #198754;
}

.soft-warning {
    background: #fff5df;
    color: #c47a00;
}

.soft-info {
    background: #e7f6fa;
    color: #0b7a8e;
}

.metric-label {
    color: var(--dc-muted);
    font-size: 13px;
    margin-bottom: 4px;
}

.metric-value {
    font-size: 27px;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 10px;
}

.metric-footer {
    font-size: 12px;
}

.panel-card {
    padding: 20px;
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--dc-border);
}

.session-warning {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 2000;
    background: #fff;
    border-left: 4px solid var(--dc-orange);
    border-radius: 12px;
    padding: 14px 16px;
    max-width: 360px;
}

.warning-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: #fff3e4;
    color: #bd6b12;
}

/* ==========================================================
   GRÁFICOS & ANALYTICS DASHBOARD
   ========================================================== */
.chart-panel {
    min-height: 330px;
}

.chart-wrap {
    position: relative;
    width: 100%;
    margin-top: 18px;
}

.chart-wrap-lg {
    height: 270px;
}

.chart-wrap-sm {
    height: 255px;
}

.chart-wrap-medium {
    height: 300px;
}

.chart-wrap-brand {
    min-height: 360px;
    height: 360px;
}

.dashboard-brand-icon {
    width: 54px;
    height: 54px;
    object-fit: contain;
    flex: 0 0 54px;
    filter: drop-shadow(0 6px 12px rgba(18,104,179,.14));
}

.dashboard-period-select {
    min-width: 165px;
}

.dashboard-brand-select {
    min-width: 190px;
}

.analytics-summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 13px 0;
    border-bottom: 1px solid var(--dc-border);
    font-size: 14px;
}

.analytics-summary-row:last-child {
    border-bottom: 0;
}

.analytics-summary-row span {
    color: var(--dc-muted);
}

.analytics-summary-row strong {
    color: var(--dc-text);
}

.analytics-summary-total {
    margin-top: 4px;
    padding-top: 17px;
}

.analytics-summary-total strong {
    font-size: 18px;
    color: var(--dc-primary);
}

/* ==========================================================
   GERAÇÃO DE PAGAMENTO & REGRAS
   ========================================================== */
.payment-condition-card {
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    background: #fff;
    user-select: none;
}
.payment-condition-card:hover {
    border-color: #1268b3 !important;
    background: #f8fbff;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(18, 104, 179, 0.08);
}
.payment-condition-card.active-condition {
    border-color: #1268b3 !important;
    background: #f0f7ff !important;
    box-shadow: 0 0 0 2px rgba(18, 104, 179, 0.35);
}
.payment-condition-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}
.condition-badge-pix {
    background: #00bdae;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}
.condition-badge-card {
    background: #1268b3;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.payment-create-head-icon {
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.payment-create-head-icon img {
    width: 68px;
    height: 68px;
    object-fit: contain;
}

.payment-rule-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px 0;
    border-bottom: 1px solid var(--dc-border);
}

.payment-rule-row:last-child {
    border-bottom: 0;
}

.payment-rule-row span {
    color: var(--dc-muted);
    font-size: 14px;
}

.payment-rule-row strong {
    color: var(--dc-text);
    white-space: nowrap;
}

.payment-installment-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 42px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #f7f9fc;
    color: var(--dc-muted);
    font-size: 13px;
}

.payment-installment-preview span {
    padding: 6px 10px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--dc-border);
    color: var(--dc-text);
    font-weight: 600;
}

.payment-created-icon {
    width: 76px;
    height: 76px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(25, 135, 84, .12);
    color: #198754;
    font-size: 42px;
}

.payment-created-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.payment-created-summary > div {
    padding: 14px;
    border: 1px solid var(--dc-border);
    border-radius: 12px;
    background: #f9fafc;
}

.payment-created-summary span {
    color: var(--dc-muted);
    font-size: 12px;
    margin-bottom: 4px;
    display: block;
}

.payment-created-summary strong {
    color: var(--dc-text);
    font-size: 14px;
    display: block;
}

@media (max-width: 767.98px) {
    .payment-created-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 575.98px) {
    .payment-created-summary {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================
   INTEGRAÇÕES, LOGO EMPRESA E WHATSAPP
   ========================================================== */
.company-logo-preview {
    width: 104px;
    height: 78px;
    flex: 0 0 104px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 8px;
    border: 1px solid var(--dc-border);
    border-radius: 14px;
    background: #fff;
    color: var(--dc-muted);
    font-size: 30px;
}

.company-logo-preview img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.company-logo-actions {
    width: min(100%, 560px);
}
