:root {
  --ink: #1b1030;
  --bg: #fbfaff;
  --content-bg: #f6f4fc;
  --surface: #f3effc;
  --border: #e6e0f5;
  --violet: #6d28d9;
  --violet-soft-bg: #ede6fb;
  --violet-soft-text: #4c1d95;
  --danger-bg: #fee2e2;
  --danger-text: #991b1b;
  --sidebar-bg: #1b1030;
  --sidebar-link: #cfc6e8;
  --sidebar-active: rgba(255, 255, 255, 0.1);
  --pill-draft-bg: #e5e7eb;
  --pill-draft-text: #374151;
  --pill-review-bg: #fef3c7;
  --pill-review-text: #92400e;
  --pill-published-bg: #d1fae5;
  --pill-published-text: #065f46;
  --pill-archived-bg: #f3f4f6;
  --pill-archived-text: #6b7280;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body.admin {
  background: var(--content-bg);
  color: var(--ink);
  font-family: 'Sora', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
}

h1,
h2,
h3 {
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.5em;
}

p {
  margin: 0 0 1em;
}

:focus-visible {
  outline: 3px solid #1fb6ff;
  outline-offset: 2px;
}

/* Shell layout */

.admin-shell {
  display: flex;
  min-height: 100vh;
}

.admin-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-link);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  padding: 8px 10px 20px;
}

.admin-sidebar__brand img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.admin-nav-link {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--sidebar-link);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
}

.admin-nav-link[aria-current='true'] {
  background: var(--sidebar-active);
  color: #fff;
}

.admin-sidebar__spacer {
  flex: 1;
}

.admin-sidebar__user {
  padding: 10px 12px;
  font-size: 0.82rem;
  color: var(--sidebar-link);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  margin-top: 8px;
  padding-top: 16px;
}

.admin-logout-btn {
  display: block;
  width: 100%;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 8px 10px;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  margin-top: 8px;
}

.admin-main {
  flex: 1;
  min-width: 0;
}

.admin-content {
  padding: 24px 28px 60px;
  max-width: 1200px;
}

.admin-page-title {
  font-size: 1.4rem;
  margin-bottom: 4px;
}

.admin-subtitle {
  color: #574a70;
  margin-bottom: 20px;
}

/* Flash */

.flash {
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 20px;
  font-weight: 600;
  font-size: 0.92rem;
}

.flash-success {
  background: #d1fae5;
  color: #065f46;
}

.flash-error {
  background: #fee2e2;
  color: #991b1b;
}

/* Panels */

.panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
}

.panel h2,
.panel h3 {
  font-size: 1.05rem;
}

.panel-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 20px;
}

.stat-tile {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
}

.stat-tile__value {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--violet);
}

.stat-tile__label {
  font-size: 0.85rem;
  color: #574a70;
}

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

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 10px;
  padding: 10px 18px;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.92rem;
  text-decoration: none;
  border: none;
  cursor: pointer;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--violet);
  color: #fff;
}

.btn-secondary {
  background: var(--violet-soft-bg);
  color: var(--violet-soft-text);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: 8px;
}

/* Forms */

label {
  display: block;
  font-weight: 600;
  font-size: 0.88rem;
  margin-bottom: 6px;
}

.field {
  margin-bottom: 16px;
}

.field-help {
  font-size: 0.78rem;
  color: #8a7fa3;
  margin-top: 4px;
}

input[type='text'],
input[type='password'],
input[type='number'],
input[type='email'],
input[type='url'],
input[type='search'],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-family: inherit;
  font-size: 0.92rem;
  background: #fff;
  color: var(--ink);
}

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

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
}

.checkbox-row input {
  width: auto;
}

/* Status radio cards */

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

.status-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  display: block;
}

.status-card input {
  margin-right: 8px;
}

.status-card:has(input:checked) {
  border-color: var(--violet);
  background: var(--violet-soft-bg);
}

.status-card__label {
  font-weight: 700;
}

.status-card__help {
  font-size: 0.8rem;
  color: #574a70;
  margin-top: 4px;
}

/* Niche chips (same palette as the public site) */

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.76rem;
  font-weight: 700;
}

.chip--beaute {
  background: #ffe4ee;
  color: #b4124f;
}

.chip--gaming {
  background: #e3f4ff;
  color: #0b6fa8;
}

.chip--gadgets {
  background: #ede6fb;
  color: #4c1d95;
}

/* Status pills */

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.status-pill--draft {
  background: var(--pill-draft-bg);
  color: var(--pill-draft-text);
}

.status-pill--review {
  background: var(--pill-review-bg);
  color: var(--pill-review-text);
}

.status-pill--published {
  background: var(--pill-published-bg);
  color: var(--pill-published-text);
}

.status-pill--archived {
  background: var(--pill-archived-bg);
  color: var(--pill-archived-text);
}

.featured-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: #ff3d7f;
  color: #fff;
  margin-left: 6px;
}

/* Tables */

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

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

.admin-table th {
  color: #574a70;
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.admin-table img.thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--surface);
}

/* Tabs */

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

.tab {
  padding: 8px 14px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  font-size: 0.85rem;
}

.tab[aria-current='true'] {
  background: var(--violet);
  color: #fff;
  border-color: var(--violet);
}

/* Bars (pure CSS chart) */

.bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 120px;
  margin-top: 12px;
}

.bars__col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}

.bars__bar {
  width: 100%;
  background: var(--violet);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
}

/* Discrete height steps so bar heights never need an inline style
   (blocked by our strict style-src CSP with no 'unsafe-inline'). */
.bar-h-0 { height: 1%; }
.bar-h-5 { height: 5%; }
.bar-h-10 { height: 10%; }
.bar-h-15 { height: 15%; }
.bar-h-20 { height: 20%; }
.bar-h-25 { height: 25%; }
.bar-h-30 { height: 30%; }
.bar-h-35 { height: 35%; }
.bar-h-40 { height: 40%; }
.bar-h-45 { height: 45%; }
.bar-h-50 { height: 50%; }
.bar-h-55 { height: 55%; }
.bar-h-60 { height: 60%; }
.bar-h-65 { height: 65%; }
.bar-h-70 { height: 70%; }
.bar-h-75 { height: 75%; }
.bar-h-80 { height: 80%; }
.bar-h-85 { height: 85%; }
.bar-h-90 { height: 90%; }
.bar-h-95 { height: 95%; }
.bar-h-100 { height: 100%; }

.bars__label {
  font-size: 0.65rem;
  color: #8a7fa3;
  margin-top: 4px;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  max-height: 46px;
}

/* Login page */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}

.login-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.login-card img {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  margin-bottom: 12px;
}

.login-card h1 {
  font-size: 1.2rem;
}

.login-card .field {
  text-align: left;
}

/* Small layout utilities (kept out of inline style="" attributes, which our
   strict style-src CSP with no 'unsafe-inline' blocks). */

.scroll-x {
  overflow-x: auto;
}

.list-reset {
  list-style: none;
  padding: 0;
  margin: 0;
}

.todo-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}

.activity-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.mt-16 {
  margin-top: 16px;
}

.inline-form {
  display: flex;
  gap: 6px;
}

.inline-form-mt {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.mt-8 {
  margin-top: 8px;
}

.image-preview {
  width: 100%;
  height: 180px;
  object-fit: contain;
  background: var(--surface);
  border-radius: 12px;
}

/* Mobile */

@media (max-width: 900px) {
  .panel-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .status-cards {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 767px) {
  .admin-shell {
    flex-direction: column;
  }

  .admin-sidebar {
    width: 100%;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    padding: 10px 12px;
  }

  .admin-sidebar__brand {
    padding: 4px 8px 4px 0;
  }

  .admin-sidebar__spacer {
    display: none;
  }

  .admin-sidebar__user,
  .admin-logout-btn {
    display: none;
  }

  .admin-nav-link {
    padding: 8px 10px;
    font-size: 0.82rem;
  }

  .admin-content {
    padding: 16px;
  }

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

  .admin-table .hide-mobile {
    display: none;
  }
}
