@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  --primary: #1e6b3c;
  --primary-dark: #0f3d22;
  --primary-soft: #e8f5ec;
  --primary-mid: #a7d7b5;
  --danger: #c0392b;
  --danger-soft: #fbecea;
  --danger-border: #e8b8b2;
  --warning: #e0a100;
  --warning-soft: #fff7dc;
  --warning-ink: #936a00;
  --info: #5b7083;
  --info-soft: #edf2f6;
  --ink: #17221b;
  --muted: #66756d;
  --line: #dfe6e1;
  --line-strong: #ccd7d0;
  --bg: #f6f8f7;
  --surface: #ffffff;
  --surface-alt: #fafcfa;
  --surface-hover: #f8faf9;
  --input-bg: #ffffff;
  --table-head: #f8faf9;
  --table-foot: #f4f8f5;
  --table-row-border: #edf1ee;
  --table-row-hover: #fbfdfb;
  --sidebar: #102b1c;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 61, 34, 0.04);
}

[data-theme="dark"] {
  color-scheme: dark;
  --primary: #34b364;
  --primary-dark: #1e6b3c;
  --primary-soft: rgba(52, 179, 100, 0.15);
  --primary-mid: #27854b;
  --danger: #ef5350;
  --danger-soft: rgba(239, 83, 80, 0.15);
  --danger-border: rgba(239, 83, 80, 0.35);
  --warning: #f5b82e;
  --warning-soft: rgba(245, 184, 46, 0.15);
  --warning-ink: #f5b82e;
  --info: #8aa4bc;
  --info-soft: rgba(138, 164, 188, 0.14);
  --ink: #e4ede7;
  --muted: #8fa396;
  --line: #233329;
  --line-strong: #2f4537;
  --bg: #0c1410;
  --surface: #131f18;
  --surface-alt: #17261e;
  --surface-hover: #1b2c22;
  --input-bg: #0f1914;
  --table-head: #17261e;
  --table-foot: #16281e;
  --table-row-border: #1c2d23;
  --table-row-hover: #18271f;
  --sidebar: #09170f;
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
body { margin: 0; font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); font-size: 13px; line-height: 1.5; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.icon { flex: 0 0 auto; vertical-align: middle; }

/* Layout Shell */
.app-shell { min-height: 100vh; display: flex; }
.sidebar { width: 240px; background: var(--sidebar); color: #d6e5dc; position: fixed; inset: 0 auto 0 0; padding: 20px 14px 14px; display: flex; flex-direction: column; z-index: 30; transition: width .2s ease; overflow-x: hidden; }
.sidebar.collapsed, .app-shell.sidebar-collapsed .sidebar { width: 76px; padding: 20px 10px 14px; }
.side-head { height: 42px; display: flex; align-items: center; justify-content: space-between; padding: 0 6px; }
.sidebar.collapsed .side-head, .app-shell.sidebar-collapsed .side-head { padding: 0 2px; justify-content: space-between; gap: 4px; }
.sidebar.collapsed .logo, .app-shell.sidebar-collapsed .logo { display: flex; align-items: center; justify-content: center; }
.sidebar.collapsed .side-nav a, .sidebar.collapsed .side-nav button, .app-shell.sidebar-collapsed .side-nav a, .app-shell.sidebar-collapsed .side-nav button { justify-content: center; padding: 0; }
.sidebar.collapsed .side-user, .app-shell.sidebar-collapsed .side-user { justify-content: center; padding: 14px 0 2px; }
.logo { display: flex; align-items: center; gap: 10px; color: white; font-size: 17px; letter-spacing: -.4px; white-space: nowrap; text-decoration: none !important; }
.logo strong span { color: #64c781; }
.logo-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--primary); display: flex; align-items: flex-end; justify-content: center; gap: 3px; padding: 7px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); flex-shrink: 0; }
.logo-mark span { width: 4px; border-radius: 2px 2px 0 0; background: white; }
.logo-mark span:nth-child(1) { height: 8px; opacity: .65; }
.logo-mark span:nth-child(2) { height: 12px; opacity: .82; }
.logo-mark span:nth-child(3) { height: 16px; }
.icon-btn { border: 0; background: transparent; color: inherit; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; transition: background .15s ease; flex-shrink: 0; }
.icon-btn:hover { background: rgba(255,255,255,.08); }
.side-nav { display: flex; flex-direction: column; gap: 4px; margin-top: 28px; flex: 1; overflow-y: auto; }
.side-nav a, .side-nav button { border: 0; background: transparent; color: #b9c9c0; height: 42px; border-radius: 8px; display: flex; align-items: center; gap: 12px; padding: 0 13px; text-align: left; white-space: nowrap; text-decoration: none; font-size: 12px; font-weight: 500; transition: all .15s ease; }
.side-nav a:hover, .side-nav button:hover { color: white; background: rgba(255,255,255,.06); text-decoration: none; }
.side-nav a.active, .side-nav button.active { color: white; background: var(--primary); box-shadow: 0 3px 12px rgba(0,0,0,.12); }
/* User Profile & Popover Menu */
.side-user-container { margin-top: auto; padding: 12px 2px 2px; border-top: 1px solid rgba(255,255,255,.1); position: relative; }
.side-user-btn { width: 100%; border: 0; background: transparent; padding: 6px 8px; border-radius: 10px; display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer; color: white; transition: background .15s ease; }
.side-user-btn:hover { background: rgba(255,255,255,.08); }
.side-user-info { min-width: 0; flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.side-user-info strong { font-size: 12px; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-info span { font-size: 10px; color: #94aa9d; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.user-chevron { color: #8fa598; flex-shrink: 0; margin-left: auto; }
.sidebar.collapsed .side-user-container, .app-shell.sidebar-collapsed .side-user-container { padding: 12px 0 2px; display: flex; justify-content: center; }
.sidebar.collapsed .side-user-btn, .app-shell.sidebar-collapsed .side-user-btn { width: 44px; height: 44px; padding: 0; display: grid; place-items: center; justify-content: center; border-radius: 50%; }

.user-popover-backdrop { position: fixed; inset: 0; z-index: 55; background: transparent; }
.user-popover { position: fixed; bottom: 68px; left: 16px; width: 260px; background: var(--surface); border-radius: var(--radius); box-shadow: 0 16px 40px rgba(0,0,0,.22); border: 1px solid var(--line); z-index: 60; animation: scaleUp .18s cubic-bezier(0.16, 1, 0.3, 1); overflow: hidden; color: var(--ink); }
.user-popover.collapsed-pos { left: 14px; bottom: 68px; }
.user-popover-head { padding: 14px 16px; display: flex; align-items: center; gap: 12px; background: var(--surface-alt); border-bottom: 1px solid var(--line); }
.user-popover-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-popover-meta strong { font-size: 13px; font-weight: 700; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-popover-meta span { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-popover-menu { padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.user-popover-item { width: 100%; border: 0; background: transparent; padding: 9px 10px; border-radius: 8px; display: flex; align-items: center; gap: 10px; text-align: left; font-size: 12px; color: var(--ink); cursor: pointer; transition: background .12s ease; }
.user-popover-item:hover { background: var(--bg); }
.user-popover-item .item-text { display: flex; flex-direction: column; min-width: 0; }
.user-popover-item .item-text strong { font-size: 12px; font-weight: 600; color: var(--ink); }
.user-popover-item .item-text small { font-size: 10px; color: var(--muted); }
.user-popover-item.logout-item { color: var(--danger); font-weight: 600; padding: 10px 14px; border-radius: 0; border-top: 1px solid var(--line); background: transparent; }
.user-popover-item.logout-item:hover { background: var(--danger-soft); }
.mobile-user-btn { border: 0; background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 9px; font-weight: 500; cursor: pointer; }

.main-content { margin-left: 240px; padding: 28px 30px 46px; min-width: 0; flex: 1; transition: margin .2s ease, width .2s ease; width: calc(100% - 240px); }
.app-shell.sidebar-collapsed .main-content,
.main-content.collapsed,
.sidebar.collapsed ~ .main-content,
.sidebar.collapsed + .main-content { margin-left: 76px; width: calc(100% - 76px); }
.mobile-nav { display: none; }

/* Page Header & Breadcrumbs */
.page-header { min-height: 58px; display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; gap: 20px; }
.page-header h1 { font-size: 25px; line-height: 1.2; letter-spacing: -.6px; margin: 7px 0 0; color: var(--ink); font-weight: 700; }
.breadcrumb { color: var(--muted); font-size: 11px; display: flex; align-items: center; gap: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }

/* Buttons */
.btn { height: 36px; border-radius: 8px; border: 1px solid transparent; padding: 0 13px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-weight: 600; font-size: 12px; white-space: nowrap; text-decoration: none !important; transition: all .15s ease; }
.btn-primary { background: var(--primary); color: white; box-shadow: 0 1px 2px rgba(15,61,34,.12); }
.btn-primary:hover { background: var(--primary-dark); color: white; }
.btn-secondary { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--line-strong); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); color: var(--primary-dark); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--danger-border); }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Cards & KPIs */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin-bottom: 16px; }
.kpi-grid.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
.kpi-grid.five { grid-template-columns: repeat(5, minmax(0,1fr)); }
.kpi-grid.six { grid-template-columns: repeat(6, minmax(0,1fr)); }
.kpi { padding: 16px; min-height: 126px; display: flex; flex-direction: column; justify-content: space-between; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; font-weight: 500; }
.kpi-icon { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; color: var(--info); background: var(--info-soft); }
.kpi-icon.positive { color: var(--primary); background: var(--primary-soft); }
.kpi-icon.negative { color: var(--danger); background: var(--danger-soft); }
.kpi-icon.warning { color: var(--warning); background: var(--warning-soft); }
.kpi strong { display: block; font-size: 20px; letter-spacing: -.5px; margin: 12px 0 6px; font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); }
.kpi-meta { color: var(--muted); font-size: 10px; display: flex; align-items: center; gap: 4px; font-weight: 500; }

.positive, .texto-positivo { color: var(--primary) !important; }
.negative, .texto-negativo { color: var(--danger) !important; }
.warning { color: var(--warning) !important; }
.info { color: var(--info) !important; }

/* Dashboard Layout & Charts */
.dashboard-grid { display: grid; grid-template-columns: minmax(300px,.8fr) minmax(500px,1.4fr); gap: 16px; margin-bottom: 16px; }
.dashboard-grid-2col { display: grid; grid-template-columns: 1.2fr .8fr; gap: 16px; margin-top: 16px; }
.allocation, .dividends-chart, .capital-chart, .upcoming { padding: 18px; }
.capital-chart { grid-column: 1 / 2; }
.upcoming { grid-column: 2 / 3; }
.section-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-title h2, .drawer h2, .modal h2, .backup-row h2, .upload-card h2, .state-card h2, .detail-identity h2, .settings-form h2 { font-size: 14px; margin: 0; letter-spacing: -.2px; font-weight: 700; color: var(--ink); }
.section-title p, .backup-row p, .upload-card p, .state-card p { color: var(--muted); font-size: 10px; margin: 5px 0 0; }

/* Donut & Pizza Chart */
.donut-wrap, .pizza-chart-wrap { min-height: 245px; display: flex; align-items: center; justify-content: center; gap: 28px; padding: 10px 0; }
.pizza-svg { width: 170px; height: 170px; filter: drop-shadow(0 4px 10px rgba(0,0,0,0.06)); flex-shrink: 0; }
.pizza-slice { transition: opacity .2s ease, filter .2s ease; cursor: pointer; }
.pizza-slice:hover { opacity: 0.9; filter: brightness(1.1); }
.donut { width: 160px; height: 160px; border-radius: 50%; background: conic-gradient(var(--primary) 0 48.2%, var(--primary-mid) 48.2% 79.6%, #7f9eb4 79.6% 92.7%, var(--warning) 92.7%); display: grid; place-items: center; position: relative; }
.donut::after { content:""; position: absolute; inset: 22px; border-radius: 50%; background: var(--surface); }
.donut > div { position: relative; z-index: 1; text-align: center; display: flex; flex-direction: column; }
.donut strong { font-size: 14px; font-weight: 700; }
.donut span { color: var(--muted); font-size: 9px; margin-top: 4px; }
.chart-legend { display: flex; flex-direction: column; gap: 11px; min-width: 150px; }
.chart-legend > div { display: grid; grid-template-columns: 8px 1fr auto; align-items: center; gap: 8px; font-size: 11px; }
.chart-legend strong { font-variant-numeric: tabular-nums; font-weight: 600; }
.chart-legend .legend-val { font-size: 10px; color: var(--muted); margin-left: 2px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); display: inline-block; }
.dot.light { background: var(--primary-mid); }
.dot.blue { background: #7f9eb4; }
.dot.amber { background: var(--warning); }
.dot.gray { background: #a6b2ab; }

/* Enhanced Bar Chart & Gridlines */
.chart-with-grid { position: relative; height: 200px; margin-top: 10px; display: flex; flex-direction: column; justify-content: flex-end; }
.chart-y-axis { position: absolute; inset: 0 0 24px 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; z-index: 0; }
.grid-line { display: flex; align-items: center; width: 100%; border-bottom: 1px dashed var(--line); height: 0; }
.grid-line span { font-size: 8px; color: var(--muted); background: var(--surface); padding-right: 4px; line-height: 1; transform: translateY(-50%); }
.bars-stage { position: relative; z-index: 1; display: flex; align-items: flex-end; justify-content: space-between; height: 100%; gap: 6px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.bar-chart { height: 200px; display: flex; flex-direction: column; justify-content: flex-end; margin-top: 10px; position: relative; }
.bars { display: flex; align-items: flex-end; justify-content: space-between; height: 160px; gap: 8px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.bar-col { flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; color: var(--muted); font-size: 9px; cursor: pointer; }
.bar-col:hover .stack { filter: brightness(1.12); box-shadow: 0 2px 8px rgba(30,107,60,0.22); }
.bar-col .stack-wrap { width: 100%; height: 100%; display: flex; align-items: flex-end; justify-content: center; }
.stack { width: 20px; min-height: 4px; background: var(--primary); border-radius: 4px 4px 0 0; transition: height .3s ease; }
.stack.is-current { box-shadow: 0 0 0 2px var(--primary-mid); }
.bar-col span { font-size: 9px; color: var(--muted); }
.bar-col.is-current span { color: var(--primary); font-weight: 700; }

/* Chart View Toggle */
.chart-toggle { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 2px; gap: 2px; }
.chart-toggle button { border: 0; background: transparent; font-size: 10px; font-weight: 500; color: var(--muted); padding: 3px 8px; border-radius: 4px; cursor: pointer; transition: all .15s ease; }
.chart-toggle button.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }

/* Sticky Table Container */
.table-sticky-container { max-height: 260px; overflow-y: auto; border-radius: 8px; border: 1px solid var(--line); }
.table-sticky-container table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table-sticky-container thead th { position: sticky; top: 0; z-index: 2; background: var(--table-head); box-shadow: 0 1px 0 var(--line); }
.table-sticky-container tfoot td { position: sticky; bottom: 0; z-index: 2; background: var(--table-foot); box-shadow: 0 -1px 0 var(--line); font-weight: 700; color: var(--ink); }

/* Quick Actions Banner */
.quick-actions { margin-top: 16px; min-height: 58px; display: flex; align-items: center; gap: 8px; padding: 0 16px; background: var(--primary-dark); border-radius: var(--radius); color: white; }
.quick-actions > span { font-weight: 600; font-size: 12px; margin-right: auto; }
.quick-actions a, .quick-actions button { color: white; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); height: 34px; border-radius: 8px; padding: 0 12px; display: flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 500; text-decoration: none !important; transition: background .15s ease; }
.quick-actions a:hover, .quick-actions button:hover { background: rgba(255,255,255,.16); }

/* Forms & Fields */
.field { display: flex; flex-direction: column; gap: 6px; color: var(--ink); font-weight: 500; font-size: 11px; min-width: 0; }
.field span, .campo label { color: var(--ink); font-weight: 600; font-size: 11px; }
.field input, .field select, .field textarea, select, input[type="text"], input[type="number"], input[type="date"], input[type="email"], input[type="password"], textarea { border: 1px solid var(--line); height: 36px; border-radius: 8px; padding: 0 10px; color: var(--ink); outline: none; background: var(--input-bg); min-width: 0; font-size: 12px; transition: border-color .15s ease, box-shadow .15s ease; }
.field input:focus, .field select:focus, .field textarea:focus, select:focus, input:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,107,60,.12); }
.field textarea, textarea { padding-top: 8px; min-height: 80px; resize: vertical; }
.field-error, .alerta-erro, .validation-message { color: var(--danger); font-size: 10px; margin-top: 4px; }
.alerta-erro { background: var(--danger-soft); border-radius: 8px; padding: 10px 14px; font-size: 11px; margin-bottom: 14px; font-weight: 500; }
.alerta-sucesso { background: var(--primary-soft); color: var(--primary); border-radius: 8px; padding: 10px 14px; font-size: 11px; margin-bottom: 14px; font-weight: 500; }

/* Filter Bar */
.filter-bar, .barra-filtros { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 14px; align-items: center; }
.filter-bar .field select, .filter-bar .field input, .barra-filtros select, .barra-filtros input { height: 36px; }
.search-field { height: 36px; border: 1px solid var(--line); background: var(--input-bg); border-radius: 8px; display: flex; align-items: center; padding: 0 10px; color: var(--muted); flex: 1; min-width: 200px; }
.search-field input { flex: 1; border: 0 !important; outline: 0 !important; padding: 0 8px !important; min-width: 0; box-shadow: none !important; background: transparent !important; }

/* Tabs & Subnav */
.subnav, .tabs { display: flex; align-items: center; gap: 22px; border-bottom: 1px solid var(--line); margin: -5px 0 16px; }
.subnav a, .subnav button, .tabs button { border: 0; background: transparent; padding: 0 2px 11px; color: var(--muted); font-size: 12px; font-weight: 500; text-decoration: none !important; border-bottom: 2px solid transparent; transition: all .15s ease; cursor: pointer; }
.subnav a:hover, .subnav button:hover, .tabs button:hover { color: var(--ink); }
.subnav a.active, .subnav button.active, .tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tabs button span { padding: 2px 6px; border-radius: 10px; background: var(--info-soft); margin-left: 4px; font-size: 9px; font-weight: 600; }

/* Tables */
.table-shell { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
table, table.tabela-dados { border-collapse: collapse; width: 100%; min-width: 800px; font-variant-numeric: tabular-nums; background: var(--surface); }
th { background: var(--table-head); color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .3px; text-align: left; font-weight: 600; padding: 11px 12px; white-space: nowrap; border-bottom: 1px solid var(--line); }
th.alinhar-direita, td.alinhar-direita, th:not(:first-child), td:not(:first-child) { text-align: right; }
th.alinhar-centro, td.alinhar-centro { text-align: center; }
th.alinhar-esquerda, td.alinhar-esquerda, th:first-child, td:first-child { text-align: left; }
td { padding: 11px 12px; border-bottom: 1px solid var(--table-row-border); font-size: 11px; white-space: nowrap; color: var(--ink); }
tbody tr:hover { background: var(--table-row-hover); }
tfoot tr, tfoot td, tfoot th { background: var(--table-foot); font-weight: 700; border-top: 1px solid var(--line); border-bottom: 0; padding: 11px 12px; }
.sort { color: #a6b2ab; font-size: 8px; margin-left: 2px; }
.paper-link { border: 0; background: transparent; color: var(--primary); font-weight: 700; padding: 0; cursor: pointer; text-decoration: none; font-size: 11px; }
.paper-link:hover { text-decoration: underline; color: var(--primary-dark); }
.table-footer { min-height: 47px; padding: 8px 14px; display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; border-top: 1px solid var(--line); background: var(--surface); }
.pagination { display: flex; gap: 4px; }
.pagination button { width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--muted); font-size: 11px; font-weight: 500; display: grid; place-items: center; }
.pagination button:hover { border-color: var(--line-strong); color: var(--ink); }
.pagination button.active { background: var(--primary); color: white; border-color: var(--primary); }
.col-nome-papel { width: 150px; max-width: 150px; min-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }

/* Badges */
.badge { display: inline-flex; align-items: center; width: max-content; border-radius: 20px; padding: 4px 8px; font-size: 9px; line-height: 1; font-weight: 600; color: var(--info); background: var(--info-soft); white-space: nowrap; }
.badge-positive, .badge.ativo { color: var(--primary); background: var(--primary-soft); }
.badge-negative, .badge.inativo { color: var(--danger); background: var(--danger-soft); }
.badge-warning { color: var(--warning-ink); background: var(--warning-soft); }
.badge-info { color: var(--info); background: var(--info-soft); }
.badge-neutral { color: var(--muted); background: var(--info-soft); }

/* Detail View */
.detail-identity { display: flex; justify-content: space-between; align-items: center; margin: -12px 0 16px; flex-wrap: wrap; gap: 8px; }
.detail-identity > div { display: flex; align-items: center; gap: 8px; }
.detail-identity h2 { font-size: 16px; margin: 0; }
.detail-identity > span { color: var(--muted); font-size: 10px; }

/* Overlays, Drawers, Modals */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(10,28,18,.46); display: flex; justify-content: flex-end; align-items: stretch; animation: fadeIn .2s ease; }
.overlay-close { position: absolute; inset: 0; border: 0; background: transparent; cursor: pointer; }
.drawer { width: 460px; max-width: 100%; background: var(--surface); z-index: 1; display: flex; flex-direction: column; box-shadow: -12px 0 40px rgba(0,0,0,.15); animation: slideLeft .25s ease; }
.drawer-head { min-height: 72px; padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.drawer-head span { display: block; font-size: 9px; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .4px; font-weight: 600; }
.drawer-body { padding: 20px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.drawer-actions { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-alt); }

.modal-overlay { justify-content: center; align-items: center; }
.modal { z-index: 2; width: 500px; max-width: calc(100% - 30px); background: var(--surface); border-radius: var(--radius); box-shadow: 0 20px 50px rgba(0,0,0,.2); animation: scaleUp .2s ease; overflow: hidden; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideLeft { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes scaleUp { from { transform: scale(0.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Grid Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1/-1; }
.row-actions { display: flex; justify-content: flex-end; gap: 4px; }
.row-actions button { width: 28px; height: 28px; border: 0; background: transparent; color: var(--info); display: grid; place-items: center; border-radius: 6px; cursor: pointer; transition: background .15s ease; }
.row-actions button:hover { background: var(--info-soft); }
.row-actions button.danger { color: var(--danger); }
.row-actions button.danger:hover { background: var(--danger-soft); }

/* Upload & Settings */
.upload-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; margin-bottom: 14px; }
.upload-card { padding: 26px 18px; text-align: center; border-style: dashed; border-width: 1.5px; }
.upload-icon, .empty-icon { width: 46px; height: 46px; margin: 0 auto 14px; border-radius: 12px; display: grid; place-items: center; color: var(--primary); background: var(--primary-soft); }
.import-summary { padding: 18px; margin-bottom: 14px; }
.import-summary > div:last-child { display: grid; grid-template-columns: repeat(6,1fr); gap: 10px; margin-top: 18px; }
.import-summary > div:last-child span { border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 5px; padding-right: 6px; }
.import-summary > div:last-child span:last-child { border-right: 0; }
.import-summary small { color: var(--muted); font-size: 9px; font-weight: 500; }
.import-summary strong { font-size: 17px; color: var(--ink); font-weight: 700; }
.backup-row { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; background: var(--primary-dark); color: white; border-radius: var(--radius); margin-bottom: 14px; }
.backup-row h2 { color: white !important; }
.backup-row p { color: #b9c9c0 !important; }
.danger-zone { border-color: var(--danger-border); padding: 18px; margin-top: 14px; }
.danger-zone > div:not(.section-title) { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-top: 1px solid var(--danger-border); }
.danger-zone > div span { display: flex; flex-direction: column; gap: 4px; }
.danger-zone small { color: var(--muted); font-size: 10px; }
.settings-form { padding: 20px; max-width: 700px; }

/* Empty & Loading States */
.state-card { min-height: 380px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px; }
.state-card p { margin: 8px 0 16px; color: var(--muted); }
.spinner { width: 38px; height: 38px; border: 3px solid var(--primary-soft); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; margin-bottom: 15px; }
.loading-gif { width: 268px; height: 268px; border-radius: 12px; object-fit: contain; margin-bottom: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Login Page */
.login-page { min-height: 100vh; display: grid; grid-template-columns: .9fr 1.1fr; background: var(--surface); }
.login-aside { background: var(--sidebar); padding: 44px 7vw; color: white; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-aside::after { content:""; position:absolute; width:420px; height:420px; border:1px solid rgba(167,215,181,.16); border-radius:50%; right:-220px; bottom:-100px; box-shadow:0 0 0 80px rgba(167,215,181,.04),0 0 0 160px rgba(167,215,181,.03); pointer-events: none; }
.login-aside h1 { font-size: 40px; line-height: 1.15; letter-spacing: -1.5px; margin: 20px 0 14px; font-weight: 700; color: white; }
.login-aside p { color: #b9c9c0; max-width: 440px; line-height: 1.6; font-size: 13px; }
.login-aside small { color: #80998b; font-size: 11px; }
.login-card { width: 420px; max-width: calc(100% - 40px); margin: auto; padding: 34px; border: 0; box-shadow: none; display: flex; flex-direction: column; gap: 18px; }
.login-card > .logo { display: none; }
.login-card h1 { font-size: 24px; margin: 0; font-weight: 700; color: var(--ink); }
.login-card p { color: var(--muted); margin: 6px 0 0; font-size: 12px; }
.login-card input { height: 42px; width: 100%; }
.login-options { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; align-items: center; }
.login-options label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.login-options button { border: 0; background: transparent; color: var(--primary); font-size: 11px; font-weight: 500; }
.full-btn { width: 100%; height: 42px; font-size: 13px; }
.login-card > small { text-align: center; color: var(--muted); line-height: 1.5; font-size: 10px; }
/* Competence Bar (Inline Filter) */
.competence-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  margin-bottom: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  flex-wrap: wrap;
}
.competence-group {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.competence-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}
.competence-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.competence-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.competence-field input, .competence-field select {
  height: 32px !important;
  font-size: 12px;
  padding: 0 8px !important;
  border-radius: 6px !important;
}
.competence-total {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.competence-total .label-total {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}
.competence-total strong {
  font-size: 16px;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

/* Compact Table (Grid de Inventário) */
.table-compact table {
  min-width: 650px;
}
.table-compact th {
  padding: 7px 10px !important;
  font-size: 9px !important;
}
.table-compact td {
  padding: 5px 10px !important;
  font-size: 12px !important;
  vertical-align: middle;
}
.table-compact tr:hover {
  background: var(--table-row-hover);
}
.table-compact .col-incluir {
  width: 48px;
  text-align: center;
}
.table-compact .col-ativo {
  text-align: left !important;
  width: 280px;
}
.table-compact .col-tipo {
  width: 120px;
  text-align: center;
}
.table-compact .col-valor {
  width: 160px;
  text-align: right;
}
.table-compact .col-descricao {
  text-align: left !important;
}
.cell-input-valor {
  width: 100% !important;
  max-width: 140px !important;
  height: 28px !important;
  padding: 0 8px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  text-align: right !important;
  border-radius: 6px !important;
  border: 1px solid var(--line) !important;
  font-variant-numeric: tabular-nums;
  box-sizing: border-box;
}
.cell-input-desc {
  width: 100% !important;
  height: 28px !important;
  padding: 0 8px !important;
  font-size: 11px !important;
  border-radius: 6px !important;
  border: 1px solid var(--line) !important;
  box-sizing: border-box;
}
.ativo-meta-compact {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.ativo-sub-info {
  font-size: 9px;
  color: var(--muted);
  margin-top: 1px;
  line-height: 1.2;
}

/* Evolução Patrimonial (Matriz Anual) */
.evolucao-legenda {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 11px;
  color: var(--muted);
}
.evolucao-legenda .legenda-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.evolucao-matrix-shell {
  overflow-x: auto;
}
.evolucao-matrix-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.evolucao-matrix-table th,
.evolucao-matrix-table td {
  border-bottom: 1px solid var(--table-row-border);
  border-right: 1px solid var(--table-row-border);
}
.evolucao-matrix-table th:last-child,
.evolucao-matrix-table td:last-child {
  border-right: 0;
}
.evolucao-matrix-table .sticky-col {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
  min-width: 210px;
  max-width: 240px;
  border-right: 1px solid var(--line);
}
.evolucao-matrix-table thead .sticky-col {
  background: var(--table-head);
  z-index: 3;
}
.evolucao-matrix-table tfoot .sticky-col {
  background: var(--table-foot);
  z-index: 3;
}
.evolucao-matrix-table tbody tr:hover .sticky-col {
  background: var(--table-row-hover);
}
.col-mes-evolucao {
  min-width: 138px;
}
.cell-mes-evolucao {
  padding: 8px 10px !important;
  vertical-align: middle;
}
.evolucao-valor {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
}
.evolucao-sub {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 3px;
  font-size: 9.5px;
  line-height: 1.2;
}
.evolucao-var {
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 6px;
}
.evolucao-var.var-pos {
  color: var(--primary);
  background: var(--primary-soft);
}
.evolucao-var.var-neg {
  color: var(--danger);
  background: var(--danger-soft);
}
.evolucao-var.var-neutro {
  color: var(--muted);
}
.evolucao-part {
  color: var(--muted);
  font-weight: 500;
}
.evolucao-vazio {
  color: var(--muted);
  opacity: 0.5;
  font-size: 11px;
}

/* Gráfico de Evolução Patrimonial */
.evolucao-chart-card {
  padding: 18px 20px 14px;
}
.evolucao-svg-wrap {
  width: 100%;
  overflow-x: auto;
  margin-top: 4px;
}
.evolucao-svg {
  width: 100%;
  min-width: 680px;
  height: 280px;
  display: block;
}
.chart-line-anim {
  transition: opacity .2s ease, stroke-width .2s ease;
}
.evolucao-chart-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 11px;
  cursor: pointer;
  transition: all .15s ease;
}
.legend-chip:hover {
  border-color: var(--primary);
  background: var(--surface-alt);
}
.legend-chip.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}
.legend-chip.desmarcado {
  opacity: 0.45;
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}
.legend-chip.desmarcado .legend-color-dot {
  opacity: 0.35;
  filter: grayscale(1);
}
.legend-chip.is-total {
  font-weight: 700;
}
.legend-actions-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: 4px;
}
.btn-legend-action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
}
.btn-legend-action:hover {
  border-color: var(--primary);
  color: var(--ink);
  background: var(--surface);
}
.btn-legend-action.highlight {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}
.legend-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* Responsive Media Queries */
@media (max-width: 1100px) {
  .sidebar { width: 76px; padding: 20px 10px 14px; }
  .sidebar .logo strong, .sidebar .side-nav span, .sidebar .side-user > div:nth-child(2) { display: none; }
  .sidebar .side-nav a, .sidebar .side-nav button { justify-content: center; padding: 0; }
  .sidebar .side-user { justify-content: center; padding: 14px 0 2px; }
  .main-content, .app-shell.sidebar-collapsed .main-content, .main-content.collapsed { margin-left: 76px; width: calc(100% - 76px); padding: 24px 20px; }
  .kpi-grid.five, .kpi-grid.six { grid-template-columns: repeat(3, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .capital-chart, .upcoming { grid-column: auto; }
  .filter-bar { grid-template-columns: repeat(3, 1fr); }
  .upload-grid { grid-template-columns: 1fr 1fr; }
  .import-summary > div:last-child { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 640px) {
  body { font-size: 12px; }
  .sidebar { display: none; }
  .main-content, .app-shell.sidebar-collapsed .main-content, .main-content.collapsed { margin: 0; width: 100%; padding: 18px 14px 92px; }
  .mobile-nav { position: fixed; display: grid; grid-template-columns: repeat(5, 1fr); z-index: 50; inset: auto 0 0; height: 68px; background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 24px rgba(15,61,34,.08); padding-bottom: env(safe-area-inset-bottom); }
  .mobile-nav a, .mobile-nav button { border: 0; background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 9px; font-weight: 500; text-decoration: none !important; }
  .mobile-nav a.active, .mobile-nav button.active { color: var(--primary); font-weight: 600; }
  .page-header { margin-bottom: 16px; align-items: center; min-height: 44px; }
  .page-header h1 { font-size: 21px; margin-top: 4px; }
  .breadcrumb { font-size: 9px; }
  .kpi-grid, .kpi-grid.five, .kpi-grid.six, .kpi-grid.three { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; margin-right: -14px; padding-right: 14px; gap: 10px; }
  .kpi { min-width: 220px; scroll-snap-align: start; min-height: 116px; }
  .kpi strong { font-size: 18px; }
  .dashboard-grid { display: flex; flex-direction: column; }
  .quick-actions { overflow-x: auto; padding: 10px; }
  .quick-actions > span { display: none; }
  .quick-actions a, .quick-actions button { flex: 0 0 auto; }
  .filter-bar, .barra-filtros { display: flex; overflow-x: auto; margin-right: -14px; padding-right: 14px; }
  .filter-bar > *, .barra-filtros > * { flex: 0 0 145px; }
  .table-shell { margin-right: -14px; border-radius: 10px 0 0 10px; }
  .drawer { width: 100%; }
  .upload-grid { grid-template-columns: 1fr; }
  .import-summary > div:last-child { grid-template-columns: repeat(2, 1fr); }
  .backup-row { align-items: flex-start; gap: 16px; flex-direction: column; }
  .danger-zone > div:not(.section-title) { align-items: flex-start; gap: 12px; flex-direction: column; }
  .login-page { grid-template-columns: 1fr; background: var(--bg); }
  .login-aside { display: none; }
  .login-card { background: var(--surface); border: 1px solid var(--line); padding: 26px 22px; }
  .login-card > .logo { display: flex; color: var(--ink); margin-bottom: 8px; }
  .login-card > .logo strong span { color: var(--primary); }
}
