/* TESDA RO8 Certificate QR tool
   Direction: an official government issuance instrument — precise, quiet,
   trustworthy. Boldness is spent in two places only: the verification verdict
   panel and the monospace identifiers, which read like a serial/tracking system. */

:root {
  --ink:        #0B1F33;
  --ink-soft:   #3A4B5C;
  --field:      #EEF1F5;
  --surface:    #FFFFFF;
  --line:       #D5DBE3;
  --line-soft:  #E6EAF0;
  --tesda:      #15489B;
  --action:     #1E63D6;
  --action-ink: #0E3F92;
  --authentic:  #137A4C;
  --tamper:     #B3261E;
  --caution:    #B26A00;
  --caution-bg: #FBF3E4;

  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --r: 8px;
  --r-sm: 5px;
  --shadow: 0 1px 2px rgba(11,31,51,.06), 0 6px 22px rgba(11,31,51,.05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--field);
  line-height: 1.5;
  font-size: 15px;
}
h2 { margin: 0; }
p { margin: 0 0 .6rem; }
p:last-child { margin-bottom: 0; }
code, pre, .mono { font-family: var(--mono); }

.skip {
  position: absolute; left: -999px; top: 0;
  background: var(--ink); color: #fff; padding: .5rem .9rem; z-index: 50; border-radius: 0 0 var(--r) 0;
}
.skip:focus { left: 0; }

/* ---------- app bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--ink);
  color: #fff;
  border-bottom: 3px solid var(--tesda);
}
.appbar-in {
  max-width: 1180px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .7rem 1.1rem;
}
.brand { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.seal {
  flex: none;
  width: 38px; height: 38px; border-radius: 6px;
  display: grid; place-items: center;
  background: linear-gradient(150deg, var(--tesda), #0E3578);
  font-family: var(--mono); font-weight: 700; letter-spacing: -.5px;
  border: 1px solid rgba(255,255,255,.22);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { font-size: .98rem; letter-spacing: .1px; }
.brand-sub { font-size: .72rem; color: #AFC1DA; letter-spacing: .3px; text-transform: uppercase; }

.status {
  flex: none;
  display: flex; align-items: center; gap: .45rem;
  font-size: .76rem; letter-spacing: .2px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.16);
  padding: .3rem .6rem; border-radius: 999px;
}
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: #7E8FA3; }
.status.is-offline-ready .dot { background: #34D08C; box-shadow: 0 0 0 3px rgba(52,208,140,.2); }
.status.is-online .dot { background: #4FA8FF; }
.status.is-offline .dot { background: var(--caution); }

/* ---------- tabs ---------- */
.tabs {
  max-width: 1180px; margin: 0 auto;
  display: flex; gap: .15rem; padding: 0 .7rem;
  overflow-x: auto;
}
.tab {
  appearance: none; border: 0; background: none; cursor: pointer;
  color: #B9C8DC; font-family: inherit; font-size: .86rem; font-weight: 600;
  letter-spacing: .2px;
  padding: .6rem .95rem; margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab:hover { color: #fff; }
.tab.is-active { color: #fff; border-bottom-color: #fff; }
.tab:focus-visible { outline: 2px solid #fff; outline-offset: -2px; border-radius: 3px; }

/* ---------- layout ---------- */
main { max-width: 1180px; margin: 0 auto; padding: 1.2rem 1.1rem 2rem; }
.panel { display: none; }
.panel.is-active { display: block; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; align-items: start; }
.col { display: flex; flex-direction: column; gap: 1.1rem; min-width: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 1.05rem 1.1rem;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: .72rem; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--tesda);
  margin-bottom: .85rem;
  padding-bottom: .55rem;
  border-bottom: 1px solid var(--line-soft);
}
.placeholder { color: var(--ink-soft); background: transparent; border-style: dashed; box-shadow: none; }

/* ---------- form ---------- */
.field { margin-bottom: .75rem; }
.field:last-child { margin-bottom: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
label { display: block; font-size: .78rem; font-weight: 600; color: var(--ink-soft); margin-bottom: .28rem; }
.opt { font-weight: 400; color: #8A98A8; }
input[type=text], input[type=password], input[type=url], input[type=date], select, textarea {
  width: 100%; font-family: inherit; font-size: .9rem; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: .5rem .6rem;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--action);
  box-shadow: 0 0 0 3px rgba(30,99,214,.15);
}
.hint { font-size: .76rem; color: var(--ink-soft); margin-top: .4rem; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; color: var(--ink); margin-top: .4rem; }
.check input { width: auto; }

/* ---------- drop zone ---------- */
.drop {
  border: 1.5px dashed var(--line); border-radius: var(--r);
  padding: 1.3rem 1rem; text-align: center; cursor: pointer; background: #FAFBFD;
  transition: border-color .12s, background .12s;
}
.drop:hover, .drop:focus-visible { border-color: var(--action); background: #F4F8FF; outline: none; }
.drop.is-drag { border-color: var(--action); background: #EAF2FF; }
.drop.has-file { border-style: solid; border-color: var(--tesda); background: #fff; }
.drop-main { font-weight: 600; margin-bottom: .25rem; }
.drop .link { color: var(--action); text-decoration: underline; }
.drop-sub { font-size: .78rem; color: var(--ink-soft); margin: 0; }

/* ---------- placement picker ---------- */
.placer-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: .9rem 0 .5rem; flex-wrap: wrap; }
.placer-head .label { font-size: .78rem; font-weight: 600; color: var(--ink-soft); }
.presets { display: flex; gap: .25rem; flex-wrap: wrap; }
.presets button {
  appearance: none; cursor: pointer; font-family: inherit; font-size: .72rem; font-weight: 600;
  color: var(--ink-soft); background: #fff; border: 1px solid var(--line); border-radius: 999px;
  padding: .25rem .55rem;
}
.presets button:hover { border-color: var(--action); color: var(--action); }
.presets button.is-on { background: var(--tesda); color: #fff; border-color: var(--tesda); }
.placer {
  background: #EBEEF3; border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 14px; display: grid; place-items: center; min-height: 150px;
}
.placer-page {
  position: relative; background: #fff; border: 1px solid #C4CCD8;
  box-shadow: 0 1px 6px rgba(11,31,51,.12);
  width: 160px; height: 207px; cursor: crosshair;
  display: grid; place-items: center;
}
.placer-empty { font-size: .74rem; color: #8A98A8; padding: 0 1rem; text-align: center; }
.placer-qr {
  position: absolute; background: rgba(21,72,155,.18);
  border: 1.5px solid var(--tesda);
  display: grid; place-items: center;
}
.placer-qr::after {
  content: "QR"; font-family: var(--mono); font-size: .6rem; font-weight: 700; color: var(--tesda);
}
/* ---- interactive bulk picker ---- */
.placer-lg { min-height: 180px; }
.placer-lg .placer-page { width: 300px; height: 212px; cursor: crosshair; }
.placer-qr { cursor: grab; touch-action: none; }
.placer-qr:active { cursor: grabbing; }
#bulkQrMarker { display: grid; place-items: center; font-family: var(--mono); font-size: .62rem; font-weight: 700; color: var(--tesda); }
#bulkQrMarker::after { content: none; }
.placer-name {
  position: absolute; transform: translateX(-50%); touch-action: none;
  background: rgba(19,122,76,.16); border: 1.5px solid var(--authentic);
  color: var(--authentic); font-size: .62rem; font-weight: 700; padding: .08rem .34rem;
  border-radius: 4px; white-space: nowrap; cursor: grab;
}
.placer-name:active { cursor: grabbing; }
.placer-divider { position: absolute; left: 0; right: 0; top: 50%; border-top: 1.5px dashed var(--caution); pointer-events: none; }
.presets.seg button.is-on { background: var(--action); color: #fff; border-color: var(--action); }

/* ---------- buttons ---------- */
.actions { display: flex; flex-wrap: wrap; gap: .55rem; }
.btn {
  appearance: none; cursor: pointer; font-family: inherit; font-size: .86rem; font-weight: 600;
  border-radius: var(--r-sm); padding: .58rem .95rem;
  background: #fff; color: var(--ink); border: 1px solid var(--line);
  transition: background .12s, border-color .12s, color .12s, transform .04s;
}
.btn:hover { border-color: #B9C2CF; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--action); border-color: var(--action); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--action-ink); border-color: var(--action-ink); }
.btn-accent { background: var(--authentic); border-color: var(--authentic); color: #fff; }
.btn-accent:hover:not(:disabled) { filter: brightness(.94); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--line-soft); border-color: transparent; }

/* ---------- signer card ---------- */
.signer-card { display: flex; align-items: baseline; gap: .55rem; flex-wrap: wrap; padding: .8rem 1.1rem; }
.signer-label { font-size: .72rem; text-transform: uppercase; letter-spacing: 1px; color: var(--ink-soft); }
.signer-id { font-weight: 700; font-size: .95rem; }
.signer-tag { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; padding: .12rem .45rem; border-radius: 999px; }
.signer-tag.demo { background: var(--caution-bg); color: var(--caution); }
.signer-tag.production { background: #E4F4EC; color: var(--authentic); }
.signer-tag.none { background: #F0E2E1; color: var(--tamper); }

/* ---------- generated record ---------- */
.uid-wrap { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .8rem; }
.uid-label { font-size: .72rem; text-transform: uppercase; letter-spacing: 1px; color: var(--ink-soft); }
.uid, code.uid {
  font-family: var(--mono); font-size: .9rem; font-weight: 600; color: var(--ink);
  background: #F3F6FA; border: 1px solid var(--line-soft); border-left: 3px solid var(--tesda);
  padding: .5rem .65rem; border-radius: var(--r-sm); word-break: break-all;
}
.qr-preview { display: grid; place-items: center; padding: .6rem; background: #fff; }
.qr-preview img { width: 190px; height: 190px; image-rendering: pixelated; border: 1px solid var(--line-soft); }
.uid-sample { background: #F3F6FA; padding: .55rem .65rem; border-radius: var(--r-sm); font-size: .82rem; word-break: break-all; }

details.audit { margin-top: .7rem; border-top: 1px solid var(--line-soft); padding-top: .55rem; }
details.audit summary { cursor: pointer; font-size: .78rem; font-weight: 600; color: var(--ink-soft); }
details.audit summary:hover { color: var(--action); }
details.audit pre {
  margin: .55rem 0 0; background: #0B1F33; color: #D6E2F2;
  padding: .7rem .8rem; border-radius: var(--r-sm); font-size: .76rem;
  overflow-x: auto; white-space: pre-wrap; word-break: break-all;
}

iframe#pdfPreview { width: 100%; height: 460px; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; }
iframe#bulkPreviewFrame { width: 100%; height: 460px; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; }
hr.rule { border: none; border-top: 1px solid var(--line-soft); margin: .9rem 0; }
.rtable-wrap { max-height: 320px; overflow: auto; border: 1px solid var(--line-soft); border-radius: var(--r-sm); }
.rtable { width: 100%; border-collapse: collapse; font-size: .8rem; }
.rtable th, .rtable td { text-align: left; padding: .35rem .5rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.rtable th { position: sticky; top: 0; background: var(--field); font-weight: 600; }
.rtable td.mono, .rtable .mono { font-family: var(--mono); font-size: .74rem; word-break: break-all; }
.rtable .ok { color: var(--authentic); font-weight: 600; }
.rtable .no { color: var(--tamper); font-weight: 600; }

/* ---------- verify ---------- */
.or { text-align: center; font-size: .72rem; color: #8A98A8; text-transform: uppercase; letter-spacing: 1px; margin: .6rem 0; position: relative; }
.cam-row { display: flex; gap: .5rem; }
.cam-wrap { margin-top: .7rem; }
.cam-wrap video { width: 100%; border-radius: var(--r-sm); background: #000; }

.verdict {
  display: flex; border-radius: var(--r); overflow: hidden;
  background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow);
}
.verdict-bar { width: 8px; flex: none; background: #9AA8B8; }
.verdict-body { padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.verdict-state { font-size: 1.15rem; font-weight: 800; letter-spacing: .2px; }
.verdict-detail { font-size: .84rem; color: var(--ink-soft); }
.verdict[data-state="VALID"] .verdict-bar { background: var(--authentic); }
.verdict[data-state="VALID"] .verdict-state { color: var(--authentic); }
.verdict[data-state="INVALID"] .verdict-bar,
.verdict[data-state="REVOKED"] .verdict-bar { background: var(--tamper); }
.verdict[data-state="INVALID"] .verdict-state,
.verdict[data-state="REVOKED"] .verdict-state { color: var(--tamper); }
.verdict[data-state="MALFORMED"] .verdict-bar,
.verdict[data-state="UNSUPPORTED"] .verdict-bar,
.verdict[data-state="UNKNOWN_SIGNER"] .verdict-bar { background: var(--caution); }
.verdict[data-state="MALFORMED"] .verdict-state,
.verdict[data-state="UNSUPPORTED"] .verdict-state,
.verdict[data-state="UNKNOWN_SIGNER"] .verdict-state { color: var(--caution); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: .4rem .9rem; margin: 0; }
.kv dt { font-size: .76rem; color: var(--ink-soft); font-weight: 600; }
.kv dd { margin: 0; font-size: .88rem; word-break: break-word; }

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.steps li { display: flex; gap: .6rem; align-items: flex-start; font-size: .84rem; }
.steps .mark { flex: none; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: .7rem; font-weight: 800; color: #fff; margin-top: 1px; }
.steps .ok .mark { background: var(--authentic); }
.steps .no .mark { background: var(--tamper); }
.steps .step-label { font-weight: 600; }
.steps .step-detail { color: var(--ink-soft); }

/* ---------- callouts / keys / refs ---------- */
.callout { border-radius: var(--r-sm); padding: .8rem .9rem; font-size: .82rem; }
.callout-caution { background: var(--caution-bg); border: 1px solid #EAD8B4; color: #6B4A0E; }
.callout strong { color: var(--caution); }

.keylist { list-style: none; margin: 0 0 .6rem; padding: 0; display: flex; flex-direction: column; gap: .45rem; }
.keylist li { display: flex; align-items: center; gap: .55rem; font-size: .82rem; border: 1px solid var(--line-soft); border-radius: var(--r-sm); padding: .45rem .6rem; }
.keylist .kid { font-family: var(--mono); font-weight: 700; }
.keylist .ks { font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; padding: .1rem .4rem; border-radius: 999px; }
.keylist .ks.demo { background: var(--caution-bg); color: var(--caution); }
.keylist .ks.production { background: #E4F4EC; color: var(--authentic); }
.keylist .ks.revoked { background: #F0E2E1; color: var(--tamper); }
.keylist .ks.active { background: var(--action); color: #fff; }
.keylist li { flex-wrap: wrap; }
.keylist .spacer { flex: 1 1 auto; }
.btn-sm { padding: .22rem .5rem; font-size: .74rem; }

table.ref { width: 100%; border-collapse: collapse; font-size: .84rem; }
table.ref td { padding: .4rem .5rem; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.ref td:first-child { font-family: var(--mono); font-weight: 700; color: var(--tesda); white-space: nowrap; width: 1%; }

.foot { max-width: 1180px; margin: 0 auto; padding: 1rem 1.1rem 2rem; color: #8A98A8; font-size: .76rem; text-align: center; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .field-row { grid-template-columns: 1fr; }
  .brand-sub { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}


.auth-shell { min-height: calc(100vh - 180px); display: grid; place-items: start center; padding-top: 6vh; }
.auth-card { width: min(440px, 100%); }
.admin-topline { display: flex; justify-content: space-between; align-items: center; gap: .8rem; margin-bottom: 1rem; }
.sticky-col { position: sticky; top: 112px; align-self: start; max-height: calc(100vh - 124px); overflow: auto; padding-right: 2px; }
@media (max-width: 860px) { .admin-topline { flex-direction: column; align-items: stretch; } .sticky-col { position: static; max-height: none; overflow: visible; padding-right: 0; } }
