:root {
  --bg: #0a0b0e;
  --surface: #131519;
  --surface-2: #1a1d23;
  --surface-hover: #20232a;
  --border: #23262d;
  --border-strong: #2f333c;
  --text: #f0f1f3;
  --text-secondary: #979eab;
  --text-tertiary: #5d6371;
  --accent: #5b6df8;
  --accent-hover: #4c5cf0;
  --accent-soft: rgba(91, 109, 248, 0.14);
  --amber: #d99a3d;
  --amber-soft: rgba(217, 154, 61, 0.14);
  --emerald: #2fbf82;
  --emerald-soft: rgba(47, 191, 130, 0.14);
  --red: #e55a5a;
  --red-soft: rgba(229, 90, 90, 0.14);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 48px;
  -webkit-font-smoothing: antialiased;
}

.icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.icon svg { width: 100%; height: 100%; display: block; }
.icon-lg { width: 26px; height: 26px; }

/* ---------- header ---------- */

.top {
  padding: 20px 16px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, var(--bg) 70%, transparent);
  z-index: 10;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand .icon-lg { color: var(--accent); }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }

.brand-eyebrow {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.top h1 {
  margin: 0;
  font-family: "Inter Tight", "Inter", sans-serif;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.tiempo {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 999px;
}
.tiempo .icon { color: var(--text-tertiary); }

/* ---------- layout ---------- */

main {
  max-width: 480px;
  margin: 0 auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.card h2 {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card h2 .icon { color: var(--text-tertiary); width: 15px; height: 15px; }

/* ---------- marcador rows ---------- */

.marcador-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.marcador-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.marcador-row:hover { background: var(--surface-hover); border-color: var(--border); }
.marcador-row:active { background: var(--surface-2); }

.marcador-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.marcador-row-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
}
.marcador-row-label .icon { color: var(--text-secondary); }

.marcador-row-nums {
  color: var(--text-secondary);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.marcador-row-nums .exceso { color: var(--emerald); font-weight: 600; }

.progress {
  background: var(--surface-2);
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--text-tertiary);
  border-radius: 999px;
  transition: width 0.3s ease;
  width: 0%;
}
.progress-fill.estado-progreso { background: var(--amber); }
.progress-fill.estado-completado { background: var(--emerald); }

/* ---------- status badge ---------- */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.status-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

.status-pendiente { background: var(--surface-2); color: var(--text-tertiary); }
.status-pendiente .status-dot { background: var(--text-tertiary); }

.status-progreso { background: var(--amber-soft); color: var(--amber); }
.status-progreso .status-dot { background: var(--amber); }

.status-completado { background: var(--emerald-soft); color: var(--emerald); }
.status-completado .status-dot { background: var(--emerald); }

/* ---------- subblocks (50 toques / palas summary) ---------- */

.subblock {
  margin-top: 14px;
  padding: 12px 8px 4px;
  border-top: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.subblock:hover { background: var(--surface-hover); }

.subblock-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.subblock-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
}
.subblock-title .icon { color: var(--text-secondary); }

.subblock-footer {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.parejas-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12.5px;
  color: var(--text-secondary);
}
.pareja-item { display: flex; justify-content: space-between; }
.pareja-item span:last-child { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 500; }

/* ---------- forms ---------- */

.field { margin-bottom: 14px; }
.field:last-of-type { margin-bottom: 0; }

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 8px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  min-height: 40px;
  font-family: inherit;
}
.chip .icon { color: var(--text-tertiary); }

.chip.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--text);
}
.chip.selected .icon { color: var(--accent); }

input[type="number"], select {
  width: 100%;
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
}
input[type="number"]:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}

.pareja-selects {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pareja-selects select { flex: 1; }
.pareja-sep { color: var(--text-tertiary); font-weight: 600; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  width: 100%;
  font-family: inherit;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn .icon { width: 15px; height: 15px; }

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-hover); }

.btn-warn { background: var(--red-soft); color: var(--red); border-color: transparent; }
.btn-success { background: var(--emerald-soft); color: var(--emerald); border-color: transparent; }

.btn-row { display: flex; gap: 8px; }
.btn-row .btn { width: auto; flex: 1; padding-left: 8px; padding-right: 8px; font-size: 12.5px; }

.msg {
  margin-top: 10px;
  font-size: 13px;
  min-height: 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.msg.ok { color: var(--emerald); }
.msg.err { color: var(--red); }

/* ---------- collapsible ---------- */

.collapsible .collapse-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: none;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}
.collapse-toggle-label { display: flex; align-items: center; gap: 8px; }
.collapse-toggle-label .icon { color: var(--text-tertiary); }
.icon-chevron { color: var(--text-tertiary); transition: transform 0.15s ease; }
.collapse-toggle[aria-expanded="true"] .icon-chevron { transform: rotate(180deg); }

.collapse-body { margin-top: 14px; }

/* ---------- objetivos panel ---------- */

.objetivos-list {
  display: flex;
  flex-direction: column;
}

.objetivo-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.objetivo-row:last-child { border-bottom: none; padding-bottom: 0; }
.objetivo-row:first-child { padding-top: 0; }

.objetivo-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.objetivo-row-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
}
.objetivo-row-label .icon { color: var(--text-secondary); }

.objetivo-row-current {
  font-size: 12px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.objetivo-row-edit {
  display: flex;
  gap: 8px;
}
.objetivo-row-edit input { flex: 1; }
.btn-save-objetivo {
  width: auto;
  min-height: 40px;
  padding: 0 14px;
  flex-shrink: 0;
}

/* ---------- zona de peligro ---------- */

.danger-text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0 0 14px;
}

/* ---------- modal (historial) ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 8, 0.72);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 0;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 78vh;
  display: flex;
  flex-direction: column;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}

@media (min-width: 540px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: 16px; border-bottom: 1px solid var(--border-strong); max-height: 72vh; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.modal-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
  font-weight: 700;
}
.modal-title .icon { color: var(--accent); width: 18px; height: 18px; }

.modal-close {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.modal-close:hover { background: var(--surface-hover); color: var(--text); }
.modal-close .icon { width: 15px; height: 15px; }

.modal-summary {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}
.modal-summary strong { color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }

.modal-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.modal-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.modal-row:last-child { border-bottom: none; }

.modal-row-who { display: flex; flex-direction: column; gap: 2px; }
.modal-row-name { font-weight: 600; }
.modal-row-time { font-size: 11.5px; color: var(--text-tertiary); }
.modal-row-value { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }

.modal-empty {
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
  padding: 32px 12px;
}

.modal-loading {
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
  padding: 32px 12px;
}
