/* ==========================================================================
   Kyvero — tema visual (camada por cima de style.css)
   Linguagem visual de painéis de administração com barra lateral escura, barra de título da página, cartões planos com cabeçalho,
   tabelas com cabeçalho cinzento, etiquetas suaves e botões compactos. Os valores são nossos (e cumprem o contraste AA).
   ========================================================================== */

/* ---------- Tokens (claro) ---------- */
:root {
  /* menu lateral: texto forte, fundos suaves, linhas, marca do item ativo, 2.º tom do logótipo e fundo da coluna de ícones (mudam com a cor do menu) */
  --sb-strong: #fff; --sb-a: rgba(255, 255, 255, .08); --sb-b: rgba(255, 255, 255, .16); --sb-line: rgba(255, 255, 255, .15); --sb-mark: #9db8ff; --sb-brand2: #c9d7ff;
  --sb-rail: color-mix(in srgb, var(--sidebar-bg) 78%, #000);
  --bg: #f3f3f9;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --surface-3: #f3f6f9;
  --border: #e9ebec;
  --border-strong: #ced4da;
  --text: #212529;
  --text-2: #495057;
  --muted: #5d6677;

  --primary: #3f4f8c;
  --primary-hover: #34437a;
  --primary-soft: #e8ebf5;
  --primary-solid: #3f4f8c;
  --primary-solid-hover: #34437a;
  --accent: #2859c0;
  --accent-ink: #ffffff;
  --accent-soft: #e8effc;

  --pos: #0ab39c;
  --pos-text: #067565;
  --pos-soft: #daf4f0;
  --neg: #f06548;
  --neg-text: #b83a1e;
  --neg-soft: #fde8e3;
  --danger-solid: #c2391c;
  --warn: #8f5d0c;
  --warn-fill: #f7b84b;
  --warn-soft: #fef4e4;
  --pro: #8f5d0c;
  --pro-soft: #fef4e4;
  --info: #299cdb;
  --info-text: #146a98;
  --info-soft: #dff0fa;

  --grid: #eef0f3;
  --focus: 0 0 0 3px rgba(40, 89, 192, .28);
  --radius-sm: 4px;
  --radius: 4px;
  --radius-lg: 6px;
  --card-line: transparent;
  --row-line: #e9ebec;
  --shadow-card: 0 1px 2px rgba(56, 65, 74, .15);
  --shadow: 0 1px 2px rgba(56, 65, 74, .15);
  --shadow-sm: 0 1px 2px rgba(56, 65, 74, .12);

  --sidebar-bg: #3f4f8c;
  --sidebar-text: #cbd3f0;
  --sidebar-caption: #c2cbee;
  --sidebar-hover: rgba(255, 255, 255, .08);
  --topbar-h: 70px;
  --menu-w: 250px;
  --rail-w: 70px;
  --font-head: var(--font);
  --c1: #3f4f8c; --c2: #0ab39c; --c3: #f7b84b; --c4: #f06548; --c5: #299cdb; --c6: #6559cc; --c7: #ef8a3c; --c8: #7b8499; --c9: #b4bddb;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161a24;
    --surface: #1f2431;
    --surface-2: #252b3a;
    --surface-3: #2a3142;
    --border: #2f3748;
    --border-strong: #3d465a;
    --text: #e6e9f0;
    --text-2: #b9c0cf;
    --muted: #96a0b3;
    --primary: #8da2f0;
    --primary-hover: #a6b6f4;
    --primary-soft: #28325a;
    --primary-solid: #4a5da8;
    --primary-solid-hover: #3f5090;
    --accent: #6ea1ff;
    --accent-ink: #0e1422;
    --accent-soft: #1f2f52;
    --pos: #0ab39c;
    --pos-text: #3fd1bb;
    --pos-soft: #123a37;
    --neg: #f06548;
    --neg-text: #ff9a85;
    --neg-soft: #44231d;
    --danger-solid: #c2391c;
    --warn: #f0b454;
    --warn-soft: #3a2d12;
    --pro: #f0b454;
    --pro-soft: #3a2d12;
    --info-text: #72c4ee;
    --info-soft: #14354a;
    --grid: #2f3748;
    --card-line: var(--border);
    --row-line: #2f3748;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, .4);
    --sidebar-bg: #1b2032;
    --sidebar-text: #aab3cc;
    --sidebar-caption: #8f9ab6;
    --sidebar-hover: rgba(255, 255, 255, .06);
    --c1: #8da2f0; --c2: #2fd0b9; --c3: #f7b84b; --c4: #f58b73; --c5: #5cb9ea; --c6: #9a90f0; --c7: #f5a05a; --c8: #9aa3b8; --c9: #5a6788;
  }
}
:root[data-theme="dark"] {
  --bg: #161a24;
  --surface: #1f2431;
  --surface-2: #252b3a;
  --surface-3: #2a3142;
  --border: #2f3748;
  --border-strong: #3d465a;
  --text: #e6e9f0;
  --text-2: #b9c0cf;
  --muted: #96a0b3;
  --primary: #8da2f0;
  --primary-hover: #a6b6f4;
  --primary-soft: #28325a;
  --primary-solid: #4a5da8;
  --primary-solid-hover: #3f5090;
  --accent: #6ea1ff;
  --accent-ink: #0e1422;
  --accent-soft: #1f2f52;
  --pos: #0ab39c;
  --pos-text: #3fd1bb;
  --pos-soft: #123a37;
  --neg: #f06548;
  --neg-text: #ff9a85;
  --neg-soft: #44231d;
  --danger-solid: #c2391c;
  --warn: #f0b454;
  --warn-soft: #3a2d12;
  --pro: #f0b454;
  --pro-soft: #3a2d12;
  --info-text: #72c4ee;
  --info-soft: #14354a;
  --grid: #2f3748;
  --card-line: var(--border);
  --row-line: #2f3748;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, .4);
  --sidebar-bg: #1b2032;
  --sidebar-text: #aab3cc;
  --sidebar-caption: #8f9ab6;
  --sidebar-hover: rgba(255, 255, 255, .06);
  --c1: #8da2f0; --c2: #2fd0b9; --c3: #f7b84b; --c4: #f58b73; --c5: #5cb9ea; --c6: #9a90f0; --c7: #f5a05a; --c8: #9aa3b8; --c9: #5a6788;
}

/* ---------- Base ---------- */
body { background: var(--bg); font-size: 14px; }
a { color: var(--accent); }
h1, h2, h3, h4 { font-family: var(--font-head); }
.btn, button.btn { font-family: var(--font); }
.layout-app .content { padding: 24px 32px 64px; }
html:has(.layout-app) { scroll-padding-top: 150px; }
.layout-app .toasts { top: 150px; }

/* ---------- Barra lateral escura ---------- */
.sidebar { background: var(--sidebar-bg); border-right: 0; padding: 0 0 16px; gap: 0; color: var(--sidebar-text); }
.sidebar-top { height: var(--topbar-h); padding: 0 22px; flex: none; }
.sidebar .brand { color: var(--sb-strong); }
.sidebar .brand-name span { color: var(--sb-brand2); }
.sidebar .brand-mark { filter: none; }
.sidebar .sidebar-close { color: var(--sb-strong); border-color: var(--sb-line); background: transparent; }
.sidebar .sidebar-nav { gap: 0; padding-bottom: 12px; }
.sidebar .nav-group { color: var(--sidebar-caption); padding: 18px 24px 8px; font-size: 11px; letter-spacing: .08em; }
.sidebar .nav-item { border-radius: 0; padding: 10px 24px; font-size: 14px; font-weight: 400; color: var(--sidebar-text); gap: 12px; }
.sidebar .nav-item .icon { color: inherit; opacity: .9; width: 18px; height: 18px; }
.sidebar .nav-item:hover { background: var(--sidebar-hover); color: var(--sb-strong); }
.sidebar .nav-item.active { background: var(--sidebar-hover); color: var(--sb-strong); font-weight: 500; box-shadow: inset 3px 0 0 var(--sb-mark); }
.sidebar .nav-item.active .icon { color: var(--sb-strong); }
.sidebar .nav-count { background: #f06548; color: #fff; }
.sidebar .pillar-switch { margin: 6px 20px 4px; background: var(--sb-a); }
.sidebar .pillar-tab { color: var(--sidebar-text); }
.sidebar .pillar-tab:hover { color: var(--sb-strong); background: transparent; }
.sidebar .pillar-tab.active { background: var(--sb-b); color: var(--sb-strong); box-shadow: none; }
.sidebar-nav .nav-item:focus-visible, .sidebar .brand:focus-visible { outline: 2px solid var(--sb-strong); outline-offset: -2px; }
html.menu-collapsed .sidebar { padding-left: 0; padding-right: 0; }
html.menu-collapsed .sidebar-top { padding: 0; }
html.menu-collapsed .sidebar .nav-item { padding: 13px 0; justify-content: center; }
html.menu-collapsed .sidebar .nav-item.active { box-shadow: inset 3px 0 0 var(--sb-mark); }
html.menu-collapsed .sidebar .pillar-switch { margin: 6px 10px; }

/* Seletor de conta no menu lateral: um botão como o dos pilares; abre por baixo e empurra o menu */
.sidebar-account { margin: 6px 20px 4px; flex: none; }
.sidebar .abar-switch { position: static; }
.sidebar .abar-account > .icon:first-child { display: none; }
.sidebar .abar-account { width: 100%; margin: 0; padding: 8px 12px; gap: 8px; background: var(--sb-a); border: 0; border-radius: 4px; color: var(--sb-strong); }
.sidebar .abar-account:hover, .sidebar .abar-switch[open] .abar-account { background: var(--sb-b); }
.sidebar .abar-account:focus-visible { outline: 2px solid var(--sb-strong); outline-offset: 1px; }
.sidebar .abar-account > .icon { display: block; color: var(--sidebar-text); }
.sidebar .abar-account-text { flex: 1; min-width: 0; text-align: left; }
.sidebar .abar-account strong { display: block; max-width: none; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .abar-cur { font-size: 12px; font-weight: 600; }
.sidebar .abar-account .muted, .sidebar .abar-option .muted { color: var(--sidebar-text); }
.sidebar .abar-label { color: var(--sidebar-caption); }
.sidebar .abar-menu { position: static; width: auto; margin-top: 6px; padding: 6px; background: rgba(0, 0, 0, .18); border: 0; border-radius: 4px; box-shadow: none; }
.sidebar .abar-menu-group { margin: 6px 8px 4px; font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--sidebar-caption); }
.sidebar .abar-menu ul { max-height: 240px; }
.sidebar .abar-option { color: var(--sb-strong); }
.sidebar .abar-option:hover, .sidebar .abar-option:focus-visible { background: var(--sb-b); }
.sidebar .abar-option.current { background: var(--sb-b); }
.sidebar .abar-option-cur { color: var(--sidebar-text); }
.sidebar .abar-check { color: var(--sb-strong); }
.sidebar .abar-menu-foot { border-top-color: var(--sb-line); }
.sidebar .abar-menu-foot a { color: var(--sb-strong); }
.sidebar .abar-menu-foot a:hover { background: var(--sb-b); }
.sidebar .abar-menu-foot .icon { color: var(--sidebar-text); }
/* Menu recolhido (só ícones): só o ícone da carteira; o painel abre ao lado, por cima do conteúdo */
@media (min-width: 961px) {
  html.menu-collapsed .sidebar-account { margin: 6px 10px; }
  html.menu-collapsed .sidebar .abar-account { justify-content: center; padding: 10px 0; }
  html.menu-collapsed .sidebar .abar-account > .icon:first-child { display: block; }
  html.menu-collapsed .sidebar .abar-account-text, html.menu-collapsed .sidebar .abar-cur, html.menu-collapsed .sidebar .abar-caret { display: none; }
  html.menu-collapsed .sidebar .abar-menu { position: fixed; left: calc(var(--rail-w) + 8px); top: var(--abar-top, 76px); width: 300px; max-height: calc(100vh - var(--abar-top, 76px) - 8px); overflow-y: auto; margin: 0; padding: 6px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); }
  html.menu-collapsed .sidebar .abar-menu-group { color: var(--muted); }
  html.menu-collapsed .sidebar .abar-option, html.menu-collapsed .sidebar .abar-menu-foot a { color: var(--text); }
  html.menu-collapsed .sidebar .abar-option:hover, html.menu-collapsed .sidebar .abar-option:focus-visible, html.menu-collapsed .sidebar .abar-menu-foot a:hover { background: var(--surface-2); }
  html.menu-collapsed .sidebar .abar-option.current { background: var(--primary-soft); }
  html.menu-collapsed .sidebar .abar-option .muted, html.menu-collapsed .sidebar .abar-option-cur { color: var(--muted); }
  html.menu-collapsed .sidebar .abar-check { color: var(--primary); }
  html.menu-collapsed .sidebar .abar-menu-foot { border-top-color: var(--border); }
  html.menu-collapsed .sidebar .abar-menu-foot .icon { color: var(--muted); }
}

/* ---------- Barra de topo ---------- */
.topbar { height: var(--topbar-h); background: var(--surface); box-shadow: none; border-bottom: 1px solid var(--border); padding: 0 24px; }
.topsearch input { background: var(--bg); border: 0; height: 38px; font-size: 13px; }
.topsearch-results { border-radius: 4px; }
.topbar .icon-btn { border: 0; background: transparent; color: var(--text-2); }
.topbar .icon-btn:hover { background: var(--bg); }
.topbar .icon-btn-primary { background: var(--primary-solid); color: #fff; }
.usermenu-btn { background: var(--bg); border-radius: 4px; padding: 7px 12px 7px 8px; gap: 10px; }
.usermenu-btn:hover, .usermenu[open] .usermenu-btn { background: var(--surface-3); }
.avatar { background: var(--primary-soft); color: var(--primary); }
.usermenu-panel { border-radius: 4px; }
.account-bar { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; border-bottom: 1px solid var(--border); box-shadow: none; }

/* ---------- Barra de título da página ---------- */
.titlebar { background: var(--surface); box-shadow: var(--shadow-card); }
.titlebar-inner { max-width: 1280px; margin: 0 auto; padding: 12px 32px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.titlebar h1 { margin: 0; font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; color: var(--text-2); display: block; }
.titlebar .crumbs ol { margin: 0; justify-content: flex-end; font-size: 13px; }
.titlebar .crumbs li + li::before { content: "›"; }
.layout-app .page-head h1:not(.rich) { display: none; }
.layout-app .page-head { align-items: center; margin-bottom: 20px; }
.layout-app .page-head > div:first-child:not(:has(h1.rich)) .subtitle { margin: 0; }
.layout-app .page-head:not(:has(.subtitle)):not(:has(.page-actions > *)) { display: none; }

/* ---------- Cartões ---------- */
.panel, .card, .stat-card { background: var(--surface); border: 1px solid var(--card-line); border-radius: 4px; box-shadow: var(--shadow-card); }
.panel, .card { margin-bottom: 24px; padding: 20px; }
.panel > h2:first-child, .panel > .panel-head:first-child, .panel > .panel-head, .card > h2:first-child {
  margin: 0 0 14px; padding: 0; border: 0;        /* o cabeçalho do cartão não tem linha por baixo */
}
.panel > .panel-head { margin-bottom: 16px; }
.panel > h2:first-child, .card > h2:first-child { font-size: 16px; font-weight: 600; color: var(--text-2); }
.panel-head h2, .panel > .panel-head h2 { font-size: 16px; font-weight: 600; color: var(--text-2); margin: 0; }
/* Listas compridas dentro de um cartão: altura fixa e barra de deslocação fina */
.scroll-y { max-height: 360px; overflow-y: auto; scrollbar-width: thin; padding-right: 6px; }
.positions-panel, .ideas-panel { padding-top: 16px; }
.grid-2, .grid-3 { gap: 0 24px; }
.grid-main { gap: 24px; margin-bottom: 24px; }
.stat-grid { gap: 24px; margin-bottom: 24px; }
.stat-card { padding: 18px 20px; }
.stat-card .stat-label { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
/* O emblema de variação fica no canto superior direito do cartão quando há largura (a legenda deixa-lhe espaço); nos cartões estreitos fica por baixo do valor */
.stat-card { container-type: inline-size; }
@container (min-width: 250px) {
  .stat-sub:has(> .pct-pill:only-child) { position: absolute; top: 12px; right: 12px; margin: 0; }
  .stat-sub > .pct-pill:only-child { padding: 1px 6px; font-size: 11.5px; }
  .stat-card:has(> .stat-sub > .pct-pill:only-child) > .stat-label { padding-right: 62px; }
}
.stat-card .stat-value { font-family: var(--font-head); font-size: 22px; font-weight: 600; }
.stat-icon { width: 48px; height: 48px; border-radius: 4px; background: var(--primary-soft); color: var(--primary); }
.stat-icon.tone-pos { background: var(--pos-soft); color: var(--pos-text); }
.stat-icon.tone-neg { background: var(--neg-soft); color: var(--neg-text); }
.stat-icon.tone-warn { background: var(--warn-soft); color: var(--warn); }
.hero-figure { font-family: var(--font-head); font-weight: 600; }

/* ---------- Tabelas ---------- */
.data-table { font-size: 13px; }
.data-table th { background: var(--surface-3); color: var(--text); font-size: 13px; font-weight: 600; text-transform: none; letter-spacing: 0; padding: 11px 12px; border-bottom: 1px solid var(--row-line); }
.data-table th .th-sort { color: inherit; }
.data-table td { padding: 12px; border-bottom: 1px solid var(--row-line); vertical-align: middle; }
.data-table.compact td { padding: 10px 12px; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: var(--surface-2); }
.data-table thead th:first-child { border-top-left-radius: 4px; }
.data-table thead th:last-child { border-top-right-radius: 4px; }
.chart-table th { background: var(--surface-3); color: var(--text); text-transform: none; letter-spacing: 0; font-size: 13px; }
.table-wrap { margin: 0 -20px; padding: 0 20px; }

/* ---------- Botões ---------- */
.btn, :where(button[type="submit"]:not(.btn-link, .icon-btn, .toast-close)) {
  padding: 7px 14px; border-radius: 4px; font-size: 13.5px; font-weight: 500; background: var(--primary-solid); border-color: var(--primary-solid); color: #fff; box-shadow: none;
}
.btn:hover, :where(button[type="submit"]:not(.btn-link, .icon-btn, .toast-close)):hover { background: var(--primary-solid-hover); border-color: var(--primary-solid-hover); }
.btn-small, button.btn-small { padding: 5px 10px; font-size: 12.5px; }
.btn-secondary, button.btn-secondary { background: var(--surface-3); border-color: var(--surface-3); color: var(--text); }
.btn-secondary:hover, button.btn-secondary:hover { background: var(--border); border-color: var(--border); }
.btn-ghost, button.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover, button.btn-ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn-danger, button.btn-danger { background: var(--neg-soft); border-color: var(--neg-soft); color: var(--neg-text); }
.btn-danger:hover, button.btn-danger:hover { background: var(--neg); border-color: var(--neg); color: #fff; }
.btn-danger-solid, button.btn-danger-solid { background: var(--danger-solid); border-color: var(--danger-solid); color: #fff; }
.icon-btn { border-radius: 4px; }
.icon-btn-primary { background: var(--primary-solid); border-color: var(--primary-solid); color: #fff; }

/* ---------- Grupos de botões (períodos, filtros) ---------- */
.segmented { padding: 0; gap: 0; background: transparent; border-radius: 4px; border: 1px solid var(--accent); overflow: hidden; }
.segmented button { border-radius: 0; background: var(--accent-soft); color: var(--accent); font-weight: 500; padding: 6px 12px; border: 0; border-right: 1px solid var(--accent); }
.segmented button:last-child { border-right: 0; }
.segmented button:hover { color: var(--accent); background: color-mix(in srgb, var(--accent) 20%, var(--surface)); }
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); box-shadow: none; }

/* ---------- Separadores ---------- */
.tabs, .tabs-links { border-bottom: 1px solid var(--border); }
.tabs [role=tab], .tabs-links .tab { color: var(--text-2); font-weight: 500; border-bottom: 2px solid transparent; }
.tabs [role=tab][aria-selected="true"], .tabs-links .tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Campos ---------- */
input, select, textarea { border: 1px solid var(--border-strong); border-radius: 4px; background-color: var(--surface); font-size: 13px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: var(--focus); }
label { color: var(--text-2); font-weight: 500; }
.form-actions { border-top: 1px solid var(--border); }

/* ---------- Etiquetas ---------- */
.badge { border-radius: 4px; font-size: 11px; font-weight: 600; text-transform: none; letter-spacing: 0; padding: 3px 8px; }
.badge-open { background: var(--primary-soft); color: var(--primary); }
.badge-closed { background: var(--surface-3); color: var(--text-2); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.gain-pill, .pct-pill { border-radius: 4px; padding: 2px 8px; }
/* Emblema de variação: seta para cima/baixo antes do valor (o sinal fica no texto: a cor e a seta não são a única pista) */
.pct-pill.positive, .pct-pill.negative { display: inline-flex; align-items: center; gap: 5px; }
.pct-pill.positive::before, .pct-pill.negative::before { content: ""; flex: none; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; }
.pct-pill.positive::before { border-bottom: 6px solid currentColor; }
.pct-pill.negative::before { border-top: 6px solid currentColor; }
.pct-pill.positive { color: var(--pos-text); }
.pct-pill.negative { color: var(--neg-text); }
.stat-sub .pct-pill { margin-right: 4px; }
.tx { border-radius: 4px; }

/* ---------- Avisos ---------- */
.flash { border-radius: 4px; border: 0; border-left: 3px solid var(--primary); padding: 12px 14px; }
.flash-success { background: var(--pos-soft); color: var(--pos-text); border-left-color: var(--pos); }
.flash-error { background: var(--neg-soft); color: var(--neg-text); border-left-color: var(--neg); }
.flash-info { background: var(--accent-soft); color: var(--text); border-left-color: var(--accent); }
.toast { border-radius: 4px; }

/* ---------- Janelas ---------- */
.modal-box { border-radius: 4px; box-shadow: 0 10px 30px rgba(15, 23, 40, .25); }
.modal-head { border-bottom: 1px solid var(--border); padding: 14px 20px; }
.modal-head h2 { font-size: 16px; font-weight: 500; }

/* ---------- Calendários ---------- */
.calendar { gap: 0; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; background: var(--surface); }
.calendar .dow { background: var(--surface-3); color: var(--text); text-align: center; padding: 10px 4px; font-size: 13px; font-weight: 600; text-transform: none; letter-spacing: 0; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.calendar .dow:last-of-type { border-right: 0; }
.cal-day { border: 0; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); border-radius: 0; background: var(--surface); min-height: 84px; padding: 6px 8px; align-items: stretch; box-shadow: none; }
.cal-day:nth-child(8n) { border-right: 0; }
.calendar-events .cal-day:nth-child(7n) { border-right: 0; }
.cal-day .d { align-self: flex-end; font-size: 12px; font-weight: 500; color: var(--text); min-width: 22px; height: 22px; display: grid; place-items: center; }
.cal-day.outside { background: var(--surface); border-style: solid; }
.cal-day.outside .d { color: var(--muted); }
.cal-day.today { background: color-mix(in srgb, var(--primary) 9%, var(--surface)); box-shadow: none; }
.cal-day.today .d { background: var(--primary-solid); color: #fff; border-radius: 50%; }
.cal-day.selected { box-shadow: inset 0 0 0 2px var(--accent); border-color: var(--border); }
a.cal-day:hover, .calendar-events .cal-ev.has:hover { border-color: var(--border); background: var(--surface-2); }
.cal-day.pos { background: color-mix(in srgb, var(--pos) calc(var(--i) * 22%), var(--surface)); border-color: var(--border); }
.cal-day.neg { background: color-mix(in srgb, var(--neg) calc(var(--i) * 22%), var(--surface)); border-color: var(--border); }
.cal-week { background: var(--surface-3); }
.calendar-head h2 { font-size: 16px; font-weight: 500; }
.calendar-nav .btn-secondary, .calendar-nav .btn-ghost { background: var(--accent-soft); border: 1px solid var(--accent); color: var(--accent); }
.cal-filters .cal-filter { border-radius: 4px; }
.ev { border-radius: 2px; border-left: 0; font-size: 12px; font-weight: 600; padding: 1px 7px; color: var(--ev-fg, var(--text)); background: var(--ev-bg, var(--surface-3)); }
.ev:hover { background: color-mix(in srgb, var(--ev-bg, var(--surface-3)) 80%, var(--ev-fg, var(--text))); }
.ev.pending { background: transparent; box-shadow: inset 0 0 0 1px var(--ev-fg, var(--muted)); }
.ev-earnings { --ev: var(--info); --ev-bg: var(--info-soft); --ev-fg: var(--info-text); }
.ev-ex { --ev: var(--warn-fill); --ev-bg: var(--warn-soft); --ev-fg: var(--warn); }
.ev-pay { --ev: var(--pos); --ev-bg: var(--pos-soft); --ev-fg: var(--pos-text); }
.ev-count { border-radius: 4px; color: var(--ev-fg, var(--text)); background: var(--ev-bg, var(--surface-3)); }
.ev-badge { border-radius: 4px; background: var(--ev-bg); color: var(--ev-fg); }
.cal-filter .swatch { border-radius: 2px; background: var(--ev-fg, var(--ev, var(--primary))); }

@media (max-width: 960px) {
  .layout-app .content { padding: 16px 16px 48px; }
  .titlebar-inner { padding: 10px 16px; }
  html:has(.layout-app) { scroll-padding-top: 160px; }
}

/* ---------- Campo de ficheiro ---------- */
input[type="file"]::file-selector-button { margin-right: 12px; padding: 6px 12px; border: 0; border-radius: 4px; background: var(--surface-3); color: var(--text); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; }
input[type="file"]::file-selector-button:hover { background: var(--border); }

/* ---------- Paginação ---------- */
.page-btn { border-radius: 4px; border-color: var(--border); background: var(--surface); color: var(--text-2); }
.page-btn:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); text-decoration: none; }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---------- Tabelas com barra de ferramentas ---------- */
.dt-bar, .dt-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.dt-bar { margin-bottom: 14px; }
.dt-foot { margin-top: 14px; }
.dt-bar label { display: inline-flex; flex-direction: row; align-items: center; gap: 8px; font-weight: 400; color: var(--text-2); }
.dt-bar select { width: auto; height: 32px; padding: 4px 28px 4px 10px; }
.dt-bar input { width: 200px; height: 32px; padding: 4px 10px; }
.dt-info { color: var(--text-2); }
.dt-foot .pagination { margin-left: auto; }
.dt-foot .page-btn, .page-btn { min-width: 34px; height: 32px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center; font: inherit; font-size: 13px; cursor: pointer; }
.page-btn:disabled, .page-btn[aria-disabled="true"] { opacity: .45; cursor: default; }
.data-table tr[hidden] { display: none; }
.data-table a.symbol { color: var(--accent); font-weight: 600; }
.data-table tbody tr:hover td { background: var(--surface-2); }

/* ---------- Gráficos ---------- */
.chart-tooltip { padding: 0; border: 0; border-radius: 4px; overflow: hidden; box-shadow: 0 5px 24px rgba(15, 23, 40, .18); font-size: 12.5px; }
.chart-tooltip .tt-title { margin: 0; padding: 7px 12px; background: var(--surface-3); color: var(--text); font-weight: 600; }
.chart-tooltip .tt-row { padding: 6px 12px; }
.chart-tooltip .tt-row + .tt-row { margin-top: 0; }
.chart-tooltip .tt-key { width: 10px; height: 10px; border-radius: 2px; }
.chart-legend { gap: 18px; font-size: 13px; color: var(--muted); }
.legend-box { width: 12px; height: 12px; border-radius: 2px; }
.legend-line { height: 3px; border-radius: 2px; }
.sw-bar span:first-child { border-radius: 99px 0 0 99px; }
.sw-bar span:last-child { border-radius: 0 99px 99px 0; }
.sw-bar { height: 12px; }
.chart-box { margin-top: 4px; }
@media (max-width: 700px) {
  .table-wrap .data-table:not(.holdings-table):not(.ideas-table) td { white-space: nowrap; }
  .dt-bar, .dt-foot { justify-content: flex-start; }
  .dt-bar input { width: 150px; }
  .dt-foot .pagination { margin-left: 0; }
}

/* ==========================================================================
   Barra de topo com os números da conta, conteúdos em toda a largura
   ========================================================================== */
.layout-app .content, .titlebar-inner { max-width: none; }
.layout-app .content { padding: 24px 32px 64px; }
.titlebar-inner { padding: 12px 32px; }
.topbar { gap: 16px; }
.topbar .account-bar { flex: 1 1 auto; min-width: 0; background: transparent; border: 0; box-shadow: none; backdrop-filter: none; -webkit-backdrop-filter: none; }
.topbar .account-bar-inner { max-width: none; margin: 0; padding: 0; gap: 14px; }
.topbar .abar-stats { margin-left: auto; mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent); }
.topbar .abar-stats li:last-child .abar-item { padding-right: 24px; }
.topbar .abar-item { padding: 2px 14px; }
.topbar .abar-account { padding-top: 4px; padding-bottom: 4px; }
.topbar-right { flex: none; }
@media (max-width: 1180px) {
  .topbar { flex-wrap: wrap; height: auto; min-height: var(--topbar-h); padding: 10px 16px; row-gap: 8px; }
  .topbar .account-bar { order: 9; flex: 1 1 100%; border-top: 1px solid var(--border); padding-top: 8px; }
  .topsearch { flex: 1 1 200px; }
  .topbar-right { margin-left: auto; }
}
@media (max-width: 960px) {
  .layout-app .content { padding: 16px 16px 48px; }
  .topsearch { display: none; }
}
.topsearch { flex: 100 2 400px; min-width: 180px; max-width: 560px; }
.topsearch-results { width: 400px; right: auto; }
.topbar .abar-item { padding: 2px 10px; }
@media (max-width: 1700px) and (min-width: 1181px) {
  .topbar .topbar-action { width: 38px; height: 38px; padding: 0; font-size: 0; gap: 0; }
  .topbar .topbar-action .icon { width: 18px; height: 18px; }
  .usermenu-name { display: none; }
  .usermenu-btn { padding: 6px; }
  .usermenu-btn .abar-caret { display: none; }
}
@media (max-width: 1700px) and (min-width: 1181px) {
  .topsearch { flex-basis: 300px; }
  .topbar .abar-stats li:last-child { display: none; }
  .topbar .abar-stats li:nth-last-child(2) .abar-item { padding-right: 24px; }
}

/* ---------- Screener ---------- */
.screener-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px 16px; }
.screener-grid .wide { grid-column: span 2; }
.screener-grid label { font-size: 12.5px; }
.screener-actions { margin-top: 16px; border-top: 0; padding-top: 0; }
.screener-table .holding-name { max-width: 240px; }
.screener-table td { white-space: nowrap; }
.th-link { color: inherit; text-decoration: none; }
.th-link:hover { color: var(--accent); text-decoration: none; }
.range-mini { position: relative; display: inline-block; width: 70px; height: 6px; border-radius: 3px; vertical-align: middle; background: linear-gradient(to right, var(--neg), var(--warn-fill), var(--pos)); opacity: .85; }
.range-mini i { position: absolute; top: -3px; width: 4px; height: 12px; border-radius: 2px; transform: translateX(-50%); background: var(--text); box-shadow: 0 0 0 2px var(--surface); }
@media (max-width: 700px) { .screener-grid .wide { grid-column: span 1; } }

/* ---------- Notificações ---------- */
.notifmenu { position: relative; }
.notifmenu > summary { position: relative; list-style: none; cursor: pointer; display: inline-grid; place-items: center; width: 38px; height: 38px; }
.notifmenu > summary::-webkit-details-marker { display: none; }
.notifmenu[open] > summary { background: var(--bg); }
.notif-badge { position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px; background: var(--danger-solid); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 17px; text-align: center; }
.notif-panel { position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; width: 340px; max-width: calc(100vw - 24px); background: var(--surface); border: 1px solid var(--border); border-radius: 4px; box-shadow: var(--shadow-lg); }
.notif-head { margin: 0; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.notif-list { list-style: none; margin: 0; padding: 0; max-height: 380px; overflow-y: auto; }
.notif-list li + li { border-top: 1px solid var(--row-line); }
.notif-list a { display: flex; flex-direction: column; gap: 2px; padding: 11px 14px; color: var(--text); }
.notif-list a:hover { background: var(--surface-2); text-decoration: none; }
.notif-empty { padding: 16px 14px; }

/* ---------- Mini-gráficos dos cartões ---------- */
.stat-card { position: relative; }
.stat-card > :not(.spark) { position: relative; z-index: 1; }
.stat-card .spark { border-radius: 0 0 var(--radius, 4px) var(--radius, 4px); position: absolute; inset: auto 0 0 0; display: block; width: 100%; height: 34px; margin: 0; opacity: .5; pointer-events: none; z-index: 0; }
.screener-grid label { justify-content: flex-end; }
@media (max-width: 700px) { .stat-card:has(> .spark) { padding-bottom: 46px; } }

/* ---------- Balão de ajuda (info_tip) ---------- */
.tip { display: inline-grid; place-items: center; width: 18px; height: 18px; padding: 0; margin-left: 2px; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: help; vertical-align: -3px; }
.tip .icon { width: 14px; height: 14px; }
.tip:hover, .tip:focus-visible { color: var(--accent); }
.tip::after { content: attr(data-tip); position: absolute; left: 0; top: calc(100% + 6px); z-index: 5; width: max-content; max-width: 100%; padding: 7px 10px; border-radius: 4px; background: var(--text); color: var(--surface); font-size: 12px; font-weight: 400; line-height: 1.4; text-align: left; text-transform: none; letter-spacing: 0; box-shadow: var(--shadow-lg); opacity: 0; visibility: hidden; transition: opacity .12s; pointer-events: none; }
.tip:hover::after, .tip:focus::after { opacity: 1; visibility: visible; }
.stat-card > .stat-label { position: static; z-index: 3; } /* item da grelha: z-index cria contexto, o balão fica acima do valor */
.stat-card .tip::after { top: 46px; left: 12px; right: 12px; width: auto; max-width: none; }
/* Na gestão o balão é `position: relative` (style.css) e, sem isto, as margens de 12px contavam a partir do ícone de 18px: o texto ficava numa coluna de uma palavra por linha */
.layout-admin .stat-card .tip { position: static; }
.layout-admin .stat-card .tip::after { transform: none; }

/* Página «Account value»: o gráfico ao minuto e os botões do período */
.account-chart { width: 100%; height: 380px; }
@media (max-width: 700px) { .account-chart { height: 280px; } }

/* Gestão → To review: tabela com o gráfico do TradingView em cada linha e aprovação em bloco */
.review-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin: 12px 0; }
.review-bar .checkbox { margin: 0; }
.review-table td { vertical-align: middle; }
.review-chart-cell { min-width: 280px; width: 320px; }
.review-chart { width: 100%; min-height: 60px; }
.review-chart .tradingview-widget-container { width: 100%; height: 200px; }
.review-table td.num .btn + .btn { margin-left: 4px; }
@media (max-width: 700px) { .review-chart-cell { min-width: 240px; } }
@media (prefers-reduced-motion: reduce) { .tip::after { transition: none; } }

/* ---------- Menu «Adicionar» ---------- */
.addmenu { position: relative; }
.addmenu-btn { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.addmenu-btn::-webkit-details-marker { display: none; }
.addmenu[open] .addmenu-btn { filter: brightness(.92); }
.addmenu-panel { width: 220px; }
@media (max-width: 1700px) { .addmenu-btn { width: 38px; height: 38px; padding: 0; justify-content: center; } .addmenu-label { display: none; } .addmenu-btn .icon { width: 18px; height: 18px; } }
/* O mini-gráfico ocupa a largura total do cartão (e não só a coluna do texto) */
.stat-card:has(> .stat-icon) > .spark { grid-column: auto; grid-row: auto; }
.stat-card > .spark { left: 0; right: 0; bottom: 0; width: 100%; }

/* Dashboard: o gráfico do capital ocupa as duas colunas (o dobro da largura), com a altura normal */
.dashboard-charts .panel-wide { grid-column: 1 / -1; }

/* ---------- Screener: lista de observação e filtros guardados ---------- */
.screener-saved { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; padding: 12px 16px; }
.chip-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip-wrap { display: inline-flex; align-items: stretch; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface); color: var(--text); font-size: 13px; font-weight: 500; }
.chip:hover { background: var(--surface-2); text-decoration: none; }
.chip .icon { width: 14px; height: 14px; }
.chip-on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.chip-wrap .chip { border-radius: 99px 0 0 99px; border-right: 0; }
.chip-wrap form { margin: 0; display: flex; }
.chip-x { display: inline-grid; place-items: center; width: 28px; padding: 0; border: 1px solid var(--border); border-radius: 0 99px 99px 0; background: var(--surface); color: var(--muted); cursor: pointer; }
.chip-x:hover { color: var(--neg-text); background: var(--surface-2); }
.chip-x .icon { width: 12px; height: 12px; }
.save-filter { display: flex; gap: 8px; align-items: center; margin: 0; }
.save-filter input { width: 190px; }
.star-btn { display: inline-grid; place-items: center; width: 24px; height: 24px; padding: 0; margin-right: 4px; border: 0; background: none; color: var(--muted); cursor: pointer; vertical-align: -6px; }
.star-btn .icon { width: 16px; height: 16px; }
.star-btn:hover { color: var(--warn); }
.star-btn[aria-pressed="true"] { color: var(--warn); }
.star-btn[aria-pressed="true"] .icon { fill: currentColor; }
@media (max-width: 700px) { .save-filter { width: 100%; } .save-filter input { flex: 1; width: auto; } }
.notif-foot { display: flex; justify-content: space-between; gap: 12px; margin: 0; padding: 10px 14px; border-top: 1px solid var(--border); font-size: 12.5px; }
.notif-foot .link-button { padding: 0; }

/* ---------- Entrar, registar e recuperar palavra-passe: faixa de cor com o cartão a sobrepor-se ---------- */
.auth-wrap { position: relative; padding: 64px 0 72px; }
.auth-wrap::before { content: ""; position: absolute; z-index: 0; top: 0; height: 230px; left: 50%; width: 100vw; margin-left: -50vw;
  background: linear-gradient(135deg, var(--sidebar-bg) 0%, #25305a 100%); }
.auth-card { position: relative; z-index: 1; border: 0; border-radius: 4px; box-shadow: 0 10px 30px rgba(31, 38, 79, .18); padding: 34px 34px 30px; }
.auth-card h1 { font-family: var(--font-head); font-size: 22px; }
.auth-card .btn[type="submit"], .auth-card button[type="submit"] { border-radius: 4px; }
@media (max-width: 700px) { .auth-wrap { padding-top: 32px; } .auth-wrap::before { height: 150px; } .auth-card { padding: 26px 20px 24px; } }

/* Acessibilidade das páginas públicas: a atribuição do TradingView (o widget pinta-a de cinza claro) e as ligações dentro de texto */
.auth-card .auth-switch a, .auth-card .small a { text-decoration: underline; }

/* ---------- Menu lateral: grupos que recolhem ---------- */
.sidebar .nav-bare { padding-top: 8px; }
.sidebar .nav-group { display: flex; align-items: center; justify-content: space-between; width: 100%; border: 0; background: none; cursor: pointer; text-transform: uppercase; font-weight: 600; font-family: inherit; text-align: left; }
.sidebar .nav-group:hover { color: var(--sb-strong); }
.sidebar .nav-group:focus-visible { outline: 2px solid var(--sb-strong); outline-offset: -2px; }
.nav-caret { width: 14px; height: 14px; transition: transform .15s; }
.nav-section.collapsed .nav-caret { transform: rotate(-90deg); }
.nav-section.collapsed .nav-items { display: none; }
/* só ícones: sem títulos nem setas, e os grupos recolhidos voltam a mostrar os itens */
html.menu-collapsed .sidebar .nav-group { display: none; }
html.menu-collapsed .sidebar .nav-section.collapsed .nav-items { display: block; }
html.menu-collapsed .sidebar .nav-section + .nav-section, html.menu-collapsed .sidebar .nav-bare + .nav-section { border-top: 1px solid var(--sb-line); margin-top: 6px; padding-top: 6px; }
@media (max-width: 1180px) { html.menu-collapsed .sidebar .nav-group { display: flex; } html.menu-collapsed .sidebar .nav-section.collapsed .nav-items { display: none; } }
@media (prefers-reduced-motion: reduce) { .nav-caret { transition: none; } }
.titlebar .crumbs a { color: inherit; text-decoration: none; }
.titlebar .crumbs a:hover { color: var(--accent); text-decoration: underline; }

/* ---------- Heatmap das posições ---------- */
.heatmap { position: relative; width: 100%; margin-top: 8px; border-radius: 4px; overflow: hidden; background: var(--surface); }
.hm-tile { position: absolute; box-sizing: border-box; display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 1px; padding: 7px 9px; overflow: hidden;
  border: 2px solid var(--surface); text-decoration: none; line-height: 1.2; transition: filter .12s, transform .12s; }
.hm-tile:hover, .hm-tile:focus-visible { filter: brightness(.94); text-decoration: none; z-index: 2; outline: 2px solid var(--text); outline-offset: -2px; }
.hm-sym { font-family: var(--font-head); font-weight: 600; font-size: 14px; letter-spacing: .01em; }
.hm-chg { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }
.hm-val { margin-top: auto; font-size: 12px; opacity: .9; font-variant-numeric: tabular-nums; }
.hm-na { background-image: repeating-linear-gradient(135deg, rgba(0, 0, 0, .05) 0 6px, transparent 6px 12px); }
.hm-tip { position: absolute; z-index: 5; display: flex; flex-direction: column; gap: 2px; min-width: 170px; max-width: 260px; padding: 9px 11px; border-radius: 4px; background: var(--text); color: var(--surface);
  font-size: 12.5px; line-height: 1.35; box-shadow: var(--shadow-lg); pointer-events: none; }
.hm-tip[hidden] { display: none; }
.hm-tip strong { font-size: 13px; margin-bottom: 2px; }
.heatmap-legend { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.heatmap-scale { flex: 0 1 260px; height: 10px; border-radius: 5px; background: linear-gradient(90deg, var(--neg), var(--surface-3) 50%, var(--pos)); }
.heatmap-table { padding: 0; }
.heatmap-table > summary { padding: 14px 20px; cursor: pointer; font-weight: 500; }
.heatmap-table .table-wrap { padding: 0 20px 16px; }
@media (prefers-reduced-motion: reduce) { .hm-tile { transition: none; } }

/* ---------- Logótipos das empresas ---------- */
.logo { display: inline-block; flex: none; width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--border); object-fit: contain; background: #fff; vertical-align: middle; }
.c-asset .logo, .c-inst .logo, .screener-table td:first-child .logo { float: left; margin: 1px 10px 0 0; }
h1.rich .logo { width: 40px; height: 40px; margin-right: 8px; border-radius: 8px; }
.logo[src*="t=etf"] { background: transparent; }
.footer-credits { font-size: 12px; color: var(--muted); }
.content > .footer-credits { margin: 28px 0 4px; text-align: center; }

/* ---------- Ideas: porque aparecem estas ações ---------- */
.hl-of { margin-left: 8px; font-size: 13px; font-weight: 500; color: var(--muted); }
.list-why { margin: 0 0 18px; padding: 16px 20px; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 4px; }
.list-why h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-size: 15px; }
.list-why h2 .icon { width: 18px; height: 18px; color: var(--accent); }
.list-why p { margin: 0 0 10px; max-width: 78ch; }
.why-stats { display: flex; flex-wrap: wrap; gap: 10px 28px; margin: 0 0 10px; padding: 0; list-style: none; }
.why-stats li { display: flex; align-items: baseline; gap: 8px; }
.why-stats strong { font-family: var(--font-head); font-size: 20px; }
.why-stats span { color: var(--muted); font-size: 13px; }
.why-listed { margin: 0 0 12px; padding: 8px 12px; border-radius: 4px; background: var(--primary-soft); color: var(--text); font-size: 13px; }
.why-listed .icon { color: var(--pos-text); }
.yield-control { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 0 0 16px; padding: 10px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; }
.yc-label { font-weight: 500; font-size: 13.5px; }
.yc-custom { display: inline-flex; align-items: center; gap: 6px; }
.yc-custom input { width: 84px; }
.yield-control .yc-custom { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; margin: 0; white-space: nowrap; }
.yield-control .yc-custom input { width: 84px; margin: 0; }
.list-why a, .ideas-notes a { text-decoration: underline; }
.hm-logo { position: absolute; top: 7px; right: 8px; border-radius: 6px; background: #fff; object-fit: contain; border: 1px solid rgba(0, 0, 0, .08); }

/* ---------- Lista de observação ---------- */
.watch-table td { vertical-align: middle; }
.watch-table td:first-child .logo { float: left; margin: 1px 10px 0 0; }
.alert-form { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 12px; margin: 0; }
.alert-form label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.alert-form input[type="text"] { width: 110px; }
.inline-form { display: inline-block; margin: 0 0 0 4px; }

/* ---------- Comparação com o mercado ---------- */
.bench-form select { max-width: 320px; }
.bench-rows { display: grid; gap: 12px; margin: 6px 0 14px; }
.bench-row { display: grid; grid-template-columns: 150px 1fr 80px 120px; align-items: center; gap: 12px; }
.bench-label { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bench-bar { display: block; height: 14px; border-radius: 7px; background: var(--surface-3); overflow: hidden; }
.bench-bar i { display: block; height: 100%; border-radius: 7px; }
.bench-you { background: var(--primary-solid); }
.bench-etf { background: var(--muted); }
.bench-bar i.neg { background: var(--neg); }
.bench-pct { text-align: right; font-variant-numeric: tabular-nums; }
.bench-amount { text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; }
.bench-verdict { margin: 0; font-weight: 500; }
@media (max-width: 700px) { .bench-row { grid-template-columns: 1fr 70px; } .bench-label { grid-column: 1 / -1; } .bench-bar { grid-column: 1; } .bench-amount { grid-column: 1 / -1; text-align: left; } }

/* ---------- Cookies e privacidade ---------- */
.consent-banner { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 80; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; max-width: 980px; margin: 0 auto; padding: 16px 20px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 10px 30px rgba(31, 38, 79, .22); }
.consent-banner p { margin: 0; flex: 1 1 420px; font-size: 14px; line-height: 1.5; }
.consent-banner a, .consent-card a { text-decoration: underline; }
.consent-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; }
.consent-card .consent-actions { margin: 14px 0; }
@media (max-width: 700px) { .consent-banner { left: 8px; right: 8px; bottom: 8px; } .consent-actions .btn { flex: 1 1 140px; } }

/* ---------- Explore Market (público) ---------- */
.public-nav a { padding: 4px 0; border-bottom: 2px solid transparent; }
.public-nav a[aria-current] { color: var(--accent); border-bottom-color: var(--accent); }
.market-head h1 { font-family: var(--font-head); font-size: 30px; margin: 4px 0 8px; }
.market-head .lead { max-width: 70ch; color: var(--muted); margin: 0 0 18px; }
.market-table td:first-child .logo { float: left; margin: 1px 10px 0 0; }
.logo-title { display: flex; align-items: center; gap: 14px; }
.logo-title .logo { width: 52px; height: 52px; border-radius: 10px; }
.logo-title h1.rich { margin: 0; }
.market-cta { text-align: center; padding: 26px 20px; }
.market-cta h2 { margin: 0 0 6px; }
.market-cta p { margin: 0 auto 12px; max-width: 60ch; }
.kv { display: grid; gap: 0; margin: 0; }
.kv > div { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--row-line); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; text-align: right; }

/* ---------- Histórico de preços (templates/price_history.php) ---------- */
.hist-views { margin: 0 0 12px; }
.hist-table th[scope=row] { text-align: left; font-weight: 500; white-space: nowrap; }
.hist-table .badge { margin-left: 6px; background: var(--bg-soft, #eef1f7); color: var(--muted); }
.hist-pager { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 12px 0; }
.hist-table tbody th { background: transparent; color: var(--text); }

/* Notícias de um instrumento (templates/news_list.php) */
.news-list { list-style: none; margin: 0 0 12px; padding: 0; }
.news-list li { display: flex; flex-direction: column; gap: 2px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.news-list li:last-child { border-bottom: 0; }
.news-list a { font-weight: 500; overflow-wrap: anywhere; }

/* Gestão: a barra lateral tem uma cor própria (verde-azulado escuro) para se distinguir logo do site (azul-índigo) */
body.layout-admin {
  --sidebar-bg: #1e4b49;
  --sidebar-text: #cfe6e3;
  --sidebar-caption: #b4d5d1;
  --sidebar-hover: rgba(255, 255, 255, .09);
  --sidebar-accent: #7fe3d2;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body.layout-admin { --sidebar-bg: #0f2423; --sidebar-text: #a9cbc7; --sidebar-caption: #8db3af; --sidebar-hover: rgba(255, 255, 255, .06); }
}
:root[data-theme="dark"] body.layout-admin { --sidebar-bg: #0f2423; --sidebar-text: #a9cbc7; --sidebar-caption: #8db3af; --sidebar-hover: rgba(255, 255, 255, .06); }
.layout-admin .sidebar .nav-item.active { box-shadow: inset 3px 0 0 var(--sidebar-accent, #7fe3d2); }

/* ---------- Alocação por ativo: anel com o total ao centro e a lista por baixo ---------- */
.alloc-chart { height: 220px; }
.alloc-list { list-style: none; margin: 12px 0 0; padding: 0; max-height: 340px; overflow-y: auto; scrollbar-width: thin; padding-right: 8px; }
.alloc-list li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px dashed var(--border); }
.alloc-list li:first-child { border-top: 0; }
.alloc-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--dot); }
.alloc-list .logo { flex: none; border-radius: 50%; }
.alloc-name { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.alloc-name a { color: var(--text); }
.alloc-name .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alloc-figures { display: flex; flex-direction: column; align-items: flex-end; flex: none; line-height: 1.4; font-variant-numeric: tabular-nums; }
.alloc-figures .pct-pill { padding: 0 6px; font-size: 11.5px; }

/* ---------- Atividade recente ---------- */
.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px dashed var(--border); }
.activity-list li:first-child { border-top: 0; padding-top: 2px; }
.activity-list .stat-icon { flex: none; width: 36px; height: 36px; }
.activity-list .stat-icon .icon { width: 17px; height: 17px; }
.activity-main { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.35; }
.activity-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-amount { flex: none; font-variant-numeric: tabular-nums; }

/* ---------- Atalhos e ecrã inteiro na barra de topo ---------- */
.appsmenu { position: relative; }
.appsmenu > summary { list-style: none; cursor: pointer; }
.appsmenu > summary::-webkit-details-marker { display: none; }
.apps-panel { position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; width: 300px; max-width: calc(100vw - 24px); padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 4px; box-shadow: var(--shadow-lg); }
.apps-head { margin: 0 4px 8px; font-size: 13px; }
.apps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.apps-grid a { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; border-radius: 4px; color: var(--text-2); font-size: 12.5px; text-align: center; line-height: 1.2; }
.apps-grid a:hover, .apps-grid a:focus-visible { background: var(--surface-2); color: var(--text); text-decoration: none; }
.apps-grid .icon { width: 22px; height: 22px; color: var(--primary); }
.fullscreen-toggle .icon-exit, .fullscreen-toggle.is-fullscreen .icon-enter { display: none; }
.fullscreen-toggle.is-fullscreen .icon-exit { display: inline-block; }
@media (max-width: 1700px) { .fullscreen-toggle { display: none; } }
@media (max-width: 960px) { .appsmenu { display: none; } }
.fullscreen-toggle[hidden] { display: none !important; }

.sidebar-panel { display: contents; }

/* ---------- Cor do menu e largura (painel «Customise»): a cor do menu é a da marca (por omissão), clara (segue o tema) ou escura ---------- */
:root[data-sidebar="light"] {
  --sidebar-bg: var(--surface); --sidebar-text: var(--text-2); --sidebar-caption: var(--muted); --sidebar-hover: var(--surface-3);
  --sb-strong: var(--text); --sb-a: var(--surface-3); --sb-b: var(--border); --sb-line: var(--border); --sb-mark: var(--primary); --sb-brand2: var(--primary); --sb-rail: var(--surface-2);
}
:root[data-sidebar="light"] .sidebar { border-right: 1px solid var(--border); }
:root[data-sidebar="light"] .sidebar .brand-name { color: var(--text); }
:root[data-sidebar="dark"] { --sidebar-bg: #1b2032; --sidebar-text: #aab3cc; --sidebar-caption: #8f9ab6; --sidebar-hover: rgba(255, 255, 255, .06); }
:root[data-width="boxed"] .layout-app .content, :root[data-width="boxed"] .layout-app .titlebar-inner { max-width: 1280px; margin-left: auto; margin-right: auto; }

/* ---------- Painel «Customise» ---------- */
.customizer-backdrop { position: fixed; inset: 0; z-index: 59; background: rgba(8, 12, 20, .45); }
.customizer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 60; width: 340px; max-width: 100vw; display: flex; flex-direction: column; background: var(--surface); box-shadow: var(--shadow-lg); transform: translateX(0); }
.customizer[hidden], .customizer-backdrop[hidden] { display: none; }
.customizer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; background: var(--primary-solid); color: #fff; }
.customizer-head h2 { margin: 0; font-size: 16px; font-weight: 600; color: #fff; }
.customizer-head .icon-btn { color: #fff; border: 0; background: transparent; }
.customizer-head .icon-btn:hover { background: rgba(255, 255, 255, .16); }
.customizer-body { flex: 1; overflow-y: auto; padding: 8px 20px 20px; }
.customizer fieldset { border: 0; margin: 0; padding: 14px 0 6px; min-width: 0; }
.customizer legend { padding: 0; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 8px; }
.custom-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.custom-options.two { grid-template-columns: repeat(2, 1fr); }
.custom-option { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 6px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--text-2); font: inherit; font-size: 12.5px; cursor: pointer; }
.custom-option:hover { background: var(--surface-2); }
.custom-option[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); color: var(--text); font-weight: 600; }
.custom-option:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.custom-preview { display: flex; width: 100%; height: 38px; border-radius: 3px; overflow: hidden; background: var(--surface-3); border: 1px solid var(--border); }
.custom-preview i { display: block; background: var(--primary-solid); }
.custom-preview .panel-p { width: 26%; }
.custom-preview .wide { width: 36%; }
.custom-preview.dark-p { background: #1f2431; }
.custom-preview.box-p { justify-content: center; }
.custom-preview.box-p i { width: 58%; background: var(--surface); border-inline: 1px solid var(--border); }
.custom-swatch { width: 100%; height: 38px; border-radius: 3px; border: 1px solid var(--border); }
.custom-swatch.brand { background: #3f4f8c; }
.custom-swatch.light { background: #fff; }
.custom-swatch.dark { background: #1b2032; }
.customizer-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }
@media (prefers-reduced-motion: no-preference) { .customizer { animation: customizer-in .18s ease-out; } @keyframes customizer-in { from { transform: translateX(24px); opacity: 0; } } }

/* ---------- Barra de ferramentas dos gráficos de tempo (zoom por arrasto, repor, guardar imagem) ---------- */
.chart-tools { position: absolute; top: -4px; right: 0; z-index: 2; display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.chart-box:hover .chart-tools, .chart-tools:focus-within { opacity: 1; }
@media (hover: none) { .chart-tools { opacity: 1; } }
.chart-tools .chart-tool { width: 28px; height: 28px; border: 0; background: var(--surface); color: var(--muted); border-radius: 4px; }
.chart-tools .chart-tool:hover { background: var(--surface-3); color: var(--text); }
.chart-tools .icon { width: 15px; height: 15px; }
.chart-tools [hidden] { display: none; }

/* ---------- Acabamentos ---------- */
/* cartões estreitos: o valor encolhe em vez de tocar na borda */
@container (max-width: 235px) {
  .stat-card .stat-value { font-size: 19px; }
  .stat-card > .stat-icon { display: none; }                                  /* sem o ícone, o texto ganha a largura toda */
  .stat-card:has(> .stat-icon) > :not(.stat-icon) { grid-column: 1 / -1; }
}
/* entre 1700 e 1900 px a barra de topo já não leva o último número da conta (senão fica cortado) */
@media (min-width: 1701px) and (max-width: 1900px) { .topbar .abar-stats li:last-child { display: none; } .topbar .abar-stats li:nth-last-child(2) .abar-item { padding-right: 24px; } }
/* «Recent activity» ocupa a largura toda do Dashboard e parte a lista em duas colunas quando há espaço */
.dashboard-charts > .activity-card { grid-column: 1 / -1; container-type: inline-size; }
@container (min-width: 720px) {
  .activity-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0 40px; }
  .activity-list li:nth-child(2) { border-top: 0; padding-top: 2px; }
}
.activity-amount.negative { color: var(--neg-text); }

.split-chart { height: 190px; }
.split-card .alloc-list { max-height: 260px; }

/* ==========================================================================
   Site público (página inicial, rodapé): faixa de topo com o degradê do menu, cartões planos, títulos centrados
   ========================================================================== */
.hero { position: relative; isolation: isolate; clip-path: inset(0 -100vmax); margin-top: -24px; padding: 60px 0 68px; color: #fff; }
.hero::before { content: ""; position: absolute; inset: 0 -100vmax; z-index: -1; background: linear-gradient(135deg, var(--sidebar-bg) 0%, #25305a 100%); }
.hero h1 { color: #fff; }
.hero h1 em { background: linear-gradient(90deg, #9db8ff, #d3c7ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero .lead { color: rgba(255, 255, 255, .88); }
.hero .muted { color: rgba(255, 255, 255, .78); }
.hero .eyebrow { background: rgba(255, 255, 255, .14); color: #fff; }
.hero .btn:not(.btn-secondary) { background: #fff; border-color: #fff; color: #2c3a73; }
.hero .btn:not(.btn-secondary):hover { background: #e8ebf5; border-color: #e8ebf5; color: #2c3a73; }
.hero .btn-secondary { background: transparent; border-color: rgba(255, 255, 255, .55); color: #fff; }
.hero .btn-secondary:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.hero .mock { box-shadow: 0 24px 60px rgba(8, 12, 30, .45); }
.public-content > .section-title { flex-direction: column; gap: 10px; margin-top: 48px; }
.public-content > .section-title::after { content: ""; width: 44px; height: 3px; border-radius: 3px; background: var(--accent); }
.pillar-card, .feature { border: 0; border-radius: 4px; box-shadow: var(--shadow-card); transition: box-shadow .15s, transform .15s; }
.pillar-card:hover, .feature:hover { box-shadow: 0 6px 20px rgba(56, 65, 74, .14); transform: translateY(-2px); }
@media (prefers-reduced-motion: reduce) { .pillar-card, .feature { transition: none; } .pillar-card:hover, .feature:hover { transform: none; } }
.feature-icon { width: 46px; height: 46px; border-radius: 50%; }
.cta-panel { background: linear-gradient(135deg, var(--sidebar-bg), #25305a); border: 0; color: #fff; }
.panel.cta-panel > h2:first-child, .cta-panel h2, .cta-panel p { color: #fff; }
.cta-panel .btn { background: #fff; border-color: #fff; color: #2c3a73; }
.cta-panel .btn:hover { background: #e8ebf5; border-color: #e8ebf5; }
.site-footer { background: var(--sidebar-bg); border-top: 0; color: var(--sidebar-text); }
.site-footer .brand { color: #fff; }
.site-footer .brand-name span { color: #c9d7ff; }
.site-footer .muted, .site-footer a { color: var(--sidebar-text); }
.site-footer a:hover { color: #fff; }
.site-footer .lang-links strong { color: #fff; }

html:has(body.layout-public) { overflow-x: clip; }
body.layout-public { overflow-x: clip; }   /* a faixa de topo vai além do contentor sem criar deslocação horizontal */

/* gestão: a coluna de ícones deriva da cor (própria) do menu da gestão */
body.layout-admin { --sb-rail: color-mix(in srgb, var(--sidebar-bg) 78%, #000); }

/* ---------- Cor da barra de topo e tamanho do menu (painel «Customise») ---------- */
:root[data-topbar="brand"] .topbar, :root[data-topbar="dark"] .topbar {
  --text: #fff; --text-2: #e6e9f7; --muted: #cbd3f0; --bg: rgba(255, 255, 255, .12); --surface-2: rgba(255, 255, 255, .12); --surface-3: rgba(255, 255, 255, .16); --border: rgba(255, 255, 255, .2);
  background: #3f4f8c; border-bottom-color: transparent; color: #fff;     /* a cor da marca (não a do menu, que pode ser clara) */
}
:root[data-topbar="dark"] .topbar { background: #1b2032; }
:root[data-topbar="brand"] .topbar .topsearch input::placeholder, :root[data-topbar="dark"] .topbar .topsearch input::placeholder { color: #cbd3f0; opacity: 1; }
:root[data-topbar="brand"] .topbar .btn:not(.btn-secondary), :root[data-topbar="dark"] .topbar .btn:not(.btn-secondary) { background: #fff; border-color: #fff; color: #2c3a73; }
:root[data-topbar="brand"] .topbar .avatar, :root[data-topbar="dark"] .topbar .avatar { background: rgba(255, 255, 255, .2); color: #fff; }
:root[data-topbar="brand"] .topbar .abar-value.positive, :root[data-topbar="dark"] .topbar .abar-value.positive { color: #7fe3d0; }
:root[data-topbar="brand"] .topbar .abar-value.negative, :root[data-topbar="dark"] .topbar .abar-value.negative { color: #ffb4a3; }
.lang-toggle { font-size: 12px; font-weight: 700; letter-spacing: .03em; }
@media (max-width: 1700px) { .lang-toggle { display: none; } }

/* contrastes (auditoria axe): a legenda «Account» do menu e as datas esperadas do calendário em modo escuro */
.sidebar .abar-label { color: var(--sb-strong); font-weight: 600; }
.cal-day.expected .sym.n { color: var(--text-2); }
.sidebar .abar-account .muted { color: var(--sb-strong); }

/* ---------- Telemóvel (verificação visual a 390 px) ---------- */
@media (max-width: 560px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }                 /* dois cartões por linha em vez de um muito alto */
  .screener-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }              /* filtros do Explore Market e do Screener em duas colunas */
  .screener-grid .wide { grid-column: 1 / -1; }
  .topbar-right > .btn-ghost span { display: none; }                                          /* gestão: o botão «Kyvero» fica só com a seta */
}

/* nomes longos da lista do mercado e do screener: cortados com reticências em vez de passarem para a coluna do preço */
.screener-table .holding-name { display: block; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 560px) {
  .screener-table .holding-name { max-width: 170px; }
  /* botões de período e de vista: deslizam em vez de ficarem cortados */
  .segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .segmented::-webkit-scrollbar { display: none; }
  .segmented button { flex: none; white-space: nowrap; }
}

/* ---------- Barra de título das páginas públicas (como a da aplicação) ---------- */
.public-titlebar { position: relative; isolation: isolate; clip-path: inset(0 -100vmax -6px); margin: -24px 0 24px; background: var(--surface); }
.public-titlebar::before { content: ""; position: absolute; inset: 0 -100vmax; z-index: -1; background: var(--surface); box-shadow: var(--shadow-card); }
.public-titlebar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 12px 0; }
.public-titlebar h1, .public-titlebar-title { margin: 0; font-size: 15px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; color: var(--text-2); display: block; }
.public-titlebar .crumbs ol { margin: 0; padding: 0; display: flex; gap: 6px; list-style: none; font-size: 13px; color: var(--muted); }
.public-titlebar .crumbs li + li::before { content: "›"; margin-right: 6px; }
.public-titlebar .crumbs a { color: var(--muted); }
.public-titlebar .crumbs [aria-current] { color: var(--text); }
.market-head { margin-top: 0; }

/* ---------- Disposição horizontal (menu por baixo da barra de topo) e moldura «semi-box» ---------- */
.hnav { display: none; }
@media (min-width: 961px) {
  html[data-layout="horizontal"] { --sidebar-w: 0px; }
  html[data-layout="horizontal"] .sidebar, html[data-layout="horizontal"] .sidebar-backdrop, html[data-layout="horizontal"] [data-menu-toggle] { display: none; }
  html[data-layout="horizontal"] .topbar-brand { display: inline-flex; }
  html[data-layout="horizontal"] .hnav { display: flex; align-items: center; gap: 2px; height: 46px; padding: 0 24px; background: var(--sidebar-bg); color: var(--sidebar-text); }
  .hnav-link { display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 14px; color: var(--sidebar-text); font-size: 14px; cursor: pointer; list-style: none; white-space: nowrap; }
  .hnav-link::-webkit-details-marker { display: none; }
  .hnav-link .icon { width: 17px; height: 17px; }
  .hnav-link .hnav-caret { width: 14px; height: 14px; }
  .hnav-link:hover, .hnav-group[open] > .hnav-link, .hnav-link.active { color: var(--sb-strong); background: var(--sb-a); text-decoration: none; }
  .hnav-link:focus-visible { outline: 2px solid var(--sb-strong); outline-offset: -2px; }
  .hnav-group { position: relative; }
  .hnav-menu { position: absolute; top: 100%; left: 0; z-index: 35; min-width: 230px; padding: 6px 0; background: var(--surface); border: 1px solid var(--border); border-radius: 0 0 4px 4px; box-shadow: var(--shadow-lg); }
  .hnav-menu a { display: flex; align-items: center; gap: 10px; padding: 9px 18px; color: var(--text-2); font-size: 14px; white-space: nowrap; }
  .hnav-menu a:hover, .hnav-menu a:focus-visible { background: var(--surface-2); color: var(--text); text-decoration: none; }
  .hnav-menu .icon { width: 17px; height: 17px; color: var(--muted); }
  .hnav-account { margin-left: auto; }
  .hnav .abar-switch { position: relative; }
  .hnav .abar-account { margin: 0; padding: 5px 10px; color: var(--sb-strong); background: var(--sb-a); border: 0; border-radius: 4px; }
  .hnav .abar-account .muted, .hnav .abar-label { color: var(--sb-strong); }
  .hnav .abar-account > .icon:first-child { display: none; }
  .hnav .abar-menu { left: auto; right: 0; }
}
@media (max-width: 960px) { .hnav { display: none; } }
@media (min-width: 961px) {
  html[data-frame="semibox"] .sidebar { inset: 12px auto 12px 12px; border-radius: 8px; box-shadow: var(--shadow-lg); }
  html[data-frame="semibox"] .app-main { margin-left: calc(var(--sidebar-w) + 12px); }
  html[data-frame="semibox"][data-layout="horizontal"] .app-main { margin-left: 0; }
  html[data-frame="semibox"] .topbar, html[data-frame="semibox"] .titlebar { margin: 0 12px; }
  html[data-frame="semibox"] .topbar { border-radius: 0 0 8px 8px; }
  html[data-frame="semibox"] .hnav { margin: 0 12px; border-radius: 0 0 8px 8px; }
}

/* ---------- Esqueletos de carregamento: gráficos, mapa de calor e lista do sino enquanto não chegam os dados ---------- */
.skeleton, .chart-box:not(.is-ready)::before, .heatmap:empty::before {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%); background-size: 200% 100%; animation: skeleton-shimmer 1.4s linear infinite;
}
.chart-box:not(.is-ready)::before, .heatmap:empty::before { content: ""; position: absolute; inset: 0; border-radius: 4px; pointer-events: none; }
.heatmap:empty { min-height: 200px; }
.skeleton { display: block; height: 12px; border-radius: 4px; }
.skeleton-rows { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; list-style: none; }
.skeleton-rows .skeleton.short { width: 60%; }
@keyframes skeleton-shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton, .chart-box:not(.is-ready)::before, .heatmap:empty::before { animation: none; } }

/* ---------- Gráfico de preços do instrumento: um só gráfico com compras/vendas, dividendos, resultados e notícias ---------- */
.chart-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.chart-layers { display: flex; flex-wrap: wrap; gap: 6px; }
.layer-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2); font: inherit; font-size: 12px; cursor: pointer; }
.layer-chip b { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 3px; border-radius: 9px; font-size: 10px; font-weight: 800; color: #fff; background: var(--muted); }
.layer-chip:hover { border-color: var(--text-2); }
.layer-chip[aria-pressed="false"] { opacity: .6; background: transparent; }
.layer-chip[aria-pressed="false"] b { background: var(--muted); }
.layer-chip[aria-pressed="true"] { color: var(--text); }
.layer-chip:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.layer-trades[aria-pressed="true"] b { background: var(--pos-text); }
.layer-div[aria-pressed="true"] b { background: var(--primary); }
.layer-paid[aria-pressed="true"] b { background: var(--pos-text); }
.layer-earn[aria-pressed="true"] b { background: var(--warn); }
.layer-news[aria-pressed="true"] b { background: var(--info-strong, #1b6f9e); }
.chart-day-events { margin-top: 10px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-2); font-size: 13px; display: flex; flex-direction: column; gap: 6px; }
.chart-day-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.chart-day-close { width: 28px; height: 28px; font-size: 18px; line-height: 1; }
.chart-day-events .tip-news a { color: var(--link, var(--primary)); }
.timeline-tip .tip-news { max-width: 320px; white-space: normal; }
:root { --info-strong: #1b6f9e; }
:root[data-theme="dark"] { --info-strong: #7cc4ee; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --info-strong: #7cc4ee; } }
:root[data-theme="dark"] .layer-chip b { color: #101522; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .layer-chip b { color: #101522; } }

/* O título do cartão «Account value» leva à página do gráfico */
.stat-label a { color: inherit; text-decoration: none; }
.stat-label a:hover { text-decoration: underline; }

/* ---------- Cartões de números dos dashboards (kpi_card): ícone, título, valor grande, variação e mini-gráfico suave (como os cartões de moedas do Velzon) ---------- */
.kpi { position: relative; display: flex; flex-direction: column; gap: 14px; min-width: 0; padding: 16px 18px; background: var(--surface); border: 1px solid var(--card-line); border-radius: 4px; box-shadow: var(--shadow-card); container-type: inline-size; transition: box-shadow .15s, transform .15s; }
.kpi:hover { box-shadow: 0 4px 14px rgba(56, 65, 74, .14); transform: translateY(-1px); }
.kpi-head { position: static; z-index: 3; display: flex; align-items: center; gap: 10px; min-width: 0; }
.kpi .stat-icon { flex: none; width: 36px; height: 36px; border-radius: 50%; }
.kpi .stat-icon .icon { width: 18px; height: 18px; }
.kpi-label { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; line-height: 1.25; color: var(--muted); }
.kpi-label a { color: inherit; text-decoration: none; }
.kpi-label a:hover { color: var(--text); text-decoration: underline; }
.kpi .tip { position: static; flex: none; margin: 0; }
.kpi .tip::after { top: 58px; left: 12px; right: 12px; width: auto; max-width: none; transform: none; }
.kpi-body { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; min-width: 0; }
.kpi-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kpi-value { font-family: var(--font-head); font-size: 24px; font-weight: 600; line-height: 1.1; letter-spacing: -.01em; color: var(--text); white-space: nowrap; }
.kpi-value.positive { color: var(--pos-text); }
.kpi-value.negative { color: var(--neg-text); }
.kpi-delta { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.kpi-delta small { font-size: 11.5px; font-weight: 500; color: var(--muted); }
.kpi-delta.positive { color: var(--pos-text); }
.kpi-delta.negative { color: var(--neg-text); }
.kpi-delta.positive::before, .kpi-delta.negative::before { content: ""; flex: none; width: 0; height: 0; border-left: 4px solid transparent; border-right: 4px solid transparent; }
.kpi-delta.positive::before { border-bottom: 6px solid currentColor; }
.kpi-delta.negative::before { border-top: 6px solid currentColor; }
.kpi-sub { font-size: 12.5px; color: var(--muted); }
.kpi-spark { flex: none; width: 42%; max-width: 150px; height: 46px; margin-bottom: 2px; overflow: visible; }
@container (max-width: 250px) { .kpi-body { flex-direction: column; align-items: stretch; gap: 8px; } .kpi-spark { width: 100%; max-width: none; height: 36px; margin: 0; } .kpi-value { font-size: 22px; } }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 24px; }
@media (max-width: 700px) { .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } }
.kpi .split-bar { margin-top: 2px; }
@media (prefers-reduced-motion: reduce) { .kpi { transition: none; } .kpi:hover { transform: none; } }
@media (max-width: 700px) { .kpi { padding: 14px; gap: 10px; } .kpi-value { font-size: 20px; } .kpi .stat-icon { width: 30px; height: 30px; } .kpi-head { gap: 8px; } .kpi-label { font-size: 12.5px; } }

/* ---------- Página «Account value»: cabeçalho do gráfico com o valor (que acompanha o cursor) e o período em separadores ---------- */
.segmented a { border-radius: 0; background: var(--accent-soft); color: var(--accent); font-weight: 500; font-size: 13px; padding: 6px 12px; border-right: 1px solid var(--accent); text-decoration: none; white-space: nowrap; }
.segmented a:last-child { border-right: 0; }
.segmented a:hover { color: var(--accent); background: color-mix(in srgb, var(--accent) 20%, var(--surface)); }
.segmented a[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.segmented a:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.av-head { align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.av-hero h2 { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.av-readout { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; }
.av-readout strong { font-family: var(--font-head); font-size: 30px; font-weight: 600; letter-spacing: -.01em; line-height: 1.1; }
.av-panel .account-chart { height: 420px; margin-top: 6px; }
@media (max-width: 700px) { .av-panel .account-chart { height: 300px; } .av-readout strong { font-size: 24px; } .range-tabs { overflow-x: auto; max-width: 100%; } }

/* ---------- Listas públicas do Explore Market (/market/list) ---------- */
.list-links { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; }
.list-links a { font-weight: 600; }
.list-links-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px 24px; }
.list-links li .muted { margin-left: 6px; }

/* ---------- Faixa de preços das páginas públicas (templates/market_ticker.php): as maiores capitalizações, a deslizar devagar ---------- */
.market-ticker { display: flex; align-items: stretch; background: var(--surface); border-bottom: 1px solid var(--border); min-height: 44px; overflow: hidden; }
.mt-label { flex: none; display: flex; align-items: center; padding: 0 16px; font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--primary); background: var(--primary-soft); border-right: 1px solid var(--border); position: relative; z-index: 1; }
.mt-viewport { flex: 1; min-width: 0; overflow: hidden; outline-offset: -2px; mask-image: linear-gradient(90deg, transparent 0, #000 28px, #000 calc(100% - 28px), transparent 100%); }
.mt-track { display: flex; width: max-content; animation: mt-slide var(--mt-seconds, 60s) linear infinite; }
.mt-viewport:hover .mt-track, .mt-viewport:focus-within .mt-track { animation-play-state: paused; }
.mt-list { display: flex; flex: none; margin: 0; padding: 0; list-style: none; }
.mt-list a { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 18px; color: var(--text); text-decoration: none; white-space: nowrap; border-right: 1px solid var(--border); font-size: 13.5px; }
.mt-list a:hover { background: var(--accent-soft); }
.mt-list strong { font-weight: 700; }
.mt-price { color: var(--text-2); font-variant-numeric: tabular-nums; }
.mt-change { font-weight: 600; font-variant-numeric: tabular-nums; }
.mt-change.positive { color: var(--pos-text); }
.mt-change.negative { color: var(--neg-text); }
@keyframes mt-slide { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .mt-viewport { overflow-x: auto; mask-image: none; } .mt-track { animation: none; } .mt-list[aria-hidden="true"] { display: none; } }
@media (max-width: 700px) { .mt-label { padding: 0 10px; font-size: 10.5px; } .mt-list a { padding: 0 14px; font-size: 13px; } }

/* ---------- Dados trancados para quem não tem conta (src/PublicGate.php): valores inventados e desfocados, com um convite ---------- */
.lock-blur { filter: blur(5px); user-select: none; pointer-events: none; }
.score-locked { display: inline-block; }
.lock-link { font-weight: 600; }
.locked-row td, .locked-row th { color: var(--muted); }
.locked-cta-row td { padding: 12px; text-align: center; background: var(--primary-soft); }
.locked-cta-row a { font-weight: 600; text-decoration: none; }
.locked-cta-row a:hover { text-decoration: underline; }
.locked-range { display: inline-flex; align-items: center; gap: 4px; border-radius: 0; background: var(--surface-3); color: var(--muted); font-weight: 500; font-size: 13px; padding: 6px 12px; text-decoration: none; white-space: nowrap; }
.locked-range:hover { color: var(--accent); }
.locked-panel { position: relative; }
.locked-bars { display: flex; flex-direction: column; gap: 14px; margin: 14px 0 6px; }
.locked-bars div { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 12px; }
.locked-bars span { font-size: 13px; color: var(--muted); }
.locked-bars i { display: block; height: 10px; border-radius: 99px; background: var(--primary); opacity: .75; }
.locked-cta { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 14px; margin-top: 8px; padding: 14px; border-radius: 4px; background: var(--primary-soft); text-align: center; }
.locked-cta .icon { width: 20px; height: 20px; color: var(--primary); }

/* ---------- Calendário de eventos: a grelha é desenhada por JavaScript, por isso reserva-se a sua altura (sem isto o resto da página saltava ao carregar) ---------- */
.calendar-events[style*="--cal-weeks"] { min-height: calc(33px + var(--cal-weeks, 5) * 103px); }
[data-cal-title] { min-height: 1.3em; }
.calendar-summary { min-height: 1.4em; }
.agenda-more { margin-top: 14px; }
@media (max-width: 700px) { .calendar-events[style*="--cal-weeks"] { min-height: calc(36px + var(--cal-weeks, 5) * 97px); } }

/* ---------- Página «How the score works» ---------- */
.prose p, .prose ul { max-width: 78ch; line-height: 1.6; }
.prose h2 { margin-bottom: 8px; }
.prose ul { padding-left: 20px; margin: 8px 0 14px; }
.prose li { margin: 4px 0; }
.score-parts th[scope="row"] { white-space: nowrap; font-weight: 600; }
.score-parts td.num { width: 70px; }

/* ---------- Página não encontrada: pesquisa e caminhos para continuar ---------- */
.not-found-search { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 16px auto 4px; max-width: 460px; }
.not-found-search input { flex: 1; min-width: 200px; }
.not-found-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; margin: 14px 0 0; padding: 0; list-style: none; }
.not-found-links a { font-weight: 600; }

/* ---------- Settings: exportar os meus dados ---------- */
.export-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }

/* ---------- Os cartões antigos (.stat-card com ícone) ficam com o desenho dos novos (.kpi): ícone redondo e título em cima, o valor grande por baixo e a variação a seguir.
   Só nas páginas do site (a gestão e as grelhas compactas das páginas de instrumento ficam como estão). ---------- */
body:not(.layout-admin) .stat-grid:not(.stat-grid-compact) .stat-card:has(> .stat-icon) { grid-template-columns: auto minmax(0, 1fr); column-gap: 10px; row-gap: 0; padding: 16px 18px; transition: box-shadow .15s, transform .15s; }
body:not(.layout-admin) .stat-grid:not(.stat-grid-compact) .stat-card:has(> .stat-icon):hover { box-shadow: 0 4px 14px rgba(56, 65, 74, .14); transform: translateY(-1px); }
body:not(.layout-admin) .stat-grid:not(.stat-grid-compact) .stat-card > .stat-icon { grid-row: 1; grid-column: 1; align-self: center; width: 36px; height: 36px; border-radius: 50%; }
body:not(.layout-admin) .stat-grid:not(.stat-grid-compact) .stat-card > .stat-icon .icon { width: 18px; height: 18px; }
body:not(.layout-admin) .stat-grid:not(.stat-grid-compact) .stat-card:has(> .stat-icon) > .stat-label { grid-row: 1; grid-column: 2; align-self: center; padding-right: 0; font-size: 13.5px; font-weight: 600; line-height: 1.25; letter-spacing: 0; text-transform: none; }
body:not(.layout-admin) .stat-grid:not(.stat-grid-compact) .stat-card:has(> .stat-icon) > :not(.stat-icon):not(.stat-label):not(.spark) { grid-column: 1 / -1; }
body:not(.layout-admin) .stat-grid:not(.stat-grid-compact) .stat-card:has(> .stat-icon) .stat-value { margin-top: 14px; font-size: 24px; line-height: 1.1; letter-spacing: -.01em; }
body:not(.layout-admin) .stat-grid:not(.stat-grid-compact) .stat-card:has(> .stat-icon) > .stat-sub { position: static; margin-top: 8px; }
body:not(.layout-admin) .stat-grid:not(.stat-grid-compact) .stat-card:has(> .stat-icon):has(> .spark) { padding-bottom: 44px; }
@media (prefers-reduced-motion: reduce) { body:not(.layout-admin) .stat-grid:not(.stat-grid-compact) .stat-card:has(> .stat-icon) { transition: none; } body:not(.layout-admin) .stat-grid:not(.stat-grid-compact) .stat-card:has(> .stat-icon):hover { transform: none; } }
@media (max-width: 700px) { body:not(.layout-admin) .stat-grid:not(.stat-grid-compact) .stat-card:has(> .stat-icon) > .stat-label { grid-column: 1 / -1; } body:not(.layout-admin) .stat-grid:not(.stat-grid-compact) .stat-card:has(> .stat-icon) .stat-value { font-size: 20px; margin-top: 8px; } }
body:not(.layout-admin) .stat-grid:not(.stat-grid-compact) .stat-card > .stat-icon { display: grid; }      /* o ícone fica ao lado do título (não do valor): cabe mesmo nos cartões estreitos */
@container (max-width: 185px) { body:not(.layout-admin) .stat-grid:not(.stat-grid-compact) .stat-card:has(> .stat-icon) .stat-value { font-size: 20px; } }
@media (max-width: 700px) { body:not(.layout-admin) .stat-grid:not(.stat-grid-compact) .stat-card > .stat-icon { display: none; } }

/* ---------- Primeiros passos (templates/onboarding.php) ---------- */
.onboarding { border-left: 3px solid var(--primary); }
.onb-progress { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin: 4px 0 14px; }
.onb-progress i { display: block; height: 100%; border-radius: 99px; background: var(--pos); }
.onb-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px 20px; margin: 0; padding: 0; list-style: none; }
.onb-steps li { display: flex; gap: 10px; align-items: flex-start; }
.onb-steps li > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.onb-mark { flex: none; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border-strong); color: #fff; }
.onb-steps li.done .onb-mark { background: var(--pos); border-color: var(--pos); }
.onb-mark .icon { width: 14px; height: 14px; }
.onb-steps li.done strong { color: var(--muted); font-weight: 600; text-decoration: line-through; }
.onb-steps a { text-decoration: none; }
.onb-steps a:hover strong { text-decoration: underline; }

/* ---------- Gestão → Status ---------- */
.status-pill { display: inline-block; min-width: 76px; padding: 2px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; text-align: center; }
.status-ok { background: var(--pos-soft); color: var(--pos-text); }
.status-warn { background: var(--warn-soft); color: var(--warn); }
.status-bad { background: var(--neg-soft); color: var(--neg-text); }
.status-info { background: var(--surface-3); color: var(--muted); }
.status-table th[scope="row"] { white-space: nowrap; font-weight: 600; }

/* ---------- Gestão → Proposals: aprovação pelas regras ---------- */
.rules-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 4px 0 14px; padding: 10px 14px; border-radius: 4px; background: var(--primary-soft); }
.rules-bar form { margin: 0; }

/* ---------- Menu: contadores, rodapé com Settings e What's new, separadores de página e barra de baixo no telemóvel ---------- */
.nav-badge { margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 99px; background: var(--pos); color: #fff; font-size: 11.5px; font-weight: 700; line-height: 1.5; text-align: center; }
.sidebar-foot { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--sb-line, rgba(255, 255, 255, .12)); }
.page-tabs { display: flex; gap: 4px; margin: 0 0 18px; }
.page-tabs .tab { padding: 8px 14px; text-decoration: none; }
.bottom-nav { display: none; }
@media (max-width: 700px) {
  .bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom, 0); box-shadow: 0 -2px 10px rgba(56, 65, 74, .08); }
  .bottom-nav a, .bottom-nav button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 7px; border: 0; background: none; color: var(--muted); font: inherit; font-size: 10.5px; font-weight: 600; text-decoration: none; cursor: pointer; min-width: 0; }
  .bottom-nav span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bottom-nav .icon { width: 20px; height: 20px; }
  .bottom-nav a.active { color: var(--accent); }
  .bottom-nav a:focus-visible, .bottom-nav button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
  body.layout-app:not(.layout-admin) .app-main { padding-bottom: calc(62px + env(safe-area-inset-bottom, 0px)); }
}
.nav-badge-bad { background: var(--neg); }

/* ---------- Páginas legais ---------- */
.legal-doc h2 { margin-top: 22px; font-size: 17px; }
.legal-doc h2:first-child { margin-top: 0; }
.legal-links { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 4px 0 24px; }
.auth-legal { text-align: center; margin: 10px 0 0; }
