:root {
  --bg: #f3efe6;
  --ink: #1c1915;
  --muted: #6d645b;
  --line: #e3d9cc;
  --card: #fffdf8;
  --side: #1c1915;
  --side-text: #f6f1e8;
  --side-muted: #c8bfb2;
  --green: #0f6e56;
  --green-bg: #e5f4ee;
  --amber: #8a5a00;
  --amber-bg: #fff1d6;
  --red: #9f2d2d;
  --red-bg: #fde8e6;
  --blue: #1f4e79;
  --blue-bg: #e7f0f8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  color: var(--ink);
  background: var(--bg);
}

button, input, select, .nav a, .brand span, .worker, .message, .eyebrow {
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.topbar-title {
  font-size: 16px;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

.menu-toggle {
  position: relative;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.menu-toggle span {
  position: absolute;
  left: 10px;
  width: 18px;
  height: 2px;
  background: currentColor;
  transition: transform 0.15s ease, opacity 0.15s ease, top 0.15s ease;
}

.menu-toggle span:nth-child(1) { top: 13px; }
.menu-toggle span:nth-child(2) { top: 19px; }
.menu-toggle span:nth-child(3) { top: 25px; }

.menu-toggle[aria-expanded="true"] span:nth-child(1) {
  top: 19px;
  transform: rotate(45deg);
}

.menu-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }

.menu-toggle[aria-expanded="true"] span:nth-child(3) {
  top: 19px;
  transform: rotate(-45deg);
}

.backdrop {
  display: none;
  position: fixed;
  z-index: 20;
  top: 56px;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(28, 25, 21, 0.45);
}

.sidebar {
  position: fixed;
  z-index: 30;
  top: 56px;
  left: 0;
  bottom: 0;
  width: 240px;
  background: var(--side);
  color: var(--side-text);
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  transform: translateX(-100%);
  transition: transform 0.2s ease;
}

.workspace {
  min-width: 0;
  padding-top: 56px;
  transition: margin-left 0.2s ease;
}

@media (min-width: 901px) {
  .menu-toggle { display: none; }
  .sidebar { transform: translateX(0); }
  .workspace { margin-left: 240px; }
}

@media (max-width: 900px) {
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .backdrop { display: block; }
  body.sidebar-open { overflow: hidden; }
}

.brand strong {
  display: block;
  font-size: 20px;
  font-weight: 600;
}

.brand span {
  display: block;
  margin-top: 4px;
  color: var(--side-muted);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.nav {
  display: grid;
  gap: 4px;
}

.nav a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--side-text);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 15px;
}

.nav a:hover { background: rgba(255, 255, 255, 0.08); }

.nav a.is-on {
  background: #fffdf8;
  color: var(--ink);
}

.nav em {
  font-style: normal;
  font-size: 12px;
  background: #fff1d6;
  color: var(--amber);
  border-radius: 999px;
  padding: 1px 7px;
}

.content-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  padding: 28px 32px 0;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--muted);
}

h1, h2 { margin: 0; font-weight: 600; }
h1 { font-size: 36px; line-height: 1.05; }
h2 { font-size: 22px; }

#page-blurb {
  margin: 8px 0 0;
  color: var(--muted);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 14px;
  max-width: 62ch;
}

.worker {
  margin-left: auto;
  max-width: 48vw;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  white-space: nowrap;
}

.message {
  min-height: 20px;
  margin: 12px 32px 0;
  color: var(--blue);
  font-size: 14px;
}

main {
  padding: 16px 32px 48px;
  display: grid;
  gap: 16px;
}

.view { display: grid; gap: 16px; }
.view[hidden] { display: none; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
}

.stat span {
  display: block;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 13px;
  color: var(--muted);
}

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 32px;
  line-height: 1;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px 20px 20px;
  overflow-x: auto;
  min-width: 0;
}

.panel-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 14px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 14px;
}

form.panel {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 12px 14px;
}

form .panel-head,
.span-2 { grid-column: 1 / -1; }

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
}

input, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--ink);
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: end;
}

.check input { width: auto; }

.actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

button {
  border: 0;
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
}

button.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button:disabled { opacity: 0.55; cursor: wait; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th { color: var(--muted); font-weight: 600; }

.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
}

.pill.posted, .pill.yes { background: var(--green-bg); color: var(--green); }
.pill.not_accepted, .pill.wait { background: var(--amber-bg); color: var(--amber); }
.pill.error, .pill.post_failed, .pill.invalid, .pill.no { background: var(--red-bg); color: var(--red); }
.pill.processing, .pill.pre-ping, .pill.post, .pill.pre-ping-test { background: var(--blue-bg); color: var(--blue); }

.filters { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 6px 10px;
}

.chip.is-on { background: var(--ink); color: #fff; }

details { margin-top: 4px; }
summary { cursor: pointer; color: var(--blue); }
pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #f7f3ec;
  border-radius: 8px;
  padding: 8px;
  margin: 6px 0 0;
  max-height: 220px;
  overflow: auto;
}

.empty {
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  font-size: 13px;
}

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

.linkish {
  background: none;
  color: var(--blue);
  padding: 0;
  border-radius: 0;
}

@media (max-width: 900px) {
  .content-top, main { padding-left: 16px; padding-right: 16px; }
  .message { margin-left: 16px; margin-right: 16px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .panel-head { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 640px) {
  form.panel, .stats { grid-template-columns: 1fr; }
  h1 { font-size: 30px; }
  .content-top { flex-direction: column; align-items: flex-start; }
}
