:root {
  color-scheme: light;
  --ink: #18202a;
  --muted: #667085;
  --line: #d8dee8;
  --paper: #f6f8fb;
  --panel: #ffffff;
  --accent: #1f7a6b;
  --accent-strong: #155f53;
  --blue: #2d5f9a;
  --yellow: #f5c451;
  --danger: #bc3f3f;
  --shadow: 0 16px 40px rgba(26, 36, 52, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
  background: #ffffff;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 48px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  line-height: 1.15;
}

.brand span,
.panel-label,
.eyebrow {
  color: var(--muted);
  font-size: 0.78rem;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tab,
.button,
.segment,
.icon-button {
  border: 1px solid transparent;
  border-radius: 8px;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.nav-tab.active {
  background: #e8f3f1;
  color: var(--accent-strong);
  border-color: #c7e2dc;
}

.sidebar-panel,
.panel,
.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.sidebar-panel {
  display: grid;
  gap: 12px;
  margin-top: auto;
  padding: 16px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 9px 14px;
  background: #ffffff;
  color: var(--ink);
  border-color: var(--line);
  font-weight: 650;
}

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

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

.button.full {
  width: 100%;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 5px;
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 750;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.8rem, 2.6vw, 2.35rem);
}

h2 {
  font-size: 1.08rem;
}

.sync-status,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #edf3fb;
  color: var(--blue);
  font-weight: 700;
  font-size: 0.84rem;
}

.sync-status.error {
  background: #ffe8e8;
  color: var(--danger);
}

.status-details {
  margin: -10px 0 18px;
  padding: 12px 14px;
  border: 1px solid #d6e2f2;
  border-radius: 8px;
  background: #f7fbff;
  color: #24364b;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.status-details.error {
  border-color: #f0b8b8;
  background: #fff5f5;
  color: var(--danger);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric {
  padding: 16px;
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 2rem;
  line-height: 1;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  margin-bottom: 14px;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px;
  background: #e9edf3;
  border-radius: 8px;
}

.segment {
  min-height: 34px;
  padding: 6px 10px;
  background: transparent;
  color: var(--muted);
  border-color: transparent;
  font-weight: 700;
}

.segment.active {
  background: #ffffff;
  color: var(--ink);
  border-color: var(--line);
}

.search {
  width: min(360px, 100%);
}

.search span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 11px;
}

textarea {
  resize: vertical;
}

.event-table-wrap {
  position: relative;
  overflow: auto;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.event-table {
  width: 100%;
  min-width: 1060px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #fbfcfe;
}

td {
  font-size: 0.94rem;
}

tr:last-child td {
  border-bottom: 0;
}

.event-name-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  font-weight: 800;
  text-align: left;
}

.event-description {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  max-width: 420px;
  line-height: 1.35;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e8f3f1;
  color: var(--accent-strong);
  font-weight: 750;
  font-size: 0.78rem;
}

.status-pill.pending {
  background: #fff4cf;
  color: #7d5a00;
}

.repeat-control {
  display: grid;
  gap: 8px;
  min-width: 150px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.86rem;
}

.checkbox-label input {
  width: 16px;
  height: 16px;
}

.repeat-control select {
  min-height: 34px;
  padding: 6px 8px;
}

.repeat-control select:disabled {
  color: var(--muted);
  background: #f3f5f8;
}

.event-type-select {
  min-width: 110px;
  min-height: 34px;
  padding: 6px 8px;
}

.empty-state {
  display: none;
  padding: 32px;
  color: var(--muted);
  text-align: center;
}

.empty-state.visible {
  display: block;
}

.admin-grid,
.workflow-grid {
  display: grid;
  grid-template-columns: minmax(300px, 440px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.panel {
  padding: 18px;
  box-shadow: var(--shadow);
}

.section-panel {
  display: grid;
  gap: 0;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
}

form.panel {
  display: grid;
  gap: 13px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hidden {
  display: none !important;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-weight: 700;
  font-size: 0.9rem;
}

.source-list {
  display: grid;
  gap: 10px;
}

.source-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.source-item strong,
.source-item span {
  display: block;
}

.source-item span {
  margin-top: 3px;
  color: var(--muted);
  overflow-wrap: anywhere;
  font-size: 0.86rem;
}

.source-actions {
  display: flex;
  gap: 6px;
}

.source-action-button {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 750;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
  font-weight: 800;
}

.workflow-steps {
  display: grid;
  gap: 14px;
  margin: 0;
  padding-left: 22px;
}

.workflow-steps li {
  padding-left: 5px;
}

.workflow-steps strong,
.workflow-steps span {
  display: block;
}

.workflow-steps span {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.45;
}

.field-map {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr);
  gap: 8px 12px;
  align-items: center;
}

code {
  display: inline-block;
  padding: 4px 7px;
  border-radius: 6px;
  background: #eef2f6;
  color: #24364b;
}

dialog {
  width: min(620px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 90px rgba(26, 36, 52, 0.25);
}

dialog::backdrop {
  background: rgba(24, 32, 42, 0.36);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.dialog-body {
  display: grid;
  gap: 10px;
}

.detail-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 12px;
  line-height: 1.45;
}

.detail-row span:first-child {
  color: var(--muted);
  font-weight: 750;
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 14px;
    gap: 12px;
  }

  .nav-tabs {
    grid-template-columns: repeat(4, 1fr);
  }

  .nav-tab {
    justify-content: center;
    text-align: center;
  }

  .sidebar-panel {
    display: none;
  }

  .main {
    padding: 18px;
  }

  .metrics,
  .admin-grid,
  .workflow-grid {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .search {
    width: 100%;
  }
}

@media (max-width: 580px) {
  .brand {
    align-items: flex-start;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .nav-tab {
    padding: 9px 8px;
    font-size: 0.86rem;
  }

  .metric strong {
    font-size: 1.65rem;
  }

  .segment {
    flex: 1 1 130px;
  }

  .detail-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}
