:root {
  --bg: #0f1420;
  --surface: #161d2e;
  --surface-2: #1e263a;
  --border: #2a3348;
  --text: #e8ecf5;
  --muted: #8b95ab;
  --primary: #4f7fff;
  --primary-hover: #6a92ff;
  --danger: #ef5a5a;
  --success: #3cb873;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 0.85rem; }

/* ---------- Login ---------- */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.login-card h1 { margin: 0; font-size: 1.4rem; }
.login-card label { font-size: 0.85rem; color: var(--muted); margin-top: 0.4rem; }
.login-card input {
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
}

/* ---------- Botões ---------- */

.btn-primary, .btn-secondary, .btn-small, .btn-danger {
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  font-size: 0.9rem;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
}
.btn-primary { background: var(--primary); color: white; border: none; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--primary); }
.btn-small { font-size: 0.78rem; padding: 0.25rem 0.6rem; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); }
.btn-small:hover { border-color: var(--primary); }

/* ---------- Shell / sidebar ---------- */

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

.sidebar {
  width: 240px;
  flex: 0 0 auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.2rem 0.9rem;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 1.4rem;
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}
.sidebar-brand span { font-weight: 400; font-size: 0.75rem; }

.sidebar-nav { display: flex; flex-direction: column; gap: 0.25rem; flex: 1; }
.sidebar-nav button {
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
}
.sidebar-nav button:hover { background: var(--surface-2); }
.sidebar-nav button.active { background: var(--primary); color: white; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.sidebar-user-name { font-weight: 600; font-size: 0.9rem; }
.sidebar-link {
  text-align: left;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 0.3rem 0;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
}
.sidebar-link:hover { color: var(--primary); }

.content { flex: 1; padding: 1.6rem 2rem; min-width: 0; }

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.view-header h2 { margin: 0; }

/* ---------- Formulários inline ---------- */

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  margin-bottom: 1.2rem;
}
.form-card h3 { margin-top: 0; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}
.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field-wide { grid-column: 1 / -1; }
.field label { font-size: 0.8rem; color: var(--muted); }
.field input, .field select, .field textarea {
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}
.form-actions { display: flex; gap: 0.6rem; margin-top: 0.4rem; }

.block-label { display: block; font-size: 0.8rem; color: var(--muted); margin: 0.8rem 0 0.4rem; }
.checks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.35rem 1rem;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem;
  background: var(--surface-2);
}
.checks-grid label { font-size: 0.85rem; display: flex; align-items: center; gap: 0.4rem; }
.checks-grid label.disabled-option { color: var(--muted); text-decoration: line-through; }

/* ---------- Tabelas ---------- */

.data-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.data-table th, .data-table td {
  text-align: left;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  vertical-align: top;
}
.data-table th { color: var(--muted); font-weight: 500; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.02em; }
.data-table tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  margin: 0.1rem 0.2rem 0.1rem 0;
}
.badge-success { background: rgba(60, 184, 115, 0.15); border-color: var(--success); color: var(--success); }
.badge-muted { color: var(--muted); }
.badge-danger { background: rgba(239, 90, 90, 0.15); border-color: var(--danger); color: var(--danger); }

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.8rem;
}
.module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.module-card h3 { margin: 0 0 0.3rem; font-size: 1rem; }
.module-card p { margin: 0.3rem 0 0; font-size: 0.85rem; color: var(--muted); }

/* ---------- Modal (trocar senha) ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.modal-card h3 { margin: 0; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  z-index: 30;
}
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.success { border-color: var(--success); color: var(--success); }

/* Pisca de destaque no registro (Parceiro/Usuário/etc.) que acabou de ser criado/editado, pra
   ficar claro o que mudou sem precisar procurar na lista — mesmo padrão do painel operacional. */
@keyframes editFlash {
  0% { background: rgba(60, 184, 115, 0.28); }
  100% { background: transparent; }
}
.edit-flash { animation: editFlash 1.6s ease-out; }

@media (max-width: 720px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-footer { border-top: none; flex-direction: row; gap: 0.8rem; }
  .content { padding: 1rem; }
}
