@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

/* ── Tokens compartilhados ────────────────────────────────────────── */
:root {
  --font:       'DM Sans', sans-serif;
  --font-mono:  'DM Mono', monospace;
  --accent:     #4f8ef7;
  --accent-dim: rgba(79,142,247,0.12);
  --accent-hov: #3a7ee8;
  --ok:         #34d399;
  --ok-dim:     rgba(52,211,153,0.12);
  --warn:       #fbbf24;
  --warn-dim:   rgba(251,191,36,0.12);
  --danger:     #f87171;
  --danger-dim: rgba(248,113,113,0.12);
  --radius:     10px;
  --radius-lg:  16px;
  --sidebar-w:  220px;
  --topbar-h:   56px;
}

/* ── DARK MODE (padrão) ──────────────────────────────────────────── */
:root, [data-theme="dark"] {
  --bg:         #0f1117;
  --bg2:        #181c27;
  --bg3:        #1f2435;
  --border:     rgba(255,255,255,0.07);
  --border-md:  rgba(255,255,255,0.12);
  --text:       #e8eaf0;
  --text-muted: #7a8099;
  --text-dim:   #4a506a;
  --shadow:     0 1px 3px rgba(0,0,0,0.4);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.5);
  color-scheme: dark;
}

/* ── LIGHT MODE (cinza, nunca branco absoluto) ───────────────────── */
[data-theme="light"] {
  --bg:         #cad4ee;
  --bg2:        #e8eaed;
  --bg3:        #dde0e6;
  --border:     rgba(0,0,0,0.08);
  --border-md:  rgba(0,0,0,0.14);
  --text:       #1a1d27;
  --text-muted: #5a5f74;
  --text-dim:   #9097b0;
  --shadow:     0 1px 3px rgba(0,0,0,0.12);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.18);
  --accent-dim: rgba(79,142,247,0.10);
  --ok-dim:     rgba(22,163,74,0.10);
  --warn-dim:   rgba(180,130,0,0.10);
  --danger-dim: rgba(220,38,38,0.10);
  color-scheme: light;
}

/* Ajustes de contraste no light mode */
[data-theme="light"] .badge-neutral { background: #d0d4de; color: #3a3f55; }
[data-theme="light"] .badge-ok      { background: rgba(22,163,74,.12); color: #166534; }
[data-theme="light"] .badge-danger  { background: rgba(220,38,38,.12); color: #991b1b; }
[data-theme="light"] .badge-warn    { background: rgba(180,130,0,.12);  color: #854d0e; }
[data-theme="light"] .badge-accent  { background: rgba(79,142,247,.12); color: #1d4ed8; }
[data-theme="light"] .btn-ghost     { border-color: rgba(0,0,0,0.18); color: #4a4f64; }
[data-theme="light"] .btn-ghost:hover { background: var(--bg3); color: var(--text); }
[data-theme="light"] select, [data-theme="light"] select.form-control { background-color: var(--bg3); }

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

html { font-size: 15px; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hov); }

/* ── Layout ──────────────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
  grid-row: 1 / -1;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.sidebar-brand span { color: var(--accent); }

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 14px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 400;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
}

.nav-item:hover {
  background: var(--bg3);
  color: var(--text);
}

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

.nav-item svg { flex-shrink: 0; opacity: 0.8; }
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: capitalize;
}

/* ── Topbar ──────────────────────────────────────────────────────── */
.topbar {
  grid-column: 2;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
}

.topbar-title {
  font-size: 0.95rem;
  font-weight: 500;
  flex: 1;
  color: var(--text);
}

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

/* ── Main content ────────────────────────────────────────────────── */
.main {
  grid-column: 2;
  padding: 28px 28px 48px;
  overflow-y: auto;
}

/* ── Page header ─────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--text);
}

.page-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ── Cards ───────────────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.card-title {
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* ── KPI grid ────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.2s;
}

.kpi-card:hover { border-color: var(--border-md); }

.kpi-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.kpi-value {
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--text);
}

.kpi-value.ok     { color: var(--ok); }
.kpi-value.warn   { color: var(--warn); }
.kpi-value.danger { color: var(--danger); }

.kpi-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.gap-tag {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
}
.gap-tag.pos { background: var(--ok-dim); color: var(--ok); }
.gap-tag.neg { background: var(--danger-dim); color: var(--danger); }

/* ── Progress bar ────────────────────────────────────────────────── */
.progress {
  height: 3px;
  background: var(--bg3);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 8px;
}
.progress-bar {
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width 0.5s ease;
}
.progress-bar.ok     { background: var(--ok); }
.progress-bar.warn   { background: var(--warn); }
.progress-bar.danger { background: var(--danger); }

/* ── Grids ───────────────────────────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
}

/* ── Tables ──────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead tr {
  border-bottom: 1px solid var(--border);
}

th {
  text-align: left;
  padding: 10px 14px;
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
}

td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

tbody tr { transition: background 0.1s; }
tbody tr:hover { background: var(--bg3); }
tbody tr:last-child td { border-bottom: none; }

/* ── Badges ──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 5px;
  white-space: nowrap;
}
.badge-ok      { background: var(--ok-dim);     color: var(--ok); }
.badge-warn    { background: var(--warn-dim);   color: var(--warn); }
.badge-danger  { background: var(--danger-dim); color: var(--danger); }
.badge-neutral { background: var(--bg3);        color: var(--text-muted); }
.badge-accent  { background: var(--accent-dim); color: var(--accent); }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hov); color: #fff; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-md);
}
.btn-ghost:hover { background: var(--bg3); color: var(--text); }

.btn-danger {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid rgba(248,113,113,0.2);
}
.btn-danger:hover { background: rgba(248,113,113,0.2); }

.btn-sm { padding: 5px 11px; font-size: 0.8rem; }
.btn-icon { padding: 7px; }

/* ── Forms ───────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg3);
  border: 1px solid var(--border-md);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.875rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.form-control::placeholder { color: var(--text-dim); }

select.form-control { cursor: pointer; }

/* ── Alerts ──────────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-bottom: 16px;
}
.alert-danger  { background: var(--danger-dim); color: var(--danger);  border: 1px solid rgba(248,113,113,0.2); }
.alert-ok      { background: var(--ok-dim);     color: var(--ok);      border: 1px solid rgba(52,211,153,0.2); }
.alert-warn    { background: var(--warn-dim);   color: var(--warn);    border: 1px solid rgba(251,191,36,0.2); }
.alert-info    { background: var(--accent-dim); color: var(--accent);  border: 1px solid rgba(79,142,247,0.2); }

/* ── Operador card ───────────────────────────────────────────────── */
.op-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.op-card:last-child { border-bottom: none; }

.op-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg3);
  border: 1px solid var(--border-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
  letter-spacing: 0;
}

.op-info { flex: 1; min-width: 0; }
.op-name {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.op-login {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.op-metrics {
  display: flex;
  gap: 10px;
}
.op-metric {
  text-align: center;
  min-width: 52px;
}
.op-metric-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 1px;
}
.op-metric-val {
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font-mono);
}
.op-metric-val.ok     { color: var(--ok); }
.op-metric-val.warn   { color: var(--warn); }
.op-metric-val.danger { color: var(--danger); }

/* ── Tenant selector (topbar) ────────────────────────────────────── */
.tenant-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--bg3);
  border: 1px solid var(--border-md);
  border-radius: 20px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ── Period filter ───────────────────────────────────────────────── */
.period-filter {
  display: flex;
  align-items: center;
  gap: 8px;
}
.period-filter select {
  background: var(--bg3);
  border: 1px solid var(--border-md);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.82rem;
  padding: 5px 8px;
  cursor: pointer;
  outline: none;
}
.period-filter select:focus { border-color: var(--accent); }

/* ── Divider ─────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* ── Utilities ───────────────────────────────────────────────────── */
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.flex  { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 14px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.82rem; }
.font-mono { font-family: var(--font-mono); }
.w-full { width: 100%; }
.text-center { text-align: center; }
.section-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 7px;
}

/* ── Login page ──────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
}

.login-brand {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.04em;
  margin-bottom: 6px;
}
.login-brand span { color: var(--accent); }

.login-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 28px;
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
  }
  .topbar  { grid-column: 1; }
  .main    { grid-column: 1; padding: 16px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Animations ──────────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.animate { animation: fadeIn 0.25s ease both; }
.animate-d1 { animation-delay: 0.05s; }
.animate-d2 { animation-delay: 0.10s; }
.animate-d3 { animation-delay: 0.15s; }
.animate-d4 { animation-delay: 0.20s; }

/* ══════════════════════════════════════════════════════════════════
   MOBILE NAV — hambúrguer + overlay
   ══════════════════════════════════════════════════════════════════ */
.mobile-nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius);
}
.mobile-nav-toggle:hover { background: var(--bg3); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 199;
  backdrop-filter: blur(2px);
}

@media (max-width: 768px) {
  .mobile-nav-toggle { display: flex; align-items: center; }

  /* Sidebar: sai da grid e vira drawer fixo */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 200;
    height: 100dvh;
    width: 270px;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    /* Remove qualquer display:none residual */
    display: flex !important;
    visibility: visible;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0,0,0,0.45);
  }
  .sidebar-overlay.open { display: block; }

  .topbar { grid-column: 1; padding: 0 16px; gap: 10px; }
  .main   { grid-column: 1; padding: 16px 14px 80px; }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .kpi-value { font-size: 1.35rem; }

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

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 18px;
  }
  .page-header .btn { align-self: flex-start; }

  .op-metrics { display: none; }
  .op-card { gap: 10px; }

  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 480px; }

  .period-filter select { font-size: 0.78rem; padding: 4px 6px; }

  .topbar-actions .tenant-chip { display: none; }

  /* Footer fica acima do conteúdo para não cortar */
  .app-footer { padding: 16px; font-size: 0.72rem; }
}

/* ══════════════════════════════════════════════════════════════════
   COMPONENTES FALTANTES — usado em operadores, importar, ranking…
   ══════════════════════════════════════════════════════════════════ */

/* Layout helpers */
.d-flex       { display: flex; }
.align-center { align-items: center; }
.flex-end     { justify-content: flex-end; }
.flex-1       { flex: 1; min-width: 0; }
.fw-600       { font-weight: 600; }
.fw-700       { font-weight: 700; }
.text-xs      { font-size: 0.72rem; }
.text-right   { text-align: right; }
.mb-0         { margin-bottom: 0; }
.mt-1         { margin-top: 8px; }
.mt-2         { margin-top: 16px; }
.mb-2         { margin-bottom: 16px; }
.mb-3         { margin-bottom: 24px; }
.page-top     { margin-bottom: 24px; }
.page-body    { /* wrapper neutro */ }
.page-body-narrow { max-width: 680px; }

/* Stats mini */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px,1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: 4px; }
.stat-val   { font-size: 1.5rem; font-weight: 700; color: var(--text); }
.stat-val-sm{ font-size: 1rem;   font-weight: 600; color: var(--text); }
.mini-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px,1fr)); gap: 10px; }
.mini-stat { background: var(--bg3); border-radius: var(--radius); padding: 10px 12px; }

/* Flash / Alertas (nomenclatura antiga de alguns arquivos) */
.flash {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 14px;
}
.flash-ok, .flash.flash-ok       { background: var(--ok-dim);     color: var(--ok);     border: 1px solid rgba(52,211,153,.2); }
.flash-erro, .flash.flash-erro   { background: var(--danger-dim); color: var(--danger); border: 1px solid rgba(248,113,113,.2); }
.flash-aviso, .flash.flash-aviso { background: var(--warn-dim);   color: var(--warn);   border: 1px solid rgba(251,191,36,.2); }
.animate-in { animation: fadeIn .25s ease both; }

/* Badges extras */
.badge-green { background: var(--ok-dim);     color: var(--ok); }
.badge-muted { background: var(--bg3);        color: var(--text-muted); }
.text-success { color: var(--ok); }
.text-muted   { color: var(--text-muted); }
.text-green   { color: var(--ok); }
.text-red     { color: var(--danger); }
.text-amber   { color: var(--warn); }

/* Modal */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border-md);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-lg);
  position: relative;
}
.modal-title  { font-weight: 600; font-size: 1rem; margin-bottom: 18px; }
.modal-close  {
  position: absolute;
  top: 16px; right: 16px;
  background: none; border: none;
  color: var(--text-muted);
  cursor: pointer; padding: 4px;
  border-radius: 6px;
}
.modal-close:hover { background: var(--bg3); color: var(--text); }

/* Formulário helpers */
.form-row    { display: flex; gap: 12px; flex-wrap: wrap; }
.form-label  { display: block; font-size: 0.8rem; font-weight: 500; color: var(--text-muted); margin-bottom: 6px; }
.label-muted { color: var(--text-dim); font-size: .75rem; }
.select-sm   { font-size: .82rem; padding: 5px 8px; }
.input-wrap  { position: relative; }
.input-icon  { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-dim); pointer-events: none; }
.input-wrap .form-control { padding-left: 36px; }
.info-note   { font-size: .78rem; color: var(--text-muted); display: flex; align-items: flex-start; gap: 6px; }
.surface     { background: var(--bg3); border-radius: var(--radius); padding: 14px 16px; }

/* Tabela helpers */
.tt          { /* já herda de table */ }
.tt-total td { font-weight: 700; border-top: 2px solid var(--border-md); }
.tr-active td{ background: var(--accent-dim) !important; }
.tr-highlight td { background: var(--warn-dim); }
.th-num      { text-align: right; }
.td-truncate { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-truncate-sm { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Dropzone */
.dropzone {
  border: 2px dashed var(--border-md);
  border-radius: var(--radius-lg);
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  position: relative;
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.dropzone input[type=file] {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.dropzone-icon  { color: var(--text-dim); margin-bottom: 10px; }
.dropzone-title { font-weight: 500; margin-bottom: 4px; }
.dropzone-sub   { font-size: .78rem; color: var(--text-muted); }

/* Badge wrap (importar) */
.badge-wrap { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* Spinner */
.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  display: inline-block;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Skeleton loader */
.skeleton { background: var(--bg3); border-radius: var(--radius); animation: shimmer 1.4s infinite; }
.skeleton-card  { height: 100px; }
.skeleton-title { height: 20px; width: 60%; margin-bottom: 8px; }
.skeleton-text  { height: 14px; width: 90%; }
@keyframes shimmer {
  0%,100% { opacity: .5; }
  50%      { opacity: 1; }
}

/* Ranking / Podium */
.podium-wrap  { display: flex; align-items: flex-end; justify-content: center; gap: 8px; margin: 20px 0; }
.podium-item  { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.podium-medal { font-size: 1.4rem; }
.podium-name  { font-size: .75rem; font-weight: 500; text-align: center; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-score { font-size: .7rem; color: var(--text-muted); font-family: var(--font-mono); }
.podium-bar   { border-radius: 6px 6px 0 0; background: var(--bg3); border: 1px solid var(--border-md); min-width: 52px; }
.rank-pos     { font-family: var(--font-mono); font-size: .8rem; color: var(--text-dim); }

/* Feedback */
.feedback-list { display: flex; flex-direction: column; gap: 12px; }
.feedback-item { background: var(--bg3); border-radius: var(--radius); padding: 14px; border-left: 3px solid var(--border-md); }

/* Radio label */
.radio-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: .875rem; }

/* Plano badge */
.plano-badge-free  { background: var(--ok-dim);    color: var(--ok);    border: 1px solid rgba(52,211,153,.25); border-radius: 5px; padding: 2px 8px; font-size: .7rem; font-weight: 600; }
.plano-badge-pago  { background: var(--warn-dim);  color: var(--warn);  border: 1px solid rgba(251,191,36,.25);  border-radius: 5px; padding: 2px 8px; font-size: .7rem; font-weight: 600; }
.plano-badge-none  { background: var(--bg3);       color: var(--text-muted); border: 1px solid var(--border-md); border-radius: 5px; padding: 2px 8px; font-size: .7rem; font-weight: 600; }

/* Section title (usado em alguns arquivos legados) */
.section-title    { font-size: .8rem; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: 14px; }
.section-title-sm { font-size: .72rem; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); margin-bottom: 10px; }

/* Mobile: form-row vira coluna */
@media (max-width: 600px) {
  .form-row { flex-direction: column; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .modal { padding: 20px 16px; }
  .page-body-narrow { max-width: 100%; }
  .podium-wrap { gap: 4px; }
  .podium-bar { min-width: 40px; }
}

/* ── Theme toggle button ─────────────────────────────────────────── */
.theme-toggle {
  background: none;
  border: 1px solid var(--border-md);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  font-family: var(--font);
  transition: all .15s;
  white-space: nowrap;
}
.theme-toggle:hover { background: var(--bg3); color: var(--text); }
.theme-toggle .icon-dark  { display: inline; }
.theme-toggle .icon-light { display: none;   }
[data-theme="light"] .theme-toggle .icon-dark  { display: none;   }
[data-theme="light"] .theme-toggle .icon-light { display: inline; }

/* ── App footer ──────────────────────────────────────────────────── */
.app-footer {
  grid-column: 2;
  padding: 16px 28px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: .72rem;
  color: var(--text-dim);
  gap: 6px;
}
.app-footer a { color: var(--text-dim); text-decoration: none; }
.app-footer a:hover { color: var(--text-muted); text-decoration: underline; }
@media (max-width: 768px) {
  .app-footer { grid-column: 1; padding: 12px 16px; justify-content: center; }
}

/* ── Login footer créditos ───────────────────────────────────────── */
.login-credits {
  margin-top: 28px;
  text-align: center;
  font-size: .72rem;
  color: var(--text-dim);
  line-height: 1.7;
}
.login-credits a { color: var(--text-dim); }
.login-credits a:hover { color: var(--text-muted); }
