/* Sistema de Sellos de Competencia — admin console.
   Visual identity: security-document / official seal. Ink-green on cool paper, brass seal,
   "verde sello" = válido, lacre = inválido. Piazzolla (display) / Public Sans (body) /
   IBM Plex Mono (cryptographic data). */

:root {
  --ink: #122019;
  --ink-2: #3a4d44;
  --paper: #e9ede7;
  --paper-card: #fbfcfa;
  --sello: #1c6b4a;
  --sello-deep: #114a33;
  --brass: #b5894e;
  --brass-deep: #876435;
  --lacre: #9b3b2e;
  --line: #ced5cc;
  --line-strong: #a9b3a8;
  --line-soft: rgba(18, 32, 25, 0.07);

  --display: "Piazzolla", Georgia, "Times New Roman", serif;
  --body: "Public Sans", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;

  --maxw: 1140px;
}

* { box-sizing: border-box; }

/* The [hidden] attribute must win over the flex/grid display on panels. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--body);
  color: var(--ink);
  background-color: var(--paper);
  /* faint security-paper texture: two low-contrast guilloché-ish gradients */
  background-image:
    repeating-radial-gradient(circle at 18% -10%, transparent 0 18px, rgba(28, 107, 74, 0.018) 18px 19px),
    repeating-linear-gradient(58deg, transparent 0 22px, rgba(18, 32, 25, 0.014) 22px 23px);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { font-family: var(--display); font-weight: 600; line-height: 1.05; margin: 0; }

a { color: var(--sello); }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.85rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 70%, white);
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: 0.7rem; }
.brand-mark { width: 34px; height: 34px; display: inline-block; color: var(--brass); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-family: var(--display); font-weight: 700; font-size: 1.02rem; letter-spacing: 0.01em; }
.brand-text span { font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-2); }

.session { display: flex; align-items: center; gap: 0.6rem; }
.role { display: flex; align-items: center; gap: 0.4rem; font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-2); }
.role select {
  font-family: var(--body); font-size: 0.85rem; color: var(--ink);
  border: 1px solid var(--line-strong); background: var(--paper-card);
  padding: 0.3rem 0.5rem; border-radius: 2px;
}
.status { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.78rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.status.is-on .dot { background: var(--sello); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sello) 22%, transparent); }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--body); font-weight: 600; font-size: 0.9rem; letter-spacing: 0.01em;
  padding: 0.6rem 1.05rem; border-radius: 2px; cursor: pointer; border: 1px solid transparent;
  transition: transform .08s ease, background .15s ease, color .15s ease, border-color .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-solid { background: var(--sello); color: #f3f7f3; border-color: var(--sello-deep); }
.btn-solid:hover:not(:disabled) { background: var(--sello-deep); }
.btn-outline { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn-outline:hover:not(:disabled) { background: var(--ink); color: var(--paper-card); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); font-weight: 500; }
.btn-ghost:hover:not(:disabled) { border-color: var(--ink); }

/* ---------- layout ---------- */
main { max-width: var(--maxw); margin: 0 auto; padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 4vw, 2.5rem) 3rem; }

.hero {
  display: grid; grid-template-columns: 320px 1fr; gap: clamp(1.5rem, 5vw, 3.5rem);
  align-items: center; padding-bottom: clamp(1.5rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
}
.hero-seal { display: flex; flex-direction: column; align-items: center; gap: 0.8rem; }
.seal-caption { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.04em; color: var(--ink-2); text-align: center; }

.eyebrow { font-family: var(--mono); font-size: 0.74rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--brass-deep); margin: 0 0 0.8rem; }
.hero-copy h1 { font-size: clamp(2.1rem, 5.2vw, 3.5rem); letter-spacing: -0.015em; }
.hero-copy h1 em { font-style: italic; color: var(--sello); }
.lede { max-width: 46ch; color: var(--ink-2); margin: 1.1rem 0 1.5rem; font-size: 1.02rem; }

.catalogo { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.chip {
  font-size: 0.8rem; padding: 0.32rem 0.7rem; border: 1px solid var(--line-strong);
  border-radius: 100px; background: var(--paper-card); color: var(--ink);
  cursor: pointer; transition: border-color .15s ease, color .15s ease;
}
.chip:hover { border-color: var(--brass); color: var(--brass-deep); }
.chip[aria-pressed="true"] { border-color: var(--sello); color: var(--sello); background: color-mix(in srgb, var(--sello) 8%, var(--paper-card)); }
.chip-skeleton { color: var(--ink-2); cursor: default; font-family: var(--mono); font-size: 0.72rem; }

/* ---------- work panels ---------- */
.work { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; margin-top: clamp(1.5rem, 4vw, 2.5rem); }
.panel {
  background: var(--paper-card); border: 1px solid var(--line);
  border-top: 3px solid var(--brass);
  padding: 1.4rem 1.4rem 1.6rem; display: flex; flex-direction: column; gap: 0.85rem;
}
.panel-head { display: flex; align-items: baseline; gap: 0.7rem; margin-bottom: 0.3rem; }
.panel-num { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--brass-deep); }
.panel-head h2 { font-size: 1.4rem; }

.panel label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.78rem; letter-spacing: 0.04em; color: var(--ink-2); text-transform: uppercase; }
.panel input, .panel select, .panel textarea {
  font-family: var(--body); font-size: 0.95rem; color: var(--ink); text-transform: none; letter-spacing: 0;
  border: 1px solid var(--line-strong); background: #fff; padding: 0.55rem 0.65rem; border-radius: 2px; width: 100%;
}
.panel textarea { font-family: var(--mono); font-size: 0.8rem; resize: vertical; line-height: 1.5; }
.panel input:focus, .panel select:focus, .panel textarea:focus {
  outline: none; border-color: var(--sello); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sello) 18%, transparent);
}
.panel .btn { align-self: flex-start; margin-top: 0.3rem; }

.hint { font-size: 0.82rem; color: var(--ink-2); margin: 0 0 0.4rem; border-left: 2px solid var(--brass); padding-left: 0.6rem; }
.msg { font-size: 0.85rem; margin: 0; min-height: 1.2em; }
.msg.ok { color: var(--sello-deep); }
.msg.err { color: var(--lacre); }

/* ---------- verification report ---------- */
.report { list-style: none; margin: 0.3rem 0 0; padding: 0; display: flex; flex-direction: column; }
.report li {
  display: grid; grid-template-columns: 1.4rem 1fr auto; align-items: baseline; gap: 0.5rem;
  padding: 0.5rem 0; border-bottom: 1px dashed var(--line);
  animation: rise .28s ease both;
}
.report li:last-child { border-bottom: 0; }
.report .mark { font-weight: 700; }
.report li.pass .mark { color: var(--sello); }
.report li.fail .mark { color: var(--lacre); }
.report .name { font-size: 0.92rem; }
.report .detail { font-family: var(--mono); font-size: 0.72rem; color: var(--ink-2); text-align: right; max-width: 22ch; overflow-wrap: anywhere; }

/* ---------- ficha (constancia) ---------- */
.ficha-wrap { margin-top: 1.4rem; background: var(--paper-card); border: 1px solid var(--line); border-left: 3px solid var(--sello); padding: 1.4rem; }
.ficha { display: grid; grid-template-columns: max-content 1fr; gap: 0.55rem 1.4rem; margin: 0.6rem 0 0; }
.ficha dt { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--brass-deep); }
.ficha dd { margin: 0; font-family: var(--mono); font-size: 0.82rem; overflow-wrap: anywhere; }

/* ---------- seal emblem ---------- */
.seal { margin: 0; width: 100%; max-width: 300px; color: var(--line-strong); }
.seal svg { width: 100%; height: auto; display: block; }
.seal[data-state="issued"] { color: var(--brass); }
.seal[data-state="valid"] { color: var(--sello); }
.seal[data-state="invalid"] { color: var(--lacre); }
.seal .guilloche { stroke: currentColor; opacity: 0.35; fill: none; }
.seal .ring { stroke: currentColor; fill: none; }
.seal .ring-text { fill: currentColor; font-family: var(--mono); letter-spacing: 0.28em; }
.seal .core { fill: color-mix(in srgb, currentColor 9%, var(--paper-card)); stroke: currentColor; }
.seal .glyph { fill: currentColor; font-family: var(--display); }
.seal .competency { fill: var(--ink); font-family: var(--display); }
.seal.is-stamping svg { animation: stamp .5s cubic-bezier(.2,.8,.2,1) both; transform-origin: center; }

@keyframes stamp { 0% { opacity: 0; transform: scale(1.22) rotate(-5deg); } 60% { opacity: 1; } 100% { opacity: 1; transform: scale(1) rotate(0); } }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- footer ---------- */
.foot { max-width: var(--maxw); margin: 0 auto; padding: 1.4rem clamp(1rem, 4vw, 2.5rem) 2.5rem; border-top: 1px solid var(--line); }
.foot p { font-size: 0.78rem; color: var(--ink-2); margin: 0; max-width: 70ch; }

/* ---------- gateway (root: acceso + verificación) ---------- */
.gateway {
  position: fixed; inset: 0; z-index: 100; overflow-y: auto;
  padding: clamp(1.2rem, 4vw, 2.4rem);
  background:
    repeating-radial-gradient(circle at 50% -8%, transparent 0 18px, rgba(28, 107, 74, 0.035) 18px 19px),
    var(--paper);
}
.gateway[hidden] { display: none; }
.gateway-masthead { display: flex; align-items: center; gap: 1rem; max-width: 1040px; margin: 0 auto 1.6rem; padding-bottom: 1.1rem; border-bottom: 1px solid var(--line); }
.gateway-crest { width: 66px; height: 66px; color: var(--brass-deep); flex: none; }
.gateway-eyebrow { margin: 0; font-size: 0.7rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--brass-deep); font-weight: 600; }
.gateway-masthead h1 { font-family: "Cormorant Garamond", var(--display); font-weight: 600; font-size: clamp(1.5rem, 3.4vw, 2.2rem); }
.gateway-cols { display: grid; grid-template-columns: 0.82fr 1.18fr; gap: 1.4rem; max-width: 1040px; margin: 0 auto; align-items: start; }
.gateway-card { background: var(--paper-card); border: 1px solid var(--line); border-top: 3px solid var(--brass); border-radius: 3px; padding: 1.6rem 1.6rem 1.7rem; }
.gateway-card > h2 { font-family: "Cormorant Garamond", var(--display); font-size: 1.7rem; margin: 0 0 0.15rem; }
.gateway-card .sub { margin: 0 0 1.1rem; font-size: 0.85rem; color: var(--ink-2); }

.gateway-login label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 0.7rem; }
.gateway-login input { font-family: var(--body); font-size: 0.95rem; padding: 0.55rem 0.65rem; border: 1px solid var(--line-strong); border-radius: 2px; }
.gateway-login input:focus { outline: none; border-color: var(--sello); box-shadow: 0 0 0 3px color-mix(in srgb, var(--sello) 18%, transparent); }
.gateway-login .btn { margin-top: 0.4rem; width: 100%; }

.drop { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; padding: 1.8rem 1rem; border: 1.5px dashed var(--brass); border-radius: 3px; cursor: pointer; text-align: center; transition: border-color .2s, background .2s; outline: none; }
.drop:hover, .drop:focus-visible, .drop.is-drag { border-color: var(--brass-deep); background: color-mix(in srgb, var(--paper) 50%, white); }
.drop-mark { width: 40px; height: 40px; color: var(--brass); }
.drop-title { font-family: "Cormorant Garamond", var(--display); font-size: 1.3rem; font-weight: 600; }
.drop-hint { font-size: 0.82rem; color: var(--ink-2); }
.privacy { text-align: center; font-size: 0.76rem; color: var(--ink-2); margin: 0.7rem 0 0; }

.verdict { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.1rem; border: 1px solid var(--line); border-left: 4px solid var(--sello); border-radius: 3px; background: var(--paper-card); margin-bottom: 1.2rem; }
.verdict[data-state="warn"] { border-left-color: var(--brass); }
.verdict[data-state="bad"] { border-left-color: var(--lacre); }
.verdict-seal { width: 74px; height: 74px; flex: none; color: var(--sello); }
.verdict[data-state="warn"] .verdict-seal { color: var(--brass-deep); }
.verdict[data-state="bad"] .verdict-seal { color: var(--lacre); }
.verdict-label { margin: 0; font-family: "Cormorant Garamond", var(--display); font-size: 1.5rem; font-weight: 700; }
.verdict-note { margin: .2rem 0 0; color: var(--ink-2); font-size: .9rem; }
.seal-press { animation: seal-press .55s cubic-bezier(.2,.9,.3,1.2) both; transform-origin: center; }
@keyframes seal-press { 0% { opacity: 0; transform: scale(1.4) rotate(-10deg); } 60% { opacity: 1; } 100% { opacity: 1; transform: none; } }

.instrument { border: 1px solid var(--line); border-top: 2px solid var(--brass); border-radius: 3px; padding: 1rem 1.1rem 1.2rem; margin-bottom: 1rem; background: var(--paper-card); }
.instrument h3 { margin: 0 0 .8rem; font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: var(--brass-deep); font-weight: 700; font-family: var(--body); border-bottom: 1px solid var(--line); padding-bottom: .45rem; }
.competency-name { font-family: "Cormorant Garamond", var(--display); font-size: clamp(1.5rem, 4vw, 2rem); font-weight: 700; line-height: 1.05; margin: 0 0 .9rem; }
.facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: .5rem 1rem; }
.facts dt { font-size: .64rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); font-weight: 600; padding-top: .12rem; white-space: nowrap; }
.facts dd { margin: 0; font-size: .9rem; }
.facts dd.mono { font-family: var(--mono); font-size: .76rem; word-break: break-all; }
.facts dd.strong { font-weight: 600; }
.ts-empty { color: var(--ink-2); font-style: italic; font-size: .88rem; }
.again { display: block; margin: .3rem auto 0; font-family: var(--body); font-size: .85rem; font-weight: 600; color: var(--ink); background: transparent; border: 1px solid var(--ink); border-radius: 3px; padding: .5rem 1.2rem; cursor: pointer; }
.again:hover { background: var(--ink); color: var(--paper); }

.seal-svg { width: 100%; height: 100%; }
.seal-svg .ring-outer, .seal-svg .ring-inner { fill: none; stroke: currentColor; }
.seal-svg .ring-outer { stroke-width: 2.5; }
.seal-svg .ring-inner { stroke-width: 1; }
.seal-svg .ring-ticks { fill: none; stroke: currentColor; stroke-width: 6; stroke-dasharray: 1 6.5; opacity: .5; }
.seal-svg .ring-text { fill: currentColor; font-family: var(--body); font-size: 11px; font-weight: 700; letter-spacing: .4px; }
.seal-svg .scales { stroke: currentColor; stroke-width: 3.5; stroke-linecap: round; }
.seal-svg .scales .knob { fill: currentColor; stroke: none; }

.gateway-foot { max-width: 1040px; margin: 1.6rem auto 0; padding-top: 1rem; border-top: 1px solid var(--line); font-size: .76rem; color: var(--ink-2); }

@media (max-width: 760px) { .gateway-cols { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .seal-press { animation: none; } }

.who { font-size: 0.85rem; color: var(--ink); }
.who strong { font-family: var(--display); }
.who .who-roles { font-family: var(--mono); font-size: 0.72rem; color: var(--brass-deep); margin-left: 0.45rem; }

/* ---------- users panel ---------- */
.roles { border: 1px solid var(--line); border-radius: 2px; padding: 0.55rem 0.8rem; display: flex; flex-wrap: wrap; gap: 0.35rem 1.2rem; }
.roles legend { font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2); padding: 0 0.3rem; }
.panel .roles label { flex-direction: row; align-items: center; gap: 0.35rem; font-size: 0.88rem; text-transform: none; letter-spacing: 0; color: var(--ink); }
.users { width: 100%; border-collapse: collapse; margin-top: 0.8rem; }
.users th, .users td { text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--line); }
.users th { font-family: var(--mono); font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--brass-deep); }
.users td { font-family: var(--mono); font-size: 0.8rem; }
.btn-sm { padding: 0.22rem 0.6rem; font-size: 0.72rem; }
.check-grid { display: flex; flex-wrap: wrap; gap: 0.3rem 1.2rem; }
.check-grid label { display: flex; align-items: center; gap: 0.35rem; font-size: 0.88rem; }

/* ---------- Digilogix branding + modal + forgot + multi-signature ---------- */
.gateway-logo { height: 48px; width: auto; }
.brand-logo { height: 30px; width: auto; display: block; }
.linkish { background: none; border: none; color: var(--sello); font: inherit; font-size: 0.82rem; cursor: pointer; padding: 0; text-align: left; text-decoration: underline; align-self: flex-start; }
#forgotBox { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.5rem; padding-top: 0.7rem; border-top: 1px dashed var(--line); }
#forgotBox label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
#forgotBox input { font-family: var(--body); font-size: 0.95rem; padding: 0.55rem 0.65rem; border: 1px solid var(--line-strong); border-radius: 2px; }

.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 1.5rem; background: rgba(18, 32, 25, 0.38); }
.modal[hidden] { display: none !important; }
.modal-card { width: 100%; max-width: 400px; background: var(--paper-card); border: 1px solid var(--line); border-top: 3px solid var(--brass); border-radius: 3px; padding: 1.6rem; display: flex; flex-direction: column; gap: 0.7rem; }
.modal-card h2 { font-family: "Cormorant Garamond", var(--display); font-size: 1.5rem; }
.modal-card label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
.modal-card input { font-family: var(--body); font-size: 0.95rem; padding: 0.55rem 0.65rem; border: 1px solid var(--line-strong); border-radius: 2px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 0.4rem; }

.seal-svg .mark { stroke: currentColor; stroke-width: 9; fill: none; stroke-linecap: round; stroke-linejoin: round; }

.sig-row { padding: 0.55rem 0; border-bottom: 1px solid var(--line-soft); font-size: 0.86rem; }
.sig-row:last-child { border-bottom: none; }
.sig-badge { font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.04em; padding: 0.06rem 0.4rem; border-radius: 2px; margin-left: 0.4rem; }
.sig-badge.ok { background: color-mix(in srgb, var(--sello) 16%, transparent); color: var(--sello-deep); }
.sig-badge.bad { background: color-mix(in srgb, var(--lacre) 16%, transparent); color: var(--lacre); }

.firmante-profile { font-family: "Cormorant Garamond", var(--display); font-size: 1.4rem; line-height: 1.32; color: var(--ink); border-left: 3px solid var(--brass); padding-left: 0.85rem; margin: 0.1rem 0 0.5rem; }
.firmante-profile strong { font-weight: 700; }
.hint-foot { margin-top: 0.6rem; }
main > .panel { margin-bottom: 1.6rem; }

.sig-detail { padding: 0.75rem 0; border-bottom: 1px solid var(--line); }
.sig-detail:last-child { border-bottom: none; padding-bottom: 0; }
.sig-detail-title { margin: 0 0 0.55rem; font-family: "Cormorant Garamond", var(--display); font-size: 1.2rem; font-weight: 700; }
.row-actions { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.role-edit { display: flex; flex-wrap: wrap; gap: 0.15rem 0.7rem; }
.role-edit label { display: flex; align-items: center; gap: 0.25rem; font-family: var(--body); font-size: 0.78rem; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
  .hero-seal { order: 2; }
  .work { grid-template-columns: 1fr; }
  .seal { max-width: 230px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
