:root {
  --ink: #171612;
  --paper: #f7f4ed;
  --panel: #fffbf1;
  --line: #d8d0bd;
  --green: #16644a;
  --red: #a3332f;
  --blue: #245a9a;
  --gold: #ba7b16;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: linear-gradient(90deg, rgba(23,22,18,.05) 1px, transparent 1px), var(--paper);
  background-size: 24px 24px;
  font-family: "Aptos", "Segoe UI", sans-serif;
}
a { color: var(--blue); text-decoration: none; }
button, .button {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: white;
  padding: .7rem .9rem;
  font-weight: 700;
  cursor: pointer;
}
button.ghost { background: transparent; color: var(--paper); border-color: rgba(255,255,255,.35); width: 100%; }
button.danger { background: var(--red); border-color: var(--red); }
button.secondary { background: transparent; color: var(--ink); }
button.compact-button { padding: .35rem .55rem; font-size: .8rem; }
.secondary-link { background: transparent; color: var(--ink); }
.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  display: grid;
  place-items: center;
}
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: .72rem;
  font: inherit;
}
textarea { min-height: 110px; resize: vertical; }
label { display: grid; gap: .35rem; font-size: .86rem; font-weight: 700; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: .75rem; text-align: left; vertical-align: top; }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; }
.rail {
  position: fixed;
  inset: 0 auto 0 0;
  width: 220px;
  background: #171612;
  color: var(--paper);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}
.brand { display: flex; gap: .7rem; align-items: center; font-weight: 900; }
.mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: var(--gold);
  color: #171612;
  font-weight: 900;
}
.rail nav { display: grid; gap: .25rem; }
.rail a { color: var(--paper); padding: .6rem .7rem; border-left: 3px solid transparent; }
.rail a:hover { background: rgba(255,255,255,.08); border-left-color: var(--gold); }
.page-switcher {
  border: 1px solid rgba(255,255,255,.18);
  padding: .75rem;
  background: rgba(255,255,255,.06);
}
.page-switcher label { color: var(--paper); }
.page-switcher select {
  margin-top: .35rem;
  color: var(--ink);
  min-height: 40px;
}
.shell { margin-left: 220px; padding: 2rem; min-height: 100vh; }
.page-head { display: flex; justify-content: space-between; gap: 1rem; align-items: end; margin-bottom: 1.5rem; }
.actions { display: flex; gap: .65rem; align-items: center; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: clamp(2rem, 4vw, 4rem); line-height: .95; letter-spacing: 0; }
.eyebrow { margin: 0 0 .35rem; color: var(--green); font-weight: 900; text-transform: uppercase; letter-spacing: .12em; }
.metric-grid, .columns, .split { display: grid; gap: 1rem; }
.metric-grid { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.columns { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-items: start; }
.split { grid-template-columns: minmax(280px, .9fr) minmax(320px, 1.4fr); align-items: start; }
.card, .panel, .empty {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 8px 0 rgba(23,22,18,.06);
}
.card-top, .row { display: flex; justify-content: space-between; gap: 1rem; align-items: center; }
.card h2, .panel h2 { margin: 0 0 1rem; }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; margin: 0; }
.metrics div { border: 1px solid var(--line); padding: .75rem; background: #fffdf8; }
.metrics dt { font-size: .72rem; text-transform: uppercase; color: #6c6658; font-weight: 800; }
.metrics dd { margin: .25rem 0 0; font-size: 1.6rem; font-weight: 900; }
.compact-metrics {
  grid-template-columns: repeat(3, minmax(110px, 1fr));
  width: min(520px, 100%);
}
.compact-metrics dd { font-size: 1.2rem; }
.mini-table { margin-top: 1rem; background: #fffdf8; border: 1px solid var(--line); }
.mini-table th, .mini-table td { padding: .6rem .7rem; }
.mini-table td:nth-child(2), .mini-table td:nth-child(3),
.mini-table th:nth-child(2), .mini-table th:nth-child(3) { text-align: right; }
.card-foot {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  margin-top: .85rem;
  color: #6c6658;
  font-size: .82rem;
}
.warning { color: var(--red); font-weight: 800; }
.ok { color: var(--green); font-weight: 800; }
.panel { display: grid; gap: .85rem; }
.table-panel { overflow-x: auto; }
.ignored-blog {
  border-top: 1px solid var(--line);
  padding-top: .85rem;
}
.ignored-blog summary {
  cursor: pointer;
  color: #6c6658;
  font-weight: 800;
}
.ignored-blog table {
  margin-top: .75rem;
}
.filters {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) auto;
  gap: .75rem;
  align-items: end;
}
.custom-date-fields {
  display: none;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: .75rem;
}
.filters[data-range="custom"] {
  grid-template-columns: minmax(150px, .8fr) minmax(300px, 1.4fr) minmax(150px, .8fr) auto;
}
.filters[data-range="custom"] .custom-date-fields { display: grid; }
.competitor-filters {
  grid-template-columns: minmax(180px, 1.1fr) minmax(150px, .8fr) minmax(150px, .8fr) auto;
}
.competitor-filters[data-range="custom"] {
  grid-template-columns: minmax(180px, 1.1fr) minmax(150px, .8fr) minmax(300px, 1.4fr) minmax(150px, .8fr) auto;
}
.filter-actions { display: flex; gap: .5rem; align-items: center; }
.inline-actions { display: flex; gap: .55rem; align-items: center; }
.inline-actions form { margin: 0; }
.top-post-filters {
  grid-template-columns: minmax(160px, 1.1fr) minmax(140px, .8fr) minmax(120px, .7fr) minmax(130px, .7fr) minmax(130px, .7fr) auto;
}
.top-post-filters[data-range="custom"] {
  grid-template-columns: minmax(160px, 1.1fr) minmax(140px, .8fr) minmax(300px, 1.3fr) minmax(120px, .7fr) minmax(130px, .7fr) minmax(130px, .7fr) auto;
}
.top-post-grid { display: grid; gap: 1rem; }
.top-post-card {
  border: 1px solid var(--line);
  background: #fffdf8;
  border-radius: 8px;
  padding: 1rem;
  display: grid;
  gap: .85rem;
}
.top-post-card h3 { margin: 0; font-size: 1.25rem; }
.post-copy {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.media-preview {
  background: #171612;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  max-height: 520px;
  overflow: hidden;
}
.media-preview img, .media-preview video {
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  display: block;
}
.compact-media-preview { max-height: 340px; }
.compact-media-preview img, .compact-media-preview video { max-height: 340px; }
.compact-post-table td { padding: .55rem .65rem; }
.compact-post-table small { display: block; margin-top: .15rem; }
.caption-cell {
  max-width: 360px;
  overflow-wrap: anywhere;
}
.review-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: .85rem;
}
.review-form .actions { grid-column: 1 / -1; }
.list, .compact { display: grid; gap: .5rem; }
.row, .draft, .note {
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: .75rem;
}
.active-row { border-left: 4px solid var(--green); }
.row small, .muted { color: #6c6658; overflow-wrap: anywhere; }
.profile-block {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: .9rem;
}
.profile-block h3 { margin: 0; font-size: 1.25rem; }
.profile-block p { margin: .25rem 0 0; }
.draft { display: grid; gap: .6rem; }
.draft p { margin: 0; }
.draft-workspace { display: grid; gap: 1rem; }
.draft-editor { align-items: stretch; }
.draft-summary { padding: 0; }
.draft-summary-button {
  width: 100%;
  border: 0;
  background: #fffdf8;
  color: var(--ink);
  padding: .85rem;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.draft-summary-button small { display: block; margin-top: .2rem; }
.featured-field textarea { border-color: var(--gold); box-shadow: inset 4px 0 0 rgba(186,123,22,.25); }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(120px, 1fr)); gap: .75rem; }
.day { min-height: 280px; background: var(--panel); border: 1px solid var(--line); padding: .75rem; border-radius: 8px; }
.day h2 { margin: 0 0 .7rem; font-size: 1rem; }
.slot {
  position: relative;
  display: grid;
  gap: .2rem;
  background: #fffdf8;
  border-left: 4px solid var(--green);
  padding: .55rem 1.75rem .55rem .55rem;
  margin-bottom: .5rem;
}
.slot-delete-form {
  position: absolute;
  top: .25rem;
  right: .25rem;
}
.slot-delete-button {
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--red);
  line-height: 1;
  font-size: .95rem;
  font-weight: 900;
}
.login-screen { min-height: 100vh; display: grid; place-items: center; }
.login-panel { width: min(420px, calc(100vw - 2rem)); background: var(--panel); border: 1px solid var(--line); padding: 1.5rem; display: grid; gap: 1rem; box-shadow: 0 14px 0 rgba(23,22,18,.08); }
.login-panel h1 { margin: 0; }
.alert { background: #ffe9e7; border: 1px solid #e0aaa6; padding: .75rem; }
.check { display: flex; align-items: center; gap: .5rem; }
.check input { width: auto; }
.modal {
  border: 0;
  padding: 0;
  background: transparent;
  width: min(520px, calc(100vw - 2rem));
}
.wide-modal { width: min(920px, calc(100vw - 2rem)); }
.modal::backdrop { background: rgba(23,22,18,.55); }
.modal-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  display: grid;
  gap: .85rem;
  box-shadow: 0 16px 0 rgba(23,22,18,.16);
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: .85rem;
  padding-top: .85rem;
  border-top: 1px solid var(--line);
}
.settings-grid h3,
.settings-grid .actions { grid-column: 1 / -1; margin: 0; }

@media (max-width: 860px) {
  .rail { position: static; width: auto; }
  .rail nav { grid-template-columns: repeat(2, 1fr); }
  .shell { margin-left: 0; padding: 1rem; }
  .split { grid-template-columns: 1fr; }
  .filters, .filters[data-range="custom"], .competitor-filters, .competitor-filters[data-range="custom"], .top-post-filters, .top-post-filters[data-range="custom"], .settings-grid { grid-template-columns: 1fr; }
  .custom-date-fields { grid-template-columns: 1fr; }
  .calendar { grid-template-columns: 1fr; }
  .review-form { grid-template-columns: 1fr; }
}
