:root {
  --ink: #12100e;
  --cream: #f6f3ee;
  --paper: #fffdf9;
  --line: rgba(18, 16, 14, 0.1);
  --brass: #8b6a47;
  --muted: #6a635a;
  --ok: #3d6b4f;
  --err: #a84d35;
  --sidebar: #171512;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body, input, textarea, select, button {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

.cwm-login {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background:
    radial-gradient(ellipse at top, rgba(196, 165, 116, 0.18), transparent 50%),
    var(--cream);
  color: var(--ink);
}

.cwm-login-card {
  width: min(28rem, calc(100% - 2rem));
  margin: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 2rem 1.75rem;
}

.cwm-brand {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--brass);
  font-weight: 700;
}

.cwm-brand span { color: var(--ink); }

.cwm-login-card h1 {
  margin: 0 0 1rem;
  font-size: 1.5rem;
  font-weight: 600;
}

.cwm-shell {
  display: grid;
  grid-template-columns: 15.5rem 1fr;
  min-height: 100vh;
  background: var(--cream);
  color: var(--ink);
}

.cwm-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.cwm-legal {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.5rem;
  margin-top: auto;
  padding: 1.25rem 0 0.25rem;
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--muted);
}

.cwm-legal p { margin: 0; }

.cwm-legal a {
  color: var(--ink);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
}

.cwm-legal a:hover { color: var(--brass); }

.cwm-login .cwm-legal {
  width: min(42rem, calc(100% - 2rem));
  margin: 0 auto 1.5rem;
}

.cwm-nav {
  background: var(--sidebar);
  color: #f5f2ec;
  padding: 1.25rem 1rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.cwm-nav a {
  color: rgba(245, 242, 236, 0.78);
  text-decoration: none;
  padding: 0.55rem 0.7rem;
  font-size: 0.9rem;
  border-radius: 3px;
}

.cwm-nav a:hover,
.cwm-nav a.is-active {
  background: rgba(245, 242, 236, 0.08);
  color: #fff;
}

.cwm-nav-brand {
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #c4a574;
  font-weight: 700;
  margin: 0 0.7rem 0.15rem;
}

.cwm-nav-sub {
  margin: 0 0.7rem 1.25rem;
  font-size: 0.75rem;
  color: rgba(245, 242, 236, 0.45);
}

.cwm-nav-footer {
  margin-top: auto;
  padding: 0.7rem;
  font-size: 0.75rem;
  color: rgba(245, 242, 236, 0.4);
}

.cwm-main { padding: 1.5rem 1.75rem 1.5rem; }

.cwm-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.cwm-top h1 { margin: 0; font-size: 1.6rem; font-weight: 600; }

.cwm-muted { color: var(--muted); font-size: 0.9rem; line-height: 1.5; }

.cwm-form label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.cwm-form input,
.cwm-form textarea,
.cwm-form select {
  display: block;
  width: 100%;
  margin-top: 0.4rem;
  padding: 0.65rem 0.75rem;
  font: inherit;
  font-size: 0.95rem;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: var(--ink);
  border: 1px solid var(--line);
  background: #fff;
}

.cwm-form textarea { min-height: 5.5rem; }

.cwm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.1rem;
  background: var(--ink);
  color: #f5f2ec;
  border: 0;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
}

.cwm-btn:hover { opacity: 0.92; }

.cwm-btn--ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.cwm-btn--danger { background: var(--err); }

.cwm-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.1rem; }

.cwm-card {
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 1.25rem;
}

.cwm-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.cwm-stat { padding: 1rem 1.1rem; background: var(--paper); border: 1px solid var(--line); }
.cwm-stat strong { display: block; font-size: 1.6rem; }
.cwm-stat span { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }

.cwm-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.cwm-table th, .cwm-table td {
  text-align: left;
  padding: 0.8rem 0.4rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}
.cwm-table a { color: var(--brass); font-weight: 650; text-decoration: none; }
.cwm-table a:hover { text-decoration: underline; }

.cwm-badge {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.15rem 0.4rem;
}
.cwm-badge--published { background: rgba(61, 107, 79, 0.14); color: var(--ok); }
.cwm-badge--draft { background: rgba(18, 16, 14, 0.08); color: var(--muted); }

.cwm-notice { padding: 0.7rem 0.85rem; margin: 0 0 1rem; font-size: 0.9rem; }
.cwm-notice--ok { background: rgba(61, 107, 79, 0.12); color: var(--ok); }
.cwm-notice--err { background: rgba(168, 77, 53, 0.12); color: var(--err); }

.cwm-help { font-size: 0.8rem; color: var(--muted); margin-top: 0.35rem; font-weight: 400; letter-spacing: 0; text-transform: none; }

.cwm-details { margin-top: 1.25rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.cwm-details summary {
  cursor: pointer;
  font-weight: 650;
  color: var(--ink);
}

.cwm-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: 0.75rem;
}

.cwm-media-item {
  border: 1px solid var(--line);
  background: #fff;
  padding: 0.4rem;
  text-align: center;
}

.cwm-media-item img {
  width: 100%;
  height: 7rem;
  object-fit: cover;
  display: block;
}

.cwm-media-item button, .cwm-media-item .pick {
  margin-top: 0.4rem;
  width: 100%;
}

.tox-tinymce { border-radius: 0 !important; }

.cwm-nav-backdrop {
  display: none;
}

.cwm-menu-btn {
  display: none;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0 0.7rem;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.cwm-top-titles { min-width: 0; flex: 1; }

.cwm-userchip {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.2rem 0.55rem 0.2rem 0.2rem;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line);
  background: var(--paper);
  min-height: 2.75rem;
  flex-shrink: 0;
}

.cwm-userchip.is-active,
.cwm-userchip:hover { border-color: var(--brass); }

.cwm-userchip-name {
  font-size: 0.82rem;
  font-weight: 650;
  max-width: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cwm-avatar {
  width: 2.15rem;
  height: 2.15rem;
  border-radius: 50%;
  object-fit: cover;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(139, 106, 71, 0.2);
  color: var(--brass);
  font-size: 0.72rem;
  font-weight: 800;
  flex-shrink: 0;
}

.cwm-nav-user {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.5rem !important;
  margin-bottom: 0.75rem;
}

.cwm-nav-user span { display: flex; flex-direction: column; min-width: 0; }
.cwm-nav-user strong { color: #fff; font-size: 0.85rem; }
.cwm-nav-user em {
  font-style: normal;
  font-size: 0.72rem;
  color: rgba(245, 242, 236, 0.45);
}

.cwm-stats--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cwm-stat small { display: block; margin-top: 0.2rem; font-size: 0.72rem; color: var(--muted); }

.cwm-chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.45rem;
  align-items: end;
  height: 9rem;
  margin: 1rem 0 0.25rem;
}

.cwm-chart-col {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  height: 100%;
  gap: 0.35rem;
}

.cwm-chart-col i {
  display: block;
  width: 100%;
  min-height: 4px;
  background: var(--brass);
  border-radius: 2px 2px 0 0;
}

.cwm-chart-col small {
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
}

.cwm-seo-score {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 700;
}

.cwm-seo-pill {
  display: inline-block;
  min-width: 2.4rem;
  text-align: center;
  padding: 0.15rem 0.4rem;
  font-size: 0.75rem;
  font-weight: 800;
}

.cwm-seo-pill--good { background: rgba(61, 107, 79, 0.14); color: var(--ok); }
.cwm-seo-pill--ok { background: rgba(139, 106, 71, 0.16); color: var(--brass); }
.cwm-seo-pill--poor { background: rgba(168, 77, 53, 0.12); color: var(--err); }

.cwm-issue-list { margin: 0.5rem 0 0; padding-left: 1.1rem; color: var(--muted); font-size: 0.88rem; }
.cwm-grid-2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
}
.cwm-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cwm-banner {
  background: #171512;
  color: #f5f2ec;
  padding: 0.7rem 0.9rem;
  font-size: 0.88rem;
  margin: 0 0 1rem;
}

.cwm-banner a {
  color: #c4a574;
  font-weight: 700;
  margin-left: 0.5rem;
}

.cwm-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0 1rem;
  align-items: stretch;
}

.cwm-filters input,
.cwm-filters select {
  min-height: 2.75rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
  font-size: 16px;
}

.cwm-filters input { flex: 1 1 100%; }
.cwm-filters select { flex: 1 1 10rem; max-width: 18rem; }
.cwm-filters .cwm-btn { flex: 0 0 auto; }

.cwm-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}

.cwm-table th:last-child,
.cwm-table td:last-child {
  position: sticky;
  right: 0;
  min-width: 11rem;
  background: var(--paper);
  box-shadow: -8px 0 8px -8px rgba(18, 16, 14, 0.18);
  z-index: 1;
}

.cwm-fieldset {
  border: 1px solid var(--line);
  padding: 0.75rem 1rem 0.25rem;
  margin: 0 0 1rem;
}

.cwm-fieldset legend {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 0.35rem;
}

.cwm-checkline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  font-size: 0.92rem;
  color: var(--ink);
}

.cwm-checkline input { width: auto; margin: 0; min-height: 0; }

.cwm-avatar.cwm-profile-photo {
  width: 6.5rem;
  height: 6.5rem;
  font-size: 1.4rem;
  border: 1px solid var(--line);
  margin-bottom: 0.75rem;
}

.cwm-checklist { list-style: none; margin: 0; padding: 0; }
.cwm-checklist li {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.92rem;
}
.cwm-check {
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 0.1rem;
  background: rgba(18, 16, 14, 0.08);
}
.cwm-check.is-on { background: var(--ok); }

@media (max-width: 960px) {
  .cwm-stats--4,
  .cwm-grid-2 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 840px) {
  .cwm-shell { grid-template-columns: 1fr; }
  .cwm-nav-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(18, 16, 14, 0.45);
    z-index: 30;
  }
  .cwm-nav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(18.5rem, 86vw);
    z-index: 40;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    overflow-y: auto;
    padding-top: calc(1rem + env(safe-area-inset-top, 0px));
  }
  .cwm-nav.is-open { transform: none; }
  .cwm-nav a {
    min-height: 2.75rem;
    display: flex;
    align-items: center;
  }
  .cwm-menu-btn { display: inline-flex; align-items: center; justify-content: center; }
  .cwm-main {
    padding: 0.85rem 0.9rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
  }
  .cwm-top { align-items: center; margin-bottom: 0.9rem; gap: 0.5rem; }
  .cwm-top h1 { font-size: 1.2rem; }
  .cwm-userchip-name { display: none; }
  .cwm-stats,
  .cwm-stats--4 { grid-template-columns: 1fr 1fr; }
  .cwm-grid-2 { grid-template-columns: 1fr; }
  .cwm-form input,
  .cwm-form textarea,
  .cwm-form select { font-size: 16px; min-height: 2.75rem; }
  .cwm-btn { min-height: 2.75rem; }
  .cwm-actions { gap: 0.5rem; }
  .cwm-actions .cwm-btn { flex: 1 1 8rem; }
}

@media (max-width: 520px) {
  .cwm-stats,
  .cwm-stats--4 { grid-template-columns: 1fr; }
  .cwm-chart { height: 7.5rem; }
}
