/* miguelbrito CRM panel. Calm, dense, readable: warm neutrals, one accent,
   system font, no motion beyond hover and focus. */

:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f0efec;
  --text: #1c1c1a;
  --muted: #5d5d58;
  --border: #e3e1dc;
  --border-strong: #c9c6bf;
  --accent: #2a4bc4;
  --accent-hover: #213da6;
  --accent-ink: #1e368f;
  --accent-tint: #ecf0fc;
  --danger: #a3302a;
  --danger-tint: #fbefee;
  --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
}

h1, h2, p, dl, dd, ol { margin: 0; }

a { color: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: 12px; top: -48px; z-index: 10;
  background: var(--surface); padding: 8px 12px; border-radius: var(--radius);
  border: 1px solid var(--border-strong);
}
.skip:focus { top: 12px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- Shell ---------- */

.shell { min-height: 100vh; }

.rail {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  padding: 10px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14px; letter-spacing: -0.01em; }
.brand__mark {
  width: 22px; height: 22px; border-radius: 6px; background: var(--text);
  box-shadow: inset 0 0 0 7px var(--text), inset 0 0 0 11px var(--accent);
}
.brand__sub { color: var(--muted); font-weight: 500; }

.nav { display: flex; gap: 4px; order: 3; width: 100%; }
.nav__link {
  padding: 6px 10px; border-radius: var(--radius);
  text-decoration: none; font-size: 14px; font-weight: 500; color: var(--muted);
}
.nav__link:hover { background: var(--surface); color: var(--text); }
.nav__link[aria-current="page"] { background: var(--text); color: #fff; }

.rail__logout { margin-left: auto; }

.link-btn {
  font: inherit; font-size: 13px; color: var(--muted); background: none; border: 0;
  padding: 4px 2px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.link-btn:hover { color: var(--text); }

.main { padding: 20px 16px 48px; max-width: 1180px; margin: 0 auto; }

@media (min-width: 960px) {
  .shell {
    display: grid; grid-template-columns: 220px minmax(0, 1fr);
    background: linear-gradient(to right, var(--surface-2) 220px, var(--border) 220px 221px, transparent 221px);
  }
  .rail {
    position: sticky; top: 0; height: 100vh;
    flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 0;
    padding: 24px 14px; border-bottom: 0; border-right: 1px solid var(--border);
  }
  .brand { padding: 0 8px 28px; }
  .nav { flex-direction: column; order: 0; width: auto; }
  .nav__link { padding: 8px 10px; }
  .rail__logout { margin: auto 0 0; padding: 12px 8px 0; border-top: 1px solid var(--border); }
  .main { padding: 36px 40px 64px; width: 100%; }
}

/* ---------- Page head, notices ---------- */

.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px;
  padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--border);
}
.page-title { font-size: 22px; line-height: 1.25; font-weight: 650; letter-spacing: -0.015em; overflow-wrap: anywhere; }
.page-head .muted { margin-top: 2px; font-size: 14px; }

.back { margin-bottom: 12px; font-size: 14px; }

.notice, .alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; }
.notice { background: var(--accent-tint); color: var(--accent-ink); }
.alert { background: var(--danger-tint); color: var(--danger); margin: 0; }

/* ---------- Controls ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 7px 14px;
  font: inherit; font-size: 14px; font-weight: 500; line-height: 1.2;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:hover { background: #8a2722; }
.btn--block { display: flex; width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.link { color: var(--accent-ink); text-underline-offset: 3px; }
.link:hover { color: var(--accent); }
.link--danger { color: var(--danger); }
.link--danger:hover { color: #8a2722; }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field--grow { flex: 1 1 260px; }
.field__label { font-size: 13px; font-weight: 500; color: var(--muted); }

.input {
  width: 100%; min-height: 38px; padding: 7px 10px;
  font: inherit; font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
}
.input:focus { border-color: var(--accent); outline: 2px solid var(--accent-tint); outline-offset: 0; }
.input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
select.input { padding-right: 28px; }
.textarea { resize: vertical; min-height: 96px; line-height: 1.45; }

.stack { display: flex; flex-direction: column; gap: 12px; }

/* ---------- Tabs and toolbar ---------- */

.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }
.tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px; border: 1px solid transparent;
  font-size: 13px; font-weight: 500; color: var(--muted); text-decoration: none;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab[aria-current="true"] { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.tab__n { color: var(--muted); font-weight: 400; }

.toolbar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px;
  padding: 12px 0 16px; margin-bottom: 4px;
}
.toolbar__actions { display: flex; align-items: center; gap: 12px; min-height: 38px; }

/* ---------- Table ---------- */

.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; vertical-align: middle; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.table thead th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
.table thead th:first-child { border-top-left-radius: var(--radius); }
.table thead th:last-child { border-top-right-radius: var(--radius); }
.table tbody tr:last-child > * { border-bottom: 0; }
.table tbody tr:hover { background: #fafaf8; }
.table tbody th { font-weight: 600; }
.row-link { color: var(--text); text-decoration: none; }
.row-link:hover { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; }
.cell-task { color: var(--muted); max-width: 360px; }
/* Answers of «¿Qué os come el tiempo?»: small neutral chips. */
.chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.chips--list { list-style: none; padding: 0; margin: 0; }
.chip {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--text); font-size: 12px; line-height: 1.6; white-space: nowrap;
}
.chips--list .chip { font-size: 13px; white-space: normal; }
.chip--more { color: var(--muted); }
.reply-alt { margin-top: 8px; font-size: 13px; text-align: center; }
.nowrap { white-space: nowrap; }
.empty { padding: 28px 8px; text-align: center; color: var(--muted); }

@media (max-width: 759px) {
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table, .table tbody, .table tr, .table th, .table td { display: block; }
  .table tbody tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .table tbody tr:last-child { border-bottom: 0; }
  .table tbody th, .table tbody td { display: flex; gap: 12px; padding: 3px 0; border: 0; overflow-wrap: anywhere; }
  .table tbody [data-label]::before {
    content: attr(data-label); flex: 0 0 76px; font-size: 12px; font-weight: 500; color: var(--muted); padding-top: 2px;
  }
  .table tbody th { font-size: 15px; }
  .cell-task { max-width: none; }
  .empty-row td { display: block; }
  .table tbody td:empty { display: none; }
}

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; font-size: 14px; }

/* ---------- Badges ---------- */

.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.5; white-space: nowrap;
  border: 1px solid transparent;
}
.fit--alto { background: var(--accent); color: #fff; }
.fit--medio { background: var(--accent-tint); color: var(--accent-ink); }
.fit--bajo { background: var(--surface-2); color: var(--muted); }
.status { background: var(--surface); border-color: var(--border-strong); color: var(--text); font-weight: 500; }
.status--nuevo { border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.status--ganado { background: var(--text); border-color: var(--text); color: #fff; }
.status--perdido { background: var(--surface-2); border-color: var(--surface-2); color: var(--muted); }

/* ---------- Cards and detail ---------- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card__title { font-size: 14px; font-weight: 600; margin-bottom: 14px; }
.card > .btn--block { margin-top: 12px; }

.detail { display: grid; gap: 16px; }
.detail__side { display: grid; gap: 16px; align-content: start; }

@media (min-width: 1040px) {
  .detail { grid-template-columns: minmax(0, 1fr) 320px; grid-template-areas: "answers side" "history side"; align-items: start; }
  .detail__answers { grid-area: answers; }
  .detail__side { grid-area: side; position: sticky; top: 24px; }
  .detail__history { grid-area: history; }
}

.answers { display: grid; }
.answers__row { display: grid; gap: 2px; padding: 10px 0; border-top: 1px solid var(--border); }
.answers__row:first-child { border-top: 0; padding-top: 0; }
.answers dt { font-size: 13px; color: var(--muted); }
.answers dd { overflow-wrap: anywhere; }
@media (min-width: 640px) {
  .answers__row { grid-template-columns: 190px minmax(0, 1fr); gap: 16px; }
}

.note-text { white-space: pre-line; overflow-wrap: anywhere; }

.timeline { list-style: none; padding: 0; display: grid; gap: 0; }
.timeline__item { position: relative; padding: 0 0 14px 18px; border-left: 1px solid var(--border); margin-left: 4px; }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__item::before {
  content: ""; position: absolute; left: -4px; top: 6px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong);
}
.timeline__item--note::before { background: var(--accent); }
.timeline__meta { font-size: 12px; color: var(--muted); }

.danger-zone { margin-top: 24px; font-size: 14px; }

.confirm { max-width: 560px; display: grid; gap: 14px; }
.confirm__actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- Stats (Prompt del juego) ---------- */

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
@media (min-width: 760px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stat__label { font-size: 12px; color: var(--muted); }
.stat__value { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; }

.empty-state { color: var(--muted); max-width: 640px; display: grid; gap: 8px; }
.empty-state strong { color: var(--text); }
.empty-state code, .card code { font-size: 13px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; color: var(--text); }
.table-count { margin: 0 0 8px; }

/* ---------- Login ---------- */

.login-page { display: grid; min-height: 100vh; place-items: center; padding: 24px 16px; }
.login { width: 100%; max-width: 360px; display: grid; gap: 20px; }
.login .brand { justify-content: center; }
.login__form { display: grid; gap: 16px; padding: 24px; }
.login__title { font-size: 18px; font-weight: 600; }
