:root {
  --page: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #eef4f6;
  --text: #142033;
  --muted: #647184;
  --line: #dbe3ec;
  --blue: #1f67e7;
  --teal: #108b87;
  --amber: #b7791f;
  --red: #c43d4b;
  --green: #18794e;
  --shadow: 0 18px 40px rgba(31, 46, 71, 0.11);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(31, 103, 231, 0.10), transparent 34%),
    linear-gradient(225deg, rgba(16, 139, 135, 0.12), transparent 30%),
    var(--page);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

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

button {
  border: 0;
}

.app-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

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

.setup-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid rgba(183, 121, 31, 0.25);
  border-radius: calc(var(--radius) + 4px);
  background: linear-gradient(135deg, rgba(255, 247, 232, 0.95), rgba(255, 255, 255, 0.95));
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.setup-alert strong {
  display: block;
  margin-bottom: 4px;
  color: #8c5c13;
}

.setup-alert p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.setup-alert.is-hidden {
  display: none;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.9rem, 4vw, 3rem);
  line-height: 1.05;
}

h2 {
  margin-bottom: 0;
  font-size: 1.1rem;
}

h3 {
  margin-bottom: 12px;
  font-size: 1rem;
}

.status-badge,
.small-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-badge.is-ready {
  color: var(--green);
  border-color: rgba(24, 121, 78, 0.28);
  background: #edf8f2;
}

.status-badge.is-warning {
  color: var(--amber);
  border-color: rgba(183, 121, 31, 0.28);
  background: #fff7e8;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(260px, 0.9fr);
  gap: 16px;
  margin-bottom: 16px;
}

.hero-copy,
.hero-tile {
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 6px);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.hero-copy {
  padding: 24px;
}

.hero-copy h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  margin-bottom: 10px;
}

.hero-copy p {
  color: var(--muted);
  line-height: 1.7;
  max-width: 68ch;
}

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

.hero-actions .ghost-button {
  background: #fff;
}

.hero-stack {
  display: grid;
  gap: 12px;
}

.hero-tile {
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.hero-tile::after {
  content: "";
  position: absolute;
  inset: auto -18px -18px auto;
  width: 108px;
  height: 108px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(31, 103, 231, 0.16), transparent 68%);
}

.hero-tile.accent::after {
  background: radial-gradient(circle, rgba(16, 139, 135, 0.18), transparent 68%);
}

.hero-tile span {
  display: inline-flex;
  margin-bottom: 10px;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(31, 103, 231, 0.08);
  color: var(--blue);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hero-tile.accent span {
  background: rgba(16, 139, 135, 0.1);
  color: var(--teal);
}

.hero-tile strong {
  display: block;
  margin-bottom: 8px;
  font-size: 1.1rem;
}

.hero-tile p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.metric-card {
  padding: 18px;
}

.metric-card.metric-action {
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.metric-card.metric-action:hover,
.metric-card.metric-action:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 20px 36px rgba(31, 46, 71, 0.16);
  border-color: rgba(31, 103, 231, 0.25);
}

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

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

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 16px;
}

.tab-button,
.ghost-button,
.primary-button,
.danger-button {
  min-height: 40px;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 800;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.tab-button {
  flex: 0 0 auto;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
}

.tab-button.is-active {
  color: #fff;
  border-color: var(--blue);
  background: var(--blue);
}

.tab-button:focus-visible,
.metric-card.metric-action:focus-visible,
.hero-actions .ghost-button:focus-visible {
  outline: 3px solid rgba(31, 103, 231, 0.18);
  outline-offset: 2px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.75fr);
  gap: 16px;
}

.panel {
  padding: 20px;
}

.panel-primary {
  min-height: 640px;
}

.panel-wide {
  grid-column: 1 / -1;
}

.side-column {
  display: grid;
  gap: 16px;
  align-content: start;
}

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

.stacked-form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #344154;
  font-size: 0.92rem;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  outline: none;
  padding: 12px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

textarea {
  resize: vertical;
  min-height: 140px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(31, 103, 231, 0.7);
  box-shadow: 0 0 0 4px rgba(31, 103, 231, 0.12);
}

.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.input-meta {
  color: var(--muted);
  font-size: 0.88rem;
}

.field-hint {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.primary-button {
  padding: 0 18px;
  background: var(--blue);
  color: #fff;
}

.ghost-button {
  padding: 0 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.danger-button {
  padding: 0 14px;
  background: #fff1f2;
  color: var(--red);
  border: 1px solid rgba(196, 61, 75, 0.25);
}

.primary-button:hover,
.ghost-button:hover,
.danger-button:hover,
.tab-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(31, 46, 71, 0.13);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
  transform: none;
  box-shadow: none;
}

.status-list,
.data-list,
.log-list,
.recipient-list,
.activity-list {
  display: grid;
  gap: 10px;
}

.status-row,
.data-row,
.log-row,
.recipient-row,
.activity-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
}

.status-row {
  align-items: center;
  min-height: 56px;
}

.status-row strong {
  text-align: right;
  color: var(--text);
}

.status-row span,
.data-row span,
.log-row span,
.log-row small,
.recipient-row small,
.activity-row span {
  display: block;
  color: var(--muted);
  line-height: 1.45;
}

.data-row strong,
.log-row strong,
.recipient-row strong {
  display: block;
  margin-bottom: 3px;
}

.recipient-row {
  align-items: center;
  justify-content: flex-start;
  cursor: pointer;
}

.recipient-row input {
  width: 18px;
  height: 18px;
}

.split-grid,
.automation-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  gap: 16px;
  align-items: start;
}

.automation-grid + .automation-grid {
  margin-top: 18px;
}

.log-row {
  align-items: center;
}

.log-row b {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.76rem;
}

.log-row b.success,
.activity-row strong {
  color: var(--green);
  background: #edf8f2;
}

.log-row b.failed {
  color: var(--red);
  background: #fff1f2;
}

.empty-state {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
  padding: 16px;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.tab-panel.panel-primary.is-active {
  display: block;
}

.side-column {
  display: grid;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100% - 44px));
  padding: 14px 16px;
  border-radius: var(--radius);
  background: #142033;
  color: #fff;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.22);
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.success {
  background: var(--green);
}

.toast.error {
  background: var(--red);
}

.toast.warning {
  background: var(--amber);
}

@media (max-width: 760px) {
  .setup-alert {
    flex-direction: column;
    align-items: stretch;
  }

  .setup-alert .ghost-button {
    width: 100%;
  }
}

@media (max-width: 980px) {
  .dashboard-grid,
  .split-grid,
  .automation-grid {
    grid-template-columns: 1fr;
  }

  .hero-panel {
    grid-template-columns: 1fr;
  }

  .side-column {
    grid-column: 1 / -1;
  }

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

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1280px);
    padding-top: 16px;
  }

  .topbar,
  .panel-heading,
  .form-footer {
    align-items: stretch;
    flex-direction: column;
  }

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

  .panel {
    padding: 16px;
  }

  .primary-button,
  .ghost-button,
  .danger-button {
    width: 100%;
  }
}
