:root {
  color-scheme: dark;
  --bg: #0b111d;
  --surface: #121c2d;
  --surface-2: #17243a;
  --line: #263750;
  --text: #f5f7fb;
  --muted: #91a0b7;
  --accent: #70eead;
  --accent-dark: #163d31;
  --danger: #ff7b8b;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 90% -10%, rgba(54, 138, 111, 0.26), transparent 36rem),
    var(--bg);
  color: var(--text);
}

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

.topbar,
main {
  width: min(1080px, calc(100% - 32px));
  margin-inline: auto;
}

.topbar {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

h1, h2, p { margin-top: 0; }
h1 { font-size: 1.25rem; margin-bottom: 0; }
h2 { font-size: clamp(1.45rem, 4vw, 2.5rem); line-height: 1.08; margin-bottom: 12px; }

.eyebrow {
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.hero {
  min-height: 330px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 40px;
}

.hero > div { max-width: 680px; }
.hero p:not(.eyebrow) { color: var(--muted); max-width: 600px; line-height: 1.6; }

.button {
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--text);
  font-weight: 750;
}

.button-primary { background: var(--accent); color: #07140e; }
.button-primary:hover { filter: brightness(1.06); }
.button-ghost { background: transparent; border-color: var(--line); }
.button-danger { background: transparent; border-color: #65303a; color: var(--danger); }
.button-danger:hover { background: #2b171c; }
.button-small { min-height: 38px; padding-inline: 14px; font-size: 0.88rem; }

.status {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--muted);
  font-size: 0.78rem;
}
.status-ok { color: var(--accent); border-color: #275f4b; background: #102a22; }
.status-error { color: var(--danger); border-color: #65303a; background: #2b171c; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-block: 1px solid var(--line);
  margin-bottom: 64px;
}

.stats article { padding: 24px 0; display: flex; flex-direction: column; gap: 5px; }
.stats strong { font-size: 1.75rem; }
.stats span { color: var(--muted); font-size: 0.85rem; }

.section-heading { display: flex; justify-content: space-between; align-items: end; }
.campaign-grid { display: grid; gap: 12px; padding-bottom: 80px; }

.campaign {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(135deg, var(--surface), rgba(18, 28, 45, 0.55));
}

.campaign h3 { margin: 0 0 7px; }
.campaign-meta { color: var(--muted); font-size: 0.86rem; }
.campaign-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  max-width: 520px;
}
.badge { display: inline-block; padding: 4px 8px; border-radius: 7px; background: var(--accent-dark); color: var(--accent); font-size: 0.72rem; font-weight: 750; }
.badge-off { background: #2a303a; color: var(--muted); }
.empty { color: var(--muted); padding: 30px 0; }

dialog {
  width: min(760px, calc(100% - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
}
dialog::backdrop { background: rgba(3, 7, 13, 0.8); backdrop-filter: blur(5px); }

#campaign-form { padding: 24px; }
.dialog-heading, .dialog-actions { display: flex; align-items: center; justify-content: space-between; }
.icon-button { border: 0; background: transparent; color: var(--muted); font-size: 2rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin: 20px 0; }
.wide { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 7px; color: var(--muted); font-size: 0.82rem; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0d1624;
  color: var(--text);
  padding: 0 12px;
  outline: none;
}
textarea {
  min-height: 150px;
  padding-block: 10px;
  resize: vertical;
  line-height: 1.45;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }

.child-age-field {
  display: grid;
  gap: 7px;
}

.child-age-selects {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.reference-field { display: flex; flex-direction: column; gap: 7px; }
.field-label { color: var(--muted); font-size: 0.82rem; }
.reference-checklist {
  display: grid;
  gap: 3px;
  max-height: 190px;
  overflow-y: auto;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0d1624;
}
.reference-option {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  padding: 5px 7px;
  border-radius: 7px;
  color: var(--text);
  cursor: pointer;
}
.reference-option:hover { background: var(--surface-2); }
.reference-option input {
  width: 17px;
  min-height: 17px;
  margin: 0;
  accent-color: var(--accent);
}
.reference-name {
  flex: 1;
}
.reference-id {
  margin-left: auto;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  white-space: nowrap;
}
.country-region-limits {
  display: grid;
  gap: 10px;
}
.country-region-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0d1624;
}
.country-region-title {
  display: grid;
  gap: 3px;
}
.country-region-title strong {
  color: var(--text);
  font-size: 0.9rem;
}
.country-region-title span {
  color: var(--muted);
  font-size: 0.74rem;
}
.country-region-checklist {
  max-height: 150px;
}
.id-directory {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0d1624;
}
.id-directory-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.id-directory-heading > div {
  display: grid;
  gap: 4px;
}
.id-directory-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.id-directory-results {
  display: grid;
  gap: 7px;
  max-height: 260px;
  overflow-y: auto;
}
.id-directory-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}
.id-directory-row > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.id-directory-row strong {
  overflow: hidden;
  color: var(--text);
  font-size: 0.86rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.id-directory-row span:not(.reference-id) {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reference-tools { display: flex; align-items: center; gap: 8px; }
.reference-tools input { flex: 1; }
.reference-tools .text-button { white-space: nowrap; }
.field-hint { color: var(--muted); font-size: 0.75rem; }
.reference-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.8rem;
}
.text-button {
  padding: 4px;
  border: 0;
  background: transparent;
  color: var(--accent);
}
.time-builder { display: grid; gap: 8px; }
.time-input-row { display: flex; gap: 8px; }
.time-input-row input { flex: 1; }
.time-chips { display: flex; flex-wrap: wrap; gap: 7px; min-height: 28px; }
.time-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px 5px 10px;
  border: 1px solid #275f4b;
  border-radius: 999px;
  background: var(--accent-dark);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
}
.time-chip button {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font-size: 1rem;
  line-height: 1;
}
.check { flex-direction: row; align-items: center; }
.check input { width: 18px; min-height: 18px; accent-color: var(--accent); }
.checks { display: flex; flex-wrap: wrap; gap: 16px 24px; }
.weekdays {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.weekdays legend { padding-inline: 6px; color: var(--muted); font-size: 0.82rem; }
.weekdays label { display: inline-flex; flex-direction: row; align-items: center; margin-right: 12px; }
.weekdays input { width: 16px; min-height: 16px; accent-color: var(--accent); }
.advanced {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0d162480;
}
.advanced summary {
  padding: 14px;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
}
.advanced > .form-grid, .template-fields { padding: 0 14px 14px; margin: 0; }
.template-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.template-editor { min-width: 0; }
.rich-editor {
  min-height: 220px;
  max-height: 420px;
  overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #0d1624;
  color: var(--text);
  outline: none;
  white-space: pre-wrap;
  line-height: 1.5;
}
.rich-editor:focus { border-color: var(--accent); }
.rich-editor a { color: var(--accent); text-decoration: underline; }
.link-panel {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  gap: 7px;
  margin: 0 0 8px;
}
.link-panel .button { min-height: 40px; padding-inline: 10px; font-size: 0.76rem; }
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 7px 0;
}
.editor-toolbar button,
.editor-toolbar select {
  width: auto;
  min-height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.76rem;
}
.editor-toolbar select { flex: 1; min-width: 125px; }
.dialog-actions { justify-content: flex-end; gap: 10px; }
.error { color: var(--danger); font-size: 0.85rem; }
.toast { position: fixed; right: 20px; bottom: 20px; max-width: 380px; padding: 14px 16px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); box-shadow: 0 16px 50px #0008; }
.compact-dialog { width: min(620px, calc(100% - 24px)); padding: 24px; }
.post-preview {
  overflow: hidden;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #0d1624;
}
.post-preview img { display: block; width: 100%; max-height: 280px; object-fit: cover; }
.post-preview-text {
  margin: 0;
  padding: 18px;
  color: var(--text);
  white-space: pre-wrap;
  font: inherit;
  line-height: 1.5;
}
.post-preview-text a { color: var(--accent); font-weight: 750; }
.fake-button {
  display: block;
  margin: 0 18px 18px;
  padding: 10px;
  border-radius: 9px;
  text-align: center;
  background: var(--surface-2);
  color: var(--accent);
  font-weight: 700;
}
.run-row { padding: 14px 0; border-bottom: 1px solid var(--line); }
.run-row > div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 16px; }
.run-row span { color: var(--muted); font-size: 0.82rem; }
.run-row .error { margin: 10px 0 0; }

@media (max-width: 680px) {
  .hero { grid-template-columns: 1fr; gap: 10px; padding-block: 60px; }
  .hero .button { width: 100%; }
  .stats article { padding-right: 8px; }
  .campaign { grid-template-columns: 1fr; }
  .campaign-actions { justify-content: stretch; }
  .campaign-actions .button { flex: 1 1 100px; }
  .form-grid { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
  .template-fields { grid-template-columns: 1fr; }
  .link-panel { grid-template-columns: 1fr 1fr; }
  .link-panel input { grid-column: 1 / -1; }
  .id-directory-heading { align-items: stretch; flex-direction: column; }
  .id-directory-grid { grid-template-columns: 1fr; }
  .id-directory-row { grid-template-columns: minmax(0, 1fr) auto; }
  .id-directory-row .text-button { grid-column: 1 / -1; justify-self: start; }
  .reference-tools { flex-wrap: wrap; }
  .reference-tools input { flex-basis: 100%; }
}
