:root {
  color-scheme: light;
  --ink: #24313f;
  --muted: #687485;
  --line: #d5dbe3;
  --paper: #fbfaf7;
  --wall: #eef1f3;
  --accent: #2f7d6f;
  --accent-dark: #1f5f54;
  --gold: #b88737;
  --danger: #b45309;
  --shadow: 0 18px 44px rgba(28, 38, 50, 0.12);
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea,
select {
  font: inherit;
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

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

h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.1;
  letter-spacing: 0;
}

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

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: #ffffff;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

#save-table {
  width: 100%;
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
}

#save-table:hover {
  background: var(--accent-dark);
}

.workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: 0;
  flex: 1;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  background: #ffffff;
  border-right: 1px solid var(--line);
}

.panel-header {
  display: grid;
  gap: 2px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.panel-header span,
.hint {
  color: var(--muted);
  font-size: 13px;
}

.panel-header strong {
  font-size: 20px;
}

label {
  display: grid;
  gap: 6px;
  color: #4a5565;
  font-size: 13px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  color: var(--ink);
  background: #ffffff;
}

textarea {
  resize: vertical;
  min-height: 170px;
}

.guest-count {
  margin: -6px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.guest-count.mismatch {
  color: #c62828;
}

.save-status {
  min-height: 18px;
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.save-status.error {
  color: #c62828;
}

input.mismatch {
  border-color: #c62828;
  color: #c62828;
  box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.12);
}

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

.hint {
  margin: 0;
  line-height: 1.4;
}

.floor-wrap {
  min-width: 0;
  overflow: auto;
  padding: 24px;
}

.floor {
  position: relative;
  width: min(1320px, calc(100vw - 392px));
  min-width: 930px;
  aspect-ratio: 16 / 9;
  margin: 0 auto;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(213, 219, 227, 0.42) 1px, transparent 1px),
    linear-gradient(rgba(213, 219, 227, 0.42) 1px, transparent 1px),
    var(--paper);
  background-size: 40px 40px;
  border: 3px solid #aeb8c4;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.floor::before,
.floor::after {
  content: "";
  position: absolute;
  pointer-events: none;
  border-color: #8794a3;
}

.floor::before {
  left: 0;
  right: 0;
  bottom: 9%;
  border-top: 3px solid #8794a3;
}

.floor::after {
  left: 13%;
  top: 0;
  bottom: 55%;
  border-left: 3px solid #8794a3;
}

.label {
  position: absolute;
  z-index: 1;
  color: #6c7480;
  font-size: clamp(12px, 1.2vw, 18px);
  font-weight: 700;
  pointer-events: none;
}

.top-title {
  top: 2.5%;
  left: 34%;
  color: #475569;
  font-size: clamp(16px, 1.7vw, 28px);
}

.dining {
  top: 12%;
  left: 8%;
  writing-mode: vertical-rl;
}

.sweet {
  top: 1.5%;
  left: 16%;
}

.wc {
  left: 1.5%;
  top: 47%;
}

.entry {
  right: 1.5%;
  top: 46%;
}

.window {
  left: 48%;
  bottom: 2%;
}

.staff {
  left: 2%;
  bottom: 6%;
  transform: rotate(-72deg);
}

.kids {
  right: 16%;
  bottom: 32%;
  color: var(--danger);
  writing-mode: vertical-rl;
}

#tables-layer {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.table {
  --x: 50;
  --y: 50;
  position: absolute;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  display: grid;
  place-items: center;
  width: var(--w);
  height: var(--h);
  color: #16222e;
  background: #ffffff;
  border: 3px solid #34495e;
  box-shadow: 0 7px 16px rgba(37, 49, 63, 0.14);
  cursor: grab;
  user-select: none;
  touch-action: none;
  transform: translate(-50%, -50%);
}

.table:active {
  cursor: grabbing;
}

.table.selected {
  outline: 4px solid rgba(47, 125, 111, 0.28);
  outline-offset: 4px;
}

.table.mismatch {
  border-color: #c62828;
}

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

.table.square {
  border-radius: 6px;
}

.table.rect {
  border-radius: 4px;
}

.table.sweet {
  border-radius: 4px;
  border-style: dashed;
  background: #fff7dc;
}

.table.head {
  width: var(--w);
  height: calc(var(--h) * 0.82);
  border-radius: 90px 90px 8px 8px;
  background: #f8fbff;
}

.table-number {
  display: grid;
  place-items: center;
  min-width: 44px;
  height: 44px;
  padding: 0 8px;
  border: 2px solid #526477;
  border-radius: 999px;
  font-weight: 800;
}

.table-meta {
  position: absolute;
  top: -27px;
  left: 50%;
  width: max-content;
  max-width: 150px;
  transform: translateX(-50%);
  color: #4b5563;
  font-size: 15px;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.table.mismatch .table-meta {
  color: #c62828;
}

.resize-handle {
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 18px;
  height: 18px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 4px 10px rgba(36, 49, 63, 0.26);
  cursor: nwse-resize;
}

.resize-handle::before {
  content: "";
  position: absolute;
  inset: 4px;
  border-right: 2px solid rgba(255, 255, 255, 0.85);
  border-bottom: 2px solid rgba(255, 255, 255, 0.85);
}

#tooltip {
  position: absolute;
  z-index: 4;
  display: none;
  min-width: 230px;
  max-width: 310px;
  padding: 12px 13px;
  color: #ffffff;
  background: rgba(28, 38, 50, 0.95);
  border-radius: 8px;
  box-shadow: var(--shadow);
  pointer-events: none;
}

#tooltip strong {
  display: block;
  margin-bottom: 6px;
}

#tooltip ul {
  margin: 0;
  padding-left: 18px;
  line-height: 1.45;
}

@media (max-width: 850px) {
  .topbar,
  .workspace {
    display: block;
  }

  .actions {
    margin-top: 14px;
  }

  .panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .floor-wrap {
    padding: 14px;
  }

  .floor {
    width: 930px;
  }
}
