:root {
  --indigo: #4f46e5;
  --indigo-dark: #3730a3;
  --indigo-soft: #eef0fd;
  --bg: #f3f4f8;
  --card: #ffffff;
  --border: #e3e5ee;
  --text: #1e2033;
  --text-muted: #6b6f8a;
  --red: #c0392b;
  --red-soft: #fdecea;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(30, 32, 51, 0.04), 0 4px 16px rgba(30, 32, 51, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.topbar {
  background: var(--indigo-dark);
  color: #fff;
  padding: 14px 20px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}

.topbar-inner {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--indigo);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

nav a {
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, color 0.15s;
}

nav a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

nav a.ativo {
  background: var(--indigo);
  color: #fff;
}

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 28px 20px 72px;
}

.page-head {
  margin-bottom: 20px;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}

h1 .emoji {
  font-size: 1.3rem;
}

.subtitulo {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin: 0;
}

h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 28px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 12px;
}

.tenant-bar {
  background: var(--indigo-soft);
  border: 1px solid #d7d9f7;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 0 0 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tenant-bar-rotulo {
  color: var(--indigo-dark);
  font-weight: 700;
  font-size: 0.86rem;
}

.tenant-bar-rotulo a {
  color: var(--indigo);
  text-decoration: underline;
}

.tenant-bar-select {
  padding: 6px 10px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--indigo-dark);
  background: #fff;
  border: 1px solid #c7caf2;
  border-radius: var(--radius-sm);
  min-width: 220px;
}

.erro {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid #f3b4ac;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin: 0 0 18px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.erro::before {
  content: "⚠️";
}

.erro[hidden] {
  display: none;
}

.painel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 20px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin: 0 0 20px;
  font-size: 0.88rem;
}

.tabela-scroll {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 0 0 20px;
}

.tabela-scroll table {
  box-shadow: none;
  margin: 0;
  min-width: 640px;
}

th, td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  background: var(--indigo-soft);
  color: var(--indigo-dark);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

tbody tr:hover {
  background: #fafafe;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin: 0 0 20px;
  max-width: 560px;
}

.card label {
  display: block;
  margin-bottom: 14px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-muted);
}

.card label strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
  font-weight: 600;
  font-size: 0.86rem;
}

.card input,
.card select,
.card textarea {
  width: 100%;
  padding: 9px 11px;
  margin-top: 4px;
  box-sizing: border-box;
  font-size: 0.92rem;
  font-family: inherit;
  font-weight: 400;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.card input:focus,
.card select:focus,
.card textarea:focus {
  outline: none;
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--indigo-soft);
}

.card textarea {
  min-height: 80px;
  resize: vertical;
}

select:not(.card select) {
  padding: 9px 11px;
  font-size: 0.92rem;
  font-family: inherit;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  margin: 6px 0 16px;
  min-width: 240px;
}

label[for] {
  display: block;
}

label[for] strong {
  font-size: 0.86rem;
  font-weight: 600;
}

.dica {
  color: var(--text-muted);
  font-size: 0.84rem;
  margin: -6px 0 16px;
  line-height: 1.5;
}

.dica code {
  background: var(--indigo-soft);
  color: var(--indigo-dark);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.82rem;
}

button {
  background: var(--indigo);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}

button:hover {
  background: var(--indigo-dark);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  background: #c7c9da;
  cursor: not-allowed;
}

button.secundario {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}

button.secundario:hover {
  background: #f6f7fb;
  border-color: #c7c9da;
}

button + button {
  margin-left: 8px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.01em;
}

.badge-rascunho { background: #8a8da3; }
.badge-enviado { background: #4f46e5; }
.badge-pendente { background: #c98a1c; }
.badge-aprovado { background: #1e9e62; }
.badge-rejeitado { background: #c0392b; }

.badge-contato-pendente { background: #8a8da3; }
.badge-contato-enviado { background: #4f46e5; }
.badge-contato-entregue { background: #1591a8; }
.badge-contato-lido { background: #1e9e62; }
.badge-contato-falhou { background: #c0392b; }
.badge-contato-retido { background: #c98a1c; }

.motivo {
  display: block;
  font-size: 0.78rem;
  color: var(--red);
  margin-top: 4px;
}

.vazio {
  color: var(--text-muted);
  font-style: italic;
  padding: 18px 14px;
  text-align: center;
}

.kv-lista {
  padding: 0 20px;
}

.kv-lista a {
  color: var(--indigo);
  font-weight: 600;
  text-decoration: none;
}

.kv-lista a:hover {
  text-decoration: underline;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.home-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  text-decoration: none;
  color: var(--text);
  display: block;
  transition: transform 0.12s, box-shadow 0.12s;
}

.home-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(30, 32, 51, 0.06), 0 10px 24px rgba(30, 32, 51, 0.1);
}

.home-card .emoji {
  font-size: 1.6rem;
  display: block;
  margin-bottom: 10px;
}

.home-card h3 {
  margin: 0 0 6px;
  color: var(--indigo-dark);
}

.home-card p {
  margin: 0;
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.passo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--indigo);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  flex-shrink: 0;
}

#tela-login {
  position: fixed;
  inset: 0;
  background: rgba(30, 32, 51, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.login-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.25);
  padding: 32px 28px;
  max-width: 340px;
  width: 100%;
  text-align: center;
}

.login-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--indigo);
  color: #fff;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}

.login-card h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
  justify-content: center;
}

.login-card p {
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.5;
  margin: 0 0 18px;
}

.login-card input {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  box-sizing: border-box;
  text-align: center;
}

.login-card input:focus {
  outline: none;
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px var(--indigo-soft);
}

.login-card button {
  width: 100%;
}

@media (max-width: 640px) {
  .topbar-inner {
    flex-direction: column;
    align-items: flex-start;
  }
  nav {
    width: 100%;
  }
  main {
    padding: 20px 14px 56px;
  }
  .card {
    max-width: none;
  }
}
