@import url('https://fonts.googleapis.com/css2?family=Work+Sans:ital,wght@0,400;0,600;0,700;0,800;1,400&display=swap');

:root {
  --paper:       #ffffff;
  --ink:         #1a1a1a;
  --ink-pure:    #000000;
  --muted:       #6b6b6b;
  --faint:       #9a9a9a;
  --coral:       #ff4630;
  --blue:        #005db5;
  --rule:        #e2e2e2;
  --rule-strong: #000000;
  --wash:        #f6f6f4;
  --sans:        "Work Sans", "Helvetica Neue", Arial, sans-serif;
  --serif:       Georgia, "PT Serif", "Times New Roman", serif;
  --mono:        "Courier New", monospace;
  --h1:  54px;  --h2: 34px;  --h3: 20px;
  --body: 18px; --caption: 14px; --kicker: 13px;
  --container: 1120px; --reading: 680px; --gap: 28px; --radius: 2px;
}

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

body {
  font-family: var(--serif);
  font-size: var(--body);
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
}

/* ── Layout ── */
.container { max-width: var(--container); margin: 0 auto; padding: 0 var(--gap); }
.reading   { max-width: var(--reading);   margin: 0 auto; }

/* ── Masthead público ── */
.masthead {
  padding: 24px var(--gap);
  border-bottom: 3px solid var(--rule-strong);
  margin-bottom: 56px;
}
.masthead-inner {
  max-width: var(--container);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--gap);
}
.masthead-lockup {
  font-family: var(--sans);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-pure);
}
.masthead-certamen {
  font-family: var(--sans);
  font-size: var(--kicker);
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── Kicker ── */
.kicker {
  font-family: var(--sans);
  font-size: var(--kicker);
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--coral);
  margin-bottom: 12px;
  display: block;
}

/* ── Tipografía ── */
h1 {
  font-family: var(--sans);
  font-size: var(--h1);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--ink-pure);
  margin-bottom: 32px;
}
h2 {
  font-family: var(--sans);
  font-size: var(--h2);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.01em;
  color: var(--ink-pure);
  margin-bottom: 20px;
}
h3 {
  font-family: var(--sans);
  font-size: var(--h3);
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink-pure);
  margin-bottom: 12px;
}
p { margin-bottom: 16px; }
a { color: var(--blue); }
a:hover { color: var(--coral); }

/* ── Botones ── */
.btn-primary, .btn-dark, .btn-ghost {
  display: inline-block;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 14px 26px;
  border-radius: var(--radius);
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: opacity .15s;
  line-height: 1;
}
.btn-primary { background: var(--coral); color: #fff; }
.btn-primary:hover { opacity: .88; color: #fff; }
.btn-dark    { background: var(--ink-pure); color: #fff; }
.btn-dark:hover { opacity: .85; color: #fff; }
.btn-ghost   {
  background: transparent;
  color: var(--ink-pure);
  border: 2px solid var(--ink-pure);
}
.btn-ghost:hover { background: var(--ink-pure); color: #fff; }
.btn-sm { padding: 8px 16px; font-size: 12px; }
button.btn-primary, button.btn-dark, button.btn-ghost { appearance: none; }

/* ── Formularios ── */
.form-section {
  border-top: 1px solid var(--rule);
  padding-top: 32px;
  margin-top: 32px;
}
.form-section:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.field { margin-bottom: 24px; }
.field label {
  display: block;
  font-family: var(--sans);
  font-size: var(--kicker);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 6px;
}
.field label .req { color: var(--coral); margin-left: 2px; }
.field input,
.field select,
.field textarea {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--rule-strong);
  background: transparent;
  font-family: var(--serif);
  font-size: var(--body);
  color: var(--ink);
  padding: 8px 0;
  outline: none;
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
}
.field input:focus,
.field select:focus,
.field textarea:focus { border-bottom-color: var(--coral); }
.field textarea { resize: vertical; min-height: 100px; }
.field .ayuda {
  font-family: var(--serif);
  font-size: var(--caption);
  color: var(--muted);
  margin-top: 4px;
  font-style: italic;
}
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M0 0l6 8 6-8z' fill='%231a1a1a'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
  padding-right: 24px;
  cursor: pointer;
}
.form-actions {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 40px;
  padding-top: 32px;
  border-top: 1px solid var(--rule);
  flex-wrap: wrap;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--radius);
  white-space: nowrap;
}
.badge-gray  { background: var(--rule); color: var(--muted); }
.badge-blue  { background: #dbeafe; color: #1e3a8a; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-coral { background: #fff1f0; color: var(--coral); }

/* ── Ticket de confirmación ── */
.ticket {
  border: 1px solid var(--rule);
  border-top: 3px solid var(--rule-strong);
  padding: 32px;
  margin: 40px 0;
}
.ticket-id {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: normal;
  color: var(--ink-pure);
  margin-bottom: 12px;
}
.ticket-meta {
  font-family: var(--sans);
  font-size: var(--caption);
  color: var(--muted);
  margin-bottom: 4px;
}
.ticket-enlace {
  background: var(--wash);
  padding: 12px 16px;
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-all;
  margin: 16px 0;
}

/* ── Flash messages ── */
.flash {
  padding: 12px 20px;
  margin-bottom: 24px;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: var(--caption);
  font-weight: 600;
}
.flash-ok    { background: #dcfce7; color: #166534; border-left: 3px solid #16a34a; }
.flash-error { background: #fee2e2; color: #991b1b; border-left: 3px solid var(--coral); }
.flash-info  { background: #dbeafe; color: #1e3a8a; border-left: 3px solid var(--blue); }

/* ── Banners ── */
.banner-ok {
  background: #dcfce7;
  border-left: 3px solid #16a34a;
  padding: 16px 20px;
  margin-bottom: 32px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  color: #166534;
}
.banner-info {
  background: #dbeafe;
  border-left: 3px solid var(--blue);
  padding: 16px 20px;
  margin-bottom: 32px;
  font-family: var(--sans);
  font-size: 14px;
  color: #1e3a8a;
}

/* ── Admin — barra de navegación ── */
.admin-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #111;
  padding: 0 var(--gap);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
}
.admin-bar a,
.admin-bar button {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #ccc;
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 8px;
}
.admin-bar a:hover,
.admin-bar button:hover { color: #fff; }
.admin-bar .breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #666;
}
.admin-bar .breadcrumb a { color: #999; }
.admin-bar .breadcrumb .sep { color: #444; }

/* ── Admin — login ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
}
.login-box {
  background: #1a1a1a;
  border: 1px solid #333;
  padding: 48px;
  width: 380px;
}
.login-box .kicker { color: #ff4630; }
.login-box h1 { font-size: 28px; color: #fff; margin-bottom: 32px; }
.login-box .field label { color: #ccc; }
.login-box .field input {
  color: #fff;
  border-bottom-color: #444;
  background: transparent;
}
.login-box .field input:focus { border-bottom-color: var(--coral); }

/* ── Admin — contenedor y tabla ── */
.admin-page { padding: 32px var(--gap); }

.filtros {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--rule);
}
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 16px;
  border: 1px solid var(--rule);
  text-decoration: none;
  color: var(--muted);
  white-space: nowrap;
  transition: all .15s;
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.activo { background: var(--ink-pure); color: #fff; border-color: var(--ink-pure); }

.filtros select,
.filtros input[type="search"] {
  font-family: var(--sans);
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid var(--rule);
  background: var(--paper);
  border-radius: var(--radius);
  color: var(--ink);
}
.toggle-label {
  font-family: var(--sans);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--muted);
}

table { width: 100%; border-collapse: collapse; }
thead th {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 12px;
  text-align: left;
  border-bottom: 2px solid var(--rule);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--rule); }
tbody tr:hover { background: var(--wash); }
tbody tr.preseleccionada { background: var(--wash); }
tbody td {
  padding: 12px;
  font-size: 15px;
  vertical-align: top;
}
tbody td a { color: var(--ink); text-decoration: none; }
tbody td a:hover { color: var(--coral); }
.td-proyecto { font-family: var(--sans); font-weight: 600; }
.td-mono { font-family: var(--mono); font-size: 13px; color: var(--muted); }

.accordion-content {
  display: none;
  padding: 10px 0;
  font-size: var(--caption);
  color: var(--muted);
}
.accordion-content.open { display: block; }

/* ── Admin — detalle layout ── */
.detalle-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 48px;
  align-items: start;
  padding: 32px var(--gap);
}
.detalle-main { min-width: 0; }
.detalle-sidebar {
  position: sticky;
  top: 60px;
  border: 1px solid var(--rule);
  padding: 24px;
}

.sidebar-section {
  border-top: 1px solid var(--rule);
  padding-top: 20px;
  margin-top: 20px;
}
.sidebar-section:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.sidebar-section h4 {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}

/* ── Secciones del detalle ── */
.seccion { margin-bottom: 40px; }
.seccion-titulo {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 20px;
}
.campo-readonly { margin-bottom: 20px; }
.campo-readonly dt {
  font-family: var(--sans);
  font-size: var(--caption);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.campo-readonly dd {
  font-family: var(--serif);
  font-size: 16px;
  color: var(--ink);
  white-space: pre-line;
  margin: 0;
}

/* ── Historial ── */
.evento {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
  font-size: var(--caption);
}
.evento:last-child { border-bottom: none; }
.evento-ts {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}
.evento-tipo {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 12px;
  color: var(--ink);
}
.evento-actor { color: var(--muted); font-size: 11px; }

/* ── Bloque IA ── */
.ia-bloque {
  border: 1px solid var(--rule);
  border-left: 3px solid var(--coral);
  padding: 20px 24px;
  margin-bottom: 32px;
}
.ia-bloque summary {
  font-family: var(--sans);
  font-size: var(--caption);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--coral);
  cursor: pointer;
  list-style: none;
}
.ia-bloque summary::-webkit-details-marker { display: none; }
.ia-contenido {
  font-family: var(--serif);
  font-size: 16px;
  margin-top: 16px;
  color: var(--ink);
}

/* ── Footer público ── */
.footer-pub {
  margin-top: 80px;
  padding: 24px var(--gap);
  border-top: 1px solid var(--rule);
  font-family: var(--sans);
  font-size: var(--kicker);
  color: var(--faint);
  text-align: center;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  :root { --h1: 36px; --h2: 26px; --gap: 16px; }
  .detalle-layout { grid-template-columns: 1fr; }
  .detalle-sidebar { position: static; }
  .masthead-inner { flex-direction: column; gap: 4px; }
  h1 { font-size: 32px; }
}
