:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #17202c;
  --muted: #647083;
  --line: #dce1e8;
  --accent: #1f7a5a;
  --accent-strong: #176044;
  --blue: #3758d1;
  --red: #c73535;
  --amber: #b7791f;
  --shadow: 0 10px 30px rgba(28, 36, 46, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  padding-bottom: 34px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

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

button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button.secondary {
  background: #e8eef5;
  color: var(--text);
}

button.secondary:hover {
  background: #d8e0eb;
}

button.danger {
  background: var(--red);
}

button.ghost-button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}

button.link-button {
  min-height: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font-weight: 700;
}

button.link-button:hover {
  background: transparent;
  color: var(--accent-strong);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
}

textarea {
  min-height: 150px;
  resize: vertical;
}

label span {
  display: block;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(31, 122, 90, 0.10), transparent 38%),
    linear-gradient(300deg, rgba(55, 88, 209, 0.10), transparent 35%),
    var(--bg);
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 0 0 4px;
  font-size: 24px;
}

.error-line {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
}

.app-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #ffffff;
  padding: 18px 14px;
}

.brand {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 0 8px 16px;
  border-bottom: 1px solid var(--line);
}

.brand span {
  color: var(--muted);
  font-size: 12px;
}

#nav {
  display: grid;
  gap: 4px;
  margin-top: 14px;
}

#nav button {
  justify-content: flex-start;
  width: 100%;
  background: transparent;
  color: var(--text);
  text-align: left;
}

#nav button.active {
  background: #e9f4ef;
  color: var(--accent-strong);
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
}

.topbar h2 {
  margin: 0;
  font-size: 20px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

#menuButton {
  display: none;
}

.content {
  min-width: 0;
  padding: 22px;
}

.grid {
  display: grid;
  gap: 14px;
}

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

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

.metric,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 0 rgba(28, 36, 46, 0.04);
}

.metric {
  min-height: 92px;
  padding: 16px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
}

.panel {
  padding: 16px;
}

.panel h3 {
  margin: 0 0 14px;
  font-size: 16px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-bottom: 14px;
}

.toolbar label {
  width: min(220px, 100%);
}

.check-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
}

.check-label input,
td input[type="checkbox"] {
  width: auto;
}

.check-label span {
  margin: 0;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

table.blacklist-table {
  min-width: 1120px;
}

table.isbn-library-table {
  min-width: 1280px;
}

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

th {
  color: var(--muted);
  font-weight: 600;
  background: #f9fafb;
}

.sort-button {
  min-height: 28px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  text-align: left;
}

.sort-button:hover {
  background: transparent;
  color: var(--accent-strong);
}

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

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

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

.admin-access-panel {
  margin-top: 14px;
}

.admin-access-list {
  display: grid;
  gap: 12px;
}

.admin-access-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.admin-access-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-access-head span {
  color: var(--muted);
  font-size: 13px;
}

.access-group h4 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.access-checks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px;
}

.access-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
}

.access-check input {
  width: auto;
}

.access-check span {
  margin: 0;
  color: var(--text);
}

.badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  padding: 0 9px;
  background: #eef2f7;
  color: var(--text);
  font-size: 12px;
}

.badge.good {
  background: #e6f5ee;
  color: var(--accent-strong);
}

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

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

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

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

.json-box {
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111827;
  color: #e5e7eb;
  padding: 14px;
  font: 12px/1.5 Consolas, "Courier New", monospace;
}

.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 8px;
}

.heat-cell {
  min-height: 64px;
  display: grid;
  align-content: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #eef2f7;
}

.heat-cell strong {
  font-size: 14px;
}

.heat-cell span,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.heat-1 {
  background: #e8f5ef;
}

.heat-2 {
  background: #cdebdc;
}

.heat-3 {
  background: #95d6b9;
}

.heat-4 {
  background: #57b88f;
  color: #082317;
}

.heat-5 {
  background: #1f7a5a;
  color: #fff;
}

td textarea {
  min-height: 82px;
}

.cookie-list {
  display: grid;
  gap: 12px;
}

.cookie-item {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.cookie-item-head {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  align-items: end;
  gap: 10px;
}

.cookie-item textarea {
  min-height: 116px;
  font: 12px/1.5 Consolas, "Courier New", monospace;
}

.cookie-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 13px;
}

.site-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-top: 1px solid rgba(220, 225, 232, 0.88);
  background: rgba(255, 255, 255, 0.94);
  color: var(--muted);
  font-size: 12px;
}

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

.site-footer a:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #17202c;
  color: #fff;
  box-shadow: var(--shadow);
  z-index: 30;
}

@media (max-width: 980px) {
  .app-view {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
    position: fixed;
    inset: 64px 0 auto 0;
    z-index: 20;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow);
  }

  .sidebar.open {
    display: block;
  }

  #menuButton {
    display: inline-flex;
    align-items: center;
  }

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

@media (max-width: 640px) {
  .content {
    padding: 14px;
  }

  .topbar {
    padding: 10px 14px;
  }

  .topbar h2 {
    font-size: 18px;
  }

  .top-actions {
    gap: 6px;
  }

  #currentUser {
    display: none;
  }

  .metrics,
  .grid.two-col,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .toolbar label {
    width: 100%;
  }

  .cookie-item-head {
    grid-template-columns: 1fr;
  }
}
