/* ============================================================
   Painel Rondonet — Design System Escuro
   Paleta: bg #020617  sidebar #0f172a  card #111827
           primary #3b82f6  text #f1f5f9  muted #64748b
   Fonte:  Inter / Space Grotesk
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  --bg-app:       #020617;
  --bg-sidebar:   #0f172a;
  --bg-card:      #111827;
  --bg-card-alt:  #0f172a;
  --bg-input:     #0c1425;
  --border:       #1e293b;
  --border-light: #263248;

  --text:         #f1f5f9;
  --text-sub:     #94a3b8;
  --muted:        #64748b;

  --primary:      #3b82f6;
  --primary-deep: #2563eb;
  --primary-faint:rgba(59,130,246,.12);

  --accent:       #f59e0b;
  --danger:       #ef4444;
  --danger-faint: rgba(239,68,68,.12);
  --success:      #22c55e;
  --success-faint:rgba(34,197,94,.12);
  --info:         #38bdf8;

  /* compat — keep old names used by templates */
  --ink:          #0f172a;
  --ink-soft:     #162032;
  --surface:      #020617;
  --card:         #111827;
  --line:         #1e293b;
  --bg1:          #020617;
  --bg2:          #0f172a;
  --bg3:          #111827;

  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.5), 0 4px 20px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-app);
  color: var(--text);
  line-height: 1.5;
}

/* ── Layout ── */
.app { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  color: var(--text-sub);
  padding: 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: width .22s ease, min-width .22s ease;
  overflow-x: hidden;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 2px; }

/* Sidebar collapsed */
.app.sidebar-collapsed .sidebar {
  width: 0;
  min-width: 0;
  border-right: none;
}

/* Botão de toggle do sidebar */
.btn-sidebar-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--muted);
  cursor: pointer;
  padding: 5px 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
  flex-shrink: 0;
  line-height: 1;
}
.btn-sidebar-toggle:hover {
  color: var(--text);
  border-color: var(--border-light);
  background: rgba(255,255,255,.04);
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand .dot {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  display: grid; place-items: center;
  font-family: 'Space Grotesk'; font-weight: 700; color: #fff; font-size: 14px;
  flex-shrink: 0;
}
.brand .name {
  font-family: 'Space Grotesk'; font-weight: 700; font-size: 14px;
  color: #fff; letter-spacing: -.01em; line-height: 1.2;
}
.brand .sub { display: block; font-size: 10px; color: var(--muted); margin-top: 1px; font-weight: 400; }

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

.nav a {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 8px;
  color: var(--muted); text-decoration: none; font-size: 12.5px; font-weight: 500;
  border-left: 2px solid transparent;
  transition: background .12s, color .12s;
  white-space: nowrap; overflow: hidden;
}
.nav a:hover { background: rgba(255,255,255,.05); color: var(--text-sub); }
.nav a.active {
  background: var(--primary-faint); color: #93c5fd; font-weight: 600;
  border-left-color: var(--primary);
}
.nav a .ic { width: 16px; text-align: center; flex-shrink: 0; font-size: 13px; }
.nav .sep {
  font-size: 10px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--border-light); padding: 12px 10px 3px; font-weight: 600;
}

/* sidebar user footer */
.sidebar-user {
  margin-top: auto; border-top: 1px solid var(--border);
  padding: 10px 12px; flex-shrink: 0;
}
.user-info { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  display: grid; place-items: center;
  font-weight: 700; color: #fff; font-size: 12px; flex-shrink: 0;
}
.user-name  { font-size: 12px; font-weight: 600; color: var(--text); line-height: 1.2; }
.user-role  { font-size: 10px; margin-top: 2px; font-weight: 500; }
.user-actions { display: flex; gap: 4px; }

.sidebar .foot {
  padding: 8px 12px;
  font-size: 10px; color: var(--muted);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── Main area ── */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg-app); }

.topbar {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; padding: 24px 32px 0;
  border-bottom: 1px solid var(--border);
  padding-bottom: 20px;
}
.topbar h1 {
  font-family: 'Space Grotesk'; font-weight: 700; font-size: 22px;
  margin: 0; letter-spacing: -.3px; color: var(--text);
}
.topbar .eyebrow {
  font-size: 11px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--primary); font-weight: 600; margin-bottom: 4px;
}
.content { padding: 24px 32px 48px; }

/* ── Cards (home/grid) ── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 14px; }
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; text-decoration: none; color: inherit; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px; min-height: 120px;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.card.link:hover {
  transform: translateY(-2px); border-color: var(--primary);
  box-shadow: 0 8px 24px rgba(59,130,246,.15);
}
.card h3 { font-family: 'Space Grotesk'; font-weight: 600; font-size: 15px; margin: 0; color: var(--text); }
.card p { margin: 0; color: var(--muted); font-size: 12.5px; }
.card .tag {
  align-self: flex-start; margin-top: auto; font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px;
}
.tag.on   { background: var(--success-faint); color: var(--success); }
.tag.soon { background: rgba(255,255,255,.06); color: var(--muted); }

/* ── Metrics (resumo) ── */
.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px,1fr)); gap: 12px; }
.metric {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.metric .v { font-family: 'Space Grotesk'; font-weight: 700; font-size: 28px; line-height: 1; color: var(--text); }
.metric .l { font-size: 12px; color: var(--muted); margin-top: 6px; }
.metric.danger .v { color: var(--danger); }
.metric.warn   .v { color: var(--accent); }
.metric.good   .v { color: var(--success); }
.metric .bar { height: 3px; border-radius: 3px; margin-top: 10px; background: var(--border); }
.metric.danger .bar { background: var(--danger); }
.metric.warn   .bar { background: var(--accent); }
.metric.good   .bar { background: var(--success); }

/* ── Painel / Form de auditoria ── */
.panel {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px; margin-bottom: 20px;
}
.searchrow { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.field input {
  font: inherit; padding: 10px 14px; border: 1px solid var(--border);
  border-radius: 10px; min-width: 240px; background: var(--bg-input); color: var(--text);
  transition: border-color .15s, outline .15s;
}
.field input::placeholder { color: var(--muted); }
.field input:focus { outline: 2px solid rgba(59,130,246,.4); border-color: var(--primary); }

.field select {
  font: inherit; padding: 10px 14px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--bg-input); color: var(--text);
  appearance: auto; min-width: 200px;
}
.field select:focus { outline: 2px solid rgba(59,130,246,.4); border-color: var(--primary); }
.field select option { background: var(--bg-card); }

.btn {
  font: inherit; font-weight: 600; cursor: pointer; border: 0;
  background: var(--primary); color: #fff; padding: 10px 22px; border-radius: 10px;
  transition: background .15s; font-size: 14px;
}
.btn:hover { background: var(--primary-deep); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Auditoria resultado ── */
.res-head {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.res-head .id { font-family: 'Space Grotesk'; font-weight: 700; font-size: 18px; color: var(--text); }
.res-head .origin { font-size: 12px; color: var(--muted); margin-left: auto; }

table.audit { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.audit thead th {
  text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 600; padding: 0 14px 10px; border-bottom: 1px solid var(--border);
}
table.audit tbody td { padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.audit tbody tr:last-child td { border-bottom: 0; }
table.audit tbody tr:hover { background: rgba(255,255,255,.02); }
table.audit tbody td:first-child { border-left: 3px solid var(--border); font-weight: 500; }
tr.g-baixa td:first-child { border-left-color: var(--success); }
tr.g-media td:first-child { border-left-color: var(--accent); }
tr.g-alta  td:first-child { border-left-color: var(--danger); }

/* ── Pills / badges ── */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.aprovado   { background: var(--success-faint); color: var(--success); }
.pill.erro       { background: rgba(245,158,11,.12); color: #fbbf24; }
.pill.erro_grave { background: var(--danger-faint);  color: var(--danger); }
.pill.pendente   { background: rgba(245,158,11,.12); color: #fbbf24; }

.grav { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; }
.grav.baixa { background: var(--success-faint); color: var(--success); }
.grav.media { background: rgba(245,158,11,.12);  color: #fbbf24; }
.grav.alta  { background: var(--danger-faint);   color: var(--danger); }

/* ── Alertas / vazios ── */
.alert {
  border-radius: 10px; padding: 13px 16px; font-size: 13.5px; margin-bottom: 16px;
  border: 1px solid; display: flex; gap: 10px; align-items: flex-start;
}
.alert.err  { background: rgba(239,68,68,.08);   border-color: rgba(239,68,68,.25);  color: #fca5a5; }
.alert.info { background: rgba(56,189,248,.08);  border-color: rgba(56,189,248,.2);  color: #7dd3fc; }

.empty { text-align: center; color: var(--muted); padding: 48px 24px; }
.empty .big { font-family: 'Space Grotesk'; font-size: 18px; color: var(--text-sub); margin-bottom: 8px; }

/* ── Empty state moderno ── */
.empty-state-box {
  text-align: center; padding: 56px 32px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.empty-state-box .eso-icon { font-size: 40px; opacity: .4; }
.empty-state-box .eso-title { font-family: 'Space Grotesk'; font-size: 17px; font-weight: 600; color: var(--text-sub); }
.empty-state-box .eso-desc  { font-size: 13px; color: var(--muted); max-width: 380px; }

.note { font-size: 12px; color: var(--muted); margin-top: 12px; }
.kbd  { font-family: ui-monospace, monospace; background: var(--border); padding: 2px 6px;
        border-radius: 5px; font-size: 11px; color: var(--text-sub); }

/* ── AUTH ── */
.auth-body {
  background: var(--bg-app); display: flex; align-items: center;
  justify-content: center; min-height: 100vh; padding: 24px;
}
.auth-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 18px;
  box-shadow: 0 8px 40px rgba(0,0,0,.5); padding: 40px; width: 100%; max-width: 420px;
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.auth-brand .dot {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  display: grid; place-items: center;
  font-family: 'Space Grotesk'; font-weight: 700; color: #fff; font-size: 18px;
}
.auth-brand .name { font-family: 'Space Grotesk'; font-weight: 700; font-size: 17px; color: var(--text); }
.auth-brand .sub  { display: block; font-size: 11px; color: var(--muted); }
.auth-title { font-family: 'Space Grotesk'; font-weight: 700; font-size: 20px;
  margin: 0 0 20px; color: var(--text); }
.auth-info  { font-size: 13px; color: var(--muted); margin: 12px 0 0; line-height: 1.6; }
.auth-divider {
  text-align: center; position: relative; margin: 18px 0; color: var(--muted); font-size: 12px;
}
.auth-divider::before, .auth-divider::after {
  content: ''; position: absolute; top: 50%; width: 40%; height: 1px; background: var(--border);
}
.auth-divider::before { left: 0; }
.auth-divider::after  { right: 0; }
.otp-icon { font-size: 40px; text-align: center; margin-bottom: 8px; }
.otp-input {
  font-size: 26px !important; letter-spacing: 10px; text-align: center;
  padding: 14px !important; font-family: 'Space Grotesk' !important; font-weight: 600 !important;
}

/* ── Botões extras ── */
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-deep); }
.btn-secondary { background: rgba(255,255,255,.06); color: var(--text-sub); border: 1px solid var(--border); }
.btn-secondary:hover { background: rgba(255,255,255,.1); }
.btn-ghost     { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-ghost:hover { background: var(--primary-faint); }
.btn-danger-ghost  { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-faint); }
.btn-success-ghost { background: transparent; color: var(--success); border: 1px solid var(--success); }
.btn-success-ghost:hover { background: var(--success-faint); }
.btn-full { width: 100%; text-align: center; display: block; }
.btn-sm   { padding: 6px 14px; font-size: 12.5px; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 7px; background: rgba(255,255,255,.06);
  color: var(--muted); text-decoration: none; font-size: 14px;
  transition: background .12s; border: 0; cursor: pointer;
}
.btn-icon:hover { background: rgba(255,255,255,.12); color: var(--text-sub); }
.btn-logout:hover { background: rgba(239,68,68,.2); color: #f87171; }

/* ── Flash / alertas globais ── */
.flash-wrap { padding: 0 32px; margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.flash { border-radius: 10px; padding: 11px 16px; font-size: 13.5px; border: 1px solid; }
.flash-success { background: rgba(34,197,94,.1);  border-color: rgba(34,197,94,.25);  color: #86efac; }
.flash-danger  { background: rgba(239,68,68,.1);  border-color: rgba(239,68,68,.25);  color: #fca5a5; }
.flash-warning { background: rgba(245,158,11,.1); border-color: rgba(245,158,11,.25); color: #fcd34d; }
.flash-info    { background: rgba(56,189,248,.1); border-color: rgba(56,189,248,.2);  color: #7dd3fc; }

/* ── Badges / roles ── */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-success { background: var(--success-faint); color: var(--success); }
.badge-danger  { background: var(--danger-faint);  color: var(--danger);  }
.badge-neutral { background: rgba(255,255,255,.07); color: var(--muted);  }

.role-admin_master { background: rgba(245,158,11,.15); color: #fcd34d; }
.role-admin_tenant { background: rgba(99,102,241,.15); color: #a5b4fc; }
.role-lider        { background: var(--primary-faint); color: #93c5fd; }
.role-analista     { background: rgba(255,255,255,.07);color: var(--muted); }

/* ── Tabela admin ── */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%; border-collapse: collapse; font-size: 13.5px;
  background: var(--bg-card); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  overflow: hidden;
}
.table thead th {
  text-align: left; padding: 11px 16px;
  font-size: 10px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border);
  background: var(--bg-card-alt); white-space: nowrap;
}
.table tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: rgba(255,255,255,.025); }
.row-inactive { opacity: .45; }
.muted  { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* ── KPI cards ── */
.kpi-card { min-height: auto !important; gap: 6px !important; padding: 18px !important; }
.kpi-label { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.kpi-value { font-family: 'Space Grotesk'; font-weight: 700; font-size: 26px; color: var(--text); }
.kpi-danger .kpi-value { color: var(--danger); }

/* ── TOTP setup ── */
.totp-steps { display: flex; flex-direction: column; gap: 12px; }
.totp-step  { display: flex; align-items: flex-start; gap: 12px; font-size: 13.5px; color: var(--text-sub); }
.step-num   { flex-shrink: 0; width: 24px; height: 24px; border-radius: 50%;
              background: var(--primary); color: #fff;
              display: grid; place-items: center; font-weight: 700; font-size: 12px; }

/* ── Misc ── */
.info-box {
  background: var(--primary-faint); border: 1px solid rgba(59,130,246,.25); border-radius: 10px;
  padding: 13px 16px; font-size: 13px; color: #93c5fd;
}
.link-muted { color: var(--muted); font-size: 13px; text-decoration: none; }
.link-muted:hover { color: var(--primary); }
.empty-state { text-align: center; color: var(--muted); padding: 48px 0; font-size: 14px; }

/* ── Responsivo ── */
@media (max-width: 768px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row;
             flex-wrap: wrap; align-items: center; gap: 4px; padding: 12px; overflow: visible; }
  .sidebar::-webkit-scrollbar { display: none; }
  .brand { border-bottom: 0; padding: 0; }
  .nav { display: flex; flex-direction: row; flex-wrap: wrap; gap: 3px; padding: 0; }
  .nav .sep, .sidebar .foot, .sidebar-user { display: none; }
  .nav a { padding: 6px 10px; border-left: 0; }
  .topbar, .content { padding-left: 16px; padding-right: 16px; }
  .topbar { padding-top: 16px; padding-bottom: 14px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
