/* ============================================================
   ASTRALIS CRM · Identidad corporativa
   Blanco + azul · cantidades en amarillo · menú en blanco · rojo = eliminar
   ============================================================ */
:root {
  --azul-950: #071A33;
  --azul-900: #0B2545;   /* menú / cielo */
  --azul-700: #13315C;
  --azul-500: #1D5FBF;   /* acción principal */
  --azul-100: #E3ECF9;
  --fondo:    #F4F7FB;
  --blanco:   #FFFFFF;
  --amarillo: #F5B301;   /* cantidades */
  --rojo:     #D64545;   /* eliminación */
  --verde:    #2E9E6B;   /* en línea */
  --tinta:    #1C2733;
  --tinta-2:  #5A6B7E;
  --borde:    #DCE4EE;
  --radio: 10px;
  --sombra: 0 6px 24px rgba(11,37,69,.08);
  --f-display: "Sora", system-ui, sans-serif;
  --f-body: "Manrope", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--f-body); color: var(--tinta); background: var(--fondo); font-size: 15px; }
.hidden { display: none !important; }
h1,h2,h3 { font-family: var(--f-display); }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- Botones ---------- */
.btn { border: none; border-radius: var(--radio); padding: 10px 18px; font-weight: 600; transition: filter .15s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--azul-500); color: var(--blanco); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--azul-100); color: var(--azul-700); }
.btn-danger { background: var(--rojo); color: var(--blanco); }   /* solo eliminación */
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn-ghost { background: transparent; border: 1px solid rgba(255,255,255,.35); color: var(--blanco); border-radius: 8px; padding: 8px 12px; width: 100%; }
.btn-ghost:hover { background: rgba(255,255,255,.08); }

/* ---------- Login ---------- */
.login-screen { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-sky {
  position: relative; overflow: hidden; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
  background: radial-gradient(1200px 700px at 30% 20%, #123563 0%, var(--azul-900) 55%, var(--azul-950) 100%);
}
.constellation { width: min(60%, 460px); }
.star { animation: twinkle 3.2s ease-in-out infinite; transform-origin: center; }
.star.s2 { animation-delay: .6s; } .star.s3 { animation-delay: 1.2s; }
.star.s4 { animation-delay: 1.8s; } .star.s5 { animation-delay: 2.4s; }
@keyframes twinkle { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .star { animation: none; } }
.login-brand { text-align: center; color: var(--blanco); }
.login-brand h1 { margin: 0; font-size: 44px; letter-spacing: .35em; padding-left: .35em; font-weight: 700; }
.login-brand p { margin: 6px 0 0; color: #AFC3DF; letter-spacing: .08em; text-transform: uppercase; font-size: 12px; }

.login-panel { display: flex; align-items: center; justify-content: center; background: var(--blanco); padding: 24px; }
.login-form { width: min(360px, 100%); display: flex; flex-direction: column; gap: 14px; }
.login-form h2 { margin: 0; font-size: 24px; color: var(--azul-900); }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; color: var(--tinta-2); }
.login-form input { border: 1px solid var(--borde); border-radius: var(--radio); padding: 11px 12px; }
.login-form input:focus { outline: 2px solid var(--azul-500); border-color: transparent; }
.muted { color: var(--tinta-2); font-size: 13px; margin: 0; }
.error { color: var(--rojo); font-size: 13px; min-height: 18px; margin: 0; }

/* ---------- Estructura ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--azul-900), var(--azul-950));
  color: var(--blanco); display: flex; flex-direction: column; padding: 18px 14px; gap: 18px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--f-display); font-weight: 700; letter-spacing: .18em; }
.brand-mark { width: 30px; height: 30px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav a {
  color: var(--blanco); text-decoration: none; padding: 10px 12px; border-radius: 8px;
  font-weight: 500; font-size: 14px; display: flex; justify-content: space-between; align-items: center;
}
.nav a:hover { background: rgba(255,255,255,.08); }
.nav a.active { background: var(--azul-500); }
.nav .nav-group { margin-top: 10px; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: #8FA6C6; padding: 6px 12px 2px; }
.nav .sub { padding-left: 24px; font-size: 13.5px; }
.nav .count { background: rgba(255,255,255,.12); color: var(--amarillo); font-weight: 700; border-radius: 20px; padding: 1px 8px; font-size: 12px; }
.sidebar-footer { display: flex; flex-direction: column; gap: 10px; }
.user-chip { font-size: 13px; line-height: 1.35; color: #C9D8EE; }
.user-chip strong { color: var(--blanco); display: block; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: var(--blanco); border-bottom: 1px solid var(--borde);
  padding: 14px 26px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 5;
}
.topbar h2 { margin: 0; font-size: 19px; color: var(--azul-900); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.entity-filter { border: 1px solid var(--borde); border-radius: 8px; padding: 8px 10px; background: var(--blanco); }
.alert-badge { background: var(--amarillo); color: var(--azul-950); font-weight: 700; border-radius: 20px; padding: 4px 11px; font-size: 13px; }

.view { padding: 24px 26px; display: flex; flex-direction: column; gap: 18px; }

/* ---------- Tarjetas y tablas ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.card { background: var(--blanco); border: 1px solid var(--borde); border-radius: var(--radio); padding: 16px 18px; box-shadow: var(--sombra); }
.card .qty { font-family: var(--f-display); font-size: 32px; font-weight: 700; color: var(--amarillo); text-shadow: 0 1px 0 rgba(11,37,69,.12); }
.card .lbl { color: var(--tinta-2); font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; margin-top: 2px; }

.panel { background: var(--blanco); border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: var(--sombra); }
.panel-head { padding: 14px 18px; border-bottom: 1px solid var(--borde); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.panel-head h3 { margin: 0; font-size: 16px; color: var(--azul-900); flex: 1; }
.panel-body { padding: 8px 0; overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--tinta-2); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; padding: 10px 16px; border-bottom: 1px solid var(--borde); }
td { padding: 11px 16px; border-bottom: 1px solid #EDF2F8; vertical-align: middle; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #F6F9FD; }
tr.clickable { cursor: pointer; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters input, .filters select { border: 1px solid var(--borde); border-radius: 8px; padding: 9px 11px; background: var(--blanco); min-width: 160px; }
.filters input:focus, .filters select:focus { outline: 2px solid var(--azul-500); }

/* ---------- Etiquetas de estado ---------- */
.tag { display: inline-block; border-radius: 20px; padding: 3px 10px; font-size: 12px; font-weight: 600; }
.tag-nuevo { background: var(--azul-100); color: var(--azul-700); }
.tag-mio { background: #FFF4D6; color: #8A6400; }
.tag-gestion_inicial { background: #E2F3EA; color: #1E6E48; }
.tag-gestion_progresiva { background: #E8E4F9; color: #4A3AA3; }
.tag-asesorias { background: #DDF0F7; color: #0E6784; }
.tag-no_interesado { background: #F1F3F6; color: #66727F; }
.tag-dup { background: #FCE4E4; color: var(--rojo); }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.dot.on { background: var(--verde); } .dot.off { background: #C3CDD9; }

.subtabs { display: flex; gap: 8px; flex-wrap: wrap; }
.subtabs button { border: 1px solid var(--borde); background: var(--blanco); border-radius: 20px; padding: 8px 15px; font-weight: 600; color: var(--tinta-2); }
.subtabs button.active { background: var(--azul-500); border-color: var(--azul-500); color: var(--blanco); }
.subtabs .count { color: var(--amarillo); font-weight: 700; margin-left: 6px; }
.subtabs button.active .count { color: var(--amarillo); }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(7,26,51,.55); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px; }
.modal { background: var(--blanco); border-radius: 14px; width: min(680px, 100%); max-height: 90vh; overflow-y: auto; box-shadow: 0 24px 64px rgba(0,0,0,.28); }
.modal-head { padding: 16px 22px; border-bottom: 1px solid var(--borde); display: flex; align-items: center; }
.modal-head h3 { margin: 0; flex: 1; color: var(--azul-900); font-size: 17px; }
.modal-close { background: none; border: none; font-size: 22px; color: var(--tinta-2); line-height: 1; }
.modal-body { padding: 18px 22px; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--borde); display: flex; gap: 10px; justify-content: flex-end; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--tinta-2); }
.field input, .field select, .field textarea { border: 1px solid var(--borde); border-radius: 8px; padding: 10px 11px; font-weight: 400; color: var(--tinta); }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--azul-500); }
.field .locked { background: #F1F4F9; color: var(--tinta-2); font-style: italic; }

.history { border-top: 1px dashed var(--borde); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.history-item { font-size: 13px; color: var(--tinta-2); }
.history-item b { color: var(--tinta); }

/* ---------- Chat ---------- */
.chat-layout { display: grid; grid-template-columns: 240px 1fr; gap: 0; min-height: 520px; }
.chat-threads { border-right: 1px solid var(--borde); overflow-y: auto; }
.chat-thread { padding: 12px 14px; border-bottom: 1px solid #EDF2F8; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.chat-thread:hover, .chat-thread.active { background: var(--azul-100); }
.chat-thread .unread { margin-left: auto; background: var(--amarillo); color: var(--azul-950); border-radius: 20px; font-size: 11px; font-weight: 700; padding: 1px 7px; }
.chat-box { display: flex; flex-direction: column; height: 560px; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: #F8FAFD; }
.msg { max-width: 70%; border-radius: 12px; padding: 9px 13px; font-size: 14px; background: var(--blanco); border: 1px solid var(--borde); }
.msg.mine { align-self: flex-end; background: var(--azul-500); color: var(--blanco); border-color: var(--azul-500); }
.msg .meta { font-size: 11px; opacity: .7; margin-top: 4px; }
.msg img { max-width: 240px; border-radius: 8px; display: block; margin-top: 6px; }
.msg audio { margin-top: 6px; width: 230px; }
.msg a.file { color: inherit; font-weight: 600; }
.chat-input { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--borde); align-items: center; }
.chat-input input[type="text"] { flex: 1; border: 1px solid var(--borde); border-radius: 20px; padding: 11px 15px; }
.icon-btn { background: var(--azul-100); border: none; border-radius: 50%; width: 40px; height: 40px; font-size: 17px; }
.icon-btn.rec { background: var(--rojo); color: var(--blanco); }

/* ---------- Toasts ---------- */
.toast-root { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 90; }
.toast { background: var(--azul-900); color: var(--blanco); padding: 12px 16px; border-radius: 10px; box-shadow: var(--sombra); font-size: 14px; max-width: 340px; border-left: 4px solid var(--azul-500); }
.toast.warn { border-left-color: var(--amarillo); }
.toast.err { border-left-color: var(--rojo); }

.empty { padding: 34px; text-align: center; color: var(--tinta-2); }
.qty-inline { color: var(--amarillo); font-weight: 700; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .login-screen { grid-template-columns: 1fr; }
  .login-sky { min-height: 34vh; }
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .chat-layout { grid-template-columns: 1fr; }
  .chat-threads { max-height: 180px; }
  .form-grid { grid-template-columns: 1fr; }
}

/* ===== Frase motivacional del día ===== */
.motivacion {
  font-family: 'Sora', sans-serif;
  font-size: 20px;
  line-height: 1.5;
  color: var(--azul-900);
  text-align: center;
  padding: 24px 12px;
  font-style: italic;
}

/* ===== Indicadores de cumplimiento ===== */
.progress {
  height: 10px; background: #E5EDF8; border-radius: 6px;
  overflow: hidden; margin: 10px 0 6px;
}
.progress span {
  display: block; height: 100%;
  background: var(--azul-500); border-radius: 6px;
  transition: width .4s ease;
}
.progress span.done { background: var(--amarillo); }

.podium {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px; margin-bottom: 14px;
}
.podium-card {
  border: 1px solid #E1E8F2; border-radius: 12px;
  padding: 16px; text-align: center; background: #fff;
}
.podium-card .medal { font-size: 30px; margin-bottom: 6px; }
.podium-card .qty { font-size: 22px; margin: 4px 0; }
.podium-card.p1 { border-color: var(--amarillo); box-shadow: 0 4px 14px rgba(245,179,1,.18); }
.podium-card.me { outline: 2px solid var(--azul-500); }
.row-me td { background: #F0F6FF; }

/* ===== Zona crítica (autodestrucción) ===== */
.danger-zone { border: 1px solid var(--rojo); }
.danger-zone .panel-head h3 { color: var(--rojo); }
