:root {
    color-scheme: light;
}

html,
body {
    min-height: 100%;
    margin: 0;
    background: #f6f7f3;
    font-family: Inter, Arial, sans-serif;
}

.KSTRATEGY-appbar {
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.brand-wordmark {
    font-weight: 800;
    letter-spacing: 0;
}

.KSTRATEGY-drawer {
    border-right: 1px solid #e5e9e1;
}

/* ── Drawer Logo ─────────────────────────────── */
.drawer-logo-header {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 24px 14px;
    min-height: 116px;
    background: transparent;
    border-bottom: 1px solid #E5E9E1;
}

.drawer-logo-full {
    height: 42px;
    width: auto;
    object-fit: contain;
    display: block;
}

.drawer-logo-word {
    font-family: 'Outfit', 'Inter', sans-serif;
    font-weight: 800;
    font-size: 1.5rem;
    color: #0B1E30;
    letter-spacing: -1px;
    line-height: 1;
}
.drawer-logo-word .lw-accent {
    color: #0E9E78;
}

.drawer-logo-mini {
    width: 46px;
    height: 46px;
    object-fit: contain;
    display: block;
}

.nav-label {
    display: block;
    margin: 20px 18px 8px;
    color: #6a756f;
}

.main-shell {
    min-height: 100vh;
    background:
        linear-gradient(135deg, rgba(17, 106, 91, .08), transparent 34%),
        linear-gradient(315deg, rgba(217, 154, 43, .10), transparent 28%),
        #f6f7f3;
}

.dashboard-page {
    padding: 32px;
}

.page-title {
    font-weight: 800;
    letter-spacing: 0;
}

.hero-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.metric-card,
.panel {
    border: 1px solid #e3e8df;
    border-radius: 8px;
    background: rgba(255, 255, 255, .92);
}

.metric-card {
    min-height: 150px;
    padding: 20px;
}

.panel {
    padding: 22px;
}

.panel-heading {
    margin-bottom: 18px;
}

.trend-positive {
    color: #116a5b;
    font-weight: 700;
}

.trend-neutral {
    color: #6c5b2b;
    font-weight: 700;
}

.trend-negative {
    color: #b3261e;
    font-weight: 700;
}

.portfolio-filters {
    margin-bottom: 10px;
}

.portfolio-table {
    margin-top: 8px;
}

.filter-total {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 56px;
}

.numeric-stack {
    align-items: flex-end;
}

.movement-tab-panel {
    padding-top: 18px;
}

.asset-type-grid,
.fixed-income-type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
    gap: 8px;
}

.asset-type-button,
.fixed-income-type-button {
    min-height: 40px;
    border-radius: 8px;
    justify-content: flex-start;
    text-align: left;
}

.asset-type-button.active,
.fixed-income-type-button.active {
    background: #dbeee8 !important;
    border-color: #116a5b !important;
    color: #10231f !important;
    font-weight: 700;
}

.order-description-panel {
    border: 1px solid #c7ded4;
    border-left: 5px solid #116a5b;
    border-radius: 8px;
    background: #eef7f2;
    padding: 14px 16px;
}

.order-description-panel.active {
    box-shadow: inset 0 0 0 1px rgba(17, 106, 91, .08);
}

.fixed-income-panel {
    border: 1px solid #d4dfcf;
    border-radius: 8px;
    background: #f7f9f4;
    padding: 16px;
}

.order-form-row {
    align-items: flex-start;
}


.chart-bars {
    display: grid;
    grid-template-columns: repeat(6, minmax(38px, 1fr));
    gap: 18px;
    min-height: 280px;
    align-items: end;
}

.bar-column {
    display: grid;
    gap: 10px;
    align-items: end;
    text-align: center;
}

.bar-track {
    position: relative;
    height: 220px;
    border-radius: 8px;
    background: #edf0ea;
    overflow: hidden;
}

.bar-fill {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 8px 8px 0 0;
    background: linear-gradient(180deg, #365cce, #116a5b);
}

.allocation-panel {
    min-height: 326px;
}

.allocation-list {
    margin-top: 24px;
}

.empty-state {
    min-height: 340px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    text-align: center;
}

.goal-progress {
    margin: 18px 0 10px;
}

@media (max-width: 720px) {
    .dashboard-page {
        padding: 20px;
    }

    .hero-actions {
        justify-content: flex-start;
    }

    .chart-bars {
        gap: 10px;
        min-height: 220px;
    }

    .bar-track {
        height: 160px;
    }
}

/* ── Portfolio Hierarchy ─────────────────────────────────── */

.portfolio-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 14px;
    background: #10231F;
    border-radius: 8px 8px 0 0;
    flex-wrap: wrap;
}

.portfolio-toolbar-actions {
    display: flex;
    gap: 2px;
    align-items: center;
}

.ph-toolbar-stat {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.ph-toolbar-stat .ph-stat-label {
    font-size: 10px;
    color: rgba(255, 255, 255, .55);
    text-transform: uppercase;
    letter-spacing: .4px;
}

.ph-toolbar-stat .ph-stat-value {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
}

.ph-toolbar-badge {
    padding: 3px 10px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 700;
}

.ph-toolbar-badge.negative { background: #b3261e; color: #fff; }
.ph-toolbar-badge.positive { background: #116a5b; color: #fff; }

.portfolio-hierarchy {
    font-size: 13px;
    overflow-x: auto;
}

/* DIVISÃO */
.ph-divisao-header,
.ph-divisao-row {
    display: grid;
    grid-template-columns: 3fr 1.5fr 1.5fr 1.5fr 1.5fr 1fr 1fr 1fr;
    padding: 7px 16px;
}

.ph-divisao-header {
    background: #e0e8dc;
    border-bottom: 1px solid #ccd7c6;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #455440;
    letter-spacing: .5px;
}

.ph-divisao-row {
    background: #eef3ea;
    border-bottom: 2px solid #c8d3c3;
    align-items: center;
    cursor: pointer;
}

.ph-divisao-row:hover { background: #e5ece0; }

/* CLASSE */
.ph-classe-header,
.ph-classe-row {
    display: grid;
    grid-template-columns: 3fr 1.5fr 1.5fr 1.5fr 1.2fr 1.5fr 1fr;
    padding: 6px 16px 6px 32px;
}

.ph-classe-header {
    background: #f8faf6;
    border-bottom: 1px solid #e5e9e1;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #5C6661;
    letter-spacing: .4px;
}

.ph-classe-row {
    border-bottom: 1px solid #e5e9e1;
    align-items: center;
    cursor: pointer;
}

.ph-classe-row:hover { background: rgba(17, 106, 91, .04); }

.ph-classe-indicator {
    width: 13px;
    height: 13px;
    border-radius: 3px;
    display: inline-block;
    flex-shrink: 0;
    margin-top: 2px;
}

.ph-classe-name-cell {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.ph-classe-aporte {
    font-size: 11px;
    color: #5C6661;
}

/* ATIVO */
.ph-ativo-header,
.ph-ativo-row {
    display: grid;
    grid-template-columns: 1.2fr 1.5fr 1.5fr 0.7fr 1.2fr 1.2fr 1.2fr 1.3fr 1.4fr 1fr 1fr 0.8fr 0.7fr;
    padding: 5px 16px 5px 48px;
}

.ph-ativo-header {
    background: #fafbf9;
    border-bottom: 1px solid #e5e9e1;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #5C6661;
    letter-spacing: .3px;
}

.ph-ativo-row {
    border-bottom: 1px solid #eef1ea;
    align-items: center;
}

.ph-ativo-row:hover { background: rgba(17, 106, 91, .025); }

/* Asset Detail Dialog - metrics grid */
.asset-detail-metrics {
    display: grid;
    grid-template-columns: repeat(11, 1fr);
    min-width: 660px;
}
.adm-header {
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 600;
    color: #5C6661;
    text-transform: uppercase;
    letter-spacing: .3px;
    text-align: right;
    border-right: 1px solid #eef1ea;
    background: #fafbf9;
    border-bottom: 1px solid #e5e9e1;
}
.adm-header:first-child { text-align: left; }
.adm-cell {
    padding: 8px 12px;
    font-size: 13px;
    text-align: right;
    border-right: 1px solid #eef1ea;
}
.adm-cell:first-child { text-align: left; font-weight: 600; }

/* Shared */
.ph-right { text-align: right; }

.ph-num-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 1px;
}

.ph-num-secondary {
    font-size: 11px;
    color: #5C6661;
}

.ph-signal {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    white-space: nowrap;
}

.ph-signal.over   { background: #b3261e; }
.ph-signal.on-target { background: #116a5b; }
.ph-signal.under  { background: #116a5b; }

/* ── Estrategia ─────────────────────────────────────────────────── */

.estrategia-panel { height: 100%; }

.estrategia-info {
    font-size: 12px;
    padding: 8px 12px;
}

.estrategia-status-box {
    background: #eef7f2;
    border: 1px solid #c7ded4;
    border-left: 4px solid #116a5b;
    border-radius: 6px;
    padding: 12px 14px;
    font-size: 13px;
}

.estrategia-classes-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 24px;
}

.estrategia-class-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.estrategia-class-row .mud-input-control {
    width: 110px;
    flex-shrink: 0;
}

/* ── Portfolio Hierarchy ─────────────────────────────────────────── */

/* ── Metrics row (5-card single line) ──────────────────────────── */

.metrics-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.metrics-row .metric-card {
    flex: 1 1 0;
    min-width: 140px;
}

.metric-card-sm {
    min-height: 0 !important;
    padding: 14px 16px !important;
}

/* ── Controle de Gastos ─────────────────────────────────────────── */

/* Barra de filtros alinhada à direita no cabeçalho das telas do módulo.
   Campos com largura fixa (não esticam) para caberem numa única linha. */
.cg-filterbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

.cg-filterbar > * {
    flex: 0 0 auto;
    min-width: 0;
}

/* Barra de filtros dedicada (não no header) alinhada à esquerda */
.cg-filterbar--start {
    justify-content: flex-start;
}

@media (max-width: 960px) {
    .cg-filterbar {
        justify-content: flex-start;
    }
}

/* KPI com acento colorido no topo (combina com .metric-card .metric-card-sm) */
.kpi-card {
    border-top: 3px solid #cfd8cf;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.kpi-card .kpi-value {
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1.15;
}

.kpi-receita  { border-top-color: var(--mud-palette-success); }
.kpi-despesa  { border-top-color: var(--mud-palette-error); }
.kpi-invest   { border-top-color: #26A69A; }
.kpi-transfer { border-top-color: var(--mud-palette-info); }
.kpi-saldo    { border-top-color: var(--mud-palette-primary); }

body.app-dark .kpi-card { border-top-color: #2A3B35; }

/* Barra de progresso simples com cor arbitrária (índices e ranking de categorias) */
.cg-bar {
    height: 8px;
    border-radius: 4px;
    background: var(--mud-palette-lines-default);
    overflow: hidden;
    margin-top: 5px;
}

.cg-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width .3s ease;
}

/* ── Dividendos ─────────────────────────────────────────────────── */

.div-year-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 22px;
    background: #eef3ea;
    border-top: 1px solid #dde6d8;
    border-bottom: 1px solid #dde6d8;
    cursor: pointer;
}

.div-year-row:hover { background: #e5ece0; }

.div-table-header,
.div-table-row {
    display: grid;
    grid-template-columns: 90px 1fr 1fr 1fr 1fr 1fr 44px;
    padding: 6px 22px;
    align-items: center;
    font-size: 13px;
}

.div-table-header {
    background: #f8faf6;
    border-bottom: 1px solid #e5e9e1;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: #5C6661;
    letter-spacing: .4px;
}

.div-table-row {
    border-bottom: 1px solid #eef1ea;
}

.div-table-row:hover { background: rgba(17, 106, 91, .03); }

.div-right { text-align: right; }

/* ── Save bar ──────────────────────────────────────────────────── */

.ph-save-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 16px;
    background: #eef7f2;
    border-bottom: 1px solid #c7ded4;
    font-size: 13px;
}

.ph-classe-section { border-bottom: 1px solid #e5e9e1; }
.ph-classe-section:last-child { border-bottom: none; }

.ph-ativos-section { overflow-x: auto; }
.ph-ativo-header, .ph-ativo-row { border-bottom: 1px solid #eef1ea; }

/* ── Metric cards filter interactive styles ── */
.metric-card-clickable {
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    user-select: none;
}

.metric-card-clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(17, 106, 91, 0.08);
    border-color: #116a5b;
}

.metric-card-clickable.active {
    border-color: #116a5b;
    border-width: 2px !important;
    background-color: rgba(17, 106, 91, 0.04) !important;
    box-shadow: 0 4px 12px rgba(17, 106, 91, 0.12);
}

/* ── Division balance dashboard cards ── */
.division-card {
    border-top: 4px solid transparent !important;
    transition: all 0.2s ease-in-out;
    padding: 16px !important;
}

.division-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.05);
}

/* ══════════════════════════════════════════════════════════════
   DARK MODE — escopado em body.app-dark (alternado via JS no MainLayout).
   Sobrescreve as cores claras hardcoded das classes customizadas.
   ══════════════════════════════════════════════════════════════ */
body.app-dark {
    color-scheme: dark;
    background: #0F1A17;
}

body.app-dark .main-shell {
    background:
        linear-gradient(135deg, rgba(45, 212, 168, .06), transparent 34%),
        linear-gradient(315deg, rgba(245, 200, 66, .06), transparent 28%),
        #0F1A17;
}

body.app-dark .KSTRATEGY-drawer {
    border-right: 1px solid #2A3B35;
}

body.app-dark .drawer-logo-header {
    border-bottom: 1px solid #2A3B35;
}

body.app-dark .drawer-logo-word {
    color: #FFFFFF;
}
body.app-dark .drawer-logo-word .lw-accent {
    color: #13DBA2;
}

body.app-dark .nav-label {
    color: #8A9B94;
}

body.app-dark .metric-card,
body.app-dark .panel {
    border: 1px solid #2A3B35;
    background: rgba(26, 43, 38, .92);
    color: #E8EDE9;
}

/* Linhas/painéis com fundos claros hardcoded → tons escuros */
body.app-dark .panel-heading,
body.app-dark .ph-divisao-row,
body.app-dark .ph-classe-row,
body.app-dark .ph-ativo-row,
body.app-dark .div-year-row,
body.app-dark .div-table-row,
body.app-dark .metric-card-sm {
    background: #1A2B26 !important;
    color: #E8EDE9;
}

body.app-dark .ph-divisao-row:hover,
body.app-dark .ph-classe-row:hover,
body.app-dark .ph-ativo-row:hover,
body.app-dark .div-year-row:hover,
body.app-dark .div-table-row:hover {
    background: #223530 !important;
}

body.app-dark .metric-card-clickable.active {
    border-color: #2DD4A8;
    background-color: rgba(45, 212, 168, 0.08) !important;
    box-shadow: 0 4px 12px rgba(45, 212, 168, 0.15);
}

body.app-dark .division-card:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}



