:root {
  --bg: #eef7f6;
  --panel: #ffffff;
  --panel-soft: #f4fbfa;
  --ink: #212121;
  --muted: #757575;
  --line: rgba(117, 117, 117, .28);
  --gold: #009688;
  --accent: #8bc34a;
  --danger: #b3261e;
  --primary: #009688;
  --primary-dark: #00796b;
  --primary-light: #b2dfdb;
  --primary-soft: #e0f2f1;
  --surface-hover: #f1fbfa;
  --shadow: 0 2px 6px rgba(33, 33, 33, .08), 0 12px 28px rgba(33, 33, 33, .08);
  --radius: 12px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  box-shadow: 0 1px 0 rgba(33, 33, 33, .04), 0 2px 8px rgba(33, 33, 33, .06);
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: clamp(28px, 3.2vw, 40px); line-height: .95; letter-spacing: 0; }
h2 { margin-bottom: 10px; font-size: clamp(22px, 3vw, 30px); line-height: 1.05; }
h3 { margin: 0 0 10px; }
p { color: var(--muted); line-height: 1.5; }
.small-note { margin-bottom: 0; font-size: 13px; }

.workspace {
  padding: 20px;
  max-width: 1240px;
  margin: 0 auto;
  display: grid;
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

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

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.metric {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
  padding: 12px;
}
.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}
.metric strong {
  display: block;
  font-size: clamp(24px, 4vw, 38px);
  line-height: 1;
}
.metric.accent {
  border-color: rgba(0, 150, 136, .28);
  background: var(--primary-soft);
}

.dashboard-tools {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) minmax(160px, 1fr) minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-soft);
}
.dashboard-tools select {
  min-height: 44px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 6px;
  padding: 10px 11px;
  font: inherit;
  width: 100%;
}
.tool-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  margin-bottom: 16px;
  box-shadow: inset 0 1px 0 rgba(33, 33, 33, .04);
}
.rsvp-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 14px;
}
.rsvp-table th,
.rsvp-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.rsvp-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: var(--panel-soft);
}
.rsvp-table tbody tr:hover td { background: var(--surface-hover); }
.rsvp-table tbody tr:last-child td { border-bottom: 0; }
.status-pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  font-weight: 700;
  white-space: nowrap;
}
.status-pill.confirmed {
  color: var(--primary-dark);
  background: var(--primary-soft);
  border-color: rgba(0, 121, 107, .24);
}
.status-pill.declined {
  color: var(--danger);
  background: #fce8e6;
  border-color: rgba(179, 38, 30, .24);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.data-list {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  min-height: 92px;
  overflow: hidden;
}
.data-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}
.data-row:last-child { border-bottom: 0; }
.data-row strong { color: var(--ink); }
.data-row a { color: var(--ink); text-underline-offset: .18em; }

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

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  background: var(--panel-soft);
}
fieldset.full { grid-column: 1 / -1; }
legend { color: var(--gold); font-weight: 700; padding: 0 4px; }

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}
label.full { grid-column: 1 / -1; }
label.checkbox-label {
  min-height: 44px;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}
.color-options-fieldset {
  grid-template-columns: 1fr;
  gap: 8px;
}
.color-option-row {
  display: grid;
  grid-template-columns: minmax(112px, .7fr) minmax(180px, 1fr) 76px;
  gap: 8px;
  align-items: end;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.color-option-toggle {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 700;
}
.color-option-toggle input { flex: 0 0 auto; }
.color-option-name,
.color-option-picker {
  display: grid;
  gap: 4px;
}
.color-option-name span,
.color-option-picker span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

input, textarea {
  min-height: 44px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 6px;
  padding: 10px 11px;
  font: inherit;
  width: 100%;
}
textarea { min-height: 90px; resize: vertical; }
input[type="color"] {
  padding: 4px;
  cursor: pointer;
}
input[type="checkbox"] {
  width: 18px;
  min-height: auto;
  accent-color: var(--primary);
}
.color-option-row input { min-height: 40px; }
.color-option-row input[type="color"] { padding: 3px; }
input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(0, 150, 136, .18);
  border-color: rgba(0, 150, 136, .68);
}

button, .button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 10px 13px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}
.primary { background: var(--primary); color: #fff; box-shadow: 0 2px 5px rgba(0, 150, 136, .28); }
.primary:hover, .ghost:hover { transform: translateY(-1px); }
.primary:hover { background: var(--primary-dark); }
.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.ghost:hover { border-color: rgba(0, 150, 136, .38); background: var(--primary-soft); color: var(--primary-dark); }
.actions, .upload-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.topbar .actions {
  justify-content: flex-end;
  max-width: 880px;
}
.topbar .primary {
  order: 10;
}
.upload-row input[type="text"] { flex: 1 1 260px; }
.file-button input { display: none; }

.image-preview {
  width: 128px;
  height: 82px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
}
.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .12s ease, object-position .12s ease;
}
.range-label {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 10px;
  align-items: center;
}
.range-label input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
}
.range-value {
  color: var(--muted);
  font-size: .84rem;
  font-weight: 600;
}

.preview-shell {
  width: 100%;
  height: min(760px, calc(100vh - 210px));
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}
.preview-shell iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: 420px;
  background: var(--ink);
  color: var(--panel);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: 0 6px 18px rgba(33, 33, 33, .24);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }

@media (max-width: 860px) {
  .topbar {
    flex-direction: column;
    align-items: stretch;
  }
  .workspace { padding: 12px; }
  .panel { padding: 14px; }
  .config-form, fieldset { grid-template-columns: 1fr; }
  .color-option-row { grid-template-columns: 1fr; }
  .metrics-grid, .dashboard-grid, .dashboard-tools { grid-template-columns: 1fr; }
  .tool-actions { justify-content: stretch; }
  .tool-actions button { flex: 1 1 180px; }
  .preview-shell { min-height: 620px; }
  .image-preview { width: 100%; height: 170px; }
}

@media print {
  body { background: #fff; color: #000; }
  .topbar .actions,
  .panel:nth-of-type(n+2),
  .toast {
    display: none !important;
  }
  .topbar,
  .panel {
    border: 0;
    background: #fff;
    padding: 0;
  }
  .workspace {
    padding: 0;
    max-width: none;
  }
  .metrics-grid,
  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
