:root {
  color-scheme: light;
  --page: #f5f7f6;
  --surface: #ffffff;
  --surface-subtle: #f0f3f2;
  --ink: #18221f;
  --muted: #68736f;
  --faint: #8d9692;
  --border: #dce2df;
  --border-strong: #c8d0cc;
  --primary: #176b55;
  --primary-hover: #105844;
  --primary-soft: #e8f3ef;
  --amber: #a96312;
  --amber-soft: #fff4df;
  --blue: #29688a;
  --blue-soft: #e8f3f8;
  --danger: #a63d3d;
  --danger-hover: #8e3030;
  --danger-soft: #fbecec;
  --sidebar: #1d2925;
  --sidebar-muted: #aebbb6;
  --shadow-dialog: 0 24px 60px rgba(20, 34, 29, 0.18);
  --focus: 0 0 0 3px rgba(23, 107, 85, 0.2);
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  letter-spacing: 0;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--page);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--page);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  color: inherit;
  font: inherit;
  letter-spacing: 0;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3,
strong {
  overflow-wrap: anywhere;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.25;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.35;
  letter-spacing: 0;
}

svg {
  display: block;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  stroke-width: 1.8;
}

[hidden] {
  display: none !important;
}

.shell {
  width: min(100% - 40px, 1160px);
  margin-inline: auto;
}

.sr-only,
.visually-hidden-heading {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 8px 12px;
  color: #ffffff;
  background: var(--primary);
  border-radius: 6px;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.topbar {
  height: 64px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border);
}

.topbar-inner,
.login-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  gap: 20px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: 17px;
  font-weight: 720;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  color: #ffffff;
  background: var(--primary);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quiet-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.quiet-link:hover {
  color: var(--ink);
}

.button,
.icon-button,
.input-icon-button,
.admin-nav-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.button {
  min-height: 40px;
  padding: 8px 15px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 680;
  line-height: 1.2;
}

.button-primary {
  color: #ffffff;
  background: var(--primary);
}

.button-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.button-secondary {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--border-strong);
}

.button-secondary:hover:not(:disabled) {
  background: var(--surface-subtle);
}

.button-danger {
  color: #ffffff;
  background: var(--danger);
}

.button-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.button:disabled,
.icon-button:disabled,
.input-icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.button-full {
  width: 100%;
}

.icon-button,
.input-icon-button {
  width: 40px;
  height: 40px;
  padding: 0;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  flex: 0 0 auto;
}

.icon-button:hover:not(:disabled),
.input-icon-button:hover:not(:disabled) {
  color: var(--ink);
  background: var(--surface-subtle);
}

.input-icon-button {
  width: 36px;
  height: 36px;
  background: transparent;
  border-color: transparent;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 780;
  line-height: 1.2;
  letter-spacing: 0;
}

.state-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  min-height: 180px;
  padding: 30px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: left;
}

.state-panel > svg {
  width: 24px;
  height: 24px;
}

.state-panel > div {
  display: grid;
  gap: 3px;
}

.state-panel strong {
  color: var(--ink);
  font-size: 15px;
}

.state-panel span {
  font-size: 13px;
}

.state-panel .button {
  margin-left: 8px;
}

.state-error > svg {
  color: var(--danger);
}

.state-empty > svg {
  color: var(--faint);
}

.spin {
  animation: spin 900ms linear infinite;
}

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

.table-frame {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.data-table th,
.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.data-table th {
  height: 44px;
  padding-top: 10px;
  padding-bottom: 10px;
  color: var(--muted);
  background: #fafbfb;
  font-size: 12px;
  font-weight: 680;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover {
  background: #fbfcfc;
}

.catalog-table th:nth-child(1) { width: 46%; }
.catalog-table th:nth-child(2) { width: 11%; }
.catalog-table th:nth-child(3) { width: 12%; }
.catalog-table th:nth-child(4) { width: 13%; }
.catalog-table th:nth-child(5) { width: 18%; text-align: right; }
.catalog-table td:last-child { text-align: right; }

.item-name {
  display: block;
  margin-bottom: 3px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 680;
}

.item-path,
.secondary-text {
  display: block;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 680;
  line-height: 1.2;
  white-space: nowrap;
}

.status-healthy,
.status-approved {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: #cce4db;
}

.status-unknown,
.status-pending {
  color: var(--amber);
  background: var(--amber-soft);
  border-color: #f0d9ad;
}

.status-invalid,
.status-missing,
.status-rejected {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: #efcaca;
}

.site-footer {
  min-height: 64px;
  color: var(--muted);
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  gap: 20px;
  font-size: 12px;
}

.dialog {
  width: min(calc(100% - 32px), 520px);
  max-height: min(760px, calc(100vh - 32px));
  margin: auto;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-dialog);
}

.dialog-small {
  width: min(calc(100% - 32px), 460px);
}

.dialog::backdrop {
  background: rgba(20, 29, 26, 0.52);
}

.dialog-content {
  display: grid;
  gap: 20px;
  padding: 24px;
}

.dialog-header {
  align-items: flex-start;
}

.dialog-actions,
.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.form-field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.form-field label,
.settings-form legend {
  color: var(--ink);
  font-size: 13px;
  font-weight: 680;
}

.form-field input,
.form-field textarea,
.form-field select {
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
}

.form-field input,
.form-field select {
  height: 42px;
}

.form-field textarea {
  min-height: 96px;
  line-height: 1.5;
  resize: vertical;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
  border-color: var(--primary);
  box-shadow: var(--focus);
  outline: none;
}

.form-field input[aria-invalid="true"],
.form-field textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

.form-message {
  min-height: 20px;
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.form-message.is-error {
  color: var(--danger);
}

.form-message.is-success {
  color: var(--primary);
}

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 110;
  display: grid;
  width: min(360px, calc(100% - 40px));
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--primary);
  border-radius: 6px;
  box-shadow: 0 12px 32px rgba(20, 34, 29, 0.14);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.toast.is-error {
  border-left-color: var(--danger);
}

@media (max-width: 720px) {
  .shell,
  .login-topbar {
    width: min(100% - 28px, 1160px);
  }

  .desktop-link {
    display: none;
  }

  .public-main {
    min-height: calc(100vh - 116px);
    padding-top: 34px;
    padding-bottom: 48px;
  }

  .catalog-heading {
    align-items: flex-start;
  }

  .catalog-meta {
    max-width: 42%;
  }

  .search-form {
    grid-template-columns: minmax(0, 1fr);
  }

  .search-form > .button {
    width: 100%;
  }

  .state-panel {
    min-height: 150px;
    padding: 24px 18px;
  }

  .table-frame {
    overflow: visible;
    background: transparent;
    border: 0;
    border-radius: 0;
  }

  .data-table,
  .data-table tbody {
    display: block;
    width: 100%;
  }

  .data-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .data-table tbody {
    display: grid;
    gap: 10px;
  }

  .data-table tr {
    display: grid;
    padding: 8px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
  }

  .data-table td {
    display: grid;
    grid-template-columns: minmax(76px, 28%) minmax(0, 1fr);
    gap: 12px;
    width: 100%;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
    text-align: left !important;
  }

  .data-table td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 12px;
    font-weight: 650;
  }

  .data-table td:last-child {
    border-bottom: 0;
  }

  .data-table td[data-label="操作"] {
    align-items: center;
  }

  .data-table td[data-label="操作"] .button,
  .data-table td[data-label="操作"] .row-actions {
    width: 100%;
  }

  .data-table td[data-label="操作"] .row-actions .button {
    flex: 1 1 0;
  }


  .dialog-content {
    padding: 20px;
  }
}

@media (max-width: 460px) {
  h1 {
    font-size: 24px;
  }

  .topbar .button-secondary {
    width: 40px;
    padding: 0;
  }

  .topbar .button-secondary span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .catalog-heading {
    display: block;
  }

  .catalog-meta {
    max-width: none;
    margin-top: 10px;
    text-align: left;
  }

  .results-toolbar {
    margin-top: 22px;
  }

  .state-panel {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .state-panel .button {
    width: 100%;
    margin: 8px 0 0;
  }


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

  .dialog-actions .button {
    width: 100%;
  }

  .toast-region {
    right: 14px;
    bottom: 14px;
    width: calc(100% - 28px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
