/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --primary:      #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light:#eff6ff;
  --success:      #22c55e;
  --warning:      #f59e0b;
  --danger:       #ef4444;
  --text:         #0f172a;
  --text-muted:   #64748b;
  --border:       #e2e8f0;
  --bg:           #f8fafc;
  --bg-card:      #ffffff;
  --sidebar-w:    240px;
  --radius:       10px;
  --shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:    0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.06);
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
button { cursor: pointer; font: inherit; border: none; background: none; }
input, select, textarea { font: inherit; }
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); font-size: .85rem; }

/* ── Animaciones ───────────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin .8s linear infinite; display: inline-block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── Login ─────────────────────────────────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
}
.login-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 48px 40px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  max-width: 400px;
  width: 90%;
  animation: fadeIn .4s ease;
}
.login-logo {
  width: 64px; height: 64px;
  background: var(--primary-light);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
  font-size: 32px;
}
.login-logo-img {
  width: 88px; height: 88px;
  object-fit: contain;
  display: block;
  margin: 0 auto 18px;
}
.login-card h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 6px; }
.login-card p  { color: var(--text-muted); margin-bottom: 28px; }
.btn-microsoft {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--primary);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: .95rem;
  font-weight: 500;
  width: 100%;
  justify-content: center;
  transition: background .15s;
}
.btn-microsoft:hover  { background: var(--primary-dark); }
.btn-microsoft:disabled { opacity: .65; cursor: not-allowed; }

/* ── Layout ────────────────────────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: #1e293b;
  color: #f1f5f9;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
}
.sidebar-brand {
  padding: 20px 16px 16px;
  border-bottom: 1px solid #334155;
  text-align: center;
}
.sidebar-logo-img {
  width: 56px; height: 56px;
  object-fit: contain;
  background: #fff;
  border-radius: 12px;
  padding: 6px;
  margin: 0 auto 8px;
  display: block;
}
.sidebar-brand h2 { font-size: 1rem; font-weight: 700; color: #f8fafc; }
.sidebar-brand small { color: #94a3b8; font-size: .75rem; }
.sidebar-nav { flex: 1; padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #94a3b8;
  font-size: .9rem;
  cursor: pointer;
  transition: all .15s;
  user-select: none;
}
.nav-item:hover  { background: #334155; color: #f1f5f9; }
.nav-item.active { background: var(--primary); color: #fff; }
.sidebar-user {
  padding: 12px;
  border-top: 1px solid #334155;
}
.user-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  border-radius: 8px;
}
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700;
  flex-shrink: 0;
}
.user-meta { flex: 1; min-width: 0; }
.user-meta strong { display: block; font-size: .85rem; color: #f1f5f9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta small  { font-size: .72rem; color: #94a3b8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.btn-icon { color: #64748b; padding: 4px; border-radius: 4px; }
.btn-icon:hover { color: #f1f5f9; }

/* Main content */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 28px;
  min-height: 100vh;
  position: relative;
}

/* ── Demo badge ────────────────────────────────────────────────────────────── */
.demo-badge {
  display: inline-flex; align-items: center; gap: 5px;
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  margin-bottom: 16px;
}

/* ── Stats ─────────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.stat-label { font-size: .8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--text); }
.stat-card.stat-success .stat-value { color: var(--success); }
.stat-card.stat-warning .stat-value { color: var(--warning); }
.stat-card.stat-primary .stat-value { color: var(--primary); }

/* Tarjetas-filtro clicables */
.stat-clickable { cursor: pointer; transition: box-shadow .15s, border-color .15s, transform .1s; }
.stat-clickable:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card.stat-active-filter { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }

/* Barra de búsqueda */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px 14px; margin-bottom: 16px;
  box-shadow: var(--shadow); color: var(--text-muted);
  max-width: 420px;
}
.search-bar input {
  flex: 1; border: none; background: none; outline: none;
  font-size: .9rem; color: var(--text);
}
.search-bar:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

/* ── Section header ─────────────────────────────────────────────────────────  */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.section-header h2 { font-size: 1.1rem; font-weight: 600; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 7px;
  font-size: .9rem; font-weight: 500;
  transition: all .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { color: var(--text-muted); }
.btn-ghost:hover { background: var(--border); color: var(--text); }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ── Employee cards ────────────────────────────────────────────────────────── */
.employee-list { display: flex; flex-direction: column; gap: 10px; }
.employee-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s;
  animation: fadeIn .2s ease;
}
.employee-card:hover { box-shadow: var(--shadow-md); border-color: var(--primary); }
.employee-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem; flex-shrink: 0;
}
.employee-info { flex: 1; min-width: 0; }
.employee-info h3 { font-size: .95rem; font-weight: 600; margin-bottom: 2px; }
.progress-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 20px; font-size: .8rem; font-weight: 600;
  white-space: nowrap;
}
.badge-done     { background: #dcfce7; color: #166534; }
.badge-progress { background: #eff6ff; color: var(--primary); }
.progress-bar-wrap {
  height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-bottom: 10px;
}
.progress-bar { height: 100%; background: var(--primary); border-radius: 3px; transition: width .4s ease; }
.employee-card-footer { display: flex; justify-content: space-between; }

/* Botón eliminar en la tarjeta */
.btn-delete {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 7px;
  color: var(--text-muted); flex-shrink: 0;
  transition: all .15s;
}
.btn-delete:hover { background: #fef2f2; color: var(--danger); }

/* ── Employee detail ────────────────────────────────────────────────────────── */
.employee-detail-header {
  display: flex; align-items: flex-start; gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.avatar-lg {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.1rem; flex-shrink: 0;
}
.employee-detail-info { flex: 1; }
.employee-detail-info h2 { font-size: 1.2rem; font-weight: 700; }
.employee-detail-info .meta { color: var(--text-muted); font-size: .85rem; display: flex; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.progress-summary { text-align: right; min-width: 80px; }
.progress-pct { font-size: 1.8rem; font-weight: 700; color: var(--primary); line-height: 1; }

/* ── Task categories ────────────────────────────────────────────────────────── */
.task-categories { display: flex; flex-direction: column; gap: 12px; }
.task-category {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.category-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
}
.category-label { font-weight: 600; font-size: .9rem; }
.category-count  { font-size: .8rem; }
.task-list { padding: 4px 0; }

/* ── Task items ─────────────────────────────────────────────────────────────── */
.task-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.task-item:last-child { border-bottom: none; }
.task-item:hover { background: var(--bg); }
.task-item.task-done .task-title { text-decoration: line-through; opacity: .6; }
.task-item.task-skipped { opacity: .5; }

.task-check { flex-shrink: 0; cursor: pointer; }
.check-empty {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--border);
  transition: border-color .15s;
}
.check-empty:hover { border-color: var(--primary); }
.check-done {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--success); color: #fff;
  display: flex; align-items: center; justify-content: center;
}

.task-body { flex: 1; min-width: 0; }
.task-title {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  font-size: .9rem; font-weight: 500; margin-bottom: 3px;
}
.task-icon { color: var(--text-muted); flex-shrink: 0; }
.task-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

.tag-optional, .tag-auto {
  padding: 1px 7px; border-radius: 10px; font-size: .72rem; font-weight: 600;
}
.tag-optional { background: #f1f5f9; color: var(--text-muted); }
.tag-auto     { background: #ede9fe; color: #6d28d9; }

/* Campo de detalle/evidencia por tarea */
.task-note-wrap { margin-top: 6px; }
.task-note-input {
  width: 100%; max-width: 480px;
  padding: 6px 10px; border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: .82rem; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.task-note-input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
  background: #fff;
}
.task-note-input.note-required { border-color: #fcd34d; background: #fffbeb; }
.task-note-readonly {
  margin-top: 5px; font-size: .82rem; color: var(--text-muted);
  background: var(--bg); padding: 5px 10px; border-radius: 6px;
  max-width: 480px;
}

.task-actions { flex-shrink: 0; }
.status-select {
  padding: 4px 8px; border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: .8rem;
  color: var(--text);
  cursor: pointer;
}

/* ── New employee form ─────────────────────────────────────────────────────── */
.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
  max-width: 640px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
@media (max-width: 500px) { .form-grid { grid-template-columns: 1fr; } }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.span-2 { grid-column: span 2; }
.form-group label { font-size: .85rem; font-weight: 500; color: var(--text); }
.form-group input, .form-group select {
  padding: 8px 12px; border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  transition: border-color .15s;
}
.form-group input:focus, .form-group select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form-footer { display: flex; justify-content: flex-end; gap: 10px; }

/* ── Empty state ───────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 48px 24px;
  color: var(--text-muted);
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}

/* ── Loading overlay ───────────────────────────────────────────────────────── */
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  backdrop-filter: blur(2px);
}
.loading-spinner { color: var(--primary); }

/* ── Toasts ────────────────────────────────────────────────────────────────── */
#toast-area {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 999;
}
.toast {
  padding: 12px 18px; border-radius: 8px;
  font-size: .9rem; font-weight: 500;
  max-width: 320px; box-shadow: var(--shadow-md);
  opacity: 0; transform: translateY(10px);
  transition: all .25s;
}
.toast-show { opacity: 1; transform: none; }
.toast-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.toast-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.toast-info    { background: #eff6ff; color: var(--primary); border: 1px solid #bfdbfe; }

/* ── Page titles ───────────────────────────────────────────────────────────── */
.page-title {
  font-size: 1.25rem; font-weight: 700; margin-bottom: 4px;
}
.page-sub { color: var(--text-muted); margin-bottom: 20px; font-size: .9rem; }

/* ── Tareas bloqueadas ─────────────────────────────────────────────────────── */
.task-item.task-blocked {
  opacity: .75;
  background: #fafafa;
}
.check-blocked {
  width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.check-interactive:hover { border-color: var(--primary); }
.no-pointer { cursor: default; }
.blocked-reason {
  font-size: .78rem; color: #ef4444; margin-bottom: 3px;
  display: flex; align-items: center; gap: 4px;
}
.blocked-reason::before { content: "⚠"; }

/* ── Aviso de rol (vista de responsable) ───────────────────────────────────── */
.role-notice {
  background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px;
  padding: 10px 14px; font-size: .85rem; color: var(--primary);
  margin-bottom: 12px;
}

/* ── Categoría propia resaltada ────────────────────────────────────────────── */
.my-category { box-shadow: 0 0 0 2px var(--primary); }

/* ── Type toggle (Entrada / Salida) ────────────────────────────────────────── */
.type-toggle { display: flex; gap: 10px; }
.type-option { cursor: pointer; }
.type-option input[type="radio"] { display: none; }
.type-btn {
  display: inline-block; padding: 8px 20px; border-radius: 8px;
  border: 2px solid var(--border); font-size: .9rem; font-weight: 500;
  cursor: pointer; transition: all .15s; background: var(--bg);
}
.type-option input:checked + .type-entrada {
  background: #eff6ff; border-color: var(--primary); color: var(--primary);
}
.type-option input:checked + .type-salida {
  background: #fef2f2; border-color: var(--danger); color: var(--danger);
}

/* ── Badge de tipo en cards ────────────────────────────────────────────────── */
.badge-type {
  padding: 2px 8px; border-radius: 20px; font-size: .72rem; font-weight: 600;
}
.badge-entrada { background: #eff6ff; color: var(--primary); }
.badge-salida  { background: #fef2f2; color: var(--danger); }
