:root {
  --cert-bg: #f5f5f7;
  --cert-card: #ffffff;
  --cert-text: #1d1d1f;
  --cert-muted: #86868b;
  --cert-border: rgba(0,0,0,0.06);
  --cert-section: #6e6e73;
  --cert-radius: 18px;
}

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
a { text-decoration: none; color: inherit; }
a:hover { text-decoration: none; }
button, .dsu-cert-login-btn { text-decoration: none; outline: none; border: none; cursor: pointer; }

body.dsu-cert-shell {
  font: 400 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--cert-text);
  background:
    radial-gradient(1400px 1000px at 15% 15%, rgba(163,196,243,0.65), transparent 60%),
    radial-gradient(1200px 900px at 85% 10%, rgba(237,180,255,0.6), transparent 60%),
    radial-gradient(1400px 1100px at 25% 90%, rgba(172,255,221,0.55), transparent 65%),
    radial-gradient(1000px 900px at 90% 85%, rgba(255,228,196,0.45), transparent 65%),
    linear-gradient(180deg, #fdfdfd 0%, #f5f8ff 100%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: cover;
  min-height: 100vh;
}

.dsu-cert-bg {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

/* ── Header ── */
.dsu-cert-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255,255,255,0.75);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid rgba(255,255,255,0.4);
}
.dsu-cert-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 24px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.dsu-cert-header-inner .dsu-cert-login-wrap:first-child { justify-content: flex-start; }
.dsu-cert-logo-wrap { display: flex; justify-content: center; align-items: center; pointer-events: none; }
.dsu-cert-header-inner .dsu-cert-login-wrap:last-child { justify-content: flex-end; }
.dsu-cert-logo { height: 44px; width: auto; object-fit: contain; }
.dsu-cert-login-wrap { display: flex; justify-content: flex-end; gap: 8px; }
.dsu-cert-login-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--cert-text);
  background: var(--cert-card);
  border: 1px solid var(--cert-border);
  border-radius: 8px;
  transition: background 0.15s;
}
.dsu-cert-login-btn,
.dsu-cert-login-btn:link,
.dsu-cert-login-btn:visited,
.dsu-cert-login-btn:hover,
.dsu-cert-login-btn:focus,
.dsu-cert-login-btn:active {
  text-decoration: none !important;
}
.dsu-cert-login-btn:hover { background: #f0f0f5; }
.back-chevron { padding: 8px 14px !important; font-size: 20px !important; line-height: 1; }

/* ── Main ── */
.dsu-cert-main {
  display: grid;
  place-items: center;
  padding: 40px 24px 32px;
}

/* ── Card ── */
.dsu-cert-card {
  width: 100%;
  max-width: 800px;
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: var(--cert-radius);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 12px 40px rgba(0,0,0,0.08);
  padding: 36px 40px;
}
.dsu-cert-card--wide { max-width: 960px; }

/* Badge */
.dsu-cert-badge-wrap { text-align: center; margin-bottom: 16px; }
.dsu-cert-badge {
  height: 56px;
  width: auto;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.2)) drop-shadow(0 0 12px rgba(255,230,120,0.4));
  animation: dsu-glow 2.8s ease-in-out infinite;
}
@keyframes dsu-glow {
  0%, 100% { filter: drop-shadow(0 2px 6px rgba(0,0,0,0.2)) drop-shadow(0 0 12px rgba(255,227,100,0.6)); }
  50% { filter: drop-shadow(0 2px 6px rgba(0,0,0,0.2)) drop-shadow(0 0 20px rgba(255,211,68,0.75)); }
}

/* Titles */
.dsu-cert-title {
  margin: 6px 0 12px;
  font-size: clamp(1.1rem, 3vw, 1.6rem);
  font-weight: 700;
  text-align: center;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.dsu-cert-subtle {
  margin: 0 auto 20px;
  max-width: 700px;
  text-align: center;
  color: var(--cert-muted);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Verify bar ── */
.dsu-verify {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border: 1px solid var(--cert-border);
  border-radius: 12px;
  background: #f9f9fb;
  margin-bottom: 8px;
}
.dsu-verify-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.pill { border-radius: 6px; padding: 4px 10px; font-size: 12px; font-weight: 700; }
.pill-ok { background: #e8f9ee; color: #1a7d36; border: 1px solid #bde6c9; }
.pill-warn { background: #fff6e5; color: #8a5a00; border: 1px solid #f1d7a8; }
.uid, .issued, .hashcode { font-family: 'SF Mono', Menlo, Consolas, monospace; font-size: 13px; color: var(--cert-muted); }
.dsu-verify-qr img { height: 64px; width: 64px; }

/* ── Sections ── */
.dsu-section {
  margin: 28px 0 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cert-section);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--cert-border);
}

/* ── Key-value grid ── */
.dsu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}
.dsu-kv {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0,0,0,0.03);
  font-size: 14px;
}
.dsu-kv:last-child { border-bottom: none; }
.dsu-k {
  flex: 0 0 140px;
  font-size: 12px;
  font-weight: 600;
  color: var(--cert-muted);
}
.dsu-v {
  flex: 1;
  color: var(--cert-text);
  font-weight: 500;
  word-break: break-word;
}

/* ── Tests grid ── */
.dsu-tests {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}
.dsu-test {
  border: 1px solid var(--cert-border);
  border-radius: 10px;
  background: #f9f9fb;
  padding: 12px 14px;
}
.dsu-test h4 { margin: 0 0 6px; font-size: 13px; font-weight: 700; }
.dsu-test-notes { margin-top: 6px; color: var(--cert-muted); font-size: 12px; }
.dsu-pill { display: inline-block; padding: 3px 9px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.passed { background: #e8f9ee; color: #1a7d36; border: 1px solid #bde6c9; }
.failed { background: #ffe5e5; color: #d70015; border: 1px solid #f2c2c2; }
.not-tested { background: #f0f0f5; color: #86868b; border: 1px solid #e5e5ea; }

/* ── Parts table ── */
table.dsu-parts { width: 100%; border-collapse: collapse; font-size: 13px; }
table.dsu-parts th, table.dsu-parts td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--cert-border); }
table.dsu-parts th { font-size: 11px; font-weight: 700; color: var(--cert-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-responsive > table { min-width: 500px; }

/* ── Issuer ── */
.dsu-issuer { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--cert-border); }
.dsu-cert-signature { display: block; max-height: 48px; opacity: 0.9; margin-left: auto; margin-bottom: 6px; }
.issuer-text { font-size: 13px; color: var(--cert-muted); text-align: right; line-height: 1.6; }

/* ── Certified border — subtle, no glow ── */
.border {
  border: 1px solid rgba(255,220,70,0.4);
}

/* ── Footer ── */
.dsu-cert-footer {
  padding: 20px 24px 28px;
  text-align: center;
  color: var(--cert-muted);
  font-size: 13px;
  border-top: 1px solid rgba(255,255,255,0.4);
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.dsu-cert-footer a { color: #dc5028; font-weight: 600; }
.dsu-cert-footer a:hover { text-decoration: underline; }
.copyright { margin-top: 12px; font-size: 11px; }

/* ── Search page ── */
.dsu-cert-search { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; margin: 18px auto 8px; max-width: 560px; }
.dsu-cert-input {
  width: 100%;
  border: 1px solid var(--cert-border);
  background: #f9f9fb;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.dsu-cert-input:focus { border-color: #dc5028; box-shadow: 0 0 0 3px rgba(220,80,40,0.1); }
.dsu-cert-search-btn {
  border: 1px solid rgba(255,255,255,0.5);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.42) 0%, rgba(255,255,255,0.2) 100%),
    linear-gradient(135deg, rgba(220,80,40,0.18) 0%, rgba(163,196,243,0.16) 100%);
  color: #1d1d1f;
  border-radius: 14px;
  padding: 12px 20px;
  font-weight: 700;
  font-size: 14px;
  min-width: 100px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.6),
    0 10px 24px rgba(15,23,42,0.08);
  backdrop-filter: blur(14px) saturate(145%);
  -webkit-backdrop-filter: blur(14px) saturate(145%);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}
.dsu-cert-search-btn:hover {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.5) 0%, rgba(255,255,255,0.26) 100%),
    linear-gradient(135deg, rgba(220,80,40,0.22) 0%, rgba(163,196,243,0.2) 100%);
  border-color: rgba(255,255,255,0.68);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.72),
    0 14px 30px rgba(15,23,42,0.12);
  transform: translateY(-1px);
}
.dsu-cert-search-btn:active {
  transform: translateY(0);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.55),
    0 6px 14px rgba(15,23,42,0.08);
}
.dsu-cert-placeholder { margin: 18px auto 0; max-width: 560px; color: var(--cert-muted); font-size: 14px; text-align: center; }

/* ── Print toolbar ── */
.dsu-print-toolbar { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 16px; }
.dsu-print-btn {
  border: 1px solid var(--cert-border);
  background: var(--cert-card);
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  transition: background 0.15s;
}
.dsu-print-btn:hover { background: #f0f0f5; }

/* ── Alert ── */
.dsu-cert-alert {
  padding: 12px 18px;
  background: #ffe5e5;
  border: 1px solid rgba(255,0,0,0.15);
  color: #d70015;
  font-weight: 600;
  text-align: center;
  font-size: 14px;
}

/* ── Tap targets ── */
.dsu-cert-login-btn, .dsu-cert-search-btn { min-height: 44px; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .dsu-grid { grid-template-columns: 1fr; }
  .dsu-tests { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .dsu-cert-header-inner { grid-template-columns: 50px 1fr 48px; gap: 6px; }
  .dsu-cert-logo { height: 36px; }
  .dsu-cert-card { padding: 24px 20px; border-radius: 14px; }
  .dsu-cert-card--wide { max-width: 100%; }
  .dsu-verify { flex-direction: column; align-items: flex-start; gap: 10px; }
  .dsu-verify-qr img { height: 52px; width: 52px; }
}

@media (max-width: 600px) {
  html, body { overflow-x: hidden; max-width: 100%; }
  body.dsu-cert-shell { font-size: 14px; overflow-x: hidden; }
  .dsu-cert-bg { max-width: 100vw; overflow-x: hidden; }
  .dsu-cert-main { padding: 16px 10px 24px; max-width: 100%; }
  .dsu-cert-card { padding: 18px 14px; border-radius: 12px; max-width: 100%; width: 100%; }
  .dsu-cert-search { grid-template-columns: 1fr; }
  .dsu-cert-search-btn { width: 100%; }

  /* Make every descendant wrap rather than overflow */
  .dsu-cert-card,
  .dsu-cert-card * { min-width: 0; max-width: 100%; }
  .dsu-cert-card img { max-width: 100%; height: auto; }

  /* Long monospace values (UIDs, serials, JobIDs, hashes) — break anywhere */
  .uid, .issued, .hashcode,
  .dsu-cert-card [style*="monospace"] { word-break: break-all; overflow-wrap: anywhere; }

  /* Verify bar — stack + wrap */
  .dsu-verify { flex-direction: column; align-items: stretch; padding: 12px 14px; }
  .dsu-verify-row { flex-direction: column; align-items: flex-start; gap: 6px; }
  .dsu-verify-qr { align-self: center; }

  /* Key-value grid — one column, no forced label width */
  .dsu-grid { grid-template-columns: 1fr; gap: 0; }
  .dsu-kv { flex-direction: column; gap: 2px; }
  .dsu-k { flex: none; }
  .dsu-v { overflow-wrap: anywhere; }

  /* Tests grid */
  .dsu-tests { grid-template-columns: 1fr; }

  /* Erasure-cert inline-flex headers (from inline styles) — let them wrap */
  .dsu-cert-card div[style*="display:flex"] { flex-wrap: wrap; }
  .dsu-cert-card div[style*="justify-content:space-between"] { gap: 6px; }

  /* Table wrapper contains its own horizontal scroll */
  .table-responsive { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-responsive > table { min-width: 560px; }

  /* Footer / issuer */
  .dsu-cert-signature { max-height: 40px; }
  .issuer-text { font-size: 12px; text-align: left; }
  .dsu-cert-signature { margin-left: 0; }

  /* Print toolbar stays compact */
  .dsu-print-toolbar { padding: 10px 12px; }
  .dsu-print-btn { padding: 8px 14px; font-size: 12px; }

  /* Header padding tighter, centred logo keeps room */
  .dsu-cert-header-inner { padding: 10px 12px; }
}

@media (max-width: 420px) {
  .dsu-cert-main { padding: 12px 8px 20px; }
  .dsu-cert-card { padding: 16px 12px; }
  .dsu-cert-title { font-size: 1.1rem; }
  .dsu-cert-subtle { font-size: 13px; }
  .dsu-section { font-size: 10px; margin: 22px 0 8px; }
  .dsu-test { padding: 10px 12px; }
  .table-responsive > table { min-width: 480px; }
}

/* ── Print ── */
@media print {
  body * { visibility: hidden !important; }
  .dsu-cert-main, .dsu-cert-main * { visibility: visible !important; }
  .dsu-cert-main { position: absolute; inset: 0 auto auto 0; width: 100%; }
  .dsu-print-toolbar, .dsu-cert-header, .dsu-cert-footer { display: none !important; }
  body.dsu-cert-shell::after { display: none !important; }
  .dsu-cert-bg { box-shadow: none !important; background: transparent !important; }
  .dsu-cert-main { font-size: 11px; line-height: 1.3; }
  .dsu-grid { grid-template-columns: 1fr; gap: 4px; }
  .dsu-kv { padding: 4px 0; }
  .dsu-k { flex: 0 0 110px; font-size: 10px; }
  .dsu-parts { font-size: 10px; }
  .dsu-parts th, .dsu-parts td { padding: 4px 6px; }
  .dsu-section { margin-top: 12px; }
  .dsu-tests { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
  .dsu-test { padding: 6px 8px; }
  .dsu-test h4 { font-size: 10px; }
}
