:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1f2933;
  --muted: #667085;
  --line: #d9dee7;
  --primary: #176b87;
  --primary-dark: #104e63;
  --accent: #c77700;
  --danger: #b42318;
  --success: #147a49;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  font-size: 15px;
}

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

a:hover {
  text-decoration: underline;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 58px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

.brand {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  white-space: nowrap;
}

.nav {
  display: flex;
  flex: 1;
  gap: 8px;
  overflow-x: auto;
}

.nav a {
  color: var(--text);
  padding: 8px 10px;
  border-radius: 6px;
  white-space: nowrap;
}

.nav a:hover {
  background: #edf3f6;
  text-decoration: none;
}

.logout {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  white-space: nowrap;
}

.container {
  width: min(1180px, calc(100% - 32px));
  margin: 26px auto 48px;
}

.page-head,
.preview-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 18px;
}

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

h1 {
  margin-bottom: 6px;
  font-size: 28px;
}

h2 {
  font-size: 18px;
}

h3 {
  margin-top: 24px;
  font-size: 15px;
}

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

.panel,
.stat-card,
.login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
  margin-bottom: 18px;
}

.narrow-panel {
  max-width: 520px;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px;
  color: var(--text);
}

.stat-card:hover {
  text-decoration: none;
  border-color: var(--primary);
}

.stat-card span {
  color: var(--muted);
}

.stat-card strong {
  font-size: 28px;
}

.quick-search form,
.filter-bar,
.inline-form {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.quick-search input,
.filter-bar input,
.filter-bar select,
.inline-form input,
.grid-form input,
.grid-form select,
.grid-form textarea,
.stack-form input,
.stack-form select,
.stack-form textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.quick-search input {
  flex: 1;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}

button:hover,
.button:hover {
  border-color: var(--primary);
  text-decoration: none;
}

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

.primary:hover {
  background: var(--primary-dark);
  color: #fff;
}

.ghost {
  background: #f9fafb;
}

.small {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 13px;
}

.mini {
  min-height: 26px;
  padding: 3px 7px;
  font-size: 12px;
}

.danger {
  border-color: #fecdca;
  background: #fff3f2;
  color: var(--danger);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

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

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

.strong-link {
  color: var(--text);
  font-weight: 650;
}

.muted {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.actions,
.head-actions,
.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
}

.status-effective {
  background: #ecfdf3;
  color: var(--success);
}

.status-obsolete {
  background: #fff3f2;
  color: var(--danger);
}

.status-history,
.status-draft {
  background: #fff7e6;
  color: var(--accent);
}

.empty {
  padding: 34px;
  text-align: center;
  color: var(--muted);
}

.compact {
  padding: 14px;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.meta-list {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 10px 14px;
  margin: 0;
}

.meta-list dt {
  color: var(--muted);
}

.meta-list dd {
  margin: 0;
  word-break: break-word;
}

.link-list,
.pill-list {
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.link-list li,
.pill-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.link-list span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.pill-list li {
  justify-content: flex-start;
}

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

.grid-form label,
.stack-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

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

.stack-form {
  display: grid;
  gap: 14px;
}

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

.check-row {
  display: flex !important;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px !important;
  color: var(--text) !important;
}

.check-row input {
  width: auto;
  min-height: auto;
}

.login-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
  background: linear-gradient(180deg, #eef5f7 0%, #f8fafc 100%);
}

.login-panel {
  width: min(420px, 100%);
  padding: 28px;
}

.login-panel h1 {
  font-size: 25px;
}

.alert {
  margin-bottom: 14px;
  padding: 10px;
  border: 1px solid #fecdca;
  border-radius: 6px;
  background: #fff3f2;
  color: var(--danger);
}

.success {
  margin-bottom: 14px;
  padding: 10px;
  border: 1px solid #abefc6;
  border-radius: 6px;
  background: #ecfdf3;
  color: var(--success);
}

.hint {
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.pdf-frame-wrap {
  height: calc(100vh - 150px);
  min-height: 580px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.pdf-frame {
  width: 100%;
  height: 100%;
  border: 0;
}

.image-preview-wrap {
  display: grid;
  min-height: 580px;
  place-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.image-preview-wrap img {
  width: auto;
  max-width: 100%;
  max-height: calc(100vh - 180px);
  object-fit: contain;
}

.file-preview-fallback {
  max-width: 720px;
}

@media (max-width: 860px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
  }

  .nav {
    width: 100%;
  }

  .logout {
    width: 100%;
    justify-content: space-between;
  }

  .container {
    width: min(100% - 20px, 1180px);
    margin-top: 18px;
  }

  .page-head,
  .preview-head,
  .quick-search form,
  .filter-bar,
  .inline-form {
    flex-direction: column;
  }

  .stats-grid,
  .detail-grid,
  .grid-form {
    grid-template-columns: 1fr;
  }

  .wide {
    grid-column: auto;
  }

  h1 {
    font-size: 24px;
  }

  .pdf-frame-wrap {
    height: calc(100vh - 230px);
    min-height: 460px;
  }
}
