@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #0A0A0C;
  --surface: #141417;
  --surface-2: #1B1B1F;
  --line: #2A2A30;
  --line-soft: #232327;
  --ink: #F3F1EA;
  --ink-soft: #A6A3AE;
  --ink-faint: #6E6C77;

  --gold: #D9B472;
  --gold-bright: #F0D9A8;
  --gold-dim: #8A733F;
  --gold-soft: rgba(217, 180, 114, 0.12);

  --money: #D9B472;
  --money-soft: rgba(217, 180, 114, 0.14);
  --amber: #E0A857;
  --amber-soft: rgba(224, 168, 87, 0.14);
  --red: #D9705C;
  --red-soft: rgba(217, 112, 92, 0.14);

  --radius: 4px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 0.4em 0;
  color: var(--ink);
}

a { color: inherit; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 900px 500px at 50% -10%, rgba(217, 180, 114, 0.10), transparent 60%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 44px 36px;
  box-shadow: 0 30px 60px -20px rgba(0,0,0,0.6);
}

.login-logo {
  display: block;
  height: 56px;
  margin: 0 auto 22px auto;
}

.login-card .brand {
  font-family: 'Fraunces', serif;
  font-size: 1.15rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-align: center;
  margin-bottom: 2px;
  color: var(--ink);
}

.login-card .sub {
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin-bottom: 30px;
  text-align: center;
}

.gold-rule {
  height: 1px;
  width: 64px;
  margin: 0 auto 28px auto;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

/* ---------- Layout general (dashboard / admin) ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: #08080A;
  color: var(--ink-soft);
  padding: 30px 22px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line-soft);
}

.sidebar .brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.sidebar .brand-row img {
  height: 26px;
  width: auto;
}

.sidebar .brand {
  font-family: 'Fraunces', serif;
  font-size: 1.02rem;
  letter-spacing: 0.14em;
  color: var(--ink);
  text-transform: uppercase;
}

.sidebar .who {
  font-size: 0.78rem;
  color: var(--ink-faint);
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line-soft);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: 3px;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.nav-item svg { flex-shrink: 0; opacity: 0.75; }
.nav-item.active svg { opacity: 1; }

.nav-item:hover { background: var(--surface); color: var(--ink); }
.nav-item.active {
  background: linear-gradient(90deg, var(--gold-soft), transparent);
  color: var(--gold-bright);
  border-left: 2px solid var(--gold);
  padding-left: 10px;
}

.logout-btn {
  margin-top: auto;
  color: var(--ink-faint);
  font-size: 0.82rem;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
  padding: 8px 10px;
  font-family: inherit;
}
.logout-btn:hover { color: var(--ink); }

/* ---------- Botón de cambio de rol (admin <-> comercial) ---------- */
.switch-role-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--gold-dim);
  background: var(--gold-soft);
  color: var(--gold-bright);
  font-size: 0.86rem;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
  text-align: left;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.switch-role-btn svg { flex-shrink: 0; }
.switch-role-btn:hover { background: rgba(217, 180, 114, 0.2); border-color: var(--gold); }

/* ---------- Banner de motivación ---------- */
.motivacion-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  background: linear-gradient(90deg, var(--gold-soft), var(--surface) 45%);
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 24px;
  font-family: 'Fraunces', Georgia, serif;
  font-style: italic;
  font-size: 0.98rem;
  color: var(--ink);
}
.motivacion-banner .icon { flex-shrink: 0; color: var(--gold); opacity: 0.9; }
.motivacion-banner .txt { flex: 1; }
.motivacion-banner .close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--ink-faint);
  cursor: pointer;
  font-size: 1rem;
  font-family: inherit;
  line-height: 1;
  padding: 4px;
}
.motivacion-banner .close:hover { color: var(--ink); }

.main {
  flex: 1;
  padding: 40px 48px;
  max-width: 1220px;
}

.main header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 30px;
}

.main header h1 { font-size: 1.6rem; }

.main header .fecha-hoy {
  color: var(--ink-faint);
  font-size: 0.85rem;
  text-transform: capitalize;
}

/* ---------- Tira de estadísticas ---------- */
.stat-strip {
  display: flex;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border-radius: 8px;
  margin-bottom: 34px;
  overflow: hidden;
}

.stat {
  flex: 1;
  padding: 20px 24px;
  border-right: 1px solid var(--line-soft);
  position: relative;
}
.stat:last-child { border-right: none; }

.stat .num {
  font-family: 'Fraunces', serif;
  font-size: 2.1rem;
  font-weight: 600;
  line-height: 1;
  display: block;
  color: var(--ink);
}
.stat .num.money {
  background: linear-gradient(120deg, var(--gold-bright), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.stat .label {
  color: var(--ink-faint);
  font-size: 0.76rem;
  margin-top: 8px;
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------- Secciones / tarjetas de contenido ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px 30px;
  margin-bottom: 24px;
}

.panel h2 {
  font-size: 1.08rem;
}

.panel-sub {
  color: var(--ink-soft);
  font-size: 0.85rem;
  margin-bottom: 22px;
}

.section-view { display: none; }
.section-view.active { display: block; }

/* ---------- Formularios ---------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}

.form-grid .full { grid-column: 1 / -1; }

label {
  display: block;
  font-size: 0.76rem;
  color: var(--ink-soft);
  margin-bottom: 7px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--ink);
}

input::placeholder, textarea::placeholder { color: var(--ink-faint); }

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

textarea { resize: vertical; min-height: 64px; }

button.primary {
  background: linear-gradient(120deg, var(--gold-bright), var(--gold-dim));
  color: #16130A;
  border: none;
  padding: 11px 20px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.02em;
}
button.primary:hover { filter: brightness(1.08); }
button.primary:disabled { opacity: 0.5; cursor: default; }

button.secondary {
  background: none;
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 10px 17px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  cursor: pointer;
  font-family: inherit;
}
button.secondary:hover { border-color: var(--gold); color: var(--gold-bright); }

button.money {
  background: linear-gradient(120deg, var(--gold-bright), var(--gold-dim));
  color: #16130A;
  border: none;
  padding: 11px 20px;
  border-radius: var(--radius);
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.88rem;
}
button.money:hover { filter: brightness(1.08); }

.form-msg { font-size: 0.85rem; margin-top: 12px; }
.form-msg.error { color: var(--red); }
.form-msg.ok { color: var(--gold-bright); }

/* ---------- Toast de confirmación ---------- */
.toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
  max-width: 360px;
  padding: 13px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--gold-dim);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  color: var(--ink);
  font-size: 0.88rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  border-left: 3px solid var(--gold);
  animation: toast-in 0.25s ease-out;
}
.toast.error { border-left-color: var(--red); }
.toast .toast-icon { flex-shrink: 0; color: var(--gold); }
.toast.error .toast-icon { color: var(--red); }
.toast.leaving { animation: toast-out 0.25s ease-in forwards; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(8px); }
}
@media (max-width: 640px) {
  .toast-stack { left: 16px; right: 16px; bottom: 16px; }
  .toast { max-width: none; }
}

/* ---------- Modales (ventana de detalle, cambio de contraseña) ---------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 12, 0.72);
  backdrop-filter: blur(2px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-box {
  position: relative;
  width: 100%;
  max-width: 460px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 26px 26px 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: modal-in 0.2s ease-out;
}
.modal-box.small { max-width: 360px; }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-box h2 { margin: 0 0 6px; font-size: 1.15rem; color: var(--gold-bright); }
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  color: var(--ink-faint);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px;
  font-family: inherit;
}
.modal-close:hover { color: var(--ink); }
.modal-detalle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 20px;
  margin: 18px 0;
}
.modal-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
  margin-bottom: 3px;
}
.modal-detalle-grid a { color: var(--gold-bright); text-decoration: none; }
.modal-detalle-grid a:hover { text-decoration: underline; }
.modal-notas p {
  margin: 4px 0 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
  white-space: pre-wrap;
}

/* ---------- Alerta de comerciales sin actividad reciente ---------- */
.alerta-banner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  border: 1px solid #6b3a3a;
  border-left: 3px solid var(--red);
  background: rgba(217, 112, 92, 0.08);
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 24px;
  font-size: 0.88rem;
  color: var(--ink);
}
.alerta-banner .icon { flex-shrink: 0; color: var(--red); margin-top: 1px; }

/* ---------- Historial rápido (aviso bajo el campo empresa) ---------- */
.historial-hint {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--gold-dim);
  background: var(--gold-soft);
  color: var(--ink-soft);
  font-size: 0.8rem;
  line-height: 1.55;
}

/* ---------- Tablas ---------- */
table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }

thead th {
  text-align: left;
  color: var(--ink-faint);
  font-weight: 500;
  font-size: 0.72rem;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge.cerrado { background: var(--money-soft); color: var(--gold-bright); }
.badge.reunion { background: var(--amber-soft); color: var(--amber); }
.badge.negativo { background: var(--red-soft); color: var(--red); }
.badge.neutro { background: var(--surface-2); color: var(--ink-soft); border: 1px solid var(--line-soft); }

.pct-input {
  width: 64px;
  padding: 6px 8px;
  display: inline-block;
}

.filters-row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.filters-row .field { min-width: 160px; }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.empty-state {
  color: var(--ink-faint);
  font-size: 0.87rem;
  padding: 26px 0;
  text-align: center;
}

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: auto; flex-direction: row; overflow-x: auto; align-items: center; padding: 14px 16px; border-right: none; border-bottom: 1px solid var(--line-soft); }
  .sidebar .who, .sidebar .brand-row { display: none; }
  .nav-item { white-space: nowrap; }
  .nav-item.active { border-left: none; border-bottom: 2px solid var(--gold); }
  .logout-btn { margin-top: 0; }
  .main { padding: 26px 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .stat-strip { flex-wrap: wrap; }
  .stat { flex: 1 1 50%; border-bottom: 1px solid var(--line-soft); }
}
