:root {
  --bg: #f1f2ec;
  --surface: #ffffff;
  --surface-2: #eaece3;
  --ink: #14181a;
  --ink-muted: #666f6b;
  --border: #dde1d6;
  --accent: #4c3bcf;
  --accent-soft: #ece9fb;
  --accent-ink: #ffffff;
  --success: #257a41;
  --success-bg: #e3f3e8;
  --warning: #9c6206;
  --warning-bg: #faedd6;
  --critical: #b3372e;
  --critical-bg: #fbe7e4;
  --shadow-sm: 0 1px 2px rgba(20, 24, 26, .05);
  --shadow-md: 0 4px 16px rgba(20, 24, 26, .07);
  --shadow-lg: 0 12px 32px rgba(20, 24, 26, .10);
  --sidebar-bg: #1a1533;
  --sidebar-bg-2: #221c40;
  --sidebar-ink: #f1eefb;
  --sidebar-muted: #9d94c4;
  --sidebar-active-bg: rgba(255,255,255,.08);
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Work Sans', -apple-system, Segoe UI, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); text-wrap: balance; margin: 0 0 4px; letter-spacing: -.01em; }
h1 { font-size: 30px; font-weight: 600; }
h2 { font-size: 20px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }
p { margin: 0 0 12px; color: var(--ink-muted); }

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

.mono, .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.icone { display: inline-block; vertical-align: -4px; flex-shrink: 0; }

/* Layout: sidebar + conteúdo */
.app-shell { min-height: 100vh; display: flex; }

.sidebar {
  width: 236px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
  color: var(--sidebar-ink);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 26px;
}
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.brand-nome { font-family: var(--font-display); font-weight: 600; font-size: 17px; }

.sidenav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidenav a {
  display: flex; align-items: center; gap: 11px;
  color: var(--sidebar-muted);
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}
.sidenav a:hover { background: var(--sidebar-active-bg); color: var(--sidebar-ink); }
.sidenav a.active { background: var(--accent); color: #fff; }

.sideuser { border-top: 1px solid rgba(255,255,255,.1); padding-top: 14px; display: flex; align-items: center; gap: 8px; }
.sideuser-link { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; color: var(--sidebar-ink); text-decoration: none; padding: 6px; border-radius: 9px; }
.sideuser-link:hover { background: var(--sidebar-active-bg); text-decoration: none; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,.12);
  color: var(--sidebar-ink);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
  flex-shrink: 0;
}
.sideuser-info { display: flex; flex-direction: column; min-width: 0; }
.sideuser-nome { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sideuser-papel { font-size: 11px; color: var(--sidebar-muted); text-transform: uppercase; letter-spacing: .05em; }
.sideuser-sair { color: var(--sidebar-muted); padding: 8px; border-radius: 8px; display: flex; }
.sideuser-sair:hover { background: var(--sidebar-active-bg); color: var(--sidebar-ink); }

.content-area { flex: 1; min-width: 0; }
main { padding: 34px 40px; max-width: 1180px; margin: 0 auto; }

.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.grid-cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 28px; }
.stat-tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.stat-tile .label { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-muted); margin-bottom: 8px; font-weight: 600; }
.stat-tile .value { font-family: var(--font-mono); font-size: 28px; font-weight: 600; letter-spacing: -.01em; }
.stat-tile .icone-wrap {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* Grupos de objetivo */
.grupo-objetivo { margin-bottom: 32px; }
.grupo-objetivo .grupo-titulo { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.grupo-objetivo .grupo-titulo .icone-wrap {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.grupo-objetivo h2 { margin: 0; }
.grupo-objetivo .contagem { font-family: var(--font-mono); font-size: 13px; color: var(--ink-muted); font-weight: 400; margin-left: 2px; }

.client-row {
  display: grid;
  grid-template-columns: auto 1.6fr 1fr 1fr 0.9fr auto;
  gap: 16px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 9px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s ease, transform .15s ease;
}
.client-row:hover { box-shadow: var(--shadow-md); }
.client-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; font-family: var(--font-mono);
}
.client-row .nome { font-weight: 600; }
.client-row .segmento { font-size: 12px; color: var(--ink-muted); }
.client-row .metric-label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-muted); margin-bottom: 3px; font-weight: 600; }
.client-row .metric-value { font-family: var(--font-mono); font-weight: 600; font-size: 15px; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; }
.pill.bom { background: var(--success-bg); color: var(--success); }
.pill.bom::before { background: var(--success); }
.pill.atencao { background: var(--warning-bg); color: var(--warning); }
.pill.atencao::before { background: var(--warning); }
.pill.critico { background: var(--critical-bg); color: var(--critical); }
.pill.critico::before { background: var(--critical); }

/* Tabelas */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-muted); font-weight: 700; }
td.num { text-align: right; font-family: var(--font-mono); }
th.num { text-align: right; }
tbody tr:hover { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

/* Formulários */
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
input, select, textarea {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.field { margin-bottom: 16px; }
.field-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  padding: 11px 20px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(76,59,207,.25);
}
.btn:hover { opacity: .93; text-decoration: none; }
.btn.secundario { background: var(--surface); color: var(--ink); border: 1px solid var(--border); box-shadow: none; }
.btn.perigo { background: var(--critical); box-shadow: 0 2px 8px rgba(179,55,46,.25); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.alerta {
  padding: 14px 18px;
  border-radius: 12px;
  margin-bottom: 20px;
  font-size: 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.alerta.erro { background: var(--critical-bg); color: var(--critical); }
.alerta.sucesso { background: var(--success-bg); color: var(--success); }
.alerta.info { background: var(--accent-soft); color: var(--accent); }

.login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(circle at 20% 20%, #241d47, #14102b 60%);
}
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 38px; width: 100%; max-width: 390px; box-shadow: var(--shadow-lg); }
.login-card .brand-mark { margin-bottom: 14px; }

.empty-state { text-align: center; padding: 56px 20px; color: var(--ink-muted); }
.empty-state .icone-wrap {
  width: 52px; height: 52px; border-radius: 14px; margin: 0 auto 16px;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}

.tabs { display: flex; gap: 6px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.tabs a { padding: 9px 14px; font-size: 14px; font-weight: 500; color: var(--ink-muted); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); }

@media (max-width: 860px) {
  .sidebar { position: fixed; z-index: 20; transform: translateX(-100%); transition: transform .2s ease; }
  .client-row { grid-template-columns: auto 1fr 1fr; }
  main { padding: 20px; }
}
