/* ============================================================
   Sistema de diseño — Centro de Control de Proyectos
   Profesional, sobrio, denso en información, sin adornos.
   ============================================================ */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-alt: #f9fafb;
  --border: #e2e5e9;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;
  --primary: #1f3a5f;
  --primary-hover: #16304d;
  --primary-soft: #e8eef5;
  --accent: #2563a8;

  --green: #15803d;   --green-bg: #dcfce7;
  --yellow: #a16207;  --yellow-bg: #fef9c3;
  --orange: #c2410c;  --orange-bg: #ffedd5;
  --red: #b91c1c;     --red-bg: #fee2e2;
  --blue: #1d4ed8;    --blue-bg: #dbeafe;
  --gray: #4b5563;    --gray-bg: #f3f4f6;
  --black-bg: #e5e7eb; --black: #111827;

  --radius: 8px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.10);
  --sidebar-w: 220px;
  --topbar-h: 56px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }

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

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--primary);
  color: #dbe4f0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
}
.sidebar-brand {
  padding: 18px 20px;
  font-weight: 700;
  color: #fff;
  font-size: 15px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  letter-spacing: 0.2px;
}
.sidebar-brand small { display: block; font-weight: 400; font-size: 11px; color: #a8bcd6; margin-top: 2px; }
.nav { flex: 1; padding: 10px 0; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  color: #c7d5e8;
  cursor: pointer;
  font-size: 13.5px;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.10); color: #fff; border-left-color: #5b9bd5; font-weight: 600; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-footer { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,0.12); font-size: 12px; color: #a8bcd6; }
.sidebar-footer .user-name { color: #fff; font-weight: 600; display: block; }
.sidebar-footer .user-cargo, .sidebar-footer .user-nivel { display: block; }
.sidebar-footer .user-nivel { color: #8fb3dc; font-size: 11px; margin-top: 2px; }
.btn-logout { display: block; margin-top: 10px; background: none; border: 1px solid rgba(255,255,255,0.25); color: #dbe4f0; padding: 5px 10px; border-radius: var(--radius-sm); cursor: pointer; font-size: 12px; }
.btn-logout:hover { background: rgba(255,255,255,0.1); }
.sidebar-footer .credito { margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.12); font-size: 10.5px; color: #7f9bbd; letter-spacing: 0.2px; }

.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 17px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.content { padding: 24px; flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--surface-alt); }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { color: var(--red); border-color: #f3caca; }
.btn-danger:hover { background: var(--red-bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Cards / stats ---------- */
.grid { display: grid; gap: 16px; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.stat-card { display: flex; flex-direction: column; gap: 4px; cursor: pointer; }
.stat-card .stat-value { font-size: 26px; font-weight: 700; }
.stat-card .stat-label { font-size: 12.5px; color: var(--text-muted); }
.stat-card.red .stat-value { color: var(--red); }
.stat-card.yellow .stat-value { color: var(--yellow); }
.stat-card.green .stat-value { color: var(--green); }
.stat-card.blue .stat-value { color: var(--blue); }
.stat-card.gray .stat-value { color: var(--gray); }

.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-muted); margin: 28px 0 12px; display: flex; align-items: center; gap: 8px; }
.section-title:first-child { margin-top: 0; }

/* ---------- Table ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.3px;
  color: var(--text-muted); padding: 10px 14px; background: var(--surface-alt);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 13px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-alt); }
.empty-row td { text-align: center; color: var(--text-faint); padding: 32px; }

/* ---------- Badges / semáforo ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.badge-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.badge.green { background: var(--green-bg); color: var(--green); } .badge.green .badge-dot { background: var(--green); }
.badge.yellow { background: var(--yellow-bg); color: var(--yellow); } .badge.yellow .badge-dot { background: var(--yellow); }
.badge.orange { background: var(--orange-bg); color: var(--orange); } .badge.orange .badge-dot { background: var(--orange); }
.badge.red { background: var(--red-bg); color: var(--red); } .badge.red .badge-dot { background: var(--red); }
.badge.blue { background: var(--blue-bg); color: var(--blue); } .badge.blue .badge-dot { background: var(--blue); }
.badge.gray { background: var(--gray-bg); color: var(--gray); } .badge.gray .badge-dot { background: var(--gray); }
.badge.black, .badge.blue-check { background: var(--black-bg); color: var(--black); } .badge.black .badge-dot, .badge.blue-check .badge-dot { background: var(--black); }
.badge.prioridad-Alta { background: var(--red-bg); color: var(--red); }
.badge.prioridad-Media { background: var(--yellow-bg); color: var(--yellow); }
.badge.prioridad-Baja { background: var(--gray-bg); color: var(--gray); }

.progress { height: 6px; border-radius: 4px; background: var(--gray-bg); overflow: hidden; width: 100%; min-width: 60px; }
.progress > div { height: 100%; background: var(--accent); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-grid.single { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.span-2 { grid-column: span 2; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.field input, .field select, .field textarea {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 13.5px; font-family: inherit; color: var(--text); background: var(--surface);
}
.field textarea { resize: vertical; min-height: 60px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--primary-soft); }
.field-hint { font-size: 11px; color: var(--text-faint); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; z-index: 100; overflow-y: auto; }
.modal { background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 620px; box-shadow: var(--shadow-md); }
.modal.modal-lg { max-width: 860px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 15px; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 18px; line-height: 1; padding: 4px; }
.modal-body { padding: 20px; max-height: 72vh; overflow-y: auto; }

/* ---------- Timeline ---------- */
.timeline { display: flex; flex-wrap: wrap; align-items: stretch; gap: 0; }
.timeline-step { display: flex; align-items: center; }
.timeline-step .step-box {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; min-width: 140px;
  background: var(--surface); cursor: pointer; transition: box-shadow 0.12s;
}
.timeline-step .step-box:hover { box-shadow: var(--shadow-sm); }
.timeline-step .step-box.completada { border-color: var(--green); background: var(--green-bg); }
.timeline-step .step-box.en-proceso, .timeline-step .step-box.en-preparacion { border-color: var(--yellow); background: var(--yellow-bg); }
.timeline-step .step-box.bloqueada { border-color: var(--red); background: var(--red-bg); }
.timeline-step .step-name { font-size: 12.5px; font-weight: 700; margin-bottom: 3px; }
.timeline-step .step-meta { font-size: 11px; color: var(--text-muted); }
.timeline-arrow { color: var(--text-faint); padding: 0 8px; font-size: 16px; }
.timeline-add { border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 10px 16px; color: var(--text-faint); cursor: pointer; font-size: 12.5px; background: none; }
.timeline-add:hover { color: var(--accent); border-color: var(--accent); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab { padding: 9px 14px; font-size: 13px; font-weight: 600; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Hoy view ---------- */
.hoy-section { margin-bottom: 26px; }
.hoy-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); margin-bottom: 8px; }
.hoy-item-main { min-width: 0; }
.hoy-item-title { font-weight: 600; font-size: 13.5px; margin-bottom: 2px; }
.hoy-item-sub { font-size: 12px; color: var(--text-muted); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(160deg, #1f3a5f 0%, #16304d 100%); }
.login-card { background: var(--surface); border-radius: 12px; padding: 36px 32px; width: 100%; max-width: 380px; box-shadow: var(--shadow-md); }
.login-card h1 { font-size: 18px; margin-bottom: 4px; }
.login-card .sub { color: var(--text-muted); font-size: 13px; margin-bottom: 22px; }
.login-error { background: var(--red-bg); color: var(--red); padding: 8px 12px; border-radius: var(--radius-sm); font-size: 12.5px; margin-top: 12px; display: none; }

/* ---------- Misc ---------- */
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.mono { font-variant-numeric: tabular-nums; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.toast-wrap { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm); font-size: 13px; box-shadow: var(--shadow-md); }
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }
.spinner { width: 22px; height: 22px; border: 2.5px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 12.5px; padding: 0; }
.icon-btn { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 4px; border-radius: 4px; display: inline-flex; }
.icon-btn:hover { background: var(--surface-alt); color: var(--text); }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.banner-error { background: var(--red-bg); color: var(--red); padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; }
.test-tag { font-size: 10px; background: var(--yellow-bg); color: var(--yellow); padding: 1px 6px; border-radius: 4px; margin-left: 6px; font-weight: 700; vertical-align: middle; }
.nota-lectura { background: var(--blue-bg); color: var(--blue); padding: 8px 12px; border-radius: var(--radius-sm); font-size: 12.5px; margin-bottom: 14px; }
fieldset.form-fieldset { border: none; margin: 0; padding: 0; min-width: 0; }
.checklist { max-height: 220px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px 10px; }
.checklist label { display: flex; align-items: center; gap: 8px; padding: 5px 0; font-size: 13px; font-weight: 400; color: var(--text); cursor: pointer; }
.checklist input { width: auto; }
.checklist.deshabilitada { opacity: 0.45; pointer-events: none; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.2s; z-index: 50; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .field.span-2 { grid-column: span 1; }
  .topbar { padding: 0 14px; }
  .content { padding: 14px; }
  .menu-toggle { display: inline-flex !important; }
}
.menu-toggle { display: none; }
