/* ==== SmartGeek — tema claro único ==== */
:root {
  --bg: #F4F7FA;
  --panel: #FFFFFF;
  --panel-2: #EEF2F6;
  --border: #D5DDE6;
  --cyan: #0B7F95;          /* cian oscuro: texto legible sobre fondo blanco */
  --cyan-bright: #3FD4E8;   /* cian brillante: solo para degradados y acentos */
  --blue: #2563EB;
  --text: #0F1620;
  --muted: #566577;
  --amber: #B45309;
  --green: #15803D;
  --red: #DC2626;
  --input-bg: #FFFFFF;
  --shadow: 0 1px 2px rgba(15, 22, 32, .05), 0 4px 14px rgba(15, 22, 32, .04);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 100% -10%, rgba(59,130,246,0.08), transparent 60%), var(--bg);
  color: var(--text);
  font-family: 'Space Grotesk', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
}
a { color: var(--cyan); }
img, video { max-width: 100%; }
[hidden] { display: none !important; }

/* ---- Marca ---- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand img.logo { height: 30px; width: auto; display: block; }
.brand h1 { font-size: 20px; font-weight: 600; margin: 0; letter-spacing: -0.3px; }

/* ---- Layout ---- */
.wrap { padding: 24px 28px 60px; max-width: 1200px; margin: 0 auto; }
header.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 14px; }
header.top .actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
nav.tabs, .tabs { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 4px; overflow-x: auto; max-width: 100%; scrollbar-width: thin; }
nav.tabs a, .tabs .tab { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 7px; text-decoration: none; color: var(--muted); font-weight: 500; font-size: 13px; white-space: nowrap; cursor: pointer; border: 0; background: transparent; font-family: inherit; }
nav.tabs a:hover, .tabs .tab:hover { color: var(--text); background: var(--panel-2); }
nav.tabs a.active, .tabs .tab.active { background: linear-gradient(135deg, var(--cyan-bright), var(--blue)); color: #04141C; font-weight: 600; }

.error-banner { background: #FFF7E6; border: 1px solid #F2C879; color: var(--amber); padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 18px; display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.error-banner button { background: transparent; border: 0; color: inherit; cursor: pointer; font-size: 15px; line-height: 1; }
.success-banner { background: #EAF8EF; border: 1px solid #86D3A0; color: var(--green); padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 18px; }
.info-note { color: var(--muted); font-size: 12px; margin-top: 30px; line-height: 1.6; }

/* ---- Tarjetas y estadísticas ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px; box-shadow: var(--shadow); }
.stat-card.clickable { cursor: pointer; transition: transform .12s, border-color .12s; }
.stat-card.clickable:hover { border-color: var(--cyan); transform: translateY(-1px); }
.stat-card .row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.stat-card .label { font-size: 11.5px; color: var(--muted); }
.stat-card .value { font-size: 24px; font-weight: 700; }
.stat-card .sub { font-size: 11px; color: var(--muted); margin-top: 4px; }

.section-title { font-size: 14px; font-weight: 600; color: var(--muted); margin: 0 0 10px; }
.empty { border: 1px dashed var(--border); border-radius: 14px; padding: 60px 20px; text-align: center; color: var(--muted); background: var(--panel); }
.empty p { margin: 0 0 6px; font-size: 15px; color: var(--text); }

/* ---- Botones ---- */
.btn, a.btn { display: inline-flex; align-items: center; gap: 6px; border: none; border-radius: 8px; padding: 10px 16px; font-weight: 600; font-size: 13px; cursor: pointer; background: linear-gradient(135deg, var(--cyan-bright), var(--blue)); color: #04141C; text-decoration: none; font-family: inherit; }
.btn:hover { filter: brightness(1.05); }
.btn-secondary, a.btn-secondary { display: inline-flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--border); color: var(--text); font-weight: 500; padding: 9px 14px; border-radius: 8px; font-size: 12.5px; cursor: pointer; text-decoration: none; font-family: inherit; }
.btn-secondary:hover { border-color: var(--cyan); background: var(--panel-2); }
.btn-wa, a.btn-wa { background: linear-gradient(135deg, #25D366, #128C7E); color: #04210F; }
.btn[disabled], .btn-secondary[disabled] { opacity: .5; cursor: not-allowed; }
.btn-danger { color: var(--red) !important; border-color: #F2B8B8 !important; }
.icon-btn { background: transparent; border: none; color: var(--muted); cursor: pointer; padding: 4px 6px; font-size: 14px; border-radius: 6px; }
.icon-btn:hover:not([disabled]) { background: var(--panel-2); color: var(--text); }
.icon-btn[disabled] { color: #B6C0CC; cursor: default; }
.toolbar { display: flex; justify-content: flex-end; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar.between { justify-content: space-between; align-items: center; }

/* ---- Campos de formulario (siempre legibles) ---- */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); flex: 1; margin-bottom: 14px; }
input, textarea, select {
  background: var(--input-bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font-size: 13.5px; outline: none; font-family: inherit; max-width: 100%;
}
input::placeholder, textarea::placeholder { color: #8A97A6; }
.field input, .field textarea, .field select, select { width: 100%; }
select { width: auto; }
input:focus, textarea:focus, select:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(14, 165, 192, .18); }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--blue); }
textarea { resize: vertical; }
.field-row { display: flex; gap: 10px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 64px; }
.pw-wrap button { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: transparent; border: 0; color: var(--cyan); font-size: 12px; font-weight: 600; cursor: pointer; padding: 6px 8px; font-family: inherit; }
.pill-group { display: flex; gap: 8px; flex-wrap: wrap; }
.pill { padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel); color: var(--text); cursor: pointer; font-size: 12.5px; font-family: inherit; }
.pill:hover { border-color: var(--cyan); }
.pill.active { border-color: var(--cyan); background: rgba(14,165,192,.12); color: var(--cyan); font-weight: 600; }

/* ---- Listas y tarjetas de fila ---- */
.board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; }
.column { min-width: 232px; width: 232px; flex-shrink: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 10px; align-self: flex-start; }
.column .head { display: flex; justify-content: space-between; align-items: center; }
.column .head .title { font-size: 12.5px; font-weight: 600; line-height: 1.3; }
.column .head .count { font-size: 11px; color: var(--muted); background: var(--panel-2); border-radius: 20px; padding: 2px 8px; }
.cards { display: flex; flex-direction: column; gap: 8px; min-height: 6px; }
.card { background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; padding: 10px 10px 8px; cursor: pointer; }
.card:hover { border-color: var(--cyan); }
.card.stale { border-color: #E5B25E; background: #FFF9EC; }
.card .name { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.card .contact { font-size: 11.5px; color: var(--muted); margin-bottom: 6px; }
.card .footer { display: flex; justify-content: space-between; align-items: center; }
.card .days { font-size: 10.5px; color: var(--muted); }
.card .days.stale { color: var(--amber); font-weight: 600; }
.card .moves { display: flex; gap: 2px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.row-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; box-shadow: var(--shadow); }
.row-card.clickable { cursor: pointer; }
.row-card.clickable:hover { border-color: var(--cyan); }
.row-card.urgent { border-color: #E5B25E; background: #FFFBF2; }
.row-card.overdue { border-color: #F2A5A5; background: #FFF6F6; }
.row-card.paid { border-color: #A7DDB9; }
.row-card .name { font-size: 14.5px; font-weight: 600; margin-bottom: 3px; }
.row-card .meta { font-size: 12px; color: var(--muted); }
.row-card .meta.urgent { color: var(--amber); font-weight: 600; }
.row-card .meta.overdue { color: var(--red); font-weight: 600; }
.badge { font-size: 10.5px; border-radius: 20px; padding: 1px 8px; }

table.data { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
table.data th { text-align: left; padding: 14px 16px; font-size: 11.5px; color: var(--muted); text-transform: uppercase; background: var(--panel-2); border-bottom: 1px solid var(--border); }
table.data th.c, table.data td.c { text-align: center; }
table.data td { padding: 14px 16px; font-size: 13px; border-bottom: 1px solid var(--border); }
.table-scroll { overflow-x: auto; }

/* ---- Modal ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,22,32,.45); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 24px; width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto; position: relative; color: var(--text); box-shadow: 0 20px 60px rgba(15,22,32,.25); }
.modal .close-x { position: absolute; top: 16px; right: 16px; background: transparent; border: none; color: var(--muted); cursor: pointer; font-size: 16px; }
.modal h2 { margin: 0 0 12px; font-size: 18px; font-weight: 600; padding-right: 24px; }
.modal-actions { display: flex; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.modal-actions .btn, .modal-actions .btn-secondary { flex: 1; justify-content: center; }
pre.preview { white-space: pre-wrap; font-family: inherit; font-size: 12.5px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: 14px; max-height: 260px; overflow-y: auto; margin: 0; }
.detail-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; margin-bottom: 8px; flex-wrap: wrap; }
.detail-row .dlabel { color: var(--muted); min-width: 90px; }
.note-box { margin-top: 14px; font-size: 13px; color: var(--muted); line-height: 1.5; background: var(--panel-2); padding: 12px; border-radius: 8px; }

/* ---- Portal y tarjetas ---- */
.portal-greeting { font-size: 22px; font-weight: 700; margin: 0 0 4px; }
.portal-sub { color: var(--muted); font-size: 13.5px; margin: 0 0 26px; }
.progress-track { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 22px; margin-bottom: 20px; box-shadow: var(--shadow); }
.progress-bar-bg { height: 8px; background: var(--panel-2); border-radius: 20px; overflow: hidden; margin: 14px 0 10px; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--cyan-bright), var(--blue)); border-radius: 20px; }
.portal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.portal-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); }
.portal-card h4 { margin: 0 0 10px; font-size: 14px; font-weight: 600; color: var(--muted); }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.mini-card { background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; margin-bottom: 8px; font-size: 12.5px; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.status-on { font-size: 10px; background: #EAF8EF; color: var(--green); border: 1px solid var(--green); border-radius: 20px; padding: 2px 8px; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.file-tile { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px; }
.file-tile img { width: 100%; height: 88px; object-fit: cover; border-radius: 6px; margin-bottom: 6px; display: block; }
.file-tile .ph { width: 100%; height: 88px; display: flex; align-items: center; justify-content: center; font-size: 26px; margin-bottom: 6px; }
.file-tile .fname { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Sitio público (landing, login) ---- */
.hero-banner { display: block; width: calc(100% - 12vw); max-height: 480px; object-fit: cover; border-radius: 18px; border: 1px solid var(--border); margin: 0 6vw 10px; background: #0A0F16; }
.site-header { display: flex; align-items: center; justify-content: space-between; padding: 22px 6vw; flex-wrap: wrap; gap: 12px; }
.site-header .brand h1 { font-size: 18px; font-weight: 700; margin: 0; letter-spacing: -0.2px; }
.site-header .links { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.site-header a.plain { color: var(--muted); text-decoration: none; font-size: 13.5px; }
.site-header a.plain:hover { color: var(--text); }

.hero { padding: 60px 6vw 40px; max-width: 780px; }
.hero .eyebrow { color: var(--cyan); font-size: 13px; margin-bottom: 14px; font-weight: 600; letter-spacing: .5px; }
.hero h2 { font-size: clamp(30px, 5vw, 48px); line-height: 1.08; margin: 0 0 18px; letter-spacing: -0.5px; font-weight: 700; }
.hero p.lead { color: var(--muted); font-size: 16px; line-height: 1.6; max-width: 560px; margin: 0 0 28px; }
.cta-row { display: flex; gap: 12px; flex-wrap: wrap; }

.section { padding: 40px 6vw; }
.section h3.title { font-size: 24px; font-weight: 700; margin: 0 0 8px; letter-spacing: -0.3px; }
.section p.sub { color: var(--muted); font-size: 14.5px; margin: 0 0 28px; max-width: 520px; }
.service-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.service-card { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 22px; box-shadow: var(--shadow); }
.service-card .icon { width: 34px; height: 34px; border-radius: 8px; background: linear-gradient(135deg, rgba(63,212,232,.22), rgba(59,130,246,.18)); display: flex; align-items: center; justify-content: center; color: var(--cyan); margin-bottom: 14px; font-size: 16px; }
.service-card h4 { margin: 0 0 6px; font-size: 15.5px; font-weight: 600; }
.service-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.site-footer { padding: 30px 6vw 50px; border-top: 1px solid var(--border); margin-top: 30px; color: var(--muted); font-size: 12.5px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.site-footer a.plain { color: var(--muted); }

.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-box { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 32px; box-shadow: var(--shadow); }
.auth-box .brand { justify-content: center; margin-bottom: 22px; }
.auth-box h2 { text-align: center; font-size: 19px; margin: 0 0 6px; }
.auth-box p.sub { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 24px; }
.auth-box .field { margin-bottom: 16px; }
.auth-box .btn { width: 100%; justify-content: center; padding: 12px 0; }
.auth-box .back-link { display: block; text-align: center; margin-top: 18px; color: var(--muted); font-size: 12.5px; text-decoration: none; }
.auth-error { background: #FEF0F0; border: 1px solid #F2A5A5; color: var(--red); padding: 9px 12px; border-radius: 8px; font-size: 12.5px; margin-bottom: 14px; }

.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--cyan); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 720px) {
  .wrap { padding: 16px; }
  header.top { align-items: flex-start; }
  header.top .actions { width: 100%; }
  header.top nav.tabs { width: 100%; flex: 1 1 100%; min-width: 0; }
  nav.tabs a, .tabs .tab { padding: 7px 10px; font-size: 12px; }
  .field-row { flex-direction: column; gap: 0; }
  .hero { padding-top: 30px; }
  .modal { padding: 18px; }
  .hero-banner { width: calc(100% - 32px); margin: 0 16px 10px; border-radius: 12px; }
}
@media (prefers-reduced-motion: reduce) { .hero-banner { animation: none; } .spinner { animation-duration: 2s; } }

.portal-card.overdue { border-color: #F2A5A5; background: #FFF6F6; }
.portal-card.urgent { border-color: #E5B25E; background: #FFFBF2; }

/* ---- Chat del equipo ---- */
.chat-badge { background: var(--red); color: #fff; font-size: 10px; font-weight: 700; border-radius: 20px; padding: 1px 6px; margin-left: 2px; line-height: 1.4; }
.chat-caja { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px; height: min(58vh, 520px); overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 78%; display: flex; flex-direction: column; gap: 2px; }
.msg.mio { align-self: flex-end; align-items: flex-end; }
.msg.otro { align-self: flex-start; }
.msg-autor { font-size: 10.5px; color: var(--muted); }
.msg-texto { padding: 8px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.45; word-break: break-word; }
.msg.otro .msg-texto { background: var(--panel-2); border: 1px solid var(--border); border-top-left-radius: 4px; }
.msg.mio .msg-texto { background: linear-gradient(135deg, rgba(63,212,232,.25), rgba(37,99,235,.18)); border: 1px solid #A9CBF5; border-top-right-radius: 4px; }
.chat-form { display: flex; gap: 8px; margin-top: 10px; align-items: flex-end; }
.chat-form textarea { flex: 1; resize: vertical; min-height: 44px; }
.chat-layout { display: grid; grid-template-columns: 250px 1fr; gap: 16px; }
.chat-hilos { display: flex; flex-direction: column; gap: 6px; }
.chat-hilo { display: flex; justify-content: space-between; align-items: center; gap: 8px; text-align: left; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; cursor: pointer; font-family: inherit; font-size: 13px; color: var(--text); }
.chat-hilo:hover { border-color: var(--cyan); }
.chat-hilo.activo { border-color: var(--blue); background: #EEF4FF; }
.chat-hilo small { display: block; color: var(--muted); font-size: 11px; }
@media (max-width: 760px) { .chat-layout { grid-template-columns: 1fr; } .msg { max-width: 92%; } }

/* ---- Fichas y calendario del equipo ---- */
.barra { height: 8px; background: var(--panel-2); border-radius: 20px; overflow: hidden; border: 1px solid var(--border); }
.barra > span { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan-bright), var(--blue)); }
.chip-color { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--border); vertical-align: middle; }
.dias-sel { display: flex; gap: 6px; flex-wrap: wrap; }
.dias-sel label { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 20px; padding: 4px 10px; cursor: pointer; color: var(--text); }
.checks { display: flex; flex-direction: column; gap: 6px; max-height: 180px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: var(--input-bg); }
.checks label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); }
.checks input, .dias-sel input { width: auto; }

/* ==== Markdown renderizado (brief estratégico con IA) ==== */
.md-render { font-size: 13.5px; line-height: 1.6; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; max-height: 640px; overflow-y: auto; overflow-wrap: anywhere; }
.md-render > :first-child { margin-top: 0; }
.md-render h1, .md-render h2, .md-render h3, .md-render h4, .md-render h5, .md-render h6 { margin: 20px 0 8px; line-height: 1.3; color: var(--text); }
.md-render h1 { font-size: 20px; }
.md-render h2 { font-size: 17px; padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.md-render h3 { font-size: 15px; }
.md-render h4, .md-render h5, .md-render h6 { font-size: 13.5px; }
.md-render p { margin: 0 0 10px; }
.md-render ul, .md-render ol { margin: 0 0 10px; padding-left: 22px; }
.md-render li { margin: 2px 0; }
.md-render li > ul, .md-render li > ol { margin: 2px 0 0; }
.md-render strong { font-weight: 700; }
.md-render a { color: var(--cyan); }
.md-render hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.md-render blockquote { margin: 0 0 10px; padding: 8px 12px; border-left: 3px solid var(--cyan); background: var(--panel-2); border-radius: 0 6px 6px 0; color: var(--muted); }
.md-render code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
.md-render pre { background: var(--panel-2); border-radius: 8px; padding: 10px 12px; overflow-x: auto; margin: 0 0 10px; }
.md-render pre code { background: none; padding: 0; }
.md-render .md-tabla { overflow-x: auto; margin: 0 0 12px; }
.md-render table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.md-render th, .md-render td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
.md-render th { background: var(--panel-2); font-weight: 600; }
