:root {
  --bg: #d6dbe1;
  --bg-alt: #c6ced6;
  --surface: rgba(245, 245, 246, 0.95);
  --surface-strong: #f2f2f4;
  --text: #2d3238;
  --muted: #6a7078;
  --border: rgba(66, 74, 82, 0.14);
  --brand: #3b4a59;
  --brand-hover: #2f3c49;
  --danger: #d64545;
  --shadow: 0 20px 45px rgba(42, 52, 62, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Plus Jakarta Sans", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 10%, var(--bg-alt), transparent 42%),
    radial-gradient(circle at 90% 90%, rgba(120, 130, 140, 0.18), transparent 34%),
    var(--bg);
}

.page {
  min-height: 100vh;
  width: min(1100px, 92vw);
  margin: 0 auto;
  padding: 40px 0;
  display: grid;
  align-items: center;
}

.site-footer {
  width: min(1100px, 92vw);
  margin: 0 auto;
  padding: 6px 0 18px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: inherit;
  font-weight: 700;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.page-center {
  max-width: 640px;
}

.glass-card,
.result-shell,
.admin-header,
.admin-form-card,
.admin-table-card {
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  border-radius: 24px;
}

.glass-card {
  padding: 32px;
}

.logo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

.logo-link {
  display: inline-flex;
  border-radius: 12px;
}

.logo-link:focus-visible {
  outline: 3px solid rgba(59, 74, 89, 0.35);
  outline-offset: 4px;
}

.logo-img {
  width: 130px;
  max-width: 100%;
  cursor: pointer;
}

.logo-name {
  margin: 2px 0 10px;
  text-align: center;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #2a2f35;
}

.home-btn {
  margin-top: 10px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.title {
  margin: 0;
  text-align: center;
  font-size: clamp(1.7rem, 2.2vw, 2.1rem);
}

.subtitle {
  margin-top: 8px;
  margin-bottom: 22px;
  color: var(--muted);
  text-align: center;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.92rem;
  font-weight: 600;
}

.text-input {
  width: 100%;
  height: 46px;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 0 14px;
  background: var(--surface-strong);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 0.22s ease, box-shadow 0.22s ease;
}

.text-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(59, 74, 89, 0.2);
}

.stack-gap-lg {
  display: grid;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 12px;
  height: 44px;
  padding: 0 16px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: transform 0.18s ease, opacity 0.18s ease, background-color 0.18s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

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

.btn-primary:hover {
  background: var(--brand-hover);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

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

.btn-small {
  height: 34px;
  padding: 0 10px;
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
}

.result-shell {
  padding: 30px;
}

.loading-wrap {
  min-height: 280px;
  display: grid;
  place-content: center;
  gap: 14px;
  color: var(--muted);
}

.spinner {
  width: 42px;
  height: 42px;
  border: 4px solid rgba(15, 157, 133, 0.22);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

.certificate-page {
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  animation: fadeIn 0.35s ease;
}

.certificate-header {
  border-bottom: 1px dashed var(--border);
  margin-bottom: 22px;
  padding-bottom: 18px;
}

.verify-pass {
  margin: 0;
  font-size: clamp(1.7rem, 2.2vw, 2.5rem);
}

.verify-subtitle {
  color: var(--muted);
  margin: 10px 0 0;
}

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

.detail-block {
  border: 1px solid var(--border);
  background: rgba(75, 86, 97, 0.05);
  border-radius: 14px;
  padding: 12px;
}

.full-row {
  grid-column: 1 / -1;
}

.detail-label {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 6px;
}

.detail-value {
  font-weight: 700;
}

.badge {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.95rem;
}

.certificate-footer {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}

.centered-content {
  min-height: 280px;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 12px;
}

.error-title {
  margin: 0;
  font-size: 1.5rem;
}

.admin-page {
  align-items: start;
  padding-top: 32px;
  padding-bottom: 32px;
}

.admin-auth {
  max-width: 540px;
  margin: 0 auto;
}

.admin-shell {
  display: grid;
  gap: 18px;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
}

.admin-header-logo {
  justify-content: center;
  margin-bottom: 2px;
}

.admin-logo-small {
  width: 76px;
}

.admin-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.admin-title {
  margin: 0;
}

.admin-form-card,
.admin-table-card {
  padding: 22px;
}

.admin-import-card {
  padding: 22px;
}

.import-help {
  margin: 8px 0 14px;
  color: var(--muted);
  line-height: 1.45;
}

.import-help code {
  background: rgba(75, 86, 97, 0.12);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px 6px;
}

.import-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.import-row .text-input {
  flex: 1 1 360px;
  padding-top: 10px;
}

.import-status {
  margin: 10px 0 0;
  min-height: 22px;
  color: var(--muted);
  font-weight: 600;
}

.import-status.working {
  color: #ca8a04;
}

.import-status.error {
  color: var(--danger);
}

.import-status.success {
  color: var(--brand);
}

.admin-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.table-toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
  align-items: center;
  flex-wrap: wrap;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

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

.select-col {
  width: 56px;
}

.checkbox-cell {
  width: 56px;
}

.checkbox-cell input,
.select-col input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
  cursor: pointer;
}

th {
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.action-cell {
  display: flex;
  gap: 8px;
}

.empty-cell {
  text-align: center;
  color: var(--muted);
}

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 20;
  display: grid;
  gap: 8px;
}

.toast {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  animation: toastIn 0.25s ease;
}

.toast.error {
  border-color: rgba(214, 69, 69, 0.45);
}

.toast.hide {
  opacity: 0;
}

.hidden {
  display: none !important;
}

.reveal-up {
  animation: riseIn 0.45s ease both;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .admin-form-grid {
    grid-template-columns: 1fr;
  }

  .admin-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .table-toolbar {
    flex-direction: column;
  }

  .admin-actions {
    width: 100%;
    justify-content: stretch;
  }

  .admin-actions .btn {
    flex: 1;
  }
}

@media (max-width: 700px) {
  .page {
    width: min(1200px, 94vw);
    padding: 24px 0;
  }

  .glass-card,
  .result-shell,
  .admin-form-card,
  .admin-table-card {
    border-radius: 16px;
    padding: 18px;
  }

  .certificate-grid {
    grid-template-columns: 1fr;
  }

  .certificate-footer {
    justify-content: center;
  }

  .verify-pass {
    font-size: 1.5rem;
  }

  .site-footer {
    padding: 4px 0 14px;
    font-size: 0.82rem;
  }

  .admin-header {
    padding: 16px;
  }

  .admin-title,
  .admin-header .subtitle {
    text-align: center;
  }

  .admin-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .admin-actions .btn {
    width: 100%;
  }

  .table-wrap {
    overflow: visible;
  }

  table {
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0 10px;
  }

  thead {
    display: none;
  }

  tbody,
  tr,
  td {
    display: block;
    width: 100%;
  }

  tr {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-strong);
    padding: 8px 10px;
    box-shadow: 0 8px 20px rgba(42, 52, 62, 0.08);
  }

  td {
    border-bottom: 1px dashed var(--border);
    padding: 8px 6px;
  }

  td:last-child {
    border-bottom: 0;
  }

  td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin-bottom: 3px;
    font-weight: 700;
  }

  td.action-cell {
    display: flex;
    gap: 8px;
    padding-top: 10px;
  }

  td.checkbox-cell {
    display: flex;
    align-items: center;
    min-height: 42px;
  }

  td.action-cell::before {
    display: none;
  }

  td.checkbox-cell::before {
    display: none;
  }

  td.action-cell .btn {
    flex: 1;
  }

  .empty-cell {
    text-align: left;
    border: 0;
    padding: 10px 4px;
  }

  .empty-cell::before {
    display: none;
  }
}
