:root {
  --bg: #f4f0ed;
  --card: #ffffff;
  --text: #2f3433;
  --muted: #6d7372;
  --line: #e6dfda;
  --primary: #5b8f87;
  --primary-dark: #4a7a72;
  --primary-soft: #e3efec;
  --accent: #e3655b;
  --accent-soft: #fbe7e4;
  --warn: #c28a2c;
  --warn-soft: #fbf1df;
  --radius: 20px;
  --shadow: 0 2px 14px rgba(70, 50, 40, .06);
  --serif: 'Merriweather', Georgia, serif;
  --sans: 'Lato', system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--sans); }
a { color: var(--primary); }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; margin: 0; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }

/* ---------- Topo ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; height: 70px; background: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .06); display: flex; align-items: center; gap: 16px; padding: 0 24px;
}
.brand { color: var(--accent); display: flex; }
.mainnav { flex: 1; display: flex; justify-content: center; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.mainnav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px;
  color: var(--muted); text-decoration: none; white-space: nowrap;
}
.mainnav a:hover { background: var(--bg); }
.mainnav a.active { color: var(--primary); }
.mainnav .t-short { display: none; }
.account {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: var(--text);
  background: #fff; box-shadow: var(--shadow); border: 1px solid var(--line);
}
.account.active { color: var(--primary); border-color: var(--primary); }
.ico { display: inline-flex; width: 22px; height: 22px; }
.ico svg { width: 100%; height: 100%; }

.view { max-width: 1140px; margin: 0 auto; padding: 32px 20px 80px; outline: none; }

/* ---------- Componentes ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px; }
.stack { display: grid; gap: 16px; align-content: start; }
.stack > *, .grid-2 > *, .grid-3 > *, .grid-4 > * { min-width: 0; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head h1 { margin-right: auto; }
.page-head .btn { padding: 0 18px; }
.page-head .icon-btn { margin: 0 -4px; }
.head-icons { display: flex; gap: 12px; align-items: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 26px;
  border-radius: 999px; border: 1px solid var(--primary); background: #fff; color: var(--primary);
  font-weight: 700; font-size: 14px; cursor: pointer; text-decoration: none; transition: background .15s, box-shadow .15s;
}
.btn:hover { background: var(--primary-soft); }
.btn.primary { background: linear-gradient(90deg, #6fa098, var(--primary)); color: #fff; border-color: transparent; box-shadow: 0 6px 16px rgba(91, 143, 135, .35); }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { border-color: var(--accent); color: var(--accent); }
.btn.danger:hover { background: var(--accent-soft); }
.btn.small { min-height: 34px; padding: 0 16px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; display: inline-grid; place-items: center;
  cursor: pointer; color: var(--text); text-decoration: none;
}
.icon-btn:hover { background: var(--bg); }
.icon-btn.edit { color: var(--primary); }
.icon-btn.del { color: var(--accent); }
.icon-btn .ico { width: 22px; height: 22px; }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--bg); color: var(--muted); }
.chip.confirmed { background: var(--primary-soft); color: var(--primary-dark); }
.chip.declined { background: var(--accent-soft); color: var(--accent); }
.chip.pending { background: var(--warn-soft); color: var(--warn); }
button.chip { border: 0; cursor: pointer; }

.field { display: grid; gap: 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
.input, input[type=text], input[type=email], input[type=password], input[type=tel], input[type=url], input[type=number], input[type=date], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 14px; border: 1px solid #cfc7c1; border-radius: 12px; background: #fff; font-weight: 400; color: var(--text);
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 400; color: var(--text); font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }

.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: #e4e0dd; transition: background .2s; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

.tabs { display: flex; gap: 6px; background: #fff; padding: 6px; border-radius: 999px; box-shadow: var(--shadow); width: fit-content; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.tabs > * { flex: none; }
.tabs a, .tabs button { border: 0; background: transparent; padding: 8px 18px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 700; cursor: pointer; font-size: 14px; }
.tabs .active { background: var(--primary); color: #fff; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .big { font-size: 46px; }

/* ---------- Stats ---------- */
.stat { display: grid; gap: 4px; }
.stat .label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 700; }
.stat .value { font-family: var(--serif); font-size: 26px; font-weight: 700; }
.stat .sub { color: var(--muted); font-size: 13px; }
.bar { height: 8px; border-radius: 99px; background: var(--bg); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--primary); border-radius: inherit; }

/* ---------- Painel inicial ---------- */
.hero {
  border-radius: var(--radius); padding: 34px; color: #fff; display: grid; gap: 6px;
  background: linear-gradient(120deg, rgba(47, 52, 51, .55), rgba(47, 52, 51, .2)), var(--hero-img, linear-gradient(120deg, #e3655b, #c9877b));
  background-size: cover; background-position: center; min-height: 220px; align-content: end;
}
.hero h1 { font-size: 30px; }
.hero .days { font-family: var(--serif); font-size: 18px; }
.checklist { display: grid; gap: 4px; }
.checklist a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; text-decoration: none; color: var(--text); }
.checklist a:hover { background: var(--bg); }
.checklist .tick { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; flex: none; color: #fff; }
.checklist .done .tick { background: var(--primary); border-color: var(--primary); }
.checklist .done span.t { color: var(--muted); text-decoration: line-through; }

/* ---------- Convidados ---------- */
.inv-list { display: grid; gap: 10px; }
.inv {
  background: #fff; border-radius: 16px; padding: 14px 18px; display: grid; grid-template-columns: 44px 1fr auto; gap: 14px; align-items: center;
}
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-dark); display: grid; place-items: center; font-weight: 700; font-family: var(--serif); }
.inv .title { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-weight: 700; }
.inv .guests { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.inv .meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.filters { display: grid; grid-template-columns: 1fr 200px 200px; gap: 12px; }

/* ---------- Presentes ---------- */
.gift-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.gift { background: #fff; border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.gift .img { aspect-ratio: 4 / 3; background: var(--bg) center / cover no-repeat; display: grid; place-items: center; font-size: 40px; }
.gift .body { padding: 14px 16px; display: grid; gap: 4px; flex: 1; }
.gift .price { font-weight: 700; color: var(--primary-dark); }
.gift .actions { display: flex; justify-content: flex-end; padding: 0 8px 8px; }
.add-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.add-card { background: #fff; border-radius: 18px; padding: 20px; display: flex; gap: 14px; align-items: center; border: 0; cursor: pointer; text-align: left; box-shadow: var(--shadow); font-weight: 700; font-size: 15px; }
.add-card:hover { box-shadow: 0 6px 22px rgba(70, 50, 40, .12); }
.add-card .em { font-size: 34px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.share { display: flex; gap: 8px; align-items: center; background: var(--bg); border-radius: 999px; padding: 6px 6px 6px 16px; }
.share code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }

/* ---------- Site ---------- */
.site-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.sec-list { display: grid; gap: 10px; }
.sec { background: #fff; border-radius: 16px; padding: 14px 16px; display: flex; align-items: center; gap: 14px; font-size: 16px; }
.sec.dragging { opacity: .4; }
.sec.drop-before { box-shadow: inset 0 3px 0 var(--primary); }
.handle { cursor: grab; color: var(--text); display: flex; }
.sec .name { flex: 1; }
.preview-frame { position: sticky; top: 90px; background: #fff; border-radius: 26px; padding: 10px; box-shadow: var(--shadow); }
.preview-frame iframe { width: 100%; height: 680px; border: 0; border-radius: 18px; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 40px; height: 40px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.swatch.active { box-shadow: 0 0 0 2px var(--text); }
.tpl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.tpl { border: 2px solid var(--line); border-radius: 16px; padding: 14px; background: #fff; cursor: pointer; text-align: center; font-weight: 700; }
.tpl.active { border-color: var(--primary); color: var(--primary); }
.tpl .mini { height: 70px; border-radius: 10px; margin-bottom: 8px; }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(30, 30, 30, .45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: 24px; width: min(640px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal header { display: flex; align-items: center; gap: 12px; padding: 20px 24px 8px; }
.modal header h2 { flex: 1; }
.modal .content { padding: 8px 24px 16px; overflow: auto; display: grid; gap: 14px; }
.modal footer { padding: 14px 24px 20px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--line); }
.list-item { border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: grid; gap: 10px; }
.guest-row { display: grid; grid-template-columns: 1fr 120px 140px 40px; gap: 8px; align-items: center; }
.img-field { display: flex; gap: 10px; align-items: center; }
.img-field .thumb { width: 64px; height: 64px; border-radius: 12px; background: var(--bg) center / cover; flex: none; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 120px); background: var(--text); color: #fff; padding: 12px 22px; border-radius: 999px; transition: transform .25s; z-index: 60; font-weight: 700; }
.toast.show { transform: translate(-50%, 0); }
.toast.error { background: var(--accent); }

@media (max-width: 900px) {
  .site-layout { grid-template-columns: 1fr; }
  .preview-frame { position: static; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .add-cards { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  /* Celular: menu principal vira barra fixa no rodapé, como em apps. */
  .topbar { height: 60px; padding: 0 12px; gap: 6px; }
  .topbar .brand { margin-right: auto; }
  .account { width: 40px; height: 40px; }
  .mainnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; gap: 0; justify-content: space-around;
    background: #fff; box-shadow: 0 -2px 12px rgba(0, 0, 0, .08); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .mainnav a { flex: 1; flex-direction: column; gap: 3px; padding: 6px 2px; font-size: 11px; font-weight: 700; border-radius: 10px; min-width: 0; }
  .mainnav a .ico { width: 24px; height: 24px; }
  .mainnav a.active { background: var(--primary-soft); }
  .mainnav .t-full { display: none; }
  .mainnav .t-short { display: block; }
  .view { padding: 18px 14px calc(96px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .page-head h1 { flex-basis: 100%; }
  .page-head .btn { padding: 0 14px; white-space: nowrap; }
  .page-head .icon-btn { margin: 0; }
  .page-head .btn .ico { display: none; }
  .head-icons { gap: 0; margin-left: auto; }
  .card { padding: 18px; }
  .share { flex-wrap: wrap; border-radius: 16px; padding: 10px 12px; }
  .share code { flex-basis: 100%; order: -1; }
  .share .btn { flex: 1; }
  .hero { padding: 24px; min-height: 180px; }
  .hero h1 { font-size: 24px; }
  .grid-3, .grid-2, .filters { grid-template-columns: 1fr; }
  .tpl-grid { grid-template-columns: repeat(2, 1fr); }
  .guest-row { grid-template-columns: 1fr 1fr 40px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
  .guest-row > [data-g=name] { grid-column: 1 / -1; }
  .inv { grid-template-columns: 1fr; }
  .inv .avatar { display: none; }
  .page-head .btn { flex: 1; }
}
.palettes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.palette { display: grid; gap: 8px; justify-items: center; border: 2px solid var(--line); border-radius: 14px; padding: 12px 8px; background: #fff; cursor: pointer; font: inherit; font-size: .9em; }
.palette.active { border-color: var(--primary); color: var(--primary); font-weight: 700; }
.palette .dots { display: flex; }
.palette .dots i { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); margin-left: -6px; }
.palette .dots i:first-child { margin-left: 0; }
@media (max-width: 600px) { .palettes { grid-template-columns: 1fr; } .palette { grid-template-columns: auto 1fr; justify-items: start; align-items: center; } }
