:root {
  --bg: #edf5e8;
  --panel: rgba(247, 250, 245, 0.9);
  --panel-strong: #fdfefd;
  --text: #111111;
  --muted: #4d574f;
  --line: rgba(104, 164, 74, 0.18);
  --accent: #8ac84a;
  --accent-dark: #5f9e43;
  --accent-deep: #3f6f2f;
  --accent-soft: rgba(138, 200, 74, 0.14);
  --success: #5f9e43;
  --shadow: 0 18px 60px rgba(37, 67, 31, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(138, 200, 74, 0.22), transparent 32%),
    radial-gradient(circle at 85% 15%, rgba(95, 158, 67, 0.14), transparent 18%),
    linear-gradient(180deg, #f7fbf5 0%, var(--bg) 100%);
}

body.tables-workspace-mode .page-shell {
  width: min(100vw - 24px, 1880px);
  min-height: 100vh;
  padding: 12px 0 16px;
}

body.tables-workspace-mode .panel-form,
body.tables-workspace-mode #openWorkspaceBtn {
  display: none;
}

body.tables-workspace-mode .hero {
  padding: 12px 18px;
  gap: 12px;
}

body.tables-workspace-mode .hero-logo {
  width: min(96px, 100%);
}

body.tables-workspace-mode .hero-actions {
  display: none;
}

body.tables-workspace-mode .dashboard {
  min-height: calc(100vh - 116px);
  margin-top: 12px;
}

body.tables-workspace-mode .workspace {
  grid-template-columns: minmax(0, 1fr);
  min-height: calc(100vh - 116px);
  align-items: stretch;
}

body.tables-workspace-mode .workspace > .panel {
  height: 100%;
}

body.tables-workspace-mode .workspace > .panel:first-child {
  display: none;
}

body.tables-workspace-mode .workspace > .panel:last-child {
  display: flex;
  flex-direction: column;
}

body.tables-workspace-mode .workspace > .panel:last-child {
  order: 1;
  min-height: 0;
}

body.tables-workspace-mode .floorplan-card {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

body.tables-workspace-mode .floorplan-canvas {
  flex: 1 1 auto;
  min-height: clamp(700px, calc(100vh - 280px), 1800px);
}

body.tables-workspace-mode #tablesGrid {
  margin-top: 16px;
}

body.tables-workspace-mode .popup-workspace-unassigned {
  display: flex;
  flex-direction: column;
  margin-bottom: 16px;
}

body.tables-workspace-mode #popupUnassignedList {
  max-height: min(34vh, 340px);
  overflow: auto;
  padding-right: 4px;
}

button,
input,
select {
  font: inherit;
}

.page-shell {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.hero,
.panel,
.card {
  backdrop-filter: blur(18px);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  padding: 20px 24px;
  background:
    radial-gradient(circle at top left, rgba(138, 200, 74, 0.18), transparent 26%),
    linear-gradient(135deg, rgba(248, 252, 246, 0.97), rgba(242, 248, 239, 0.86));
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.hero-brand {
  display: grid;
  gap: 8px;
}

.hero-logo {
  width: min(150px, 100%);
  display: block;
}

.eyebrow,
.panel-kicker,
.card-kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.76rem;
  color: var(--accent-dark);
}

h1,
h2,
h3,
h4 {
  margin: 0;
}

h1,
h2 {
  font-family: "Source Serif 4", serif;
}

h1 {
  max-width: 10ch;
  font-size: clamp(2.8rem, 5vw, 4.5rem);
  line-height: 0.95;
}

.hero-copy {
  max-width: 56ch;
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: end;
}

.project-manager {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}

.compact-field {
  min-width: 180px;
}

.dashboard {
  margin-top: 24px;
  display: grid;
  gap: 24px;
}

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

.panel-form {
  background: linear-gradient(180deg, rgba(250, 253, 248, 0.98), rgba(244, 249, 241, 0.9));
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.form-grid,
.workspace {
  display: grid;
  gap: 20px;
}

.form-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.workspace {
  grid-template-columns: 360px minmax(0, 1fr);
  align-items: start;
}

.card {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.stack {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.94rem;
}

.field input,
.search-field input,
.guest-select {
  width: 100%;
  border: 1px solid rgba(95, 158, 67, 0.18);
  background: white;
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--text);
}

.helper-copy {
  margin: -4px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.import-mode {
  margin: 0;
  padding: 12px;
  border: 1px solid rgba(95, 158, 67, 0.12);
  border-radius: 14px;
  display: grid;
  gap: 10px;
}

.import-mode legend {
  padding: 0 6px;
  color: var(--accent-dark);
  font-weight: 700;
}

.radio-option {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--text);
}

.radio-option input {
  accent-color: var(--accent);
}

.import-status {
  margin: 0;
  min-height: 24px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(138, 200, 74, 0.12);
  color: var(--accent-dark);
  font-size: 0.92rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.field input:focus,
.search-field input:focus,
.guest-select:focus {
  outline: 2px solid rgba(138, 200, 74, 0.25);
  border-color: var(--accent);
}

.button,
.icon-button {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
}

.button {
  padding: 12px 18px;
  background: var(--accent);
  color: white;
  font-weight: 700;
}

.button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

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

.button-ghost {
  background: rgba(17, 17, 17, 0.06);
  color: var(--text);
}

.stats-row {
  margin-top: 20px;
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-card {
  padding: 18px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
}

.stat-card.is-clickable {
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.stat-card.is-clickable:hover {
  transform: translateY(-1px);
}

.stat-card.is-active {
  border-color: rgba(95, 158, 67, 0.42);
  box-shadow: 0 12px 24px rgba(63, 111, 47, 0.12);
  background: rgba(242, 249, 238, 0.96);
}

.stat-card strong {
  display: block;
  font-size: 1.9rem;
  margin-top: 10px;
}

.search-field {
  flex: 1 1 220px;
  min-width: 0;
  max-width: 100%;
}

.panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex: 1 1 320px;
  flex-wrap: wrap;
}

.popup-only {
  display: none;
}

body.tables-workspace-mode .popup-only {
  display: inline-flex;
}

.guest-list,
.table-guest-list,
.tables-grid {
  display: grid;
  gap: 14px;
}

.floorplan-card {
  margin-bottom: 20px;
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.94), rgba(242, 249, 238, 0.82)),
    linear-gradient(180deg, rgba(138, 200, 74, 0.08), rgba(138, 200, 74, 0));
}

.floorplan-tools {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.floorplan-upload-field {
  flex: 1 1 260px;
}

.floorplan-grid-field {
  flex: 1 1 180px;
}

.floorplan-zoom-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.floorplan-zoom-label {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
}

.floorplan-status {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

.floorplan-copy {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.floorplan-note {
  margin: 0;
  max-width: 44ch;
  color: var(--muted);
  line-height: 1.5;
}

.floorplan-canvas {
  position: relative;
  overflow-x: scroll;
  overflow-y: scroll;
  border-radius: 22px;
  border: 1px solid rgba(95, 158, 67, 0.14);
  background:
    linear-gradient(180deg, rgba(252, 254, 251, 0.98), rgba(240, 247, 236, 0.94)),
    repeating-linear-gradient(
      90deg,
      rgba(95, 158, 67, 0.06) 0,
      rgba(95, 158, 67, 0.06) 1px,
      transparent 1px,
      transparent 78px
    ),
    repeating-linear-gradient(
      0deg,
      rgba(95, 158, 67, 0.06) 0,
      rgba(95, 158, 67, 0.06) 1px,
      transparent 1px,
      transparent 78px
    );
  min-height: 380px;
  padding: 14px;
  scrollbar-gutter: stable both-edges;
  -webkit-overflow-scrolling: touch;
}

.floorplan-room {
  position: relative;
  min-height: 380px;
}

.floorplan-viewport {
  position: relative;
  min-width: 100%;
}

.floorplan-background {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  overflow: hidden;
  pointer-events: none;
}

.floorplan-background::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(250, 253, 248, 0.16),
    rgba(250, 253, 248, 0.06)
  );
}

.floorplan-background img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
}

.floorplan-reference-point {
  position: absolute;
  width: 16px;
  height: 16px;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 50%;
  background: rgba(95, 158, 67, 0.92);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.92);
  cursor: pointer;
  z-index: 3;
  padding: 0;
}

.floorplan-calibration-line {
  position: absolute;
  height: 0;
  border-top: 3px dashed rgba(201, 109, 66, 0.95);
  transform-origin: left center;
  z-index: 2;
  pointer-events: none;
}

.floorplan-calibration-label {
  position: absolute;
  transform: translate(-50%, -50%);
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 250, 243, 0.96);
  border: 1px solid rgba(201, 109, 66, 0.28);
  color: #8f4523;
  font-size: 0.8rem;
  font-weight: 700;
  z-index: 3;
  pointer-events: none;
}

.floorplan-stage {
  position: absolute;
  left: 24px;
  top: 24px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 18px;
  transform-origin: center center;
  background: rgba(138, 200, 74, 0.14);
  color: var(--accent-dark);
  text-align: center;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: grab;
  user-select: none;
  touch-action: none;
  border: 1px solid rgba(95, 158, 67, 0.18);
}

.floorplan-stage.is-stage {
  border-radius: 999px;
}

.floorplan-stage.is-dance-floor,
.floorplan-stage.is-combined {
  border-radius: 18px;
}

.floorplan-stage.is-combined {
  justify-content: space-between;
}

.floorplan-stage-split {
  flex: 1 1 0;
  text-align: center;
}

.floorplan-stage-split + .floorplan-stage-split {
  border-left: 2px solid rgba(95, 158, 67, 0.2);
}

.floorplan-room.is-dragging .floorplan-stage {
  cursor: grabbing;
}

.floorplan-stage-resize {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 14px;
  height: 14px;
  border: 0;
  border-radius: 50%;
  background: var(--accent-dark);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9);
  cursor: nwse-resize;
  padding: 0;
}

.floorplan-stage-resize:hover {
  transform: scale(1.06);
}

.floorplan-stage-rotate {
  position: absolute;
  top: -18px;
  left: 50%;
  width: 16px;
  height: 16px;
  transform: translateX(-50%);
  border: 0;
  border-radius: 50%;
  background: #fffaf3;
  box-shadow: 0 0 0 2px rgba(95, 158, 67, 0.3);
  cursor: grab;
  padding: 0;
}

.floorplan-stage-rotate::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--accent-dark);
}

.floorplan-table {
  position: absolute;
  width: 180px;
  height: 180px;
  z-index: 1;
  transform: translate(-50%, -50%);
  transition: opacity 180ms ease, filter 180ms ease;
}

.floorplan-table.is-muted {
  opacity: 0.16;
  filter: saturate(0.7);
}

.floorplan-table.is-featured {
  z-index: 6;
}

.floorplan-table-disc {
  position: absolute;
  inset: 24px;
  --table-name-size: 1.05rem;
  --table-meta-size: 0.8rem;
  --table-meta-gap: 0.08rem;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #9dd95f, #5f9e43);
  box-shadow: 0 16px 34px rgba(63, 111, 47, 0.22);
  color: #f7fff2;
  cursor: grab;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 10px 12px;
  touch-action: none;
  overflow: hidden;
}

.floorplan-room.is-dragging .floorplan-table-disc {
  cursor: grabbing;
}

.floorplan-table-disc strong,
.floorplan-table-disc span {
  display: block;
}

.floorplan-table-disc strong {
  font-family: "Source Serif 4", serif;
  font-size: var(--table-name-size);
  line-height: 0.95;
  max-width: 100%;
}

.floorplan-table-disc span {
  margin-top: var(--table-meta-gap);
  font-size: var(--table-meta-size);
  line-height: 1;
}

.floorplan-table-name-line {
  display: block;
}

.floorplan-seat {
  position: absolute;
  width: 56px;
  height: 56px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #deefcf;
  color: var(--accent-deep);
  border: 3px solid #fffaf3;
  box-shadow: 0 8px 18px rgba(63, 111, 47, 0.12);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  padding: 4px;
  overflow: hidden;
}

.floorplan-seat.is-filled {
  background: var(--success);
  color: #f4fff7;
}

.floorplan-seat-line {
  display: block;
  width: 100%;
  text-align: center;
}

.floorplan-empty-state {
  min-height: 280px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 500;
}

.guest-card,
.table-card {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
  border-radius: 18px;
}

.guest-card {
  padding: 14px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.guest-name {
  font-size: 1rem;
}

.guest-meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.guest-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.guest-actions .icon-button,
.delete-table-btn {
  padding: 8px 12px;
  background: rgba(95, 158, 67, 0.1);
  color: var(--text);
}

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

.table-card.is-featured {
  border-color: rgba(95, 158, 67, 0.4);
  box-shadow: 0 14px 28px rgba(63, 111, 47, 0.12);
}

.table-card {
  padding: 18px;
}

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

.table-settings {
  margin-top: 14px;
}

.table-settings .field {
  max-width: 160px;
}

.table-capacity {
  margin: 6px 0 0;
  color: var(--muted);
}

.table-dropzone {
  margin-top: 16px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(201, 109, 66, 0.08), rgba(201, 109, 66, 0.02));
  padding: 12px;
  min-height: 140px;
}

.table-guest-card {
  padding: 12px;
  background: white;
  border-radius: 14px;
  border: 1px solid rgba(79, 57, 29, 0.12);
}

.table-guest-card h4 {
  margin-bottom: 4px;
}

.table-guest-controls {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

.empty-state {
  padding: 18px;
  border-radius: 14px;
  border: 1px dashed rgba(79, 57, 29, 0.22);
  color: var(--muted);
  text-align: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 700;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 920px) {
  .hero,
  .panel-header {
    align-items: start;
  }

  .hero,
  .workspace,
  .form-grid {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

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

  .floorplan-copy {
    align-items: start;
    flex-direction: column;
  }

  body.tables-workspace-mode .workspace {
    grid-template-columns: 1fr;
    min-height: auto;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 20px, 1200px);
    padding-top: 20px;
  }

  .hero,
  .panel {
    padding: 18px;
  }

  .stats-row {
    grid-template-columns: 1fr;
  }

  h1 {
    max-width: none;
    font-size: 2.7rem;
  }
}
