:root {
  color-scheme: light;
  --ink: #1f2933;
  --muted: #64748b;
  --line: #d8dee8;
  --paper: #fbfaf7;
  --surface: #ffffff;
  --accent: #2f6f73;
  --accent-dark: #24585b;
  --rose: #b85b6a;
  --gold: #b68a35;
  --shadow: 0 12px 30px rgba(31, 41, 51, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body.locked {
  overflow: hidden;
}

button,
textarea,
input {
  font: inherit;
}

.password-gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: var(--paper);
}

.password-panel {
  width: min(420px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(31, 41, 51, 0.18);
}

.password-panel h2 {
  margin-bottom: 18px;
  font-size: 1.8rem;
}

.password-panel label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.password-panel input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
}

.password-message {
  min-height: 22px;
  margin: 10px 0 0;
  color: #a33b3b;
  font-size: 0.9rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 32px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--rose);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

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

h2 {
  margin-bottom: 14px;
  font-size: 1rem;
}

.stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.stats span {
  min-width: 112px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fb;
  color: var(--muted);
  font-size: 0.88rem;
}

.stats strong {
  display: block;
  color: var(--ink);
  font-size: 1.25rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  gap: 24px;
  padding: 24px 32px 40px;
}

.mobile-planner {
  display: none;
}

.sidebar {
  display: grid;
  align-content: start;
  gap: 18px;
}

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

textarea {
  width: 100%;
  min-height: 170px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: #fff;
}

.search-input {
  width: 100%;
  min-height: 42px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
}

textarea:focus,
input:focus,
button:focus-visible,
.guest-card:focus-visible {
  outline: 3px solid rgba(47, 111, 115, 0.25);
  outline-offset: 2px;
}

button {
  width: 100%;
  margin-top: 12px;
  border: 0;
  border-radius: 8px;
  padding: 11px 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.ghost {
  width: auto;
  margin: 0;
  padding: 8px 10px;
  background: #eef5f5;
  color: var(--accent-dark);
}

.ghost:hover {
  background: #dfecec;
}

.message {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.message.error {
  color: #a33b3b;
}

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

.panel-head h2 {
  margin: 0;
}

.guest-list {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 8px;
  min-height: 90px;
  border-radius: 8px;
}

.guest-panel .guest-list {
  max-height: calc(100vh - 430px);
  min-height: 220px;
  overflow: auto;
  padding: 10px;
  background: #f7f9fb;
  border: 1px dashed #b8c3cf;
}

.all-guests-panel {
  max-height: calc(100vh - 120px);
  overflow: auto;
}

.grouped-guests {
  display: grid;
  gap: 12px;
}

.guest-group {
  display: grid;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.guest-group:first-child {
  padding-top: 0;
  border-top: 0;
}

.group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--ink);
  font-size: 0.88rem;
}

.group-title span {
  min-width: 26px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(47, 111, 115, 0.12);
  color: var(--accent-dark);
  font-weight: 800;
  text-align: center;
}

.compact-list {
  display: grid;
  gap: 6px;
  min-height: 0;
}

.tables-area {
  min-width: 0;
}

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

.view-switch {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.arrange-map-button {
  min-height: 42px;
}

.view-button {
  width: auto;
  min-width: 84px;
  margin: 0;
  padding: 8px 12px;
  background: transparent;
  color: var(--muted);
}

.view-button:hover,
.view-button.active {
  background: var(--accent);
  color: #fff;
}

.tables-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.table-card {
  min-height: 190px;
  display: grid;
  grid-template-rows: auto 1fr;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-card.collapsed {
  min-height: 0;
  grid-template-rows: auto;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 52px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #f9fbfb;
}

.table-toggle {
  width: auto;
  min-width: 0;
  min-height: 28px;
  margin: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-weight: 850;
  text-align: left;
}

.table-toggle:hover {
  background: transparent;
  color: var(--accent-dark);
}

.table-toggle-icon {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #bfd0d2;
  border-radius: 50%;
  background: #fff;
}

.table-toggle-icon::before {
  content: "";
  width: 6px;
  height: 6px;
  border-right: 2px solid var(--accent-dark);
  border-bottom: 2px solid var(--accent-dark);
  transform: translateY(-1px) rotate(45deg);
  transition: transform 0.16s ease;
}

.table-card.collapsed .table-toggle-icon::before {
  transform: translateX(-1px) rotate(-45deg);
}

.table-header h3 {
  margin: 0;
  font-size: 1rem;
}

.count {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(182, 138, 53, 0.15);
  color: #76581f;
  font-size: 0.82rem;
  font-weight: 800;
}

.table-card .guest-list {
  padding: 12px;
}

.guest-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  max-width: 100%;
  min-height: 34px;
  padding: 5px 6px 5px 10px;
  border: 1px solid #bfd0d2;
  border-radius: 8px;
  background: #eef7f7;
  color: #173f42;
  font-size: 0.9rem;
  font-weight: 750;
  cursor: grab;
  user-select: none;
}

.guest-card.compact {
  min-height: 30px;
  padding: 4px 5px 4px 8px;
  font-size: 0.82rem;
}

.guest-card.compact .icon-button {
  width: 24px;
  height: 24px;
  font-size: 0.82rem;
}

.guest-name {
  min-width: 0;
  word-break: break-word;
}

.guest-card:active {
  cursor: grabbing;
}

.guest-actions {
  display: inline-flex;
  gap: 4px;
}

.move-guest {
  display: none;
  width: auto;
  min-height: 28px;
  margin: 0;
  padding: 0 9px;
  border: 1px solid #bfd0d2;
  border-radius: 6px;
  background: #fff;
  color: var(--accent-dark);
  font-size: 0.78rem;
  line-height: 1;
}

.move-guest:hover {
  background: #f7fbfb;
}

.icon-button {
  width: 28px;
  height: 28px;
  margin: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  display: inline-grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.7);
  color: #24585b;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.icon-button:hover {
  background: #fff;
  border-color: #bfd0d2;
}

.delete-guest {
  color: #a33b3b;
}

.dropzone.drag-over {
  background: #e6f2ef;
  box-shadow: inset 0 0 0 2px var(--accent);
}

.map-scroll {
  max-width: 100%;
  max-height: max(calc(100vh - 190px), 560px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.map-board {
  position: relative;
  min-width: 1040px;
  min-height: 1240px;
  background:
    linear-gradient(rgba(47, 111, 115, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(47, 111, 115, 0.08) 1px, transparent 1px),
    #fffdf8;
  background-size: 44px 44px;
}

.map-table {
  position: absolute;
  width: 156px;
  height: 156px;
  transform: translate(-50%, -50%);
  touch-action: none;
}

.map-table.moving {
  z-index: 5;
}

.map-table-handle {
  position: absolute;
  left: 50%;
  top: -18px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--accent-dark);
  box-shadow: 0 6px 16px rgba(31, 41, 51, 0.12);
  cursor: move;
  transform: translateX(-50%);
}

.map-table-handle strong,
.map-table-handle span {
  line-height: 1;
}

.map-table-handle span {
  min-width: 20px;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(182, 138, 53, 0.16);
  color: #76581f;
  font-size: 0.75rem;
  font-weight: 800;
  text-align: center;
}

.round-table {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border: 2px solid #d4b76f;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0 45%, #f8efe0 46% 100%);
  color: #76581f;
  font-size: 0.78rem;
  font-weight: 850;
  text-align: center;
  box-shadow: 0 14px 28px rgba(31, 41, 51, 0.12);
}

.round-table.drag-over {
  box-shadow: inset 0 0 0 3px var(--accent), 0 14px 28px rgba(31, 41, 51, 0.12);
}

.map-table-count {
  position: absolute;
  left: 50%;
  bottom: -34px;
  min-width: 86px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-align: center;
  transform: translateX(-50%);
  box-shadow: 0 6px 14px rgba(31, 41, 51, 0.08);
}

.seat {
  position: absolute;
  z-index: 3;
  max-width: 82px;
  min-height: 24px;
  padding: 3px 6px;
  border: 1px solid #bfd0d2;
  border-radius: 999px;
  overflow: hidden;
  background: #eef7f7;
  color: #173f42;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: grab;
  transform: translate(-50%, -50%);
}

.seat:active {
  cursor: grabbing;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(31, 41, 51, 0.52);
}

.table-detail-modal {
  width: min(720px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(31, 41, 51, 0.28);
}

.table-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
  background: #f9fbfb;
}

.table-detail-head h2 {
  margin: 0;
  font-size: 1.7rem;
}

.modal-close-button {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  background: #fff;
}

.table-detail-body {
  overflow: auto;
  padding: 22px 24px 26px;
}

.table-detail-summary {
  margin-bottom: 18px;
  color: var(--muted);
  font-weight: 800;
}

.table-detail-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 24px;
}

.table-detail-list li {
  padding: 10px 12px;
  border: 1px solid #bfd0d2;
  border-radius: 8px;
  background: #eef7f7;
  color: #173f42;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.guest-move-modal {
  width: min(680px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(31, 41, 51, 0.28);
}

.guest-move-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  background: #f9fbfb;
}

.guest-move-head h2 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.guest-move-meta {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.guest-move-destinations {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 10px;
  overflow: auto;
  padding: 18px;
}

.guest-move-option {
  min-height: 56px;
  margin: 0;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid #bfd0d2;
  background: #eef7f7;
  color: #173f42;
  text-align: left;
}

.guest-move-option:hover,
.guest-move-option.current {
  background: var(--accent);
  color: #fff;
}

.guest-move-option span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.guest-move-option strong {
  flex: 0 0 auto;
  min-width: 30px;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--accent-dark);
  font-size: 0.84rem;
  text-align: center;
}

.quick-table-modal {
  width: min(720px, 100%);
  max-height: min(820px, calc(100vh - 48px));
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(31, 41, 51, 0.28);
}

.quick-table-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  background: #f9fbfb;
}

.quick-table-head h2 {
  margin: 0;
  font-size: 1.5rem;
  line-height: 1.1;
}

.quick-table-meta {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.quick-table-body {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 18px;
  overflow: hidden;
  padding: 18px;
}

.quick-table-body section {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.quick-table-add {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.quick-table-body h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.quick-table-guests,
.quick-guest-results {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 8px;
}

.quick-table-guest,
.quick-add-guest {
  width: 100%;
  min-height: 42px;
  margin: 0;
  padding: 7px 8px 7px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid #bfd0d2;
  border-radius: 8px;
  background: #eef7f7;
  color: #173f42;
  text-align: left;
}

.quick-table-guest span,
.quick-add-guest span {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.quick-remove-guest,
.quick-add-guest strong {
  flex: 0 0 auto;
  width: auto;
  min-height: 28px;
  margin: 0;
  padding: 5px 8px;
  border-radius: 6px;
  background: #fff;
  color: var(--accent-dark);
  font-size: 0.78rem;
  line-height: 1;
}

.quick-remove-guest {
  border: 1px solid #e4b4b4;
  color: #a33b3b;
}

.quick-add-guest:hover {
  background: var(--accent);
  color: #fff;
}

.empty {
  width: 100%;
  margin: auto;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

@media (max-width: 900px) {
  .topbar,
  .layout {
    padding-left: 18px;
    padding-right: 18px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
    padding-top: 16px;
    padding-bottom: 14px;
  }

  h1 {
    font-size: 1.45rem;
  }

  .stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .stats span {
    min-width: 0;
    padding: 7px 8px;
    font-size: 0.76rem;
  }

  .stats strong {
    font-size: 1.05rem;
  }

  .layout {
    grid-template-columns: 1fr;
    gap: 14px;
    padding-top: 14px;
  }

  .mobile-planner {
    order: -2;
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    box-shadow: var(--shadow);
  }

  .mobile-planner-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .mobile-planner-head h2 {
    margin: 0;
    font-size: 1.05rem;
  }

  .mobile-tables-overview {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
  }

  .mobile-table-cell {
    min-width: 0;
    min-height: 40px;
    margin: 0;
    padding: 5px 6px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px;
    border: 1px solid #bfd0d2;
    border-radius: 8px;
    background: #eef7f7;
    color: #173f42;
  }

  .mobile-table-cell.full {
    border-color: #d4b76f;
    background: #fff6df;
    color: #76581f;
  }

  .mobile-table-cell span {
    min-width: 0;
    font-size: 0.82rem;
    font-weight: 900;
    line-height: 1;
  }

  .mobile-table-cell strong {
    min-width: 23px;
    padding: 3px 5px;
    border-radius: 999px;
    background: #fff;
    color: var(--accent-dark);
    font-size: 0.78rem;
    line-height: 1;
    text-align: center;
  }

  .sidebar {
    order: 1;
    gap: 14px;
  }

  .tables-area {
    order: 2;
  }

  .guest-panel {
    order: -1;
  }

  .sidebar > .panel:first-child {
    order: 1;
  }

  .all-guests-panel {
    order: 2;
  }

  .panel {
    padding: 14px;
  }

  .guest-panel .guest-list {
    max-height: 42vh;
    min-height: 160px;
  }

  .map-scroll {
    max-height: 72vh;
  }

  .tables-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .table-card {
    min-height: 150px;
  }

  .guest-card {
    width: 100%;
    min-height: 44px;
    padding: 8px 8px 8px 12px;
    cursor: pointer;
  }

  .guest-card.compact {
    min-height: 40px;
    padding: 7px 7px 7px 10px;
  }

  .icon-button {
    width: 34px;
    height: 34px;
  }

  .move-guest {
    display: inline-grid;
    place-items: center;
    min-height: 34px;
  }

  .guest-card.compact .icon-button {
    width: 32px;
    height: 32px;
  }

  .modal-overlay {
    align-items: end;
    padding: 12px;
  }

  .guest-move-modal,
  .quick-table-modal,
  .table-detail-modal {
    width: 100%;
    max-height: min(88vh, 760px);
  }

  .guest-move-head,
  .quick-table-head,
  .table-detail-head {
    padding: 16px;
  }

  .quick-table-body {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(108px, 0.42fr) minmax(0, 0.58fr);
    gap: 14px;
    padding: 14px;
  }

  .quick-table-guests,
  .quick-guest-results {
    border-radius: 8px;
  }

  .quick-table-guest,
  .quick-add-guest {
    min-height: 44px;
  }

  .guest-move-destinations {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 12px;
  }

  .guest-move-option {
    min-height: 58px;
    padding: 9px 10px;
  }
}
