/* ==========================================================================
   NowoTrade — 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 {
  --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: "Poppins", 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: #fff; }
.sidebar .brand-name span { color: #c9d7ff; }
.sidebar .brand-mark { filter: none; }
.sidebar .sidebar-close { color: #fff; border-color: rgba(255, 255, 255, .25); 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: #fff; }
.sidebar .nav-item.active { background: var(--sidebar-hover); color: #fff; font-weight: 500; box-shadow: inset 3px 0 0 #9db8ff; }
.sidebar .nav-item.active .icon { color: #fff; }
.sidebar .nav-count { background: #f06548; color: #fff; }
.sidebar .pillar-switch { margin: 6px 20px 4px; background: rgba(255, 255, 255, .08); }
.sidebar .pillar-tab { color: var(--sidebar-text); }
.sidebar .pillar-tab:hover { color: #fff; background: transparent; }
.sidebar .pillar-tab.active { background: rgba(255, 255, 255, .16); color: #fff; box-shadow: none; }
.sidebar-nav .nav-item:focus-visible, .sidebar .brand:focus-visible { outline: 2px solid #fff; 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 #9db8ff; }
html.menu-collapsed .sidebar .pillar-switch { margin: 6px 10px; }

/* ---------- 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: -20px -20px 18px; padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.panel > .panel-head { margin-bottom: 18px; }
.panel > h2:first-child, .card > h2:first-child { font-size: 16px; font-weight: 500; color: var(--text-2); }
.panel-head h2, .panel > .panel-head h2 { font-size: 16px; font-weight: 500; color: var(--text-2); margin: 0; }
.modal-body .panel > h2:first-child, .modal-body .panel > .panel-head { margin-left: -20px; margin-right: -20px; }
.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: 13px; font-weight: 500; color: var(--muted); text-transform: none; letter-spacing: 0; }
.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; }
.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; }
.topsearch { flex: 0 1 280px; }
.topbar .account-bar { flex: 1 1 0; 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: 0 0 170px; }
.topsearch-results { width: 360px; right: auto; }
.topbar .abar-item { padding: 2px 10px; }
.topbar .abar-account-text .abar-label { display: none; }
.topbar .abar-account strong { max-width: 130px; }
@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: 150px; }
  .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; }
@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 */
.commodities-ticker .tradingview-widget-copyright a { color: var(--muted) !important; }
.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: #fff; }
.sidebar .nav-group:focus-visible { outline: 2px solid #fff; 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 rgba(255, 255, 255, .1); 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; }
