:root {
  --ink: #16181D;
  --ink-2: #3A3E47;
  --muted: #5A5F6B;
  --navy: #1E2A4A;
  --blue: #1E4FA3;
  --blue-dark: #163B7A;
  --accent: #E8A33D;
  --line: #ECECE8;
  --line-2: #DCDCD6;
  --soft: #F7F7F4;
  --sel: #F2F5FB;
  --warn: #8A3B00;
  --ok: #2D5A2D;
  --f-sans: 'IBM Plex Sans', system-ui, sans-serif;
  --f-head: 'Outfit', 'IBM Plex Sans', sans-serif;
  --f-script: 'Allura', cursive;
  --f-serif: 'Cormorant Garamond', Georgia, serif;
  --f-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: #FFFFFF; color: var(--ink); font-family: var(--f-sans); font-size: 15px; line-height: 1.5; }
a { color: var(--blue); }
a:hover { color: var(--blue-dark); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--f-mono); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.italic { font-style: italic; }
.wrap { max-width: 1140px; margin: 0 auto; padding-left: 24px; padding-right: 24px; }

/* Visibilidad según sesión */
body:not(.is-auth) .solo-auth { display: none !important; }
body.is-auth .solo-anon { display: none !important; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 44px; padding: 0 20px; border-radius: 999px; border: 1px solid transparent; font-size: 15px; font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn--dark { background: var(--ink); color: #FFFFFF; }
.btn--dark:hover { background: #2A2D35; color: #FFFFFF; }
.btn--blue { background: var(--blue); color: #FFFFFF; font-weight: 600; }
.btn--blue:hover { background: var(--blue-dark); color: #FFFFFF; }
.btn--accent { background: var(--accent); color: var(--ink); font-weight: 600; }
.btn--accent:hover { background: #D99430; color: var(--ink); }
.btn--outline { background: #FFFFFF; border-color: var(--line-2); color: var(--ink); }
.btn--outline:hover { border-color: var(--ink); color: var(--ink); }
.btn--danger { color: var(--warn); }
.btn--sm { height: 38px; padding: 0 14px; font-size: 14px; }
.btn--lg { height: 48px; padding: 0 30px; }
.icon-btn { width: 44px; height: 44px; border: 0; background: transparent; font-size: 26px; cursor: pointer; color: var(--ink-2); }

/* Encabezado */
.topbar { border-bottom: 1px solid var(--line); }
.topbar__inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 32px; padding-top: 18px; padding-bottom: 18px; }
.logo { font-family: var(--f-script); font-size: 42px; line-height: 1; color: var(--ink); text-decoration: none; }
.logo:hover { color: var(--ink); }
.logo--sm { font-size: 30px; }
.nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 26px; font-family: var(--f-head); font-size: 17px; font-weight: 500; }
.nav a, .nav__link { color: var(--muted); text-decoration: none; padding: 10px 0; background: none; border: 0; cursor: pointer; font-family: var(--f-head); font-size: 17px; font-weight: 500; }
.nav a:hover, .nav__link:hover { color: var(--ink); }
.nav__lock { display: inline-flex; align-items: center; gap: 6px; }
.nav .btn { font-family: var(--f-sans); font-size: 15px; height: 40px; }

/* Portada */
.hero { display: flex; flex-wrap: wrap; align-items: center; }
.hero__photo { flex: 1 1 480px; min-width: 0; height: 560px; background: #E9E9E5; position: relative; overflow: hidden; }
.hero__photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero__photo img.is-bn { filter: grayscale(1); }
.hero__placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted); font-family: var(--f-head); font-size: 17px; }
.hero__text { flex: 1 1 440px; min-width: 0; padding: 56px clamp(24px, 6vw, 96px); display: flex; flex-direction: column; align-items: flex-end; text-align: right; gap: 18px; }
.hero__role { font-family: var(--f-head); font-size: 13px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: var(--blue); }
.hero__quote { margin: 0; font-family: var(--f-head); font-weight: 700; font-size: clamp(28px, 3.2vw, 42px); line-height: 1.18; max-width: 560px; }
.hero__author { font-family: var(--f-serif); font-style: italic; font-weight: 500; font-size: 22px; color: var(--navy); }
@media (max-width: 640px) {
  .hero__photo { height: 380px; }
  .hero__text { align-items: flex-start; text-align: left; }
}

/* Título de sección con líneas */
.section-title { display: flex; align-items: center; justify-content: center; gap: 24px; }
.section-title h2 { margin: 0; font-family: var(--f-head); font-weight: 700; font-size: clamp(22px, 3vw, 34px); letter-spacing: 0.04em; text-transform: uppercase; text-align: center; }
.section-title__line { flex: 0 1 110px; height: 2px; background: var(--navy); }

/* Repositorio */
.repo { padding-top: 80px; padding-bottom: 96px; display: flex; flex-direction: column; gap: 28px; }
.repo__body { display: flex; flex-direction: column; gap: 24px; }
.locked { max-width: 560px; margin: 8px auto 0; border: 1px solid var(--line); border-radius: 12px; padding: 40px 32px; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.locked__title { font-family: var(--f-head); font-size: 22px; font-weight: 600; }
.locked p { margin: 0; color: var(--muted); max-width: 400px; }
.repo__toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.repo__actions { display: flex; flex-wrap: wrap; gap: 10px; }
.search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line-2); border-radius: 999px; padding: 0 16px; height: 44px; flex: 0 1 320px; }
.search input { border: 0; outline: none; width: 100%; background: transparent; font-size: 15px; }
.search:focus-within { border-color: var(--blue); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat { padding: 20px 8px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; }
.stat__value { font-family: var(--f-head); font-size: 34px; font-weight: 600; }
.stat__value.is-warn { color: var(--warn); }
.stat__value.is-ok { color: var(--ok); }
.stat__label { font-size: 13px; color: var(--muted); letter-spacing: 0.04em; }

.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chip { height: 40px; padding: 0 16px; border-radius: 999px; font-size: 14px; cursor: pointer; border: 1px solid var(--line-2); background: #FFFFFF; color: var(--ink); }
.chip:hover { border-color: var(--ink); }
.chip.is-on { background: var(--ink); border-color: var(--ink); color: #FFFFFF; }

.repo__grid { display: flex; flex-wrap: wrap; gap: 28px; align-items: flex-start; }
/* Tabla: se adapta al ancho de su propio contenedor (no solo de la ventana) */
.table-box { flex: 999 1 520px; min-width: 0; container-type: inline-size; }
.table__head, .row {
  display: grid;
  grid-template-columns: 28px minmax(0, 2.2fr) minmax(0, 1.6fr) 104px 96px;
  grid-template-areas: "grip main user crit tfa";
  column-gap: 14px;
  align-items: center;
}
.table__head { padding: 10px 12px 10px 4px; border-bottom: 2px solid var(--navy); font-family: var(--f-head); font-size: 13px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; white-space: nowrap; }
.row { width: 100%; text-align: left; padding: 14px 12px 14px 4px; border: 0; border-bottom: 1px solid var(--line); background: #FFFFFF; cursor: pointer; font-size: 15px; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.col-grip { grid-area: grip; }
.col-main { grid-area: main; min-width: 0; }
.col-user { grid-area: user; min-width: 0; }
.col-crit { grid-area: crit; }
.col-tfa  { grid-area: tfa; white-space: nowrap; }
.row__grip { display: flex; align-items: center; justify-content: center; width: 28px; height: 40px; color: #A3A6AE; cursor: grab; touch-action: none; font-size: 15px; letter-spacing: -3px; }

.tfa-label { display: none; }

/* Espacio angosto: cada fila pasa a tarjeta de dos líneas */
@container (max-width: 600px) {
  .table__head { display: none; }
  .row {
    grid-template-columns: 28px minmax(0, 1fr) auto;
    grid-template-areas:
      "grip main crit"
      "grip user tfa";
    row-gap: 6px;
    border-top: 0;
  }
  .table__body { border-top: 2px solid var(--navy); }
  .col-crit, .col-tfa { justify-self: end; text-align: right; }
  .tfa-label { display: inline; color: var(--muted); }
  .row__grip { height: 100%; min-height: 44px; }
}
.row:hover .row__grip { color: var(--ink-2); }
.row.is-holding { background: var(--soft); }
.row.is-dragging { position: relative; z-index: 2; background: #FFFFFF; box-shadow: 0 8px 24px rgba(22, 24, 29, 0.16); cursor: grabbing; }
.table.is-sorting .row:not(.is-dragging) { transition: transform 0.12s ease; }
body.is-sorting, body.is-sorting * { cursor: grabbing !important; }
.hint { margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.select-pill select { height: 44px; border: 1px solid var(--line-2); border-radius: 999px; padding: 0 16px; background: #FFFFFF; font-size: 15px; }
.row:hover { background: var(--soft); }
.row.is-sel { background: var(--sel); box-shadow: inset 3px 0 0 var(--blue); }
.row__name { font-family: var(--f-head); font-weight: 600; font-size: 17px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__sub { display: block; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__user { font-family: var(--f-mono); font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 32px 16px; color: var(--muted); }

.badge { display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge--Alta { background: #FBE3CF; color: var(--warn); }
.badge--Media { background: #E3ECF8; color: var(--blue-dark); }
.badge--Baja { background: #E6F0E6; color: var(--ok); }
.badge--Sin { background: #F0F0EC; color: var(--muted); }
.tfa--si { color: var(--ok); font-size: 14px; }
.tfa--no { color: var(--warn); font-size: 14px; }
.tfa--na { color: var(--muted); font-size: 14px; }

.detail { flex: 1 1 340px; min-width: 0; border: 1px solid var(--line); border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.detail__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.detail__name { font-family: var(--f-head); font-size: 26px; font-weight: 700; line-height: 1.2; }
.detail__dl { margin: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px 16px; font-size: 14px; }
.detail__dl dt { color: var(--muted); }
.detail__dl dd { margin: 0; word-break: break-all; }
.detail__actions { display: flex; gap: 8px; }
.obs { border-top: 1px solid var(--line); padding-top: 18px; display: flex; flex-direction: column; gap: 12px; }
.label-caps { font-family: var(--f-head); font-size: 13px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; }
.obs__item { display: flex; flex-direction: column; gap: 2px; padding-left: 12px; border-left: 2px solid var(--accent); margin-bottom: 10px; }
.obs__meta { font-family: var(--f-mono); font-size: 12px; color: var(--muted); }
.obs__text { font-size: 14px; white-space: pre-line; }
.obs__form { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 13px; color: var(--ink-2); }
.obs__form select, .obs__form textarea, .field input, .field select, .field textarea {
  border: 1px solid var(--line-2); border-radius: 8px; background: #FFFFFF; font-size: 15px;
}
.obs__form select, .field input, .field select { height: 44px; padding: 0 12px; }
.obs__form textarea, .field textarea { padding: 10px 12px; resize: vertical; }
.field input[type=file] { height: auto; padding: 10px 12px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 1px; }

/* Diálogos */
.dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 32px)); color: var(--ink); }
.dialog::backdrop { background: rgba(22, 24, 29, 0.55); }
.dialog__body { padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.dialog__head { display: flex; justify-content: space-between; align-items: center; }
.dialog__head h3 { margin: 0; font-family: var(--f-head); font-size: 24px; font-weight: 700; }
.dialog__foot { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.dialog__foot--split { justify-content: space-between; }
.row-gap { display: flex; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; min-height: 44px; }
.check input { width: 20px; height: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 520px) { .grid-3 { grid-template-columns: 1fr; } }
.mask-preview { background: var(--soft); border: 1px dashed var(--line-2); border-radius: 8px; padding: 10px 12px; font-size: 13px; color: var(--ink-2); }
.form-error { color: var(--warn); font-size: 14px; }

/* Pie */
.footer { border-top: 1px solid var(--line); }
.footer__inner { padding-top: 28px; padding-bottom: 28px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }
