:root {
  --primary: #082dca;
  --primary-dark: #061e87;
  --cyan: #11d3e8;
  --ink: #101828;
  --muted: #667085;
  --line: #e4e7ec;
  --soft: #f5f7fb;
  --success: #067647;
  --warning: #b54708;
  --danger: #b42318;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--soft); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
img { max-width: 100%; display: block; }

.site-shell { min-height: 100vh; background: linear-gradient(180deg, #fff 0%, #f5f7fb 100%); }
.public-nav { height: 74px; display: flex; align-items: center; justify-content: space-between; padding: 0 6vw; background: #fff; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; color: var(--primary); }
.brand img { width: 48px; height: 48px; object-fit: contain; }
.nav-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.hero { padding: 72px 6vw 36px; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr); gap: 44px; align-items: center; }
.hero h1 { margin: 0 0 18px; font-size: clamp(2.2rem, 5vw, 5rem); line-height: .98; color: var(--primary); letter-spacing: 0; }
.hero p { font-size: 1.1rem; color: var(--muted); line-height: 1.7; max-width: 700px; }
.hero-panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: 0 18px 50px rgba(16, 24, 40, .08); }
.trust-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; padding: 28px 6vw 72px; }
.trust-item, .card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: 0 8px 30px rgba(16, 24, 40, .04); }
.trust-item h3, .card h3 { margin: 0 0 8px; }
.trust-item p, .card p { margin: 0; color: var(--muted); line-height: 1.55; }

.btn { border: 1px solid transparent; border-radius: var(--radius); min-height: 42px; padding: 10px 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; font-weight: 700; transition: .18s ease; background: #fff; color: var(--ink); }
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(16,24,40,.1); }
.btn:disabled { opacity: .65; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-outline { border-color: var(--line); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top left, rgba(8,45,202,.16), transparent 30%), var(--soft); }
.login-card { width: min(440px, 100%); background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 30px; box-shadow: 0 24px 70px rgba(16,24,40,.12); }
.login-card .brand { margin-bottom: 24px; }
.login-card h1 { margin: 0 0 8px; }
.login-card p { color: var(--muted); margin: 0 0 22px; }

.app-layout { min-height: 100vh; display: grid; grid-template-columns: 270px minmax(0, 1fr); }
.sidebar { background: #071f8b; color: #fff; padding: 22px; display: flex; flex-direction: column; gap: 24px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { color: #fff; }
.sidebar nav { display: grid; gap: 8px; }
.sidebar a { padding: 12px 14px; border-radius: var(--radius); color: rgba(255,255,255,.86); font-weight: 700; }
.sidebar a.active, .sidebar a:hover { background: rgba(255,255,255,.14); color: #fff; }
.sidebar-footer { margin-top: auto; color: rgba(255,255,255,.72); font-size: .9rem; }
.main { min-width: 0; }
.topbar { height: 74px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 28px; position: sticky; top: 0; z-index: 5; }
.topbar h1 { margin: 0; font-size: 1.3rem; }
.userbox { color: var(--muted); text-align: right; font-size: .9rem; }
.content { padding: 28px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h2 { margin: 0 0 6px; font-size: 1.7rem; }
.page-head p { margin: 0; color: var(--muted); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.stat strong { display: block; font-size: 2.2rem; color: var(--primary); margin-top: 10px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field { display: grid; gap: 7px; margin-bottom: 14px; }
.field label { font-weight: 750; font-size: .92rem; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid #cfd4dc; border-radius: var(--radius); padding: 11px 12px; background: #fff; min-height: 42px; }
.field textarea { min-height: 110px; resize: vertical; }
.span-2 { grid-column: 1 / -1; }
.hint, .error-text { color: var(--muted); font-size: .9rem; }
.error-text { color: var(--danger); white-space: pre-line; }
.preview-img { width: 130px; height: 150px; border: 1px solid var(--line); border-radius: var(--radius); object-fit: cover; background: #f2f4f7; }

.table-wrap { width: 100%; overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: #475467; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; background: #f9fafb; }
tr:last-child td { border-bottom: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions .btn { min-height: 34px; padding: 7px 10px; font-size: .86rem; }

.badge { display: inline-flex; align-items: center; justify-content: center; min-height: 26px; padding: 4px 9px; border-radius: 999px; font-weight: 800; font-size: .78rem; }
.badge-valid { background: #dcfae6; color: var(--success); }
.badge-expired { background: #fef0c7; color: var(--warning); }
.badge-revoked { background: #fee4e2; color: var(--danger); }
.badge-not, .badge-not_found, .badge-unknown { background: #eaecf0; color: #475467; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(16,24,40,.62); display: none; align-items: center; justify-content: center; z-index: 30; padding: 18px; }
.modal-backdrop.open { display: flex; }
.modal { width: min(620px, 100%); max-height: 90vh; overflow: auto; background: #fff; border-radius: var(--radius); padding: 22px; box-shadow: 0 24px 80px rgba(0,0,0,.25); }
.modal h3 { margin: 0 0 14px; }
.toast-wrap { position: fixed; right: 18px; top: 18px; display: grid; gap: 10px; z-index: 60; }
.toast { padding: 13px 15px; border-radius: var(--radius); background: #fff; border-left: 5px solid var(--primary); box-shadow: 0 14px 34px rgba(16,24,40,.18); max-width: 360px; white-space: pre-line; }
.toast-error { border-color: var(--danger); }
.toast-success { border-color: var(--success); }

.verify-shell { min-height: 100vh; background: #fff; }
.verify-head { background: var(--primary); color: #fff; padding: 24px 6vw; display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.verify-main { padding: 34px 6vw; display: grid; gap: 24px; }
.verify-result { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 24px; align-items: start; }
.passport-large { width: 180px; height: 210px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); background: #f2f4f7; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.detail { border-bottom: 1px solid var(--line); padding: 10px 0; }
.detail span { display: block; color: var(--muted); font-size: .86rem; }
.detail strong { display: block; margin-top: 3px; }

.empty { padding: 28px; color: var(--muted); text-align: center; }
.loading { opacity: .7; pointer-events: none; }
.mt { margin-top: 18px; }
.pdf-preview {
  min-height: 680px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #101828;
}
.pdf-preview iframe,
.pdf-preview object,
.pdf-preview embed {
  display: block;
  width: 100%;
  height: 680px;
  border: 0;
  background: #101828;
}

@media (max-width: 980px) {
  .hero, .grid-2, .verify-result { grid-template-columns: 1fr; }
  .grid-4, .trust-grid { grid-template-columns: repeat(2, 1fr); }
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { height: auto; position: static; }
  .sidebar nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .public-nav, .verify-head, .topbar, .page-head { align-items: flex-start; flex-direction: column; height: auto; padding-top: 16px; padding-bottom: 16px; }
  .hero, .content, .verify-main { padding-left: 18px; padding-right: 18px; }
  .grid-4, .trust-grid, .form-grid, .detail-grid { grid-template-columns: 1fr; }
  .sidebar nav { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .table-wrap { overflow-x: visible; background: transparent; border: 0; display: grid; gap: 10px; }
  table { min-width: 0; border-collapse: separate; border-spacing: 0 10px; }
  thead { display: none; }
  tbody { display: block; width: 100%; }
  tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    background: #fff;
    border: 1px solid var(--line);
    border-bottom: 3px solid var(--primary);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(16, 24, 40, .04);
  }
  td {
    display: block;
    width: 100%;
    min-height: 0;
    padding: 8px 11px;
    border-bottom: 1px solid var(--line);
    font-size: .9rem;
    line-height: 1.28;
  }
  td:nth-child(1),
  td:nth-child(3),
  td:nth-child(4) { border-right: 1px solid var(--line); }
  td:nth-child(7) { grid-column: 1 / -1; }
  td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    color: #475467;
    font-size: .66rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
  }
  td:last-child { border-bottom: 0; }
  td.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; padding-top: 9px; }
  td.actions::before { grid-column: 1 / -1; }
  .actions .btn { width: 100%; min-height: 34px; padding: 6px 8px; font-size: .78rem; }
  .badge { min-height: 22px; padding: 3px 8px; font-size: .7rem; }
}
