:root {
  --bg: #f7f3f4;
  --surface: #ffffff;
  --surface-soft: #fbf8f8;
  --ink: #292326;
  --muted: #746b70;
  --line: #e8dfdf;
  --line-strong: #d5c8c9;
  --primary: #a72f39;
  --primary-dark: #7f2029;
  --primary-soft: #fae9e9;
  --gold: #b78a45;
  --gold-soft: #f6ead5;
  --green: #28765a;
  --green-soft: #e5f3ed;
  --amber: #9b6618;
  --amber-soft: #fff2d8;
  --blue: #356a96;
  --blue-soft: #e8f1f8;
  --danger: #b33131;
  --shadow: 0 8px 24px rgba(34, 38, 44, 0.08);
  --sidebar: 252px;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "Noto Sans SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { color: inherit; }
button, select, input[type="checkbox"] { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(53, 106, 150, 0.23);
  outline-offset: 1px;
}

.app-shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  width: var(--sidebar);
  flex-direction: column;
  padding: 22px 14px 18px;
  color: #f8f4f2;
  background: #2d2327;
  border-right: 1px solid #4a353b;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 4px 8px 20px;
  color: inherit;
  text-align: left;
  border: 0;
  background: transparent;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  flex: 0 0 auto;
  color: #fff;
  background: #9f2934;
  border: 1px solid #c69a58;
  border-radius: 6px;
  font-family: Georgia, serif;
  font-size: 24px;
  line-height: 1;
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; }
.brand small { margin-top: 2px; color: #bdb7b8; font-size: 11px; }

.main-nav { display: grid; gap: 5px; }
.nav-item {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  color: #c9c4c5;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
}
.nav-item:hover { color: #fff; background: #3d2d33; }
.nav-item.active { color: #fff; background: #512f37; border-color: #72505a; }
.nav-item svg { width: 19px; height: 19px; }
.nav-item b {
  min-width: 22px;
  padding: 2px 6px;
  color: #d9d3d4;
  text-align: center;
  background: #403b3c;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
}
.nav-item.active b { background: var(--primary); color: #fff; }

.sidebar-summary {
  margin-top: auto;
  padding: 14px 12px;
  background: #322e2f;
  border: 1px solid #423d3e;
  border-radius: 6px;
}
.sidebar-summary p { margin: 0 0 10px; color: #aaa3a5; font-size: 11px; }
.side-progress { height: 5px; overflow: hidden; background: #4a4445; border-radius: 3px; }
.side-progress span { display: block; height: 100%; background: #d8ae6d; }
.side-numbers { display: flex; justify-content: space-between; margin-top: 8px; color: #d8d3d4; font-size: 12px; }
.save-state { display: flex; align-items: center; gap: 7px; padding: 14px 10px 0; color: #989294; font-size: 11px; }
.save-dot { width: 7px; height: 7px; background: #64b18e; border-radius: 50%; }

.workspace { min-height: 100vh; margin-left: var(--sidebar); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  min-height: 78px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 30px;
  background: rgba(255, 253, 253, 0.97);
  border-bottom: 1px solid var(--line);
}
.eyebrow { margin: 0 0 3px; color: var(--primary); font-size: 11px; font-weight: 700; }
.topbar h1 { margin: 0; font-family: "Noto Serif SC", "Songti SC", "STSong", serif; font-size: 21px; line-height: 1.25; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }

main { max-width: 1540px; margin: 0 auto; padding: 26px 30px 56px; }
.page-stack { display: grid; gap: 24px; }
.section-block { min-width: 0; }
.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.section-heading h2 { margin: 0; font-size: 16px; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.section-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.wedding-banner {
  position: relative;
  display: grid;
  min-height: 190px;
  grid-template-columns: minmax(0, 1fr) 180px;
  align-items: center;
  overflow: hidden;
  padding: 24px 30px;
  color: #fffaf7;
  background: #852832;
  border: 1px solid #71202a;
  border-radius: 7px;
  box-shadow: 0 10px 26px rgba(90, 31, 38, 0.15);
}
.wedding-banner::before,
.wedding-banner::after {
  content: "";
  position: absolute;
  width: 86px;
  height: 86px;
  border: 1px solid rgba(224, 187, 128, 0.38);
  transform: rotate(45deg);
}
.wedding-banner::before { top: -54px; left: -26px; }
.wedding-banner::after { right: -28px; bottom: -56px; }
.wedding-banner-copy { position: relative; z-index: 1; min-width: 0; }
.wedding-kicker { display: flex; align-items: center; gap: 7px; margin: 0 0 9px; color: #efd9b3; font-size: 11px; font-weight: 650; }
.wedding-kicker svg { width: 15px; height: 15px; fill: currentColor; }
.wedding-banner h2 { margin: 0; font-family: "Noto Serif SC", "Songti SC", "STSong", serif; font-size: 30px; font-weight: 700; }
.wedding-couple { margin: 7px 0 0; color: #f5e5df; font-family: "Noto Serif SC", "Songti SC", serif; font-size: 16px; }
.wedding-meta { display: flex; gap: 18px; margin: 15px 0 0; color: #f0d9d3; font-size: 11px; }
.wedding-meta span { display: inline-flex; align-items: center; gap: 6px; }
.wedding-meta svg { width: 14px; height: 14px; color: #e4bd7d; }
.button.banner-edit { margin-top: 16px; color: #fff; border-color: rgba(255,255,255,.36); background: rgba(60, 12, 20, .24); }
.button.banner-edit:hover { color: #fff; border-color: #efd3a4; background: rgba(60, 12, 20, .44); }
.wedding-emblem {
  position: relative;
  z-index: 1;
  display: grid;
  width: 126px;
  height: 126px;
  place-items: center;
  justify-self: center;
  align-content: center;
  color: #f6d59d;
  border: 1px solid rgba(244, 209, 153, .65);
  outline: 1px solid rgba(244, 209, 153, .28);
  outline-offset: 6px;
  border-radius: 50%;
}
.wedding-emblem span { font-family: "STKaiti", "KaiTi", serif; font-size: 54px; line-height: 1; }
.wedding-emblem small { margin-top: 5px; color: #f3dfbd; font-size: 9px; }

.button, .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}
.button {
  min-height: 38px;
  gap: 7px;
  padding: 0 13px;
  border-radius: 6px;
  font-weight: 650;
  white-space: nowrap;
}
.button svg { width: 17px; height: 17px; }
.button:hover, .icon-button:hover { border-color: #aeb5bf; background: #f8f9fa; }
.button:active, .icon-button:active { transform: translateY(1px); }
.button.primary { color: #fff; background: var(--primary); border-color: var(--primary); }
.button.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.button.soft { color: var(--primary); background: var(--primary-soft); border-color: #e9c2bf; }
.button.danger { color: var(--danger); background: #fff; border-color: #e4baba; }
.button.text { min-height: 32px; padding: 0 8px; border-color: transparent; background: transparent; }
.button.small { min-height: 32px; padding: 0 10px; font-size: 12px; }
.button[disabled] { cursor: not-allowed; opacity: 0.45; }
.icon-button { width: 38px; height: 38px; padding: 0; border-radius: 6px; }
.icon-button svg { width: 18px; height: 18px; }
.icon-button.small { width: 31px; height: 31px; }
.icon-button.danger { color: var(--danger); }
.cloud-button { width: auto; min-width: 38px; gap: 6px; padding: 0 10px; }
.cloud-button span { font-size: 11px; font-weight: 650; }
.cloud-button.online { color: var(--green); border-color: #afd5c5; background: var(--green-soft); }
.cloud-button.syncing { color: var(--blue); border-color: #bad0df; background: var(--blue-soft); }
.cloud-button.offline { color: var(--amber); border-color: #e4c98f; background: var(--amber-soft); }
.modal[data-locked="true"] .modal-header .icon-button { display: none; }

.stats-grid { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); gap: 10px; }
.stat-card {
  position: relative;
  min-height: 112px;
  padding: 17px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
}
.stat-card::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--stat-color, var(--primary)); }
.stat-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; }
.stat-top svg { width: 17px; height: 17px; color: var(--stat-color, var(--primary)); }
.stat-number { display: block; margin-top: 9px; font-size: 28px; line-height: 1; }
.stat-note { display: block; margin-top: 8px; color: var(--muted); font-size: 11px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.75fr); gap: 18px; align-items: start; }
.panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
}
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 54px; padding: 0 17px; border-bottom: 1px solid var(--line); box-shadow: inset 0 2px 0 #f4e4c8; }
.panel-header h3 { margin: 0; font-size: 14px; }
.panel-body { padding: 16px 17px; }
.quick-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.quick-action {
  display: flex;
  min-height: 62px;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  text-align: left;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.quick-action:hover { border-color: #c5a4a2; background: var(--primary-soft); }
.quick-action svg { width: 20px; color: var(--primary); }
.quick-action strong, .quick-action small { display: block; }
.quick-action strong { font-size: 13px; }
.quick-action small { margin-top: 3px; color: var(--muted); font-size: 10px; }

.summary-list { display: grid; gap: 2px; }
.summary-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto auto; align-items: center; gap: 9px; min-height: 39px; border-bottom: 1px solid #eff1f3; }
.summary-row:last-child { border-bottom: 0; }
.color-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dot, var(--primary)); }
.summary-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.summary-row small { color: var(--muted); }
.summary-row b { min-width: 40px; text-align: right; }

.alert-list { display: grid; gap: 8px; }
.alert-row { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 9px; padding: 9px 10px; background: var(--amber-soft); border-radius: 5px; }
.alert-row > svg { width: 17px; color: var(--amber); justify-self: center; }
.alert-row strong, .alert-row small { display: block; }
.alert-row strong { font-size: 12px; }
.alert-row small { margin-top: 2px; color: #765c32; font-size: 10px; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 7px;
}
.search-box { position: relative; flex: 1 1 250px; min-width: 180px; }
.search-box svg { position: absolute; top: 50%; left: 11px; width: 17px; color: var(--muted); transform: translateY(-50%); }
.search-box input { width: 100%; height: 38px; padding: 0 12px 0 36px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; }
.toolbar select { height: 38px; min-width: 120px; padding: 0 30px 0 10px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; }

.family-list { display: grid; gap: 9px; }
.family-row { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.family-summary {
  display: grid;
  grid-template-columns: 42px minmax(140px, 1.4fr) minmax(120px, 1fr) auto auto auto;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 9px 12px;
}
.family-avatar { display: grid; width: 38px; height: 38px; place-items: center; color: #fff; background: var(--avatar, var(--primary)); border-radius: 6px; font-weight: 800; }
.family-name strong, .family-name small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.family-name small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.family-location { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.family-count { min-width: 70px; text-align: center; }
.family-count b, .family-count small { display: block; }
.family-count small { color: var(--muted); font-size: 10px; }
.row-actions { display: flex; justify-content: flex-end; gap: 5px; }
.expand-button { border: 0; background: transparent; }
.family-row.expanded .expand-button svg { transform: rotate(180deg); }
.family-members { display: none; padding: 0 12px 12px 66px; }
.family-row.expanded .family-members { display: block; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th { height: 36px; color: var(--muted); font-size: 11px; font-weight: 600; text-align: left; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.data-table td { min-height: 42px; padding: 8px 6px; border-bottom: 1px solid #edf0f2; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table select { max-width: 135px; height: 31px; border: 1px solid var(--line); border-radius: 5px; background: #fff; font-size: 12px; }
.person-name { font-weight: 650; }
.person-sub { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }

.badge { display: inline-flex; min-height: 23px; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 8px; font-size: 10px; font-weight: 650; white-space: nowrap; }
.badge.confirmed { color: var(--green); background: var(--green-soft); }
.badge.pending { color: var(--blue); background: var(--blue-soft); }
.badge.maybe { color: var(--amber); background: var(--amber-soft); }
.badge.absent { color: #777; background: #eceeef; }
.badge.adult { color: #5e4b76; background: #f0eaf6; }
.badge.child { color: #33718d; background: #e6f4f7; }
.badge.seated { color: var(--green); background: var(--green-soft); }
.badge.unseated { color: var(--primary); background: var(--primary-soft); }
.badge.locked { color: #5f6268; background: #eceef0; }

.table-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.table-grid { display: grid; grid-template-columns: repeat(2, minmax(280px, 1fr)); gap: 10px; }
.table-card { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.table-card.drag-over { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.table-card-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 14px; border-bottom: 1px solid var(--line); }
.table-card-title { display: flex; align-items: center; gap: 9px; min-width: 0; }
.table-index { display: grid; width: 35px; height: 35px; place-items: center; color: #fff; background: var(--primary); border: 1px solid #c79856; border-radius: 50%; font-size: 12px; }
.table-card-title strong, .table-card-title small { display: block; }
.table-card-title small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.capacity { min-width: 50px; text-align: right; }
.capacity b { font-size: 16px; }
.capacity.over { color: var(--danger); }
.seat-progress { height: 4px; overflow: hidden; background: #eceef0; }
.seat-progress span { display: block; height: 100%; background: var(--green); }
.seat-progress span.full { background: var(--amber); }
.seat-progress span.over { background: var(--danger); }
.table-people { min-height: 95px; padding: 10px 12px; }
.person-chip {
  display: inline-flex;
  max-width: 100%;
  min-height: 30px;
  align-items: center;
  gap: 5px;
  margin: 3px 2px;
  padding: 3px 8px;
  background: #f3f5f6;
  border: 1px solid #e1e5e8;
  border-radius: 6px;
  font-size: 11px;
}
.person-chip[draggable="true"] { cursor: grab; }
.person-chip.maybe { background: var(--amber-soft); border-color: #f0d8aa; }
.person-chip .family-mini { max-width: 68px; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }
.person-chip button { display: grid; width: 20px; height: 20px; place-items: center; padding: 0; color: var(--muted); border: 0; background: transparent; }
.person-chip button svg { width: 13px; }
.table-card-footer { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 12px; background: var(--surface-soft); border-top: 1px solid var(--line); }

.waiting-panel { position: sticky; top: 96px; max-height: calc(100vh - 120px); overflow: hidden; }
.waiting-list { max-height: calc(100vh - 270px); padding: 8px 10px 12px; overflow-y: auto; }
.waiting-family { padding: 8px 2px; border-bottom: 1px solid var(--line); }
.waiting-family:last-child { border-bottom: 0; }
.waiting-family > strong { display: flex; justify-content: space-between; margin-bottom: 5px; font-size: 11px; }
.waiting-family > strong span { color: var(--muted); font-weight: 500; }

.seating-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.segmented { display: inline-flex; padding: 3px; background: #e9ecef; border-radius: 6px; }
.segmented button { min-height: 31px; padding: 0 11px; border: 0; border-radius: 4px; color: var(--muted); background: transparent; font-weight: 650; font-size: 11px; }
.segmented button.active { color: var(--ink); background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.seating-grid { display: grid; grid-template-columns: repeat(2, minmax(360px, 1fr)); gap: 14px; }
.seating-sheet { break-inside: avoid; min-width: 0; padding: 14px; background: #fff; border: 1px solid var(--line); border-top: 3px solid #b99050; border-radius: 7px; }
.seating-sheet-header { display: flex; justify-content: space-between; align-items: center; min-height: 40px; border-bottom: 1px solid var(--line); }
.seating-sheet-header h3 { margin: 0; font-size: 15px; }
.seating-sheet-header span { color: var(--muted); font-size: 11px; }
.seat-map { position: relative; width: min(100%, 440px); aspect-ratio: 1 / 0.78; margin: 8px auto 0; overflow: hidden; }
.table-shape {
  position: absolute;
  top: 50%; left: 50%;
  display: grid;
  width: 34%;
  aspect-ratio: 1;
  place-items: center;
  padding: 8px;
  color: #5d3e20;
  text-align: center;
  background: #f5dfb8;
  border: 3px solid #c99a54;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}
.table-shape.square { border-radius: 6px; }
.table-shape strong, .table-shape small { display: block; }
.table-shape strong { font-size: 13px; }
.table-shape small { margin-top: 3px; font-size: 9px; }
.seat-node {
  position: absolute;
  top: var(--y);
  left: var(--x);
  display: flex;
  width: clamp(68px, 20%, 92px);
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 4px 5px;
  text-align: center;
  background: #fff;
  border: 1px solid #cfd4d9;
  border-radius: 6px;
  transform: translate(-50%, -50%);
  font-size: 10px;
  line-height: 1.25;
}
.seat-node.filled { border-color: #c19b98; background: #fff8f7; cursor: grab; }
.seat-node.empty { color: #9ba1aa; border-style: dashed; background: #fafbfc; }
.seat-node.drag-over { border-color: var(--primary); background: var(--primary-soft); }
.seat-node strong, .seat-node small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-node small { margin-top: 2px; color: var(--muted); font-size: 8px; }
.child-line { color: var(--blue) !important; }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; align-items: start; }
.setting-section { background: #fff; border: 1px solid var(--line); border-radius: 7px; }
.setting-section.wide { grid-column: 1 / -1; }
.setting-header { padding: 15px 17px; border-bottom: 1px solid var(--line); }
.setting-header h2 { margin: 0; font-size: 15px; }
.setting-header p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.setting-body { padding: 16px 17px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: grid; align-content: start; gap: 6px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field > label { color: #555b64; font-size: 11px; font-weight: 650; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
}
.field textarea { min-height: 72px; resize: vertical; }
.field-note { color: var(--muted); font-size: 10px; line-height: 1.5; }
.setting-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.tag-manager { display: flex; flex-wrap: wrap; gap: 7px; }
.manage-tag { display: inline-flex; min-height: 34px; align-items: center; gap: 7px; padding: 3px 5px 3px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); }
.manage-tag .color-dot { flex: 0 0 auto; }
.manage-tag button { display: grid; width: 25px; height: 25px; place-items: center; padding: 0; border: 0; background: transparent; }
.manage-tag button svg { width: 13px; }
.danger-zone { border-color: #e6c1c1; }
.danger-zone .setting-header { background: #fff8f8; }

.empty-state { display: grid; min-height: 220px; place-items: center; padding: 35px; color: var(--muted); text-align: center; background: #fff; border: 1px dashed var(--line-strong); border-radius: 7px; }
.empty-state svg { width: 34px; height: 34px; margin-bottom: 9px; color: #a9afb8; }
.empty-state h3 { margin: 0 0 5px; color: var(--ink); font-size: 15px; }
.empty-state p { max-width: 390px; margin: 0 0 14px; font-size: 12px; line-height: 1.7; }

.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 18px; background: rgba(23, 24, 26, 0.58); }
.modal-backdrop[hidden] { display: none; }
.modal { display: flex; width: min(760px, 100%); max-height: calc(100vh - 36px); flex-direction: column; overflow: hidden; background: #fff; border-radius: 8px; box-shadow: 0 20px 55px rgba(0,0,0,.22); }
.modal.wide { width: min(1040px, 100%); }
.modal.small { width: min(470px, 100%); }
.modal-header { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 18px; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-footer { display: flex; flex: 0 0 auto; justify-content: flex-end; gap: 8px; padding: 12px 18px; background: var(--surface-soft); border-top: 1px solid var(--line); }

.member-editor { margin-top: 18px; }
.member-editor-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.member-editor-head h3 { margin: 0; font-size: 14px; }
.member-form-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(105px, 1fr)) 34px;
  gap: 7px;
  align-items: end;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}
.member-form-row .field > label { font-size: 9px; }
.member-form-row input, .member-form-row select { min-width: 0; height: 35px; padding: 5px 7px; font-size: 11px; }
.member-form-row .member-note { grid-column: span 2; }
.member-checks { display: flex; min-height: 35px; align-items: center; gap: 12px; grid-column: span 2; }
.member-form-row .remove-member { grid-column: 5; grid-row: 1; align-self: end; }
.check-field { display: flex; min-height: 35px; align-items: center; gap: 5px; font-size: 10px; }
.check-field input { width: 16px; height: 16px; }
.attendance-help { margin: 8px 0 0; padding: 9px 11px; color: #65502f; background: var(--amber-soft); border-radius: 5px; font-size: 10px; line-height: 1.6; }

.toast-stack { position: fixed; z-index: 200; right: 18px; bottom: 18px; display: grid; width: min(350px, calc(100vw - 36px)); gap: 8px; }
.toast { display: flex; align-items: center; gap: 9px; padding: 12px 13px; color: #fff; background: #2f3439; border-radius: 6px; box-shadow: var(--shadow); animation: toast-in 180ms ease-out; }
.toast.success { background: #28664f; }
.toast.warning { background: #76501d; }
.toast.error { background: #8e2d2d; }
.toast svg { width: 18px; flex: 0 0 auto; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.mobile-nav { display: none; }
.desktop-only { display: initial; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

@media (max-width: 1120px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
  .table-layout { grid-template-columns: minmax(0, 1fr) 270px; }
  .table-grid { grid-template-columns: 1fr; }
  .seating-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  :root { --sidebar: 0px; }
  body { padding-bottom: 70px; }
  .sidebar { display: none; }
  .workspace { margin-left: 0; }
  .topbar { min-height: 66px; padding: 10px 15px; }
  .topbar h1 { font-size: 18px; }
  .topbar-actions .icon-button { display: none; }
  .topbar-actions .cloud-button { display: inline-flex; padding: 0 8px; }
  .topbar-actions .cloud-button span { display: none; }
  .topbar-actions .button { width: 38px; padding: 0; }
  .topbar-actions .button span { display: none; }
  main { padding: 16px 13px 28px; }
  .wedding-banner { min-height: 178px; grid-template-columns: minmax(0, 1fr) 96px; padding: 20px 17px; }
  .wedding-banner h2 { font-size: 24px; }
  .wedding-couple { font-size: 14px; }
  .wedding-meta { flex-direction: column; gap: 5px; margin-top: 11px; }
  .button.banner-edit { position: static; min-height: 34px; margin-top: 13px; padding-inline: 10px; font-size: 11px; }
  .wedding-emblem { width: 78px; height: 78px; outline-offset: 4px; }
  .wedding-emblem span { font-size: 38px; }
  .wedding-emblem small { font-size: 8px; }
  .section-heading { flex-direction: column; align-items: stretch; }
  .section-heading .section-actions { width: 100%; }
  .seating-toolbar { align-items: stretch; }
  .seating-toolbar > select { flex: 1 1 150px; min-height: 38px; padding: 0 9px; border: 1px solid var(--line-strong); border-radius: 6px; background: #fff; }
  .mobile-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 50;
    display: grid;
    height: 64px;
    grid-template-columns: repeat(5, 1fr);
    padding: 4px max(8px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    background: #fff;
    border-top: 1px solid var(--line);
  }
  .mobile-nav button { display: grid; place-items: center; align-content: center; gap: 2px; padding: 0; color: var(--muted); border: 0; background: transparent; font-size: 9px; }
  .mobile-nav button svg { width: 19px; height: 19px; }
  .mobile-nav button.active { color: var(--primary); }
  .mobile-nav .mobile-add { width: 44px; height: 44px; place-self: center; color: #fff; background: var(--primary); border-radius: 50%; }
  .mobile-nav .mobile-add svg { width: 23px; height: 23px; }
  .stats-grid { display: flex; margin-right: -13px; padding-right: 13px; overflow-x: auto; scroll-snap-type: x mandatory; }
  .stat-card { min-width: 148px; min-height: 102px; scroll-snap-align: start; }
  .dashboard-grid, .settings-grid, .table-layout { grid-template-columns: 1fr; }
  .waiting-panel { position: static; max-height: none; }
  .waiting-list { max-height: 330px; }
  .family-summary { grid-template-columns: 40px minmax(120px, 1fr) auto auto; gap: 8px; }
  .family-location, .family-count.people-total { display: none; }
  .family-members { padding-left: 12px; overflow-x: auto; }
  .data-table { min-width: 660px; }
  .form-grid.three { grid-template-columns: 1fr 1fr; }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal, .modal.wide, .modal.small { width: 100%; max-height: 92vh; border-radius: 8px 8px 0 0; }
  .member-form-row { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 12px 0; }
  .member-form-row .member-note, .member-checks { grid-column: 1 / -1; }
  .member-form-row .remove-member { grid-column: 2; grid-row: auto; justify-self: end; }
}

@media (max-width: 520px) {
  .section-heading { align-items: stretch; }
  .seating-toolbar .segmented { flex: 1 1 auto; }
  .seating-toolbar .segmented button { flex: 1; }
  .section-actions .button span.optional { display: none; }
  .quick-actions { grid-template-columns: 1fr; }
  .wedding-banner { grid-template-columns: minmax(0, 1fr) 76px; }
  .settings-grid, .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .setting-section.wide, .field.full { grid-column: auto; }
  .toolbar select { flex: 1 1 110px; min-width: 0; }
  .table-grid { grid-template-columns: minmax(0, 1fr); }
  .family-summary { grid-template-columns: 36px minmax(105px, 1fr) auto auto; padding-inline: 9px; }
  .family-avatar { width: 34px; height: 34px; }
  .family-count { min-width: 54px; }
  .seating-sheet { padding: 10px; }
  .seat-map { aspect-ratio: 1 / 0.95; }
  .seat-node { width: 66px; min-height: 39px; font-size: 9px; }
  .table-shape { width: 31%; }
  .modal-body { padding: 14px; }
}

@media print {
  body { padding: 0; background: #fff; }
  .sidebar, .topbar, .mobile-nav, .seating-toolbar, .section-heading .section-actions, .toast-stack { display: none !important; }
  .workspace { margin: 0; }
  main { max-width: none; padding: 0; }
  .page-stack { gap: 10mm; }
  .seating-grid { display: block; }
  .seating-sheet { margin-bottom: 8mm; page-break-inside: avoid; border-color: #bbb; }
  .seat-map { width: 160mm; max-width: 100%; }
}
