* {
  box-sizing: border-box;
}

:root {
  --bg: #f7f4f1;
  --panel: #fff;
  --ink: #26201d;
  --muted: #746a65;
  --accent: #9c4f47;
  --accent-dark: #74352f;
  --line: #e5d9d3;
  --success: #236a35;
  --warning: #9b6500;
  --danger: #a3261d;
  --shadow: 0 14px 36px rgba(44, 32, 28, 0.09);
}

body.admin-body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

a {
  color: var(--accent-dark);
}

.admin-container {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
}

.admin-header {
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.admin-header-inner {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.admin-brand {
  text-decoration: none;
  color: var(--ink);
  font-weight: 800;
  font-size: 1.2rem;
}

.admin-nav {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.admin-nav a {
  text-decoration: none;
  color: var(--ink);
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 0.93rem;
}

.admin-nav a:hover {
  background: #f0e3dd;
}

.admin-main {
  padding: 34px 0 60px;
}

.admin-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.admin-page-head h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1.05;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent-dark);
  font-weight: 800;
  font-size: 0.78rem;
  margin: 0 0 8px;
}

.muted,
.help,
small {
  color: var(--muted);
}

.admin-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 22px;
}

.admin-card h2 {
  margin-top: 0;
}

.narrow-card {
  max-width: 680px;
}

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

.admin-button {
  appearance: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  padding: 10px 17px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(156, 79, 71, 0.2);
}

.admin-button:hover {
  background: var(--accent-dark);
}

.admin-button.secondary {
  background: #fff;
  color: var(--accent-dark);
  border: 1px solid var(--line);
  box-shadow: none;
}

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

.admin-flash,
.admin-alert {
  border-radius: 14px;
  padding: 13px 15px;
  margin-bottom: 18px;
  border: 1px solid #bdd9c3;
  background: #f0fbf2;
  color: var(--success);
}

.admin-alert.error {
  border-color: #edbdb8;
  background: #fff0ef;
  color: var(--danger);
}

.admin-alert.warning {
  border-color: #e4c78c;
  background: #fff8e8;
  color: var(--warning);
}

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

.admin-stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.admin-stat strong {
  display: block;
  font-size: 2rem;
}

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

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

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

.admin-table th {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.admin-table .actions {
  white-space: nowrap;
  text-align: right;
}

.admin-table .actions a,
.admin-form-actions a {
  margin-left: 10px;
}

.danger {
  color: var(--danger);
}

.status {
  display: inline-flex;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
}

.status.published {
  background: #edf8ee;
  color: var(--success);
}

.status.draft {
  background: #fff5df;
  color: var(--warning);
}

label {
  display: block;
  margin-bottom: 16px;
}

label span {
  display: block;
  font-weight: 800;
  margin-bottom: 7px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 12px;
  font: 1rem Arial, Helvetica, sans-serif;
  background: #fff;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

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

.admin-filters {
  display: grid;
  grid-template-columns: 1fr 180px 180px auto;
  align-items: end;
  gap: 14px;
}

.admin-edit-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
  align-items: start;
}

.editor-card {
  min-width: 0;
}

.editor-toolbar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  background: #f6eee9;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
  padding: 8px;
}

.editor-toolbar button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 7px 10px;
  cursor: pointer;
}

.editor-toolbar button:hover {
  background: #fff6f2;
}

.visual-editor {
  min-height: 420px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0 0 16px 16px;
  padding: 18px;
  outline: none;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.7;
  overflow: auto;
}

.visual-editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(156, 79, 71, 0.1);
}

.visual-editor img {
  max-width: 100%;
  height: auto;
}

.source-editor {
  min-height: 210px;
  margin-top: 12px;
  font-family: Consolas, Monaco, monospace;
  font-size: 0.9rem;
}

.check-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.check-row input {
  width: auto;
}

.check-row span {
  margin: 0;
}

.admin-form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 16px;
}

.admin-form-actions.compact {
  margin-top: 8px;
  font-size: 0.9rem;
}

.admin-login {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 160px);
}

.admin-login-card {
  width: min(460px, 100%);
}

.media-upload-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 14px;
  align-items: end;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.media-item {
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: #fff;
}

.media-item img,
.file-tile {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: grid;
  place-items: center;
  background: #f3ece8;
  color: var(--muted);
  font-weight: 900;
  font-size: 2rem;
}

.media-info {
  padding: 12px;
}

.media-info input {
  margin-top: 8px;
  font-size: 0.9rem;
}

@media (max-width: 940px) {
  .admin-header-inner,
  .admin-page-head {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .admin-edit-layout,
  .admin-filters,
  .media-upload-form {
    grid-template-columns: 1fr;
  }

  .settings-card {
    order: -1;
  }
}

@media (max-width: 620px) {
  .admin-stats,
  .media-grid,
  .two-col {
    grid-template-columns: 1fr;
  }

  .admin-nav {
    justify-content: flex-start;
  }
}
