/* ── Variables y base ── */
:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e5e7eb;
  --blue: #2563eb;
  --red: #ef4444;
  --violet: #7c3aed;
  --green: #10b981;
  --orange: #f59e0b;
  --shadow: 0 18px 40px rgba(15, 23, 42, .08);
  --radius: 22px;
  --hour: 74px;
  --slot: 37px;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, Segoe UI, Arial, sans-serif; background: var(--bg); color: var(--ink); }

/* ── Layout principal ── */
.app { max-width: 1500px; margin: 0 auto; padding: 22px; }

.hero {
  background: linear-gradient(135deg, #0f172a, #1d4ed8);
  color: white;
  border-radius: 28px;
  padding: 26px 30px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}
.hero h1 { margin: 0 0 8px; font-size: 28px; }
.hero p { margin: 0; color: #dbeafe; max-width: 780px; line-height: 1.5; }
.hero .pill { background: rgba(255,255,255,.13); padding: 10px 14px; border-radius: 999px; font-weight: 700; white-space: nowrap; }

/* ── Selector de personas ── */
.people { display: flex; gap: 10px; flex-wrap: wrap; margin: 18px 0; }
.person { border: 1px solid var(--line); background: white; border-radius: 999px; padding: 10px 14px; font-weight: 750; cursor: pointer; box-shadow: 0 6px 18px rgba(15,23,42,.05); }
.person.active { background: #0f172a; color: white; border-color: #0f172a; }

/* ── Grid y tarjetas ── */
.topgrid { display: grid; grid-template-columns: 1fr 320px; gap: 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ── Calendario ── */
.calendar-card { overflow: hidden; }
.cal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.cal-head h2 { font-size: 18px; margin: 0; }
.nav { display: flex; gap: 8px; align-items: center; font-weight: 800; }

.btn { border: none; background: #f1f5f9; color: #0f172a; border-radius: 12px; padding: 10px 13px; font-weight: 800; cursor: pointer; }
.btn.primary { background: #2563eb; color: white; }
.btn.small { padding: 7px 10px; font-size: 12px; }
.btn:hover { filter: brightness(.97); }

.board { overflow: auto; }
.calendar { min-width: 980px; display: grid; grid-template-columns: 72px repeat(7, 1fr); }

.time-head,
.day-head {
  height: 56px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 850;
  font-size: 12px;
  text-align: center;
}
.day-head { border-left: 1px solid var(--line); line-height: 1.25; }
.time-col { border-right: 1px solid var(--line); }
.hour-label { height: var(--hour); border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; justify-content: center; padding-top: 8px; color: var(--muted); font-size: 12px; }

.cell-drop { position: absolute; left: 0; right: 0; height: var(--slot); border-bottom: 1px solid transparent; user-select: none; }

.day-col {
  position: relative;
  overflow: hidden;
  border-left: 1px solid var(--line);
  background: repeating-linear-gradient(to bottom,
    #fff 0, #fff calc(var(--slot) - 1px),
    #f1f5f9 calc(var(--slot) - 1px), #f1f5f9 var(--slot),
    #fff var(--slot), #fff calc(var(--hour) - 1px),
    #e5e7eb calc(var(--hour) - 1px), #e5e7eb var(--hour));
  min-height: calc(var(--slot) * 18);
}
.cell-drop.dragover { background: #eff6ff; outline: 2px dashed #93c5fd; outline-offset: -5px; }

/* ── Eventos ── */
.event {
  position: absolute;
  cursor: pointer;
  left: 6px;
  right: 6px;
  border-radius: 14px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 8px 18px rgba(15,23,42,.08);
  overflow: hidden;
  font-size: 12px;
}
.event .type { display: inline-flex; border-radius: 999px; padding: 3px 8px; font-size: 11px; font-weight: 900; margin-bottom: 4px; }
.event b { display: block; font-size: 12.5px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event .meta { color: var(--muted); font-weight: 650; }
.event .note { margin-top: 4px; color: #475569; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.event.proyecto   { border-left: 5px solid var(--blue); }
.event.proyecto   .type { background: #dbeafe; color: #1d4ed8; }
.event.incidencia { border-left: 5px solid var(--red); }
.event.incidencia .type { background: #fee2e2; color: #dc2626; }
.event.reunion    { border-left: 5px solid var(--violet); }
.event.reunion    .type { background: #ede9fe; color: #6d28d9; }
.event.actividad  { border-left: 5px solid var(--green); }
.event.actividad  .type { background: #dcfce7; color: #047857; }

.event[draggable="true"] { cursor: grab; }
.event[draggable="true"]:active { cursor: grabbing; }

.x { position: absolute; right: 8px; top: 8px; border: none; background: #f8fafc; border-radius: 10px; width: 24px; height: 24px; cursor: pointer; color: #64748b; }

/* ── Sidebar ── */
.side { display: flex; flex-direction: column; gap: 16px; }
.side .card { padding: 18px; }
.side h3 { margin: 0 0 12px; font-size: 16px; }

.palette { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.drag { user-select: none; border: 1px solid var(--line); background: #f8fafc; border-radius: 16px; padding: 13px 12px; font-weight: 850; cursor: grab; text-align: center; }
.drag:active { cursor: grabbing; }
.drag[data-type="incidencia"] { background: #fff1f2; }
.drag[data-type="reunion"]    { background: #f5f3ff; }
.drag[data-type="actividad"]  { background: #ecfdf5; }
.drag[data-type="proyecto"]   { background: #eff6ff; }

.hint { font-size: 12px; color: var(--muted); line-height: 1.4; margin-top: 10px; }
kbd { font-size: 11px; font-family: inherit; background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 4px; padding: 1px 5px; color: var(--ink); }

/* ── Estadísticas ── */
.stats .bar { height: 14px; border-radius: 999px; overflow: hidden; background: #e5e7eb; display: flex; margin: 12px 0; }
.seg { height: 100%; }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 12px; color: var(--muted); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; }
.summary { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; font-size: 13px; color: var(--muted); line-height: 1.5; }

/* ── Resumen del equipo ── */
.ts-row { display: flex; align-items: flex-start; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.ts-row:last-child { border-bottom: none; }
.ts-name { font-size: 12px; font-weight: 700; width: 76px; flex-shrink: 0; padding-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ts-right { flex: 1; min-width: 0; }
.ts-bar { height: 10px; border-radius: 999px; overflow: hidden; display: flex; background: var(--line); margin-bottom: 5px; }
.ts-seg { height: 100%; }
.ts-pct { font-size: 10px; line-height: 1.5; color: var(--muted); }
.ts-total { font-size: 12px; font-weight: 700; width: 30px; text-align: right; flex-shrink: 0; padding-top: 3px; color: var(--ink); }
.ts-empty { font-size: 12px; color: var(--muted); padding: 8px 0; }

/* ── Paneles colapsables ── */
.panel { margin-top: 18px; }
.panel summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; font-weight: 900; }
.panel summary::-webkit-details-marker { display: none; }
.panel .content { border-top: 1px solid var(--line); padding: 18px; }

/* ── Proyectos y actividades ── */
.proj-grid { display: grid; grid-template-columns: 360px 1fr; gap: 18px; }

.form input,
.form select,
.form textarea { width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 11px 12px; margin: 7px 0 10px; font-family: inherit; }
.form label { font-size: 12px; font-weight: 850; color: #334155; }

.project { border: 1px solid var(--line); border-radius: 18px; padding: 14px; margin-bottom: 12px; background: #fff; }
.project-head { display: flex; justify-content: space-between; gap: 12px; }
.project h4 { margin: 0 0 4px; }

.progress-wrap { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; margin: 10px 0; }
.pct { font-size: 12px; font-weight: 900; color: #2563eb; background: #eff6ff; border-radius: 999px; padding: 4px 8px; }
.progress { height: 10px; background: #e5e7eb; border-radius: 999px; overflow: hidden; margin: 10px 0; }
.progress span { display: block; height: 100%; background: var(--blue); border-radius: 999px; }

.activity { border: 1px solid var(--line); border-radius: 14px; padding: 10px; margin-top: 9px; background: #f8fafc; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.activity .title { font-weight: 850; }
.activity .mini { font-size: 12px; color: var(--muted); }
.activity[draggable="true"] { cursor: grab; }

.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 22px; border: 1px dashed var(--line); border-radius: 16px; background: #f8fafc; }

/* ── Modal ── */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: none; align-items: center; justify-content: center; padding: 20px; z-index: 50; }
.modal.open { display: flex; }
.dialog { background: white; border-radius: 24px; box-shadow: var(--shadow); padding: 22px; width: min(520px, 100%); }
.dialog h3 { margin: 0 0 6px; }
.dialog p { margin: 0 0 14px; color: var(--muted); font-size: 13px; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.checks { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 12px; }
.check {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  user-select: none;
}
.check input { display: none; }
.check:has(input:checked) {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
}
.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 12px; }
.hours-warn { background: #fef2f2; color: #dc2626; border-radius: 10px; padding: 8px 12px; font-size: 12px; font-weight: 600; margin-top: -4px; margin-bottom: 6px; }
.input-warn { border-color: #ef4444 !important; }

.project-info { border: 1px solid var(--line); background: #f8fafc; border-radius: 16px; padding: 10px 12px; margin: 10px 0 14px; font-size: 13px; color: #334155; }
.project-info b { color: #0f172a; }

/* ── Cartera de proyectos ── */
.projects-section { margin-top: 18px; }
.projects-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.projects-head h3 { margin: 0; font-size: 18px; }
#projectList { padding: 18px; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }

.proj-card { border: 1px solid var(--line); border-radius: 18px; padding: 16px; background: #fff; }
.proj-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.proj-card-info h4 { margin: 4px 0 4px; font-size: 15px; }
.proj-desc { margin: 0 0 4px; font-size: 12px; color: var(--muted); line-height: 1.4; }
.proj-card-actions { display: flex; gap: 6px; flex-shrink: 0; }
.proj-meta { font-size: 12px; color: var(--muted); margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; display: flex; gap: 16px; }

.proj-status { display: inline-flex; border-radius: 999px; padding: 3px 10px; font-size: 11px; font-weight: 900; margin-bottom: 4px; }
.proj-status-activo    { background: #dcfce7; color: #047857; }
.proj-status-pausado   { background: #fef9c3; color: #a16207; }
.proj-status-terminado { background: #f1f5f9; color: #64748b; }

.proj-eta { font-size: 12px; color: var(--muted); margin-top: 8px; }
.proj-eta b { color: var(--ink); }
.proj-progress-wrap { display: flex; align-items: center; gap: 10px; margin: 12px 0 0; }
.proj-progress { flex: 1; height: 10px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.proj-progress-bar { height: 100%; background: var(--blue); border-radius: 999px; transition: width .4s; }
.proj-pct { font-size: 12px; font-weight: 900; color: #2563eb; background: #eff6ff; border-radius: 999px; padding: 3px 8px; flex-shrink: 0; }

/* ── Responsive: tablet ── */
@media (max-width: 1050px) {
  .topgrid,
  .proj-grid { grid-template-columns: 1fr; }
  .side { order: -1; }
  .hero { flex-direction: column; gap: 14px; }
  .hero > div:last-child { flex-wrap: wrap; }
}

/* ── Responsive: móvil ── */
@media (max-width: 640px) {
  .app { padding: 12px; }

  .hero { padding: 18px 20px; border-radius: 20px; }
  .hero h1 { font-size: 20px; }
  .hero p { font-size: 13px; }
  .hero > div:last-child { gap: 8px; }
  .hero .pill { padding: 8px 12px; font-size: 13px; }

  .cal-head { flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px 16px; }
  .cal-head h2 { font-size: 15px; }
  .nav { font-size: 13px; }

  .person { padding: 8px 12px; font-size: 13px; }

  .side .card { padding: 14px; }

  .row { grid-template-columns: 1fr; }
  .actions { flex-wrap: wrap; }
  .dialog { padding: 18px; }
}
