:root {
  color-scheme: light;
  --background: #f7f5f0;
  --panel: #ffffff;
  --ink: #22201c;
  --muted: #6e675d;
  --line: #ddd6c9;
  --accent: #146c5f;
  --accent-dark: #0f5148;
  --warning: #9b3d2d;
  --soft: #edf7f4;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 700;
  min-height: 44px;
  padding: 0 14px;
}

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

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 44px;
  padding: 0 12px;
  background: white;
  color: var(--ink);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.app {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 34px;
}

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

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

.ghost-button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}

.ghost-button:hover {
  background: #eee8dc;
}

.form-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.form-row:last-child {
  grid-template-columns: minmax(180px, 1fr) 120px auto;
  margin-bottom: 0;
}

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

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

.section-title h2 {
  margin-bottom: 0;
}

.section-title span {
  display: grid;
  min-width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent-dark);
  font-weight: 800;
}

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

.guest-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffdf8;
}

.guest-card strong {
  line-height: 1.25;
}

.guest-card select {
  min-height: 38px;
}

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

.table-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  padding: 14px;
}

.table-card.is-full {
  border-color: var(--warning);
}

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

.table-header h3 {
  margin: 0;
  font-size: 18px;
}

.capacity {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.warning {
  color: var(--warning);
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 14px;
  text-align: center;
}

@media (max-width: 760px) {
  .app {
    padding: 16px;
  }

  .topbar {
    align-items: start;
  }

  h1 {
    font-size: 28px;
  }

  .form-row,
  .form-row:last-child,
  .layout {
    grid-template-columns: 1fr;
  }
}

.auth-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 2fr;
  gap: 16px;
  margin-bottom: 18px;
  align-items: start;
}

.auth-form {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.button-row,
.save-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.helper-text {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

.app-actions {
  align-items: start;
}

.save-actions {
  justify-content: flex-end;
}

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

@media (max-width: 900px) {
  .auth-panel,
  .auth-form {
    grid-template-columns: 1fr;
  }

  .save-actions {
    justify-content: flex-start;
  }
}

[hidden] {
  display: none !important;
}

/* Seating workspace */
.layout {
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
}

.guest-list {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.guest-list .stack {
  max-height: min(640px, calc(100vh - 150px));
  overflow-y: auto;
  padding-right: 4px;
}

.compact-guest-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  padding: 8px;
}

.compact-guest-info {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.compact-guest-info strong,
.seat-guest-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-guest-info span {
  color: var(--muted);
  font-size: 12px;
}

.assignment-select {
  min-height: 34px;
  border-radius: 7px;
  padding: 0 8px;
  font-size: 13px;
}

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

.table-card {
  overflow: hidden;
}

.table-map {
  position: relative;
  min-height: 360px;
  aspect-ratio: 1 / 1;
  width: min(100%, 460px);
  margin: 4px auto 0;
}

.table-center {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  width: 38%;
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  border: 2px solid var(--accent);
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent-dark);
  text-align: center;
  padding: 16px;
}

.table-center strong {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-center span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.seat {
  position: absolute;
  z-index: 2;
  width: 34%;
  min-height: 74px;
  transform: translate(-50%, -50%);
  display: grid;
  gap: 5px;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 8px;
  box-shadow: 0 6px 18px rgba(34, 32, 28, 0.08);
}

.seat.is-empty {
  border-style: dashed;
  background: #fbfaf6;
  color: var(--muted);
}

.seat-number {
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.seat-empty-label {
  font-size: 13px;
}

.seat .assignment-select {
  min-height: 30px;
  font-size: 12px;
}

@media (max-width: 900px) {
  .guest-list {
    position: static;
    max-height: none;
  }

  .guest-list .stack {
    max-height: 360px;
  }

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

@media (max-width: 520px) {
  .compact-guest-row {
    grid-template-columns: 1fr;
  }

  .table-map {
    min-height: 420px;
    aspect-ratio: auto;
  }

  .table-center {
    width: 44%;
  }

  .seat {
    width: 42%;
    min-height: 68px;
    padding: 7px;
  }
}

/* Table type and seat assignment refinements */
.form-row:last-child {
  grid-template-columns: minmax(180px, 1fr) 160px 120px auto;
}

.compact-guest-row {
  grid-template-columns: minmax(0, 1fr) 170px;
}

.compact-guest-row > strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-map-round {
  aspect-ratio: 1 / 1;
}

.table-map-square {
  aspect-ratio: 1 / 1;
}

.table-map-long {
  width: min(100%, 620px);
  min-height: 310px;
  aspect-ratio: 1.65 / 1;
}

.table-center-round {
  border-radius: 999px;
}

.table-center-square {
  border-radius: 8px;
}

.table-center-long {
  width: 58%;
  height: 30%;
  aspect-ratio: auto;
  border-radius: 8px;
}

.table-map-long .seat {
  width: 28%;
}

@media (max-width: 900px) {
  .form-row:last-child {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .compact-guest-row {
    grid-template-columns: 1fr;
  }

  .table-map-long {
    min-height: 430px;
    aspect-ratio: auto;
  }

  .table-map-long .seat {
    width: 42%;
  }
}

/* Management actions and room overview */
.danger-button {
  min-height: 34px;
  border: 1px solid #ead2cc;
  background: #fff7f5;
  color: var(--warning);
  padding: 0 10px;
  font-size: 13px;
}

.danger-button:hover {
  background: #f7e4df;
}

.compact-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.table-header .danger-button {
  white-space: nowrap;
}

.seat-meta {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-overview-panel {
  margin-top: 18px;
}

.room-overview {
  min-height: 420px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfaf6;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 18px;
  align-items: center;
  padding: 18px;
}

.overview-table {
  min-height: 150px;
  display: grid;
  gap: 6px;
  align-content: center;
  justify-items: center;
  border: 2px solid var(--accent);
  background: white;
  color: var(--ink);
  padding: 14px;
  text-align: center;
  box-shadow: 0 8px 22px rgba(34, 32, 28, 0.08);
}

.overview-table-round {
  border-radius: 999px;
  aspect-ratio: 1 / 1;
}

.overview-table-square {
  border-radius: 8px;
  aspect-ratio: 1 / 1;
}

.overview-table-long {
  border-radius: 8px;
  min-height: 110px;
  aspect-ratio: 1.75 / 1;
}

.overview-table > strong {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview-table > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.overview-guests {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  max-width: 100%;
}

.overview-guests span {
  border-radius: 999px;
  background: var(--soft);
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 700;
  max-width: 110px;
  overflow: hidden;
  padding: 3px 7px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 520px) {
  .compact-actions {
    grid-template-columns: 1fr;
  }

  .room-overview {
    grid-template-columns: 1fr;
    min-height: auto;
  }
}

/* Square table seating alignment */
.table-map-square {
  width: min(100%, 520px);
  min-height: 430px;
}

.table-map-square .table-center {
  width: 34%;
}

.table-map-square .seat {
  width: 24%;
  min-width: 0;
  min-height: 72px;
}

.table-map-square .seat-guest-name,
.table-map-square .assignment-select {
  max-width: 100%;
}

@media (max-width: 640px) {
  .table-map-square {
    min-height: 520px;
  }

  .table-map-square .seat {
    width: 34%;
  }
}

/* Compact work mode for seating maps */
.tables {
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
}

.table-card {
  padding: 10px;
}

.table-header {
  margin-bottom: 4px;
}

.table-header h3 {
  font-size: 17px;
}

.capacity {
  font-size: 13px;
}

.table-map {
  width: min(100%, 330px);
  min-height: 270px;
  margin-top: 0;
}

.table-center {
  width: 30%;
  padding: 10px;
}

.table-center strong {
  font-size: 15px;
}

.table-center span {
  font-size: 11px;
}

.seat {
  width: 28%;
  min-height: 50px;
  gap: 3px;
  padding: 6px;
  box-shadow: 0 3px 10px rgba(34, 32, 28, 0.06);
}

.seat-number {
  font-size: 10px;
}

.seat-empty-label {
  font-size: 12px;
}

.seat-guest-name {
  font-size: 13px;
}

.seat .assignment-select {
  min-height: 28px;
  font-size: 12px;
  padding: 0 6px;
}

.table-map-square {
  width: min(100%, 340px);
  min-height: 300px;
}

.table-map-square .table-center {
  width: 30%;
}

.table-map-square .seat {
  width: 21%;
  min-height: 52px;
}

.table-map-long {
  width: min(100%, 390px);
  min-height: 220px;
}

.table-map-long .seat {
  width: 22%;
}

.table-center-long {
  width: 52%;
  height: 26%;
}

.room-overview {
  min-height: 300px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.overview-table {
  min-height: 120px;
  padding: 10px;
}

@media (max-width: 640px) {
  .table-map,
  .table-map-square,
  .table-map-long {
    width: 100%;
    min-height: 360px;
  }

  .table-map-square .seat,
  .table-map-long .seat,
  .seat {
    width: 35%;
  }
}

/* Dense seating planner overrides */
.app {
  width: min(1440px, 100%);
}

.layout {
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 12px;
}

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

.table-card {
  padding: 8px;
}

.table-header h3 {
  font-size: 16px;
}

.table-header .danger-button {
  min-height: 30px;
  padding: 0 8px;
  font-size: 12px;
}

.table-map {
  width: min(100%, 250px);
  min-height: 210px;
}

.table-map-square {
  width: min(100%, 260px);
  min-height: 230px;
}

.table-map-long {
  width: min(100%, 300px);
  min-height: 170px;
}

.table-center {
  width: 26%;
  padding: 0;
}

.table-center strong,
.table-center span {
  display: none;
}

.seat {
  width: 24%;
  min-height: 42px;
  padding: 5px;
}

.seat.is-empty {
  min-height: 36px;
}

.table-map-square .seat {
  width: 19%;
  min-height: 42px;
}

.table-map-long .seat {
  width: 18%;
}

.seat-guest-name {
  font-size: 12px;
}

.seat-empty-label,
.seat-number {
  font-size: 10px;
}

.seat .assignment-select {
  min-height: 25px;
  font-size: 11px;
}

.assignment-select {
  min-height: 30px;
}

/* Draggable room overview */
.room-overview {
  position: relative;
  min-height: 520px;
  display: block;
  overflow: hidden;
  background:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px),
    #fbfaf6;
  background-size: 40px 40px;
  touch-action: none;
}

.overview-table {
  position: absolute;
  width: 120px;
  min-height: 72px;
  cursor: grab;
  user-select: none;
  touch-action: none;
  padding: 8px;
}

.overview-table.is-dragging {
  cursor: grabbing;
  opacity: 0.86;
  z-index: 5;
}

.overview-table-round,
.overview-table-square {
  aspect-ratio: 1 / 1;
}

.overview-table-long {
  width: 150px;
  min-height: 68px;
}

.overview-guests {
  display: none;
}

@media (max-width: 700px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .table-map,
  .table-map-square,
  .table-map-long {
    width: 100%;
    min-height: 300px;
  }

  .seat,
  .table-map-square .seat,
  .table-map-long .seat {
    width: 34%;
  }
}

/* Overview grid and readable compact names */
.seat-guest-name {
  line-height: 1.05;
  overflow-wrap: anywhere;
  text-align: center;
  white-space: normal;
}

.compact-guest-row > strong {
  white-space: normal;
}

.room-overview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: minmax(150px, auto);
  gap: 16px;
  min-height: auto;
  overflow: visible;
  touch-action: auto;
}

.overview-table {
  position: static;
  width: auto;
  min-height: 150px;
  cursor: default;
  touch-action: auto;
}

.overview-table-long {
  width: auto;
  min-height: 120px;
}

.overview-guests {
  display: flex;
}

@media (max-width: 900px) {
  .room-overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .room-overview {
    grid-template-columns: 1fr;
  }
}

/* Full short names and mini seating overview */
.seat-guest-name {
  overflow: visible;
  text-overflow: clip;
  white-space: nowrap;
}

.overview-table {
  gap: 8px;
  align-content: start;
  justify-items: stretch;
}

.overview-table-header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.overview-table-header strong,
.overview-table-header span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview-table-header span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.overview-mini-map {
  position: relative;
  width: 100%;
  min-height: 150px;
  margin-top: 4px;
}

.overview-mini-map-long {
  min-height: 120px;
}

.overview-mini-center {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 28%;
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  border: 2px solid var(--accent);
  background: var(--soft);
}

.overview-mini-center-round {
  border-radius: 999px;
}

.overview-mini-center-square,
.overview-mini-center-long {
  border-radius: 6px;
}

.overview-mini-center-long {
  width: 52%;
  height: 24%;
  aspect-ratio: auto;
}

.overview-seat {
  position: absolute;
  width: 28%;
  min-height: 22px;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  overflow: hidden;
  padding: 3px;
  text-align: center;
  white-space: nowrap;
}

.overview-seat.is-occupied {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.overview-mini-map-square .overview-seat {
  width: 24%;
}

.overview-mini-map-long .overview-seat {
  width: 22%;
}

@media (max-width: 560px) {
  .overview-mini-map {
    min-height: 180px;
  }
}

/* Compact draggable room overview override */
.room-overview {
  position: relative;
  display: block;
  overflow: hidden;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px),
    #fbfaf6;
  background-size: 40px 40px;
  touch-action: none;
}

.overview-table {
  position: absolute;
  width: 30%;
  min-height: 230px;
  display: block;
  border: 0;
  background: transparent;
  box-shadow: none;
  cursor: grab;
  padding: 0;
  touch-action: none;
  user-select: none;
}

.overview-table.is-dragging {
  cursor: grabbing;
  opacity: 0.88;
  z-index: 5;
}

.overview-table-long {
  width: 30%;
  min-height: 190px;
}

.overview-mini-map {
  min-height: 220px;
}

.overview-mini-map-long {
  min-height: 180px;
}

.overview-mini-center {
  display: grid;
  place-items: center;
  color: var(--accent-dark);
  font-size: 18px;
  font-weight: 900;
}

.overview-seat {
  width: 26%;
  min-height: 24px;
}

.overview-mini-map-square .overview-seat {
  width: 23%;
}

.overview-mini-map-long .overview-seat {
  width: 20%;
}

@media (max-width: 800px) {
  .overview-table,
  .overview-table-long {
    width: 45%;
  }
}

@media (max-width: 560px) {
  .overview-table,
  .overview-table-long {
    width: 88%;
  }
}

/* Alignment and overflow fixes */
.compact-guest-row > strong {
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
}

.seat-guest-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
}

.room-overview {
  background-size: 48px 48px;
}

.overview-table,
.overview-table-long {
  width: 28%;
  min-height: 300px;
}

.overview-mini-map {
  min-height: 290px;
}

.overview-mini-map-long {
  min-height: 230px;
}

.overview-mini-center {
  width: 24%;
}

.overview-mini-center-long {
  width: 46%;
  height: 20%;
}

.overview-seat {
  width: 21%;
  min-height: 22px;
  font-size: 9px;
  padding: 2px;
}

.overview-mini-map-square .overview-seat {
  width: 19%;
}

.overview-mini-map-long .overview-seat {
  width: 18%;
}

@media (max-width: 900px) {
  .overview-table,
  .overview-table-long {
    width: 42%;
  }
}

@media (max-width: 560px) {
  .overview-table,
  .overview-table-long {
    width: 86%;
    min-height: 300px;
  }
}

/* Larger table bodies and two-row unassigned guests */
.compact-guest-row {
  grid-template-columns: 1fr;
  gap: 6px;
}

.compact-guest-row > strong {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
}

.compact-actions {
  grid-template-columns: minmax(0, 1fr) auto;
}

.table-center {
  width: 38%;
  display: grid;
  place-items: center;
  color: var(--accent-dark);
  font-size: 24px;
  font-weight: 900;
}

.table-center-square {
  width: 42%;
}

.table-center-long {
  width: 62%;
  height: 34%;
}

.table-map-square .seat {
  width: 19%;
}

.table-map-long .seat {
  width: 18%;
}

.overview-mini-center {
  width: 36%;
  font-size: 22px;
}

.overview-mini-center-square {
  width: 40%;
}

.overview-mini-center-long {
  width: 62%;
  height: 30%;
}

.overview-mini-map-square .overview-seat {
  width: 18%;
}

.overview-mini-map-long .overview-seat {
  width: 17%;
}

@media (max-width: 700px) {
  .table-center {
    width: 34%;
  }

  .table-center-square {
    width: 38%;
  }
}

/* Cleaner table cards and readable seat names */
.table-header {
  justify-content: flex-end;
  min-height: 30px;
}

.table-header .danger-button {
  margin-left: auto;
}

.seat-guest-name {
  display: block;
  max-width: 100%;
  overflow: visible;
  overflow-wrap: anywhere;
  text-align: center;
  white-space: normal;
  font-size: 11px;
  line-height: 1.05;
}

.seat {
  justify-items: stretch;
}
