:root {
  --ink: #1c1914;
  --muted: #6d675d;
  --paper: #f4efe6;
  --panel: #fffaf3;
  --line: #ddd4c6;
  --gold: #8a6d3b;
  --gold-deep: #6e5429;
  --danger: #8f2d2d;
  --available: #2f6b4f;
  --reserved: #9a6b24;
  --incoming: #2c5d8a;
  --sold: #6d675d;
  --draft: #8a8378;
  --in_service: #5a4b8a;
  --written_off: #8f2d2d;
  --unlisted: #b3aa9c;
  --pending: #9a6b24;
  --active: #2f6b4f;
  --ended: #6d675d;
  --error: #8f2d2d;
  --shadow: 0 1px 2px rgba(28, 25, 20, 0.06);
}

* { box-sizing: border-box; }

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

body {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, "Times New Roman", serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.45;
}

body.app {
  background:
    radial-gradient(1200px 400px at 10% -10%, rgba(138, 109, 59, 0.08), transparent 50%),
    var(--paper);
}

h1, h2, h3 {
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 0.6rem;
}

h1 { font-size: 1.85rem; }
h2 { font-size: 1.1rem; }

a {
  color: var(--gold-deep);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.5rem 1.5rem;
  background: #161410;
  color: #f4efe6;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar nav {
  display: flex;
  gap: 1rem;
  flex: 1;
}

.topbar a, .topbar .text-btn {
  color: #f4efe6;
  background: none;
  border: 0;
  font: inherit;
  cursor: pointer;
  padding: 0;
}

.wordmark {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none !important;
  color: #f4efe6 !important;
}

.wordmark img {
  display: block;
  height: 4.5rem;
  width: auto;
}

.topbar-end {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.who { color: #cbbfaa; font-size: 0.9rem; }

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 4rem;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.auth-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 2rem;
  box-shadow: var(--shadow);
}

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

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--gold);
  margin: 0 0 0.25rem;
}

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

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stats article, .panel, .empty, .channel-card {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 0.2rem;
}

.stats strong { font-size: 1.35rem; }

.filters, .stack, .actions, .choice-row, .row-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: end;
}

.stack { flex-direction: column; align-items: stretch; }
.stack.tight { gap: 0.4rem; }
.actions { align-items: center; }
.actions.wrap { margin-bottom: 0.75rem; }

.filters {
  margin-bottom: 1rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.92rem;
}

.choice {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
}

.short { max-width: 10rem; }

input, select, textarea, button, .btn {
  font: inherit;
}

input, select, textarea {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0.45rem 0.55rem;
  border-radius: 2px;
}

.btn, input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  border-radius: 2px;
  text-decoration: none !important;
}

.btn.primary, input[type="submit"].btn.primary, input[type="submit"]:not(.btn) {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

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

.text-btn {
  background: none;
  border: 0;
  color: var(--gold-deep);
  padding: 0;
  cursor: pointer;
  font: inherit;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
}

table.data th, table.data td {
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

table.data th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}

.thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  display: block;
  background: #ece6da;
}

.thumb-placeholder {
  display: grid;
  place-items: center;
  font-size: 0.7rem;
  color: var(--muted);
}

.pill {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  background: #ece6da;
}

.pill-available, .pill-active { background: color-mix(in srgb, var(--available) 18%, white); color: var(--available); }
.pill-reserved, .pill-pending { background: color-mix(in srgb, var(--reserved) 18%, white); color: var(--reserved); }
.pill-incoming { background: color-mix(in srgb, var(--incoming) 18%, white); color: var(--incoming); }
.pill-sold, .pill-ended, .pill-unlisted { background: #ece6da; color: var(--sold); }
.pill-draft { color: var(--draft); }
.pill-in_service { background: color-mix(in srgb, var(--in_service) 18%, white); color: var(--in_service); }
.pill-written_off, .pill-error { background: color-mix(in srgb, var(--danger) 16%, white); color: var(--danger); }

.channel-dots { display: flex; gap: 0.3rem; }
.dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--unlisted);
  display: inline-block;
}
.dot-active { background: var(--active); }
.dot-pending { background: var(--pending); }
.dot-error { background: var(--error); }
.dot-ended { background: var(--ended); }

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(260px, 0.9fr);
  gap: 1.25rem;
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.8rem 1rem;
  margin: 0 0 1rem;
}

.facts div { margin: 0; }
.facts dt { color: var(--muted); font-size: 0.78rem; }
.facts dd { margin: 0.15rem 0 0; }

.form-wide, fieldset {
  max-width: 820px;
}

fieldset {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 1rem 1.1rem 1.15rem;
  margin: 0;
}

legend {
  padding: 0 0.35rem;
  color: var(--gold-deep);
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem 1rem;
}

.photo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.photo {
  width: 160px;
  height: 160px;
  object-fit: cover;
  background: #ece6da;
}

.photo-grid.large .photo {
  width: min(100%, 360px);
  height: auto;
  max-height: 420px;
}

.channel-cards {
  display: grid;
  gap: 0.5rem;
}

.flash {
  padding: 0.7rem 0.85rem;
  margin-bottom: 1rem;
  border: 1px solid var(--line);
}

.flash.notice { background: color-mix(in srgb, var(--available) 12%, white); }
.flash.alert { background: color-mix(in srgb, var(--danger) 12%, white); }

.errors {
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 0.75rem 1rem;
  background: #fff;
}

.empty { text-align: center; padding: 2rem 1rem; }
.empty.compact { padding: 1rem; }

.plain-list { padding-left: 1.1rem; }
.row-actions { justify-content: flex-end; }

@media (max-width: 800px) {
  .topbar { flex-wrap: wrap; }
  .split { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; }
}
