:root {
  --at-bg: #f4f6f8;
  --at-surface: #ffffff;
  --at-ink: #12202e;
  --at-muted: #5b6b7c;
  --at-line: #e3e8ee;
  --at-brand: #0f6e56;
  --at-brand-2: #0b4f3f;
  --at-accent: #c9782c;
  --at-sidebar: #10233a;
  --at-sidebar-2: #16324f;
  --at-sidebar-text: #d7e2ef;
  --at-sidebar-muted: #8fa3b8;
  --at-ok: #1f8a5b;
  --at-warn: #c9782c;
  --at-danger: #c0392b;
  --at-sidebar-w: 272px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Manrope", system-ui, sans-serif;
}

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

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--at-ink);
  background: var(--at-bg);
  min-height: 100vh;
}

a { color: var(--at-brand); }

.app-shell {
  min-height: 100vh;
  display: flex;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--at-sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--at-sidebar) 0%, #0c1a2b 100%);
  color: var(--at-sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 1040;
  border-right: 1px solid rgba(255,255,255,.06);
}

.sidebar-brand {
  padding: 1.35rem 1.25rem 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand .brand-mark {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #fff;
  text-decoration: none;
  display: block;
  line-height: 1.2;
}

.sidebar-brand .brand-sub {
  display: block;
  margin-top: .35rem;
  font-size: .75rem;
  color: var(--at-sidebar-muted);
}

.sidebar-nav {
  padding: 1rem .85rem;
  overflow-y: auto;
  flex: 1;
}

.nav-section {
  margin-bottom: 1.25rem;
}

.nav-section-label {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--at-sidebar-muted);
  padding: 0 .65rem;
  margin-bottom: .45rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .65rem .75rem;
  border-radius: .7rem;
  color: var(--at-sidebar-text);
  text-decoration: none;
  font-size: .92rem;
  font-weight: 500;
  transition: background .15s ease, color .15s ease;
}

.sidebar-link:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
}

.sidebar-link.active {
  background: rgba(15, 110, 86, .35);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(95, 201, 166, .25);
}

.sidebar-link .nav-ico {
  width: 1.25rem;
  text-align: center;
  opacity: .85;
  font-size: .95rem;
}

.sidebar-footer {
  padding: 1rem 1.1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.08);
}

.tenant-chip {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: .75rem;
  padding: .7rem .8rem;
  margin-bottom: .75rem;
}

.tenant-chip .label {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--at-sidebar-muted);
}

.tenant-chip .value {
  font-size: .9rem;
  font-weight: 600;
  color: #fff;
  margin-top: .15rem;
  word-break: break-word;
}

.sidebar-user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  color: var(--at-sidebar-muted);
  font-size: .82rem;
}

.sidebar-user strong {
  color: var(--at-sidebar-text);
  font-weight: 600;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  background: rgba(244, 246, 248, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--at-line);
  padding: .75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: .75rem;
}

.topbar-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.02em;
}

.content-area {
  padding: 1.25rem 1.25rem 2rem;
  flex: 1;
}

.page-head {
  margin-bottom: 1.5rem;
}

.page-head h1 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 2vw, 1.85rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  margin: 0 0 .35rem;
}

.page-head p {
  color: var(--at-muted);
  margin: 0;
}

.surface {
  background: var(--at-surface);
  border: 1px solid var(--at-line);
  border-radius: 1rem;
}

.stat-card {
  background: var(--at-surface);
  border: 1px solid var(--at-line);
  border-radius: 1rem;
  padding: 1rem 1.1rem;
  height: 100%;
}

.stat-card .label {
  color: var(--at-muted);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.stat-card .value {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 600;
  margin-top: .2rem;
  letter-spacing: -0.03em;
}

.aviso-legal {
  margin-top: 2rem;
  padding: .9rem 1rem;
  border-radius: .85rem;
  background: #eef2f6;
  color: var(--at-muted);
  font-size: .82rem;
  border: 1px solid var(--at-line);
}

.btn-brand {
  background: var(--at-brand);
  border-color: var(--at-brand);
  color: #fff;
}
.btn-brand:hover {
  background: var(--at-brand-2);
  border-color: var(--at-brand-2);
  color: #fff;
}

.status-correto { color: var(--at-ok); }
.status-divergente, .status-alto_risco { color: var(--at-danger); }
.status-revisao_manual, .status-incompleto { color: var(--at-warn); }
.status-sem_regra { color: var(--at-muted); }

/* ---------- Mobile ---------- */
.sidebar-backdrop {
  display: none;
}

@media (max-width: 991.98px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: 12px 0 40px rgba(0,0,0,.25);
  }

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

  body.sidebar-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(8, 16, 28, .45);
    z-index: 1035;
  }

  .content-area {
    padding: 1rem 1rem 1.75rem;
  }
}

/* ---------- Auth ---------- */
.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(15,110,86,.18), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(201,120,44,.12), transparent 50%),
    linear-gradient(160deg, #0f1c2b 0%, #16324f 45%, #1a3d3a 100%);
}

.auth-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 1.25rem;
  padding: 1.75rem;
  box-shadow: 0 24px 60px rgba(0,0,0,.25);
}

.auth-card h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  letter-spacing: -0.03em;
  margin-bottom: .25rem;
}

.auth-card .lead {
  color: var(--at-muted);
  font-size: .92rem;
  margin-bottom: 1.25rem;
}

.form-label { font-weight: 600; font-size: .88rem; }
.form-control, .form-select {
  border-radius: .65rem;
  border-color: #cfd8e3;
  padding: .65rem .8rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--at-brand);
  box-shadow: 0 0 0 .2rem rgba(15,110,86,.15);
}

.table > :not(caption) > * > * {
  padding: .85rem .9rem;
}
