:root {
  --bg: #f4f7fb;
  --bg-deep: #e8eef6;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --line: rgba(15, 23, 42, 0.08);
  --accent: #0f766e;
  --accent-2: #0d9488;
  --accent-soft: #ccfbf1;
  --danger: #be123c;
  --warning: #b45309;
  --ok: #047857;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
  --radius: 18px;
  --font: "Outfit", sans-serif;
  --serif: "Source Serif 4", Georgia, serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(165deg, #f8fafc 0%, var(--bg) 45%, var(--bg-deep) 100%);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 50% 20%, black, transparent 75%);
  pointer-events: none;
  z-index: 0;
}

.bg-glow {
  position: fixed;
  width: 42vw;
  height: 42vw;
  top: -12vw;
  right: -8vw;
  background: radial-gradient(circle, rgba(13, 148, 136, 0.18), transparent 70%);
  pointer-events: none;
  z-index: 0;
  animation: floatGlow 12s ease-in-out infinite alternate;
}

@keyframes floatGlow {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(-4vw, 3vw) scale(1.08); }
}

.container {
  width: min(1100px, calc(100% - 2rem));
  margin-inline: auto;
  position: relative;
  z-index: 1;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(16px);
  background: rgba(244, 247, 251, 0.75);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 72px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #0f172a, #134e4a);
  color: #ecfeff;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.25);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  font-size: 1.05rem;
}

.brand-text small {
  color: var(--muted);
  font-size: 0.8rem;
}

.nav {
  display: flex;
  gap: 0.35rem;
}

.nav a {
  text-decoration: none;
  color: var(--ink-soft);
  padding: 0.55rem 0.95rem;
  border-radius: 999px;
  font-weight: 500;
  font-size: 0.95rem;
  transition: background 0.25s var(--ease), color 0.25s var(--ease), transform 0.25s var(--ease);
}

.nav a:hover {
  background: rgba(15, 23, 42, 0.05);
  transform: translateY(-1px);
}

.nav a.active {
  background: var(--ink);
  color: #fff;
}

.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-solid);
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
}

.nav-toggle span {
  width: 18px;
  height: 2px;
  background: var(--ink);
  transition: transform 0.3s var(--ease), opacity 0.3s;
}

.nav-toggle[aria-expanded="true"] span:first-child {
  transform: translateY(4px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] span:last-child {
  transform: translateY(-4px) rotate(-45deg);
}

.main {
  padding: 2rem 0 4rem;
}

.hero {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1.75rem;
  animation: riseIn 0.7s var(--ease) both;
}

.hero h1 {
  font-family: var(--serif);
  font-size: clamp(1.9rem, 4vw, 2.7rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.hero p {
  color: var(--muted);
  max-width: 42rem;
  font-size: 1.05rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  padding: 1.35rem;
  animation: riseIn 0.75s var(--ease) both;
}

.panel + .panel { margin-top: 1.25rem; }

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  margin-bottom: 1.1rem;
}

.panel-head h2 {
  font-size: 1.15rem;
  font-weight: 600;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1.25rem;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.stat {
  background: linear-gradient(180deg, #fff, #f8fafc);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.95rem;
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
  animation: riseIn 0.8s var(--ease) both;
}

.stat:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.stat strong {
  font-size: 1.45rem;
  font-weight: 700;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.9rem;
}

.form-grid .full { grid-column: 1 / -1; }

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink-soft);
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 0.72rem 0.85rem;
  font: inherit;
  color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(13, 148, 136, 0.55);
  box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.12);
}

textarea { min-height: 96px; resize: vertical; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.35rem;
}

.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.72rem 1.1rem;
  border-radius: 12px;
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), background 0.25s;
}

.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(145deg, #0f172a, #134e4a);
  color: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.22);
}

.btn-accent {
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 10px 24px rgba(13, 148, 136, 0.28);
}

.btn-ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn-danger {
  background: #fff1f2;
  color: var(--danger);
  border: 1px solid rgba(190, 18, 60, 0.15);
}

.btn-sm {
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  border-radius: 10px;
}

.task-list {
  display: grid;
  gap: 0.75rem;
}

.task-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
  animation: riseIn 0.55s var(--ease) both;
}

.task-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.07);
}

.task-card h3 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.task-card p {
  color: var(--muted);
  font-size: 0.9rem;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.65rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-pendiente { background: #fff7ed; color: #c2410c; }
.badge-en_progreso { background: #eff6ff; color: #1d4ed8; }
.badge-completada { background: #ecfdf5; color: #047857; }
.badge-alta { background: #fff1f2; color: #be123c; }
.badge-media { background: #f8fafc; color: #475569; }
.badge-baja { background: #f1f5f9; color: #64748b; }

.task-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: stretch;
}

.empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted);
}

.empty strong {
  display: block;
  color: var(--ink);
  margin-bottom: 0.35rem;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 14px;
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  min-width: 680px;
}

th, td {
  padding: 0.85rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: #f8fafc;
}

tr {
  animation: riseIn 0.45s var(--ease) both;
}

tr:hover td { background: #f8fafc; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
}

.filters label { min-width: 150px; }

.report-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.report-card {
  padding: 1.25rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(165deg, #ffffff, #f8fafc);
  display: grid;
  gap: 0.85rem;
  transition: transform 0.3s var(--ease), box-shadow 0.3s var(--ease);
  animation: riseIn 0.7s var(--ease) both;
}

.report-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.report-card h3 {
  font-family: var(--serif);
  font-size: 1.25rem;
}

.report-card p {
  color: var(--muted);
  font-size: 0.92rem;
}

.toast {
  position: relative;
  margin-bottom: 1rem;
  padding: 0.9rem 2.5rem 0.9rem 1rem;
  border-radius: 14px;
  animation: slideDown 0.45s var(--ease);
  font-weight: 500;
}

.toast-success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid rgba(4, 120, 87, 0.15);
}

.toast-error {
  background: #fff1f2;
  color: #9f1239;
  border: 1px solid rgba(190, 18, 60, 0.15);
}

.toast-close {
  position: absolute;
  right: 0.7rem;
  top: 0.55rem;
  border: none;
  background: transparent;
  font-size: 1.25rem;
  cursor: pointer;
  color: inherit;
  opacity: 0.7;
}

.footer {
  border-top: 1px solid var(--line);
  padding: 1.5rem 0 2rem;
  position: relative;
  z-index: 1;
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.9rem;
}

.muted { color: var(--muted); }

.day-group {
  margin-bottom: 1.25rem;
}

.day-group > h3 {
  font-size: 0.95rem;
  margin-bottom: 0.65rem;
  color: var(--accent);
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 900px) {
  .grid-2, .report-cards { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .nav-toggle { display: flex; }

  .nav {
    position: absolute;
    top: 72px;
    left: 1rem;
    right: 1rem;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 0.55rem;
    box-shadow: var(--shadow);
    display: none;
  }

  .nav.open { display: flex; animation: slideDown 0.3s var(--ease); }

  .form-grid { grid-template-columns: 1fr; }

  .task-card {
    grid-template-columns: 1fr;
  }

  .task-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

/* Stagger children */
.task-list .task-card:nth-child(1) { animation-delay: 0.05s; }
.task-list .task-card:nth-child(2) { animation-delay: 0.1s; }
.task-list .task-card:nth-child(3) { animation-delay: 0.15s; }
.task-list .task-card:nth-child(4) { animation-delay: 0.2s; }
.task-list .task-card:nth-child(5) { animation-delay: 0.25s; }
.stats .stat:nth-child(1) { animation-delay: 0.05s; }
.stats .stat:nth-child(2) { animation-delay: 0.12s; }
.stats .stat:nth-child(3) { animation-delay: 0.18s; }
.report-card:nth-child(1) { animation-delay: 0.05s; }
.report-card:nth-child(2) { animation-delay: 0.12s; }
.report-card:nth-child(3) { animation-delay: 0.18s; }
