:root {
  --bg-0: #1a2332;
  --bg-1: #243044;
  --bg-2: #2e3d55;
  --floor: #d4c4a8;
  --floor-edge: #b8a588;
  --ink: #1a2332;
  --ink-soft: #5a6578;
  --cream: #f7f1e6;
  --panel: #fbf8f3;
  --accent: #0f6b5c;
  --accent-2: #c4a35a;
  --danger: #b33a3a;
  --ok: #2f7d4a;
  --warn: #c47a1a;
  --shadow: 0 18px 50px rgba(15, 25, 40, 0.28);
  --radius: 18px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Manrope", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #3a4f6d 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #1f4d45 0%, transparent 50%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1) 45%, #182131);
}

body {
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  min-height: 100vh;
  padding: 20px;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-radius: var(--radius);
  background: rgba(251, 248, 243, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.55rem;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.brand .sub {
  color: var(--ink-soft);
  font-size: 0.86rem;
}

.event-name {
  border: 0;
  background: transparent;
  border-radius: 0;
  padding: 4px 0;
  min-width: 0;
  outline: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--ink);
  pointer-events: none;
  user-select: none;
}

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

.stat {
  background: #efe8db;
  border-radius: 12px;
  padding: 8px 12px;
  min-width: 88px;
  text-align: center;
}

.stat b {
  display: block;
  font-size: 1.15rem;
  font-family: var(--font-display);
  line-height: 1.1;
}

.stat span {
  font-size: 0.72rem;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, filter 0.15s ease, background 0.15s ease;
}

.btn:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn.secondary {
  background: #e8dfd0;
  color: var(--ink);
}

.btn.ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1px solid #d8cfc0;
}

.btn.warn {
  background: var(--warn);
}

.btn.danger {
  background: var(--danger);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.floor-wrap {
  position: relative;
  border-radius: calc(var(--radius) + 4px);
  background: rgba(251, 248, 243, 0.92);
  box-shadow: var(--shadow);
  padding: 16px;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.toolbar-right {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.legend i {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: -1px;
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.legend .empty {
  background: #f4efe6;
}
.legend .partial {
  background: #d7ebe4;
}
.legend .full {
  background: #0f6b5c;
}
.legend .blocked {
  background: #d9d3c8;
}
.legend .special {
  background: #e8d7a8;
}

.search {
  border: 1px solid #ddd3c2;
  border-radius: 12px;
  padding: 10px 12px;
  min-width: 220px;
  background: #fff;
  outline: none;
}

.search:focus {
  border-color: var(--accent);
}

.floor-scroll {
  flex: 1;
  min-height: 0;
  width: 100%;
  position: relative;
}

.floor {
  position: relative;
  container-type: inline-size;
  container-name: sala;
  width: 100%;
  min-height: 640px;
  height: 100%;
  border-radius: 16px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(120, 95, 60, 0.06) 1px, transparent 1px),
    linear-gradient(rgba(120, 95, 60, 0.06) 1px, transparent 1px),
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.35), transparent 40%),
    linear-gradient(145deg, #e7d7bb, var(--floor) 40%, #cbb892);
  background-size: 28px 28px, 28px 28px, auto, auto;
  border: 3px solid var(--floor-edge);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.landmark {
  position: absolute;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #fff;
  user-select: none;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.landmark.stage {
  background: linear-gradient(180deg, #3a465c, #252e3f);
  clip-path: polygon(12% 0, 88% 0, 100% 100%, 0 100%);
  border-radius: 4px;
  font-size: clamp(0.65rem, 2.4cqi, 1.05rem);
  z-index: 1;
}

.landmark.entrance {
  background: linear-gradient(180deg, #6b5840, #4d3f2d);
  border-radius: 10px;
  font-size: clamp(0.55rem, 1.8cqi, 0.78rem);
  border: 2px dashed rgba(255, 255, 255, 0.35);
  z-index: 1;
}

.landmark.aisle {
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.22) 20%,
    rgba(255, 255, 255, 0.28) 50%,
    rgba(255, 255, 255, 0.22) 80%,
    transparent
  );
  border-radius: 8px;
  opacity: 0.9;
  z-index: 0;
}

.table {
  position: absolute;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(40, 35, 25, 0.18);
  background: #f8f3ea;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  box-shadow:
    0 8px 18px rgba(40, 30, 15, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.65);
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease;
  user-select: none;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.table.circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}

.table.rect {
  width: 100px;
  height: 58px;
  border-radius: 12px;
}

.table .num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1;
}

.table.rect .num {
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

.table .cap {
  font-size: 0.55rem;
  color: var(--ink-soft);
  line-height: 1;
}

.table .fill {
  font-size: 0.58rem;
  font-weight: 700;
  color: var(--accent);
}

@supports (width: 1cqi) {
  .table.circle {
    width: clamp(28px, 8.5cqi, 64px);
    height: clamp(28px, 8.5cqi, 64px);
  }

  .table.rect {
    width: clamp(70px, 16cqi, 118px);
    height: clamp(42px, 10cqi, 72px);
  }

  .table .num {
    font-size: clamp(0.62rem, 2.4cqi, 1.05rem);
  }

  .table.rect .num {
    font-size: clamp(0.58rem, 2.1cqi, 0.95rem);
  }

  .table .cap {
    font-size: clamp(0.42rem, 1.5cqi, 0.62rem);
  }

  .table .fill {
    font-size: clamp(0.42rem, 1.6cqi, 0.68rem);
  }

  .landmark.stage {
    font-size: clamp(0.65rem, 2.4cqi, 1.05rem);
  }

  .landmark.entrance {
    font-size: clamp(0.55rem, 1.8cqi, 0.78rem);
  }
}

.table .tag {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: #c4a35a;
  color: #1a2332;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 999px;
  white-space: nowrap;
}

.table:hover {
  transform: translate(-50%, -50%) scale(1.06);
  z-index: 5;
  box-shadow: 0 14px 28px rgba(40, 30, 15, 0.28);
}

.table.selected {
  border-color: var(--accent);
  box-shadow:
    0 0 0 4px rgba(15, 107, 92, 0.25),
    0 14px 28px rgba(40, 30, 15, 0.28);
  z-index: 6;
}

.table.partial {
  background: #d9eee7;
}

.table.full {
  background: #0f6b5c;
  color: #fff;
  border-color: #0a5246;
}

.table.full .cap,
.table.full .fill {
  color: rgba(255, 255, 255, 0.85);
}

.table.blocked {
  background: #cfc7ba;
  color: #6a6358;
  cursor: pointer;
}

.table.blocked::after {
  content: "✕";
  position: absolute;
  font-size: 1.6rem;
  color: rgba(140, 40, 40, 0.55);
  font-weight: 700;
  pointer-events: none;
}

.table.special-newlyweds {
  background: linear-gradient(160deg, #f4e6c8, #e8d19a);
  border-color: #c4a35a;
  border-width: 3px;
}

.table.special-music {
  background: #ead9a5;
  border-color: #b8963d;
}

.table.hit {
  animation: pulse 0.9s ease;
}

.floor.layout-edit .table.draggable {
  cursor: grab;
}

.floor.layout-edit .table.dragging {
  cursor: grabbing;
  z-index: 20;
  opacity: 0.92;
  box-shadow: 0 16px 32px rgba(40, 30, 15, 0.35);
}

.floor.layout-edit {
  outline: 2px dashed rgba(15, 107, 92, 0.45);
  outline-offset: -6px;
}

@keyframes pulse {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(1);
  }
  50% {
    transform: translate(-50%, -50%) scale(1.12);
  }
}

.side {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}

.panel {
  background: rgba(251, 248, 243, 0.96);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.panel h2 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 1.25rem;
}

.panel .muted {
  margin: 0 0 14px;
  color: var(--ink-soft);
  font-size: 0.86rem;
}

.meta-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.chip {
  background: #efe8db;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 600;
}

.chip.ok {
  background: #d7ebe4;
  color: var(--accent);
}
.chip.warn {
  background: #f3e1c4;
  color: var(--warn);
}
.chip.bad {
  background: #f0d4d4;
  color: var(--danger);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 72px;
  gap: 8px;
  margin-bottom: 8px;
}

.form-row input,
.note-input {
  width: 100%;
  border: 1px solid #ddd3c2;
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  outline: none;
}

.form-row input:focus,
.note-input:focus {
  border-color: var(--accent);
}

.guest-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.side .guest-list {
  max-height: 280px;
}

.guest-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
  background: #fff;
  border: 1px solid #ebe3d5;
  border-radius: 12px;
  padding: 10px;
}

.guest-item .name {
  font-weight: 700;
}

.guest-item .meta {
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-top: 2px;
}

.guest-item .ops {
  display: flex;
  gap: 4px;
}

.icon-btn {
  border: 0;
  background: #efe8db;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.icon-btn:hover {
  background: #e2d7c4;
}

.icon-btn.danger {
  color: var(--danger);
}

.empty-state {
  padding: 24px 10px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.list-panel {
  flex: 1;
  min-height: 180px;
  display: flex;
  flex-direction: column;
}

.all-guests {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  max-height: 320px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.all-guests li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #ebe3d5;
  cursor: pointer;
  font-size: 0.86rem;
}

.all-guests li:hover {
  border-color: var(--accent);
}

.all-guests .t {
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
}

.save-status {
  font-size: 0.8rem;
  color: var(--ink-soft);
  min-height: 1.2em;
}

.save-status.ok {
  color: var(--ok);
}
.save-status.err {
  color: var(--danger);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: 0.25s ease;
  z-index: 50;
  font-weight: 600;
  box-shadow: var(--shadow);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* —— Table popup —— */
body.modal-open {
  overflow: hidden;
  touch-action: none;
}

.table-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0;
}

.table-modal[hidden] {
  display: none !important;
}

.table-modal-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% 100%, rgba(15, 107, 92, 0.22), transparent 55%),
    rgba(10, 16, 26, 0.58);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: modalFade 0.22s ease;
}

.table-modal-sheet {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 100%;
  height: 100%;
  height: 100dvh;
  max-height: 100%;
  max-height: 100dvh;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: env(safe-area-inset-top, 0px) 0 0;
  border-radius: 0;
  background:
    linear-gradient(180deg, #fffdf9 0%, #f7f1e6 100%);
  border: 0;
  box-shadow: none;
  animation: modalSheet 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}

.table-modal-handle {
  display: none;
}

.table-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 10px;
  border-bottom: 1px solid rgba(26, 35, 50, 0.08);
  flex: 0 0 auto;
}

.table-modal-head-text {
  min-width: 0;
  flex: 1 1 auto;
}

.table-modal-kicker {
  display: none;
}

.table-modal-head h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 5vw, 1.75rem);
  line-height: 1.1;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.table-modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.table-modal-meta .chip {
  margin: 0;
  font-size: 0.75rem;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(15, 107, 92, 0.08);
  border: 1px solid rgba(15, 107, 92, 0.12);
}

.table-modal-meta .chip.ok {
  background: rgba(47, 125, 74, 0.12);
  border-color: rgba(47, 125, 74, 0.2);
}

.table-modal-meta .chip.bad {
  background: rgba(179, 58, 58, 0.1);
  border-color: rgba(179, 58, 58, 0.18);
}

.table-modal-meta .chip.warn {
  background: rgba(196, 122, 26, 0.12);
  border-color: rgba(196, 122, 26, 0.2);
}

.table-modal-close {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  margin-top: 2px;
  border: 0;
  border-radius: 14px;
  background: rgba(26, 35, 50, 0.07);
  color: var(--ink);
  font-size: 1.55rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s ease, transform 0.15s ease;
}

.table-modal-close:hover {
  background: rgba(26, 35, 50, 0.12);
}

.table-modal-close:active {
  transform: scale(0.96);
}

.table-modal-body {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 8px;
  padding: 10px 14px;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.table-modal-section-label {
  display: none;
}

.table-modal-list,
.table-modal .guest-list {
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: auto;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  max-height: none !important;
  height: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.table-modal-list .guest-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(26, 35, 50, 0.07);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

.table-modal-list .guest-item .name {
  font-size: 1.02rem;
  font-weight: 750;
  color: var(--ink);
  line-height: 1.25;
  word-break: break-word;
}

.table-modal-list .guest-item .meta {
  margin-top: 3px;
  font-size: 0.84rem;
  color: var(--ink-soft);
  font-weight: 600;
}

.table-modal-list .empty-state {
  margin: 0;
  padding: 14px 12px;
  text-align: center;
  border-radius: 14px;
  background: rgba(26, 35, 50, 0.04);
  border: 1px dashed rgba(26, 35, 50, 0.14);
  color: var(--ink-soft);
  font-weight: 600;
}

.table-modal-list .icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  font-size: 1.2rem;
}

.table-modal-edit {
  flex: 0 0 auto;
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(26, 35, 50, 0.08);
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 -8px 24px rgba(26, 35, 50, 0.06);
}

.table-modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.table-modal-actions .btn {
  min-width: 0;
  width: 100%;
  justify-content: center;
  padding: 12px 10px;
  font-size: 0.9rem;
  border-radius: 12px;
}

.table-modal-form {
  display: grid;
  gap: 10px;
}

.table-modal-form .form-row {
  display: grid;
  grid-template-columns: 1fr 72px;
  gap: 8px;
}

.table-modal-form input,
.table-modal-form .note-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid #d5c9b4;
  background: #fff;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
}

.table-modal-form input:focus,
.table-modal-form .note-input:focus {
  outline: none;
  border-color: #0f6b5c;
  box-shadow: 0 0 0 3px rgba(15, 107, 92, 0.16);
}

.table-modal-form-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.table-modal-form-actions .btn {
  width: 100%;
  justify-content: center;
  padding: 12px 10px;
  border-radius: 12px;
}

@keyframes modalFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalSheet {
  from {
    opacity: 0.85;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 420px) {
  .table-modal-actions .btn {
    padding: 13px 12px;
  }

  .table-modal-head {
    padding: 12px 12px 8px;
  }

  .table-modal-body,
  .table-modal-edit {
    padding-left: 12px;
    padding-right: 12px;
  }
}

@media (min-width: 720px) {
  .table-modal {
    align-items: center;
    padding: clamp(16px, 3vh, 32px);
  }

  .table-modal-sheet {
    width: min(520px, 100%);
    height: auto;
    max-height: min(82vh, 720px);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.55);
    box-shadow:
      0 18px 50px rgba(8, 16, 28, 0.38),
      inset 0 1px 0 rgba(255, 255, 255, 0.9);
    padding: 0;
    animation-name: modalPop;
  }

  .table-modal-body {
    justify-content: flex-start;
  }

  .table-modal-list {
    flex: 1 1 auto;
    max-height: none !important;
  }

  .table-modal-kicker {
    display: block;
    margin: 0 0 4px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #0f6b5c;
  }

  .table-modal-section-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-soft);
  }

  .table-modal-head {
    padding: 20px 22px 16px;
  }

  .table-modal-body {
    padding: 16px 22px 10px;
  }

  .table-modal-list {
    max-height: min(46vh, 380px) !important;
  }

  .table-modal-edit {
    padding: 14px 22px 20px;
  }

  .table-modal-list .guest-item {
    padding: 14px 16px;
  }
}

@keyframes modalPop {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .table-modal-backdrop,
  .table-modal-sheet {
    animation: none !important;
  }
}

@media print {
  body {
    background: #fff;
  }
  .app {
    display: block;
    padding: 0;
  }
  .topbar .actions,
  .floor-toolbar,
  .side,
  .toast,
  .table-modal {
    display: none !important;
  }
  .floor-wrap,
  .topbar {
    box-shadow: none;
    background: #fff;
  }
  .floor {
    min-height: 900px;
    break-inside: avoid;
  }
}

/* Tablet + phone: мапата се собира во ширината на уредот */
@media (max-width: 1100px) {
  .app {
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 14px;
  }

  .topbar {
    flex-wrap: wrap;
    padding: 12px 14px;
  }

  .event-name {
    min-width: 0;
    flex: 1 1 180px;
  }

  .stats {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }

  .stat {
    min-width: 0;
    padding: 8px 6px;
  }

  .actions {
    width: 100%;
    justify-content: flex-end;
  }

  .side {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }

  .floor-wrap {
    flex: none;
  }

  .floor-scroll {
    flex: none;
    width: 100%;
    overflow: hidden;
  }

  .floor {
    flex: none;
    width: 100%;
    height: auto;
    min-height: 0;
    aspect-ratio: 32 / 35;
  }
}

/* Phone */
@media (max-width: 700px) {
  .app {
    gap: 10px;
    padding: 10px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .topbar {
    gap: 10px;
    padding: 12px;
    border-radius: 14px;
  }

  .brand h1 {
    font-size: 1.2rem;
  }

  .brand .sub {
    display: none;
  }

  .event-name {
    flex: 1 1 100%;
    width: 100%;
    padding: 2px 0;
    font-size: 1.05rem;
  }

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

  .stat b {
    font-size: 1.05rem;
  }

  .stat span {
    font-size: 0.65rem;
  }

  .actions {
    gap: 8px;
  }

  .actions .save-status {
    flex: 1 1 100%;
    order: -1;
    font-size: 0.75rem;
  }

  .btn {
    padding: 12px 14px;
    min-height: 44px;
    border-radius: 12px;
    flex: 1;
  }

  .btnPrint-hide-mobile {
    display: none;
  }

  .floor-wrap {
    padding: 10px;
    border-radius: 14px;
    gap: 10px;
  }

  .floor-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .legend {
    gap: 6px 8px;
    font-size: 0.68rem;
  }

  .toolbar-right {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-right .btn,
  .toolbar-right .search {
    width: 100%;
    min-width: 0;
  }

  .search {
    font-size: 16px;
    padding: 12px 14px;
    min-width: 0;
  }

  .floor {
    aspect-ratio: 32 / 36;
    border-radius: 12px;
    border-width: 2px;
  }

  .side {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .panel {
    padding: 14px;
    border-radius: 14px;
  }

  .panel h2 {
    font-size: 1.1rem;
  }

  .form-row {
    grid-template-columns: 1fr 70px;
  }

  .form-row input,
  .note-input {
    font-size: 16px;
    padding: 12px;
    min-height: 44px;
  }

  #guestForm > div:last-of-type {
    flex-direction: column;
  }

  #guestForm .btn {
    width: 100%;
  }

  .side .guest-list {
    max-height: 200px;
  }

  .table-modal .guest-list,
  .table-modal-list {
    max-height: none !important;
  }

  .all-guests {
    max-height: 220px;
  }

  .all-guests li {
    min-height: 44px;
    align-items: center;
    padding: 10px 12px;
  }

  .toast {
    left: 12px;
    right: 12px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    transform: translateY(20px);
    text-align: center;
    border-radius: 14px;
    max-width: none;
  }

  .toast.show {
    transform: translateY(0);
  }
}

@media (max-width: 400px) {
  .stats {
    gap: 6px;
  }

  .legend span:nth-child(n + 4) {
    display: none;
  }

  .floor {
    aspect-ratio: 30 / 36;
  }
}

/* ===== Листа на маси / гости ===== */
.page-list {
  min-height: 100vh;
}

.list-app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100vh;
}

.list-topbar .search {
  min-width: 200px;
  flex: 1;
}

.list-main {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  align-content: start;
}

.list-loading {
  grid-column: 1 / -1;
  text-align: center;
  color: rgba(251, 248, 243, 0.85);
  font-size: 1rem;
  padding: 40px 12px;
}

.list-loading.err {
  color: #ffb4b4;
}

.table-card {
  background: rgba(251, 248, 243, 0.96);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid transparent;
}

.table-card.is-empty {
  opacity: 0.78;
}

.table-card.is-blocked {
  background: #ebe6dc;
}

.table-card.is-full {
  border-color: rgba(15, 107, 92, 0.35);
}

.table-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.table-card-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
}

.table-card-head p {
  margin: 2px 0 0;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.table-card-count {
  background: #efe8db;
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 800;
  font-size: 0.85rem;
  white-space: nowrap;
  color: var(--accent);
}

.table-card.is-full .table-card-count {
  background: #0f6b5c;
  color: #fff;
}

.table-card-guests {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.table-card-guests li {
  background: #fff;
  border: 1px solid #ebe3d5;
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.table-card-guests .g-name {
  font-weight: 700;
}

.table-card-guests .g-meta {
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.table-card-guests .guest-empty {
  border-style: dashed;
  color: var(--ink-soft);
  text-align: center;
  background: transparent;
}

@media (max-width: 700px) {
  .list-app {
    padding: 10px;
    gap: 12px;
  }

  .list-main {
    grid-template-columns: 1fr;
  }

  .list-topbar .actions {
    width: 100%;
  }

  .list-topbar .search {
    width: 100%;
    min-width: 0;
    flex: 1 1 100%;
  }
}

@media print {
  .page-list {
    background: #fff;
  }

  .list-app {
    max-width: none;
    padding: 0;
  }

  .list-topbar .actions,
  .list-topbar .search {
    display: none !important;
  }

  .list-main {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .table-card {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }
}

/* —— Login —— */
.page-login {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  color: #1a2332;
  background: #1a2332;
}

.login-stage {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: clamp(20px, 4vw, 40px);
}

.login-atmosphere {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 55% at 50% 0%, rgba(196, 163, 90, 0.18), transparent 60%),
    radial-gradient(ellipse 70% 50% at 20% 100%, rgba(15, 107, 92, 0.35), transparent 55%),
    radial-gradient(ellipse 60% 45% at 90% 80%, rgba(58, 79, 109, 0.45), transparent 50%),
    linear-gradient(165deg, #15202e 0%, #1f3340 42%, #16352f 100%);
}

.login-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.55;
  animation: loginDrift 14s ease-in-out infinite alternate;
}

.login-glow-a {
  width: min(48vw, 420px);
  height: min(48vw, 420px);
  left: -8%;
  top: 18%;
  background: rgba(15, 107, 92, 0.45);
}

.login-glow-b {
  width: min(42vw, 360px);
  height: min(42vw, 360px);
  right: -6%;
  bottom: 8%;
  background: rgba(196, 163, 90, 0.28);
  animation-delay: -4s;
  animation-duration: 18s;
}

.login-floor {
  position: absolute;
  inset: 12% 8% 10%;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(212, 196, 168, 0.12), rgba(212, 196, 168, 0.04)),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 48px,
      rgba(255, 255, 255, 0.03) 48px,
      rgba(255, 255, 255, 0.03) 49px
    );
  border: 1px solid rgba(247, 241, 230, 0.08);
  opacity: 0.9;
}

.login-table {
  position: absolute;
  width: 7.5%;
  aspect-ratio: 1;
  border-radius: 999px;
  background: rgba(247, 241, 230, 0.14);
  border: 1px solid rgba(196, 163, 90, 0.35);
  box-shadow: inset 0 0 0 6px rgba(15, 107, 92, 0.08);
  animation: loginPulse 5.5s ease-in-out infinite;
}

.login-table.t1 { left: 18%; top: 22%; animation-delay: 0s; }
.login-table.t2 { left: 38%; top: 18%; animation-delay: 0.4s; }
.login-table.t3 { left: 58%; top: 24%; animation-delay: 0.8s; }
.login-table.t4 { left: 22%; top: 52%; animation-delay: 1.2s; }
.login-table.t5 { left: 48%; top: 58%; animation-delay: 1.6s; }
.login-table.t6 { left: 72%; top: 48%; animation-delay: 2s; width: 9%; }

.login-stage-mark {
  position: absolute;
  left: 50%;
  top: 8%;
  transform: translateX(-50%);
  width: 28%;
  height: 5%;
  border-radius: 8px;
  background: rgba(196, 163, 90, 0.35);
}

.login-entrance {
  position: absolute;
  right: 10%;
  bottom: 8%;
  width: 10%;
  height: 4%;
  border-radius: 6px;
  background: rgba(247, 241, 230, 0.2);
}

.login-main {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  display: grid;
  gap: clamp(28px, 5vh, 40px);
  animation: loginRise 0.85s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.login-hero {
  text-align: center;
  color: #f7f1e6;
}

.login-names {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 8vw, 3.6rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
  text-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

.login-names em {
  font-style: italic;
  font-weight: 500;
  color: #c4a35a;
  margin: 0 0.12em;
}

.login-hero h1 {
  margin: 0;
  font-family: var(--font-body);
  font-size: clamp(0.95rem, 2.5vw, 1.05rem);
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(247, 241, 230, 0.72);
}

.login-lead {
  margin: 14px auto 0;
  max-width: 28ch;
  font-size: 1rem;
  line-height: 1.5;
  color: rgba(247, 241, 230, 0.62);
  font-weight: 500;
}

.login-form {
  display: grid;
  gap: 14px;
  padding: 22px 22px 20px;
  border-radius: 22px;
  background:
    linear-gradient(165deg, rgba(251, 248, 243, 0.96), rgba(247, 241, 230, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow:
    0 24px 60px rgba(8, 16, 28, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  animation: loginRise 0.95s cubic-bezier(0.22, 1, 0.36, 1) 0.12s both;
}

.login-field {
  display: grid;
  gap: 7px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #5a6578;
}

.login-field input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1.5px solid #d5c9b4;
  background: #fff;
  color: #1a2332;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: normal;
  text-transform: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.login-field input::placeholder {
  color: #a8a092;
  font-weight: 500;
}

.login-field input:focus {
  outline: none;
  border-color: #0f6b5c;
  box-shadow: 0 0 0 4px rgba(15, 107, 92, 0.18);
  transform: translateY(-1px);
}

.login-btn {
  margin-top: 6px;
  appearance: none;
  border: 0;
  cursor: pointer;
  width: 100%;
  padding: 15px 18px;
  border-radius: 14px;
  background: linear-gradient(135deg, #0f6b5c, #0b8572 55%, #0f6b5c);
  background-size: 160% 160%;
  color: #f7f1e6;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 12px 28px rgba(15, 107, 92, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-position 0.35s ease;
}

.login-btn:hover {
  transform: translateY(-2px);
  background-position: 100% 50%;
  box-shadow: 0 16px 34px rgba(15, 107, 92, 0.42);
}

.login-btn:active {
  transform: translateY(0);
}

.login-error {
  padding: 12px 14px;
  border-radius: 12px;
  background: #f6e0e0;
  border: 1px solid #e5b4b4;
  color: #8a2a2a;
  font-size: 0.92rem;
  font-weight: 700;
  animation: loginShake 0.45s ease;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #f3ebe0;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.view-only #guestForm,
.view-only #btnEditLayout {
  display: none !important;
}

.page-list .user-chip {
  color: #f3ebe0;
}

@keyframes loginRise {
  from {
    opacity: 0;
    transform: translateY(22px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes loginDrift {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(18px, -14px) scale(1.08); }
}

@keyframes loginPulse {
  0%, 100% { opacity: 0.45; transform: scale(1); }
  50% { opacity: 0.85; transform: scale(1.06); }
}

@keyframes loginShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

@media (max-width: 560px) {
  .login-floor {
    inset: 8% 4% 6%;
    border-radius: 18px;
  }

  .login-form {
    padding: 18px 16px 16px;
  }

  .login-names {
    font-size: clamp(2.1rem, 11vw, 2.8rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .login-main,
  .login-form,
  .login-glow,
  .login-table,
  .login-error {
    animation: none !important;
  }
}
