/* Asistencia de Visas HN — Panel de administración (CRM) */
:root {
  --navy-900: #0b1628; --navy-800: #0f1f38; --navy-700: #16294a; --navy-600: #1f3761;
  --gold-500: #c29a4b; --gold-400: #d4b06a; --gold-600: #a57b2e; --gold-700: #8a6420; --gold-50: #faf5ea;
  --bg: #f5f3ee; --paper: #fff; --ink: #16213a; --muted: #5f687a; --line: #e7e2d8;
  --ok: #1f7a4d; --ok-bg: #e9f6ef; --warn: #9a6400; --warn-bg: #fff5e0; --err: #b42318; --err-bg: #fdeceb;
  --info: #1f4f99; --info-bg: #eaf1fc;
  --radius: 14px; --shadow: 0 1px 2px rgba(11,22,40,.06), 0 8px 24px -14px rgba(11,22,40,.18);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; --display: "Cinzel", Georgia, serif;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.5; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--gold-700); }
h1, h2, h3 { margin: 0; color: var(--navy-800); line-height: 1.25; }
:focus-visible { outline: 3px solid var(--gold-500); outline-offset: 2px; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-fill { fill: currentColor; stroke: none; }

/* ---------- Estructura ---------- */
.shell { display: grid; min-height: 100vh; }
@media (min-width: 1000px) { .shell { grid-template-columns: 250px 1fr; } }
.sidebar { background: var(--navy-900); color: rgba(255,255,255,.75); display: flex; flex-direction: column; }
@media (min-width: 1000px) { .sidebar { position: sticky; top: 0; height: 100vh; } }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,.08); text-decoration: none; }
.side-brand img { width: 42px; height: 42px; }
.side-brand span { font-family: var(--display); color: var(--gold-400); font-weight: 700; font-size: .95rem; line-height: 1.15; }
.side-brand small { display: block; font-family: var(--font); color: rgba(255,255,255,.5); font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; font-weight: 500; }
.side-nav { padding: 14px 10px; display: grid; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; color: rgba(255,255,255,.72); text-decoration: none; font-weight: 500; transition: background .15s, color .15s; }
.side-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-nav a.active { background: linear-gradient(90deg, rgba(194,154,75,.22), rgba(194,154,75,.05)); color: #fff; box-shadow: inset 3px 0 0 var(--gold-500); }
.side-nav a.active .icon { color: var(--gold-400); }
.side-nav .count { margin-left: auto; background: var(--gold-500); color: var(--navy-900); font-size: .72rem; font-weight: 700; padding: 1px 8px; border-radius: 99px; }
.side-foot { margin-top: auto; padding: 16px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: .85rem; }
.side-foot b { color: #fff; display: block; }
.side-foot button { background: none; border: 0; color: var(--gold-400); cursor: pointer; padding: 0; font: inherit; margin-top: 4px; }
@media (max-width: 999px) {
  .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side-brand { border: 0; padding: 12px 16px; }
  .side-nav { display: flex; overflow-x: auto; width: 100%; padding: 0 10px 10px; order: 3; }
  .side-nav a { white-space: nowrap; }
  .side-foot { margin: 0 0 0 auto; border: 0; padding: 12px 16px; }
  .side-foot b { display: none; }
}
.main { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 22px 28px 0; }
.topbar h1 { font-size: 1.5rem; font-weight: 700; }
.topbar p { margin: 2px 0 0; color: var(--muted); }
.content { padding: 22px 28px 48px; }
@media (max-width: 640px) { .topbar, .content { padding-left: 16px; padding-right: 16px; } }

/* ---------- Componentes ---------- */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: 1rem; }
.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-2 { grid-template-columns: 1fr; }
@media (min-width: 1100px) { .grid-2 { grid-template-columns: 1.4fr 1fr; } .grid-2.even { grid-template-columns: 1fr 1fr; } }

.kpi { padding: 18px 20px; position: relative; overflow: hidden; animation: up .5s cubic-bezier(.2,.7,.2,1) both; }
.kpi:nth-child(2) { animation-delay: .05s; } .kpi:nth-child(3) { animation-delay: .1s; } .kpi:nth-child(4) { animation-delay: .15s; } .kpi:nth-child(5) { animation-delay: .2s; }
.kpi::after { content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: radial-gradient(circle, rgba(194,154,75,.16), transparent 70%); }
.kpi small { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
.kpi b { display: block; white-space: nowrap; font-size: clamp(1.35rem, 1.9vw, 1.9rem); font-weight: 700; color: var(--navy-800); margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi span { font-size: .82rem; color: var(--muted); }
@keyframes up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px; border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, color .15s; }
.btn-primary { background: var(--navy-800); color: #fff; }
.btn-primary:hover { background: var(--navy-600); }
.btn-gold { background: var(--gold-500); color: var(--navy-900); }
.btn-gold:hover { background: var(--gold-400); }
.btn-light { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-light:hover { border-color: var(--gold-500); }
.btn-wa { background: #0e7a3f; color: #fff; }
.btn-sm { padding: 6px 11px; font-size: .82rem; border-radius: 8px; }
.btn-danger { background: #fff; border-color: #f0c7c2; color: var(--err); }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fbfaf7; white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #fcfaf5; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .name { font-weight: 600; color: var(--navy-800); text-decoration: none; }
.table .name:hover { color: var(--gold-700); }
.table small { color: var(--muted); display: block; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 99px; font-size: .76rem; font-weight: 600; white-space: nowrap; background: #eef0f4; color: #475069; }
.pill-alto, .pill-aprobado, .pill-confirmada, .pill-atendida, .pill-visa_aprobada, .pill-cita_confirmada, .pill-atendido { background: var(--ok-bg); color: var(--ok); }
.pill-medio, .pill-pendiente, .pill-pendiente_pago, .pill-cita_pendiente { background: var(--warn-bg); color: var(--warn); }
.pill-bajo, .pill-rechazado, .pill-no_asistio, .pill-cancelada, .pill-visa_negada, .pill-no_califica, .pill-descartado { background: var(--err-bg); color: var(--err); }
.pill-precalificado, .pill-en_tramite, .pill-nuevo { background: var(--info-bg); color: var(--info); }
.pill-expirada { background: #f1f1f1; color: #777; }
.pill-US, .pill-CA { background: var(--gold-50); color: var(--gold-700); border: 1px solid #eddcb6; }

.score { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-variant-numeric: tabular-nums; }
.score i { display: block; width: 54px; height: 6px; border-radius: 99px; background: #eee9dd; overflow: hidden; position: relative; }
.score i::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--w); border-radius: 99px; background: var(--c, var(--gold-500)); }

.filters { display: flex; gap: 10px; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--line); align-items: center; }
.input, select.input, textarea.input { padding: 9px 12px; border: 1px solid #d9d3c6; border-radius: 9px; font: inherit; background: #fff; color: var(--ink); min-width: 0; }
.input:focus { outline: none; border-color: var(--gold-600); box-shadow: 0 0 0 3px rgba(194,154,75,.2); }
.filters .input[type=search] { flex: 1 1 220px; }

.field { display: grid; gap: 5px; }
.field label { font-weight: 600; font-size: .85rem; color: var(--navy-800); }
.field small { color: var(--muted); font-size: .8rem; }
.field-error { color: var(--err); font-size: .82rem; }
.form-grid { display: grid; gap: 14px; }
@media (min-width: 700px) { .form-grid.cols-2 { grid-template-columns: 1fr 1fr; } .form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); } }
.form-section { padding: 20px; border-bottom: 1px solid var(--line); }
.form-section h3 { font-size: .95rem; margin-bottom: 4px; }
.form-section > p { color: var(--muted); margin: 0 0 14px; font-size: .88rem; }

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; animation: up .35s ease both; }
.alert-ok { background: var(--ok-bg); color: var(--ok); }
.alert-error { background: var(--err-bg); color: var(--err); }
.alert-warn { background: var(--warn-bg); color: var(--warn); }

/* Embudo y barras */
.funnel { display: grid; gap: 12px; }
.funnel-row { display: grid; grid-template-columns: 170px 1fr 48px; gap: 12px; align-items: center; font-size: .88rem; }
.funnel-bar { height: 28px; background: #f1ede4; border-radius: 8px; overflow: hidden; }
.funnel-bar i { display: block; height: 100%; border-radius: 8px; background: linear-gradient(90deg, var(--navy-700), var(--navy-600)); width: 0; transition: width 1s cubic-bezier(.2,.7,.2,1); }
.funnel-row:nth-child(2) .funnel-bar i { background: linear-gradient(90deg, var(--navy-600), #2f5189); }
.funnel-row:nth-child(3) .funnel-bar i { background: linear-gradient(90deg, var(--gold-600), var(--gold-500)); }
.funnel-row:nth-child(4) .funnel-bar i { background: linear-gradient(90deg, #17643f, var(--ok)); }
.funnel-row b { text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .funnel-row { grid-template-columns: 1fr 44px; } .funnel-row span { grid-column: 1 / -1; } }

.stack { display: grid; gap: 0; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; transition: background .12s; }
.list-item:hover { background: #fcfaf5; }
.list-item:last-child { border-bottom: 0; }
.date-chip { width: 48px; flex: none; text-align: center; background: var(--navy-800); color: #fff; border-radius: 10px; padding: 5px 0; line-height: 1.1; }
.date-chip small { display: block; font-size: .66rem; text-transform: uppercase; color: var(--gold-400); letter-spacing: .06em; }
.date-chip b { font-size: 1.15rem; }
.avatar { width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; font-size: .82rem; color: var(--navy-800); background: var(--gold-50); border: 1px solid #eddcb6; }

/* Tablero kanban */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.column { background: #ece8df; border-radius: 14px; padding: 10px; min-height: 200px; transition: background .15s, box-shadow .15s; }
.column.drag-over { background: #e4dac4; box-shadow: inset 0 0 0 2px var(--gold-500); }
.column-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 10px; font-weight: 700; font-size: .85rem; color: var(--navy-800); }
.column-head span { background: #fff; border-radius: 99px; padding: 1px 9px; font-size: .75rem; }
.column-body { display: grid; gap: 8px; min-height: 60px; }
.lead-card { background: #fff; border-radius: 10px; padding: 11px 12px; box-shadow: 0 1px 2px rgba(11,22,40,.08); cursor: grab; border: 1px solid transparent; text-decoration: none; color: inherit; display: block; transition: transform .15s, box-shadow .15s, border-color .15s; }
.lead-card:hover { border-color: var(--gold-400); transform: translateY(-1px); box-shadow: 0 6px 14px -8px rgba(11,22,40,.3); }
.lead-card.dragging { opacity: .45; }
.lead-card b { display: block; color: var(--navy-800); font-size: .9rem; }
.lead-card .meta { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; gap: 6px; font-size: .78rem; color: var(--muted); }

/* Ficha del lead */
.lead-header { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.lead-header .avatar { width: 56px; height: 56px; font-size: 1.1rem; }
.lead-header h1 { font-size: 1.45rem; }
.def { display: grid; grid-template-columns: 120px 1fr; gap: 10px 14px; margin: 0; font-size: .9rem; }
.def dt { color: var(--muted); }
.def dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.breakdown td:last-child { text-align: right; white-space: nowrap; }
.timeline { list-style: none; margin: 0; padding: 6px 20px 20px; }
.timeline li { position: relative; padding: 12px 0 12px 26px; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 16px; width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 2px solid var(--gold-500); }
.timeline li.nota::before { background: var(--gold-500); }
.timeline li.etapa::before { border-color: var(--navy-600); background: var(--navy-600); }
.timeline time { display: block; font-size: .76rem; color: var(--muted); }
.timeline p { margin: 2px 0 0; white-space: pre-line; }

/* Calendario semanal */
.week { display: grid; grid-template-columns: repeat(7, minmax(130px, 1fr)); gap: 10px; overflow-x: auto; }
.week-day { background: #fff; border: 1px solid var(--line); border-radius: 12px; min-height: 160px; padding: 10px; }
.week-day.today { border-color: var(--gold-500); box-shadow: inset 0 3px 0 var(--gold-500); }
.week-day h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 8px; }
.week-day h3 b { color: var(--navy-800); font-size: 1rem; }
.appt { display: block; padding: 7px 9px; border-radius: 8px; margin-bottom: 6px; font-size: .8rem; text-decoration: none; background: var(--info-bg); color: var(--info); border-left: 3px solid var(--info); }
.appt b { display: block; color: inherit; }
.appt.confirmada { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.appt.pendiente_pago { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.appt.no_asistio { background: var(--err-bg); color: var(--err); border-color: var(--err); }

/* Paginación */
.pagination { display: flex; gap: 6px; justify-content: flex-end; padding: 14px 16px; flex-wrap: wrap; }
.pagination a, .pagination span { padding: 6px 11px; border-radius: 8px; border: 1px solid var(--line); text-decoration: none; color: var(--ink); background: #fff; font-size: .85rem; }
.pagination .current { background: var(--navy-800); color: #fff; border-color: var(--navy-800); }
.pagination .disabled { color: #aaa; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 20% -10%, rgba(194,154,75,.25), transparent 60%), var(--navy-900); }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 20px; padding: 34px 30px; box-shadow: 0 30px 60px -20px rgba(0,0,0,.5); animation: up .6s cubic-bezier(.2,.7,.2,1) both; }
.login-card img { width: 120px; margin: 0 auto 10px; display: block; }
.login-card h1 { text-align: center; font-size: 1.2rem; margin-bottom: 4px; }
.login-card p { text-align: center; color: var(--muted); margin: 0 0 22px; }

.muted { color: var(--muted); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.mt { margin-top: 18px; }

/* Banderas */
.flag { display: block; width: 100%; height: 100%; }
.flag-inline { display: inline-block; width: 18px; height: 12px; border-radius: 2px; vertical-align: -1px; margin-right: 5px; box-shadow: 0 0 0 1px rgba(11,22,40,.12); }
.pill .flag-inline { margin-right: 4px; }

/* Evita que contenidos anchos estiren las columnas */
.grid > *, .shell > *, .main { min-width: 0; }

/* Textos con código o URLs largas: que partan línea en pantallas angostas */
.form-section p, .form-section code, .field small { overflow-wrap: anywhere; }
