:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --text: #202624;
  --muted: #66706c;
  --line: #d9ded8;
  --line-strong: #b9c2ba;
  --primary: #0f766e;
  --primary-dark: #0b5f59;
  --accent: #b45309;
  --danger: #b91c1c;
  --danger-bg: #fff1f2;
  --ok-bg: #ecfdf5;
  --warn-bg: #fff7ed;
  --shadow: 0 18px 38px rgba(24, 36, 32, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 14px;
}

.brand-mark {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 800;
  letter-spacing: 0;
  flex: 0 0 auto;
}

.brand-mark.admin {
  background: var(--accent);
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.topnav {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.topnav a {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  background: #ffffff;
}

.topnav a:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.shell,
.admin-shell {
  display: grid;
  gap: 20px;
  width: min(1180px, calc(100vw - 32px));
  margin: 24px auto;
}

.shell {
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.9fr);
}

.admin-shell {
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
}

.single-shell {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
}

.tool-panel,
.result-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.tool-panel {
  padding: 22px;
}

.result-panel {
  position: sticky;
  top: 20px;
  align-self: start;
  padding: 24px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.section-title.compact {
  margin: 0 0 10px;
}

.section-title h2,
.section-title h3 {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
}

.section-title h3 {
  font-size: 14px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid > .section-title,
.field-wide,
.campaign-meta,
.conditional-fields,
.actions,
.message-box {
  grid-column: 1 / -1;
}

.field {
  display: grid;
  gap: 7px;
}

.field span,
.check-row span {
  color: #34413d;
  font-size: 13px;
  font-weight: 650;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 9px 11px;
  background: #ffffff;
  color: var(--text);
}

.field textarea {
  min-height: 84px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  outline: 3px solid rgba(15, 118, 110, 0.16);
}

.field-code input {
  text-transform: uppercase;
  font-weight: 750;
  letter-spacing: 0;
}

.check-row {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  flex: 0 0 auto;
}

.compact-check {
  padding-top: 25px;
}

.campaign-meta {
  min-height: 46px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf7;
  color: var(--muted);
}

.campaign-meta strong {
  color: var(--text);
}

.campaign-meta.is-empty {
  border-style: dashed;
}

.conditional-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.conditional-fields[hidden] {
  display: none;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 750;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.button.primary {
  background: var(--primary);
  color: #ffffff;
}

.button.primary:hover {
  background: var(--primary-dark);
}

.button.secondary,
.button.ghost {
  border-color: var(--line-strong);
  background: #ffffff;
  color: var(--text);
}

.button.secondary:hover,
.button.ghost:hover {
  border-color: var(--primary);
}

.button.danger {
  border-color: #fecdd3;
  background: var(--danger-bg);
  color: var(--danger);
}

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

.status-badge {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border-radius: 999px;
  padding: 0 10px;
  background: #eef2f0;
  color: #43514d;
  font-size: 12px;
  font-weight: 800;
}

.status-badge.ok {
  background: var(--ok-bg);
  color: #047857;
}

.status-badge.warn {
  background: var(--warn-bg);
  color: #9a3412;
}

.status-badge.error {
  background: var(--danger-bg);
  color: var(--danger);
}

.result-block {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.secondary-result {
  padding-top: 14px;
}

.result-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.amount {
  display: block;
  min-height: 54px;
  font-size: 42px;
  line-height: 1.1;
  letter-spacing: 0;
}

.amount.small {
  min-height: 36px;
  font-size: 28px;
}

.message-box {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf7;
  color: #43514d;
  font-size: 14px;
  line-height: 1.45;
}

.message-box.error {
  border-color: #fecdd3;
  background: var(--danger-bg);
  color: var(--danger);
}

.message-box.ok {
  border-color: #bbf7d0;
  background: var(--ok-bg);
  color: #047857;
}

.details-list {
  display: grid;
  gap: 0;
  margin: 18px 0 0;
  border-top: 1px solid var(--line);
}

.details-list div {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.details-list dt {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.details-list dd {
  margin: 0;
  font-weight: 750;
}

.admin-form-panel {
  align-self: start;
}

.token-row,
.filter-row {
  display: grid;
  align-items: end;
  gap: 12px;
  margin-bottom: 18px;
}

.token-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.filter-row {
  grid-template-columns: minmax(220px, 1fr) auto auto;
}

.admin-campaign-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.table-panel {
  min-width: 0;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.campaign-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: #ffffff;
}

.campaign-table th,
.campaign-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

.campaign-table th {
  position: sticky;
  top: 0;
  background: #f8faf7;
  color: #34413d;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.campaign-table tbody tr {
  cursor: pointer;
}

.campaign-table tbody tr:hover {
  background: #f2f7f5;
}

.campaign-table tbody tr.selected {
  background: #e6f4f1;
}

.campaign-code {
  font-weight: 850;
}

.inactive-row {
  color: var(--muted);
}

.pill {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  padding: 0 9px;
  background: #eef2f0;
  color: #34413d;
  font-size: 12px;
  font-weight: 800;
}

.pill.inactive {
  background: #f1f5f9;
  color: #64748b;
}

.pill.active {
  background: var(--ok-bg);
  color: #047857;
}

.param-help {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

@media (max-width: 920px) {
  .shell,
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .result-panel {
    position: static;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topnav,
  .topnav a {
    width: 100%;
  }

  .form-grid,
  .conditional-fields,
  .admin-campaign-form,
  .token-row,
  .filter-row {
    grid-template-columns: 1fr;
  }

  .compact-check {
    padding-top: 0;
  }

  .details-list div {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .amount {
    font-size: 34px;
  }
}
