:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-strong: #eef3fb;
  --text: #16243a;
  --muted: #718096;
  --line: #e0e7ef;
  --green: #2563eb;
  --green-deep: #1d4ed8;
  --amber: #a65f00;
  --red: #b33a31;
  --blue: #0f9f77;
  --shadow: 0 18px 40px rgba(22, 36, 58, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    "Segoe UI",
    Arial,
    sans-serif;
}

body.drawer-open {
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: #fbfcfa;
}

.brand {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
}

.brand h1,
.toolbar h2,
.section-head h3 {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  line-height: 1.25;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.filter-group {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.filter-group label {
  color: #33443a;
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(31, 122, 77, 0.14);
}

.split-controls {
  gap: 10px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
}

.checkbox-row input {
  width: 16px;
  min-height: 16px;
}

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

.province-option {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: #304038;
  font-size: 12px;
  font-weight: 600;
}

.province-option input {
  width: 14px;
  min-height: 14px;
}

.province-empty {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.keyword-entry {
  display: grid;
  grid-template-columns: 1fr 40px;
  gap: 8px;
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 6px;
  background: var(--green);
  color: #fff;
  font-size: 22px;
  line-height: 1;
}

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

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

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #304038;
  font-size: 12px;
}

.tag button {
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: #e7ece8;
  color: #304038;
  line-height: 1;
}

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

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

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

.toolbar h2 {
  font-size: 28px;
  letter-spacing: 0;
}

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

.account-entry-button {
  color: var(--green-deep);
  text-decoration: none;
}

.account-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-height: 32px;
  margin: -4px 0 14px;
  padding: 0;
  border: 0;
  background: transparent;
}

.account-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  margin-right: 2px;
  padding: 0 10px;
  border: 1px solid #d9e4f4;
  border-radius: 999px;
  background: #f7faff;
  color: #40516b;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.account-status::before {
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  background: var(--green);
  content: "";
}

.account-membership-button,
.account-logout-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition:
    background 180ms ease,
    border-color 180ms ease,
    color 180ms ease;
}

.account-membership-button {
  border: 1px solid var(--green);
  background: var(--green);
  color: #fff;
}

.account-membership-button:hover {
  border-color: var(--green-deep);
  background: var(--green-deep);
}

.account-logout-button {
  border: 1px solid #d7e0eb;
  background: transparent;
  color: #52627a;
}

.account-logout-button:hover {
  border-color: #b8c7d9;
  background: #f7f9fc;
  color: var(--text);
}

.account-membership-button:focus-visible,
.account-logout-button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.18);
  outline-offset: 2px;
}

.membership-gate {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  min-height: 0;
  padding: 24px 28px;
  border: 1px solid #cbdaf8;
  border-radius: 8px;
  background: #fff;
}

.membership-gate h3 {
  margin: 0;
  font-size: 19px;
}

.membership-gate p:not(.eyebrow) {
  margin: 9px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.data-status {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.data-status div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
}

.data-status strong {
  font-size: 13px;
}

.data-status span,
.data-status p {
  color: var(--muted);
  font-size: 13px;
}

.data-status p {
  margin: 0;
  text-align: right;
}

.refresh-summary {
  flex: 1 0 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.refresh-summary[hidden] {
  display: none;
}

.refresh-summary span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8faf8;
  color: #40534b;
  font-size: 12px;
}

.refresh-summary.running span:first-child {
  border-color: #b8d6ff;
  background: #eef6ff;
  color: #1d5fa7;
}

.refresh-summary.success span:first-child {
  border-color: #c5dfce;
  background: #eef8f1;
  color: var(--green);
}

.refresh-summary.failed span:first-child {
  border-color: #f0c3bc;
  background: #fff2f0;
  color: #b5362d;
}

.refresh-progress {
  flex: 1 0 100%;
  padding: 2px 0 4px;
}

.refresh-progress[hidden] {
  display: none;
}

.refresh-progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
}

.refresh-progress-head strong {
  color: #1d5fa7;
  font-size: 12px;
  font-weight: 700;
}

.refresh-progress-track {
  position: relative;
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: #e6edf7;
}

.refresh-progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #4f86f7);
  transition: width .35s ease;
}

.refresh-progress.running .refresh-progress-track span {
  position: relative;
  width: 38% !important;
  animation: refresh-progress-slide 1.35s ease-in-out infinite;
}

.refresh-progress.success .refresh-progress-track span {
  background: linear-gradient(90deg, #198754, #39ad7b);
}

.refresh-progress.success .refresh-progress-head strong {
  color: var(--green);
}

.refresh-progress.failed .refresh-progress-track span {
  background: #c2413c;
}

.refresh-progress.failed .refresh-progress-head strong {
  color: #b5362d;
}

@keyframes refresh-progress-slide {
  0% { transform: translateX(-120%); }
  50% { transform: translateX(155%); }
  100% { transform: translateX(275%); }
}

.refresh-log {
  display: none;
}

.refresh-log p {
  margin: 0;
  text-align: left;
  color: #40534b;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.refresh-log p.latest {
  color: var(--green);
  font-weight: 700;
}

.secondary-button[disabled],
.primary-button[disabled] {
  opacity: 0.65;
  cursor: wait;
}

.primary-button,
.secondary-button,
.project-action {
  min-height: 38px;
  border-radius: 6px;
  padding: 0 14px;
  border: 1px solid transparent;
  font-weight: 700;
}

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

.secondary-button,
.project-action {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}

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

.stat {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stat span {
  display: block;
  color: var(--green-deep);
  font-size: 28px;
  font-weight: 800;
}

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

.admin-quality-panel {
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.quality-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 13px 16px;
  border: 0;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.quality-toggle span {
  font-weight: 800;
  font-size: 16px;
}

.quality-toggle small {
  color: var(--muted);
  font-size: 12px;
}

.quality-toggle[aria-expanded="true"] {
  border-bottom: 1px solid var(--line);
  background: #fbfcfb;
}

.quality-panel-body {
  padding: 14px 16px 16px;
}

.quality-panel-body[hidden] {
  display: none;
}

.admin-settings-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8faf8;
}

.admin-settings-row label {
  font-weight: 800;
}

.admin-settings-row select {
  min-width: 150px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

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

.admin-auth-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8faf8;
}

.admin-auth-row > span {
  color: var(--muted);
  font-size: 13px;
}

.admin-auth-input {
  width: 150px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.admin-pack-settings {
  margin-bottom: 12px;
}

.keyword-packs-admin {
  display: grid;
  gap: 8px;
}

.admin-pack-row {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(320px, 1.6fr) auto;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.admin-pack-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.admin-pack-row label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.admin-pack-row input,
.admin-pack-row textarea {
  width: 100%;
  min-height: 36px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  resize: vertical;
}

.admin-pack-remove {
  min-height: 36px;
  color: var(--red);
}

.admin-pack-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-pack-enabled {
  display: inline-flex !important;
  grid-template-columns: auto !important;
  align-items: center;
  gap: 6px !important;
  min-height: 36px;
  color: var(--text) !important;
  white-space: nowrap;
}

.admin-pack-enabled input {
  width: 17px;
  min-height: 17px;
  accent-color: var(--green);
}

.keyword-pack-history-row {
  margin-top: 8px;
  margin-bottom: 0;
}

.keyword-pack-history-row select {
  min-width: 360px;
  max-width: 100%;
}

.keyword-pack-note {
  min-width: 220px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.keyword-pack-audit-row {
  margin-top: 8px;
  margin-bottom: 6px;
}

.admin-audit-log {
  display: grid;
  gap: 6px;
  max-height: 270px;
  overflow: auto;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafcfa;
}

.admin-audit-item {
  display: grid;
  grid-template-columns: 150px 90px minmax(0, 1fr) 150px;
  gap: 8px;
  align-items: center;
  min-height: 30px;
  color: var(--muted);
  font-size: 13px;
}

.admin-audit-item time,
.admin-audit-item small {
  white-space: nowrap;
}

.admin-audit-item strong {
  color: var(--text);
}

.admin-audit-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-audit-empty {
  padding: 8px 0;
  color: var(--muted);
  font-size: 13px;
}

.collection-run-history-head {
  margin-top: 8px;
  margin-bottom: 6px;
}

.collection-run-filters {
  display: flex;
  flex: 1 1 420px;
  gap: 6px;
  min-width: 240px;
}

.collection-run-filters select {
  min-width: 0;
  flex: 1 1 0;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
}

.collection-run-history {
  display: grid;
  gap: 6px;
  max-height: 300px;
  overflow: auto;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafcfa;
}

.collection-run-item {
  border-bottom: 1px solid var(--line);
  padding: 5px 0;
}

.collection-run-item:last-child {
  border-bottom: 0;
}

.collection-run-item summary {
  display: grid;
  grid-template-columns: 58px 150px minmax(0, 1fr) 70px;
  gap: 8px;
  align-items: center;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}

.collection-run-item summary strong {
  color: var(--text);
}

.collection-run-item summary span:not(.collection-run-status) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.collection-run-status {
  display: inline-flex;
  justify-content: center;
  padding: 3px 6px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.collection-run-status.good {
  color: #146c43;
  background: #e8f6ed;
}

.collection-run-status.bad {
  color: #a33a2b;
  background: #fff0ed;
}

.collection-run-meta {
  margin: 8px 0 6px 66px;
  color: var(--muted);
  font-size: 12px;
}

.collection-run-platforms {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 0 0 7px 66px;
}

.collection-run-platform {
  display: inline-flex;
  padding: 3px 7px;
  border-radius: 999px;
  color: #236145;
  background: #edf8f0;
  font-size: 12px;
}

.collection-run-platform.skipped {
  color: #98510a;
  background: #fff3dd;
}

.collection-run-item pre {
  max-height: 150px;
  margin: 0 0 6px 66px;
  padding: 8px;
  overflow: auto;
  border-radius: 5px;
  background: #15231d;
  color: #d7f2df;
  font: 12px/1.55 Consolas, monospace;
  white-space: pre-wrap;
}

.collection-run-empty {
  padding: 6px 0;
  color: var(--muted);
  font-size: 13px;
}

.collection-run-summary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 10px;
  margin-bottom: 8px;
}

.collection-run-reasons {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.collection-run-reasons span {
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fafcfa;
}

.collection-run-pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  color: var(--muted);
  font-size: 12px;
}

.quality-summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.quality-metric {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8faf8;
}

.quality-metric strong {
  display: block;
  color: var(--green-deep);
  font-size: 22px;
  line-height: 1;
}

.quality-metric span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.quality-metric.bad strong {
  color: #b5362d;
}

.quality-metric.warn strong {
  color: #a05a00;
}

.quality-metric.muted strong {
  color: #66756e;
}

.quality-table-wrap {
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.quality-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  font-size: 13px;
}

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

.quality-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8faf8;
  color: #40534b;
  font-size: 12px;
}

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

.quality-important,
.quality-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.quality-important {
  margin-left: 6px;
  background: #fff3d7;
  color: #8b5a00;
}

.quality-status.good {
  background: #eef8f1;
  color: var(--green);
}

.quality-status.warn {
  background: #fff3d7;
  color: #8b5a00;
}

.quality-status.bad {
  background: #fff2f0;
  color: #b5362d;
}

.quality-status.muted {
  background: #eef1ef;
  color: #66756e;
}

.table-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

.section-head select {
  width: 180px;
}

.project-list {
  display: grid;
}

.project-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.project-card:last-child {
  border-bottom: 0;
}

.project-title-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.favorite-button {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--amber);
  font-size: 18px;
}

.favorite-button.active {
  background: #fff6df;
  border-color: #e5b84f;
}

.project-title {
  margin: 0;
  font-size: 17px;
  line-height: 1.4;
  word-break: break-word;
}

.project-title-link {
  color: var(--text);
  text-decoration-color: rgba(31, 122, 77, 0.35);
  text-underline-offset: 4px;
}

.project-title-link:hover {
  color: var(--green-deep);
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 10px 42px;
}

.pill {
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--panel-strong);
  color: #31453a;
  font-size: 12px;
  font-weight: 700;
}

.pill.blue {
  background: #e7f0fa;
  color: var(--blue);
}

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

.pill.red {
  background: #fae8e6;
  color: var(--red);
}

.hit-reason {
  padding: 4px 8px;
  border-radius: 6px;
  background: #edf7f1;
  color: var(--green-deep);
  font-size: 12px;
  font-weight: 800;
  max-width: min(100%, 560px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-hit-reason {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--green);
  background: #edf7f1;
  color: var(--green-deep);
  font-size: 13px;
  line-height: 1.6;
}

.project-summary {
  margin: 0 0 0 42px;
  color: var(--muted);
  line-height: 1.7;
}

.project-side {
  display: grid;
  align-content: start;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.project-action {
  display: inline-grid;
  place-items: center;
  text-decoration: none;
  color: var(--green-deep);
}

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

.project-action.unavailable {
  background: #f2f4f2;
  color: #7d8880;
  border-color: var(--line);
  cursor: not-allowed;
}

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

.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
}

.pagination[hidden] {
  display: none;
}

.page-button {
  min-width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
}

.page-button.active {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.page-button[disabled] {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.65;
}

.detail-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(14, 24, 18, 0.36);
}

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 21;
  display: grid;
  grid-template-rows: auto 1fr;
  width: min(520px, 100vw);
  height: 100vh;
  border-left: 1px solid var(--line);
  background: #fff;
  box-shadow: -18px 0 42px rgba(18, 36, 26, 0.18);
  transform: translateX(100%);
  transition: transform 0.18s ease;
}

.detail-drawer[aria-hidden="false"] {
  transform: translateX(0);
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
}

.detail-head h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.45;
}

.detail-close {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}

.detail-body {
  overflow: auto;
  padding: 22px;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.pill.muted {
  color: var(--muted);
}

.detail-list {
  display: grid;
  gap: 10px;
  margin: 0 0 22px;
}

.detail-list div {
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.detail-list dt {
  color: var(--muted);
  font-weight: 700;
}

.detail-list dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  line-height: 1.6;
}

.detail-section {
  margin-bottom: 22px;
}

.detail-section h4 {
  margin: 0 0 8px;
  font-size: 16px;
}

.detail-section p {
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
}

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.detail-link {
  display: inline-grid;
  min-width: 0;
  overflow-wrap: anywhere;
  place-items: center;
  text-decoration: none;
}

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

  .sidebar {
    position: static;
    height: auto;
  }

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

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

  .project-card {
    grid-template-columns: 1fr;
  }

  .admin-pack-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .workspace,
  .sidebar {
    padding: 16px;
  }

  .toolbar,
  .account-bar,
  .section-head,
  .data-status,
  .membership-gate {
    align-items: stretch;
    flex-direction: column;
  }

  .data-status p {
    text-align: left;
  }

  .toolbar h2 {
    font-size: 23px;
  }

  .account-status {
    justify-content: flex-start;
    white-space: normal;
  }

  .account-membership-button,
  .account-logout-button {
    width: 100%;
  }

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

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

  .quality-toggle {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-head select {
    width: 100%;
  }

  .meta-line,
  .project-summary {
    margin-left: 0;
  }

  .detail-drawer {
    width: 100vw;
  }

  .detail-list div,
  .detail-actions {
    grid-template-columns: 1fr;
  }

  .admin-audit-item {
    grid-template-columns: 1fr;
    gap: 2px;
    padding: 5px 0;
  }

  .admin-audit-item time,
  .admin-audit-item small,
  .admin-audit-item span {
    white-space: normal;
  }

  .collection-run-item summary {
    grid-template-columns: 58px minmax(0, 1fr);
  }

  .collection-run-item summary span:not(.collection-run-status),
  .collection-run-item summary small {
    grid-column: 2;
  }

  .collection-run-filters {
    flex-basis: 100%;
  }

  .collection-run-filters select {
    min-width: 0;
  }

  .collection-run-meta,
  .collection-run-item pre,
  .collection-run-platforms {
    margin-left: 0;
  }

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