:root {
  --navy: #1f2a5c;
  --border: #3b4a8f;
  --blue: #3a5fb4;
  --blue-dark: #2d4c96;
  --accent: #e0566b;
  --accent-bg: #fde8ec;
  --text: #222;
  --muted: #555;
  --req: #d33;
  --card: #fff;
  --canvas: #f3f3f3;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--text);
  background-color: var(--canvas);
  background-image: radial-gradient(#cfcfcf 1px, transparent 1px);
  background-size: 18px 18px;
  min-height: 100vh;
  padding: 24px 16px;
}

.sheet {
  max-width: 800px;
  margin: 0 auto;
  background: var(--card);
  box-shadow: 0 1px 6px rgba(0,0,0,.15);
  padding: 20px 100px 20px;
  display: flex;
  flex-direction: column;
  min-height: 460px;
}

.pill {
  align-self: flex-start;
  font-size: 9px;
  padding: 3px 9px;
  border: 1px solid #bbb;
  border-radius: 10px;
  background: #eee;
  color: #444;
}

h1 { font-size: 17px; margin: 10px 0 18px; line-height: 1.25; }

/* Stepper */
.stepper {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  margin: 0 0 10px;
  padding: 0;
}
.stepper li {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
}
.stepper li:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 10px;
  left: calc(50% + 12px);
  width: calc(100% - 24px);
  height: 1px;
  background: #ccc;
}
.num {
  width: 22px; height: 22px;
  border: 1.5px solid var(--navy);
  color: var(--navy);
  font-size: 11px;
  display: grid; place-items: center;
  background: #fff;
}
.lbl { font-size: 8px; color: var(--navy); margin-top: 6px; line-height: 1.2; padding: 0 2px; }
.stepper li.active .num,
.stepper li.visited .num { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }
.stepper li.active .lbl,
.stepper li.visited .lbl { color: var(--accent); }
.stepper li.active .num { box-shadow: 0 0 0 1px var(--accent); }

/* Form card */
form {
  flex: none;
  border: 1px solid #e3e3e3;
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  padding: 4px 10px 12px;
  height: 230px;
  overflow-y: auto;
  margin-bottom: 10px;
}
.step { display: none; }
.step.show { display: block; }

.intro { font-size: 8.5px; line-height: 1.45; text-align: justify; margin: 4px 0 24px; color: #111; }

.grid { display: grid; gap: 4px 10px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }

label, .field { display: block; font-size: 9px; color: #333; margin-bottom: 6px; }
.flabel { display: block; margin-bottom: 4px; }
label i, .pep-head i { color: var(--req); font-style: normal; }

input:not([type=checkbox]):not([type=file]), select, textarea {
  display: block;
  margin-top: 3px;
  font: inherit;
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 5px 7px;
  height: 25px;
  background: #fff;
  color: #111;
  width: 100%;
}
textarea { height: auto; resize: vertical; }
input::placeholder, textarea::placeholder { color: #999; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9fb2e8; outline-offset: 0; }

select {
  appearance: none;
  padding-right: 30px;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='white' stroke-width='1.8'/%3E%3C/svg%3E"),
    linear-gradient(var(--blue), var(--blue));
  background-repeat: no-repeat;
  background-position: right 6px center, right top;
  background-size: 12px 8px, 24px 100%;
}

.invalid { border-color: var(--req) !important; background-color: #fff6f6; }
select.invalid { background-color: #fff6f6; }

.checks { display: flex; gap: 10px; align-items: center; }
.chk { display: flex; flex-direction: row; align-items: center; gap: 5px; font-size: 10px; margin: 0; }
.chk input { width: 16px; height: 16px; margin: 0; accent-color: var(--navy); }
.chk.big { margin-top: 10px; font-size: 11px; }

/* PEP */
.pep-head {
  font-size: 9px;
  padding: 6px 4px;
  border-bottom: 1px solid #eee;
  margin-bottom: 12px;
}
.pep-row { margin-bottom: 8px; padding: 0 4px; }
.pep-row input, .pep-row select { margin-top: 0 !important; }
.pep-last { display: flex; gap: 4px; }
.rm { border: none; background: none; color: var(--req); font-size: 16px; cursor: pointer; padding: 0 4px; }
.pep-row:first-child .rm { visibility: hidden; }
.btn-outline {
  font: inherit; font-size: 10px;
  border: 1px solid var(--border);
  color: var(--navy);
  background: #fff;
  border-radius: 9px;
  padding: 4px 8px;
  cursor: pointer;
  margin-left: 4px;
}
.btn-outline:disabled { opacity: .5; cursor: not-allowed; }

.docs { gap: 4px 20px; }
.docs label { display: flex; flex-direction: column; justify-content: space-between; margin-bottom: 10px; font-size: 10px; }
.docs label i { display: inline; }
.docs input[type=file] { display: block; margin-top: 4px; font-size: 10px; }

/* Nav */
.error { color: var(--req); font-size: 11px; margin: 0 0 8px; }
.error[hidden] { display: none; }
.btn:disabled { opacity: .7; cursor: wait; }
.nav { display: flex; gap: 10px; }
.btn {
  flex: 1;
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  color: #fff;
  background: var(--blue);
  border: 1px solid var(--blue-dark);
  border-radius: 5px;
  height: 26px;
  cursor: pointer;
}
.btn:hover { background: var(--blue-dark); }
.btn[hidden] { display: none; }

.ok { text-align: center; padding: 30px 0; }
.okmark { width: 48px; height: 48px; border-radius: 50%; background: var(--blue); color: #fff; font-size: 26px; display: grid; place-items: center; margin: 0 auto 10px; }
.ok h2 { font-size: 16px; margin: 0 0 6px; }
.ok p { font-size: 11px; color: var(--muted); }

@media (max-width: 760px) {
  .sheet { padding: 20px 16px; }
  .lbl { display: none; }
  .stepper li.active .lbl { display: block; position: absolute; top: 26px; white-space: nowrap; }
  .stepper { margin-bottom: 24px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .pep-head { display: none; }
  .pep-row { border-bottom: 1px solid #eee; padding-bottom: 8px; }
  form { height: auto; min-height: 300px; max-height: 60vh; }
}

/* Barra superior y botón de sesión */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.login-link { text-decoration: none; font-size: 10px; }
[hidden] { display: none !important; }

/* Administración */
.admin-login { max-width: 420px; padding: 24px; min-height: 0; }
.login-box { border: none; box-shadow: none; height: auto; overflow: visible; padding: 0; }
.login-box label { margin-bottom: 12px; font-size: 11px; }
.login-box .btn { width: 100%; height: 32px; margin-top: 4px; }
.volver { display: block; margin-top: 14px; font-size: 11px; color: var(--navy); }

.sheet.admin { max-width: 1100px; padding: 20px 32px; min-height: 0; }
.admin h1 { margin-bottom: 10px; }
.admin h2 { font-size: 12px; color: var(--navy); margin: 18px 0 8px; padding-bottom: 4px; border-bottom: 1px solid #e3e3e3; }
.admin form { height: auto; overflow: visible; border: none; box-shadow: none; padding: 0; }
.who { font-size: 11px; color: var(--muted); }
.muted { color: var(--muted); font-size: 11px; }
.link { background: none; border: none; padding: 0; font: inherit; color: var(--blue); cursor: pointer; text-decoration: underline; }
.danger-text { color: var(--req); }
.btn.danger { background: #fff; color: var(--req); border-color: var(--req); }
.btn.danger:hover { background: #fff1f1; }
.ok-msg { color: #1d7a3a; font-size: 11px; margin: 0 0 8px; }

.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.toolbar input { max-width: 360px; }
.table-wrap { overflow-x: auto; border: 1px solid #e3e3e3; border-radius: 3px; }
.tabla { width: 100%; border-collapse: collapse; font-size: 11px; }
.tabla th { text-align: left; background: #f4f6fb; color: var(--navy); font-weight: 600; padding: 7px 8px; white-space: nowrap; }
.tabla td { padding: 7px 8px; border-top: 1px solid #eee; }
.tabla tr.clic { cursor: pointer; }
.tabla tr.clic:hover td { background: #f7f9ff; }

.docs-list { list-style: none; padding: 0; margin: 0 0 12px; font-size: 11px; }
.docs-list li { padding: 6px 0; border-bottom: 1px solid #f0f0f0; display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.doc-tipo { font-weight: 600; min-width: 220px; }
.admin .nav { margin-top: 10px; }

@media (max-width: 760px) {
  .sheet.admin { padding: 16px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .doc-tipo { min-width: 0; width: 100%; }
}
.admin .link { font-size: 11px; }
.admin .grid .chk.big { grid-column: 1 / -1; margin: 4px 0 8px; }
