:root {
  --ink: #10231f;
  --ink-soft: #1c3832;
  --paper: #f3efe6;
  --paper-2: #e8e1d2;
  --line: rgba(16, 35, 31, 0.12);
  --accent: #c45c26;
  --accent-deep: #9a3f14;
  --teal: #1f6f63;
  --teal-soft: #d7ebe6;
  --done: #1f6f63;
  --live: #2f6fed;
  --wait: #b7791f;
  --cancel: #b42318;
  --muted: #5d6b66;
  --shadow: 0 18px 50px rgba(16, 35, 31, 0.12);
  --radius: 18px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Manrope", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(1100px 520px at 8% -10%, rgba(196, 92, 38, 0.18), transparent 55%),
    radial-gradient(900px 480px at 100% 0%, rgba(31, 111, 99, 0.16), transparent 50%),
    linear-gradient(180deg, #f7f3eb 0%, var(--paper) 40%, #ebe4d6 100%);
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

.shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 3rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.brand {
  display: grid;
  gap: 0.35rem;
}

.brand__mark {
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 3vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

.brand__mark span { color: var(--accent); }

.brand__sub {
  color: var(--muted);
  font-size: 0.82rem;
  max-width: 42ch;
}

.stats {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stat {
  min-width: 88px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,0.55);
  backdrop-filter: blur(8px);
}

.stat strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.15rem;
  line-height: 1.1;
}

.stat span {
  color: var(--muted);
  font-size: 0.7rem;
}

.panel {
  background: rgba(255,255,255,0.72);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.filters {
  padding: 0.75rem 0.85rem;
  margin-bottom: 0.85rem;
}

.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.65rem;
  align-items: end;
}

.filters .field {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
}

.filters .field > label:not(.proto-toggle) {
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
  align-items: baseline;
}

.filters .field > input,
.filters .field > select,
.filters .pair input,
.filters .pair select,
.filters .range-values input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 0.5rem 0.65rem;
  color: var(--ink);
  min-height: 2.35rem;
}

.filters .field > input:focus,
.filters .field > select:focus,
.filters .pair input:focus,
.filters .pair select:focus {
  outline: 2px solid rgba(196, 92, 38, 0.35);
  border-color: transparent;
}

.field-grow { flex: 1.4 1 220px; }
.field-sm { flex: 0.8 1 130px; }
.field-sum { flex: 0.9 1 150px; }
.field-range { flex: 1.1 1 200px; }
.field-sort { flex: 0.95 1 160px; }
.filters .field.field-actions {
  flex: 0 0 auto;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
  min-width: max-content;
}

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
}

.field-sort .pair {
  grid-template-columns: 1fr 3rem;
}

.range-hint {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 700;
  color: var(--teal);
  font-size: 0.75rem;
}

.range-box {
  display: grid;
  gap: 0.3rem;
}

.range-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
}

.range-values input {
  text-align: center;
  padding: 0.35rem 0.4rem !important;
  min-height: 1.9rem !important;
  font-size: 0.85rem;
}

.range-slider {
  position: relative;
  height: 22px;
}

.range-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 5px;
  border-radius: 999px;
  background: #ddd4c4;
  pointer-events: none;
  z-index: 1;
}

.range-track::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--range-from, 0%);
  right: calc(100% - var(--range-to, 100%));
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--accent));
}

.range-slider input[type="range"] {
  position: absolute;
  inset: 0;
  width: 100%;
  margin: 0;
  padding: 0 !important;
  min-height: 0 !important;
  appearance: none;
  -webkit-appearance: none;
  background: transparent !important;
  border: 0 !important;
  outline: none !important;
  box-shadow: none !important;
  pointer-events: none;
  z-index: 2;
}

.range-slider input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  background: transparent;
}

.range-slider input[type="range"]::-moz-range-track {
  height: 5px;
  background: transparent;
  border: none;
}

.range-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--ink);
  box-shadow: 0 1px 3px rgba(16, 35, 31, 0.2);
  pointer-events: auto;
  cursor: pointer;
  position: relative;
  z-index: 3;
}

.range-slider input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--ink);
  box-shadow: 0 1px 3px rgba(16, 35, 31, 0.2);
  pointer-events: auto;
  cursor: pointer;
}

.filters .field label.proto-toggle,
.proto-toggle {
  display: inline-flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  justify-content: flex-start !important;
  align-items: center !important;
  gap: 0.5rem;
  min-height: 2.35rem;
  padding: 0 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  user-select: none;
  white-space: nowrap !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  color: inherit;
  flex: 0 0 auto;
  width: auto !important;
  max-width: none;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

.proto-toggle input {
  position: absolute !important;
  opacity: 0 !important;
  width: 1px !important;
  height: 1px !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  pointer-events: none;
}

.proto-toggle__box {
  width: 1.05rem;
  height: 1.05rem;
  border-radius: 6px;
  border: 1.5px solid rgba(16, 35, 31, 0.35);
  background: #fff;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  transition: background .15s ease, border-color .15s ease;
}

.proto-toggle__box::after {
  content: "";
  width: 0.35rem;
  height: 0.6rem;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-0.5px, -1px) scale(0);
  transition: transform .12s ease;
}

.proto-toggle__text {
  display: inline-block;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: none !important;
  letter-spacing: 0 !important;
  white-space: nowrap !important;
  line-height: 1;
}

.proto-toggle:hover {
  border-color: rgba(31, 111, 99, 0.45);
}

.proto-toggle:has(input:checked) {
  background: var(--teal-soft);
  border-color: rgba(31, 111, 99, 0.55);
  box-shadow: inset 0 0 0 1px rgba(31, 111, 99, 0.08);
}

.proto-toggle:has(input:checked) .proto-toggle__box {
  background: var(--teal);
  border-color: var(--teal);
}

.proto-toggle:has(input:checked) .proto-toggle__box::after {
  transform: rotate(45deg) translate(-0.5px, -1px) scale(1);
}

.proto-toggle:has(input:focus-visible) {
  outline: 2px solid rgba(196, 92, 38, 0.35);
  outline-offset: 2px;
}

.field-actions .btn {
  min-height: 2.35rem;
  padding: 0.5rem 1.05rem;
}

.sort-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dashed transparent;
}

.sort-link:hover {
  color: var(--teal);
  border-bottom-color: rgba(31, 111, 99, 0.45);
}

.sort-link.is-active {
  color: var(--accent-deep);
  border-bottom-color: rgba(154, 63, 20, 0.45);
}

.participants-count {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.participants-count.has-value {
  color: var(--teal);
}

.field { display: grid; gap: 0.35rem; }
.field label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field input,
.field select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  color: var(--ink);
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(196, 92, 38, 0.35);
  border-color: transparent;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.7rem 0.2rem 0.2rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 0;
  border-radius: 12px;
  padding: 0.75rem 1.1rem;
  cursor: pointer;
  font-weight: 700;
  transition: transform .15s ease, background .15s ease;
}

.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--ink-soft); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-deep); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

.btn-donor__icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border-radius: 3px;
  object-fit: contain;
  image-rendering: pixelated;
}

.table-wrap { overflow-x: auto; }

table.adverts {
  width: 100%;
  border-collapse: collapse;
}

table.adverts th,
table.adverts td {
  padding: 0.95rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

table.adverts th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: rgba(243, 239, 230, 0.65);
}

table.adverts tbody tr {
  transition: background .15s ease;
}

table.adverts tbody tr:hover {
  background: rgba(31, 111, 99, 0.06);
}

.adv-id {
  font-weight: 800;
  color: var(--teal);
}

.adv-title {
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 0.25rem;
}

.adv-meta {
  color: var(--muted);
  font-size: 0.86rem;
}

.money {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.tone-done { background: #d9f0ea; color: #0f5248; }
.tone-live { background: #dce8ff; color: #1d4fbf; }
.tone-wait { background: #f8e8c7; color: #8a5a10; }
.tone-cancel { background: #f8d6d3; color: #8f1d16; }
.tone-muted { background: #e7e2d8; color: #4d5753; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal);
  font-size: 0.75rem;
  font-weight: 700;
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  flex-wrap: wrap;
}

.pagination .links {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.pagination .links a,
.pagination .links span {
  display: inline-flex;
  min-width: 2.2rem;
  height: 2.2rem;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 0.9rem;
}

.pagination .links span[aria-current="page"] {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.empty {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--muted);
}

/* detail */
.crumb {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  color: var(--muted);
  margin-bottom: 1rem;
  font-size: 0.92rem;
}

.detail-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: start;
  padding: 1.4rem;
  margin-bottom: 1rem;
}

.detail-head h1 {
  margin: 0.4rem 0 0.6rem;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.detail-actions {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  align-items: stretch;
}

.grid-info {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.info-card {
  padding: 1rem 1.1rem;
}

.info-card .label {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.info-card .value {
  font-weight: 700;
  line-height: 1.35;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin: 0 0 0.85rem;
}

.lots-panel { padding: 1.2rem; }

table.lots td, table.lots th {
  font-size: 0.92rem;
}

@media (max-width: 960px) {
  .grid-info { grid-template-columns: 1fr 1fr; }
  .detail-head { grid-template-columns: 1fr; }
  .stats { justify-content: flex-start; }
  .filters .field.field-actions { width: 100%; justify-content: flex-start; }
  .filters .field.field-actions .btn { margin-left: auto; }
}

@media (max-width: 640px) {
  .grid-info { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: stretch; }
  .field-grow,
  .field-sm,
  .field-sum,
  .field-range,
  .field-sort { flex: 1 1 100%; }
}
