:root {
  color-scheme: light;
  --ink: #16201f;
  --muted: #66736f;
  --line: #d9e1dd;
  --surface: #ffffff;
  --soft: #f4f7f4;
  --teal: #04746f;
  --green: #18865b;
  --amber: #b6710b;
  --red: #b93d35;
  --navy: #22304a;
  --shadow: 0 18px 48px rgba(22, 32, 31, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--soft);
  font-family: "Inter", "Segoe UI", Arial, "Microsoft YaHei", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.link-btn {
  border: 0;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  min-height: 44px;
  padding: 0 16px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

button:hover,
.link-btn:hover {
  filter: brightness(0.96);
}

.ghost-btn {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}

.hidden {
  display: none !important;
}

.eyebrow {
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 4px;
}

.seal {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--teal);
  color: #fff;
  font-weight: 900;
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.16);
}

.public-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 16% 12%, rgba(4, 116, 111, 0.16), transparent 28%),
    linear-gradient(145deg, #eef5ef 0%, #fbfaf5 52%, #e8f2f1 100%);
}

.home-page {
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(4, 116, 111, 0.12), transparent 34%),
    linear-gradient(145deg, #f4f7f4 0%, #ffffff 54%, #e7f1ee 100%);
}

.home-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.home-hero {
  width: min(100%, 720px);
  text-align: center;
  padding: clamp(30px, 7vw, 64px) 20px;
}

.home-hero .seal {
  margin: 0 auto 18px;
}

.home-hero h1 {
  margin: 0;
  font-size: clamp(40px, 10vw, 78px);
  line-height: 1;
}

.home-copy {
  color: var(--muted);
  font-size: clamp(16px, 3vw, 20px);
  line-height: 1.8;
  margin: 22px auto 0;
  max-width: 620px;
}

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

.home-actions a {
  min-height: 46px;
  min-width: 132px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-weight: 900;
  text-decoration: none;
  padding: 0 18px;
}

.home-actions a.secondary {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}

.login-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 10%, rgba(4, 116, 111, 0.16), transparent 28%),
    linear-gradient(145deg, #eef5ef 0%, #ffffff 56%, #e8f2f1 100%);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: min(100%, 430px);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 26px;
}

.login-card h1 {
  margin: 0;
  font-size: 32px;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.login-form label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.login-form input {
  margin-top: 6px;
}

.login-message {
  color: var(--muted);
  line-height: 1.6;
  margin: 16px 0 0;
}

.verify-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.verify-card {
  width: min(100%, 760px);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(217, 225, 221, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(22px, 5vw, 38px);
}

.brand-row,
.result-head,
.admin-brand,
.admin-header,
.panel-head {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-row h1,
.admin-header h1 {
  margin: 0;
  font-size: clamp(26px, 6vw, 42px);
  line-height: 1.05;
}

.state-panel {
  margin-top: 28px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.state-panel.success {
  border-color: rgba(24, 134, 91, 0.32);
  background: #effaf4;
}

.state-panel.warning {
  border-color: rgba(182, 113, 11, 0.32);
  background: #fff7e8;
}

.state-panel.error {
  border-color: rgba(185, 61, 53, 0.32);
  background: #fff0ef;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid rgba(4, 116, 111, 0.2);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}

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

.product-panel {
  margin-top: 22px;
}

.result-head {
  align-items: flex-start;
}

.result-head h2 {
  margin: 0 0 6px;
  font-size: clamp(24px, 5vw, 34px);
}

.result-head p {
  margin: 0;
  color: var(--muted);
}

.badge {
  min-width: 72px;
  min-height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--green);
  color: #fff;
  font-weight: 900;
}

.badge.bad {
  background: var(--red);
}

.badge.warn {
  background: var(--amber);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 24px;
}

.info-grid div,
.metric-grid article {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 14px;
}

.info-grid span,
.metric-grid span,
.trace-line small {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.info-grid strong {
  overflow-wrap: anywhere;
}

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

.trace-line div {
  position: relative;
  padding: 14px 14px 14px 44px;
  border-radius: 8px;
  background: #eef7f4;
}

.trace-line span {
  position: absolute;
  left: 14px;
  top: 17px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(24, 134, 91, 0.16);
}

.description {
  line-height: 1.7;
  color: #34413e;
}

.scan-history {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.scan-history summary {
  cursor: pointer;
  font-weight: 800;
}

.scan-history p {
  margin: 10px 0 0;
  color: var(--muted);
}

.manual-form {
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.manual-form label {
  display: block;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 8px;
}

.manual-form div {
  display: flex;
  gap: 10px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 46px;
  padding: 9px 11px;
}

textarea {
  resize: vertical;
}

.admin-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
  background: #f5f6f2;
}

.sidebar {
  min-height: 100vh;
  padding: 22px;
  background: #172423;
  color: #fff;
  position: sticky;
  top: 0;
}

.admin-brand {
  margin-bottom: 28px;
}

.admin-brand strong,
.admin-brand span {
  display: block;
}

.admin-brand span {
  color: #b8c6c1;
  font-size: 13px;
}

.tabs {
  display: grid;
  gap: 8px;
}

.tab {
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #dfe8e4;
}

.tab.active {
  background: #f4f7f4;
  color: var(--ink);
}

.public-link {
  display: block;
  margin-top: 24px;
  color: #f5d88d;
  text-decoration: none;
  font-weight: 800;
}

.admin-main {
  padding: 28px;
  min-width: 0;
}

.admin-header {
  justify-content: space-between;
  margin-bottom: 22px;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.admin-header h1 {
  font-size: clamp(26px, 4vw, 40px);
}

.compact-head {
  align-items: flex-start;
}

.compact-head p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric-grid strong {
  display: block;
  font-size: 30px;
}

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(22, 32, 31, 0.06);
  padding: 18px;
  margin-bottom: 16px;
}

.primary-panel {
  border-color: rgba(4, 116, 111, 0.28);
  box-shadow: 0 14px 34px rgba(4, 116, 111, 0.1);
}

.panel-head {
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel h2 {
  margin: 0;
  font-size: 18px;
}

.split-panel {
  display: grid;
  grid-template-columns: minmax(280px, 430px) 1fr;
  gap: 20px;
  align-items: start;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.form-grid label,
.inline-form label,
.bind-form label,
.import-form label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.form-details {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.form-details summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 900;
  min-height: 34px;
  display: flex;
  align-items: center;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding-top: 10px;
}

.form-grid label input,
.form-grid label select,
.form-grid label textarea,
.inline-form label input,
.bind-form label input,
.import-form label input {
  margin-top: 6px;
}

.wide {
  grid-column: 1 / -1;
}

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

.record-list {
  display: grid;
  gap: 10px;
}

.record-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.record-item header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.record-item h3 {
  margin: 0;
  font-size: 16px;
}

.record-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.record-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.record-actions button {
  min-height: 40px;
  padding: 0 10px;
}

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

.quick-card {
  min-height: 96px;
  align-items: flex-start;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  text-align: left;
}

.quick-card strong {
  font-size: 17px;
}

.quick-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.inline-form,
.bind-form,
.import-form {
  display: grid;
  grid-template-columns: 130px 120px minmax(160px, 1fr) auto auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}

.bind-form {
  grid-template-columns: repeat(2, minmax(180px, 1fr)) auto;
  margin: 0;
}

.import-form {
  grid-template-columns: minmax(220px, 1fr) auto auto;
}

.import-result {
  border-radius: 8px;
  background: #f8faf7;
  border: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.6;
  padding: 12px;
}

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

.summary-grid span {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-weight: 800;
  padding: 9px 10px;
}

.import-errors {
  margin: 10px 0 0;
  padding-left: 20px;
  color: var(--amber);
}

.large-action {
  min-height: 48px;
}

.bind-result {
  margin-top: 16px;
  padding: 14px;
  border-radius: 8px;
  background: #eef7f4;
  color: #17453a;
  min-height: 52px;
}

.search {
  max-width: 320px;
}

.table-wrap {
  overflow: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 13px;
  background: #f8faf7;
}

td {
  font-size: 14px;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  background: #e8f3ef;
  color: #185946;
  font-weight: 800;
  font-size: 12px;
}

.status-pill.warn {
  background: #fff2d6;
  color: #7a4c08;
}

.status-pill.bad {
  background: #ffe5e2;
  color: #8f271f;
}

.mono {
  font-family: "Cascadia Mono", Consolas, monospace;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #172423;
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1100px) {
  .admin-page {
    grid-template-columns: 1fr;
    padding-bottom: 82px;
  }

  .sidebar {
    min-height: 0;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 20;
    padding: 8px 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
  }

  .admin-brand,
  .public-link {
    display: none;
  }

  .tabs {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
  }

  .tab {
    min-height: 52px;
    justify-content: center;
    padding: 0 8px;
  }

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

  .split-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .verify-shell,
  .admin-main {
    padding: 16px;
  }

  .admin-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(245, 246, 242, 0.96);
    padding: 12px 0;
    margin: -16px 0 14px;
  }

  .admin-header h1 {
    font-size: 25px;
  }

  .manual-form div,
  .brand-row,
  .admin-header {
    align-items: stretch;
  }

  .manual-form div,
  .admin-header,
  .result-head {
    flex-direction: column;
  }

  .header-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .info-grid,
  .trace-line,
  .metric-grid,
  .form-grid,
  .details-grid,
  .inline-form,
  .bind-form,
  .import-form,
  .quick-grid {
    grid-template-columns: 1fr;
  }

  .search {
    max-width: none;
  }

  .panel {
    padding: 14px;
    margin-bottom: 12px;
  }

  .panel-head {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .form-actions,
  .record-actions,
  .row-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .form-actions button,
  .record-actions button,
  .row-actions button,
  .link-btn {
    width: 100%;
  }

  table,
  thead,
  tbody,
  tr,
  td {
    display: block;
  }

  table {
    min-width: 0;
  }

  thead {
    display: none;
  }

  tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 10px;
    padding: 8px 10px;
    background: #fff;
  }

  td {
    border-bottom: 0;
    padding: 8px 0;
  }

  td::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 4px;
  }

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

  .metric-grid article {
    padding: 12px;
  }

  .metric-grid strong {
    font-size: 26px;
  }

  .bind-result {
    font-size: 15px;
    line-height: 1.6;
  }

  .home-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .home-actions a {
    width: 100%;
  }

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