:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --bg-gradient: linear-gradient(180deg, #f6f8fc 0%, #eef2f7 100%);
  --card: #ffffff;
  --panel: rgba(255, 255, 255, 0.92);
  --muted-card: #f7f9fc;
  --chat-panel: linear-gradient(180deg, #0b3868 0%, #0a2748 100%);
  --chat-border: rgba(255, 255, 255, 0.18);
  --border: rgba(12, 62, 99, 0.14);
  --border-soft: rgba(12, 62, 99, 0.08);
  --main: #0a66c2;
  --main-dark: #004182;
  --main-glow: #1f8ceb;
  --text: #1f2933;
  --muted: #516173;
  --accent: #0b8a6f;
  --danger: #d93025;
  --shadow: rgba(15, 34, 64, 0.18);
  font-family: "Poppins", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background: var(--bg-gradient);
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(16px, 4vw, 32px);
  gap: 24px;
}

.layout {
  width: min(1280px, 100%);
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: clamp(16px, 3vw, 28px);
  align-items: start;
}

main {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

h1,
h2,
h3 {
  color: var(--main-dark);
  font-weight: 600;
  letter-spacing: 0.3px;
}

header {
  width: 100%;
  background: linear-gradient(100deg, #0b305a 0%, #0a66c2 85%);
  border-radius: 18px;
  padding: 20px 24px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  box-shadow: 0 24px 48px rgba(10, 38, 72, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

header h1 {
  font-size: clamp(1.5rem, 2.4vw, 2.1rem);
  color: #ffffff;
}

.heading {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.subtitle {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.95rem;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

button,
.logs {
  background: linear-gradient(120deg, var(--main) 0%, var(--main-dark) 100%);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 9px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 6px 16px rgba(10, 70, 130, 0.28);
}

button:hover,
.logs:hover {
  transform: translateY(-1px);
  background: linear-gradient(120deg, var(--main-glow) 0%, var(--main) 100%);
  box-shadow: 0 10px 22px rgba(10, 70, 130, 0.34);
}

button:focus-visible,
.logs:focus-visible,
.ghost:focus-visible {
  outline: 2px solid var(--main-glow);
  outline-offset: 2px;
}

button.pdf {
  background: linear-gradient(120deg, #ff7a59 0%, #f3438f 100%);
}

button.pdf:hover {
  box-shadow: 0 10px 20px rgba(242, 85, 134, 0.35);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.7;
  box-shadow: none;
}

.ghost {
  background: transparent;
  border: 1px solid rgba(10, 102, 194, 0.3);
  color: var(--main-dark);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 0.85rem;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.ghost:hover {
  background: rgba(10, 102, 194, 0.08);
  color: var(--main);
  border-color: rgba(10, 102, 194, 0.45);
}

#chatPanel .ghost {
  border-color: rgba(255, 255, 255, 0.45);
  color: #ffffff;
}

#chatPanel .ghost:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.7);
}

#chatPanel {
  width: 100%;
  background: var(--chat-panel);
  border-radius: 18px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 24px 54px rgba(8, 25, 48, 0.45);
  border: 1px solid var(--chat-border);
  position: sticky;
  top: clamp(12px, 3vw, 24px);
  color: #f7fafc;
}

#chatPanel h2 {
  font-size: 1.25rem;
  color: #ffffff;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.chat-box {
  max-height: 320px;
  overflow-y: auto;
  background: rgba(7, 25, 53, 0.35);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.4) transparent;
}

.chat-box::-webkit-scrollbar {
  width: 6px;
}

.chat-box::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.45);
  border-radius: 999px;
}

.msg {
  padding: 10px 14px;
  border-radius: 12px;
  max-width: 85%;
  line-height: 1.5;
  font-size: 0.92rem;
  word-break: break-word;
  animation: fadeIn 0.3s ease;
}

.msg.user {
  align-self: flex-end;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #e9f2ff;
}

.msg.bot {
  background: rgba(8, 20, 42, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #f8fbff;
}

#chatInput {
  display: flex;
  gap: 10px;
  align-items: center;
}

#chatInput input {
  flex: 1;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #0f172a;
  border-radius: 12px;
  padding: 10px 14px;
  font-family: inherit;
}

#chatInput input:focus {
  outline: none;
  border-color: var(--main-glow);
  box-shadow: 0 0 0 2px rgba(16, 105, 197, 0.25);
}

#chatInput button {
  box-shadow: 0 6px 16px rgba(10, 70, 130, 0.3);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

.stat-card {
  background: var(--card);
  border-radius: 16px;
  text-align: center;
  padding: 16px 18px;
  border: 1px solid var(--border);
  box-shadow: 0 12px 28px rgba(12, 62, 99, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 32px rgba(12, 62, 99, 0.12);
}

.stat-card h3 {
  color: var(--main-dark);
  font-size: 1.6rem;
}

.stat-card p {
  color: var(--muted);
  font-size: 0.85rem;
}

.project-meta,
.charts,
.view,
.resources {
  background: var(--panel);
  border-radius: 16px;
  border: 1px solid var(--border-soft);
  padding: 20px;
  box-shadow: 0 18px 34px rgba(15, 34, 64, 0.12);
}

.project-meta h2,
.view h2,
.resources h2 {
  margin-bottom: 14px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.meta-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meta-field label {
  font-size: 0.85rem;
  color: var(--muted);
}

.meta-field input {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 9px 12px;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.meta-field input:focus {
  outline: none;
  border-color: var(--main);
  box-shadow: 0 0 0 2px rgba(10, 102, 194, 0.2);
}

.view-tabs {
  display: inline-flex;
  gap: 8px;
  background: rgba(10, 102, 194, 0.12);
  border-radius: 999px;
  padding: 6px;
  border: 1px solid rgba(10, 102, 194, 0.18);
  align-self: flex-start;
}

.tab-btn {
  background: transparent;
  border: none;
  border-radius: 999px;
  padding: 8px 20px;
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.tab-btn:hover {
  color: var(--main-dark);
}

.tab-btn.active {
  background: #ffffff;
  color: var(--main-dark);
  box-shadow: 0 10px 24px rgba(15, 34, 64, 0.12);
}

.view {
  display: none;
  animation: fadeIn 0.25s ease;
}

.view.active {
  display: block;
}

.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.chart-card {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  border: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 12px 26px rgba(12, 62, 99, 0.08);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chart-card canvas {
  width: 100% !important;
  height: auto !important;
}

.task-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

#taskList {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty-msg {
  text-align: center;
  color: var(--muted);
  padding: 24px 12px;
  border: 1px dashed rgba(10, 102, 194, 0.24);
  border-radius: 16px;
  background: rgba(10, 102, 194, 0.05);
}

.task-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  font-size: 0.92rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  box-shadow: 0 16px 28px rgba(12, 62, 99, 0.08);
}

.task-card:hover {
  border-color: rgba(10, 102, 194, 0.32);
  box-shadow: 0 20px 34px rgba(12, 62, 99, 0.12);
  transform: translateY(-2px);
}

.task-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
}

.task-card input,
.task-card select,
.task-card textarea {
  width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.task-card input:focus,
.task-card select:focus,
.task-card textarea:focus {
  outline: none;
  border-color: var(--main);
  box-shadow: 0 0 0 2px rgba(10, 102, 194, 0.2);
}

.task-card textarea {
  resize: vertical;
  min-height: 60px;
  max-height: 200px;
}

.task-header {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  justify-content: space-between;
  align-items: flex-end;
}

.task-context,
.task-status {
  display: grid;
  gap: 12px;
}

.task-context {
  flex: 1;
  min-width: 240px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.task-status {
  min-width: 220px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.task-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.task-grid label {
  font-size: 0.78rem;
  color: var(--muted);
}

.task-actions-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.task-actions-row .notify-btn {
  flex: 1;
  min-width: 160px;
}

.task-actions-row .delete-btn {
  flex: none;
}

.activity-list {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}

.activity-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 16px 30px rgba(12, 62, 99, 0.1);
}

.activity-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

.activity-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.activity-title h3 {
  font-size: 1rem;
  color: var(--main-dark);
}

.activity-progress {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.activity-objective {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.55;
}

.activity-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.78rem;
  color: var(--muted);
}

.activity-meta span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.activity-tasks {
  list-style: none;
  padding-left: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text);
}

.activity-tasks li small {
  color: var(--muted);
}

.activity-tasks li.more {
  color: var(--muted);
  font-style: italic;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  background: rgba(10, 102, 194, 0.12);
  color: var(--main-dark);
  text-transform: capitalize;
  white-space: nowrap;
}

.badge + .badge {
  margin-left: 6px;
}

.badge.etapa-idea-inicial {
  background: rgba(14, 118, 214, 0.12);
}

.badge.etapa-planificación {
  background: rgba(10, 102, 194, 0.18);
}

.badge.etapa-ejecución {
  background: rgba(11, 138, 111, 0.18);
}

.badge.etapa-control {
  background: rgba(242, 159, 33, 0.18);
}

.badge.etapa-cierre {
  background: rgba(140, 118, 255, 0.18);
}

.delete-btn {
  background: rgba(217, 48, 37, 0.08);
  border: 1px solid rgba(217, 48, 37, 0.24);
  color: #b91c1c;
  border-radius: 12px;
  padding: 9px 16px;
  font-size: 0.85rem;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.delete-btn:hover {
  background: rgba(217, 48, 37, 0.16);
  border-color: rgba(217, 48, 37, 0.4);
  color: #7f1d1d;
}

.notify-btn {
  background: linear-gradient(120deg, var(--accent) 0%, #0a6f59 100%);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 9px 16px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 6px 16px rgba(11, 138, 111, 0.25);
}

.notify-btn:hover {
  box-shadow: 0 10px 22px rgba(11, 138, 111, 0.3);
  transform: translateY(-1px);
}

.kanban {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.kanban-col {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 16px 30px rgba(12, 62, 99, 0.08);
}

.kanban-col h3 {
  color: var(--main-dark);
  font-size: 1rem;
}

.kanban-list {
  flex: 1;
  min-height: 220px;
  border: 2px dashed rgba(10, 102, 194, 0.18);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.2s ease, background 0.2s ease;
  background: rgba(10, 102, 194, 0.04);
}

.kanban-list.drag-over {
  border-color: var(--main-glow);
  background: rgba(31, 140, 235, 0.08);
}

.kb-card {
  background: #fff;
  border: 1px solid rgba(10, 102, 194, 0.25);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 0.9rem;
  cursor: grab;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 10px 20px rgba(12, 62, 99, 0.08);
}

.kb-card:hover {
  transform: translateY(-2px);
  border-color: rgba(10, 102, 194, 0.5);
  box-shadow: 0 14px 24px rgba(12, 62, 99, 0.12);
}

.kb-card.dragging {
  opacity: 0.6;
}

.kb-card b {
  font-weight: 600;
  color: var(--main-dark);
}

.kb-card > span {
  color: var(--muted);
  font-size: 0.78rem;
}

.kb-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--muted);
}

.kb-activity {
  font-weight: 500;
  color: var(--main-dark);
}

.kb-card.prioridad-iu {
  border-left: 4px solid #f87171;
}

.kb-card.prioridad-inu {
  border-left: 4px solid #60a5fa;
}

.kb-card.prioridad-niu {
  border-left: 4px solid #fbbf24;
}

.kb-card.prioridad-ninu {
  border-left: 4px solid #94a3af;
}

.gantt-wrap {
  overflow-x: auto;
  background: var(--card);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 16px;
  box-shadow: 0 18px 34px rgba(12, 62, 99, 0.09);
}

.gantt-wrap .bar.prior-iu {
  fill: #f87171;
}

.gantt-wrap .bar.prior-inu {
  fill: #60a5fa;
}

.gantt-wrap .bar.prior-niu {
  fill: #fbbf24;
}

.gantt-wrap .bar.prior-ninu {
  fill: #94a3af;
}

.resources {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.resources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.resource-card {
  background: var(--card);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 120px;
  box-shadow: 0 16px 28px rgba(12, 62, 99, 0.08);
}

.resource-card h3 {
  font-size: 0.95rem;
  color: var(--main-dark);
}

.resource-card p {
  color: var(--muted);
  font-size: 0.88rem;
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 34, 64, 0.45);
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal.open {
  display: flex;
}

.modal-content {
  background: var(--card);
  border-radius: 18px;
  padding: 20px;
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 28px 60px rgba(15, 34, 64, 0.25);
}

.modal-content input,
.modal-content select {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 9px 12px;
  width: 100%;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.modal-content input:focus,
.modal-content select:focus {
  outline: none;
  border-color: var(--main);
  box-shadow: 0 0 0 2px rgba(10, 102, 194, 0.18);
}

.modal-content label {
  font-size: 0.82rem;
  color: var(--muted);
}

.modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

footer {
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
  padding: 10px 0 20px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 320px 1fr;
  }
}

@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 1fr;
  }

  #chatPanel {
    position: relative;
    top: 0;
  }
}

@media (max-width: 900px) {
  .task-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .task-context,
  .task-status {
    grid-template-columns: minmax(0, 1fr);
  }

  .task-actions-row {
    justify-content: flex-start;
  }

  .kanban {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  body {
    padding: 14px;
    font-size: 0.95rem;
  }

  header {
    flex-direction: column;
    align-items: flex-start;
  }

  .chat-box {
    max-height: 260px;
  }

  button,
  .logs {
    padding: 7px 14px;
    font-size: 0.85rem;
  }

  .view-tabs {
    align-self: stretch;
    justify-content: center;
  }

  .charts {
    grid-template-columns: 1fr;
  }

  .task-context,
  .task-status {
    grid-template-columns: 1fr;
  }

  .activity-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

@media (max-width: 520px) {
  #chatInput {
    flex-direction: column;
  }

  #chatInput button {
    width: 100%;
  }

  .actions {
    width: 100%;
    justify-content: center;
  }
}
#ganttChart {
  min-height: 400px;
  overflow-x: auto;
  background: var(--card);
  border-radius: 10px;
  border: 1px solid rgba(99, 102, 241, 0.15);
  padding: 10px;
}

.gantt-popup {
  background: rgba(15, 23, 42, 0.9);
  color: #e2e8f0;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.85rem;
  line-height: 1.3em;
}
