/**
 * Nivvo — Design System v2
 * Refined warm palette, vibrancy surfaces, premium typography.
 * Backward-compatible with existing class names: .nv-card, .nv-btn-*, .nv-table, .nv-badge-*, .nv-nav-*
 */

/* ── Font imports (auto-loaded for every page that links this CSS) ───────── */
@import url("https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,GRAD@20..48,300..700,0..1,-25..200&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&display=swap");

/* ── CSS Design Tokens ───────────────────────────────────────────────────── */
:root {
  /* Apple system colors (kept for backward compat) */
  --apple-blue:    #0F6FE0;
  --apple-blue-lt: #2F86F0;
  --apple-green:   #15B886;
  --apple-red:     #F46B5D;
  --apple-orange:  #E8A957;
  --apple-purple:  #8B7CF6;
  --apple-gray:    #9D9DA5;

  /* Warm-Mac surfaces (Copilot-inspired) */
  --bg:            #F4F2EE;
  --bg-elev:       #FBFAF7;
  --surface:       #FFFFFF;
  --surface-2:     #F7F5F1;
  --surface-3:     #EFEDE7;
  --surface-4:     #E5E2D9;

  /* Text */
  --text-1:        #15151A;
  --text-2:        #6A6A72;
  --text-3:        #9D9DA5;
  --text-soft:     #BDBDC4;

  /* Hairlines & focus */
  --hairline:        rgba(20, 20, 25, 0.07);
  --hairline-strong: rgba(20, 20, 25, 0.13);
  --vibrancy:        rgba(255, 255, 255, 0.62);
  --card-border:     rgba(20, 20, 25, 0.07);

  /* Brand accent */
  --accent:        #0F6FE0;
  --accent-2:      #2F86F0;
  --accent-soft:   rgba(15, 111, 224, 0.10);
  --accent-ring:   rgba(15, 111, 224, 0.22);

  /* Semantic accents */
  --pos:           #15B886;
  --pos-soft:      rgba(21, 184, 134, 0.10);
  --neg:           #F46B5D;
  --neg-soft:      rgba(244, 107, 93, 0.10);
  --warn:          #E8A957;
  --warn-soft:     rgba(232, 169, 87, 0.14);
  --inv:           #8B7CF6;
  --inv-soft:      rgba(139, 124, 246, 0.12);

  /* Categories */
  --cat-food:      #F46B5D;
  --cat-transport: #0F6FE0;
  --cat-home:      #8B7CF6;
  --cat-health:    #15B886;
  --cat-leisure:   #E8A957;
  --cat-shopping:  #E961A8;
  --cat-services:  #5BC0EB;
  --cat-other:     #9D9DA5;

  /* Backward compat aliases used elsewhere */
  --sep:           var(--hairline);
  --sep-strong:    var(--hairline-strong);
  --surface-w:     var(--surface);
  --focus-ring:    var(--accent-ring);
  --focus-outline: #1b6dd8;

  /* Radii */
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  /* Elevation */
  --shadow-1: 0 1px 0 rgba(255,255,255,0.7) inset, 0 1px 2px rgba(20,20,25,0.04), 0 8px 24px rgba(20,20,25,0.05);
  --shadow-2: 0 1px 0 rgba(255,255,255,0.85) inset, 0 2px 6px rgba(20,20,25,0.05), 0 18px 50px rgba(20,20,25,0.08);
  --shadow-pop:0 1px 0 rgba(255,255,255,0.85) inset, 0 12px 36px rgba(15, 111, 224, 0.18);
  --shadow-soft:   var(--shadow-1);
  --shadow-strong: 0 10px 28px rgba(15, 111, 224, 0.18);

  --traffic-red:    #FF5F57;
  --traffic-amber:  #FEBC2E;
  --traffic-green:  #28C840;
}

/* ── Body / Shell ────────────────────────────────────────────────────────── */
body.app-macos-shell {
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--text-1);
  letter-spacing: -0.005em;
  font-feature-settings: "ss01", "cv11", "cv02";
}

/* Background ambient gradients on main */
#app-shell-main {
  background:
    radial-gradient(900px 480px at 16% -8%, rgba(15, 111, 224, 0.10), transparent 60%),
    radial-gradient(720px 420px at 100% 4%, rgba(232, 169, 87, 0.10), transparent 60%),
    radial-gradient(900px 600px at 50% 100%, rgba(139, 124, 246, 0.06), transparent 60%),
    var(--bg);
  min-height: 100vh;
}

/* ── Sidebar (vibrancy) ─────────────────────────────────────────────────── */
#app-sidebar {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.55) 0%, rgba(255,255,255,0.22) 100%),
    var(--bg);
  border-right: 1px solid var(--hairline);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  backdrop-filter: blur(40px) saturate(180%);
  box-shadow:
    inset -1px 0 0 var(--hairline),
    12px 0 36px rgba(15, 23, 42, 0.04);
}

/* Brand mark (sidebar) */
.nv-brand-mark {
  width: 28px; height: 28px; border-radius: 9px;
  background: conic-gradient(from 200deg, #0F6FE0, #8B7CF6, #15B886, #E8A957, #0F6FE0);
  box-shadow: 0 6px 16px rgba(15, 111, 224, 0.32), inset 0 0 0 1px rgba(255,255,255,0.4);
  position: relative; flex-shrink: 0;
}
.nv-brand-mark::after {
  content: "N"; position: absolute; inset: 0; display: grid; place-items: center;
  color: white; font-weight: 800; font-size: 14px; letter-spacing: -0.04em;
  text-shadow: 0 1px 2px rgba(0,0,0,0.18);
}

/* Traffic lights */
.nv-traffic { display: inline-flex; gap: 8px; align-items: center; padding: 4px 10px 12px; }
.nv-traffic .dot { width: 12px; height: 12px; border-radius: 999px; box-shadow: inset 0 0 0 0.5px rgba(0,0,0,0.18); }
.nv-traffic .dot.red    { background: var(--traffic-red); }
.nv-traffic .dot.amber  { background: var(--traffic-amber); }
.nv-traffic .dot.green  { background: var(--traffic-green); }

/* Command bar (⌘K) */
.nv-cmd {
  display: flex; align-items: center; gap: 8px;
  margin: 0 4px 12px; padding: 7px 10px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.7) inset, 0 1px 1px rgba(20,20,25,0.04);
  color: var(--text-2); font-size: 13px;
}
.nv-cmd .icon, .nv-cmd .material-symbols-rounded, .nv-cmd .material-symbols-outlined { color: var(--text-3); font-size: 16px; }
.nv-cmd input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: var(--text-1); font-size: 13px; }
.nv-kbd { display: inline-flex; gap: 2px; font-size: 10.5px; color: var(--text-3); }
.nv-kbd > span {
  display: inline-grid; place-items: center;
  min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 5px; background: var(--surface-2);
  border: 1px solid var(--hairline);
  box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset;
  font-weight: 600;
}

/* Sidebar nav links (legacy class .sidebar-nav-link kept) */
#app-sidebar .sidebar-nav-link {
  color: var(--text-2);
  border-radius: 10px;
  transition: background 120ms ease, color 120ms ease;
  border: 1px solid transparent;
  letter-spacing: -0.005em;
}
#app-sidebar .sidebar-nav-link .material-symbols-outlined,
#app-sidebar .sidebar-nav-link .material-symbols-rounded {
  color: var(--text-3); transition: color 120ms ease;
}
#app-sidebar .sidebar-nav-link:not(.nv-nav-active):hover {
  background: rgba(20,20,25,0.05);
  color: var(--text-1);
}
#app-sidebar .sidebar-nav-link:not(.nv-nav-active):hover .material-symbols-outlined,
#app-sidebar .sidebar-nav-link:not(.nv-nav-active):hover .material-symbols-rounded {
  color: var(--text-1);
}
#app-sidebar .sidebar-nav-link.nv-nav-active {
  background: linear-gradient(180deg, rgba(15,111,224,0.12), rgba(15,111,224,0.06));
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(15,111,224,0.16);
  font-weight: 600;
}
#app-sidebar .sidebar-nav-link.nv-nav-active .material-symbols-outlined,
#app-sidebar .sidebar-nav-link.nv-nav-active .material-symbols-rounded {
  color: var(--accent);
  font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 24;
}
#app-sidebar .sidebar-nav-link.relative::before { display: none !important; }

/* Sidebar sections */
.sidebar-group { display: block; }
.sidebar-group--static .sidebar-group-body { margin-bottom: 2px; }
.sidebar-section-label {
  display: block;
  padding: 10px 10px 4px;
  margin: 0;
}
.sidebar-group:first-of-type .sidebar-section-label {
  padding-top: 4px;
}
.sidebar-group--collapsible .sidebar-group-header {
  padding-top: 12px;
}
.sidebar-group--collapsible:first-of-type .sidebar-group-header {
  padding-top: 6px;
}

/* Seção separada visualmente (ex.: "Sistema" no fim do nav) */
.sidebar-group--separated {
  margin-top: 8px;
  padding-top: 4px;
  border-top: 1px solid var(--hairline);
}
.sidebar-group--separated .sidebar-section-label {
  padding-top: 8px;
  color: var(--text-3);
  opacity: 0.85;
}

/* Footer do sidebar (perfil + sair) */
#sidebar-footer { padding-bottom: 4px; }
#sidebar-profile-card { cursor: default; }
[data-collapsed="1"] #sidebar-footer { padding-top: 6px; }

/* Assistente / busca no sidebar */
.sidebar-cmd { cursor: pointer; }
.sidebar-cmd-kbd {
  display: inline-flex;
  gap: 2px;
  flex-shrink: 0;
  font-size: 10px;
  color: var(--text-3);
}
.sidebar-cmd-kbd > span {
  display: inline-grid;
  place-items: center;
  min-width: 17px;
  height: 17px;
  padding: 0 3px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  font-weight: 600;
}
.sidebar-cmd--icon-only {
  width: auto !important;
  min-width: 0;
  padding-left: 0.5rem !important;
  padding-right: 0.5rem !important;
}
html.dark .sidebar-cmd-kbd > span { background: var(--surface-3); }

.sidebar-group-header {
  display: flex; align-items: center; gap: 6px;
  width: 100%;
  padding: 14px 8px 6px 8px;
  background: transparent; border: 0; cursor: pointer;
  text-align: left;
  border-radius: 6px;
  transition: background 120ms ease;
}
.sidebar-group-header:hover { background: rgba(20,20,25,0.04); }
html.dark .sidebar-group-header:hover { background: rgba(255,255,255,0.04); }
.sidebar-group-header[disabled] { opacity: 1; }
.sidebar-group-header[disabled]:hover { background: transparent; }

/* Sidebar submenu */
.sidebar-submenu {
  display: block;
  margin-top: 2px;
  margin-bottom: 4px;
}
.sidebar-submenu-toggle {
  width: 22px; height: 28px;
  display: grid; place-items: center;
  background: transparent; border: 0; cursor: pointer;
  color: var(--text-3);
  border-radius: 6px;
  transition: background 120ms ease, color 120ms ease;
}
.sidebar-submenu-toggle:hover { background: rgba(20,20,25,0.06); color: var(--text-1); }
html.dark .sidebar-submenu-toggle:hover { background: rgba(255,255,255,0.06); }

/* Sidebar fav toggle */
.sidebar-fav-toggle {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 5px;
  background: transparent; border: 0; cursor: pointer;
  color: var(--text-3);
  opacity: 0;
  transition: opacity 120ms ease, color 120ms ease, background 120ms ease;
  flex-shrink: 0;
}
.sidebar-link-wrap:hover .sidebar-fav-toggle { opacity: 1; }
.sidebar-fav-toggle:hover { color: var(--warn); background: rgba(232,169,87,0.14); }

/* Show filled star when already favorited */
.sidebar-fav-toggle .material-symbols-rounded { font-size: 15px; }
.sidebar-link-wrap .sidebar-fav-toggle:has(.material-symbols-rounded:contains("star")) { opacity: 1; color: var(--warn); }

/* Side badge (counts) */
.nv-side-badge {
  display: inline-flex; align-items: center;
  font-size: 10.5px; font-weight: 700;
  padding: 1px 7px; min-width: 16px; height: 16px; justify-content: center;
  border-radius: 999px;
  background: var(--surface-3); color: var(--text-2);
  flex-shrink: 0;
}
#app-sidebar .sidebar-nav-link.nv-nav-active .nv-side-badge {
  background: rgba(15,111,224,0.20); color: var(--accent);
}

/* ── Selo de licença no rodapé da sidebar ──────────────────────────────── */
.nv-license-badge {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 700;
  padding: 1px 8px; height: 18px;
  border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  flex-shrink: 0; letter-spacing: 0.01em;
}
.nv-license-badge[data-tone="pos"]  { background: var(--pos-soft);  color: var(--pos); }
.nv-license-badge[data-tone="warn"] { background: var(--warn-soft); color: var(--warn); }
.nv-license-badge[data-tone="neg"]  { background: var(--neg-soft);  color: var(--neg); }
#sidebar-license:hover { background: var(--surface-3) !important; }

/* ── Barra de progresso de navegação (topo) ────────────────────────────── */
#nv-nav-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  z-index: 99999; opacity: 0; pointer-events: none;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 8px rgba(15,111,224,0.5);
}

/* ── Fade-in suave do conteúdo principal ───────────────────────────────── */
@keyframes nv-fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
#app-shell-main { animation: nv-fade-in 0.18s ease-out; }

/* ── Foco acessível ────────────────────────────────────────────────────── */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--focus-outline);
  outline-offset: 2px;
  border-radius: 6px;
}
@media (prefers-reduced-motion: reduce) {
  #app-shell-main { animation: none; }
  #nv-nav-progress { display: none; }
}

/* ── Skeletons (placeholders de carregamento) ──────────────────────────── */
.nv-skeleton {
  position: relative; overflow: hidden;
  background: var(--surface-3);
  border-radius: 8px;
}
.nv-skeleton::after {
  content: ""; position: absolute; inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.55), transparent);
  animation: nv-shimmer 1.2s infinite;
}
.nv-skeleton-text { height: 12px; margin: 6px 0; }
.nv-skeleton-card { height: 120px; border-radius: var(--radius-md); }
@keyframes nv-shimmer { 100% { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .nv-skeleton::after { animation: none; } }

/* ── Category Filter (multi-select popover) ─────────────────────────────── */
.nv-catfilter-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 11px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-1);
  color: var(--text-1);
  font-size: 13px; font-weight: 600; letter-spacing: -0.005em;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, box-shadow 120ms;
}
.nv-catfilter-btn:hover { background: var(--surface-2); }
.nv-catfilter-btn.active {
  border-color: var(--accent-ring);
  background: var(--accent-soft);
  color: var(--accent);
}
.nv-catfilter-btn.active .material-symbols-rounded { color: var(--accent) !important; }
.nv-catfilter-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px;
  background: var(--accent); color: white;
  font-size: 10.5px; font-weight: 800;
  letter-spacing: 0;
}

.nv-catfilter-popover {
  position: fixed; z-index: 80;
  width: 360px; max-height: 480px;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  box-shadow: var(--shadow-2);
  overflow: hidden;
  animation: nv-popover-in 180ms cubic-bezier(0.2, 0.7, 0.2, 1);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
}
.nv-catfilter-popover.hidden { display: none; }
@keyframes nv-popover-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

.nv-catfilter-head {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--hairline);
}
.nv-catfilter-search {
  display: flex; align-items: center; gap: 8px;
  margin-top: 10px;
  padding: 7px 10px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 9px;
}
.nv-catfilter-search input {
  flex: 1; min-width: 0;
  background: transparent !important;
  border: 0 !important;
  outline: 0 !important;
  font-size: 13px; color: var(--text-1);
  padding: 0 !important;
}
.nv-catfilter-search input::placeholder { color: var(--text-3); }

.nv-catfilter-tabs {
  display: flex; gap: 4px;
  padding: 8px 14px 0;
}
.nv-catfilter-tabs button {
  padding: 5px 12px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid transparent;
  font-size: 12px; font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: background 120ms, border-color 120ms, color 120ms;
}
.nv-catfilter-tabs button:hover { background: var(--surface-2); color: var(--text-1); }
.nv-catfilter-tabs button.on {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent-ring);
}

.nv-catfilter-actions {
  display: flex; gap: 4px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--hairline);
}
.nv-catfilter-actions button {
  padding: 3px 8px;
  border-radius: 7px;
  background: transparent;
  border: 0;
  font-size: 11px; font-weight: 600;
  color: var(--text-3);
  cursor: pointer;
  transition: background 120ms, color 120ms;
}
.nv-catfilter-actions button:hover { background: var(--surface-2); color: var(--text-1); }

.nv-catfilter-list {
  flex: 1; overflow-y: auto;
  padding: 6px 8px;
  outline: none;
}
.nv-catfilter-group + .nv-catfilter-group { margin-top: 8px; }
.nv-catfilter-group-label {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 8px 4px;
  font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-3);
  user-select: none;
}
.nv-catfilter-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 100ms;
  user-select: none;
}
.nv-catfilter-row:hover { background: var(--surface-2); }
.nv-catfilter-row.on { background: rgba(15,111,224,0.04); }

.nv-catfilter-check {
  width: 18px; height: 18px; border-radius: 5px;
  background: var(--surface);
  border: 1.5px solid var(--hairline-strong);
  display: grid; place-items: center;
  flex-shrink: 0;
  transition: background 120ms, border-color 120ms;
}
.nv-catfilter-check.on {
  background: var(--accent);
  border-color: var(--accent);
}
.nv-catfilter-swatch {
  width: 10px; height: 10px; border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.06);
  flex-shrink: 0;
}
.nv-catfilter-name {
  flex: 1; min-width: 0;
  font-size: 13px; font-weight: 500; color: var(--text-1);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  letter-spacing: -0.005em;
}

.nv-catfilter-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-3); font-size: 12.5px;
  display: flex; flex-direction: column; align-items: center;
}
.nv-catfilter-empty p { margin: 0; }

.nv-catfilter-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--hairline);
  background: var(--surface-2);
}
.nv-catfilter-summary {
  font-size: 11.5px; color: var(--text-2); font-weight: 500;
}

/* Assistente Nivvo modal */
.nv-assistant-modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh;
}
.nv-assistant-modal.hidden { display: none; }
.nv-assistant-backdrop {
  position: absolute; inset: 0;
  background: rgba(20, 20, 25, 0.45);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.nv-assistant-panel {
  position: relative; z-index: 1;
  width: min(720px, 90vw);
  max-height: 70vh;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 18px;
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.nv-assistant-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--hairline);
}
.nv-assistant-body {
  flex: 1; overflow-y: auto;
  padding: 18px;
}
.nv-assistant-welcome p { margin: 0; }
.nv-assistant-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 12px;
}
.nv-assistant-chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  color: var(--text-1);
  font-size: 12px; font-weight: 500;
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
}
.nv-assistant-chip:hover { background: var(--accent-soft); border-color: var(--accent-ring); color: var(--accent); }
.nv-assist-msg { display: flex; margin-top: 12px; }
.nv-assist-msg.user { justify-content: flex-end; }
.nv-assist-msg.assistant { justify-content: flex-start; }
.nv-assist-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px; line-height: 1.5; color: var(--text-1);
  background: var(--surface-2);
}
.nv-assist-bubble.user {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: white;
}
.nv-assist-bubble.user p { margin: 0; }
.nv-assist-bubble p { margin: 0; }
.nv-assist-bubble p + p { margin-top: 6px; }
.nv-assist-thinking {
  display: inline-flex; gap: 4px;
}
.nv-assist-thinking span {
  width: 6px; height: 6px; border-radius: 999px;
  background: var(--text-3);
  animation: nv-bounce 1.2s ease-in-out infinite;
}
.nv-assist-thinking span:nth-child(2) { animation-delay: 0.15s; }
.nv-assist-thinking span:nth-child(3) { animation-delay: 0.3s; }
@keyframes nv-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}
.nv-assistant-input-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--hairline);
  background: var(--surface-2);
}
.nv-assistant-input-row input {
  flex: 1; min-width: 0;
  background: transparent !important;
  border: 0 !important;
  color: var(--text-1) !important;
  font-size: 13.5px;
  padding: 6px 0 !important;
}
.nv-assistant-input-row input:focus { outline: 0 !important; box-shadow: none !important; }

/* Notifications popover */
.nv-bell-popover {
  position: fixed; z-index: 60;
  width: 360px; max-height: 480px;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  box-shadow: var(--shadow-2);
  overflow: hidden;
}
.nv-bell-popover.hidden { display: none; }
.nv-bell-head {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--hairline);
}
.nv-bell-head > div { flex: 1; min-width: 0; }
.nv-bell-list {
  flex: 1; overflow-y: auto;
  padding: 6px;
}
.nv-bell-item {
  display: grid; grid-template-columns: 32px 1fr; gap: 10px;
  padding: 10px;
  border-radius: 9px;
  text-decoration: none;
  transition: background 120ms ease;
}
.nv-bell-item:hover { background: var(--surface-2); }
.nv-bell-item.unread { background: var(--accent-soft); }
.nv-bell-item.unread:hover { background: rgba(15,111,224,0.16); }
.nv-bell-empty {
  padding: 32px 16px;
  text-align: center;
}

/* Sidebar profile card */
#sidebar-profile-card {
  background: transparent;
  border: 0;
  box-shadow: none;
  border-radius: 10px;
}

/* ── Header / Toolbar ────────────────────────────────────────────────────── */
#app-shell-header {
  background: var(--vibrancy);
  border-bottom: 1px solid var(--hairline);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  backdrop-filter: blur(28px) saturate(180%);
  box-shadow: 0 1px 0 var(--hairline);
}

/* Crumbs (used by .toolbar-crumbs) */
.nv-crumbs { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 13px; min-width: 0; }
.nv-crumbs b { color: var(--text-1); font-weight: 600; letter-spacing: -0.01em; }
.nv-crumbs .material-symbols-outlined,
.nv-crumbs .material-symbols-rounded { font-size: 16px; color: var(--text-3); }

/* Month pill */
.nv-month-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 6px 5px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-1);
  font-size: 12.5px; font-weight: 600;
  color: var(--text-1);
}
.nv-month-pill button {
  width: 22px; height: 22px; border-radius: 999px;
  display: grid; place-items: center;
  color: var(--text-2);
  background: transparent; border: 0; cursor: pointer;
}
.nv-month-pill button:hover { background: var(--surface-2); color: var(--text-1); }
.nv-month-pill .nv-today {
  padding: 2px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
}

/* Toolbar global search */
.nv-toolbar-search {
  flex: 1 1 auto;
  display: flex; align-items: center; gap: 8px;
  max-width: 460px;
  margin: 0 auto;
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  box-shadow: var(--shadow-1);
  color: var(--text-2);
  font-size: 13px;
  transition: border-color 120ms, box-shadow 120ms;
}
.nv-toolbar-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-ring);
}
.nv-toolbar-search > .material-symbols-rounded,
.nv-toolbar-search > .material-symbols-outlined {
  color: var(--text-3); font-size: 16px;
}
.nv-toolbar-search input {
  flex: 1; min-width: 0;
  background: transparent; border: 0; outline: 0;
  color: var(--text-1); font-size: 13px;
  padding: 0;
}
.nv-toolbar-search input::placeholder { color: var(--text-3); }

/* Toolbar small icon button */
.nv-tb-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 9px;
  color: var(--text-2);
  transition: background 120ms, color 120ms, box-shadow 120ms;
  position: relative;
  background: transparent; border: 0; cursor: pointer;
}
.nv-tb-btn:hover { background: var(--surface); color: var(--text-1); box-shadow: var(--shadow-1); }
.nv-tb-btn .dotnot {
  position: absolute; top: 7px; right: 7px;
  width: 7px; height: 7px; border-radius: 999px; background: var(--neg);
  box-shadow: 0 0 0 2px var(--vibrancy);
}

/* Toolbar avatar */
.nv-tb-avatar {
  width: 30px; height: 30px; border-radius: 999px;
  background: linear-gradient(135deg, #FBC97A, #F46B5D 60%, #8B7CF6);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.35);
  display: grid; place-items: center; color: white; font-weight: 700; font-size: 12px;
}

/* Theme toggle */
.nv-theme-toggle {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--hairline);
}
.nv-theme-toggle button {
  width: 26px; height: 26px; border-radius: 999px;
  display: grid; place-items: center; color: var(--text-3);
  background: transparent; border: 0; cursor: pointer;
}
.nv-theme-toggle button.on {
  background: var(--surface); color: var(--text-1); box-shadow: var(--shadow-1);
}

/* ── Hero ────────────────────────────────────────────────────────────────── */
body.app-macos-shell .nv-home-hero,
.nv-hero {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 24px;
  align-items: center;
  padding: clamp(1.5rem, 2.4vw, 1.9rem);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(640px 320px at 8% 0%, rgba(15,111,224,0.10), transparent 70%),
    radial-gradient(560px 320px at 100% 100%, rgba(21,184,134,0.09), transparent 65%),
    var(--surface);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-2);
  position: relative;
  overflow: hidden;
}

/* Display & numerics */
.nv-display {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", system-ui, sans-serif;
  letter-spacing: -0.025em;
}
.nv-num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1, "ss01" 1; letter-spacing: -0.01em; }
.nv-serif { font-family: "Instrument Serif", "Times New Roman", serif; font-style: italic; letter-spacing: 0; }
.nv-micro {
  font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--text-3);
}

/* Eyebrow & pulse */
.nv-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11.5px; font-weight: 700;
  letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--text-3);
}
.nv-pulse {
  width: 7px; height: 7px; border-radius: 999px; background: var(--pos);
  box-shadow: 0 0 0 4px var(--pos-soft);
}

/* Delta chip */
.nv-delta {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px 6px 8px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700;
  background: var(--pos-soft); color: var(--pos);
}
.nv-delta .material-symbols-outlined,
.nv-delta .material-symbols-rounded { font-size: 16px; }
.nv-delta.neg { background: var(--neg-soft); color: var(--neg); }
.nv-delta.warn { background: var(--warn-soft); color: var(--warn); }

/* Chip */
.nv-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px; border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  font-size: 12px; color: var(--text-2); font-weight: 500;
}
.nv-chip .swatch { width: 8px; height: 8px; border-radius: 3px; }
.nv-chip b { color: var(--text-1); font-weight: 700; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.nv-card {
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}
.nv-card.elevated { box-shadow: var(--shadow-2); }
.nv-card.flat { box-shadow: none; background: var(--surface-2); }

/* Tailwind compat — restyle existing rounded-2xl cards too */
.rounded-xl.bg-surface-container-lowest,
.rounded-2xl.bg-surface-container-lowest {
  border: 1px solid var(--card-border) !important;
  box-shadow: var(--shadow-1) !important;
  border-radius: var(--radius-lg) !important;
}

.nv-card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.nv-card-title { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; color: var(--text-1); }
.nv-card-sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; font-weight: 500; }
.nv-card-link {
  font-size: 12px; font-weight: 600; color: var(--accent);
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 8px; border-radius: 8px;
  transition: background 120ms;
}
.nv-card-link:hover { background: var(--accent-soft); }
.nv-card-link .material-symbols-outlined,
.nv-card-link .material-symbols-rounded { font-size: 14px; }

/* KPI cards */
.nv-kpi {
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.nv-kpi:hover { transform: translateY(-1px); box-shadow: var(--shadow-2); }
.nv-kpi .nv-kpi-row { display: flex; justify-content: space-between; align-items: center; }
.nv-kpi .nv-kpi-label { font-size: 11.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-3); }
.nv-kpi .nv-kpi-value { font-size: 24px; font-weight: 800; letter-spacing: -0.025em; margin-top: 6px; color: var(--text-1); }
.nv-kpi .nv-kpi-trend { font-size: 11.5px; font-weight: 600; }
.nv-kpi .nv-kpi-trend.pos { color: var(--pos); }
.nv-kpi .nv-kpi-trend.neg { color: var(--neg); }
.nv-kpi .nv-kpi-iconbox {
  width: 26px; height: 26px; border-radius: 8px;
  display: grid; place-items: center;
}
.nv-kpi.pos .nv-kpi-iconbox { background: var(--pos-soft); color: var(--pos); }
.nv-kpi.neg .nv-kpi-iconbox { background: var(--neg-soft); color: var(--neg); }
.nv-kpi.bal .nv-kpi-iconbox { background: var(--accent-soft); color: var(--accent); }
.nv-kpi.inv .nv-kpi-iconbox { background: var(--inv-soft); color: var(--inv); }
.nv-kpi.warn .nv-kpi-iconbox { background: var(--warn-soft); color: var(--warn); }

/* Segmented control */
.nv-seg {
  display: inline-flex; padding: 3px;
  background: var(--surface-2); border: 1px solid var(--hairline);
  border-radius: 9px;
}
.nv-seg button {
  padding: 4px 10px; border-radius: 7px;
  font-size: 11.5px; font-weight: 600; color: var(--text-2);
  background: transparent; border: 0; cursor: pointer;
}
.nv-seg button.on { background: var(--surface); color: var(--text-1); box-shadow: var(--shadow-1); }

/* Legend */
.nv-legend { display: flex; gap: 14px; align-items: center; font-size: 12px; color: var(--text-2); font-weight: 500; flex-wrap: wrap; }
.nv-legend .item { display: inline-flex; align-items: center; gap: 6px; }
.nv-legend .swatch { width: 10px; height: 10px; border-radius: 3px; }

/* Icon tile (small) */
.nv-icon-tile {
  width: 28px; height: 28px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
}
.nv-icon-tile.pos { background: var(--pos-soft); color: var(--pos); }
.nv-icon-tile.neg { background: var(--neg-soft); color: var(--neg); }
.nv-icon-tile.warn { background: var(--warn-soft); color: var(--warn); }
.nv-icon-tile.inv { background: var(--inv-soft); color: var(--inv); }
.nv-icon-tile .material-symbols-outlined,
.nv-icon-tile .material-symbols-rounded { font-size: 16px; }

/* Tag/Badge */
.nv-badge-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700;
  background: var(--surface-3); color: var(--text-2);
}
.nv-badge-tag .material-symbols-outlined,
.nv-badge-tag .material-symbols-rounded { font-size: 12px; }
.nv-badge-ai {
  background: linear-gradient(180deg, rgba(139,124,246,0.20), rgba(15,111,224,0.18));
  color: var(--accent); border: 1px solid var(--accent-soft);
}

/* Transactions list */
.nv-tx-list { display: flex; flex-direction: column; }
.nv-tx {
  display: grid;
  grid-template-columns: 36px 1fr auto auto;
  gap: 12px; align-items: center;
  padding: 10px 6px; border-radius: 10px;
  transition: background 120ms;
}
.nv-tx:hover { background: var(--surface-2); }
.nv-tx + .nv-tx { border-top: 1px solid var(--hairline); }
.nv-tx-tile {
  width: 36px; height: 36px; border-radius: 11px;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-1);
}
.nv-tx-tile.tg-food   { background: rgba(244,107,93,0.14);  color: var(--cat-food); }
.nv-tx-tile.tg-tr     { background: rgba(15,111,224,0.12);  color: var(--cat-transport); }
.nv-tx-tile.tg-home   { background: rgba(139,124,246,0.14); color: var(--cat-home); }
.nv-tx-tile.tg-health { background: rgba(21,184,134,0.14);  color: var(--cat-health); }
.nv-tx-tile.tg-leisure{ background: rgba(232,169,87,0.16);  color: var(--cat-leisure); }
.nv-tx-tile.tg-shop   { background: rgba(233,97,168,0.14);  color: var(--cat-shopping); }
.nv-tx-tile.tg-svc    { background: rgba(91,192,235,0.16);  color: var(--cat-services); }
.nv-tx-tile.tg-income { background: var(--pos-soft);        color: var(--pos); }
.nv-tx-tile .material-symbols-outlined,
.nv-tx-tile .material-symbols-rounded { font-size: 19px; }
.nv-tx .label { font-size: 13.5px; font-weight: 600; letter-spacing: -0.005em; color: var(--text-1); }
.nv-tx .meta-row { font-size: 11.5px; color: var(--text-3); margin-top: 2px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.nv-tx .dotsep { width: 3px; height: 3px; border-radius: 999px; background: var(--text-soft); }
.nv-tx .amt { font-size: 13.5px; font-weight: 700; text-align: right; }
.nv-tx .amt.neg { color: var(--text-1); }
.nv-tx .amt.pos { color: var(--pos); }
.nv-tx .when { font-size: 11.5px; color: var(--text-3); width: 48px; text-align: right; }

/* Goal row */
.nv-goal {
  display: grid; grid-template-columns: 56px 1fr auto;
  gap: 14px; align-items: center;
  padding: 10px 4px;
}
.nv-goal + .nv-goal { border-top: 1px dashed var(--hairline); }
.nv-goal .info .nm { font-size: 13.5px; font-weight: 700; letter-spacing: -0.005em; color: var(--text-1); }
.nv-goal .info .sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.nv-goal .right { text-align: right; }
.nv-goal .right .pct { font-size: 12.5px; font-weight: 700; color: var(--text-1); }
.nv-goal .right .left { font-size: 11px; color: var(--text-3); }

/* Investment row */
.nv-inv-row {
  display: grid; grid-template-columns: 36px 1fr 84px auto;
  gap: 12px; align-items: center;
  padding: 10px 4px;
}
.nv-inv-row + .nv-inv-row { border-top: 1px dashed var(--hairline); }
.nv-inv-row .nm { font-size: 13.5px; font-weight: 600; color: var(--text-1); }
.nv-inv-row .sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.nv-inv-row .v { font-size: 13.5px; font-weight: 700; text-align: right; color: var(--text-1); }
.nv-inv-row .d { font-size: 11.5px; font-weight: 700; }
.nv-inv-row .d.pos { color: var(--pos); }
.nv-inv-row .d.neg { color: var(--neg); }

/* Category row */
.nv-cat-row {
  display: grid; grid-template-columns: 14px 1fr auto;
  gap: 10px; align-items: center;
  padding: 6px 0;
}
.nv-cat-row + .nv-cat-row { border-top: 1px dashed var(--hairline); }
.nv-cat-row .swatch { width: 12px; height: 12px; border-radius: 4px; }
.nv-cat-row .name { font-size: 13px; font-weight: 600; color: var(--text-1); }
.nv-cat-row .pct { font-size: 11.5px; color: var(--text-3); margin-left: 6px; }
.nv-cat-row .val { font-size: 13px; font-weight: 700; color: var(--text-1); }

/* AI Insights card */
.nv-ai {
  padding: 22px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--hairline);
  background:
    radial-gradient(380px 200px at 0% 0%, rgba(139,124,246,0.16), transparent 70%),
    radial-gradient(420px 240px at 100% 100%, rgba(15,111,224,0.10), transparent 70%),
    var(--surface);
  box-shadow: var(--shadow-1);
  position: relative;
  overflow: hidden;
}
.nv-ai-icon {
  width: 30px; height: 30px; border-radius: 10px;
  background: linear-gradient(135deg, var(--inv), var(--accent));
  display: grid; place-items: center;
  color: white; box-shadow: 0 6px 18px rgba(139,124,246,0.36);
}
.nv-ai-icon .material-symbols-outlined,
.nv-ai-icon .material-symbols-rounded { font-size: 17px; }
.nv-ai-bullet {
  display: grid; grid-template-columns: 22px 1fr; gap: 10px;
  padding: 10px 12px; border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--hairline);
}
.nv-ai-bullet .num-pill {
  width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center;
  font-size: 11px; font-weight: 800; color: var(--accent);
  background: var(--accent-soft);
}

/* Mini calendar card (home dashboard) */
.hc-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
  margin-bottom: 6px;
}
.hc-weekdays div {
  text-align: center;
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-3);
}
.hc-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.hc-cell {
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 600; color: var(--text-2);
  transition: transform 100ms ease;
  font-variant-numeric: tabular-nums;
}
.hc-cell.outside { background: transparent; border-color: transparent; color: transparent; pointer-events: none; }
.hc-cell.l1 { background: rgba(244,107,93,0.10); border-color: rgba(244,107,93,0.20); }
.hc-cell.l2 { background: rgba(244,107,93,0.22); border-color: rgba(244,107,93,0.30); }
.hc-cell.l3 { background: rgba(244,107,93,0.42); border-color: rgba(244,107,93,0.50); color: white; }
.hc-cell.l4 { background: rgba(244,107,93,0.60); border-color: rgba(244,107,93,0.66); color: white; font-weight: 700; }
.hc-cell.income { background: rgba(21,184,134,0.22); border-color: rgba(21,184,134,0.32); color: #0e8462; font-weight: 700; }
.hc-cell.today { box-shadow: inset 0 0 0 2px var(--accent); border-color: var(--accent); color: var(--accent); font-weight: 800; }
.hc-cell.future { opacity: 0.55; }
html.dark .hc-cell.income { color: var(--pos); }

/* Mini calendar — alerts: atrasado pulsa em vermelho, pendente é dot âmbar */
.hc-cell.late {
  animation: nv-cell-pulse-late 2s ease-in-out infinite;
  border-color: rgba(244,107,93,0.55) !important;
  background: rgba(244,107,93,0.18) !important;
}
.hc-cell.late .hc-dot { background: var(--neg); }
.hc-cell.pending-future { border-color: rgba(232,169,87,0.55) !important; }
.hc-cell.pending-future .hc-dot { background: var(--warn); }
.hc-dot {
  position: absolute; top: 3px; right: 3px;
  width: 5px; height: 5px; border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 1.5px var(--surface);
}
.hc-cell.late .hc-dot { animation: nv-dot-pulse-late 1.5s ease-in-out infinite; }

/* Big calendar — same alert language */
.nv-cal-cell.late {
  animation: nv-cell-pulse-late 2s ease-in-out infinite;
  border-color: rgba(244,107,93,0.55) !important;
}
.nv-cal-cell.late .ev-dot {
  background: var(--neg) !important;
  animation: nv-dot-pulse-late 1.5s ease-in-out infinite;
}
.nv-cal-cell.pending-future {
  border-color: rgba(232,169,87,0.55) !important;
}
.nv-cal-cell.pending-future .ev-dot { background: var(--warn) !important; }
.nv-cal-cell.has-fatura .ev-dot { background: var(--inv) !important; }

@keyframes nv-cell-pulse-late {
  0%, 100% { box-shadow: 0 0 0 0 rgba(244,107,93,0); }
  50%      { box-shadow: 0 0 0 5px rgba(244,107,93,0.18); }
}
@keyframes nv-dot-pulse-late {
  0%, 100% { transform: scale(1);   box-shadow: 0 0 0 1.5px var(--surface), 0 0 0 0 rgba(244,107,93,0); }
  50%      { transform: scale(1.4); box-shadow: 0 0 0 1.5px var(--surface), 0 0 0 5px rgba(244,107,93,0.30); }
}

@media (prefers-reduced-motion: reduce) {
  .hc-cell.late, .nv-cal-cell.late { animation: none !important; }
  .hc-cell.late .hc-dot, .nv-cal-cell.late .ev-dot { animation: none !important; transform: none !important; }
}

/* Alert banner (atop calendario-financeiro) */
.nv-cal-alert {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(244,107,93,0.10), rgba(244,107,93,0.04));
  border: 1px solid rgba(244,107,93,0.30);
  margin-bottom: 14px;
}
.nv-cal-alert .alert-icon {
  width: 36px; height: 36px; border-radius: 12px;
  background: var(--neg-soft); color: var(--neg);
  display: grid; place-items: center; flex-shrink: 0;
  animation: nv-dot-pulse-late 2s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .nv-cal-alert .alert-icon { animation: none !important; transform: none !important; }
}

/* Heatmap */
.nv-heat-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.nv-heat-cell {
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  background: var(--surface-2);
  position: relative;
  display: grid; grid-template-rows: auto 1fr;
  padding: 4px 6px;
  border: 1px solid var(--hairline);
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.nv-heat-cell:hover { transform: translateY(-1px); box-shadow: var(--shadow-1); }
.nv-heat-cell .day { font-size: 11px; font-weight: 700; color: var(--text-2); }
.nv-heat-cell .v { font-size: 10.5px; color: var(--text-3); align-self: end; font-weight: 600; }
.nv-heat-cell.today { box-shadow: inset 0 0 0 2px var(--accent); }
.nv-heat-cell.l1 { background: rgba(244,107,93,0.06); }
.nv-heat-cell.l2 { background: rgba(244,107,93,0.16); }
.nv-heat-cell.l3 { background: rgba(244,107,93,0.30); }
.nv-heat-cell.l4 { background: rgba(244,107,93,0.55); color: white; }
.nv-heat-cell.l4 .day, .nv-heat-cell.l4 .v { color: white; }
.nv-heat-cell.income { background: rgba(21,184,134,0.18); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.nv-btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
  transition: opacity 0.15s ease, transform 0.12s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease !important;
  white-space: nowrap;
  border: 1px solid transparent;
}
.nv-btn:disabled, button.nv-btn:disabled {
  opacity: 0.45 !important; cursor: not-allowed !important;
  transform: none !important; box-shadow: none !important;
}

.liquid-gradient,
.nv-btn-primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent)) !important;
  box-shadow: 0 1px 0 rgba(255,255,255,0.35) inset, 0 8px 22px rgba(15,111,224,0.36) !important;
  border: none !important;
  color: #FFFFFF !important;
}
.liquid-gradient:hover,
.nv-btn-primary:hover { opacity: 0.94; }
.liquid-gradient:active,
.nv-btn-primary:active { transform: scale(0.98) !important; opacity: 0.86; }
.liquid-gradient:disabled,
.nv-btn-primary:disabled {
  opacity: 0.45 !important; transform: none !important; box-shadow: none !important; cursor: not-allowed !important;
}

.nv-btn-secondary {
  background: var(--surface) !important;
  color: var(--text-2) !important;
  border: 1px solid var(--hairline) !important;
  box-shadow: var(--shadow-1) !important;
  font-weight: 600 !important;
}
.nv-btn-secondary:hover {
  background: var(--surface-2) !important;
  color: var(--text-1) !important;
}

.nv-btn-ghost {
  background: transparent !important;
  color: var(--text-2) !important;
  border-color: transparent !important;
  box-shadow: none !important;
  font-weight: 600 !important;
}
.nv-btn-ghost:hover {
  color: var(--text-1) !important;
  background: rgba(20,20,25,0.05) !important;
}

.nv-btn-danger-soft {
  background: rgba(244, 107, 93, 0.10) !important;
  color: #b3392b !important;
  border: 1px solid rgba(244, 107, 93, 0.22) !important;
  font-weight: 600 !important;
  box-shadow: none !important;
}
.nv-btn-danger-soft:hover { background: rgba(244, 107, 93, 0.16) !important; }

/* ── Loading / empty panels ─────────────────────────────────────────────── */
@keyframes nv-spin { to { transform: rotate(360deg); } }
.nv-spinner {
  width: 2.35rem; height: 2.35rem;
  border: 3px solid rgba(15, 111, 224, 0.14);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: nv-spin 0.72s linear infinite;
}
.nv-loading-panel {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 0.75rem; padding: 3rem 1.5rem; text-align: center;
}
/* Garante que .hidden esconda o painel de loading (vence o display:flex acima). */
.nv-loading-panel.hidden { display: none; }
.nv-empty-panel { padding: 2.5rem 1.5rem; text-align: center; }
.nv-empty-panel.hidden { display: none; }
.nv-empty-panel .nv-empty-icon-wrap {
  display: inline-flex; align-items: center; justify-content: center;
  width: 3.5rem; height: 3.5rem; border-radius: 1rem;
  background: var(--accent-soft); color: var(--accent);
  margin-bottom: 1rem;
}

/* Section / Nav group labels */
.nv-nav-group {
  font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--text-3);
  padding: 14px 12px 6px;
  display: block;
  user-select: none;
}

/* Material Symbols (both Outlined + Rounded loaded — default settings) */
.material-symbols-outlined,
.material-symbols-rounded {
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
}
.material-symbols-rounded.fill,
.material-symbols-outlined.fill {
  font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 24;
}

/* ── Tables ──────────────────────────────────────────────────────────────── */
.nv-table { border-collapse: separate; border-spacing: 0; }
.nv-table thead th {
  background: var(--surface-2);
  font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-2);
  padding: 12px 20px;
  border-bottom: 1px solid var(--hairline);
}
.nv-table tbody tr { border-bottom: 1px solid var(--hairline); transition: background 0.1s; }
.nv-table tbody tr:hover { background: var(--accent-soft); }
.nv-table tbody td { padding: 14px 20px; font-size: 13.5px; color: var(--text-1); }

/* ── Inputs ──────────────────────────────────────────────────────────────── */
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="search"],
select, textarea {
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--hairline-strong) !important;
  background: var(--surface) !important;
  color: var(--text-1) !important;
  transition: border-color 0.15s, box-shadow 0.15s !important;
}
input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus,
input[type="number"]:focus, input[type="date"]:focus, input[type="search"]:focus,
select:focus, textarea:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 4px var(--accent-ring) !important;
  outline: none !important;
}
::placeholder { color: rgba(80, 87, 101, 0.66); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Badges (legacy) ─────────────────────────────────────────────────────── */
.nv-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
}
.nv-badge-blue   { background: rgba(15,111,224,0.10); color: var(--accent); }
.nv-badge-green  { background: var(--pos-soft);       color: #0d8062; }
.nv-badge-red    { background: var(--neg-soft);       color: #b3392b; }
.nv-badge-orange { background: var(--warn-soft);      color: #a06a1f; }
.nv-badge-gray   { background: rgba(157,157,165,0.16);color: var(--text-2); }
.nv-badge-purple { background: var(--inv-soft);       color: #5d4dc7; }

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(20,20,25,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(20,20,25,0.25); }

/* ── Selection ───────────────────────────────────────────────────────────── */
::selection { background: rgba(15,111,224,0.20); }

/* ── Animations ──────────────────────────────────────────────────────────── */
@keyframes nv-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.nv-fade-in { animation: nv-fade-in 0.22s ease both; }

@keyframes nv-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.nv-rise { animation: nv-rise 360ms cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.nv-rise.d1 { animation-delay: 60ms; }
.nv-rise.d2 { animation-delay: 120ms; }
.nv-rise.d3 { animation-delay: 180ms; }
.nv-rise.d4 { animation-delay: 240ms; }
.nv-rise.d5 { animation-delay: 300ms; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .nv-spinner { animation: none !important; opacity: 0.85; border-top-color: var(--accent); }
}

/* ── Tailwind palette overrides for new tokens ───────────────────────────── */
/* Map existing utility classes to new warm-mac palette */
.bg-background { background-color: var(--bg) !important; }
.bg-surface { background-color: var(--surface) !important; }
.bg-surface-container-lowest { background-color: var(--surface) !important; }
.bg-surface-container-low { background-color: var(--surface-2) !important; }
.bg-surface-container { background-color: var(--surface-3) !important; }
.bg-surface-container-high { background-color: var(--surface-4) !important; }
.text-on-surface { color: var(--text-1) !important; }
.text-on-surface-variant { color: var(--text-2) !important; }
.text-primary { color: var(--accent) !important; }
.bg-primary { background-color: var(--accent) !important; }
.text-error { color: var(--neg) !important; }
.text-tertiary { color: var(--pos) !important; }
.border-outline-variant\/30 { border-color: var(--hairline) !important; }
.border-outline-variant\/40 { border-color: var(--hairline) !important; }
.border-outline-variant\/25 { border-color: var(--hairline) !important; }
.border-outline-variant\/20 { border-color: var(--hairline) !important; }
.border-outline-variant\/15 { border-color: var(--hairline) !important; }
.border-outline-variant\/10 { border-color: var(--hairline) !important; }
.ring-outline-variant\/30 { --tw-ring-color: var(--hairline) !important; }
.ring-outline-variant\/20 { --tw-ring-color: var(--hairline) !important; }
.ring-outline-variant\/15 { --tw-ring-color: var(--hairline) !important; }
.ring-outline-variant\/10 { --tw-ring-color: var(--hairline) !important; }

/* ── DARK MODE ───────────────────────────────────────────────────────────── */
html.dark {
  --bg:            #0E0E11;
  --bg-elev:       #14141A;
  --surface:       #17171D;
  --surface-2:     #1C1C24;
  --surface-3:     #22222B;
  --surface-4:     #2A2A35;
  --hairline:      rgba(255, 255, 255, 0.07);
  --hairline-strong: rgba(255, 255, 255, 0.14);
  --vibrancy:      rgba(28, 28, 36, 0.66);
  --card-border:   rgba(255, 255, 255, 0.07);

  --text-1:        #F2F2F4;
  --text-2:        #B7B7BE;
  --text-3:        #7C7C85;
  --text-soft:     #54545C;

  --accent:        #5DA0FF;
  --accent-2:      #82B6FF;
  --accent-soft:   rgba(93, 160, 255, 0.16);
  --accent-ring:   rgba(93, 160, 255, 0.30);

  --pos:           #2EDDA4;
  --pos-soft:      rgba(46, 221, 164, 0.14);
  --neg:           #FF8275;
  --neg-soft:      rgba(255, 130, 117, 0.14);
  --warn:          #F1B96A;
  --warn-soft:     rgba(241, 185, 106, 0.16);
  --inv:           #A99CFF;
  --inv-soft:      rgba(169, 156, 255, 0.18);

  --shadow-1: 0 1px 0 rgba(255,255,255,0.04) inset, 0 1px 2px rgba(0,0,0,0.4), 0 12px 36px rgba(0,0,0,0.45);
  --shadow-2: 0 1px 0 rgba(255,255,255,0.06) inset, 0 2px 6px rgba(0,0,0,0.45), 0 24px 60px rgba(0,0,0,0.55);
  --shadow-pop:0 1px 0 rgba(255,255,255,0.06) inset, 0 16px 44px rgba(93, 160, 255, 0.28);
  --shadow-soft:   var(--shadow-1);
  --shadow-strong: 0 10px 28px rgba(93, 160, 255, 0.28);
}

html.dark body.app-macos-shell { background-color: var(--bg); color: var(--text-1); }

html.dark #app-shell-main {
  background:
    radial-gradient(900px 480px at 14% -10%, rgba(93, 160, 255, 0.16), transparent 58%),
    radial-gradient(820px 420px at 100% 0%, rgba(241, 185, 106, 0.10), transparent 56%),
    radial-gradient(900px 600px at 50% 100%, rgba(169, 156, 255, 0.10), transparent 60%),
    var(--bg);
}

html.dark #app-sidebar {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.01) 100%),
    var(--bg-elev);
  border-right: 1px solid var(--hairline);
  box-shadow:
    inset -1px 0 0 rgba(93, 160, 255, 0.18),
    12px 0 40px rgba(0, 0, 0, 0.35);
}

html.dark #app-shell-header {
  background: rgba(20, 20, 26, 0.78);
  border-bottom: 1px solid var(--hairline);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

html.dark .nv-cmd { background: var(--surface-2); }
html.dark .nv-kbd > span { background: var(--surface-3); }

html.dark #app-sidebar .sidebar-nav-link:not(.nv-nav-active):hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-1);
}
html.dark #app-sidebar .sidebar-nav-link.nv-nav-active {
  background: linear-gradient(180deg, rgba(93,160,255,0.18), rgba(93,160,255,0.08));
  box-shadow: inset 0 0 0 1px rgba(93,160,255,0.26);
  color: var(--accent);
}

html.dark #sidebar-profile-card {
  background: transparent;
  border: 0;
}

html.dark .nv-nav-group { color: var(--text-3); }

html.dark .nv-card { background: var(--surface); border-color: var(--card-border); box-shadow: var(--shadow-1); }
html.dark .rounded-xl.bg-surface-container-lowest,
html.dark .rounded-2xl.bg-surface-container-lowest {
  background-color: var(--surface) !important;
  border-color: var(--card-border) !important;
  box-shadow: var(--shadow-1) !important;
}

html.dark .nv-hero,
html.dark body.app-macos-shell .nv-home-hero {
  background:
    radial-gradient(640px 320px at 8% 0%, rgba(93,160,255,0.18), transparent 70%),
    radial-gradient(560px 320px at 100% 100%, rgba(46,221,164,0.10), transparent 65%),
    var(--surface);
}

html.dark .nv-ai {
  background:
    radial-gradient(380px 200px at 0% 0%, rgba(169,156,255,0.20), transparent 70%),
    radial-gradient(420px 240px at 100% 100%, rgba(93,160,255,0.16), transparent 70%),
    var(--surface);
}

html.dark .nv-ai-bullet { background: rgba(255,255,255,0.04); border-color: var(--hairline); }

html.dark .bg-surface-container-lowest { background-color: var(--surface) !important; }
html.dark .bg-surface-container-low { background-color: var(--surface-2) !important; }
html.dark .bg-surface-container { background-color: var(--surface-3) !important; }
html.dark .bg-surface-container-high { background-color: var(--surface-4) !important; }
html.dark .text-on-surface { color: var(--text-1) !important; }
html.dark .text-on-surface-variant { color: var(--text-2) !important; }

html.dark input, html.dark select, html.dark textarea {
  background: var(--surface-2) !important;
  border-color: var(--hairline-strong) !important;
  color: var(--text-1) !important;
}

html.dark ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); }
html.dark ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

html.dark .nv-btn-secondary {
  background: rgba(255, 255, 255, 0.04) !important;
  color: rgba(255, 255, 255, 0.74) !important;
  border-color: var(--hairline-strong) !important;
  box-shadow: none !important;
}
html.dark .nv-btn-secondary:hover { background: rgba(255, 255, 255, 0.08) !important; color: var(--text-1) !important; }
html.dark .nv-btn-ghost:hover { background: rgba(255, 255, 255, 0.06) !important; }
html.dark .nv-btn-danger-soft {
  background: rgba(255, 130, 117, 0.14) !important;
  color: #fca5a5 !important;
  border-color: rgba(255, 130, 117, 0.30) !important;
}

html.dark .nv-spinner { border-color: rgba(93, 160, 255, 0.2); border-top-color: var(--accent); }
html.dark .nv-empty-panel .nv-empty-icon-wrap { background: var(--accent-soft); color: var(--accent); }

html.dark :focus-visible { outline-color: var(--accent); }

/* ── Drag handles (kept for home dashboard customization) ────────────────── */
.dashboard-card-drag-ready { position: relative; }
.card-drag-handle {
  position: absolute; top: 12px; right: 12px; z-index: 5;
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  border-radius: 8px;
  border: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--text-2);
  cursor: grab;
  transition: opacity .15s, background .15s;
  opacity: 0;
}
.dashboard-card-drag-ready:hover .card-drag-handle { opacity: 1; }
.card-drag-handle:hover { background: var(--surface-2); color: var(--text-1); }
.card-drag-handle:active { cursor: grabbing; }
html.dark .card-drag-handle { background: var(--surface-3); color: var(--text-2); border-color: var(--hairline); }
.dashboard-card-dragging { opacity: 0.55; }
.dashboard-card-drop-before { box-shadow: inset 0 3px 0 var(--accent); }
.dashboard-card-drop-after  { box-shadow: inset 0 -3px 0 var(--accent); }
