:root {
  --bg: #f5f6f7;
  --panel: #ffffff;
  --ink: #1d2226;
  --muted: #656f76;
  --line: #dde2e5;
  --green: #256d49;
  --clay: #b65734;
  --danger: #b32d2d;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.login-card h1 { margin: 0 0 6px; font-size: 26px; }
.login-card label, .panel form label, .edit-grid label { display: grid; gap: 5px; margin-top: 12px; font-weight: 600; }
input, select, textarea {
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  outline-color: var(--green);
}
textarea { resize: vertical; }
.primary-button, .secondary-button {
  min-height: 40px;
  padding: 9px 14px;
  border: 0;
  border-radius: 6px;
  font-weight: 700;
}
.primary-button { background: var(--green); color: #fff; margin-top: 14px; }
.secondary-button { background: #e9ecee; color: var(--ink); margin-top: 14px; }
.message { min-height: 20px; color: var(--danger); margin-top: 10px; white-space: pre-wrap; }
.message.success { color: var(--green); }

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px 1fr;
}
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 14px;
  background: #182420;
  color: #fff;
}
.brand { font-size: 20px; font-weight: 800; margin-bottom: 18px; }
.sidebar nav { display: grid; gap: 5px; }
.nav-link {
  text-align: left;
  border: 0;
  border-radius: 6px;
  padding: 10px;
  color: #d7e0d9;
  background: transparent;
}
.nav-link:hover, .nav-link.active { background: #263c33; color: #fff; }
.logout-button {
  margin-top: auto;
  background: transparent;
  color: #f4c8c8;
  border: 1px solid #5f3636;
  border-radius: 6px;
  padding: 9px;
}
.admin-main { padding: 22px; min-width: 0; }
.admin-header { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 20px; }
.admin-header h1 { font-size: 26px; margin: 0; }
#api-label { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.view { display: none; }
.view.active { display: block; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.stat-card span { display: block; color: var(--muted); font-size: 13px; }
.stat-card strong { font-size: 24px; }
.panel {
  padding: 18px;
  margin-bottom: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.panel h2 { margin: 0 0 12px; font-size: 19px; }
.panel p { margin: 0 0 10px; color: var(--muted); }
.checklist { color: #47514d; }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}
.toolbar input, .toolbar select { min-width: 150px; }
.toolbar .secondary-button { margin: 0; }
.table-panel {
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.table-panel.compact { max-height: 560px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td {
  padding: 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th { background: #f0f2f3; font-size: 12px; text-transform: uppercase; letter-spacing: .02em; color: #586066; }
td .mini { color: var(--muted); font-size: 12px; }
.action-button {
  margin-top: 6px;
  margin-right: 4px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
}
.action-button.primary { color: #fff; background: var(--green); border-color: var(--green); }
.action-button.warning { color: #fff; background: #9d6b00; border-color: #9d6b00; }
.action-button.danger { color: #fff; background: var(--danger); border-color: var(--danger); }
.pagination { display: flex; gap: 8px; align-items: center; justify-content: center; margin: 14px 0; }
.pagination button { min-width: 74px; padding: 8px; border: 1px solid var(--line); background: #fff; border-radius: 6px; }
.pagination button:disabled { opacity: .45; }
.edit-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 14px; }
.edit-grid .wide, .edit-grid .editor-actions { grid-column: 1 / -1; }
.editor-actions { display: flex; gap: 8px; margin-top: 14px; }
.editor-actions button { margin: 0; }
.inline-form { display: grid; grid-template-columns: 1fr .6fr auto; gap: 8px; align-items: center; }
.inline-form .primary-button { margin: 0; }
.keyword-list { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.keyword-chip { display: inline-flex; gap: 5px; align-items: center; background: #eef3ef; border-radius: 20px; padding: 5px 9px; font-size: 13px; }
.keyword-chip button { border: 0; background: transparent; font-weight: 800; }
.two-column { display: grid; grid-template-columns: .8fr 1.2fr; gap: 14px; align-items: start; }
.two-column .panel { margin-bottom: 0; }
.review-text { max-width: 420px; white-space: pre-wrap; }
.badge { display: inline-block; border-radius: 20px; padding: 2px 8px; background: #eef1f2; font-size: 12px; }
.badge.active, .badge.approved, .badge.paid, .badge.shipped { color: #fff; background: var(--green); }
.badge.pending { color: #6b4b00; background: #f4e8cd; }
.badge.rejected, .badge.cancelled, .badge.failed { color: #fff; background: var(--danger); }
.badge.draft { background: #e8e8e8; }
.code-cell { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.empty { padding: 24px; text-align: center; color: var(--muted); }

@media (max-width: 1024px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; align-items: center; overflow-x: auto; }
  .sidebar nav { display: flex; }
  .brand, .logout-button { margin: 0; white-space: nowrap; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .two-column { grid-template-columns: 1fr; }
  .edit-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .admin-main { padding: 14px; }
  .admin-header { align-items: start; flex-direction: column; }
  .stats-grid { grid-template-columns: 1fr; }
  .inline-form { grid-template-columns: 1fr; }
}
