:root {
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #eff4ff;
  --text: #111111;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg: #ffffff;
  --bg-alt: #f7f7f8;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(17, 17, 17, 0.04), 0 4px 16px rgba(17, 17, 17, 0.04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1, h2, h3, h4 {
  margin: 0 0 0.5em;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.01em;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.15rem; }

p {
  margin: 0 0 1em;
}

img {
  max-width: 100%;
  height: auto;
}

code, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
}

pre {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  overflow-x: auto;
}

/* ---------- Layout ---------- */
.container {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

.narrow {
  max-width: 720px;
}

.muted {
  color: var(--muted);
}

main {
  display: block;
  min-height: 60vh;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 64px;
  flex-wrap: wrap;
}

.logo {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.logo:hover {
  text-decoration: none;
}

.logo span {
  color: var(--accent);
}

.nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  flex-wrap: wrap;
}

.nav a {
  color: var(--muted);
  font-size: 0.95rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  white-space: nowrap;
}

.nav a:hover {
  color: var(--text);
  background: var(--bg-alt);
  text-decoration: none;
}

.nav a.active {
  color: var(--accent);
  font-weight: 600;
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  white-space: nowrap;
}

.lang-switch a {
  color: var(--muted);
  text-decoration: none;
}

.lang-switch a:hover {
  color: var(--text);
}

.lang-switch a.active {
  color: var(--accent);
  font-weight: 600;
}

.lang-switch .sep {
  color: var(--border);
}

/* ---------- Hero ---------- */
.hero {
  padding: 96px 0 80px;
  background:
    radial-gradient(1200px 400px at 50% -100px, var(--accent-soft), transparent 70%),
    var(--bg);
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.hero h1 {
  font-size: 3rem;
  max-width: 820px;
  margin: 0 auto 0.4em;
}

.hero-lead {
  font-size: 1.2rem;
  color: var(--muted);
  max-width: 680px;
  margin: 0 auto 2em;
}

.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

.demo-line {
  margin-top: 24px;
  font-size: 0.95rem;
}

.demo-line a {
  margin-left: 6px;
}

/* ---------- Sections ---------- */
.section {
  padding: 72px 0;
}

.section-alt {
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.section-head {
  text-align: center;
  max-width: 680px;
  margin: 0 auto 40px;
}

.section-head h2 {
  margin-bottom: 0.3em;
}

.section-title {
  font-size: 1.25rem;
  margin: 0 0 16px;
}

.page-head {
  padding: 56px 0 32px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 40px;
}

.page-head h1 {
  margin-bottom: 0.2em;
}

.page-head p {
  color: var(--muted);
  margin: 0;
  max-width: 720px;
}

/* ---------- Grid ---------- */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.card h3 {
  margin-bottom: 0.4em;
}

.card p:last-child {
  margin-bottom: 0;
}

.feature h3 {
  font-size: 1.05rem;
}

.product {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.product h3 {
  margin: 0;
}

.product p {
  margin: 0;
  flex: 1;
}

.product .btn {
  align-self: flex-start;
  margin-top: 8px;
}

.tag {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 10px;
  letter-spacing: 0.02em;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.btn-ghost {
  background: var(--bg);
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover {
  border-color: #cbd5e1;
  background: var(--bg-alt);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
}

.btn-small {
  font-size: 0.85rem;
  padding: 6px 12px;
}

/* ---------- Forms ---------- */
.form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 0.9rem;
  font-weight: 600;
}

.field input,
.field select,
.field textarea {
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.field textarea {
  min-height: 120px;
  resize: vertical;
}

.field .hint {
  font-size: 0.8rem;
  color: var(--muted);
}

.req {
  color: var(--danger);
  margin-left: 2px;
}

.form-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 4px;
}

.form-inline {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.form-inline .field {
  flex: 1;
  min-width: 160px;
}

.inline-form {
  display: inline;
  margin: 0;
}

/* ---------- Messages ---------- */
.flash {
  background: var(--accent-soft);
  border: 1px solid #c7d7fe;
  color: var(--accent-dark);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 24px;
  font-size: 0.95rem;
}

.flash-error {
  background: var(--danger-soft);
  border-color: #fecaca;
  color: var(--danger);
}

.success {
  background: var(--success-soft);
  border: 1px solid #bbf7d0;
  color: var(--success);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 24px;
}

.errors {
  background: var(--danger-soft);
  border: 1px solid #fecaca;
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 12px 16px 12px 32px;
  margin: 0 0 24px;
}

.errors li {
  margin: 2px 0;
}

/* ---------- Prose / steps ---------- */
.prose {
  max-width: 760px;
}

.prose h2 {
  margin-top: 1.6em;
}

.prose h2:first-child {
  margin-top: 0;
}

.prose ul,
.prose ol {
  padding-left: 1.4em;
}

.prose li {
  margin: 0.35em 0;
}

.steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin: 32px 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.step {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 10px;
}

.step h3 {
  font-size: 1rem;
  margin-bottom: 0.3em;
}

.step p {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0;
}

/* ---------- Result / check ---------- */
.result {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.result h2 {
  margin-bottom: 0.6em;
}

.detail-meta {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 10px 20px;
  margin: 0;
}

.detail-meta dt {
  color: var(--muted);
  font-size: 0.9rem;
}

.detail-meta dd {
  margin: 0;
  font-weight: 500;
  word-break: break-word;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.4;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-pending {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: #fde68a;
}

.badge-active {
  background: var(--success-soft);
  color: var(--success);
  border-color: #bbf7d0;
}

.badge-expired {
  background: #f3f4f6;
  color: #4b5563;
  border-color: #d1d5db;
}

.badge-rejected {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #fecaca;
}

.badge-revoked {
  background: #faf5ff;
  color: #7e22ce;
  border-color: #e9d5ff;
}

/* ---------- Tables ---------- */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  background: var(--bg);
}

.table th,
.table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table th {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--bg-alt);
  white-space: nowrap;
}

.table tbody tr:hover {
  background: #fafafa;
}

.table td.num,
.table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.table-wrap .table {
  min-width: 640px;
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.toolbar .field {
  flex: 1;
  min-width: 180px;
}

.toolbar .btn {
  flex: none;
}

/* ---------- Products page ---------- */
.product-group {
  margin-bottom: 48px;
}

.product-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.product-head h2 {
  margin: 0;
}

.product-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

/* ---------- Footer ---------- */
.site-footer {
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
  padding: 48px 0;
  margin-top: 0;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-start;
  justify-content: space-between;
}

.footer-brand {
  max-width: 360px;
}

.footer-brand .logo {
  display: inline-block;
  margin-bottom: 8px;
}

.footer-brand p {
  margin: 0;
  font-size: 0.88rem;
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.9rem;
}

.footer-links a {
  color: var(--muted);
}

.footer-links a:hover {
  color: var(--text);
}

.footer-contact {
  font-size: 0.85rem;
  margin: 0;
  flex-basis: 100%;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ---------- Admin ---------- */
.admin-body {
  background: var(--bg-alt);
}

.admin-wrap {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 232px;
  flex: none;
  background: #111827;
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  gap: 24px;
}

.sidebar-brand {
  font-weight: 800;
  font-size: 1.05rem;
  color: #fff;
  padding: 0 8px;
  letter-spacing: -0.01em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.sidebar-nav a {
  color: #cbd5e1;
  text-decoration: none;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
}

.sidebar-nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-nav a.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.sidebar-logout {
  margin: 0;
}

.sidebar-logout .btn {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  color: #e5e7eb;
  border-color: rgba(255, 255, 255, 0.12);
}

.sidebar-logout .btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.admin-main {
  flex: 1;
  min-width: 0;
  padding: 32px 40px 64px;
}

.admin-main h1 {
  font-size: 1.6rem;
  margin-bottom: 24px;
}

.admin-main h2 {
  font-size: 1.2rem;
  margin: 32px 0 16px;
}

.admin-main .card {
  box-shadow: none;
}

/* ---------- Stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-label {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .grid-3,
  .product-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero h1 {
    font-size: 2.4rem;
  }
}

@media (max-width: 860px) {
  .admin-wrap {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
  }

  .sidebar-brand {
    padding: 0;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    flex: 1;
    gap: 4px;
  }

  .sidebar-nav a {
    padding: 6px 10px;
    font-size: 0.85rem;
  }

  .sidebar-logout {
    flex: none;
  }

  .sidebar-logout .btn {
    width: auto;
  }

  .admin-main {
    padding: 24px 20px 48px;
  }
}

@media (max-width: 720px) {
  .container {
    padding: 0 16px;
  }

  .header-inner {
    gap: 12px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .nav {
    order: 3;
    flex-basis: 100%;
    gap: 2px;
  }

  .nav a {
    padding: 6px 8px;
    font-size: 0.9rem;
  }

  .lang-switch {
    margin-left: auto;
  }

  .hero {
    padding: 64px 0 56px;
  }

  .hero h1 {
    font-size: 1.9rem;
  }

  .hero-lead {
    font-size: 1.05rem;
  }

  .section {
    padding: 48px 0;
  }

  .grid-2,
  .grid-3,
  .product-list,
  .steps,
  .stats {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 20px;
  }

  .detail-meta {
    grid-template-columns: 1fr;
    gap: 2px 0;
  }

  .detail-meta dd {
    margin-bottom: 10px;
  }

  .footer-inner {
    flex-direction: column;
  }

  .form-inline {
    flex-direction: column;
    align-items: stretch;
  }

  .form-inline .btn {
    width: 100%;
  }

  .table-wrap {
    border-radius: var(--radius-sm);
  }
}

.cert { margin: 1.5rem 0; text-align: center; }
.cert img, .cert-img { max-width: 100%; height: auto; border: 1px solid #e5e7eb; border-radius: 6px; }
