:root {
  color-scheme: dark;
  --background: #09090b;
  --panel: #17171b;
  --panel-raised: #202026;
  --border: #3b3b45;
  --text: #fff9ee;
  --muted: #aaa6ae;
  --orange: #ff703d;
  --pink: #ff315f;
  --purple: #b717c5;
  --yellow: #ffe879;
  --green: #52d397;
  --red: #ff6678;
  --focus: #7ddcff;
  --radius: 16px;
  --shadow: 0 16px 45px rgb(0 0 0 / 0.28);
  font-family:
    Inter,
    ui-sans-serif,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--background);
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 15% -10%, rgb(183 23 197 / 0.2), transparent 38rem),
    radial-gradient(circle at 100% 0%, rgb(255 112 61 / 0.15), transparent 32rem),
    var(--background);
}

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

button,
select,
input[type="checkbox"] {
  cursor: pointer;
}

button:disabled,
select:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.admin-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 88px;
  padding:
    calc(16px + env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    16px
    max(18px, env(safe-area-inset-left));
  border-bottom: 1px solid rgb(255 255 255 / 0.1);
  background: rgb(9 9 11 / 0.9);
  backdrop-filter: blur(18px);
}

.admin-header h1,
.section-heading h2 {
  margin: 0;
  letter-spacing: -0.035em;
}

.admin-header h1 {
  font-size: clamp(1.65rem, 7vw, 2.3rem);
  line-height: 1;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  border: 1px solid rgb(255 255 255 / 0.12);
  border-radius: 12px;
  object-fit: cover;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--orange);
  font-size: 0.7rem;
  font-weight: 850;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.icon-button {
  display: grid;
  width: 45px;
  height: 45px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  background: var(--panel);
  font-size: 1.5rem;
  line-height: 1;
}

.icon-button.busy {
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.admin-shell {
  display: grid;
  width: min(100% - 28px, 920px);
  gap: 20px;
  margin: 24px auto 54px;
}

.sync-panel,
.events-panel,
.status-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgb(23 23 27 / 0.96);
  box-shadow: var(--shadow);
}

.sync-panel,
.status-panel {
  padding: 20px;
}

.events-panel {
  padding: 20px 14px 14px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.section-heading h2 {
  font-size: 1.3rem;
}

.pending-summary,
.event-count,
.status-updated {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-align: right;
}

.pending-summary.has-pending {
  color: var(--yellow);
}

.sync-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 11px;
  margin-top: 18px;
}

.action-button {
  display: flex;
  min-height: 76px;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 0;
  border-radius: 13px;
  color: #100b0e;
  text-align: left;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.22);
}

.action-button > span:first-child {
  font-size: 1.65rem;
  font-weight: 900;
}

.action-button strong,
.action-button small {
  display: block;
}

.action-button strong {
  font-size: 1rem;
}

.action-button small {
  margin-top: 2px;
  font-size: 0.69rem;
  font-weight: 700;
  opacity: 0.7;
}

.action-button.pull {
  background: linear-gradient(135deg, var(--orange), #ffb14d);
}

.action-button.push {
  background: linear-gradient(135deg, var(--pink), #ff7290);
}

.sync-note,
.status-footnote {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.sync-note {
  margin: 14px 1px 0;
}

.event-heading {
  padding: 0 6px;
}

.event-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
  margin: 17px 0 14px;
}

.search-field input,
.filter-field select,
.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  background: #0f0f12;
}

.search-field input,
.filter-field select {
  height: 44px;
  padding: 0 12px;
}

.filter-field select {
  max-width: 190px;
}

.state-message {
  padding: 48px 16px;
  color: var(--muted);
  text-align: center;
}

.event-list {
  display: grid;
  gap: 12px;
}

.event-card {
  position: relative;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel-raised);
}

.event-card.is-dirty {
  border-color: var(--yellow);
  box-shadow: inset 4px 0 0 var(--yellow);
}

.event-card.is-saving {
  pointer-events: none;
  opacity: 0.68;
}

.event-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.event-date,
.event-place,
.event-id {
  margin: 0;
}

.event-date {
  font-size: 0.96rem;
  font-weight: 850;
}

.event-place {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.77rem;
  line-height: 1.35;
}

.sync-badge {
  flex: 0 0 auto;
  padding: 5px 8px;
  border: 1px solid rgb(82 211 151 / 0.38);
  border-radius: 999px;
  color: var(--green);
  background: rgb(82 211 151 / 0.09);
  font-size: 0.66rem;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sync-badge.needs-push {
  border-color: rgb(255 232 121 / 0.42);
  color: var(--yellow);
  background: rgb(255 232 121 / 0.09);
}

.publish-control {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #151519;
}

.publish-control > input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.toggle {
  position: relative;
  width: 43px;
  height: 25px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #54545e;
  transition: background 150ms ease;
}

.toggle::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: white;
  content: "";
  transition: transform 150ms ease;
}

.publish-input:checked + .toggle {
  background: linear-gradient(90deg, var(--purple), var(--pink));
}

.publish-input:checked + .toggle::after {
  transform: translateX(18px);
}

.publish-input:focus-visible + .toggle {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.publish-control strong,
.publish-control small {
  display: block;
}

.publish-control strong {
  font-size: 0.82rem;
}

.publish-control small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.7rem;
}

.field {
  display: block;
  margin-top: 13px;
}

.field > span {
  display: block;
  margin: 0 0 6px 2px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.field input,
.field textarea {
  padding: 11px 12px;
}

.field input {
  min-height: 44px;
}

.field textarea {
  min-height: 112px;
  line-height: 1.45;
  resize: vertical;
}

.event-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 13px;
}

.reset-button,
.save-button {
  min-height: 42px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 850;
}

.reset-button {
  border: 1px solid var(--border);
  color: var(--text);
  background: transparent;
}

.save-button {
  border: 0;
  color: #15080e;
  background: linear-gradient(135deg, var(--pink), var(--orange));
}

.event-id {
  margin-top: 12px;
  color: #77737c;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.64rem;
  overflow-wrap: anywhere;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0 0;
}

.status-grid > div {
  min-height: 79px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #101013;
}

.status-grid dt {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.status-grid dd {
  margin: 7px 0 0;
  font-size: 0.91rem;
  font-weight: 800;
  line-height: 1.3;
}

.status-grid dd.error {
  color: var(--red);
}

.status-grid dd.warning {
  color: var(--yellow);
}

.status-footnote {
  margin: 13px 2px 0;
}

.toast {
  position: fixed;
  z-index: 50;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  left: max(16px, env(safe-area-inset-left));
  max-width: 620px;
  padding: 13px 15px;
  border: 1px solid rgb(255 255 255 / 0.15);
  border-radius: 12px;
  color: #120c0f;
  background: var(--green);
  box-shadow: 0 18px 55px rgb(0 0 0 / 0.48);
  font-size: 0.84rem;
  font-weight: 800;
}

.toast.error {
  color: white;
  background: #b7253f;
}

.noscript {
  margin: 30px;
  color: var(--red);
}

@media (min-width: 680px) {
  .admin-shell {
    gap: 24px;
    margin-top: 32px;
  }

  .sync-panel,
  .status-panel {
    padding: 25px;
  }

  .events-panel {
    padding: 25px 20px 20px;
  }

  .event-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .status-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .toast {
    right: 22px;
    left: auto;
    min-width: 340px;
  }
}

@media (max-width: 470px) {
  .event-tools {
    grid-template-columns: 1fr;
  }

  .filter-field select {
    max-width: none;
  }

  .action-button {
    align-items: flex-start;
    gap: 8px;
    padding: 13px 11px;
  }

  .action-button > span:first-child {
    font-size: 1.35rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
