*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Grid System ─────────────────────────────────────── */
.row {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--row-gap, 12px);
}

.col-1  { grid-column: span 1; }
.col-2  { grid-column: span 2; }
.col-3  { grid-column: span 3; }
.col-4  { grid-column: span 4; }
.col-5  { grid-column: span 5; }
.col-6  { grid-column: span 6; }
.col-7  { grid-column: span 7; }
.col-8  { grid-column: span 8; }
.col-9  { grid-column: span 9; }
.col-10 { grid-column: span 10; }
.col-11 { grid-column: span 11; }
.col-12 { grid-column: span 12; }

/* Gap variants */
.row-gap-8  { --row-gap: 8px; }
.row-gap-16 { --row-gap: 16px; }
.row-gap-24 { --row-gap: 24px; }

/* Alinhamento vertical */
.row-top    { align-items: start; }
.row-center { align-items: center; }
.row-bottom { align-items: end; }
.row-stretch { align-items: stretch; }

.p-0 { padding: 0px;}
.m-0 { margin: 0px; }

.m-b-0 { margin-bottom: 0px; }
.m-b-1 { margin-bottom: 5px; }
.m-b-2 { margin-bottom: 10px; }
.m-b-3 { margin-bottom: 15px; }

.m-t-0 { margin-top: 0px; }
.m-t-1 { margin-top: 5px; }
.m-t-2 { margin-top: 10px; }
.m-t-3 { margin-top: 15px; }

.text-start { text-align: left; }
.text-end   { text-align: right; }
.text-center { text-align: center; }
.text-justify { text-align: justify; }

@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter-variable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Inter';
  src: url('../fonts/inter-variable-italic.woff2') format('woff2');
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'Paper Mono';
  src: url('../fonts/paper-mono-regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

.hide {
    display: none;
}

/* Responsivo — abaixo de 768px tudo vira coluna única */
@media (max-width: 768px) {
  [class*="col-"] { grid-column: span 12; }
}

/* ── Tokens ──────────────────────────────────────────── */
:root {
  --surface-base:     #FFFFFF;
  --surface-grouped:  #F5F5F7;
  --surface-inset:    #EBEBED;
  --surface-input:    #F5F5F7;
  --surface-heatmap:  #F9F9FB;

  --ink-primary:   #1C1C1E;
  --ink-secondary: #3A3A3C;
  --ink-tertiary:  #636366;
  --ink-muted:     #AEAEB2;

  --border:         rgba(0, 0, 0, 0.08);
  --border-soft:    rgba(0, 0, 0, 0.04);
  --border-strong:  rgba(0, 0, 0, 0.14);
  --border-focus:   #0066cc70;
  --focus-ring:     rgba(0, 102, 204, 0.2);

  --accent:         #0066CC;
  --accent-soft:    rgba(0, 102, 204, 0.08);
  --accent-mid:     rgba(0, 102, 204, 0.18);

  --success:     #34C759;
  --warning:     #FF9500;
  --danger:      #FF3B30;
  --danger-soft: rgba(255, 59, 48, 0.08);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  --font-mono: 'Paper Mono', monospace;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
}

[data-theme="dark"] {
  --surface-base:     #1C1C1E;
  --surface-grouped:  #000000;
  --surface-inset:    #2C2C2E;
  --surface-input:    #2C2C2E;
  --surface-heatmap:  #141414;

  --ink-primary:   #F5F5F7;
  --ink-secondary: #D1D1D6;
  --ink-tertiary:  #8E8E93;
  --ink-muted:     #48484A;

  --border:         rgba(255, 255, 255, 0.08);
  --border-soft:    rgba(255, 255, 255, 0.04);
  --border-strong:  rgba(255, 255, 255, 0.13);
  --border-focus:   #0066ccc4;
  --focus-ring:     rgba(64, 156, 255, 0.18);

  --accent:         #409CFF;
  --accent-soft:    rgba(64, 156, 255, 0.12);
  --accent-mid:     rgba(64, 156, 255, 0.22);

  --success:     #32D74B;
  --warning:     #FF9F0A;
  --danger:      #FF453A;
  --danger-soft: rgba(255, 69, 58, 0.10);
}

/* ── Base ────────────────────────────────────────────── */
body {
  font-family: var(--font);
  background: var(--surface-grouped);
  color: var(--ink-primary);
  min-height: 100vh;
  display: flex;
  -webkit-font-smoothing: antialiased;
}

/* Login page centers content */
body.login-page {
  align-items: center;
  justify-content: center;
  background-image: url('../img/bg-auth.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* ── Theme toggle ────────────────────────────────────── */
.theme-toggle {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface-base);
  color: var(--ink-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: var(--surface-grouped);
  color: var(--ink-primary);
}

.theme-toggle svg { width: 15px; height: 15px; pointer-events: none; }

/* Fixed position only on login page */
body.login-page .theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
}

/* Theme icon visibility */
.icon-sun  { display: none; }
.icon-moon { display: block; }
[data-theme="dark"] .icon-sun  { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
  width: 216px;
  flex-shrink: 0;
  background: var(--surface-base);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: visible;
  transition: width 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-top {
  padding: 16px 16px 14px;
  max-height: 52px;
  border-bottom: 1px solid var(--border-soft);
  transition: padding 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Brand row */
.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

/* Toggle button */
.sidebar-toggle {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: none;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, opacity 0.15s;
  opacity: 0;
}

.sidebar:hover .sidebar-toggle,
.sidebar-toggle:focus-visible { opacity: 1; }

.sidebar-toggle:hover { background: var(--surface-grouped); color: var(--ink-primary); }
.sidebar-toggle svg {
  width: 11px;
  height: 11px;
  pointer-events: none;
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Sidebar mini mode ───────────────────────────────── */
body.sidebar-mini .sidebar {
  width: 56px;
  overflow: visible;
}

/* Brand: só o favicon centrado */
body.sidebar-mini .sidebar-top {
  padding: 14px 0 12px;
}

body.sidebar-mini .sidebar-brand {
  justify-content: center;
}

/* Toggle invisível no mini — só aparece no peek */
body.sidebar-mini .sidebar-toggle {
  display: none;
}

/* Nav */
body.sidebar-mini .nav-section { padding: 8px 4px 0; }
body.sidebar-mini .nav-label   { display: none; }

body.sidebar-mini .nav-item {
  justify-content: center;
  padding: 9px 0;
  gap: 0;
  width: 100%;
}

body.sidebar-mini .nav-item svg {
  flex-shrink: 0;
}

/* Footer */
body.sidebar-mini .sidebar-footer {
  padding: 12px 0;
  justify-content: center;
  gap: 0;
}

/* Text elements que saem com animação */
.nav-text,
.sidebar-footer-info {
  overflow: hidden;
  white-space: nowrap;
  max-width: 200px;
  transition: max-width 0.22s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.15s ease;
}

body.sidebar-mini .nav-text,
body.sidebar-mini .sidebar-footer-info {
  max-width: 0;
  opacity: 0;
}

/* Tooltips in mini mode */
body.sidebar-mini .nav-item {
  position: relative;
}

body.sidebar-mini .nav-item::after {
  content: attr(data-label);
  position: fixed;
  left: 68px;
  background: var(--ink-primary);
  color: var(--surface-base);
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font);
  padding: 5px 10px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
  z-index: 200;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

body.sidebar-mini .nav-item:hover::after { opacity: 1; }

.logomark {
  background: var(--ink-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.logomark svg { color: #fff; }

/* Sidebar logomark — imagens reais */
.sidebar .logomark {
  background: none;
  border-radius: 0;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.logo-img {
  height: 28px;
  width: auto;
  display: block;
  object-fit: contain;
}

.logo-favicon {
  width: 28px;
  height: 28px;
  object-fit: contain;
  display: none;
}

/* Troca light/dark */
.logo-dark-img { display: none; }
[data-theme="dark"] .logo-light-img { display: none; }
[data-theme="dark"] .logo-dark-img  { display: block; }

/* Mini: mostra favicon, esconde logo full */
body.sidebar-mini .logo-img     { display: none; }
body.sidebar-mini .logo-favicon { display: block; }

/* Login card logomark — large */
.card .logomark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  margin-bottom: 14px;
}

.app-name { font-size: 13px; font-weight: 600; letter-spacing: -0.01em; }
.app-sub  { font-size: 11px; color: var(--ink-muted); margin-top: 1px; }

.nav-section { padding: 12px 10px 0; }

.nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding: 0 6px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--ink-secondary);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.1s;
}

.nav-item:hover { background: var(--surface-grouped); }

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; opacity: 0.6; }
.nav-item.active svg { opacity: 1; }

.sidebar-spacer { flex: 1; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--surface-grouped);
  border: 1px solid var(--border);
  font-size: 11px; font-weight: 600;
  color: var(--ink-tertiary);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.avatar-name { font-size: 12px; font-weight: 500; }
.avatar-role { font-size: 10px; color: var(--ink-muted); }

/* ── Profile footer ──────────────────────────────────── */
.sidebar-footer {
  text-decoration: none;
  color: inherit;
  transition: background 0.12s;
}

.sidebar-footer:hover { background: var(--surface-grouped); }

/* ── Sidebar peek (hover expand no mini mode) ────────── */
body.sidebar-mini.sidebar-peek .sidebar {
  width: 216px;
  margin-right: -160px;          /* flutua sobre o conteúdo sem empurrá-lo */
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.07);
  z-index: 30;
}

body.sidebar-mini.sidebar-peek .sidebar-top {
  padding: 16px 16px 14px;
  display: block;
}

body.sidebar-mini.sidebar-peek .sidebar-brand {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

body.sidebar-mini.sidebar-peek .sidebar-toggle {
  display: flex;
  opacity: 1;
}

body.sidebar-mini.sidebar-peek .sidebar-toggle svg {
  transform: rotate(180deg);
}

body.sidebar-mini.sidebar-peek .nav-section    { padding: 12px 10px 0; }
body.sidebar-mini.sidebar-peek .nav-label      { display: block; }
body.sidebar-mini.sidebar-peek .nav-item       { justify-content: flex-start; padding: 7px 8px; width: auto; gap: 8px; }
body.sidebar-mini.sidebar-peek .sidebar-footer { padding: 12px 16px; justify-content: flex-start; gap: 10px; }

/* Mostra logo full durante o peek */
body.sidebar-mini.sidebar-peek .logo-favicon                              { display: none !important; }
body.sidebar-mini.sidebar-peek .logo-light-img                            { display: block !important; }
[data-theme="dark"] body.sidebar-mini.sidebar-peek .logo-light-img        { display: none !important; }
[data-theme="dark"] body.sidebar-mini.sidebar-peek .logo-dark-img         { display: block !important; }

body.sidebar-mini.sidebar-peek .nav-text,
body.sidebar-mini.sidebar-peek .sidebar-footer-info {
  max-width: 200px;
  opacity: 1;
}

/* desabilita tooltips durante o peek */
body.sidebar-mini.sidebar-peek .nav-item::after { display: none; }

/* ── Main ────────────────────────────────────────────── */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ── Topbar ──────────────────────────────────────────── */
.topbar {
  height: 52px;
  background: var(--surface-base);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-left { display: flex; align-items: center; gap: 16px; }

.page-title { font-size: 15px; font-weight: 600; letter-spacing: -0.015em; }

/* ── Location selector ───────────────────────────────── */
.location-selector { position: relative; }

.location-pill {
  display: flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  font-size: 12px;
  color: var(--ink-secondary);
  cursor: pointer;
  background: var(--surface-base);
  user-select: none;
  transition: border-color 0.15s;
}

.location-pill:hover { border-color: var(--accent); color: var(--ink-primary); }
.location-pill.open  { border-color: var(--accent); color: var(--ink-primary); }
.location-pill svg   { opacity: 0.5; flex-shrink: 0; }

.location-pill .chevron { transition: transform 0.18s ease; }
.location-pill.open .chevron { transform: rotate(180deg); }

.location-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 260px;
  background: var(--surface-base);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  overflow: hidden;
}

.location-dropdown.open { display: block; }

.loc-search-wrap {
  position: relative;
  padding: 8px;
  border-bottom: 1px solid var(--border-soft);
}

.loc-search {
  width: 100%;
  padding: 6px 10px 6px 30px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface-inset);
  font-size: 12px;
  font-family: var(--font);
  color: var(--ink-primary);
  outline: none;
  transition: border-color 0.15s;
}

.loc-search::placeholder { color: var(--ink-muted); }
.loc-search:focus { border-color: var(--accent); }

.loc-search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--ink-muted);
}

.loc-list {
  padding: 5px;
  max-height: 260px;
  overflow-y: auto;
}

.loc-empty {
  display: none;
  padding: 20px 8px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-muted);
}

.loc-group-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding: 6px 8px 4px;
}

.loc-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: var(--r-sm);
  font-size: 12px;
  color: var(--ink-secondary);
  cursor: pointer;
  transition: background 0.1s;
}

.loc-option:hover    { background: var(--surface-grouped); }
.loc-option.selected { color: var(--accent); font-weight: 500; }

.loc-option-icon {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: var(--surface-grouped);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.loc-option-icon svg { width: 11px; height: 11px; opacity: 0.55; }
.loc-option.selected .loc-option-icon { background: var(--accent-soft); }
.loc-option.selected .loc-option-icon svg { opacity: 1; color: var(--accent); }

.loc-option-info { flex: 1; min-width: 0; }
.loc-option-name { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loc-option-sub  { font-size: 10px; color: var(--ink-muted); margin-top: 1px; }

.loc-check {
  width: 14px; height: 14px;
  flex-shrink: 0;
  color: var(--accent);
  opacity: 0;
}

.loc-option.selected .loc-check { opacity: 1; }

.loc-divider { height: 1px; background: var(--border-soft); margin: 4px 0; }

/* ── Live indicator ──────────────────────────────────── */
.live-indicator {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 500;
  color: var(--success);
}

.live-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--success);
  animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

/* ── Topbar right ────────────────────────────────────── */
.topbar-right { display: flex; align-items: center; gap: 10px; }

.time-range {
  display: flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.tr-btn {
  padding: 4px 12px;
  font-size: 12px;
  color: var(--ink-tertiary);
  cursor: pointer;
  border-right: 1px solid var(--border);
  background: var(--surface-base);
  font-family: var(--font);
  border-top: none; border-bottom: none; border-left: none;
}

.tr-btn:last-child { border-right: none; }
.tr-btn.active { background: var(--ink-primary); color: var(--surface-grouped); }
.tr-btn:hover:not(.active) { background: var(--surface-grouped); color: var(--ink-secondary); }

/* ── Logout button ───────────────────────────────────── */
.btn-logout {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface-base);
  color: var(--ink-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.btn-logout svg { width: 15px; height: 15px; pointer-events: none; }

.btn-logout:hover {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger);
}

/* ── Content ─────────────────────────────────────────── */
.content {
  padding: 20px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Metric Strip ────────────────────────────────────── */

.mcard {
  background: var(--surface-base);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 18px;
}

.mcard-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 6px;
}

.mcard-value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.04em;
  color: var(--ink-primary);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin-bottom: 6px;
}

.mcard-delta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--ink-muted);
}

.up   { color: var(--success); }
.down { color: var(--danger); }

/* ── Main grid ───────────────────────────────────────── */
.panel {
  background: var(--surface-base);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  display: flex;
  flex-direction: column;
}

.panel-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-shrink: 0;
}

.panel-title { font-size: 13px; font-weight: 600; letter-spacing: -0.01em; }
.panel-sub   { font-size: 11px; color: var(--ink-muted); margin-top: 2px; }

.panel-body { padding: 14px 18px; flex: 1; }

/* ── Heatmap ─────────────────────────────────────────── */
.heatmap-wrap {
  position: relative;
  width: 100%;
  height: 300px;
  background: var(--surface-heatmap);
  border-radius: var(--r-sm);
  overflow: hidden;
}

#heatmapCanvas { width: 100%; height: 100%; display: block; }

.cam-badge {
  position: absolute;
  background: rgba(28, 28, 30, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  font-size: 10px;
  font-weight: 500;
  font-family: var(--font-mono);
  padding: 3px 8px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.cam-badge::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.heat-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.heat-legend-label { font-size: 10px; color: var(--ink-muted); }

.heat-legend-bar {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    rgba(0, 102, 204, 0.2),
    rgba(255, 149, 0, 0.55),
    rgba(255, 59, 48, 0.82)
  );
}

/* ── Right column ────────────────────────────────────── */
.right-col { display: flex; flex-direction: column; gap: 12px; }

/* ── Gender panel ────────────────────────────────────── */
.gender-combined {
  display: flex;
  height: 7px;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 14px;
}

.gcol-m { background: var(--ink-primary); }
.gcol-f { background: var(--ink-tertiary); }

.gender-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.gender-row:last-child { margin-bottom: 0; }

.gender-lbl { font-size: 12px; color: var(--ink-secondary); width: 60px; flex-shrink: 0; }

.gender-track {
  flex: 1;
  height: 5px;
  background: var(--surface-grouped);
  border-radius: 3px;
  overflow: hidden;
}

.gender-fill { height: 100%; border-radius: 3px; }

.gender-pct {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-secondary);
  font-family: var(--font-mono);
  width: 30px;
  text-align: right;
}

.divider {
  height: 1px;
  background: var(--border-soft);
  margin: 10px 0;
}

.confidence-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.conf-label { font-size: 11px; color: var(--ink-muted); }

.conf-value {
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-mono);
}

/* ── Zones panel ─────────────────────────────────────── */
.zone-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-soft);
}

.zone-row:last-child { border-bottom: none; }

.zone-name-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-secondary);
}

.zone-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-hot  { background: var(--danger); }
.dot-warm { background: var(--warning); }
.dot-cool { background: var(--accent); }

.zone-time {
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--ink-primary);
}

/* ── Flow Timeline ───────────────────────────────────── */
.timeline-panel {
  background: var(--surface-base);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.flow-chart-area {
  padding: 12px 18px 0;
  height: 84px;
}

#flowSvg { width: 100%; height: 68px; display: block; }

.flow-time-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 18px 10px;
}

.t-label { font-size: 10px; color: var(--ink-muted); font-family: var(--font-mono); }

.flow-legend {
  display: flex;
  gap: 16px;
  padding: 8px 18px 12px;
  border-top: 1px solid var(--border-soft);
}

.fl-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--ink-tertiary);
}

.fl-line { width: 16px; height: 1.5px; border-radius: 1px; }

/* ── Login card ──────────────────────────────────────── */
.card {
  width: 100%;
  max-width: 360px;
  background: var(--surface-base);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 36px 32px 32px;
}

.card-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 28px;
}

.card-title {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink-primary);
  margin-bottom: 4px;
}

.card-sub {
  font-size: 13px;
  color: var(--ink-tertiary);
}

/* ── Form ────────────────────────────────────────────── */
.form { display: flex; flex-direction: column; gap: 14px; }

.field { display: flex; flex-direction: column; gap: 5px; }

.field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-secondary);
  margin-bottom: -2px;
}

.input-wrap { position: relative; margin-top: 0px; }

.input-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-muted);
  pointer-events: none;
  display: flex;
  align-items: center;
}

.field-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--surface-input);
  border-radius: var(--r-sm);
  background: var(--surface-input);
  font-size: 13px;
  font-family: var(--font);
  color: var(--ink-primary);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  -webkit-appearance: none;
}

.input-icon + .field-input { padding-left: 34px; }

.field-input::placeholder { color: var(--ink-muted); }

.field-input:focus {
  border-color: var(--border-focus);
  background: var(--surface-base);
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.field-input.error {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.pass-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-muted);
  padding: 2px;
  display: flex;
  align-items: center;
  transition: color 0.15s;
}

.pass-toggle:hover { color: var(--ink-secondary); }
.pass-toggle svg   { width: 15px; height: 15px; pointer-events: none; }
.icon-eye-off { display: none; }

/* ── Error message ───────────────────────────────────── */
.error-msg {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  background: var(--danger-soft);
  border: 1px solid rgba(255, 59, 48, 0.18);
  border-radius: var(--r-sm);
  font-size: 12px;
  color: var(--danger);
}

.error-msg.visible { display: flex; }
.error-msg svg { flex-shrink: 0; }

/* ── Remember / forgot row ───────────────────────────── */
.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: -2px;
}

.checkbox-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.checkbox-wrap input[type="checkbox"] { display: none; }

.checkbox-box {
  width: 16px;
  height: 16px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface-inset);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}

.checkbox-box svg {
  width: 10px;
  height: 10px;
  color: #fff;
  opacity: 0;
  transition: opacity 0.1s;
}

.checkbox-wrap input:checked ~ .checkbox-box {
  background: var(--accent);
  border-color: var(--accent);
}

.checkbox-wrap input:checked ~ .checkbox-box svg { opacity: 1; }

.checkbox-label {
  font-size: 12px;
  color: var(--ink-tertiary);
}

.forgot-link {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
}

.forgot-link:hover { text-decoration: underline; }

/* ── Submit button ───────────────────────────────────── */
.btn-submit {
  width: 100%;
  padding: 10px;
  background: var(--ink-primary);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity 0.15s;
  margin-top: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: -0.01em;
}

.btn-submit:hover   { opacity: 0.88; }
.btn-submit:active  { opacity: 0.76; }
.btn-submit:disabled { opacity: 0.4; cursor: not-allowed; }

[data-theme="dark"] .btn-submit { color: var(--surface-grouped); }

.btn-spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn-submit.loading .btn-label   { display: none; }
.btn-submit.loading .btn-spinner { display: block; }

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

/* ── Card footer ─────────────────────────────────────── */
.card-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 11px;
  color: var(--ink-muted);
}

/* ══════════════════════════════════════════════════════
   COMPONENT LIBRARY
   ══════════════════════════════════════════════════════ */

/* ── Section header ──────────────────────────────────── */
.section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 12px;
}

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  font-size: 13px;
  font-family: var(--font);
  font-weight: 500;
  letter-spacing: -0.01em;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity 0.15s, background 0.15s, border-color 0.15s, color 0.15s;
}

.btn svg { width: 14px; height: 14px; pointer-events: none; flex-shrink: 0; }
.btn:disabled { opacity: 0.38; cursor: not-allowed; pointer-events: none; }

/* Remove outline no clique, mantém na navegação por teclado */
.btn:focus,
.btn-icon:focus,
.btn-submit:focus,
.btn-logout:focus,
.theme-toggle:focus,
.sidebar-toggle:focus,
.pass-toggle:focus,
.modal-close:focus,
.toast-close:focus        { outline: none; }

.btn:focus-visible,
.btn-icon:focus-visible,
.btn-submit:focus-visible,
.btn-logout:focus-visible,
.theme-toggle:focus-visible,
.sidebar-toggle:focus-visible,
.pass-toggle:focus-visible,
.modal-close:focus-visible,
.toast-close:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }

/* Tamanhos */
.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }

/* Variantes */
.btn-primary   { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover   { opacity: 0.88; }

.btn-secondary { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-secondary:hover { background: var(--accent-soft); }

.btn-ghost     { background: transparent; color: var(--ink-secondary); border-color: var(--border-strong); }
.btn-ghost:hover     { background: var(--surface-grouped); }

.btn-danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover    { opacity: 0.88; }

.btn-danger-soft { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.btn-danger-soft:hover { background: var(--danger); color: #fff; }

/* Ícone apenas */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-tertiary);
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  flex-shrink: 0;
}

.btn-icon svg { width: 14px; height: 14px; }

.btn-icon:hover {
  background: var(--surface-input);
  color: var(--ink-primary);
  border-color: var(--border);
}

.btn-icon.btn-icon-danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: rgba(255,59,48,.18);
}

[data-theme="dark"] .btn-icon.btn-icon-danger:hover {
  border-color: rgba(255,69,58,.25);
}

/* Grupo de botões */
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; border-right-width: 0; }
.btn-group .btn:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.btn-group .btn:last-child  { border-radius: 0 var(--r-sm) var(--r-sm) 0; border-right-width: 1px; }

/* ── Badge / Tag ─────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 20px;
  border: 1px solid transparent;
}

.badge-blue    { background: var(--accent-soft);  color: var(--accent);  border-color: var(--accent-mid); }
.badge-green   { background: rgba(52,199,89,.1);  color: var(--success); border-color: rgba(52,199,89,.25); }
.badge-yellow  { background: rgba(255,149,0,.1);  color: var(--warning); border-color: rgba(255,149,0,.25); }
.badge-red     { background: var(--danger-soft);  color: var(--danger);  border-color: rgba(255,59,48,.25); }
.badge-neutral { background: var(--surface-inset); color: var(--ink-tertiary); border-color: var(--border); }

/* ── Form extras ─────────────────────────────────────── */
.field-select {
  width: 100%;
  padding: 9px 32px 9px 12px;
  border: 1px solid var(--surface-input);
  border-radius: var(--r-sm);
  background: var(--surface-input);
  font-size: 13px;
  font-family: var(--font);
  color: var(--ink-primary);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10' fill='none' stroke='%23AEAEB2' stroke-width='1.5' stroke-linecap='round'%3E%3Cpath d='M2 4l3 3 3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 0.15s, background-color 0.15s;
  cursor: pointer;
}

.field-select:focus { border-color: var(--border-focus); background-color: var(--surface-base); outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }

.field-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--surface-input);
  border-radius: var(--r-sm);
  background: var(--surface-input);
  font-size: 13px;
  font-family: var(--font);
  color: var(--ink-primary);
  outline: none;
  resize: vertical;
  min-height: 88px;
  line-height: 1.5;
  transition: border-color 0.15s, background 0.15s;
}

.field-textarea::placeholder { color: var(--ink-muted); }
.field-textarea:focus { border-color: var(--border-focus); background: var(--surface-base); outline: none; box-shadow: 0 0 0 3px var(--focus-ring); }

/* Radio */
.radio-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.radio-wrap input[type="radio"] { display: none; }

.radio-box {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface-inset);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: border-color 0.15s, background 0.15s;
}

.radio-box::after {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  opacity: 0;
  transition: opacity 0.1s;
}

.radio-wrap input:checked ~ .radio-box {
  background: var(--accent);
  border-color: var(--accent);
}

.radio-wrap input:checked ~ .radio-box::after { opacity: 1; }

.radio-label { font-size: 13px; color: var(--ink-secondary); }

/* Toggle switch */
.switch-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.switch-wrap input[type="checkbox"] { display: none; }

.switch-track {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: var(--surface-inset);
  border: 1px solid var(--border-strong);
  position: relative;
  flex-shrink: 0;
  transition: background 0.18s, border-color 0.18s;
}

.switch-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ink-muted);
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.18s cubic-bezier(0.4, 0, 0.2, 1), background 0.18s;
}

.switch-wrap input:checked ~ .switch-track {
  background: var(--accent);
  border-color: var(--accent);
}

.switch-wrap input:checked ~ .switch-track .switch-thumb {
  transform: translateX(16px);
  background: #fff;
}

.switch-label { font-size: 13px; color: var(--ink-secondary); }

/* ── Alert (SweetAlert-style) ────────────────────────── */
.alert-backdrop {
  position: fixed;
  inset: 0;
  z-index: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.alert-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

.alert-box {
  background: var(--surface-base);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 380px;
  padding: 32px 28px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
  transform: scale(0.92) translateY(12px);
  transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.alert-backdrop.open .alert-box {
  transform: scale(1) translateY(0);
}

/* ícone */
.alert-icon {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  flex-shrink: 0;
  animation: alert-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: 0.1s;
}

@keyframes alert-pop {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.alert-icon svg {
  width: 30px;
  height: 30px;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* variantes de cor do ícone */
.alert-icon-success { background: rgba(52, 199, 89, 0.12);  color: var(--success); }
.alert-icon-danger  { background: var(--danger-soft);        color: var(--danger); }
.alert-icon-warning { background: rgba(255, 149, 0, 0.12);  color: var(--warning); }
.alert-icon-info    { background: var(--accent-soft);        color: var(--accent); }
.alert-icon-confirm { background: var(--surface-grouped);    color: var(--ink-secondary); }

/* animação do checkmark */
.alert-icon-success .alert-check {
  stroke-dasharray: 28;
  stroke-dashoffset: 28;
  animation: draw-stroke 0.35s 0.28s ease forwards;
}

.alert-icon-danger .alert-x1,
.alert-icon-danger .alert-x2 {
  stroke-dasharray: 18;
  stroke-dashoffset: 18;
}
.alert-icon-danger .alert-x1 { animation: draw-stroke 0.25s 0.28s ease forwards; }
.alert-icon-danger .alert-x2 { animation: draw-stroke 0.25s 0.38s ease forwards; }

@keyframes draw-stroke {
  to { stroke-dashoffset: 0; }
}

/* título e texto */
.alert-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--ink-primary);
  line-height: 1.3;
  margin-bottom: 8px;
}

.alert-text {
  font-size: 13px;
  color: var(--ink-tertiary);
  line-height: 1.6;
  margin-bottom: 24px;
  max-width: 300px;
}

.alert-text:empty { margin-bottom: 16px; }

/* botões */
.alert-foot {
  display: flex;
  gap: 8px;
  width: 100%;
  justify-content: center;
}

.alert-foot .btn { min-width: 90px; }

/* ── Toast ───────────────────────────────────────────── */
.toast-stack {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 700;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 320px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
  pointer-events: all;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  animation: toast-in 0.22s cubic-bezier(0.4, 0, 0.2, 1) forwards;

  /* default — sempre escuro independente do tema */
  background: #1C1C1E;
  color: #F5F5F7;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.toast.toast-success {
  background: var(--surface-base);
  color: var(--ink-primary);
  border: 1px solid rgba(52, 199, 89, 0.3);
}

.toast.toast-danger {
  background: var(--surface-base);
  color: var(--ink-primary);
  border: 1px solid rgba(255, 59, 48, 0.3);
}

[data-theme="dark"] .toast.toast-success {
  background: var(--surface-inset);
  border-color: rgba(50, 215, 75, 0.3);
}

[data-theme="dark"] .toast.toast-danger {
  background: var(--surface-inset);
  border-color: rgba(255, 69, 58, 0.3);
}

/* ícone colorido */
.toast-icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-icon svg { width: 16px; height: 16px; }

.toast          .toast-icon { color: #F5F5F7; }
.toast-success  .toast-icon { color: var(--success); }
.toast-danger   .toast-icon { color: var(--danger); }

/* texto */
.toast-msg {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
}

/* botão fechar */
.toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  opacity: 0.5;
  transition: opacity 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
  color: inherit;
}

.toast-close:hover { opacity: 1; }
.toast-close svg { width: 12px; height: 12px; }

/* barra de progresso */
.toast-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 100%;
  transform-origin: left;
  animation: toast-bar var(--toast-duration, 4000ms) linear forwards;
}

.toast          .toast-bar { background: rgba(255, 255, 255, 0.35); }
.toast-success  .toast-bar { background: var(--success); }
.toast-danger   .toast-bar { background: var(--danger); }

/* animações */
@keyframes toast-in {
  from { opacity: 0; transform: translateX(calc(100% + 20px)); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  0%   { opacity: 1; transform: translateX(0);               max-height: 64px; margin-bottom: 0; }
  100% { opacity: 0; transform: translateX(calc(100% + 20px)); max-height: 0;   margin-bottom: -8px; }
}

@keyframes toast-bar {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

.toast.toast-removing {
  animation: toast-out 0.24s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  pointer-events: none;
}

/* ── Loading overlay ────────────────────────────────── */
.load-overlay {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.load-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.load-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  background: var(--surface-base);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px 36px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14);
  transform: scale(0.95);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.load-overlay.visible .load-card {
  transform: scale(1);
}

.load-spinner {
  width: 32px;
  height: 32px;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

.load-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-secondary);
}

/* ── Popup animation (shared: select, datepicker, timepicker) */
@keyframes vm-popup-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── VM DatePicker ───────────────────────────────────── */
.vm-dp { position: relative; width: 100%; }

.vm-dp-popup {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 300;
  background: var(--surface-base);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  padding: 14px;
  width: 264px;
  display: none;
  user-select: none;
}
.vm-dp.open .vm-dp-popup {
  display: block;
  animation: vm-popup-in 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.vm-dp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.vm-dp-nav {
  width: 26px; height: 26px;
  border-radius: var(--r-sm);
  border: none;
  background: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-tertiary);
  transition: background 0.1s, color 0.1s;
  flex-shrink: 0;
}
.vm-dp-nav:hover { background: var(--surface-input); color: var(--ink-primary); }
.vm-dp-nav svg   { width: 12px; height: 12px; pointer-events: none; }

.vm-dp-month-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-primary);
  flex: 1;
  text-align: center;
}

.vm-dp-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 2px;
}
.vm-dp-wd {
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-muted);
  padding: 4px 0;
}

.vm-dp-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
}

.vm-dp-day {
  text-align: center;
  padding: 6px 2px;
  border-radius: var(--r-sm);
  font-size: 12px;
  cursor: pointer;
  color: var(--ink-primary);
  transition: background 0.1s, color 0.1s;
  position: relative;
  line-height: 1;
}
.vm-dp-day:hover         { background: var(--surface-input); }
.vm-dp-day.other-month   { color: var(--ink-muted); }
.vm-dp-day.today         { font-weight: 700; color: var(--accent); }
.vm-dp-day.today::after  {
  content: '';
  position: absolute;
  bottom: 2px; left: 50%;
  transform: translateX(-50%);
  width: 3px; height: 3px;
  border-radius: 50%;
  background: var(--accent);
}
.vm-dp-day.selected {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.vm-dp-day.selected.today::after { background: rgba(255,255,255,0.6); }
.vm-dp-day.disabled { opacity: 0.28; cursor: not-allowed; pointer-events: none; }

.vm-dp-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
}

/* ── VM TimePicker ───────────────────────────────────── */
.vm-tp { position: relative; width: 100%; }

.vm-tp-popup {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 300;
  background: var(--surface-base);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  width: 156px;
  overflow: hidden;
  display: none;
  flex-direction: column;
}
.vm-tp.open .vm-tp-popup {
  display: flex;
  animation: vm-popup-in 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.vm-tp-cols { display: flex; }

.vm-tp-col {
  flex: 1;
  max-height: 196px;
  overflow-y: auto;
  scrollbar-width: none;
  border-right: 1px solid var(--border-soft);
}
.vm-tp-col:last-child            { border-right: none; }
.vm-tp-col::-webkit-scrollbar    { display: none; }

.vm-tp-col-label {
  position: sticky;
  top: 0;
  background: var(--surface-base);
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--ink-muted);
  padding: 7px 0 5px;
  border-bottom: 1px solid var(--border-soft);
  z-index: 1;
}

.vm-tp-item {
  text-align: center;
  padding: 7px 0;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink-primary);
  transition: background 0.1s;
}
.vm-tp-item:hover    { background: var(--surface-input); }
.vm-tp-item.selected { background: var(--accent); color: #fff; font-weight: 600; }

.vm-tp-confirm {
  width: 100%;
  padding: 8px;
  border: none;
  border-top: 1px solid var(--border-soft);
  background: none;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.1s;
}
.vm-tp-confirm:hover { background: var(--surface-input); }

/* ── VM Select ───────────────────────────────────────── */
.vm-select {
  position: relative;
  width: 100%;
  font-size: 13px;
  font-family: var(--font);
}

/* Trigger */
.vm-select-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px 7px 12px;
  min-height: 36px;
  border: 1px solid var(--surface-input);
  border-radius: var(--r-sm);
  background: var(--surface-input);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s, background 0.15s;
}

.vm-select.open .vm-select-trigger {
  border-color: var(--border-focus);
  background: var(--surface-base);
  border-radius: var(--r-sm) var(--r-sm) 0 0;
}
.vm-select.open {
  border-radius: var(--r-sm);
}
.vm-select.open::after {
  content: '';
  position: absolute;
  inset: -3px;
  bottom: calc(-3px - var(--dropdown-h, 0px));
  border: 3px solid var(--focus-ring);
  border-radius: calc(var(--r-sm) + 3px);
  pointer-events: none;
  z-index: 201;
}

.vm-select-val {
  flex: 1;
  color: var(--ink-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vm-select-val.placeholder { color: var(--ink-muted); }

.vm-select-arrow {
  flex-shrink: 0;
  width: 13px; height: 13px;
  color: var(--ink-muted);
  transition: transform 0.18s;
  pointer-events: none;
}
.vm-select.open .vm-select-arrow { transform: rotate(180deg); }

/* Dropdown */
.vm-select-dropdown {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  z-index: 200;
  background: var(--surface-base);
  border: 1px solid var(--border-focus);
  border-top: none;
  border-radius: 0 0 var(--r-sm) var(--r-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  display: none;
}
.vm-select.open .vm-select-dropdown { display: block; }

/* Search inside dropdown (single) */
.vm-select-search-wrap {
  padding: 8px 8px 6px;
  border-bottom: 1px solid var(--border-soft);
}

.vm-select-search {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--surface-input);
  border-radius: var(--r-sm);
  background: var(--surface-input);
  font-size: 12px;
  font-family: var(--font);
  color: var(--ink-primary);
  outline: none;
  transition: border-color 0.15s;
}
.vm-select-search:focus { border-color: var(--border-focus); }
.vm-select-search::placeholder { color: var(--ink-muted); }

/* Option list */
.vm-select-list {
  max-height: 210px;
  overflow-y: auto;
  padding: 4px;
}

.vm-select-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--ink-primary);
  transition: background 0.1s;
}
.vm-select-item:hover    { background: var(--surface-input); }
.vm-select-item.selected { color: var(--accent); font-weight: 500; }
.vm-select-item.focused  { background: var(--surface-input); }

/* checkmark (single) */
.vm-item-check {
  margin-left: auto;
  flex-shrink: 0;
  width: 14px; height: 14px;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.1s;
}
.vm-select-item.selected .vm-item-check { opacity: 1; }
.vm-item-check svg { width: 14px; height: 14px; }

/* checkbox (multi) */
.vm-item-box {
  flex-shrink: 0;
  width: 15px; height: 15px;
  border-radius: 3px;
  border: 1.5px solid var(--border-strong);
  background: var(--surface-base);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.12s, border-color 0.12s;
}
.vm-item-box svg { width: 9px; height: 9px; stroke: #fff; display: none; }
.vm-select-item.selected .vm-item-box {
  background: var(--accent);
  border-color: var(--accent);
}
.vm-select-item.selected .vm-item-box svg { display: block; }

/* No results */
.vm-select-empty {
  padding: 14px 10px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-muted);
}

/* ── Multi: tags inline ──────────────────────────────── */
.vm-select-multi .vm-select-trigger {
  flex-wrap: nowrap;
  min-height: 36px;
  padding: 5px 8px 5px 10px;
  gap: 6px;
  align-items: center;
}

.vm-tags-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.vm-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 4px 2px 8px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-mid);
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  white-space: nowrap;
  line-height: 1.4;
}

.vm-tag-remove {
  display: flex; align-items: center; justify-content: center;
  width: 16px; height: 16px;
  border-radius: 3px;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.1s, background 0.1s;
  flex-shrink: 0;
}
.vm-tag-remove:hover { opacity: 1; background: var(--accent-mid); }
.vm-tag-remove svg { width: 8px; height: 8px; }

/* inline search input (multi) */
.vm-inline-search {
  flex: 1;
  min-width: 60px;
  border: none;
  outline: none;
  background: transparent;
  font-size: 12px;
  font-family: var(--font);
  color: var(--ink-primary);
  padding: 2px 0;
}
.vm-inline-search::placeholder { color: var(--ink-muted); }

/* footer: limpar seleção */
.vm-select-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px 8px;
  border-top: 1px solid var(--border-soft);
}
.vm-select-count { font-size: 11px; color: var(--ink-muted); }
.vm-select-clear {
  font-size: 11px;
  color: var(--ink-tertiary);
  cursor: pointer;
  background: none;
  border: none;
  font-family: var(--font);
  padding: 0;
  transition: color 0.12s;
}
.vm-select-clear:hover { color: var(--danger); }

/* ── Widgets ─────────────────────────────────────────── */

/* ── Tipo 8: Stats Group — painel com múltiplas métricas inline */
.widget-stats-group {
  background: var(--surface-base);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px 22px;
}

.wsg-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}
.wsg-title   { font-size: 15px; font-weight: 600; color: var(--ink-primary); }
.wsg-updated { font-size: 11px; color: var(--ink-muted); }

.wsg-items {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
}

.wsg-item {
  display: flex;
  align-items: center;
  gap: 11px;
  flex-shrink: 0;
}

.wsg-icon {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: var(--w-bg, var(--accent-soft));
  color: var(--w-color, var(--accent));
}
.wsg-icon svg { width: 17px; height: 17px; }

.wsg-value { font-size: 17px; font-weight: 700; color: var(--ink-primary); line-height: 1.2; }
.wsg-label { font-size: 11px; color: var(--ink-tertiary); margin-top: 1px; }

/* ── Tipo 9: Chart — mini sparkline dentro do card ────── */
.widget-chart {
  background: var(--surface-base);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.wch-head { margin-bottom: 12px; }
.wch-title  { font-size: 14px; font-weight: 600; color: var(--ink-primary); }
.wch-period { font-size: 11px; color: var(--ink-tertiary); margin-top: 1px; }

.wch-chart {
  height: 68px;
  overflow: visible;
  margin: 0 -4px;
}
.wch-chart svg { width: 100%; height: 100%; overflow: visible; }

.wch-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 10px;
}
.wch-value { font-size: 22px; font-weight: 700; color: var(--ink-primary); letter-spacing: -0.5px; }
.wch-delta { font-size: 12px; font-weight: 500; }

/* gauge semicircular */
.wch-gauge {
  height: 68px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}
.wch-gauge svg { width: 120px; height: 68px; }
.wch-gauge-pct {
  position: absolute;
  bottom: 2px;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink-primary);
}

/* ── Tipo 10: Bottom — borda inferior colorida ─────────── */
.widget-bottom {
  background: var(--surface-base);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  border-bottom: 3px solid var(--w-color, var(--accent));
  padding: 18px 20px 16px;
}

.wb-main {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
}

.wb-icon {
  width: 44px; height: 44px;
  border-radius: var(--r-sm);
  background: var(--w-bg, var(--accent-soft));
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--w-color, var(--accent));
}
.wb-icon svg { width: 20px; height: 20px; }

.wb-value { font-size: 28px; font-weight: 700; color: var(--ink-primary); letter-spacing: -0.5px; line-height: 1; }
.wb-label { font-size: 12px; color: var(--ink-tertiary); margin-top: 3px; }
.wb-trend { font-size: 11px; color: var(--ink-tertiary); }
.wb-trend strong { font-weight: 600; margin-right: 3px; }

/* helpers de tendência */
.delta-up   { color: var(--success); }
.delta-down { color: var(--danger); }

.delta-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.delta-badge.up   { background: rgba(52, 199, 89, 0.12); color: var(--success); }
.delta-badge.down { background: var(--danger-soft);       color: var(--danger); }

/* ── Tipo 1: Solid — fundo colorido total ─────────────── */
.widget-solid {
  position: relative;
  overflow: hidden;
  background: var(--w-color, var(--accent));
  border-radius: var(--r-md);
  padding: 18px 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  min-height: 94px;
  color: #fff;
}

.ws-body { display: flex; flex-direction: column; gap: 6px; position: relative; z-index: 1; }
.ws-label { font-size: 13px; font-weight: 500; opacity: 0.88; }
.ws-value { font-size: 30px; font-weight: 700; line-height: 1; letter-spacing: -0.5px; }

.ws-icon { position: relative; z-index: 1; flex-shrink: 0; opacity: 0.72; }
.ws-icon svg { width: 34px; height: 34px; }

.widget-solid::before,
.widget-solid::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  pointer-events: none;
}
.widget-solid::before { width: 90px; height: 90px; bottom: -24px; right: 16px; }
.widget-solid::after  { width: 56px; height: 56px; bottom: 8px;   right: 68px; }

/* ── Tipo 2: Soft — pastel + borda esquerda + tendência ── */
.widget-soft {
  background: var(--w-bg, var(--surface-input));
  border-radius: var(--r-md);
  border-left: 3px solid var(--w-color, var(--accent));
  padding: 16px 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.wsoft-body { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.wsoft-label { font-size: 12px; font-weight: 500; color: var(--ink-tertiary); }
.wsoft-value { font-size: 26px; font-weight: 700; color: var(--ink-primary); line-height: 1.15; }
.wsoft-trend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-tertiary); margin-top: 6px; }

.wsoft-icon {
  width: 42px; height: 42px;
  border-radius: var(--r-sm);
  background: var(--surface-base);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--w-color, var(--accent));
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
}
.wsoft-icon svg { width: 19px; height: 19px; }

/* ── Tipo 3: Compact — icon + valor + delta + progress bar */
.widget-compact {
  background: var(--surface-base);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wcompact-top { display: flex; align-items: center; gap: 12px; }
.wcompact-icon {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--surface-input);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--ink-tertiary);
}
.wcompact-icon svg { width: 16px; height: 16px; }
.wcompact-meta { display: flex; flex-direction: column; gap: 1px; }
.wcompact-row { display: flex; align-items: baseline; gap: 8px; }
.wcompact-value { font-size: 22px; font-weight: 700; color: var(--ink-primary); }
.wcompact-delta { font-size: 12px; font-weight: 500; }
.wcompact-label { font-size: 12px; color: var(--ink-tertiary); }
.wcompact-bar { height: 3px; border-radius: 2px; background: var(--surface-input); overflow: hidden; }
.wcompact-bar-fill { height: 100%; border-radius: 2px; background: var(--w-color, var(--accent)); }

/* ── Tipo 4: Stat — label caps + icon badge + valor + tendência */
.widget-stat {
  background: var(--surface-base);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px 20px;
}
.widget-stat.ws-highlight {
  background: var(--w-color, var(--accent));
  border-color: transparent;
}
.widget-stat.ws-highlight .wstat-label,
.widget-stat.ws-highlight .wstat-value,
.widget-stat.ws-highlight .wstat-trend { color: #fff; }
.widget-stat.ws-highlight .wstat-icon  { background: rgba(255,255,255,0.18); color: #fff; }
.widget-stat.ws-highlight .delta-badge { background: rgba(255,255,255,0.18); color: #fff; }

.wstat-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; }
.wstat-label { font-size: 10px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-tertiary); }
.wstat-icon {
  width: 38px; height: 38px;
  border-radius: var(--r-sm);
  background: var(--w-bg, var(--surface-input));
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--w-color, var(--accent));
}
.wstat-icon svg { width: 18px; height: 18px; }
.wstat-value { font-size: 27px; font-weight: 700; color: var(--ink-primary); margin-bottom: 8px; letter-spacing: -0.5px; }
.wstat-trend { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-tertiary); }

/* ── Tipo 5: Icon-center — ícone central + valor + badge */
.widget-icon-center {
  background: var(--surface-base);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 24px 16px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}

.wic-icon {
  width: 54px; height: 54px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
  color: var(--w-color, var(--accent));
  background: var(--w-bg, var(--accent-soft));
}
.wic-icon svg { width: 24px; height: 24px; }
.wic-value { font-size: 24px; font-weight: 700; color: var(--ink-primary); letter-spacing: -0.5px; }
.wic-label { font-size: 12px; color: var(--ink-tertiary); margin-bottom: 6px; }
.wic-badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px; font-weight: 500;
  margin-top: 2px;
}
.wic-badge.up   { background: rgba(52,199,89,0.12);  color: var(--success); }
.wic-badge.down { background: var(--danger-soft);      color: var(--danger); }

/* ── Tipo 6: Ring — arco SVG + ícone central ──────────── */
.widget-ring {
  background: var(--surface-base);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.wring-chart {
  position: relative;
  width: 58px; height: 58px;
  flex-shrink: 0;
}
.wring-chart svg { width: 58px; height: 58px; transform: rotate(-90deg); }
.wring-bg   { fill: none; stroke: var(--surface-input); stroke-width: 2.8; }
.wring-fill {
  fill: none;
  stroke: var(--w-color, var(--accent));
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-dasharray: 0 100;
  transition: stroke-dasharray 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
.wring-icon {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--w-color, var(--accent));
}
.wring-icon svg { width: 20px; height: 20px; }
.wring-body { display: flex; flex-direction: column; gap: 2px; }
.wring-value { font-size: 22px; font-weight: 700; color: var(--ink-primary); letter-spacing: -0.5px; }
.wring-label { font-size: 12px; color: var(--ink-tertiary); }

/* ── Tipo 7: Plain — label + ícone colorido sólido + valor */
.widget-plain {
  background: var(--surface-base);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 18px 20px;
}
.wplain-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.wplain-label { font-size: 13px; color: var(--ink-tertiary); line-height: 1.4; }
.wplain-icon {
  width: 40px; height: 40px;
  border-radius: var(--r-sm);
  background: var(--w-color, var(--accent));
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: #fff;
}
.wplain-icon svg { width: 24px; height: 24px; }
.wplain-value { font-size: 28px; font-weight: 700; color: var(--ink-primary); letter-spacing: -0.5px; }

/* ── Table ───────────────────────────────────────────── */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table thead tr {
  background: var(--surface-input);
}

.table th {
  padding: 9px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--ink-tertiary);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 5px 14px;
  color: var(--ink-primary);
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
  white-space: nowrap;
}

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

.table tbody tr:hover td { background: var(--surface-input); }

/* column alignment helpers */
.table .col-right { text-align: right; }
.table .col-center { text-align: center; }

/* row status accent */
.table tbody tr.row-active td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}
.table tbody tr.row-danger td:first-child {
  box-shadow: inset 3px 0 0 var(--danger);
}
.table tbody tr.row-warning td:first-child {
  box-shadow: inset 3px 0 0 var(--warning);
}

/* ── Modal ───────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 400;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface-base);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 440px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.14);
  animation: modal-in 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-head {
  padding: 20px 20px 0 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.modal-title { font-size: 15px; font-weight: 600; letter-spacing: -0.015em; }
.modal-sub   { font-size: 12px; color: var(--ink-muted); margin-top: 3px; }

.modal-close {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: var(--r-sm);
  border: none;
  background: none;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.modal-close:hover { background: var(--surface-grouped); color: var(--ink-primary); }
.modal-close svg { width: 14px; height: 14px; pointer-events: none; }

.modal-body {
  padding: 14px 24px;
  font-size: 13px;
  color: var(--ink-tertiary);
  line-height: 1.65;
}

.modal-foot {
  padding: 4px 24px 20px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.modal-divider { height: 1px; background: var(--border-soft); margin: 0 24px; }

/* ── Modal fullscreen ────────────────────────────────── */
.modal-backdrop.modal-fs {
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
}

.modal-backdrop.modal-fs .modal {
  max-width: 100%;
  width: 100%;
  height: 100%;
  border-radius: 0;
  border: none;
  display: flex;
  flex-direction: column;
  animation: modal-fs-in 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modal-fs-in {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-backdrop.modal-fs .modal-head {
  padding: 16px 20px 16px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

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

.modal-backdrop.modal-fs .modal-foot {
  flex-shrink: 0;
  padding: 12px 24px 16px;
  border-top: 1px solid var(--border);
}

/* ── Pagination ──────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.pagination-info {
  font-size: 12px;
  color: var(--ink-tertiary);
  white-space: nowrap;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 2px;
}

.pg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: none;
  font-size: 12.5px;
  font-family: var(--font);
  color: var(--ink-secondary);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  user-select: none;
  line-height: 1;
}

.pg-btn:hover:not(:disabled):not(.pg-active) {
  background: var(--surface-inset);
  color: var(--ink-primary);
}

.pg-btn.pg-active {
  background: var(--accent-soft);
  border-color: var(--accent-mid);
  color: var(--accent);
  font-weight: 600;
  cursor: default;
}

.pg-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.pg-btn svg {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}

.pg-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  font-size: 12.5px;
  color: var(--ink-muted);
  user-select: none;
}

/* ── Tooltip ─────────────────────────────────────────── */
#vmTooltip {
  position: fixed;
  z-index: 9000;
  max-width: 240px;
  padding: 7px 10px;
  background: var(--ink-secondary);
  color: var(--surface-base);
  font-size: 12px;
  line-height: 1.45;
  border-radius: var(--r-sm);
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
  pointer-events: none;
  white-space: pre-wrap;
  word-break: break-word;
  transition: opacity 0.12s ease;
  opacity: 0;
}

#vmTooltip.tt-visible { opacity: 1; }

/* Seta */
#vmTooltip::after {
  content: '';
  position: absolute;
  width: 0;
  height: 0;
}

#vmTooltip[data-placement="top"]::after {
  top: 100%; left: 50%; transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--ink-secondary);
  border-bottom: 0;
}

#vmTooltip[data-placement="bottom"]::after {
  bottom: 100%; left: 50%; transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom-color: var(--ink-secondary);
  border-top: 0;
}

#vmTooltip[data-placement="left"]::after {
  left: 100%; top: 50%; transform: translateY(-50%);
  border: 5px solid transparent;
  border-left-color: var(--ink-secondary);
  border-right: 0;
}

#vmTooltip[data-placement="right"]::after {
  right: 100%; top: 50%; transform: translateY(-50%);
  border: 5px solid transparent;
  border-right-color: var(--ink-secondary);
  border-left: 0;
}

/* Spinner interno (modo ajax) */
#vmTooltip .tt-spinner {
  display: inline-block;
  width: 11px;
  height: 11px;
  border: 1.5px solid rgba(255,255,255,0.3);
  border-top-color: rgba(255,255,255,0.85);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 5px;
}

/* Dark mode — inverte para fundo escuro já é escuro, então usa surface-base invertido */
[data-theme="dark"] #vmTooltip {
  background: var(--surface-inset);
  color: var(--ink-primary);
  box-shadow: 0 4px 14px rgba(0,0,0,0.45);
}

[data-theme="dark"] #vmTooltip[data-placement="top"]::after    { border-top-color:    var(--surface-inset); }
[data-theme="dark"] #vmTooltip[data-placement="bottom"]::after { border-bottom-color: var(--surface-inset); }
[data-theme="dark"] #vmTooltip[data-placement="left"]::after   { border-left-color:   var(--surface-inset); }
[data-theme="dark"] #vmTooltip[data-placement="right"]::after  { border-right-color:  var(--surface-inset); }

[data-theme="dark"] #vmTooltip .tt-spinner {
  border-color: rgba(255,255,255,0.15);
  border-top-color: var(--accent);
}


/* ── Validação ── */
.field-input.is-invalid,
.field-select.is-invalid {
  border-color: var(--danger, #e5534b) !important;
  outline: none;
  box-shadow: 0 0 0 2px rgba(229, 83, 75, 0.18);
}

/* ── VmDateRange ── */
.vm-daterange {
  position: relative;
  width: 100%;
  font-size: 13px;
  font-family: var(--font);
}

.vm-dr-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px 7px 12px;
  min-height: 36px;
  border: 1px solid var(--surface-input);
  border-radius: var(--r-sm);
  background: var(--surface-input);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s, background 0.15s;
}
.vm-daterange.open .vm-dr-trigger {
  border-color: var(--border-focus);
  background: var(--surface-base);
  border-radius: var(--r-sm) var(--r-sm) 0 0;
}
.vm-daterange.open {
  border-radius: var(--r-sm);
}
.vm-daterange.open::after {
  content: '';
  position: absolute;
  inset: -3px;
  bottom: calc(-3px - var(--dropdown-h, 0px));
  border: 3px solid var(--focus-ring);
  border-radius: calc(var(--r-sm) + 3px);
  pointer-events: none;
  z-index: 201;
}

.vm-dr-icon {
  flex-shrink: 0;
  width: 14px; height: 14px;
  color: var(--ink-muted);
}

.vm-dr-val {
  flex: 1;
  color: var(--ink-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vm-dr-val.placeholder { color: var(--ink-muted); }

.vm-dr-arrow {
  flex-shrink: 0;
  width: 13px; height: 13px;
  color: var(--ink-muted);
  transition: transform 0.18s;
  pointer-events: none;
}
.vm-daterange.open .vm-dr-arrow { transform: rotate(180deg); }

.vm-dr-dropdown {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  z-index: 200;
  background: var(--surface-base);
  border: 1px solid var(--border-focus);
  border-top: none;
  border-radius: 0 0 var(--r-sm) var(--r-sm);
  overflow: hidden;
  display: none;
  min-width: 180px;
}
.vm-daterange.open .vm-dr-dropdown { display: block; }

.vm-dr-presets {
  display: flex;
  flex-direction: column;
  padding: 4px 0;
}

.vm-dr-preset {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 8px 14px;
  text-align: left;
  background: none;
  border: none;
  font-size: 13px;
  font-family: var(--font);
  color: var(--ink-secondary);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.vm-dr-preset svg { width: 13px; height: 13px; flex-shrink: 0; opacity: 0.6; }
.vm-dr-preset:hover { background: var(--surface-hover); color: var(--ink-primary); }
.vm-dr-preset.active { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
.vm-dr-preset-custom { border-top: 1px solid var(--border-soft); margin-top: 4px; padding-top: 10px; }

.vm-dr-custom {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.2s ease, padding 0.2s ease;
  border-top: 0px solid var(--border-soft);
  padding: 0 12px;
}
.vm-dr-custom.open {
  max-height: 120px;
  border-top-width: 1px;
  padding: 10px 12px;
}

.vm-dr-custom-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.vm-dr-custom-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.vm-dr-custom-field label {
  font-size: 11px;
  color: var(--ink-muted);
  font-weight: 500;
}
.vm-dr-date-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.vm-dr-date-wrap input[type="text"] {
  width: 100%;
  padding: 5px 28px 5px 8px;
  border: 1px solid var(--surface-input);
  border-radius: var(--r-sm);
  background: var(--surface-input);
  font-size: 12px;
  font-family: var(--font);
  color: var(--ink-primary);
  outline: none;
  transition: border-color 0.15s;
}
.vm-dr-date-wrap input[type="text"]:focus { border-color: var(--border-focus); }
.vm-dr-date-native {
  position: absolute;
  bottom: 0;
  right: 26px;
  width: 0;
  height: 0;
  opacity: 0;
  border: none;
  pointer-events: none;
}
.vm-dr-cal-btn {
  position: absolute;
  right: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink-muted);
  border-radius: var(--r-sm);
  transition: color 0.12s;
}
.vm-dr-cal-btn:hover { color: var(--accent); }
.vm-dr-cal-btn svg  { width: 13px; height: 13px; pointer-events: none; }

.vm-dr-apply {
  display: block;
  width: 100%;
  padding: 6px 0;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r-sm);
  font-size: 12px;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}
.vm-dr-apply:hover { opacity: 0.85; }

/* ── Agent Cards ── */
.no-agents { text-align:center; padding:60px 0; color:var(--ink-muted); font-size:13px; }
.agent-card-foot { padding:10px 14px; border-top:1px solid var(--border); display:flex; gap:6px; flex-wrap:wrap; align-items:center; }
.agent-metric { display:flex; justify-content:space-between; align-items:center; margin-bottom:4px; }
.agent-metric-label { font-size:11px; color:var(--ink-muted); }
.agent-metric-val { font-size:11px; font-weight:600; font-family:var(--font-mono); font-variant-numeric:tabular-nums; }
.agent-metric-val.c-ok   { color:var(--success); }
.agent-metric-val.c-warn { color:var(--warning); }
.agent-metric-val.c-bad  { color:var(--danger); }
.cam-row { display:flex; align-items:center; gap:6px; padding:3px 0; }
.cam-dot { width:6px; height:6px; border-radius:50%; background:var(--success); flex-shrink:0; }
.cam-name { flex:1; font-size:12px; color:var(--ink-secondary); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.cam-ip { font-size:11px; color:var(--ink-muted); font-family:var(--font-mono); }
.ws-dot { display:inline-block; width:6px; height:6px; border-radius:50%; margin-right:4px; background:currentColor; vertical-align:middle; }
.ws-dot.on { color:var(--success); }
.ws-dot.off { color:var(--danger); }
.ws-dot.connecting { color:var(--warning); animation:ws-blink 1s infinite; }
@keyframes ws-blink { 0%,100%{opacity:1} 50%{opacity:0.25} }
.btn-ghost--muted { opacity:.45; }

/* ── Resultado de Processamento ── */
.rs-stat { flex:1; min-width:0; display:flex; flex-direction:column; align-items:center; padding:8px 16px; border:1px solid var(--border); border-radius:var(--r-md); }
.rs-stat-val { font-size:20px; font-weight:700; font-family:var(--font-mono); font-variant-numeric:tabular-nums; line-height:1.2; }
.rs-stat-label { font-size:11px; color:var(--ink-muted); margin-top:4px; white-space:nowrap; }
