:root {
  color-scheme: light;
  --primary: #206bc4;
  --primary-dark: #1a569d;
  --ink: #182433;
  --muted: #667382;
  --border: #dce1e7;
  --canvas: #f6f8fb;
  --surface: #fff;
  --sidebar: #182433;
  --green: #2fb344;
  --red: #d63939;
  --orange: #f59f00;
  --purple: #ae3ec9;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--canvas); font-size: 14px; }
a { color: var(--primary); }
button, input { font: inherit; }
.hidden { display: none !important; }

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  display: flex;
  width: 250px;
  flex-direction: column;
  color: #d7e0ea;
  background: var(--sidebar);
  box-shadow: 1px 0 0 rgba(255, 255, 255, .04);
}

.sidebar-brand {
  display: flex;
  min-height: 72px;
  align-items: center;
  gap: 11px;
  padding: 0 22px;
  color: inherit;
  text-decoration: none;
}

.sidebar-brand > span:last-child { display: flex; flex-direction: column; }
.sidebar-brand strong { color: #fff; font-size: 16px; }
.sidebar-brand small { margin-top: 2px; color: #8f9baa; font-size: 11px; }
.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 7px;
  color: #fff;
  background: var(--primary);
  font-size: 18px;
  font-weight: 800;
}

.sidebar-nav { padding: 14px 12px; }
.sidebar-nav a {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 11px;
  margin: 3px 0;
  padding: 0 12px;
  border-radius: 6px;
  color: #b8c2cf;
  font-weight: 600;
  text-decoration: none;
}
.sidebar-nav a:hover, .sidebar-nav a.active { color: #fff; background: rgba(255, 255, 255, .08); }
.nav-icon { width: 20px; color: #8fa7c4; font-size: 17px; text-align: center; }
.sidebar-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: auto 18px 22px;
  padding: 14px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 8px;
  background: rgba(255,255,255,.035);
}
.sidebar-status div { display: flex; flex-direction: column; }
.sidebar-status strong { color: #fff; font-size: 12px; }
.sidebar-status small { margin-top: 3px; color: #8f9baa; font-size: 10px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(47,179,68,.13); }

.app-shell { min-height: 100vh; margin-left: 250px; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(8px);
}
.topbar-title { font-weight: 700; }
.user-menu { display: flex; align-items: center; gap: 10px; }
.user-menu form { margin: 0 0 0 8px; }
.avatar {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  background: var(--primary);
  font-weight: 700;
}
.user-copy { display: flex; flex-direction: column; }
.user-copy strong { font-size: 12px; }
.user-copy small { color: var(--muted); font-size: 10px; }
.menu-button { display: none; padding: 6px 9px; border: 0; background: transparent; font-size: 20px; cursor: pointer; }

.page-body { width: min(1380px, calc(100% - 48px)); margin: 0 auto; padding: 30px 0 24px; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-header h1 { margin: 3px 0 5px; font-size: 28px; letter-spacing: -.025em; }
.page-header p { margin: 0; color: var(--muted); }
.page-pretitle { margin: 0; color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }

.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 5px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.button-primary { color: #fff; background: var(--primary); border-color: var(--primary); }
.button-primary:hover { color: #fff; background: var(--primary-dark); }
.button-secondary { color: var(--ink); background: #fff; border-color: var(--border); }
.button-secondary:hover { border-color: #aab3be; background: #f8fafc; }
.button-sm { min-height: 32px; padding: 0 11px; font-size: 12px; }
.button:disabled { opacity: .55; cursor: wait; }

.stats-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card {
  display: flex;
  min-height: 92px;
  align-items: center;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(24,36,51,.03);
}
.stat-card > div { display: flex; flex-direction: column; }
.stat-card small { color: var(--muted); font-size: 11px; }
.stat-card strong { margin-top: 2px; font-size: 23px; }
.stat-icon { display: grid; width: 42px; height: 42px; flex: 0 0 auto; place-items: center; border-radius: 6px; font-weight: 800; }
.stat-icon.blue { color: #206bc4; background: #e9f2fc; }
.stat-icon.green { color: #2b8a3e; background: #eaf7ec; }
.stat-icon.azure { color: #1098ad; background: #e5f8fb; }
.stat-icon.orange { color: #e67700; background: #fff4e0; }
.stat-icon.purple { color: #9c36b5; background: #f6eafa; }

.card { position: relative; margin-bottom: 20px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); box-shadow: 0 1px 2px rgba(24,36,51,.035); }
.card-header { display: flex; min-height: 66px; align-items: center; justify-content: space-between; gap: 20px; padding: 15px 20px; border-bottom: 1px solid var(--border); }
.card-header h2 { margin: 0; font-size: 17px; }
.card-header p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.card-body { padding: 22px 20px; }
.card-status-top { position: absolute; inset: -1px -1px auto; height: 3px; border-radius: 7px 7px 0 0; background: var(--green); }
.verify-card .card-body { max-width: 880px; }

label { display: block; margin-bottom: 7px; font-size: 12px; font-weight: 700; }
.input-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid #b8c1cc;
  border-radius: 5px;
  color: var(--ink);
  background: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 600;
  outline: none;
}
input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(32,107,196,.14); }
.form-hint { margin: 7px 0 0; color: var(--muted); font-size: 11px; }
.link-button { margin-top: 13px; padding: 0; border: 0; color: var(--primary); background: transparent; font-size: 12px; font-weight: 600; cursor: pointer; }

.captcha-box { display: inline-flex; margin: 3px 0 15px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 5px; background: #f8fafc; }
.captcha-box img { display: block; min-width: 120px; min-height: 38px; max-width: min(100%, 360px); }
.loading-state { display: flex; align-items: center; gap: 9px; margin-top: 16px; color: var(--muted); font-size: 12px; }
.spinner { width: 16px; height: 16px; border: 2px solid #cbd2da; border-top-color: var(--primary); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.alert { margin: 0 0 16px; padding: 11px 13px; border: 1px solid; border-radius: 5px; font-size: 12px; line-height: 1.45; }
.alert-danger { color: #a92d2d; border-color: #f1c0c0; background: #fff0f0; }
.alert-info { color: #145a8d; border-color: #bddbf3; background: #edf7ff; }

.result-header { align-items: flex-start; }
.result-header h2 { margin: 5px 0; font-size: 22px; }
.green-text { color: var(--green); }
.mono { color: #546170; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.classification { min-width: 170px; padding: 12px 16px; border-radius: 6px; color: #237a35; background: #eaf7ec; }
.classification span { display: block; margin-bottom: 2px; font-size: 10px; font-weight: 700; }
.classification strong { font-size: 22px; }
.result-actions { display: flex; gap: 9px; margin-bottom: 4px; }
.certificate-details:empty { display: none; }
.certificate-section { margin-top: 24px; }
.certificate-section h2, .certificate-section h3 { margin: 0 0 9px; font-size: 15px; }
.detail-table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: 5px; background: #fff; }
.certificate-table, .key-value-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.certificate-table { min-width: 850px; }
.certificate-table th, .certificate-table td, .key-value-table th, .key-value-table td { padding: 9px 11px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; line-height: 1.45; overflow-wrap: anywhere; }
.certificate-table th { min-width: 95px; color: #52606f; background: #f5f7fa; font-size: 10px; letter-spacing: .03em; text-transform: uppercase; }
.certificate-table td { min-width: 105px; }
.key-value-table { table-layout: fixed; }
.key-value-table th { width: 34%; color: #52606f; background: #f7f9fb; }
.certificate-table tr:last-child td, .key-value-table tr:last-child th, .key-value-table tr:last-child td { border-bottom: 0; }

.badge { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 4px; font-size: 10px; font-weight: 700; }
.badge-green { color: #237a35; background: #eaf7ec; }
.badge-blue { color: #1a5b9e; background: #e9f2fc; }
.record-count { color: var(--muted); font-size: 11px; }
.record-count strong { color: var(--ink); }
.table-responsive { overflow-x: auto; }
.data-table { width: 100%; min-width: 850px; border-collapse: collapse; font-size: 12px; }
.data-table th, .data-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.data-table th { color: var(--muted); background: #f8fafc; font-size: 10px; letter-spacing: .05em; text-transform: uppercase; }
.data-table tbody tr:hover { background: #fafbfd; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.actions-column { text-align: right !important; }
.table-action { display: block; font-weight: 600; text-align: right; text-decoration: none; white-space: nowrap; }
.empty-state { padding: 34px !important; color: var(--muted); text-align: center !important; }
.disclaimer { padding: 13px 15px; border: 1px solid var(--border); border-radius: 6px; color: var(--muted); background: #fff; font-size: 11px; line-height: 1.5; }
.disclaimer strong { color: var(--ink); }
.page-body > footer { padding: 24px 2px 0; color: #84909d; font-size: 11px; }
.sidebar-overlay { display: none; }

.login-page { display: grid; place-items: center; padding: 24px; background: #f2f5f9; }
.login-shell { width: min(410px, 100%); }
.login-card { padding: 32px; border: 1px solid var(--border); border-radius: 8px; background: #fff; box-shadow: 0 8px 24px rgba(24,36,51,.08); }
.login-card .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 30px; color: var(--ink); font-size: 16px; font-weight: 700; text-decoration: none; }
.login-card h1 { margin: 5px 0 8px; font-size: 24px; }
.login-card .intro, .security-note { color: var(--muted); font-size: 12px; line-height: 1.5; }
.login-form { margin-top: 24px; }
.login-form input { margin-bottom: 16px; font-family: inherit; font-weight: 400; }
.login-form .button, .login-form button { width: 100%; min-height: 40px; border: 0; border-radius: 5px; color: #fff; background: var(--primary); font-weight: 600; cursor: pointer; }
.security-note { margin: 20px 0 0; }

.report-page { padding: 30px 20px; background: #edf1f5; }
.report-shell { width: min(1180px, 100%); margin: 0 auto; }
.report-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 15px; margin-bottom: 18px; }
.report-toolbar > div { display: flex; gap: 8px; }
.report-paper { padding: 34px 40px; border: 1px solid var(--border); background: #fff; box-shadow: 0 2px 10px rgba(24,36,51,.06); }
.report-header { display: flex; align-items: center; justify-content: space-between; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.report-brand { min-height: auto; padding: 0; color: var(--ink); }
.report-brand strong { color: var(--ink); }
.report-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 28px 0 22px; }
.report-title h1 { margin: 5px 0 7px; font-size: 28px; }
.report-meta-grid { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--border); border-radius: 5px; }
.report-meta-grid > div { display: flex; min-height: 66px; flex-direction: column; padding: 13px 15px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.report-meta-grid > div:nth-child(3n) { border-right: 0; }
.report-meta-grid > div:nth-last-child(-n+3) { border-bottom: 0; }
.report-meta-grid small { margin-bottom: 5px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.report-meta-grid strong { font-size: 12px; overflow-wrap: anywhere; }
.report-footer { display: flex; justify-content: space-between; gap: 20px; margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: 11px; }

@media (max-width: 1050px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 820px) {
  .app-sidebar { transform: translateX(-100%); transition: transform .2s; }
  body.sidebar-open .app-sidebar { transform: translateX(0); }
  .sidebar-overlay { position: fixed; inset: 0; z-index: 25; background: rgba(24,36,51,.45); }
  body.sidebar-open .sidebar-overlay { display: block; }
  .app-shell { margin-left: 0; }
  .menu-button { display: block; }
  .topbar { padding: 0 16px; }
  .topbar-title { display: none; }
  .page-body { width: min(100% - 28px, 1380px); padding-top: 22px; }
  .page-header { align-items: flex-start; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .report-meta-grid { grid-template-columns: repeat(2, 1fr); }
  .report-meta-grid > div, .report-meta-grid > div:nth-child(3n) { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
  .report-meta-grid > div:nth-child(2n) { border-right: 0; }
  .report-meta-grid > div:nth-last-child(-n+2) { border-bottom: 0; }
}

@media (max-width: 560px) {
  .user-copy { display: none; }
  .page-header { flex-direction: column; }
  .page-header .button { width: 100%; }
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { min-height: 76px; }
  .input-row { grid-template-columns: 1fr; }
  .card-header, .result-header { align-items: flex-start; flex-direction: column; }
  .classification { width: 100%; }
  .result-actions { flex-direction: column; }
  .report-page { padding: 0; }
  .report-toolbar { padding: 12px; flex-direction: column; align-items: stretch; }
  .report-toolbar > div { flex-direction: column; }
  .report-paper { padding: 22px 16px; border-inline: 0; }
  .report-title { flex-direction: column; }
  .report-meta-grid { grid-template-columns: 1fr; }
  .report-meta-grid > div, .report-meta-grid > div:nth-child(2n), .report-meta-grid > div:nth-child(3n) { border-right: 0; border-bottom: 1px solid var(--border); }
  .report-meta-grid > div:last-child { border-bottom: 0; }
}

@media print {
  @page { size: A4 landscape; margin: 10mm; }
  .report-page { padding: 0; background: #fff; }
  .report-toolbar { display: none; }
  .report-paper { padding: 0; border: 0; box-shadow: none; }
  .certificate-section { break-inside: avoid; }
  .detail-table-wrap { overflow: visible; }
  .certificate-table { min-width: 0; font-size: 8px; }
  .certificate-table th, .certificate-table td, .key-value-table th, .key-value-table td { padding: 5px 6px; }
  a { color: inherit; text-decoration: none; }
}
