:root {
  --bg: #efe7d7;
  --paper: #fffaf0;
  --line: #d8cfbd;
  --ink: #211c16;
  --muted: #6f6252;
  --accent: #325e6f;
  --accent-soft: #dbe9ef;
  --warn: #8f472f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.3), rgba(255,255,255,0)),
    radial-gradient(circle at top left, rgba(50,94,111,0.08), transparent 30%),
    var(--bg);
}

[hidden] {
  display: none !important;
}

.admin-shell {
  max-width: 1380px;
  margin: 0 auto;
  padding: 28px;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1, h2 {
  margin: 0;
  font-weight: 600;
}

.subcopy {
  margin: 8px 0 0;
  color: var(--muted);
  max-width: 720px;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 10px 25px rgba(49, 34, 18, 0.05);
}

.auth-panel {
  max-width: 720px;
}

.auth-row {
  display: flex;
  gap: 12px;
  margin-top: 14px;
}

input, button, textarea {
  font: inherit;
}

input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

button {
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f0e7d3;
  color: var(--ink);
  cursor: pointer;
}

.ghost-btn {
  background: #fff;
}

.message {
  min-height: 1.2em;
  margin: 12px 0 0;
  color: var(--warn);
}

.admin-message {
  margin: 0;
}

.admin-app {
  display: grid;
  gap: 20px;
}

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

.stat-card strong {
  display: block;
  margin-top: 10px;
  font-size: 34px;
}

.stat-label {
  color: var(--muted);
  font-size: 14px;
}

.two-col {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 20px;
}

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

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

.list-block {
  display: grid;
  gap: 10px;
  max-height: 460px;
  overflow: auto;
  padding-right: 4px;
}

.list-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 12px;
}

.project-item {
  cursor: pointer;
}

.project-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.review-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.item-topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.item-title {
  font-weight: 600;
}

.item-meta {
  color: var(--muted);
  font-size: 13px;
}

.item-preview {
  margin-top: 8px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

.memory-context {
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.45;
}

.queue-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.queue-action {
  position: relative;
  z-index: 1;
  padding: 8px 12px;
}

.context-chip {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 999px;
  background: #efe5d3;
  margin-right: 6px;
}

.project-detail {
  min-height: 260px;
  display: grid;
  gap: 14px;
}

.detail-grid--wide {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.empty-state {
  color: var(--muted);
}

.running-state {
  color: var(--accent);
  font-weight: 600;
}

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

.detail-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 12px;
}

.detail-card strong {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.text-preview {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  background: #fff;
  white-space: pre-wrap;
  line-height: 1.55;
  max-height: 420px;
  overflow: auto;
}

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

.overlay-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}

.overlay-card strong {
  display: block;
  margin-bottom: 6px;
}

.meta-copy {
  color: var(--muted);
  font-size: 14px;
}

textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  resize: vertical;
}

.memory-context--large {
  font-size: 18px;
}

.approve-btn {
  background: #e7f0de;
}

.reject-btn {
  background: #f4ddd6;
}

.review-btn {
  background: #efe5d3;
}

.danger-btn {
  background: #f5dfd8;
  border-color: #d3a89c;
}

.danger-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
}

.danger-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(33, 28, 22, 0.35);
}

.danger-modal__card {
  position: relative;
  z-index: 1;
  width: min(540px, calc(100vw - 32px));
}

.danger-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

@media (max-width: 980px) {
  .stats-grid,
  .two-col,
  .detail-grid,
  .detail-grid--wide,
  .overlay-grid {
    grid-template-columns: 1fr;
  }

  .admin-header,
  .auth-row {
    flex-direction: column;
  }
}
