:root {
  --navy: #0f2a4a;
  --navy-dark: #0a1c33;
  --gold: #c8a24a;
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1c2733;
  --muted: #6b7785;
  --border: #e2e6ec;
  --green: #2e8b57;
  --red: #c0392b;
  --blue: #2563eb;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.hidden { display: none !important; }

/* --- Login --- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy-dark), var(--navy));
}
.login-card {
  background: var(--card);
  border-radius: 14px;
  padding: 36px 32px;
  width: 360px;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
}
.brand { text-align: center; margin-bottom: 20px; }
.brand-icon { font-size: 34px; }
.brand h1 { margin: 6px 0 0; font-size: 22px; color: var(--navy); }
.brand-sub { color: var(--muted); margin: 2px 0 0; font-size: 13px; }
#login-form label { display: block; margin: 12px 0 4px; font-size: 13px; color: var(--muted); }
#login-form input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
}
.btn { border: none; border-radius: 8px; padding: 10px 16px; font-size: 14px; cursor: pointer; font-weight: 600; }
.btn-primary { background: var(--navy); color: white; }
.btn-primary:hover { background: var(--navy-dark); }
.btn-ghost { background: transparent; color: var(--navy); border: 1px solid var(--border); }
.btn-block { width: 100%; margin-top: 18px; }
.error-text { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 16px; }
.login-hint { text-align: center; color: var(--muted); font-size: 12px; margin-top: 18px; line-height: 1.5; }

/* --- App layout --- */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  background: var(--navy);
  color: white;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.topbar-right { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.topbar-right .btn-ghost { color: white; border-color: rgba(255,255,255,.35); }

.layout { display: flex; flex: 1; min-height: 0; }
.sidebar {
  width: 220px;
  background: white;
  border-right: 1px solid var(--border);
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav-item {
  text-align: left;
  background: transparent;
  border: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
}
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--navy); color: white; }

.content { flex: 1; padding: 24px 28px; overflow-y: auto; }
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.panel-header h2 { margin: 0; font-size: 20px; }
.hint { color: var(--muted); font-weight: 400; font-size: 13px; }

/* --- Client cards --- */
.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.client-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: box-shadow .15s;
}
.client-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.client-card h4 { margin: 0 0 4px; font-size: 15px; }
.client-card .meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.badge { display: inline-block; padding: 3px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.badge-primer_contacto { background: #e0ecff; color: var(--blue); }
.badge-intento_contacto { background: #fff2d6; color: #a3700a; }
.badge-seguimiento { background: #e8dcff; color: #6d28d9; }
.badge-cita_agendada { background: #d6f5e3; color: var(--green); }
.badge-cerrado { background: #ffe0dd; color: var(--red); }
.source-tag { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: var(--bg); color: var(--muted); margin-left: 6px; }

/* --- Tables --- */
.data-table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.data-table th, .data-table td { padding: 10px 12px; text-align: left; font-size: 13px; border-bottom: 1px solid var(--border); }
.data-table th { background: var(--bg); color: var(--muted); font-weight: 600; }

/* --- Stats --- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; text-align: center; }
.stat-card .num { font-size: 26px; font-weight: 800; color: var(--navy); }
.stat-card .label { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* --- Forms / modal --- */
.form-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 20px; max-width: 380px; }
.form-card label, #new-client-form label, #new-user-form label { display: block; margin: 10px 0 4px; font-size: 13px; color: var(--muted); }
.form-card input, #new-client-form input, #new-client-form select, #new-client-form textarea,
#new-user-form input, #new-user-form select {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
}
.modal { position: fixed; inset: 0; background: rgba(15,42,74,.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-card { background: white; border-radius: 12px; padding: 24px; width: 380px; max-height: 88vh; overflow-y: auto; }
.modal-wide { width: 520px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.checkbox-label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filters select { padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border); }

/* Client detail modal content */
.cd-row { display: flex; justify-content: space-between; margin: 6px 0; font-size: 14px; }
.cd-section { margin-top: 16px; }
.cd-section h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; }
.stage-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.stage-buttons button { padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border); background: white; cursor: pointer; font-size: 12px; }
.stage-buttons button.active { background: var(--navy); color: white; border-color: var(--navy); }
.log-item { font-size: 12px; color: var(--muted); padding: 4px 0; border-bottom: 1px dashed var(--border); }
