/* ============================================================
   PORTAL V2 — "Precision Architect" Design System
   Self-contained. Zero dependency on style.css.
   ============================================================ */

/* ── View Transitions (cross-page fade + morph) ──────────────── */
@view-transition { navigation: auto; }

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: .35s;
  animation-timing-function: cubic-bezier(.4,0,.2,1);
}

/* User bubble morphs from public site nav-user-btn → portal topbar */
.pv2-topbar-user { view-transition-name: nexus-user-bubble; }
::view-transition-old(nexus-user-bubble),
::view-transition-new(nexus-user-bubble) {
  animation-duration: .5s;
  animation-timing-function: cubic-bezier(.34,1.56,.64,1);
}

/* ----------------------------------------------------------
   0. CUSTOM PROPERTIES
   ---------------------------------------------------------- */
:root {
  /* surfaces */
  --pv2-bg: #f8f9ff;
  --pv2-surface-low: #eff4ff;
  --pv2-surface: #e5eeff;
  --pv2-surface-high: #dce9ff;
  --pv2-surface-highest: #d3e4fe;
  --pv2-card: #ffffff;

  /* brand */
  --pv2-primary: #006e2f;
  --pv2-primary-mid: #22c55e;
  --pv2-primary-fixed: #6bff8f;
  --pv2-primary-muted: rgba(0, 110, 47, 0.10);

  /* text */
  --pv2-on-surface: #0b1c30;
  --pv2-on-variant: #3d4a3d;
  --pv2-muted: rgba(11, 28, 48, 0.40);

  /* misc */
  --pv2-border: rgba(11, 28, 48, 0.07);
  --pv2-sidebar-bg: #f1f5f9;
  --pv2-sidebar-text: #475569;
  --pv2-error: #ba1a1a;
  --pv2-error-container: #ffdad6;

  /* fonts */
  --pv2-font-h: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  --pv2-font-b: 'Inter', 'Plus Jakarta Sans', system-ui, sans-serif;

  /* shadows (navy-tinted, never pure black) */
  --pv2-shadow-sm: 0 1px 3px rgba(11, 28, 48, 0.06);
  --pv2-shadow: 0 2px 8px rgba(11, 28, 48, 0.07);
  --pv2-shadow-md: 0 4px 16px rgba(11, 28, 48, 0.08);
  --pv2-shadow-lg: 0 8px 32px rgba(11, 28, 48, 0.10);
  --pv2-shadow-modal: 0 12px 48px rgba(11, 28, 48, 0.14);
}

/* ----------------------------------------------------------
   1. CSS RESET & BASE
   ---------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body.pv2-body {
  background: var(--pv2-bg);
  color: var(--pv2-on-surface);
  font-family: var(--pv2-font-b);
  line-height: 1.5;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.pv2-body .navbar {
  display: none !important;
}

.hidden {
  display: none !important;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}

input,
textarea,
select {
  font-family: inherit;
}

/* ----------------------------------------------------------
   2. SCROLLBAR (light theme)
   ---------------------------------------------------------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(11, 28, 48, 0.12);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(11, 28, 48, 0.22);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(11, 28, 48, 0.12) transparent;
}

/* ----------------------------------------------------------
   3. LAYOUT ARCHITECTURE
   ---------------------------------------------------------- */
.pv2-layout {
  display: flex;
  min-height: 100vh;
}

.pv2-main {
  flex: 1;
  margin-left: 256px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.pv2-content {
  flex: 1;
  padding: 40px;
}

/* ----------------------------------------------------------
   3a. SIDEBAR
   ---------------------------------------------------------- */
.pv2-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 256px;
  height: 100vh;
  background: var(--pv2-sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}

.pv2-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 24px 20px 20px;
  text-decoration: none;
  color: inherit;
}

.pv2-brand-logo {
  height: 24px;
  width: auto;
}

.pv2-brand-badge {
  background: rgba(0, 110, 47, .1);
  color: var(--pv2-primary);
  border: 1px solid rgba(0, 110, 47, .28);
  border-radius: 6px;
  font-family: var(--pv2-font-h);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 3px 8px;
  white-space: nowrap;
}
body.pv2-dark .pv2-brand-badge {
  background: rgba(34, 197, 94, .12);
  color: #4ade80;
  border-color: rgba(34, 197, 94, .3);
}

.pv2-brand-name {
  font-family: var(--pv2-font-h);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--pv2-on-surface);
  line-height: 1.2;
}

.pv2-brand-subtitle {
  font-family: var(--pv2-font-h);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--pv2-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Nav */
.pv2-nav {
  list-style: none;
  padding: 8px 12px;
  flex: 1;
}

.pv2-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: 8px;
  font-family: var(--pv2-font-h);
  font-size: 0.69rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pv2-sidebar-text);
  transition: all 0.15s ease;
  cursor: pointer;
  position: relative;
}

.pv2-nav-item .material-symbols-outlined,
.pv2-nav-item .material-icons-outlined {
  font-size: 19px;
  flex-shrink: 0;
}

.pv2-nav-item:hover {
  transform: translateX(2px);
  color: var(--pv2-on-surface);
  background: rgba(11, 28, 48, 0.04);
}

.pv2-nav-item.active {
  background: var(--pv2-card);
  color: var(--pv2-primary);
  box-shadow: var(--pv2-shadow-sm);
}

/* portal-tab compatibility */
.pv2-nav-item.portal-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: 8px;
  font-family: var(--pv2-font-h);
  font-size: 0.69rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pv2-sidebar-text);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.pv2-nav-item.portal-tab:hover {
  transform: translateX(2px);
  color: var(--pv2-on-surface);
  background: rgba(11, 28, 48, 0.04);
}

.pv2-nav-item.portal-tab.active {
  background: var(--pv2-card);
  color: var(--pv2-primary);
  box-shadow: var(--pv2-shadow-sm);
}

.pv2-nav-sep {
  height: 1px;
  background: rgba(11, 28, 48, 0.07);
  margin: 8px 16px;
}

.pv2-nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--pv2-error);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  font-family: var(--pv2-font-h);
  line-height: 1;
  margin-left: auto;
}

/* CTA */
.pv2-cta {
  padding: 12px 16px 8px;
}

.pv2-cta-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--pv2-primary), var(--pv2-primary-mid));
  color: #fff;
  font-family: var(--pv2-font-h);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 8px rgba(0, 110, 47, 0.20);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.pv2-cta-btn:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

/* Bottom nav */
.pv2-nav-bottom {
  list-style: none;
  padding: 8px 12px 16px;
}

.pv2-nav-bottom .pv2-nav-item {
  font-size: 0.67rem;
}

.pv2-logout {
  color: var(--pv2-error) !important;
}

.pv2-logout:hover {
  background: rgba(186, 26, 26, 0.06) !important;
  color: var(--pv2-error) !important;
}

/* ----------------------------------------------------------
   4. TOPBAR
   ---------------------------------------------------------- */
.pv2-topbar {
  position: sticky;
  top: 0;
  z-index: 90;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  background: rgba(248, 249, 255, 0.80);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.pv2-page-title {
  font-family: var(--pv2-font-h);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--pv2-on-surface);
}

/* Topbar global search */
.pv2-topbar-search {
  flex: 1;
  max-width: 480px;
  position: relative;
  display: flex;
  align-items: center;
}

.pv2-topbar-search .material-symbols-outlined {
  position: absolute;
  left: 12px;
  font-size: 18px;
  color: var(--pv2-muted);
  pointer-events: none;
}

.pv2-topbar-search input {
  width: 100%;
  padding: 8px 14px 8px 38px;
  background: var(--pv2-surface-low);
  border: none;
  border-radius: 10px;
  font-family: var(--pv2-font-b);
  font-size: 0.82rem;
  color: var(--pv2-on-surface);
  outline: none;
  transition: background .15s, box-shadow .15s;
}

.pv2-topbar-search input::placeholder {
  color: var(--pv2-muted);
}

.pv2-topbar-search input:focus {
  background: var(--pv2-card);
  box-shadow: var(--pv2-shadow), 0 0 0 2px var(--pv2-primary-muted);
}

.pv2-topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pv2-topbar-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  color: var(--pv2-sidebar-text);
  transition: background 0.15s ease;
  position: relative;
  cursor: pointer;
}

.pv2-topbar-icon:hover {
  background: var(--pv2-surface-low);
}

.pv2-topbar-icon .material-symbols-outlined,
.pv2-topbar-icon .material-icons-outlined {
  font-size: 20px;
}

.pv2-notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--pv2-error);
  color: #fff;
  font-size: 0.58rem;
  font-weight: 700;
  font-family: var(--pv2-font-h);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.pv2-topbar-sep {
  width: 1px;
  height: 28px;
  background: rgba(11, 28, 48, 0.08);
  margin: 0 6px;
}

.pv2-topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease;
  position: relative;
}

.pv2-topbar-user:hover {
  background: var(--pv2-surface-low);
}

.pv2-topbar-user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.pv2-topbar-company {
  font-family: var(--pv2-font-h);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--pv2-on-surface);
  line-height: 1.2;
}

.pv2-topbar-role {
  font-family: var(--pv2-font-h);
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--pv2-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.pv2-topbar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--pv2-primary), var(--pv2-primary-mid));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--pv2-font-h);
  font-size: 0.75rem;
  font-weight: 800;
  flex-shrink: 0;
}

/* User dropdown */
.nav-user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 300px;
  background: var(--pv2-card);
  border-radius: 14px;
  box-shadow: var(--pv2-shadow-lg);
  z-index: 200;
  padding: 0;
  overflow: hidden;
}

.nav-user-dropdown.open {
  display: block;
}

.nav-drop-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px;
  background: var(--pv2-surface-low);
}

.nav-drop-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--pv2-primary), var(--pv2-primary-mid));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--pv2-font-h);
  font-size: 0.85rem;
  font-weight: 800;
  flex-shrink: 0;
}

.nav-drop-name {
  font-family: var(--pv2-font-h);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--pv2-on-surface);
}

.nav-drop-email {
  font-size: 0.75rem;
  color: var(--pv2-muted);
}

.nav-drop-section {
  padding: 12px 20px;
}

.nav-drop-section-label {
  font-family: var(--pv2-font-h);
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--pv2-muted);
  margin-bottom: 8px;
}

.nav-drop-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  font-size: 0.8rem;
}

.nav-drop-key {
  color: var(--pv2-sidebar-text);
  font-size: 0.78rem;
}

.nav-drop-actions {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-top: 1px solid var(--pv2-border);
}

.nav-drop-link {
  display: flex;
  align-items: center;
  padding: 9px 12px;
  border-radius: 8px;
  font-family: var(--pv2-font-h);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--pv2-sidebar-text);
  transition: background 0.12s ease, color 0.12s ease;
  cursor: pointer;
}

.nav-drop-link:hover {
  background: var(--pv2-surface-low);
  color: var(--pv2-primary);
}

.nav-logout-btn {
  display: flex;
  align-items: center;
  padding: 9px 12px;
  border-radius: 8px;
  font-family: var(--pv2-font-h);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--pv2-error);
  cursor: pointer;
  transition: background 0.12s ease;
  width: 100%;
  border: none;
  background: none;
  font-family: inherit;
}

.nav-logout-btn:hover {
  background: rgba(186, 26, 26, 0.06);
}

/* ----------------------------------------------------------
   5. PORTAL PANELS
   ---------------------------------------------------------- */
.portal-panel {
  display: none;
}

.portal-panel.active {
  display: block;
}

/* ----------------------------------------------------------
   6. PANEL HERO
   ---------------------------------------------------------- */
.pv2-panel-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
  gap: 24px;
}

.pv2-panel-hero-text h2 {
  font-family: var(--pv2-font-h);
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--pv2-on-surface);
  line-height: 1.15;
}

.pv2-panel-hero-text p {
  font-size: 0.9rem;
  color: var(--pv2-muted);
  margin-top: 6px;
}

.pv2-panel-hero-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* ----------------------------------------------------------
   7. METRIC CARDS
   ---------------------------------------------------------- */
.pv2-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.pv2-metric-card {
  background: var(--pv2-card);
  border-radius: 12px;
  padding: 20px 22px;
  box-shadow: var(--pv2-shadow);
  border: none;
  border-bottom: 4px solid var(--pv2-border);
  font-family: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-bottom-color 0.15s ease;
}

.pv2-metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--pv2-shadow-md);
}

.pv2-metric-card:not(.active):is(button, [data-rstab], [data-enc-total], [data-cc-filter], [data-equip-filter]) { opacity: .65; }

/* Base neon-glow theming. Cada variante define só --kpi-* custom props; o
   resto do estilo (gradiente, shadow, color) é derivado destes valores. */
.pv2-metric-card.active {
  --kpi-rgb: 34,197,94;          /* default verde */
  --kpi-color: #15803d;
  --kpi-color-dark: #86efac;
  --kpi-border: #22c55e;
  opacity: 1;
  border-bottom-color: var(--kpi-border);
  background: linear-gradient(135deg, rgba(var(--kpi-rgb),.08) 0%, rgba(var(--kpi-rgb),.03) 100%);
  box-shadow: var(--pv2-shadow-md), 0 0 0 1px rgba(var(--kpi-rgb),.35), 0 0 28px rgba(var(--kpi-rgb),.28);
}
.pv2-metric-card.active .pv2-metric-label,
.pv2-metric-card.active .pv2-metric-value { color: var(--kpi-color); }
body.pv2-dark .pv2-metric-card.active {
  background: linear-gradient(135deg, rgba(var(--kpi-rgb),.15) 0%, rgba(var(--kpi-rgb),.06) 100%);
  box-shadow: 0 0 0 1px rgba(var(--kpi-rgb),.45), 0 0 32px rgba(var(--kpi-rgb),.35);
}
body.pv2-dark .pv2-metric-card.active .pv2-metric-label,
body.pv2-dark .pv2-metric-card.active .pv2-metric-value { color: var(--kpi-color-dark); }

/* ── CC ──────────────────────────────────────────────────────────── */
[data-cc-filter="aberto"].active    { --kpi-rgb: 34,197,94;  --kpi-color: #15803d; --kpi-color-dark: #86efac; --kpi-border: #22c55e; }
[data-cc-filter="vencido"].active   { --kpi-rgb: 220,38,38;  --kpi-color: #b91c1c; --kpi-color-dark: #fca5a5; --kpi-border: #dc2626; }
[data-cc-filter="a_vencer"].active  { --kpi-rgb: 245,158,11; --kpi-color: #b45309; --kpi-color-dark: #fcd34d; --kpi-border: #f59e0b; }
[data-cc-filter="mes"].active       { --kpi-rgb: 99,102,241; --kpi-color: #4338ca; --kpi-color-dark: #a5b4fc; --kpi-border: #6366f1; }
[data-cc-filter="ano"].active       { --kpi-rgb: 20,184,166; --kpi-color: #0f766e; --kpi-color-dark: #5eead4; --kpi-border: #14b8a6; }

/* ── Encomendas ─────────────────────────────────────────────────── */
[data-enc-total="historico"].active { --kpi-rgb: 59,130,246; --kpi-color: #1d4ed8; --kpi-color-dark: #93c5fd; --kpi-border: #3b82f6; }
[data-enc-total="loja"].active      { --kpi-rgb: 168,85,247; --kpi-color: #7c3aed; --kpi-color-dark: #d8b4fe; --kpi-border: #a855f7; }
[data-enc-total="maquinas"].active  { --kpi-rgb: 249,115,22; --kpi-color: #c2410c; --kpi-color-dark: #fdba74; --kpi-border: #f97316; }

/* ── Equipamentos ──────────────────────────────────────────────── */
[data-equip-filter=""].active         { --kpi-rgb: 59,130,246; --kpi-color: #1d4ed8; --kpi-color-dark: #93c5fd; --kpi-border: #3b82f6; }
[data-equip-filter="ativa"].active    { --kpi-rgb: 34,197,94;  --kpi-color: #15803d; --kpi-color-dark: #86efac; --kpi-border: #22c55e; }
[data-equip-filter="inactive"].active { --kpi-rgb: 220,38,38;  --kpi-color: #b91c1c; --kpi-color-dark: #fca5a5; --kpi-border: #dc2626; }

/* ── Licenciamento (data-rstab) ─────────────────────────────────── */
[data-rstab="todos"].active     { --kpi-rgb: 59,130,246; --kpi-color: #1d4ed8; --kpi-color-dark: #93c5fd; --kpi-border: #3b82f6; }
[data-rstab="a_expirar"].active { --kpi-rgb: 245,158,11; --kpi-color: #b45309; --kpi-color-dark: #fcd34d; --kpi-border: #f59e0b; }
[data-rstab="expirado"].active  { --kpi-rgb: 220,38,38;  --kpi-color: #b91c1c; --kpi-color-dark: #fca5a5; --kpi-border: #dc2626; }
[data-rstab="ativo"].active     { --kpi-rgb: 34,197,94;  --kpi-color: #15803d; --kpi-color-dark: #86efac; --kpi-border: #22c55e; }

.pv2-metric-card.accent {
  border-bottom-color: var(--pv2-primary);
}

.pv2-metric-card.accent2 {
  border-bottom-color: var(--pv2-primary-mid);
}

.pv2-metric-card.accent-yellow {
  border-bottom-color: #f59e0b;
}
.pv2-metric-card.accent-red {
  border-bottom-color: #dc2626;
}
.pv2-metric-card.accent-blue {
  border-bottom-color: #3b82f6;
}

.pv2-metric-label {
  font-family: var(--pv2-font-h);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pv2-muted);
  margin-bottom: 8px;
}

.pv2-metric-value {
  font-family: var(--pv2-font-h);
  font-size: 1.875rem;
  font-weight: 800;
  color: var(--pv2-on-surface);
  line-height: 1.1;
}

/* ----------------------------------------------------------
   8. TABLES
   ---------------------------------------------------------- */
.portal-table-wrap {
  background: var(--pv2-card);
  border-radius: 12px;
  box-shadow: var(--pv2-shadow);
  overflow: hidden;
}

.portal-table {
  width: 100%;
  border-collapse: collapse;
}

.portal-table th {
  background: var(--pv2-surface-low);
  font-family: var(--pv2-font-h);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pv2-muted);
  padding: 12px 14px;
  text-align: left;
  white-space: nowrap;
}

.portal-table td {
  padding: 14px;
  font-size: 0.855rem;
  color: var(--pv2-on-surface);
  border-bottom: 1px solid var(--pv2-border);
  vertical-align: middle;
}

.portal-table tr:hover td {
  background: var(--pv2-surface-low);
}

.portal-table tr:last-child td {
  border-bottom: none;
}

.portal-table code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.8rem;
  background: var(--pv2-surface-low);
  color: var(--pv2-primary);
  padding: 2px 6px;
  border-radius: 4px;
}

.portal-table-loading td {
  text-align: center;
  color: var(--pv2-muted);
  padding: 32px 14px;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background 0.12s ease;
}

th.sortable:hover {
  background: var(--pv2-surface);
}

.sort-icon {
  display: inline-block;
  margin-left: 4px;
  opacity: 0.5;
  font-size: 0.7rem;
}

/* Sort active override for portal-auth.js inline dark CSS */
.portal-table th[style*="rgba(22,163"] {
  background: var(--pv2-primary-muted) !important;
  color: var(--pv2-primary) !important;
  border-bottom: 2px solid var(--pv2-primary) !important;
}

/* ----------------------------------------------------------
   9. FILTERS
   ---------------------------------------------------------- */
.portal-filters,
.cc-filters {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 8px;
  background: var(--pv2-surface-low);
  border-radius: 14px;
  padding: 10px 14px;
  margin-bottom: 20px;
  overflow: visible;
  position: relative;
  z-index: 10;
}

.portal-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 2;
  min-width: 200px;
}

.portal-search-wrap svg,
.portal-search-wrap .material-symbols-outlined,
.portal-search-wrap .material-icons-outlined {
  position: absolute;
  left: 12px;
  font-size: 16px;
  width: 16px;
  height: 16px;
  color: var(--pv2-muted);
  pointer-events: none;
}

.portal-search {
  width: 100%;
  background: var(--pv2-card);
  border: none;
  border-bottom: 2px solid transparent;
  padding: 9px 14px 9px 36px;
  border-radius: 10px;
  font-size: 0.82rem;
  color: var(--pv2-on-surface);
  outline: none;
  min-width: 200px;
  transition: border-color 0.15s ease;
}

.portal-search:focus {
  border-bottom-color: var(--pv2-primary);
}

.portal-search::placeholder {
  color: var(--pv2-muted);
}

/* Filter group: stacked label + input */
.pv2-filter-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.pv2-filter-label {
  font-family: var(--pv2-font-h);
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--pv2-muted);
  padding-left: 2px;
}

.pv2-filter-input {
  background: var(--pv2-card);
  border: none;
  padding: 8px 12px;
  border-radius: 10px;
  font-family: var(--pv2-font-b);
  font-size: 0.82rem;
  color: var(--pv2-on-surface);
  color-scheme: light;
  outline: none;
  box-shadow: var(--pv2-shadow-sm);
  transition: box-shadow .15s;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

select.pv2-filter-input {
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.pv2-filter-input:focus {
  box-shadow: var(--pv2-shadow-sm), 0 0 0 2px var(--pv2-primary-muted);
}

/* Legacy compat aliases */
.cc-filter-group { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.cc-filter-label { font-family: var(--pv2-font-h); font-size: 0.55rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--pv2-muted); }
.cc-date-input { background: var(--pv2-card); border: none; padding: 8px 12px; border-radius: 10px; font-family: var(--pv2-font-b); font-size: 0.82rem; color: var(--pv2-on-surface); color-scheme: light; outline: none; box-shadow: var(--pv2-shadow-sm); }

.portal-filter-select {
  background: var(--pv2-card);
  border: none;
  padding: 9px 30px 9px 12px;
  border-radius: 10px;
  font-size: 0.82rem;
  color: var(--pv2-on-surface);
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  transition: border-color 0.15s ease;
}

.portal-filter-select:focus {
  box-shadow: var(--pv2-shadow-sm), 0 0 0 2px var(--pv2-primary-muted);
}

/* Sort bar */
.pv2-sort-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.pv2-sort-label {
  font-family: var(--pv2-font-h);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pv2-muted);
  margin-right: 2px;
}

.pv2-sort-btn {
  font-family: var(--pv2-font-h);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--pv2-muted);
  padding: 5px 10px;
  border-radius: 8px;
  background: none;
  border: none;
  cursor: pointer;
  transition: color .12s, background .12s;
  white-space: nowrap;
}

.pv2-sort-btn:hover { color: var(--pv2-on-surface); background: var(--pv2-surface-low); }
.pv2-sort-btn.active { color: var(--pv2-primary); background: var(--pv2-primary-muted); font-weight: 700; }

.pv2-sort-arrow {
  display: inline;
  font-size: 0.7rem;
  margin-left: 2px;
}

/* Dark */
body.pv2-dark .pv2-sort-btn:hover { background: rgba(22,163,74,.08); color: #e8f5ec; }
body.pv2-dark .pv2-sort-btn.active { color: #4ade80; background: rgba(22,163,74,.12); }

/* Custom dropdown (replaces native select for dark mode compat) */
.pv2-dropdown {
  position: relative;
  flex-shrink: 0;
}

.pv2-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--pv2-card);
  border: none;
  padding: 8px 12px;
  border-radius: 10px;
  font-family: var(--pv2-font-b);
  font-size: 0.82rem;
  color: var(--pv2-on-surface);
  cursor: pointer;
  box-shadow: var(--pv2-shadow-sm);
  transition: box-shadow .15s;
  white-space: nowrap;
}

.pv2-dropdown-btn:hover,
.pv2-dropdown.open .pv2-dropdown-btn {
  box-shadow: var(--pv2-shadow-sm), 0 0 0 2px var(--pv2-primary-muted);
}

.pv2-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 100%;
  background: var(--pv2-card);
  border-radius: 10px;
  box-shadow: var(--pv2-shadow-md);
  z-index: 500;
  overflow: hidden;
  padding: 4px;
}

.pv2-dropdown.open .pv2-dropdown-menu { display: block; }

.pv2-dropdown-item {
  padding: 8px 14px;
  font-size: 0.82rem;
  color: var(--pv2-on-surface);
  border-radius: 7px;
  cursor: pointer;
  transition: background .1s;
  white-space: nowrap;
}

.pv2-dropdown-item:hover { background: var(--pv2-surface-low); }
.pv2-dropdown-item.active { color: var(--pv2-primary); font-weight: 600; }

/* Dark mode dropdown */
body.pv2-dark .pv2-dropdown-btn { background: rgba(255,255,255,.05); color: #e8f5ec; box-shadow: none; }
body.pv2-dark .pv2-dropdown-btn:hover,
body.pv2-dark .pv2-dropdown.open .pv2-dropdown-btn { box-shadow: 0 0 0 2px rgba(22,163,74,.2); }
body.pv2-dark .pv2-dropdown-menu { background: #0a2914; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
body.pv2-dark .pv2-dropdown-item:hover { background: rgba(22,163,74,.1); }
body.pv2-dark .pv2-dropdown-item.active { color: #4ade80; }

/* Compact clear button inside filters */
.portal-filters .btn-outline {
  padding: 7px 14px;
  font-size: 0.68rem;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Filter selects shrink-proof */
.portal-filters .portal-filter-select,
.portal-filters .form-select {
  flex-shrink: 0;
  white-space: nowrap;
}

/* ----------------------------------------------------------
   10. BUTTONS
   ---------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--pv2-font-h);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 9px 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  line-height: 1.4;
}

.btn-primary {
  background: linear-gradient(135deg, var(--pv2-primary), var(--pv2-primary-mid));
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 110, 47, 0.18);
}

.btn-primary:hover {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 110, 47, 0.24);
}

.btn-outline {
  background: var(--pv2-card);
  color: var(--pv2-on-variant);
  border: 1px solid var(--pv2-border);
}

.btn-outline:hover {
  background: var(--pv2-surface-low);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.67rem;
}

.btn-ghost {
  background: transparent;
  color: var(--pv2-primary);
  padding: 8px 14px;
}

.btn-ghost:hover {
  background: var(--pv2-primary-muted);
}

/* ----------------------------------------------------------
   11. FORM INPUTS
   ---------------------------------------------------------- */
.form-input {
  width: 100%;
  background: var(--pv2-surface-low);
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  color: var(--pv2-on-surface);
  outline: none;
  transition: border-color 0.15s ease;
}

.form-input:focus {
  border-bottom-color: var(--pv2-primary);
}

.form-input::placeholder {
  color: var(--pv2-muted);
}

.form-select {
  width: 100%;
  background: var(--pv2-surface-low);
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  color: var(--pv2-on-surface);
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color 0.15s ease;
}

.form-select:focus {
  border-bottom-color: var(--pv2-primary);
}

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-family: var(--pv2-font-h);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pv2-on-variant);
  margin-bottom: 6px;
}

.form-error {
  font-size: 0.78rem;
  color: var(--pv2-error);
  margin-top: 4px;
}

.cc-date-input {
  color-scheme: light;
}

/* ----------------------------------------------------------
   12. BADGES
   ---------------------------------------------------------- */
.portal-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 9999px;
  font-family: var(--pv2-font-h);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  line-height: 1.5;
}

.badge-ok {
  background: #dcfce7;
  color: #15803d;
}

.badge-pending {
  background: #fef9c3;
  color: #a16207;
}

.badge-inactive {
  background: #fee2e2;
  color: #b91c1c;
}

.badge-warn {
  background: #fff7ed;
  color: #c2410c;
}

.badge-err {
  background: #fee2e2;
  color: #b91c1c;
}

.badge-neutral {
  background: #f1f5f9;
  color: #64748b;
}

/* ----------------------------------------------------------
   13. PAGINATION
   ---------------------------------------------------------- */
.portal-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 20px;
  padding: 8px 0;
}

.portal-pagination button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border: none;
  background: var(--pv2-card);
  color: var(--pv2-on-surface);
  font-family: var(--pv2-font-h);
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.portal-pagination button:hover {
  background: var(--pv2-surface-low);
}

.portal-pagination button.active,
.portal-pagination button[disabled] {
  background: var(--pv2-primary);
  color: #fff;
  cursor: default;
}

.portal-pagination button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--pv2-card);
  color: var(--pv2-on-surface);
}

.portal-page-info {
  font-size: 0.75rem;
  color: var(--pv2-muted);
  margin-left: 8px;
}

/* ----------------------------------------------------------
   14. CC SUMMARY
   ---------------------------------------------------------- */
.cc-summary {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.cc-summary-item {
  background: var(--pv2-card);
  border-radius: 10px;
  box-shadow: var(--pv2-shadow-sm);
  border-bottom: 4px solid var(--pv2-primary);
  padding: 16px 22px;
  min-width: 140px;
}

.cc-summary-label {
  font-family: var(--pv2-font-h);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pv2-muted);
  margin-bottom: 4px;
}

.cc-summary-value {
  font-family: var(--pv2-font-h);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--pv2-on-surface);
}

/* CC recibos expandable rows (injected by portal-auth.js) */
.cc-row-expand { cursor: pointer; user-select: none; }
.cc-row-expand:hover td { background: var(--pv2-surface-low); }
.cc-expand-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 4px;
  background: var(--pv2-surface-low); color: var(--pv2-primary);
  font-size: .7rem; transition: transform .2s, background .15s;
  flex-shrink: 0;
}
.cc-expand-btn.open { transform: rotate(90deg); background: var(--pv2-primary-muted); }
.cc-recibos-row { display: none; }
.cc-recibos-row.open { display: table-row; }
.cc-recibos-cell {
  padding: 0 !important;
  background: var(--pv2-surface-low) !important;
  border-bottom: 1px solid var(--pv2-border) !important;
}
.cc-recibos-inner { padding: 8px 16px 12px 40px; }
.cc-recibos-title {
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--pv2-primary); margin-bottom: 6px;
  font-family: var(--pv2-font-h);
}
.cc-recibo-item {
  display: flex; gap: 16px; align-items: center;
  font-size: .82rem; padding: 4px 0;
  border-bottom: 1px solid var(--pv2-border);
}
.cc-recibo-item:last-child { border-bottom: none; }
.cc-recibo-val { font-weight: 700; color: var(--pv2-primary); }
.cc-valor-neg { color: #dc2626; }
.cc-valor-pos { color: var(--pv2-primary); }
.cc-valor-zero { color: var(--pv2-muted); }

/* CC metrics grid — 5 columns, compact */
#ccSummary {
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}
#ccSummary .pv2-metric-card { padding: 16px 18px; }
#ccSummary .pv2-metric-value { font-size: 1.3rem !important; }
@media (max-width: 1100px) { #ccSummary { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px)  { #ccSummary { grid-template-columns: repeat(2, 1fr); } }

/* ----------------------------------------------------------
   15. ENC TOTALS
   ---------------------------------------------------------- */
.enc-totals-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.enc-total-card {
  background: var(--pv2-card);
  border-radius: 10px;
  box-shadow: var(--pv2-shadow-sm);
  padding: 14px 20px;
  min-width: 130px;
}

/* Enc total — clickable metric cards with active highlight */
.pv2-enc-total { cursor: pointer; }
/* Button-variant (e.g. licenciamento filter) — neutralize button defaults */
button.pv2-enc-total {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  text-align: left;
  border: none;
  border-bottom: 4px solid var(--pv2-border);
  background: var(--pv2-card);
  appearance: none;
  -webkit-appearance: none;
}
.pv2-enc-total:not(.active) { opacity: .65; }
/* Regras activas agora vêm das variantes themed por data-* (ver mais abaixo). */

.enc-total-label {
  font-family: var(--pv2-font-h);
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pv2-muted);
  margin-bottom: 2px;
}

.enc-total-value {
  font-family: var(--pv2-font-h);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--pv2-on-surface);
}

/* ----------------------------------------------------------
   16. SUB-TABS
   ---------------------------------------------------------- */
.panel-subtab-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 12px;
}

.panel-subtabs {
  display: flex;
  gap: 4px;
  background: var(--pv2-surface-low);
  border-radius: 10px;
  padding: 4px;
}

.panel-subtab {
  padding: 7px 16px;
  border-radius: 7px;
  font-family: var(--pv2-font-h);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--pv2-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.panel-subtab:hover {
  color: var(--pv2-on-surface);
}

.panel-subtab.active {
  background: var(--pv2-card);
  color: var(--pv2-primary);
  box-shadow: var(--pv2-shadow-sm);
}

/* Subtabs de Encomendas — cores alinhadas com os cards */
.panel-subtab[data-enc-sub="historico"].active { color: #1d4ed8; }
.panel-subtab[data-enc-sub="loja"].active      { color: #7c3aed; }
.panel-subtab[data-enc-sub="maquinas"].active  { color: #c2410c; }
body.pv2-dark .panel-subtab[data-enc-sub="historico"].active { background: rgba(59,130,246,.15); color: #93c5fd; }
body.pv2-dark .panel-subtab[data-enc-sub="loja"].active      { background: rgba(168,85,247,.15); color: #d8b4fe; }
body.pv2-dark .panel-subtab[data-enc-sub="maquinas"].active  { background: rgba(249,115,22,.15); color: #fdba74; }

.panel-subpanel {
  display: none;
}

.panel-subpanel.active {
  display: block;
}

/* Portal subtabs (renovacoes etc) */
.portal-subtabs {
  display: flex;
  gap: 4px;
  background: var(--pv2-surface-low);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.portal-subtab {
  padding: 7px 16px;
  border-radius: 7px;
  font-family: var(--pv2-font-h);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--pv2-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.portal-subtab:hover {
  color: var(--pv2-on-surface);
}

.portal-subtab.active {
  background: var(--pv2-card);
  color: var(--pv2-primary);
  box-shadow: var(--pv2-shadow-sm);
}

.portal-subtab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--pv2-surface);
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1;
}

.portal-subtab.active .portal-subtab-count {
  background: var(--pv2-primary-muted);
  color: var(--pv2-primary);
}

/* Renov colored states */
.renov-a-expirar.active {
  color: #a16207;
  background: #fef9c3;
}

.renov-a-expirar.active .portal-subtab-count {
  background: rgba(161, 98, 7, 0.12);
  color: #a16207;
}

.renov-expirado.active {
  color: #b91c1c;
  background: #fee2e2;
}

.renov-expirado.active .portal-subtab-count {
  background: rgba(185, 28, 28, 0.12);
  color: #b91c1c;
}

.renov-ativo.active {
  color: #15803d;
  background: #dcfce7;
}

.renov-ativo.active .portal-subtab-count {
  background: rgba(21, 128, 61, 0.12);
  color: #15803d;
}

/* ----------------------------------------------------------
   17. INFO CARDS (Company / Account)
   ---------------------------------------------------------- */
.portal-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.portal-info-card {
  background: var(--pv2-card);
  border-radius: 12px;
  box-shadow: var(--pv2-shadow);
  padding: 28px;
}

.portal-info-title {
  font-family: var(--pv2-font-h);
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--pv2-on-surface);
  margin-bottom: 16px;
}

.portal-info-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.portal-info-rows .row {
  display: flex;
  justify-content: space-between;
  font-size: 0.84rem;
}

.portal-info-rows .row .label {
  color: var(--pv2-muted);
}

.portal-info-rows .row .value {
  color: var(--pv2-on-surface);
  font-weight: 600;
  text-align: right;
}

.portal-erp-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
}

/* ----------------------------------------------------------
   18. NOTICES / EMPTY STATES
   ---------------------------------------------------------- */
.portal-notice {
  text-align: center;
  padding: 64px 24px;
  color: var(--pv2-muted);
  font-size: 0.9rem;
}

.portal-notice .material-symbols-outlined,
.portal-notice .material-icons-outlined {
  font-size: 40px;
  display: block;
  margin: 0 auto 12px;
  opacity: 0.4;
}

/* ----------------------------------------------------------
   19. AUTH ALERT
   ---------------------------------------------------------- */
.auth-alert:not(.hidden) {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--pv2-error-container);
  color: var(--pv2-error);
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  font-weight: 500;
}

/* ----------------------------------------------------------
   20. SPINNER
   ---------------------------------------------------------- */
.btn-spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(11, 28, 48, 0.12);
  border-top-color: var(--pv2-primary);
  border-radius: 50%;
  animation: pv2-spin 0.6s linear infinite;
}

@keyframes pv2-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ----------------------------------------------------------
   21. MODALS
   ---------------------------------------------------------- */
.portal-modal-overlay.hidden {
  display: none;
}

.portal-modal-overlay:not(.hidden) {
  position: fixed;
  inset: 0;
  background: rgba(11, 28, 48, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.portal-modal {
  background: var(--pv2-card);
  border-radius: 16px;
  box-shadow: var(--pv2-shadow-modal);
  max-width: 560px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.portal-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px 16px;
  gap: 16px;
}

.portal-modal-header h3 {
  font-family: var(--pv2-font-h);
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--pv2-on-surface);
}

.portal-modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--pv2-muted);
  cursor: pointer;
  transition: background 0.12s ease;
  flex-shrink: 0;
  border: none;
  background: none;
}

.portal-modal-close:hover {
  background: var(--pv2-surface-low);
  color: var(--pv2-on-surface);
}

.portal-modal-body {
  padding: 0 24px 24px;
  flex: 1;
  overflow-y: auto;
}

.portal-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px 22px;
  background: var(--pv2-surface-low);
  border-radius: 0 0 16px 16px;
}

/* Modal form groups */
.portal-modal-body .form-group {
  margin-bottom: 16px;
}

.portal-modal-body .form-label {
  display: block;
  font-family: var(--pv2-font-h);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pv2-on-variant);
  margin-bottom: 6px;
}

.portal-modal-body .form-input,
.portal-modal-body .form-select {
  width: 100%;
  background: var(--pv2-surface-low);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 10px 10px 0 0;
  padding: 10px 14px;
  font-family: var(--pv2-font-b);
  font-size: 0.875rem;
  color: var(--pv2-on-surface);
  outline: none;
  transition: border-color .15s;
}

.portal-modal-body .form-input:focus,
.portal-modal-body .form-select:focus {
  border-bottom-color: var(--pv2-primary);
}

.portal-modal-body .form-input::placeholder {
  color: var(--pv2-muted);
}

.portal-modal-body textarea.form-input {
  min-height: 80px;
  resize: vertical;
  border-radius: 10px;
}

/* RMA dropzone */
.rma-dropzone {
  position: relative;
  border: 2px dashed var(--pv2-border);
  border-radius: 12px;
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.rma-dropzone:hover { border-color: var(--pv2-primary); background: var(--pv2-surface-low); }
.rma-dropzone-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.rma-dropzone-text { font-size: 0.83rem; color: var(--pv2-muted); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.rma-dropzone-text svg { color: var(--pv2-muted); margin-bottom: 6px; }
.rma-dropzone-text u { color: var(--pv2-primary); cursor: pointer; }
.rma-dropzone-text small { font-size: 0.72rem; opacity: .6; }
.rma-files-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.rma-textarea { min-height: 80px; resize: vertical; }

/* RMA equip card */
.rma-equip-card {
  background: var(--pv2-surface-low);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}

.rma-equip-card h4 {
  font-family: var(--pv2-font-h);
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 8px;
}

/* Dropzone */
.portal-dropzone {
  border: 2px dashed var(--pv2-border);
  border-radius: 10px;
  padding: 28px;
  text-align: center;
  color: var(--pv2-muted);
  font-size: 0.84rem;
  transition: border-color 0.15s ease, background 0.15s ease;
  cursor: pointer;
}

.portal-dropzone:hover,
.portal-dropzone.dragover {
  border-color: var(--pv2-primary);
  background: var(--pv2-primary-muted);
}

/* Files preview */
.portal-files-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.portal-file-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--pv2-surface-low);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
}

.portal-file-item button {
  color: var(--pv2-error);
  font-size: 0.7rem;
  cursor: pointer;
}

/* Inner modal tables */
.portal-modal-body .portal-table-wrap {
  box-shadow: none;
  border-radius: 8px;
  overflow: hidden;
}

.portal-modal-body .portal-table th {
  padding: 8px 12px;
  font-size: 0.6rem;
}

.portal-modal-body .portal-table td {
  padding: 10px 12px;
  font-size: 0.8rem;
}

/* Renov proposta body */
.renov-proposta-body {
  padding: 16px 0;
}

.renov-proposta-body .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 0.84rem;
}

.renov-proposta-body .label {
  color: var(--pv2-muted);
}

.renov-proposta-body .value {
  font-weight: 600;
}

/* ----------------------------------------------------------
   22. RMA CHAT
   ---------------------------------------------------------- */
.portal-modal--chat .portal-modal {
  max-width: 640px;
}

/* Document viewer modal — fatura/encomenda/recibo em iframe */
.portal-modal--doc {
  max-width: 1100px;
  width: 92vw;
}
@media (max-width: 700px) {
  .portal-modal--doc { width: 96vw; max-height: 92vh; }
  #docViewerFrame { height: 78vh !important; }
}

/* Order detail modal — meta cards + tabela */
.order-modal-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  padding: 14px 18px;
  background: var(--pv2-surface-low);
  border-radius: 10px;
  margin-bottom: 16px;
}
.order-modal-meta > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.order-modal-meta-label {
  font-family: var(--pv2-font-h);
  font-size: .58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--pv2-muted);
}
.order-modal-meta-value {
  font-size: .9rem;
  font-weight: 600;
  color: var(--pv2-on-surface);
}

/* Chat messages area */
.rma-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
  max-height: 420px;
  overflow-y: auto;
  padding: 20px 24px;
  background: var(--pv2-bg);
  position: relative;
}


.rma-chat-loading {
  text-align: center;
  padding: 40px;
  color: var(--pv2-muted);
  font-size: 0.84rem;
}

/* Bubbles */
.rma-chat-bubble {
  max-width: 78%;
  padding: 10px 16px;
  border-radius: 14px;
  font-size: 0.84rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.rma-chat-bubble--client {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--pv2-primary), var(--pv2-primary-mid));
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,110,47,.15);
}

.rma-chat-bubble--staff {
  align-self: flex-start;
  background: var(--pv2-card);
  color: var(--pv2-on-surface);
  border-bottom-left-radius: 4px;
  box-shadow: var(--pv2-shadow-sm);
}

/* Meta inside bubble (name + time) */
.rma-chat-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--pv2-font-h);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}

.rma-chat-name { opacity: .7; }
.rma-chat-time { opacity: .5; font-weight: 600; }

/* Staff bubble meta */
.rma-chat-bubble--staff .rma-chat-meta { color: var(--pv2-muted); }

/* Client bubble meta — needs to be visible on green bg */
.rma-chat-bubble--client .rma-chat-meta { color: rgba(255,255,255,.75); }
.rma-chat-bubble--client .rma-chat-name { opacity: 1; }
.rma-chat-bubble--client .rma-chat-time { opacity: .65; }

/* Composer */
.rma-chat-composer {
  display: flex;
  gap: 10px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--pv2-border);
  align-items: flex-end;
  background: var(--pv2-card);
}

.rma-chat-input {
  flex: 1;
  background: var(--pv2-surface-low);
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 0.84rem;
  color: var(--pv2-on-surface);
  outline: none;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  transition: border-color 0.15s ease;
}

.rma-chat-input:focus {
  border-bottom-color: var(--pv2-primary);
}

/* ----------------------------------------------------------
   23. LOJA (Products)
   ---------------------------------------------------------- */
.loja-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

.loja-loading {
  text-align: center;
  padding: 48px;
  color: var(--pv2-muted);
  font-size: 0.88rem;
}

.loja-count {
  font-size: 0.78rem;
  color: var(--pv2-muted);
  margin-bottom: 12px;
}

/* Loja sort — reuse pv2-sort styles */
.loja-sort-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.loja-sort-cols {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.loja-sort-btn {
  font-family: var(--pv2-font-h);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--pv2-muted);
  padding: 5px 10px;
  border-radius: 8px;
  background: none;
  border: none;
  cursor: pointer;
  transition: color .12s, background .12s;
  white-space: nowrap;
}

.loja-sort-btn:hover { color: var(--pv2-on-surface); background: var(--pv2-surface-low); }
.loja-sort-btn.active { color: var(--pv2-primary); background: var(--pv2-primary-muted); font-weight: 700; }
.loja-sort-icon { display: none; }
.loja-sort-btn.active .loja-sort-icon { display: inline; font-size: 0.7rem; margin-left: 2px; }
.loja-sort-btn.active[data-order="desc"] .loja-sort-icon::before { content: '\2193'; }
.loja-sort-btn.active[data-order="asc"] .loja-sort-icon::before { content: '\2191'; }
.loja-sort-btn.active:not([data-order]) .loja-sort-icon::before { content: '\2191'; }

body.pv2-dark .loja-sort-btn:hover { background: rgba(22,163,74,.08); color: #e8f5ec; }
body.pv2-dark .loja-sort-btn.active { color: #4ade80; background: rgba(22,163,74,.12); }

/* Product card */
.loja-card {
  background: var(--pv2-card);
  border-radius: 12px;
  box-shadow: var(--pv2-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.loja-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--pv2-shadow-md);
}

/* Image wrapper (div with img or fallback svg) */
.loja-card-img {
  width: 100%;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--pv2-surface-low);
  padding: 12px;
  overflow: hidden;
}
.loja-card-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.loja-img-fallback { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; color: var(--pv2-muted); }

/* Card body */
.loja-card-body { padding: 12px 16px 4px; display: flex; flex-direction: column; flex: 1; gap: 4px; }
.loja-card-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 2px; }
.loja-card-tag,
.loja-card-marca { font-family: var(--pv2-font-h); font-size: 0.58rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--pv2-muted); background: var(--pv2-surface-low); padding: 2px 6px; border-radius: 4px; }
.loja-card-marca { color: var(--pv2-primary); background: var(--pv2-primary-muted); }
.loja-stock-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-left: auto; }
.loja-stock-dot.green  { background: #16a34a; }
.loja-stock-dot.yellow { background: #eab308; }
.loja-stock-dot.red    { background: #dc2626; }

.loja-card-title { font-family: var(--pv2-font-h); font-size: 0.82rem; font-weight: 700; color: var(--pv2-on-surface); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.loja-card-ref { font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace; font-size: 0.68rem; color: var(--pv2-muted); }
.loja-card-pn { font-size: 0.65rem; color: var(--pv2-muted); }

/* Card footer: price + actions */
.loja-card-footer { padding: 10px 16px 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.loja-card-price { font-family: var(--pv2-font-h); font-size: 1.05rem; font-weight: 800; color: var(--pv2-primary); }
.loja-card-actions { display: flex; gap: 6px; align-items: center; }

/* Qty controls */
.loja-card-qty-ctrl { display: flex; align-items: center; background: var(--pv2-surface-low); border-radius: 8px; overflow: hidden; }
.loja-card-qty-btn { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; font-size: 0.9rem; font-weight: 700; color: var(--pv2-on-surface); cursor: pointer; transition: background .12s; }
.loja-card-qty-btn:hover { background: var(--pv2-surface); }
.loja-card-qty-num { font-family: var(--pv2-font-h); font-size: 0.78rem; font-weight: 700; min-width: 24px; text-align: center; color: var(--pv2-primary); }

/* Extra small button */
.btn-xs { padding: 5px 10px; font-size: 0.65rem; border-radius: 6px; }

/* List view toggle */
.loja-grid.list-view {
  grid-template-columns: 1fr;
}
.loja-grid.list-view .loja-card {
  flex-direction: row;
  align-items: center;
}
.loja-grid.list-view .loja-card-img {
  width: 100px;
  height: 80px;
  flex-shrink: 0;
  border-radius: 8px 0 0 8px;
}
.loja-grid.list-view .loja-card-body {
  flex: 1;
  padding: 10px 16px;
}
.loja-grid.list-view .loja-card-footer {
  padding: 10px 16px;
  flex-shrink: 0;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

/* View toggle */
.loja-view-toggle {
  display: flex;
  gap: 2px;
  background: var(--pv2-card);
  border-radius: 8px;
  padding: 2px;
  box-shadow: var(--pv2-shadow-sm);
  flex-shrink: 0;
  align-self: flex-end;
}

.loja-view-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 30px;
  border-radius: 6px;
  color: var(--pv2-muted);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.12s ease;
}

.loja-view-btn:hover {
  color: var(--pv2-on-surface);
}

.loja-view-btn.active {
  background: var(--pv2-card);
  color: var(--pv2-primary);
  box-shadow: var(--pv2-shadow-sm);
}

.loja-subtab-bar {
  display: flex;
  gap: 8px;
  background: none;
  border-radius: 0;
  padding: 4px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.loja-filters {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-end;
  gap: 10px;
  background: var(--pv2-surface-low);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
}

.loja-subpanel {
  display: none;
}

.loja-subpanel.active {
  display: block;
}

/* ----------------------------------------------------------
   24. LOJA CART SIDEBAR
   ---------------------------------------------------------- */
.loja-cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 28, 48, 0.35);
  z-index: 900;
  display: none;
}

.loja-cart-overlay.open {
  display: block;
}

.loja-cart-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: 380px;
  height: 100vh;
  background: var(--pv2-card);
  box-shadow: -4px 0 24px rgba(11, 28, 48, 0.12);
  display: flex;
  flex-direction: column;
  z-index: 910;
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.loja-cart-sidebar.open {
  transform: translateX(0);
}

.loja-cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
}

.loja-cart-header h3 {
  font-family: var(--pv2-font-h);
  font-size: 1.05rem;
  font-weight: 800;
}

.loja-cart-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 24px;
}

.loja-cart-footer {
  padding: 16px 24px 20px;
  background: var(--pv2-surface-low);
}

.loja-cart-empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--pv2-muted);
  font-size: 0.85rem;
}

.loja-cart-item {
  display: flex;
  gap: 12px;
  padding: 14px 0;
  align-items: flex-start;
  border-bottom: 1px solid var(--pv2-border);
}

.loja-cart-item:last-child {
  border-bottom: none;
}

.loja-cart-item-name {
  font-family: var(--pv2-font-h);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--pv2-on-surface);
  line-height: 1.3;
}

.loja-cart-item-ref {
  font-size: 0.7rem;
  color: var(--pv2-muted);
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

.loja-cart-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 0.88rem;
}

.loja-cart-total-row:last-child {
  font-family: var(--pv2-font-h);
  font-weight: 800;
  font-size: 1rem;
  padding-top: 10px;
  margin-top: 6px;
}

/* Qty controls */
.loja-qty-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--pv2-surface-low);
  color: var(--pv2-on-surface);
  font-size: 0.88rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: background 0.12s ease;
}

.loja-qty-btn:hover {
  background: var(--pv2-surface);
}

.loja-qty-val {
  font-family: var(--pv2-font-h);
  font-size: 0.82rem;
  font-weight: 700;
  min-width: 24px;
  text-align: center;
  display: inline-block;
}

/* ----------------------------------------------------------
   25. LOJA MODALS
   ---------------------------------------------------------- */
.loja-modal {
  max-width: 700px;
}

.loja-modal-body {
  padding: 0 24px 24px;
}

.loja-detail-table {
  width: 100%;
  border-collapse: collapse;
}

.loja-detail-table td {
  padding: 8px 0;
  font-size: 0.84rem;
  vertical-align: top;
}

.loja-detail-table td:first-child {
  color: var(--pv2-muted);
  width: 140px;
  font-weight: 500;
}

.loja-detail-table td:last-child {
  color: var(--pv2-on-surface);
  font-weight: 600;
}

.loja-order-meta {
  background: var(--pv2-surface-low);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}

.loja-order-meta .row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 0.84rem;
}

/* ----------------------------------------------------------
   26. DOWNLOADS
   ---------------------------------------------------------- */
#downloadsContent h3 {
  font-family: var(--pv2-font-h);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--pv2-on-surface);
  margin-bottom: 16px;
  margin-top: 32px;
}

#downloadsContent h3:first-child {
  margin-top: 0;
}

/* ──────────────────────────────────────────────────────────
   NEWS CARDS (panel Notícias)
   ────────────────────────────────────────────────────────── */
.pv2-news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}
.pv2-news-card {
  background: var(--pv2-card);
  border-radius: 12px;
  box-shadow: var(--pv2-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform .15s ease, box-shadow .15s ease;
}
.pv2-news-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--pv2-shadow-md);
}
body.pv2-dark .pv2-news-card { box-shadow: none; border: 1px solid var(--pv2-border); }
.pv2-news-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  background-size: cover;
  background-position: center;
  background-color: var(--pv2-surface-low);
}
.pv2-news-body {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.pv2-news-date {
  font-family: var(--pv2-font-h);
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--pv2-primary);
}
.pv2-news-title {
  font-family: var(--pv2-font-h);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--pv2-on-surface);
  margin: 0;
  letter-spacing: -.01em;
  line-height: 1.25;
}
.pv2-news-text {
  font-size: .84rem;
  color: var(--pv2-on-surface);
  opacity: .85;
  line-height: 1.5;
  white-space: pre-wrap;
}
.pv2-news-actions {
  margin-top: auto;
  padding-top: 6px;
}

/* portal-auth.js renders .dl-card with inline styles referencing the OLD
   style.css vars (--color-surface-white, --color-border, --color-primary,
   --color-text-muted) that don't exist in portal-v2. Override them so the
   cards are visible in both themes. */
#downloadsContent .dl-card {
  background: var(--pv2-card) !important;
  border: 1px solid var(--pv2-border) !important;
  border-radius: 12px !important;
  color: var(--pv2-on-surface) !important;
  box-shadow: var(--pv2-shadow);
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease !important;
}
#downloadsContent .dl-card:hover {
  border-color: var(--pv2-primary) !important;
  box-shadow: var(--pv2-shadow-md) !important;
  transform: translateY(-1px);
}
#downloadsContent .dl-card .dl-muted {
  color: var(--pv2-muted) !important;
}
#downloadsContent .dl-card > span:last-child {
  color: var(--pv2-primary) !important;
}
body.pv2-dark #downloadsContent .dl-card { box-shadow: none; }
body.pv2-dark #downloadsContent .dl-card:hover { box-shadow: var(--pv2-shadow-md) !important; }

/* ----------------------------------------------------------
   27a. CONFIGURADOR — hide portal-auth.js table (we render cards instead) */
#cfgsTableWrap, #cfgsLoading, #cfgsEmpty { display: none !important; }

/* 27b. CONFIGURADOR CARDS
   ---------------------------------------------------------- */
.pv2-cfg-card {
  background: var(--pv2-card);
  border-radius: 12px;
  box-shadow: var(--pv2-shadow);
  margin-bottom: 12px;
  overflow: hidden;
  transition: box-shadow .15s;
}
.pv2-cfg-card:hover { box-shadow: var(--pv2-shadow-md); }

.pv2-cfg-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  cursor: pointer;
}

.pv2-cfg-info, .pv2-cfg-name, .pv2-cfg-machine, .pv2-cfg-price, .pv2-cfg-date,
.pv2-cfg-lines, .pv2-cfg-lines-table td, .pv2-cfg-lines-table th, code {
  user-select: text;
  -webkit-user-select: text;
}

.pv2-cfg-img {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--pv2-surface-low);
  flex-shrink: 0;
  padding: 4px;
}

.pv2-cfg-info { flex: 1; min-width: 0; }
.pv2-cfg-name {
  font-family: var(--pv2-font-h);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--pv2-on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pv2-cfg-machine {
  font-size: 0.78rem;
  color: var(--pv2-muted);
  margin-top: 2px;
}
.pv2-cfg-meta {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-shrink: 0;
}
.pv2-cfg-price {
  font-family: var(--pv2-font-h);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--pv2-primary);
}
.pv2-cfg-date {
  font-size: 0.72rem;
  color: var(--pv2-muted);
}

/* Equipamentos — alinhamento em colunas do meta (data, garantia, fatura, RMA) */
#pv2EquipCards .pv2-cfg-meta {
  display: grid;
  grid-template-columns: 110px 120px 40px 40px;
  align-items: center;
  gap: 10px;
}
#pv2EquipCards .pv2-cfg-meta > * {
  justify-self: center;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Uniformização de fontes em linhas de tabela/cards do portal */
.portal-panel table,
.portal-panel table td,
.portal-panel table th,
.pv2-cfg-card,
.pv2-cfg-card code,
.pv2-cfg-machine code {
  font-family: var(--pv2-font-b);
}
.pv2-cfg-name,
.portal-panel table th,
.pv2-cfg-card .pv2-cfg-price {
  font-family: var(--pv2-font-h);
}

/* Header de colunas alinhado com o grid dos cards */
.pv2-equip-colhead {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 20px 0;
}
.pv2-equip-colhead-spacer {
  flex: 1;
}
.pv2-equip-colhead-meta {
  display: grid;
  grid-template-columns: 110px 120px 40px 40px;
  gap: 10px;
  align-items: center;
}
.pv2-equip-colhead-meta span,
.pv2-equip-colhead-meta .pv2-colhead-btn {
  font-family: var(--pv2-font-h);
  font-size: .6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--pv2-muted);
  text-align: center;
}
.pv2-colhead-btn {
  background: none;
  border: none;
  padding: 4px 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border-radius: 4px;
  transition: background .15s, color .15s;
}
.pv2-colhead-btn:hover { color: var(--pv2-on-surface); background: var(--pv2-surface-low); }
.pv2-colhead-btn.active { color: var(--pv2-primary); }
.pv2-colhead-arrow { font-size: .7rem; line-height: 1; }
@media (max-width: 900px) {
  .pv2-equip-colhead { display: none; }
}
/* Botões icone-only dos equipamentos e licenciamento — mesmo formato de caixa */
.pv2-equip-fat-btn,
.pv2-equip-rma-btn,
.renov-jump-fat,
.renov-jump-proposta {
  width: 36px !important;
  height: 36px !important;
  padding: 0 !important;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 0 !important;
  margin: 0 !important;
  flex-shrink: 0;
}
#pv2EquipCards .pv2-cfg-meta .btn {
  justify-self: center;
}
@media (max-width: 900px) {
  #pv2EquipCards .pv2-cfg-meta {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  #pv2EquipCards .pv2-cfg-meta .btn { font-size: .72rem; padding: 5px 8px; }
}
.pv2-cfg-stale {
  color: #d48a00;
  font-size: 0.72rem;
}
.pv2-cfg-expand-icon {
  font-size: 18px;
  color: var(--pv2-muted);
  transition: transform .2s;
}
.pv2-cfg-card.open .pv2-cfg-expand-icon { transform: rotate(180deg); }

.pv2-cfg-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Expandable lines section */
.pv2-cfg-lines {
  display: none;
  border-top: 1px solid var(--pv2-border);
  padding: 16px 20px 20px;
  background: var(--pv2-surface-low);
}
.pv2-cfg-card.open .pv2-cfg-lines { display: block; }

.pv2-cfg-lines-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.pv2-cfg-lines-table th {
  font-family: var(--pv2-font-h);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pv2-muted);
  padding: 8px 10px;
  text-align: left;
}
.pv2-cfg-lines-table td {
  padding: 8px 10px;
  color: var(--pv2-on-surface);
  border-top: 1px solid var(--pv2-border);
}
.pv2-cfg-lines-table tr:first-child td { border-top: none; }
.pv2-cfg-lines-loading {
  text-align: center;
  padding: 24px;
  color: var(--pv2-muted);
  font-size: 0.82rem;
}

/* Dark mode */
body.pv2-dark .pv2-cfg-card { box-shadow: none; }
body.pv2-dark .pv2-cfg-img { background: rgba(255,255,255,.04); }
body.pv2-dark .pv2-cfg-lines { background: rgba(22,163,74,.04); border-top-color: rgba(22,163,74,.1); }
body.pv2-dark .pv2-cfg-lines-table td { border-top-color: rgba(22,163,74,.06); }

/* ----------------------------------------------------------
   27. RENOVACOES SPECIFIC
   ---------------------------------------------------------- */
.renov-copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 5px;
  background: transparent;
  color: var(--pv2-muted);
  border: none;
  cursor: pointer;
  font-size: 0.72rem;
  transition: background 0.12s ease, color 0.12s ease;
}

.renov-copy-btn:hover {
  background: var(--pv2-surface-low);
  color: var(--pv2-primary);
}

/* ----------------------------------------------------------
   28. FOOTER
   ---------------------------------------------------------- */
.portal-footer {
  background: var(--pv2-surface-low);
  border-top: 1px solid var(--pv2-border);
  padding: 16px 40px;
  margin-left: 256px;
  font-size: 0.75rem;
  color: var(--pv2-muted);
  text-align: center;
}

/* ----------------------------------------------------------
   29. DARK MODE  (body.pv2-dark)
   ---------------------------------------------------------- */

/* Theme toggle button visibility */
.pv2-theme-icon-light,
.pv2-theme-label-light { display: none; }
body.pv2-dark .pv2-theme-icon-dark,
body.pv2-dark .pv2-theme-label-dark { display: none; }
body.pv2-dark .pv2-theme-icon-light,
body.pv2-dark .pv2-theme-label-light { display: inline; }

/* Dark surfaces */
body.pv2-dark {
  --pv2-bg:              #041709;
  --pv2-surface-low:     #0a2914;
  --pv2-surface:         #0f3320;
  --pv2-surface-high:    #133d22;
  --pv2-surface-highest: #1a4a2c;
  --pv2-card:            #071d0d;
  --pv2-on-surface:      #e8f5ec;
  --pv2-on-variant:      #c5e8cc;
  --pv2-muted:           rgba(232,245,236,.40);
  --pv2-border:          rgba(22,163,74,.12);
  --pv2-sidebar-bg:      #061a0b;
  --pv2-sidebar-text:    rgba(232,245,236,.55);
  --pv2-shadow-sm:       0 1px 3px rgba(0,0,0,.20);
  --pv2-shadow:          0 2px 8px rgba(0,0,0,.25);
  --pv2-shadow-md:       0 4px 16px rgba(0,0,0,.30);
  --pv2-shadow-lg:       0 8px 32px rgba(0,0,0,.35);
  --pv2-shadow-modal:    0 12px 48px rgba(0,0,0,.50);
  color-scheme: dark;
}

/* Topbar dark */
body.pv2-dark .pv2-topbar {
  background: rgba(4,23,9,.85);
}

body.pv2-dark .pv2-topbar-search input {
  background: rgba(255,255,255,.06);
  color: #e8f5ec;
}
body.pv2-dark .pv2-topbar-search input::placeholder { color: rgba(232,245,236,.3); }
body.pv2-dark .pv2-topbar-search input:focus {
  background: rgba(255,255,255,.08);
  box-shadow: 0 0 0 2px rgba(22,163,74,.2);
}

/* Sidebar dark */
body.pv2-dark .pv2-brand-logo { filter: brightness(0) invert(1); }
body.pv2-dark .pv2-nav-item.active {
  background: rgba(22,163,74,.12);
  color: #4ade80;
  box-shadow: none;
}
body.pv2-dark .pv2-nav-item:hover { color: #4ade80; }
body.pv2-dark .pv2-nav-sep { background: rgba(22,163,74,.12); }

/* Panel hero */
body.pv2-dark .pv2-panel-hero h2 { color: #e8f5ec; }
body.pv2-dark .pv2-panel-hero p { color: rgba(232,245,236,.5); }

/* Tables */
body.pv2-dark .portal-table-wrap { background: var(--pv2-card); box-shadow: none; }
body.pv2-dark .portal-table th { background: rgba(22,163,74,.07); color: rgba(232,245,236,.6); border-bottom-color: rgba(22,163,74,.12); }
body.pv2-dark .portal-table th.sortable:hover { color: #e8f5ec; background: rgba(22,163,74,.18); }
body.pv2-dark .portal-table td { color: #c5e8cc; border-bottom-color: rgba(22,163,74,.06); }
body.pv2-dark .portal-table tr:hover td { background: rgba(22,163,74,.05); }
body.pv2-dark .portal-table code { background: rgba(22,163,74,.12); color: #4ade80; }
body.pv2-dark .portal-table th[style*="rgba(22,163"] {
  background: rgba(22,163,74,.18) !important;
  color: #4ade80 !important;
}

/* Filters dark */
body.pv2-dark .portal-filters { background: rgba(22,163,74,.05); }
body.pv2-dark .portal-search { background: rgba(255,255,255,.05); color: #e8f5ec; }
body.pv2-dark .portal-search::placeholder { color: rgba(232,245,236,.3); }
body.pv2-dark .portal-search:focus { border-bottom-color: #4ade80; }
body.pv2-dark .portal-search-wrap svg { color: rgba(232,245,236,.35); }
body.pv2-dark .pv2-filter-input { background: rgba(255,255,255,.05); color: #e8f5ec; box-shadow: none; color-scheme: dark; }
body.pv2-dark .pv2-filter-input:focus { box-shadow: 0 0 0 2px rgba(22,163,74,.2); }
body.pv2-dark .pv2-filter-input option,
body.pv2-dark select.pv2-filter-input option,
body.pv2-dark .portal-filter-select option,
body.pv2-dark select option { background: #0a2914 !important; color: #e8f5ec !important; }
body.pv2-dark .portal-filter-select { background: rgba(255,255,255,.05); color: #e8f5ec; color-scheme: dark; }
body.pv2-dark select { accent-color: #4ade80; color-scheme: dark; }
body.pv2-dark select.pv2-filter-input { background: rgba(255,255,255,.05) !important; color: #e8f5ec !important; border: 1px solid rgba(22,163,74,.15); }
body.pv2-dark select.pv2-filter-input option { background: #0a2914 !important; color: #e8f5ec !important; }
body.pv2-dark .pv2-filter-label { color: rgba(232,245,236,.45); }
body.pv2-dark select.pv2-filter-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234ade80' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}
body.pv2-dark .cc-date-input { color-scheme: dark; }

/* Buttons dark */
body.pv2-dark .btn-outline { background: rgba(255,255,255,.05); border-color: rgba(22,163,74,.2); color: #c5e8cc; }
body.pv2-dark .btn-outline:hover { border-color: #4ade80; color: #4ade80; }

/* Badges dark */
body.pv2-dark .badge-ok { background: rgba(22,163,74,.15); color: #86efac; border-color: rgba(22,163,74,.25); }
body.pv2-dark .badge-pending { background: rgba(245,158,11,.12); color: #fcd34d; border-color: rgba(245,158,11,.2); }
body.pv2-dark .badge-inactive { background: rgba(239,68,68,.12); color: #fca5a5; border-color: rgba(239,68,68,.25); }
body.pv2-dark .badge-warn { background: rgba(234,88,12,.12); color: #fdba74; border-color: rgba(234,88,12,.2); }
body.pv2-dark .badge-err { background: rgba(220,38,38,.12); color: #fca5a5; border-color: rgba(220,38,38,.2); }
body.pv2-dark .badge-neutral { background: rgba(255,255,255,.06); color: rgba(232,245,236,.5); border-color: rgba(255,255,255,.08); }

/* Metric cards dark */
body.pv2-dark .pv2-metric-card { box-shadow: none; }

/* CC recibos dark */
body.pv2-dark .cc-row-expand:hover td { background: rgba(22,163,74,.06); }
body.pv2-dark .cc-expand-btn { background: rgba(22,163,74,.12); color: #4ade80; }
body.pv2-dark .cc-expand-btn.open { background: rgba(22,163,74,.25); }
body.pv2-dark .cc-recibos-cell { background: rgba(22,163,74,.04) !important; border-bottom-color: rgba(22,163,74,.1) !important; }
body.pv2-dark .cc-recibos-title { color: #4ade80; }
body.pv2-dark .cc-recibo-item { color: #c5e8cc; border-bottom-color: rgba(22,163,74,.06); }
body.pv2-dark .cc-recibo-val { color: #4ade80; }
body.pv2-dark .cc-valor-neg { color: #f87171; }

/* Sub-tabs dark */
body.pv2-dark .panel-subtabs { background: rgba(22,163,74,.06); }
body.pv2-dark .panel-subtab { color: rgba(232,245,236,.45); }
body.pv2-dark .panel-subtab.active { background: rgba(22,163,74,.15); color: #4ade80; box-shadow: none; }
body.pv2-dark .portal-subtabs { background: rgba(22,163,74,.06); }
body.pv2-dark .portal-subtab { color: rgba(232,245,236,.45); }
body.pv2-dark .portal-subtab.active { background: rgba(22,163,74,.15); color: #4ade80; box-shadow: none; }
body.pv2-dark .renov-a-expirar.active { background: rgba(245,158,11,.12); color: #fcd34d; }
body.pv2-dark .renov-expirado.active { background: rgba(220,38,38,.12); color: #fca5a5; }
body.pv2-dark .renov-ativo.active { background: rgba(22,163,74,.15); color: #86efac; }

/* Enc totals dark */
body.pv2-dark .enc-total-card { box-shadow: none; }

/* Info cards dark */
body.pv2-dark .portal-info-card { box-shadow: none; }

/* Form inputs dark (modals, account) */
body.pv2-dark .form-input { background: rgba(255,255,255,.05); border-color: rgba(22,163,74,.2); color: #e8f5ec; }
body.pv2-dark .form-input::placeholder { color: rgba(232,245,236,.3); }
body.pv2-dark .form-input:focus { border-color: #4ade80; box-shadow: 0 0 0 3px rgba(22,163,74,.15); }
body.pv2-dark .form-select option { background: #0a2914; color: #e8f5ec; }
body.pv2-dark .form-label { color: rgba(232,245,236,.5); }

/* Modals dark */
body.pv2-dark .portal-modal-overlay:not(.hidden) { background: rgba(0,0,0,.6); }
body.pv2-dark .portal-modal { background: #0a2914; box-shadow: var(--pv2-shadow-modal); }
body.pv2-dark .portal-modal-header { border-bottom-color: rgba(22,163,74,.12); }
body.pv2-dark .portal-modal-header h3 { color: #e8f5ec; }
body.pv2-dark .portal-modal-close { color: rgba(232,245,236,.5); }
body.pv2-dark .portal-modal-close:hover { background: rgba(22,163,74,.12); color: #e8f5ec; }
body.pv2-dark .portal-modal-footer { border-top-color: rgba(22,163,74,.12); }
body.pv2-dark .rma-chat-messages { background: #041709; }
body.pv2-dark .rma-chat-messages::before { background: linear-gradient(to bottom, #041709, transparent); }
body.pv2-dark .rma-chat-bubble--staff { background: #0a2914; color: #e8f5ec; box-shadow: none; }
body.pv2-dark .rma-chat-bubble--client { box-shadow: 0 2px 8px rgba(0,0,0,.3); }
body.pv2-dark .rma-chat-composer { background: #071d0d; border-top-color: rgba(22,163,74,.12); }
body.pv2-dark .rma-chat-input { background: rgba(255,255,255,.05); color: #e8f5ec; }
body.pv2-dark .rma-chat-input::placeholder { color: rgba(232,245,236,.3); }
body.pv2-dark .portal-modal .rma-equip-card { background: rgba(22,163,74,.06); }
body.pv2-dark .portal-modal .rma-dropzone { border-color: rgba(22,163,74,.2); }
body.pv2-dark .portal-modal .rma-dropzone:hover { border-color: #4ade80; background: rgba(22,163,74,.05); }

/* Loja cards dark */
body.pv2-dark .loja-card-img { background: rgba(255,255,255,.03); }
body.pv2-dark .loja-card-tag { background: rgba(255,255,255,.06); color: rgba(232,245,236,.5); }
body.pv2-dark .loja-card-marca { background: rgba(22,163,74,.12); color: #4ade80; }
body.pv2-dark .loja-view-toggle { background: rgba(255,255,255,.05); }
body.pv2-dark .loja-view-btn.active { background: rgba(22,163,74,.15); color: #4ade80; box-shadow: none; }
body.pv2-dark .loja-card-qty-ctrl { background: rgba(255,255,255,.06); }

/* Loja cart dark */
body.pv2-dark .loja-cart-sidebar { background: #0a2914; border-color: rgba(22,163,74,.15); }
body.pv2-dark .loja-cart-header { border-bottom-color: rgba(22,163,74,.12); }
body.pv2-dark .loja-cart-header h3 { color: #e8f5ec; }
body.pv2-dark .loja-cart-footer { border-top-color: rgba(22,163,74,.12); }
body.pv2-dark .loja-cart-item { border-bottom-color: rgba(22,163,74,.06); }

/* Notices dark */
body.pv2-dark .portal-notice { color: rgba(232,245,236,.45); }
body.pv2-dark .portal-notice svg { color: rgba(22,163,74,.4); }
body.pv2-dark .portal-page-info { color: rgba(232,245,236,.45); }

/* Auth alert dark */
body.pv2-dark .auth-alert:not(.hidden) { background: rgba(186,26,26,.15); border-color: rgba(186,26,26,.25); color: #fca5a5; }

/* Downloads dark */
body.pv2-dark #downloadsContent h3 { color: rgba(232,245,236,.4) !important; border-bottom-color: rgba(22,163,74,.12) !important; }

/* Footer dark */
body.pv2-dark .portal-footer { background: #061a0b; border-top-color: rgba(22,163,74,.12); }
body.pv2-dark .portal-footer p,
body.pv2-dark .portal-footer a { color: rgba(232,245,236,.35); }

/* Scrollbar dark */
body.pv2-dark ::-webkit-scrollbar-track { background: rgba(255,255,255,.04); }
body.pv2-dark ::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); }
body.pv2-dark ::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.25); }
body.pv2-dark * { scrollbar-color: rgba(255,255,255,.15) rgba(255,255,255,.04); }

/* ----------------------------------------------------------
   30. RESPONSIVE
   ---------------------------------------------------------- */

/* 1024px */
@media (max-width: 1024px) {
  .pv2-sidebar {
    width: 220px;
  }

  .pv2-main {
    margin-left: 220px;
  }

  .portal-footer {
    margin-left: 220px;
  }

  .pv2-content {
    padding: 28px;
  }

  .pv2-topbar {
    padding: 0 28px;
  }
}

/* Renovação proposta modal — header "Proposta nº X" badge (inline-styled by portal-auth.js) */
#renovPropostaBody > div[style*="background"] {
  background: var(--pv2-surface-low) !important;
  color: var(--pv2-on-variant) !important;
  margin: 0 24px 12px !important;
}
#renovPropostaBody > div[style*="background"] strong { color: var(--pv2-on-surface); }
body.pv2-dark #renovPropostaBody > div[style*="background"] {
  background: rgba(255,255,255,.06) !important;
  color: rgba(232,245,236,.75) !important;
}
body.pv2-dark #renovPropostaBody > div[style*="background"] strong { color: #e8f5ec !important; }

/* Renovação proposta modal — option rows */
.renov-proposta-opcao {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin: 0 24px 8px;
  border-radius: 10px;
  background: var(--pv2-surface-low);
  cursor: pointer;
  transition: background .12s, box-shadow .12s;
}
.renov-proposta-opcao:hover { background: var(--pv2-surface); }
.renov-proposta-opcao input[type="radio"] {
  flex-shrink: 0;
  accent-color: var(--pv2-primary);
  cursor: pointer;
}
.renov-proposta-opcao input[type="radio"]:checked ~ * { color: var(--pv2-on-surface); }
.renov-proposta-opcao:has(input:checked) {
  background: var(--pv2-primary-muted);
  box-shadow: inset 0 0 0 1px var(--pv2-primary);
}
.renov-proposta-desc {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--pv2-on-surface);
  min-width: 0;
}
.renov-proposta-preco {
  font-family: var(--pv2-font-h);
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--pv2-primary);
  white-space: nowrap;
  flex-shrink: 0;
}
.renov-proposta-aprovada {
  opacity: .6;
  cursor: default;
}
.renov-proposta-aprovada:hover { background: var(--pv2-surface-low); }
.renov-proposta-aprovada .badge {
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--pv2-primary) !important;
  color: #fff;
  font-weight: 700;
}

body.pv2-dark .renov-proposta-opcao { background: rgba(255,255,255,.04); color: #e8f5ec; }
body.pv2-dark .renov-proposta-opcao:hover { background: rgba(255,255,255,.07); }
body.pv2-dark .renov-proposta-opcao:has(input:checked) {
  background: rgba(22,163,74,.15);
  box-shadow: inset 0 0 0 1px #4ade80;
}
body.pv2-dark .renov-proposta-opcao *,
body.pv2-dark .renov-proposta-desc,
body.pv2-dark .renov-proposta-opcao span { color: #e8f5ec !important; }
body.pv2-dark .renov-proposta-preco { color: #4ade80 !important; }

/* Renovações action buttons — state colors */
.renov-jump-proposta.renov-state-pendente { border-color: #f59e0b !important; color: #d48a00 !important; }
.renov-jump-proposta.renov-state-pendente:hover { background: rgba(245,158,11,.1) !important; }
.renov-jump-proposta.renov-state-aprovada { border-color: var(--pv2-primary) !important; color: var(--pv2-primary) !important; }
.renov-jump-proposta.renov-state-aprovada:hover { background: var(--pv2-primary-muted) !important; }
.renov-jump-proposta.renov-state-pedido   { border-color: #6366f1 !important; color: #4f46e5 !important; }
.renov-jump-proposta.renov-state-pedido:hover { background: rgba(99,102,241,.1) !important; }

body.pv2-dark .renov-jump-proposta.renov-state-pendente { color: #fcd34d !important; border-color: rgba(245,158,11,.4) !important; }
body.pv2-dark .renov-jump-proposta.renov-state-aprovada { color: #4ade80 !important; border-color: rgba(22,163,74,.4) !important; }
body.pv2-dark .renov-jump-proposta.renov-state-pedido   { color: #a5b4fc !important; border-color: rgba(99,102,241,.4) !important; }

/* Dashboard sections (Faturas Vencidas + Últimos Movimentos) */
.pv2-dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 32px;
}

.pv2-dash-section {
  background: var(--pv2-card);
  border-radius: 12px;
  box-shadow: var(--pv2-shadow);
  padding: 20px 22px;
}

body.pv2-dark .pv2-dash-section { box-shadow: none; }

.pv2-dash-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--pv2-border);
}

.pv2-dash-section-header h3 {
  font-family: var(--pv2-font-h);
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--pv2-on-surface);
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
}

.pv2-dash-section-link {
  font-family: var(--pv2-font-h);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--pv2-primary);
  text-decoration: none;
  white-space: nowrap;
}

.pv2-dash-section-link:hover { text-decoration: underline; }

.pv2-dash-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--pv2-border);
}
.pv2-dash-item:last-child { border-bottom: none; }

.pv2-dash-item-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--pv2-surface-low);
  flex-shrink: 0;
}
.pv2-dash-item-icon .material-symbols-outlined { font-size: 16px; color: var(--pv2-muted); }

.pv2-dash-item-info { flex: 1; min-width: 0; }
.pv2-dash-item-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--pv2-on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pv2-dash-item-sub {
  font-size: 0.7rem;
  color: var(--pv2-muted);
  margin-top: 1px;
}

.pv2-dash-item-value {
  font-family: var(--pv2-font-h);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--pv2-on-surface);
  white-space: nowrap;
  flex-shrink: 0;
}
.pv2-dash-item-value.neg { color: #dc2626; }

.pv2-dash-empty {
  text-align: center;
  padding: 24px 12px;
  color: var(--pv2-muted);
  font-size: 0.82rem;
}

@media (max-width: 900px) {
  .pv2-dash-grid { grid-template-columns: 1fr; }
}

/* ──────────────────────────────────────────────────────────
   Dashboard KPI cards (enhanced — icon + sub)
   ────────────────────────────────────────────────────────── */
.pv2-kpi-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.pv2-kpi-grid .pv2-metric-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}
.pv2-metric-body { flex: 1; min-width: 0; }
.pv2-metric-sub {
  margin-top: 8px;
  font-size: .72rem;
  color: var(--pv2-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 18px;
}
.pv2-metric-sub .material-symbols-outlined { font-size: 14px; }
.pv2-metric-ico {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.pv2-metric-ico .material-symbols-outlined { font-size: 22px; }
.pv2-metric-ico-danger { background: rgba(220,38,38,.1);  color: #dc2626; }
.pv2-metric-ico-warn   { background: rgba(245,158,11,.12); color: #d97706; }
.pv2-metric-ico-ok     { background: rgba(16,185,129,.12); color: #059669; }
.pv2-metric-ico-info   { background: rgba(59,130,246,.12); color: #2563eb; }
.pv2-metric-ico-purple { background: rgba(124,58,237,.12); color: #7c3aed; }
body.pv2-dark .pv2-metric-ico-danger { color: #f87171; }
body.pv2-dark .pv2-metric-ico-warn   { color: #fcd34d; }
body.pv2-dark .pv2-metric-ico-ok     { color: #4ade80; }
body.pv2-dark .pv2-metric-ico-info   { color: #93c5fd; }
body.pv2-dark .pv2-metric-ico-purple { color: #c4b5fd; }

/* ──────────────────────────────────────────────────────────
   Dashboard split (chart + recent list) + card containers
   ────────────────────────────────────────────────────────── */
.pv2-dash-split {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-top: 20px;
}
@media (max-width: 1000px) {
  .pv2-dash-split { grid-template-columns: 1fr; }
}

.pv2-dash-card {
  background: var(--pv2-card);
  border-radius: 12px;
  padding: 20px 22px;
  box-shadow: var(--pv2-shadow);
  margin-top: 20px;
}
.pv2-dash-split .pv2-dash-card { margin-top: 0; }
body.pv2-dark .pv2-dash-card { box-shadow: none; }

.pv2-dash-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  gap: 12px;
}
.pv2-dash-card-header h3 {
  font-family: var(--pv2-font-h);
  font-size: 1rem;
  font-weight: 800;
  color: var(--pv2-on-surface);
  margin: 0 0 2px 0;
  letter-spacing: -0.01em;
}
.pv2-dash-card-header p {
  margin: 0;
  font-size: .74rem;
  color: var(--pv2-muted);
}

/* Chart */
.pv2-chart-wrap { width: 100%; }
.pv2-chart-svg { display: block; max-width: 100%; height: auto; }
.pv2-chart-grid { stroke: var(--pv2-border); stroke-width: 1; stroke-dasharray: 2 3; opacity: .6; }
.pv2-chart-axis { font-size: 10px; fill: var(--pv2-muted); font-family: var(--pv2-font-b); }
.pv2-chart-line { fill: none; stroke: var(--pv2-primary); stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; }
.pv2-chart-dot  { fill: var(--pv2-card); stroke: var(--pv2-primary); stroke-width: 2; }
.pv2-chart-stop-0 { stop-color: var(--pv2-primary); stop-opacity: .30; }
.pv2-chart-stop-1 { stop-color: var(--pv2-primary); stop-opacity: 0;   }
body.pv2-dark .pv2-chart-stop-0 { stop-opacity: .20; }
.pv2-chart-hover-line { stroke: var(--pv2-primary); stroke-width: 1; stroke-dasharray: 3 3; opacity: .6; pointer-events: none; }
.pv2-chart-hover-dot  { fill: var(--pv2-primary); stroke: var(--pv2-card); stroke-width: 2.5; pointer-events: none; }
.pv2-chart-tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--pv2-on-surface);
  color: var(--pv2-card);
  padding: 7px 11px;
  border-radius: 8px;
  font-size: .72rem;
  font-family: var(--pv2-font-b);
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,.18);
  z-index: 5;
  transition: opacity .12s;
}
.pv2-chart-tooltip-label {
  font-family: var(--pv2-font-h);
  font-size: .66rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  opacity: .65;
  margin-bottom: 2px;
}
.pv2-chart-tooltip-value {
  font-family: var(--pv2-font-h);
  font-weight: 700;
  font-size: .85rem;
}
body.pv2-dark .pv2-chart-tooltip { background: #e6edf7; color: #0b1c30; }

/* Simple list (Encomendas Recentes) */
.pv2-dash-simple-list { display: flex; flex-direction: column; }
.pv2-dash-simple-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--pv2-border);
  text-decoration: none;
  color: inherit;
  transition: padding-left .15s ease;
}
.pv2-dash-simple-item:hover { padding-left: 4px; background: var(--pv2-surface-low); }
.pv2-dash-simple-item:last-child { border-bottom: none; }
.pv2-dash-simple-item-info .name {
  font-family: var(--pv2-font-h);
  font-weight: 700;
  font-size: .9rem;
  color: var(--pv2-on-surface);
}
.pv2-dash-simple-item-info .sub {
  font-size: .72rem;
  color: var(--pv2-muted);
  margin-top: 1px;
}
.pv2-dash-simple-item-right { text-align: right; display: flex; flex-direction: column; gap: 3px; align-items: flex-end; }
.pv2-dash-simple-item-right .val {
  font-family: var(--pv2-font-h);
  font-weight: 700;
  color: var(--pv2-on-surface);
  font-size: .92rem;
}

/* Table (Faturas Recentes) */
.pv2-dash-table-wrap { overflow-x: auto; }
.pv2-dash-table { width: 100%; border-collapse: collapse; }
.pv2-dash-table th {
  text-align: left;
  font-family: var(--pv2-font-h);
  font-size: .66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--pv2-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--pv2-border);
  white-space: nowrap;
}
.pv2-dash-table td {
  padding: 12px;
  font-size: .85rem;
  color: var(--pv2-on-surface);
  border-bottom: 1px solid var(--pv2-border);
  vertical-align: middle;
}
.pv2-dash-table tr:last-child td { border-bottom: none; }
.pv2-dash-table tbody tr:hover td { background: var(--pv2-surface-low); }
.pv2-dash-table td.pv2-dash-empty { text-align: center; color: var(--pv2-muted); }

/* Hamburger button — hidden by default (desktop) */
.pv2-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: none;
  border: none;
  cursor: pointer;
  gap: 4px;
  flex-shrink: 0;
}
.pv2-hamburger:hover { background: var(--pv2-surface-low); }
.pv2-hamburger span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--pv2-on-surface);
  border-radius: 2px;
  transition: transform .2s, opacity .2s;
}

/* Backdrop (mobile sidebar) */
.pv2-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 28, 48, 0.45);
  z-index: 199;
}
.pv2-sidebar-backdrop.open { display: block; }

/* ─────── 768px — tablet / phone ─────── */
@media (max-width: 768px) {
  /* Show hamburger */
  .pv2-hamburger { display: flex; }

  /* Sidebar → drawer (hidden until .open) */
  .pv2-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 200;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 0 0 40px rgba(0,0,0,.15);
  }
  .pv2-sidebar.open { transform: translateX(0); }

  body.pv2-dark .pv2-sidebar { box-shadow: 0 0 40px rgba(0,0,0,.4); }
  body.pv2-dark .pv2-hamburger span { background: #e8f5ec; }
  body.pv2-dark .pv2-hamburger:hover { background: rgba(255,255,255,.05); }

  /* Layout stacked */
  .pv2-layout { flex-direction: column; }
  .pv2-main { margin-left: 0; min-height: 0; }
  .portal-footer { margin-left: 0; padding: 14px 0; font-size: 0.7rem; text-align: center; }

  /* Content */
  .pv2-content { padding: 16px; }

  /* Topbar — compact */
  .pv2-topbar { padding: 0 14px; height: 56px; gap: 8px; }
  .pv2-topbar-search { max-width: 100%; flex: 1; }
  .pv2-topbar-search input { font-size: 0.78rem; padding: 7px 12px 7px 34px; }
  .pv2-topbar-sep { display: none; }
  .pv2-topbar-user-info { display: none; }
  .pv2-topbar-user { padding: 4px; }
  .pv2-topbar-icon { width: 34px; height: 34px; }

  /* Panel hero — stacks title above actions */
  .pv2-panel-hero { flex-direction: column; align-items: flex-start; gap: 12px; }
  .pv2-panel-hero h2 { font-size: 1.4rem; }
  .pv2-panel-hero p { font-size: 0.82rem; }

  /* Cards: meta wraps below info */
  .pv2-cfg-header { flex-wrap: wrap; gap: 10px; padding: 12px 14px; }
  .pv2-cfg-info { flex: 1 1 100%; min-width: 0; }
  .pv2-cfg-name { white-space: normal; }
  .pv2-cfg-machine { white-space: normal; line-height: 1.4; }
  .pv2-cfg-meta { flex: 1 1 100%; justify-content: space-between; align-items: center; gap: 8px !important; flex-wrap: wrap; }
  .pv2-cfg-img { width: 40px; height: 40px; }
  .pv2-cfg-expand-icon { flex-shrink: 0; }

  /* Metric cards */
  .pv2-metrics-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
  .pv2-metric-card { padding: 12px 14px; }
  .pv2-metric-value { font-size: 1.15rem !important; }
  .pv2-metric-label { font-size: 0.58rem; }
  #ccSummary { grid-template-columns: repeat(2, 1fr) !important; }

  /* Filters stack */
  .portal-filters, .cc-filters {
    flex-direction: column;
    align-items: stretch;
    padding: 10px;
    gap: 8px;
    overflow: visible;
  }
  .portal-search-wrap, .pv2-filter-group { width: 100%; min-width: 0; flex: 1 1 100%; }
  .pv2-filter-input, .portal-search { width: 100%; }
  .portal-filters .btn-outline { width: 100%; justify-content: center; }

  /* Sort bar — wraps */
  .pv2-sort-bar, .loja-sort-cols {
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 4px;
  }
  .pv2-sort-label { width: 100%; margin-bottom: 2px; }
  .pv2-sort-btn, .loja-sort-btn { font-size: 0.66rem; padding: 4px 8px; }

  /* Sub-tabs — horizontal scroll */
  .portal-subtabs, .panel-subtabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding: 3px;
  }
  .portal-subtab, .panel-subtab { font-size: 0.65rem; padding: 6px 10px; white-space: nowrap; }

  /* Info cards (Empresa / Conta) */
  .portal-info-grid { grid-template-columns: 1fr; gap: 12px; }
  .portal-info-card { padding: 18px; }

  /* Loja */
  .loja-cart-sidebar { width: 100%; }
  .loja-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .loja-view-toggle { align-self: stretch; }
  .loja-grid.list-view .loja-card { flex-direction: column; }
  .loja-grid.list-view .loja-card-img { width: 100%; height: 120px; border-radius: 12px 12px 0 0; }
  .loja-grid.list-view .loja-card-footer { flex-direction: row; align-items: center; }

  /* Modals */
  .portal-modal-overlay:not(.hidden) { padding: 12px; align-items: flex-end; }
  .portal-modal { max-width: 100%; max-height: 90vh; border-radius: 14px; }
  .portal-modal-header { padding: 16px 18px 12px; }
  .portal-modal-header h3 { font-size: 1rem; }
  .portal-modal-body { padding: 0 18px 18px; }
  .portal-modal-footer { padding: 12px 18px 16px; flex-wrap: wrap; }
  .portal-modal-footer .btn { flex: 1; justify-content: center; }

  /* Chat modal */
  .portal-modal--chat .portal-modal { max-width: 100%; max-height: 95vh; }
  .rma-chat-messages { max-height: 55vh; padding: 16px; }
  .rma-chat-bubble { max-width: 88%; font-size: 0.82rem; }
  .rma-chat-composer { padding: 12px 16px; }

  /* Hide hover-only table styles */
  .portal-table { font-size: 0.78rem; }
  .portal-table th, .portal-table td { padding: 8px 10px; }

  /* Detail pages — fatura / encomenda / recibo (have inline max-width/padding) */
  main.pv2-content[style*="max-width"] { padding: 16px !important; max-width: 100% !important; }

  /* Topbar detail pages — shrink buttons */
  .pv2-topbar .btn.btn-outline.btn-sm { padding: 6px 10px; font-size: 0.68rem; }
  .pv2-topbar h1.pv2-page-title { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }

  /* CC row expand table */
  .cc-recibos-inner { padding: 8px 10px 10px 20px; }
  .pv2-cfg-lines { padding: 12px 14px 14px; overflow-x: auto; }
  .pv2-cfg-lines-table { min-width: 480px; font-size: 0.75rem; }
}

/* ─────── 480px — small phone ─────── */
@media (max-width: 480px) {
  .pv2-content { padding: 12px; }
  .pv2-topbar { padding: 0 10px; height: 52px; }
  .pv2-topbar-right { gap: 2px; }
  .pv2-topbar-icon { width: 30px; height: 30px; }
  .pv2-topbar-avatar { width: 28px; height: 28px; }

  .pv2-panel-hero h2 { font-size: 1.2rem; }
  .pv2-panel-hero p { font-size: 0.75rem; }

  /* Metric cards single column */
  .pv2-metrics-grid { grid-template-columns: 1fr !important; }
  #ccSummary { grid-template-columns: 1fr !important; }

  /* Cards more compact */
  .pv2-cfg-card { margin-bottom: 8px; }
  .pv2-cfg-header { padding: 10px 12px; gap: 8px; }
  .pv2-cfg-name { font-size: 0.82rem; }
  .pv2-cfg-machine { font-size: 0.72rem; }
  .pv2-cfg-price { font-size: 0.95rem; }
  .pv2-cfg-img { width: 36px; height: 36px; }

  /* Dropdown menus wider */
  .pv2-dropdown-menu { min-width: 200px; }

  /* Nav items smaller */
  .pv2-nav-item .pv2-nav-label { font-size: 0.58rem; }

  /* Footer super compact */
  .portal-footer { padding: 10px 14px; }
  .portal-footer > div { flex-direction: column; gap: 4px; }
}

/* 480px */
@media (max-width: 480px) {
  .portal-table td:nth-child(n+4),
  .portal-table th:nth-child(n+4) {
    display: none;
  }

  .pv2-content {
    padding: 14px;
  }

  .pv2-topbar {
    padding: 0 14px;
    height: 56px;
  }

  .pv2-panel-hero-text h2 {
    font-size: 1.25rem;
  }

  .pv2-metric-card {
    padding: 14px 16px;
  }

  .pv2-metric-value {
    font-size: 1.4rem;
  }

  .loja-grid {
    grid-template-columns: 1fr;
  }
}

/* PRINT */
@media print {
  .pv2-sidebar,
  .pv2-topbar,
  .portal-footer,
  .pv2-panel-hero-actions,
  .portal-filters,
  .cc-filters,
  .portal-pagination,
  .btn,
  .loja-cart-overlay,
  .loja-cart-sidebar {
    display: none !important;
  }

  .pv2-main {
    margin-left: 0;
  }

  .pv2-content {
    padding: 0;
  }

  body.pv2-body {
    background: #fff;
    color: #000;
  }

  .portal-table-wrap {
    box-shadow: none;
  }

  .portal-table th {
    background: #f5f5f5;
  }

  .portal-table td {
    border-bottom-color: #e0e0e0;
  }

  .pv2-metric-card,
  .portal-info-card {
    box-shadow: none;
    border: 1px solid #e0e0e0;
  }
}

/* ----------------------------------------------------------
   30. PORTAL-AUTH.JS COMPATIBILITY
   ---------------------------------------------------------- */
.pv2-nav-item.portal-tab {
  transition: all 0.15s ease;
}

.pv2-nav-item.portal-tab.active {
  background: var(--pv2-card) !important;
  color: var(--pv2-primary) !important;
  box-shadow: var(--pv2-shadow-sm);
}
