/* CRM Tu Psicolaboral — hoja de estilos única, sin build.
   Paleta: azul rey + azul oscuro + blanco + neutros. Minimalista, mobile-first. */

:root {
  --brand: #1d4ed8;
  --brand-dark: #1e3a8a;
  --brand-700: #1d4ed8;
  --brand-50: #eff6ff;
  --ink: #0f172a;
  --ink-soft: #475569;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f5f7fb;
  --card: #ffffff;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
  --sidebar-w: 240px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--ink); line-height: 1.25; margin: 0; }
h1 { font-size: 1.4rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 650; }

/* ---------- Layout ---------- */
.layout { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--brand-dark);
  color: #dbe4ff;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  z-index: 60;
  transform: translateX(-100%);
  transition: transform .22s ease;
}
.sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.4); }
.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 55;
}
.menu-toggle {
  background: none; border: none; font-size: 1.5rem; line-height: 1;
  color: var(--brand-dark); cursor: pointer; padding: 4px 8px; margin-left: -4px;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 18px;
}
.sidebar .brand .brand-mark {
  width: 40px; height: 40px; flex: none;
  background: #fff; border-radius: 10px; padding: 4px;
}
.sidebar .brand .brand-txt { display: flex; flex-direction: column; gap: 1px; }
.sidebar .brand strong { color: #fff; font-size: 1rem; }
.sidebar .brand span { color: #9db4f0; font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; }
.mobile-brand img { border-radius: 6px; background: #fff; padding: 2px; }
.login-logo { display: block; width: 210px; max-width: 82%; margin: 4px auto 14px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar a.navlink {
  color: #c9d6f7;
  padding: 9px 12px;
  border-radius: 9px;
  font-size: .92rem;
  display: flex; align-items: center; gap: 10px;
}
.sidebar a.navlink:hover { background: rgba(255,255,255,.08); text-decoration: none; color: #fff; }
.sidebar a.navlink.active { background: var(--brand); color: #fff; font-weight: 600; }
.sidebar .spacer { flex: 1; }
.sidebar .userbox { border-top: 1px solid rgba(255,255,255,.12); padding-top: 12px; margin-top: 8px; font-size: .82rem; color: #9db4f0; }
.sidebar .userbox a { color: #c9d6f7; }

.content { padding: 16px; padding-bottom: 84px; }

.topbar {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 10px; margin-bottom: 16px;
}
.topbar > div:last-child { margin-left: auto; }
@media (max-width: 899px) {
  .global-search { order: 5; flex-basis: 100%; max-width: none; }
}
.topbar .mobile-brand { font-weight: 700; color: var(--brand-dark); }
.topbar .mobile-brand span { color: var(--muted); font-weight: 500; font-size: .8rem; display: block; }
.global-search { flex: 1; max-width: 420px; }
.global-search input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px;
  font: inherit; background: #fff;
}

/* ---------- Bottom nav (móvil) ---------- */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--card);
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  z-index: 40;
}
.bottomnav a {
  flex: 1;
  text-align: center;
  color: var(--muted);
  font-size: .68rem;
  padding: 4px 2px;
  border-radius: 8px;
}
.bottomnav a .ic { display: block; font-size: 1.15rem; line-height: 1.1; }
.bottomnav a.active { color: var(--brand); font-weight: 600; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card + .card { margin-top: 14px; }
.card h2 { margin-bottom: 12px; }
.card-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 10px; }

.grid { display: grid; gap: 14px; }
@media (min-width: 380px) { .grid.cols-2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px) {
  .grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
}

/* ---------- Goal panel ---------- */
.goal-panel { background: linear-gradient(135deg, var(--brand-dark), var(--brand)); color: #fff; border: none; }
.goal-panel h2 { color: #fff; }
.goal-figures { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 6px 0 14px; }
@media (min-width: 720px) { .goal-figures { grid-template-columns: repeat(4, 1fr); } }
.goal-fig .label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: #c7d6ff; }
.goal-fig .value { font-size: 1.35rem; font-weight: 700; }
.goal-fig.small .value { font-size: 1.1rem; }

.progress { margin-top: 10px; }
.progress .prow { display: flex; justify-content: space-between; font-size: .8rem; color: #dbe4ff; margin-bottom: 4px; }
.progress .track { height: 10px; background: rgba(255,255,255,.22); border-radius: 999px; overflow: hidden; }
.progress .fill { height: 100%; background: #fff; border-radius: 999px; }
.progress .fill.collected { background: #a7f3d0; }

/* ---------- Stat cards ---------- */
.stat { padding: 13px 14px; }
.stat .label { color: var(--muted); font-size: .78rem; line-height: 1.3; }
.stat .value { font-size: 1.25rem; font-weight: 700; margin-top: 3px; word-break: break-word; }
.stat .sub { color: var(--muted); font-size: .76rem; margin-top: 2px; }
@media (min-width: 900px) { .stat .value { font-size: 1.35rem; } }
.stat.accent .value { color: var(--brand); }
.stat.bad .value { color: var(--bad); }
.stat.ok .value { color: var(--ok); }

/* ---------- Tables / lists ---------- */
.list { display: flex; flex-direction: column; }
.list .row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.list .row:last-child { border-bottom: none; }
.list .row .main { flex: 1; min-width: 0; }
.list .row .main .name { font-weight: 600; }
.list .row .main .meta { color: var(--muted); font-size: .8rem; }
.list .row .amount { font-weight: 700; white-space: nowrap; }

.dot { width: 10px; height: 10px; border-radius: 999px; flex: none; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: .72rem; font-weight: 600; background: var(--brand-50); color: var(--brand-dark);
}
.badge.gray { background: #f1f5f9; color: var(--muted); }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.bad { background: #fee2e2; color: #991b1b; }

.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.data th, table.data td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data th { color: var(--muted); font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Forms ---------- */
label.field { display: block; margin-bottom: 12px; }
label.field .lbl { display: block; font-size: .82rem; color: var(--ink-soft); margin-bottom: 4px; font-weight: 600; }
input[type=text], input[type=number], input[type=email], input[type=password], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px;
  font: inherit; color: var(--ink); background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-50); border-color: var(--brand); }

.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 9px 16px; border-radius: 9px; border: 1px solid transparent;
  background: var(--brand); color: #fff; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; color: #fff; }
.btn.secondary { background: #fff; color: var(--brand-dark); border-color: var(--line); }
.btn.secondary:hover { background: var(--brand-50); }
.btn.danger { background: var(--bad); }
.btn.danger:hover { background: #b91c1c; }
.btn.block { width: 100%; }

.messages { margin-bottom: 14px; display: flex; flex-direction: column; gap: 8px; }
.msg { padding: 10px 14px; border-radius: 9px; font-size: .9rem; border: 1px solid var(--line); background: #fff; }
.msg.success { background: #dcfce7; border-color: #86efac; color: #166534; }
.msg.error { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.stack > * + * { margin-top: 12px; }
.right { text-align: right; }
.mt0 { margin-top: 0; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(135deg, var(--brand-dark), var(--brand)); }
.login-card { background: #fff; border-radius: 16px; padding: 28px; width: 100%; max-width: 360px; box-shadow: 0 20px 45px rgba(2, 6, 23, .3); }
.login-card h1 { margin-bottom: 4px; }
.login-card .sub { color: var(--muted); margin-bottom: 20px; font-size: .9rem; }

/* ---------- Empty state ---------- */
.empty { text-align: center; color: var(--muted); padding: 26px 10px; }
.empty .big { font-size: 1.6rem; margin-bottom: 6px; }

/* ---------- FAB acciones rápidas ---------- */
.fab { position: fixed; right: 16px; bottom: 74px; z-index: 45; }
.fab-menu { position: relative; }
.fab-menu > summary {
  list-style: none; cursor: pointer;
  width: 52px; height: 52px; border-radius: 999px;
  background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: 1.8rem; font-weight: 400;
  box-shadow: 0 6px 18px rgba(29,78,216,.4);
}
.fab-menu > summary::-webkit-details-marker { display: none; }
.fab-menu[open] > summary { background: var(--brand-dark); transform: rotate(45deg); }
.fab-items {
  position: absolute; right: 0; bottom: 62px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); overflow: hidden; min-width: 190px;
}
.fab-items a { display: block; padding: 12px 16px; color: var(--ink); border-bottom: 1px solid var(--line); }
.fab-items a:last-child { border-bottom: none; }
.fab-items a:hover { background: var(--brand-50); text-decoration: none; }

/* ---------- Toolbar / filtros ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex: 1; }
.toolbar .inp, .toolbar select { width: auto; min-width: 0; padding: 7px 10px; font-size: .88rem; }
.toolbar .grow { flex: 1; min-width: 160px; }
.count-pill { color: var(--muted); font-size: .85rem; }

/* ---------- Semáforo ---------- */
.sem { display: inline-flex; align-items: center; gap: 6px; }
.sem .dot { width: 9px; height: 9px; }
.sem-verde { color: var(--ok); } .sem-amarillo { color: var(--warn); }
.sem-rojo { color: var(--bad); } .sem-gris { color: var(--muted); }

/* ---------- Pipeline Kanban ---------- */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; }
.kcol { flex: 0 0 260px; background: #eef2f8; border-radius: 12px; padding: 10px; }
.kcol h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft);
  display: flex; justify-content: space-between; margin-bottom: 8px; }
.kcol h3 .n { background: #fff; border-radius: 999px; padding: 0 8px; font-size: .78rem; }
.kcards { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.kcard {
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px;
  box-shadow: var(--shadow); cursor: grab; font-size: .86rem;
}
.kcard:active { cursor: grabbing; }
.kcard .kname { font-weight: 600; display: block; }
.kcard .kmeta { color: var(--muted); font-size: .78rem; margin-top: 3px; }
.kcard .kval { font-weight: 700; color: var(--brand-dark); }
.kcard.sortable-ghost { opacity: .4; }
.kcard.sortable-chosen { box-shadow: 0 8px 20px rgba(15,23,42,.18); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 600; font-size: .9rem; white-space: nowrap; border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }
.tabs a:hover { text-decoration: none; color: var(--ink); }

/* ---------- Timeline ---------- */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 14px 18px; border-left: 2px solid var(--line); }
.timeline li:last-child { border-left-color: transparent; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 3px; width: 10px; height: 10px;
  border-radius: 999px; background: var(--brand); }
.timeline .t-when { color: var(--muted); font-size: .78rem; }

/* ---------- Definition rows ---------- */
.dl { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 620px) { .dl { grid-template-columns: 1fr 1fr; } }
.dl .d { border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.dl .d .k { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; }
.dl .d .v { font-weight: 500; }

.wa-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 0 16px; }
@media (min-width: 640px) { .form-grid { grid-template-columns: 1fr 1fr; } .form-grid .full { grid-column: 1 / -1; } }
.inp { width: 100%; }

/* ---------- Notificaciones ---------- */
.notif-bell {
  position: relative; text-decoration: none; font-size: 1.2rem; line-height: 1;
  padding: 4px; margin-left: auto;
}
.topbar > div:last-child { margin-left: 0; }
.notif-count {
  position: absolute; top: -4px; right: -6px; background: var(--bad); color: #fff;
  font-size: .68rem; font-weight: 700; min-width: 16px; height: 16px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 4px;
}
.list .row.unread { border-left: 3px solid var(--brand); }

/* ---------- Desktop ---------- */
@media (min-width: 900px) {
  .sidebar { transform: none; transition: none; z-index: 60; }
  .sidebar-backdrop { display: none !important; }
  .menu-toggle { display: none; }
  .content { margin-left: var(--sidebar-w); padding: 26px 32px; padding-bottom: 40px; max-width: 1180px; }
  .bottomnav { display: none; }
  .topbar .mobile-brand { display: none; }
  .fab { bottom: 28px; right: 28px; }
}
