/* Controle de Despesas - identidade visual propria sobre o Bootstrap 5 */
:root {
    --cd-ink: #16232e;
    --cd-sidebar: #13232f;
    --cd-sidebar-soft: #1d3342;
    --cd-primary: #0f766e;
    --cd-primary-dark: #0b5c56;
    --cd-accent: #e8a33d;
    --cd-bg: #f3f5f7;
    --cd-line: #e3e8ec;
    --cd-muted: #6b7a86;
    --bs-primary: #0f766e;
    --bs-primary-rgb: 15, 118, 110;
    --bs-link-color: #0f766e;
    --bs-link-color-rgb: 15, 118, 110;
    --bs-link-hover-color: #0b5c56;
    --bs-link-hover-color-rgb: 11, 92, 86;
}

body {
    background: var(--cd-bg);
    color: var(--cd-ink);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: .94rem;
}

.btn-primary {
    --bs-btn-bg: var(--cd-primary);
    --bs-btn-border-color: var(--cd-primary);
    --bs-btn-hover-bg: var(--cd-primary-dark);
    --bs-btn-hover-border-color: var(--cd-primary-dark);
    --bs-btn-active-bg: var(--cd-primary-dark);
    --bs-btn-active-border-color: var(--cd-primary-dark);
    --bs-btn-disabled-bg: var(--cd-primary);
    --bs-btn-disabled-border-color: var(--cd-primary);
}
.btn-outline-primary {
    --bs-btn-color: var(--cd-primary);
    --bs-btn-border-color: var(--cd-primary);
    --bs-btn-hover-bg: var(--cd-primary);
    --bs-btn-hover-border-color: var(--cd-primary);
    --bs-btn-active-bg: var(--cd-primary);
    --bs-btn-active-border-color: var(--cd-primary);
}
.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: var(--cd-primary);
    box-shadow: 0 0 0 .2rem rgba(15, 118, 110, .18);
}
.form-check-input:checked { background-color: var(--cd-primary); border-color: var(--cd-primary); }
.page-link { color: var(--cd-primary); }
.page-item.active .page-link { background: var(--cd-primary); border-color: var(--cd-primary); }

/* ---- Estrutura ---- */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    --bs-offcanvas-width: 248px;
    --bs-offcanvas-bg: var(--cd-sidebar);
    --bs-offcanvas-color: #c9d6de;
    width: 248px;
    flex-shrink: 0;
    color: #c9d6de;
}
/* O Bootstrap deixa .offcanvas-lg transparente em telas grandes. */
.app-shell .app-sidebar { background-color: var(--cd-sidebar) !important; }
@media (min-width: 992px) {
    .app-sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
}

.brand {
    display: flex; align-items: center; gap: .65rem;
    padding: 1.15rem 1.15rem 1rem;
    color: #fff; text-decoration: none;
}
.brand-mark {
    width: 36px; height: 36px; border-radius: 10px;
    background: linear-gradient(135deg, var(--cd-primary), #14a394);
    display: grid; place-items: center;
    font-size: 1.1rem; color: #fff;
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .15);
}
.brand-name { font-weight: 600; line-height: 1.15; font-size: .98rem; }
.brand-company { display: block; font-size: .72rem; font-weight: 400; color: #8fa3b0; }

.side-nav { padding: .4rem .7rem 1rem; }
.side-label {
    font-size: .68rem; letter-spacing: .08em; text-transform: uppercase;
    color: #6f8695; padding: .9rem .6rem .35rem;
}
.side-link {
    display: flex; align-items: center; gap: .7rem;
    width: 100%; padding: .55rem .7rem; margin-bottom: 2px;
    border: 0; border-radius: 8px; background: none;
    color: #c9d6de; text-decoration: none; text-align: left; font-size: .92rem;
}
.side-link i { font-size: 1.02rem; width: 1.2rem; text-align: center; color: #8fa3b0; }
.side-link:hover { background: var(--cd-sidebar-soft); color: #fff; }
.side-link.active { background: var(--cd-primary); color: #fff; }
.side-link.active i, .side-link:hover i { color: #fff; }
.side-link .badge { margin-left: auto; background: var(--cd-accent); color: #2b1d02; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.app-topbar {
    position: sticky; top: 0; z-index: 1020;
    display: flex; align-items: center; gap: .75rem;
    height: 60px; padding: 0 1.25rem;
    background: #fff; border-bottom: 1px solid var(--cd-line);
}
.app-topbar h1 { font-size: 1.12rem; font-weight: 600; margin: 0; }
.icon-btn {
    position: relative; width: 38px; height: 38px;
    border: 1px solid var(--cd-line); border-radius: 10px;
    background: #fff; color: var(--cd-ink);
    display: grid; place-items: center;
}
.icon-btn:hover { background: var(--cd-bg); }
.icon-btn .dot {
    position: absolute; top: -5px; right: -5px;
    min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
    background: #d6453d; color: #fff; font-size: .68rem; line-height: 18px; text-align: center;
}
.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: #d9efec; color: var(--cd-primary-dark);
    display: grid; place-items: center; font-weight: 600; font-size: .85rem;
}
.user-btn { border: 0; background: none; display: flex; align-items: center; gap: .55rem; padding: .2rem; }
.user-btn small { color: var(--cd-muted); display: block; line-height: 1; }

.app-content { padding: 1.4rem 1.25rem 2.5rem; }

/* ---- Componentes ---- */
.card { border: 1px solid var(--cd-line); border-radius: 12px; box-shadow: 0 1px 2px rgba(22, 35, 46, .04); }
.card-header {
    background: #fff; border-bottom: 1px solid var(--cd-line);
    font-weight: 600; padding: .8rem 1rem; border-radius: 12px 12px 0 0 !important;
}

.stat-card { padding: 1rem 1.05rem; height: 100%; border-left: 4px solid var(--stat, var(--cd-primary)); }
.stat-card .stat-label { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--cd-muted); }
.stat-card .stat-value { font-size: 1.4rem; font-weight: 650; margin: .15rem 0 0; line-height: 1.2; }
.stat-card .stat-hint { font-size: .78rem; color: var(--cd-muted); }
.stat-card .stat-icon {
    width: 38px; height: 38px; border-radius: 10px;
    display: grid; place-items: center; font-size: 1.1rem;
    color: var(--stat, var(--cd-primary));
    background: color-mix(in srgb, var(--stat, var(--cd-primary)) 12%, #fff);
}

.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table thead th {
    font-size: .74rem; text-transform: uppercase; letter-spacing: .04em;
    color: var(--cd-muted); font-weight: 600; background: #fafbfc;
    border-bottom: 1px solid var(--cd-line); white-space: nowrap;
}
.table td { vertical-align: middle; }
.table-hover tbody tr:hover { background: #f7fafa; }
.text-money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--cd-muted); }
.empty-state i { font-size: 2rem; display: block; margin-bottom: .4rem; opacity: .6; }

/* Status */
.badge[class*="status-"] { font-weight: 600; padding: .4em .7em; border-radius: 999px; }
.status-rascunho   { background: #e9edf0; color: #4a5964; }
.status-aguardando { background: #fdf0d5; color: #8a5a00; }
.status-aprovada   { background: #dbeafe; color: #1d4ed8; }
.status-rejeitada  { background: #fde2e1; color: #b3261e; }
.status-paga       { background: #d7f2e3; color: #11693f; }

/* Linha do tempo da despesa */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 1.1rem 2rem; }
.timeline li::before {
    content: ""; position: absolute; left: .55rem; top: 1.2rem; bottom: 0;
    width: 2px; background: var(--cd-line);
}
.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::before { display: none; }
.timeline .tl-dot {
    position: absolute; left: 0; top: .1rem;
    width: 1.2rem; height: 1.2rem; border-radius: 50%;
    background: #fff; border: 2px solid #c3ced6;
    display: grid; place-items: center; font-size: .6rem; color: #fff;
}
.timeline li.done .tl-dot { background: var(--cd-primary); border-color: var(--cd-primary); }
.timeline li.done::before { background: var(--cd-primary); }
.timeline li.failed .tl-dot { background: #d6453d; border-color: #d6453d; }
.timeline .tl-title { font-weight: 600; }
.timeline li:not(.done):not(.failed) .tl-title { color: var(--cd-muted); font-weight: 500; }
.timeline .tl-meta { font-size: .8rem; color: var(--cd-muted); }

.detail-list dt { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--cd-muted); font-weight: 600; }
.detail-list dd { margin-bottom: .9rem; }

.receipt-preview { border: 1px solid var(--cd-line); border-radius: 10px; background: #fafbfc; overflow: hidden; }
.receipt-preview img { display: block; max-width: 100%; max-height: 520px; margin: 0 auto; }
.receipt-preview iframe { display: block; width: 100%; height: 520px; border: 0; }

.history-item { display: flex; gap: .75rem; padding: .6rem 0; border-bottom: 1px dashed var(--cd-line); }
.history-item:last-child { border-bottom: 0; }
.history-item time { font-size: .8rem; color: var(--cd-muted); white-space: nowrap; min-width: 7.2rem; }

.chart-box { position: relative; height: 280px; }

/* ---- Login ---- */
.auth-page {
    min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
    background:
        radial-gradient(900px 500px at 10% 0%, rgba(15, 118, 110, .35), transparent 60%),
        radial-gradient(700px 500px at 100% 100%, rgba(232, 163, 61, .18), transparent 60%),
        var(--cd-sidebar);
}
.auth-card { width: 100%; max-width: 400px; border: 0; border-radius: 16px; padding: 2rem 1.8rem; box-shadow: 0 20px 50px rgba(0, 0, 0, .3); }
.auth-card .brand-mark { width: 46px; height: 46px; font-size: 1.4rem; border-radius: 12px; }

@media print {
    .app-sidebar, .app-topbar, .no-print { display: none !important; }
    .app-content { padding: 0; }
    body { background: #fff; }
    .card { border: 0; box-shadow: none; }
}
