/* Tracker: CSS propio, sin dependencias. Pensado primero para celular (375px). */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1b1f27;
  --muted: #5d6675;
  --border: #d9dde4;
  --accent: #2455d6;
  --accent-text: #ffffff;
  --ok: #17753a;
  --ok-bg: #dff3e6;
  --warn: #a14a00;
  --warn-bg: #ffe9cf;
  --bad: #a4262c;
  --bad-bg: #fbdcdd;
  --info-bg: #e4ebfb;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --surface: #1b2029;
    --text: #e8ebf0;
    --muted: #9aa4b5;
    --border: #2f3744;
    --accent: #7ba2ff;
    --accent-text: #0c1220;
    --ok: #6fd69a;
    --ok-bg: #173424;
    --warn: #ffb36b;
    --warn-bg: #3a2810;
    --bad: #ff8e93;
    --bad-bg: #3d1a1c;
    --info-bg: #1d2742;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

h1 { font-size: 1.5rem; margin: 0 0 0.75rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.5rem; }
p { margin: 0 0 0.6rem; }

.wrap { max-width: 72rem; margin: 0 auto; padding: 1rem; }

/* Barra superior y navegacion */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner {
  max-width: 72rem;
  margin: 0 auto;
  padding: 0.5rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
}
.brand { font-weight: 700; }
.nav {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  flex: 1 1 100%;
  order: 3;
}
.nav a {
  padding: 0.55rem 0.8rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.nav a:hover { background: var(--info-bg); }
.nav a[aria-current="page"] { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.sec-link { margin-left: auto; display: inline-flex; align-items: center; }
.logout { margin-left: 0; }

.foot {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

/* Tarjetas y rejilla */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.grid .card { margin-bottom: 0; }
.banner {
  background: var(--info-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}
.muted { color: var(--muted); }
.label { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.1rem; }
.topic { font-weight: 600; }
.big { font-size: 2.2rem; font-weight: 700; line-height: 1.1; margin-bottom: 0.4rem; }
.big .of { font-size: 1rem; font-weight: 400; color: var(--muted); }
.warn { color: var(--warn); }

/* Mensajes */
.msg { border-radius: 8px; padding: 0.6rem 0.8rem; margin-bottom: 0.75rem; }
.msg-error { background: var(--bad-bg); color: var(--bad); }

/* Insignias de estado */
.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  background: var(--info-bg);
  color: var(--text);
  vertical-align: middle;
}
.badge-hecha { background: var(--ok-bg); color: var(--ok); }
.badge-en-curso { background: var(--info-bg); color: var(--accent); }
.badge-pendiente { background: var(--border); color: var(--muted); }
.badge-atrasada { background: var(--bad-bg); color: var(--bad); }
.badge-todo { background: var(--warn-bg); color: var(--warn); }
.badge-todo-verify { background: var(--info-bg); color: var(--accent); }

/* Barras de progreso nativas (sin estilos en linea) */
progress {
  width: 100%;
  height: 0.75rem;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  background: var(--border);
  accent-color: var(--accent);
  -webkit-appearance: none;
  appearance: none;
}
progress::-webkit-progress-bar { background: var(--border); }
progress::-webkit-progress-value { background: var(--accent); }
progress::-moz-progress-bar { background: var(--accent); }
.hours-line { display: flex; align-items: center; gap: 0.75rem; margin: 0.5rem 0; }
.hours-line progress { flex: 1; }
.hours-line span { white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Formularios */
.stack { display: grid; gap: 0.4rem; }
.stack label { font-size: 0.9rem; color: var(--muted); margin-top: 0.3rem; }
.row { display: flex; gap: 1rem; align-items: center; }
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  min-height: 44px;
  width: 100%;
}
textarea { resize: vertical; }
input[type="checkbox"] { width: 1.4rem; height: 1.4rem; min-height: 0; flex: none; }
.btn {
  font: inherit;
  font-weight: 600;
  background: var(--accent);
  color: var(--accent-text);
  border: 0;
  border-radius: 8px;
  padding: 0.6rem 1rem;
  min-height: 44px;
  cursor: pointer;
}
.btn-small { min-height: 36px; padding: 0.3rem 0.75rem; }
.btn-link {
  font: inherit;
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  min-height: 44px;
  padding: 0 0.5rem;
}
.check { display: flex; align-items: center; gap: 0.6rem; min-height: 44px; cursor: pointer; }
.check-row { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; margin-top: 0.5rem; }
.done-text { text-decoration: line-through; color: var(--muted); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
details > summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.inline-form { display: grid; gap: 0.4rem; }

.entries { list-style: none; margin: 0 0 0.75rem; padding: 0; font-variant-numeric: tabular-nums; }
.entries li { display: flex; justify-content: space-between; border-bottom: 1px solid var(--border); padding: 0.2rem 0; }
.todos, .milestones { list-style: none; margin: 0; padding: 0; }
.todos li { padding: 0.4rem 0; border-bottom: 1px solid var(--border); }
.todos li:last-child { border-bottom: 0; }

.login { max-width: 24rem; margin: 2rem auto; }

/* Roadmap */
.week-head { display: flex; flex-wrap: wrap; gap: 0.25rem 0.75rem; align-items: baseline; }
.week-head h2 { margin: 0; }
.week-current { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }

/* Tablas: en celular cada fila se vuelve una tarjeta */
.table-wrap { margin-bottom: 1rem; }
.stack-table { width: 100%; border-collapse: collapse; }
.stack-table thead { display: none; }
.stack-table tr {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
}
.stack-table td { display: block; padding: 0.25rem 0; }
.stack-table td::before {
  content: attr(data-label);
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.stack-table td[data-label=""]::before { display: none; }
.opp-descartada, .opp-rechazado { opacity: 0.6; }
.status { font-weight: 600; }
.notes { color: var(--muted); font-size: 0.9rem; }

@media (min-width: 48rem) {
  .nav { flex: 0 1 auto; order: 0; }
  .grid { grid-template-columns: repeat(2, 1fr); }
  .card-wide { grid-column: 1 / -1; }
  .weeks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
  .weeks .card { margin-bottom: 0; }

  .stack-table thead { display: table-header-group; }
  .stack-table tr { display: table-row; border: 0; padding: 0; margin: 0; background: none; }
  .stack-table th {
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    padding: 0.5rem;
    border-bottom: 2px solid var(--border);
  }
  .stack-table td { display: table-cell; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
  .stack-table td::before { display: none; }
  .stack-table select, .stack-table input { min-width: 9rem; }
  .table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
  .inline-form { grid-template-columns: 1fr 1fr auto; align-items: center; }
}

/* Seguridad y passkeys */
.msg-warn { background: var(--warn-bg); color: var(--warn); }
.msg-ok { background: var(--ok-bg); color: var(--ok); }
.login hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
.keys { list-style: none; margin: 0 0 0.75rem; padding: 0; }
.keys li { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); padding: 0.5rem 0; }
code { font-size: 0.9em; background: var(--info-bg); padding: 0.05rem 0.3rem; border-radius: 4px; }
[hidden] { display: none !important; }
