:root {
  /* Mesma paleta de api/static/chat/app.css (DESIGN_SYSTEM.md) */
  --primary: #F71E3D;
  --primary-dark: #c4172f;
  --secondary: #25373B;
  --secondary-dark: #1B292C;
  --bg-base: #F5F5F5;
  --bg-white: #FFFFFF;
  --border-subtle: #E0E0E0;
  --border-light: #EEEEEE;
  --text-primary: #212121;
  --text-secondary: #757575;
  --text-muted: #9E9E9E;
  --grad-primary: linear-gradient(135deg, #c4172f, #F71E3D, #f94d67);
  --radius: 10px;
  --shadow-sm: 0 1px 3px rgba(37, 55, 59, 0.08);
  --shadow-md: 0 4px 16px rgba(37, 55, 59, 0.1);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
}

button { font-family: inherit; }

/* --- Botões --- */
.btn-primary {
  background: var(--grad-primary);
  border: none;
  color: #fff;
  padding: 10px 18px;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  transition: filter 0.15s;
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 9px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-outline:hover { background: var(--border-light); border-color: var(--text-muted); }

.btn-small { padding: 6px 10px; font-size: 0.85rem; }

.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 0.85rem;
  text-decoration: underline;
}

/* --- Login --- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--secondary-dark), var(--secondary));
  padding: 24px;
}

/* Uma classe com `display` sempre vence a regra nativa do atributo hidden
   (author beats user-agent, mesma especificidade) — sem isso, JS setando
   .hidden=true não esconde nada. */
.login-screen[hidden] { display: none; }

.form-card {
  background: var(--bg-white);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
}

.form-card-header {
  padding: 28px 28px 12px;
  text-align: center;
  position: relative;
}

.form-card-mark {
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  border-radius: 12px;
  background: var(--grad-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.2rem;
}

.form-card-header h2 { font-size: 1.3rem; margin-bottom: 4px; }
.form-card-sub { color: var(--text-secondary); font-size: 0.88rem; }

.form-card-body { padding: 8px 28px 28px; }

.login-form, #client-form { display: flex; flex-direction: column; gap: 14px; }

.login-form label, #client-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Mesma pegadinha do hidden — client-password-label é escondido via JS
   (edição não pede senha nesta tela). */
#client-form label[hidden] { display: none; }

.login-form input, #client-form input, #client-form select {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  background: var(--bg-white);
}

.login-form input:focus, #client-form input:focus, #client-form select:focus {
  outline: none;
  border-color: var(--primary);
}

.login-error {
  color: var(--primary-dark);
  font-size: 0.85rem;
  background: color-mix(in srgb, var(--primary) 8%, transparent);
  padding: 8px 10px;
  border-radius: 8px;
}

.checkbox-row { flex-direction: row !important; align-items: center; gap: 8px !important; }
.checkbox-row input { width: auto; }

.field-row { display: flex; align-items: flex-end; gap: 8px; }
.field-row .grow { flex: 1; }

/* --- Shell do app --- */
.app-screen { min-height: 100vh; display: flex; flex-direction: column; }
.app-screen[hidden] { display: none; }

.topbar {
  background: var(--secondary-dark);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar-brand { font-weight: 700; font-size: 1.05rem; }
.topbar-sub { font-weight: 400; color: color-mix(in srgb, #fff 55%, transparent); margin-left: 6px; font-size: 0.85rem; }

.topbar-user { display: flex; align-items: center; gap: 14px; font-size: 0.88rem; }
.topbar-user .btn-outline { color: #fff; border-color: color-mix(in srgb, #fff 30%, transparent); }
.topbar-user .btn-outline:hover { background: color-mix(in srgb, #fff 12%, transparent); }

.tabs {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 24px;
  display: flex;
  gap: 4px;
}

.tab-btn {
  background: none;
  border: none;
  padding: 14px 18px;
  cursor: pointer;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.9rem;
  border-bottom: 3px solid transparent;
}

.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.content { flex: 1; padding: 24px; max-width: 1100px; width: 100%; margin: 0 auto; }

.tab-panel[hidden] { display: none; }

.panel-toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  align-items: center;
}

.panel-toolbar select {
  padding: 9px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
  font-family: inherit;
}

/* --- Tabela --- */
.table-wrap {
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }

th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

th { color: var(--text-secondary); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.02em; }

tbody tr:hover { background: var(--bg-base); }

.empty-state { padding: 32px; text-align: center; color: var(--text-muted); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
}
.badge-new { background: #e0edff; color: #1d4ed8; }
.badge-contacted { background: #fef3c7; color: #92400e; }
.badge-converted { background: #dcfce7; color: #166534; }
.badge-discarded { background: var(--border-light); color: var(--text-muted); }
.badge-demo { background: #fef3c7; color: #92400e; }
.badge-paid { background: #dcfce7; color: #166534; }
.badge-inactive { background: var(--border-light); color: var(--text-muted); }
.text-expired { color: var(--primary-dark); font-weight: 600; }

/* --- Modal --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(27, 41, 44, 0.5);
  z-index: 90;
}
.modal-backdrop[hidden] { display: none; }

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-white);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  z-index: 91;
}
.modal[hidden] { display: none; }

.modal .form-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-align: left;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* --- Toast --- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-white);
  box-shadow: var(--shadow-md);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  min-width: 260px;
  border-left: 4px solid var(--primary);
}
.toast.success { border-left-color: #16a34a; }

.toast-close { background: none; border: none; cursor: pointer; margin-left: auto; font-size: 1.1rem; color: var(--text-muted); }

@media (max-width: 640px) {
  .content { padding: 14px; }
  th, td { padding: 10px 8px; }
}
