* {
  box-sizing: border-box;
}

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --success: #15803d;
  --success-soft: #dcfce7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --personal: #facc15;
  --education: #22c55e;
  --project: #38bdf8;
  --radius: 18px;
  --shadow: 0 14px 35px rgba(17, 24, 39, 0.08);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1280px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 60px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.subtitle,
.section-heading p {
  color: var(--muted);
}

.week-card {
  min-width: 225px;
  padding: 16px 18px;
  border: 1px solid #bfdbfe;
  border-radius: 16px;
  background: #eff6ff;
}

.week-card.saturday {
  border-color: #fca5a5;
  background: var(--danger-soft);
}

.week-card span,
.week-card strong,
.week-card small {
  display: block;
}

.week-card span {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.week-card.saturday span {
  color: var(--danger);
}

.week-card strong {
  margin: 4px 0;
  font-size: 1.35rem;
}

.week-card small {
  color: var(--muted);
  line-height: 1.45;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 7px;
  margin-bottom: 20px;
  overflow-x: auto;
  background: #e8ebef;
  border-radius: 14px;
}

.tab {
  flex: 1;
  min-width: 110px;
  padding: 12px 18px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.tab.active {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 4px 16px rgba(17, 24, 39, 0.08);
}

.panel {
  display: none;
  padding: clamp(18px, 4vw, 34px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel.active {
  display: block;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 24px;
}

.section-heading h2 {
  margin-bottom: 6px;
  font-size: clamp(1.55rem, 3vw, 2.25rem);
  letter-spacing: -0.035em;
}

.section-heading p {
  max-width: 690px;
  margin-bottom: 0;
}

.section-actions {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.metric-card {
  min-width: 170px;
  padding: 15px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.metric-card span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.metric-card strong {
  font-size: 1.7rem;
}

.button {
  border: 0;
  border-radius: 11px;
  padding: 11px 15px;
  font-weight: 800;
}

.button-primary {
  color: #ffffff;
  background: var(--accent);
}

.button-primary:hover {
  background: var(--accent-dark);
}

.button-secondary {
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
}

.button-outline {
  width: 100%;
  color: var(--accent);
  background: transparent;
  border: 1px dashed #93c5fd;
}

.routine-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.routine-table {
  width: 100%;
  min-width: 930px;
  border-collapse: collapse;
}

.routine-table th,
.routine-table td {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.routine-table th:first-child,
.routine-table td:first-child {
  width: 48%;
  text-align: left;
}

.routine-table th {
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.routine-table tr:last-child td {
  border-bottom: 0;
}

.block-title {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 7px;
}

.block-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 30px;
  padding: 0 9px;
  border-radius: 8px;
  color: #111827;
  font-size: 0.78rem;
  font-weight: 900;
}

.block-badge.personal {
  background: var(--personal);
}

.block-badge.education {
  color: #ffffff;
  background: var(--education);
}

.block-badge.project {
  background: var(--project);
}

.block-time {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.task-list {
  margin: 0;
  padding-left: 18px;
  color: #374151;
  font-size: 0.9rem;
  line-height: 1.55;
}

.routine-checkbox {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.check-ui {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 2px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  transition: 0.16s ease;
}

.routine-checkbox:checked + .check-ui {
  border-color: #86efac;
  background: var(--success-soft);
}

.routine-checkbox:checked + .check-ui::after {
  content: "✓";
  color: var(--success);
  font-size: 1rem;
  font-weight: 1000;
}

.check-label {
  display: inline-flex;
  cursor: pointer;
}

.routine-mobile {
  display: none;
}

.mobile-block-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface-soft);
}

.mobile-block-card + .mobile-block-card {
  margin-top: 12px;
}

.mobile-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(38px, 1fr));
  gap: 7px;
  margin-top: 15px;
}

.mobile-day {
  display: grid;
  gap: 7px;
  justify-items: center;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.focus-grid {
  display: grid;
  gap: 12px;
}

.focus-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(95px, 130px) auto minmax(80px, 110px);
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.focus-date strong,
.focus-date span {
  display: block;
}

.focus-date span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.84rem;
}

.focus-input,
.objective-id,
.objective-comment {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  padding: 11px 12px;
  background: #ffffff;
  outline: none;
}

.focus-result {
  padding: 11px;
  border-radius: 10px;
  background: #ffffff;
  text-align: center;
  font-weight: 900;
}

.objectives-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.objective-card {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-soft);
}

.objective-card-header {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 15px;
}

.objective-card-header h3 {
  margin: 0;
  font-size: 1.15rem;
}

.objective-number {
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 900;
}

.objective-list {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.objective-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) 34px;
  gap: 8px;
}

.objective-id {
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.remove-objective {
  border: 0;
  border-radius: 9px;
  color: var(--danger);
  background: var(--danger-soft);
  font-size: 1.15rem;
  font-weight: 900;
}

.save-message {
  min-height: 24px;
  margin: 18px 0 0;
  color: var(--success);
  font-weight: 800;
}

@media (max-width: 900px) {
  .objectives-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 18px, 1280px);
    padding-top: 18px;
  }

  .app-header,
  .section-heading {
    flex-direction: column;
  }

  .week-card,
  .section-actions,
  .section-actions .button,
  .metric-card {
    width: 100%;
  }

  .section-actions {
    flex-direction: column;
  }

  .routine-desktop {
    display: none;
  }

  .routine-mobile {
    display: block;
  }

  .focus-row {
    grid-template-columns: 1fr 90px;
  }

  .focus-row .focus-date {
    grid-column: 1 / -1;
  }

  .focus-row .button {
    width: 100%;
  }
}

@media (max-width: 460px) {
  .panel {
    padding: 16px;
  }

  .objective-row {
    grid-template-columns: 78px minmax(0, 1fr) 34px;
  }

  .mobile-days {
    gap: 4px;
  }

  .check-ui {
    width: 24px;
    height: 24px;
  }
}


.header-tools {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.button-install {
  align-self: stretch;
  color: #ffffff;
  background: #7c3aed;
}

.button-install:hover {
  background: #6d28d9;
}

.focus-progress-card {
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-soft);
}

.focus-goal-row {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 14px;
}

.focus-goal-label,
.goal-editor span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.focus-goal-row strong {
  font-size: 1.2rem;
}

.goal-editor {
  width: 145px;
}

.goal-editor input {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #ffffff;
}

.progress-track {
  height: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e7eb;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: #22c55e;
  transition: width 0.25s ease;
}

.progress-caption {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.progress-caption strong {
  color: var(--success);
}

.objective-card:nth-child(1) .objective-id {
  border-color: #eab308;
  background: #fef9c3;
  color: #854d0e;
}

.objective-card:nth-child(2) .objective-id {
  border-color: #22c55e;
  background: #dcfce7;
  color: #166534;
}

.objective-card:nth-child(3) .objective-id {
  border-color: #38bdf8;
  background: #e0f2fe;
  color: #075985;
}

.objective-comment {
  min-height: 48px;
  resize: vertical;
  overflow: hidden;
  line-height: 1.4;
  white-space: pre-wrap;
}

@media (max-width: 720px) {
  .header-tools {
    width: 100%;
    flex-direction: column;
  }

  .button-install {
    width: 100%;
  }

  .focus-goal-row {
    align-items: stretch;
    flex-direction: column;
  }

  .goal-editor {
    width: 100%;
  }

  .progress-caption {
    align-items: flex-start;
    flex-direction: column;
    gap: 3px;
  }
}


/* OBJETIVOS V5: campos completos, diferenciados y sin corrección visual */
.objective-row {
  grid-template-columns: minmax(130px, 0.72fr) minmax(220px, 1.6fr) 38px;
  align-items: start;
}

.objective-id,
.objective-comment {
  font-family: inherit;
  overflow: hidden;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.objective-id {
  min-height: 48px;
  resize: none;
  line-height: 1.35;
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: none;
}

.objective-comment {
  min-height: 58px;
  resize: none;
  border-color: #111827;
  background: #111827;
  color: #f9fafb;
  caret-color: #ffffff;
  line-height: 1.5;
}

.objective-comment::placeholder {
  color: #9ca3af;
}

.objective-comment:focus {
  border-color: #374151;
  box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.18);
}

.objective-id:focus {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Conserva el color por categoría en la etiqueta ID */
.objective-card:nth-child(1) .objective-id {
  border-color: #eab308;
  background: #fef9c3;
  color: #854d0e;
}

.objective-card:nth-child(2) .objective-id {
  border-color: #22c55e;
  background: #dcfce7;
  color: #166534;
}

.objective-card:nth-child(3) .objective-id {
  border-color: #38bdf8;
  background: #e0f2fe;
  color: #075985;
}

@media (max-width: 620px) {
  .objective-row {
    grid-template-columns: 1fr 38px;
  }

  .objective-id,
  .objective-comment {
    grid-column: 1;
  }

  .remove-objective {
    grid-column: 2;
    grid-row: 1;
    min-height: 48px;
  }

  .objective-comment {
    grid-row: 2;
  }
}
