:root {
  --bg: #f6f3ee;
  --panel: #fffdfa;
  --ink: #33302c;
  --ink-soft: #7d766c;
  --line: #e2dbd0;
  --accent: #a8745a;
  --accent-soft: #f0e2da;
  --floor: #fbf8f3;
  --grid: #e8e0d3;
  --table: #efe3d3;
  --table-line: #c9b399;
  --ok: #5b8c6e;
  --danger: #b5544a;
  --shadow: 0 1px 2px rgba(60, 45, 30, .08), 0 8px 24px rgba(60, 45, 30, .08);
  --radius: 10px;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.is-dragging {
  user-select: none;
  cursor: grabbing;
}

/* ------------------------------------------------------------------ topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(60, 45, 30, .05);
  z-index: 5;
}

.brand {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .02em;
  color: var(--accent);
}

.spacer {
  flex: 1;
}

.field-group {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.field-group__label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-soft);
  padding: 0 8px;
}

.field-group input {
  width: 62px;
}

.unit,
.times {
  color: var(--ink-soft);
  font-size: 12px;
}

.topbar__actions {
  display: flex;
  gap: 6px;
}

.sync {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px 0 4px;
  font-size: 12px;
  color: var(--ink-soft);
  white-space: nowrap;
}

.sync::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: .55;
}

.sync[data-state="saving"] {
  color: var(--ink-soft);
}

.sync[data-state="saved"] {
  color: #4b7a5c;
}

.sync[data-state="error"] {
  color: var(--danger);
  font-weight: 600;
}

input[type="number"],
input[type="text"],
input[type="search"] {
  font: inherit;
  color: inherit;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  min-width: 0;
}

input:focus-visible,
button:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn {
  font: inherit;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}

.btn:hover {
  background: var(--accent-soft);
  border-color: #d9c4b7;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn--primary:hover {
  background: #96634b;
  border-color: #96634b;
  color: #fff;
}

.btn--ghost {
  color: var(--ink-soft);
}

.btn--ghost:hover {
  color: var(--danger);
  background: #fbeceb;
  border-color: #eccfcc;
}

.btn--icon {
  width: 30px;
  height: 30px;
  padding: 0;
  font-size: 16px;
  line-height: 1;
}

.btn--wide {
  width: 66px;
  font-size: 12px;
}

/* ------------------------------------------------------------------ layout */
.layout {
  flex: 1;
  display: flex;
  min-height: 0;
}

.stage-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.stage {
  position: absolute;
  inset: 0;
  overflow: auto;
  background:
    radial-gradient(circle at 30% 20%, #fbf9f6, var(--bg) 70%);
}

.stage__inner {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: min-content;
  min-height: min-content;
  width: 100%;
  height: 100%;
  padding: 40px;
}

/* ------------------------------------------------------------------- salle */
.room {
  position: relative;
  flex: none;
  background-color: var(--floor);
  background-image:
    linear-gradient(to right, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: var(--m) var(--m);
  border: 2px solid #d3c7b4;
  border-radius: 3px;
  box-shadow: var(--shadow);
  touch-action: none;
}

.room__dims {
  position: absolute;
  bottom: -22px;
  right: 0;
  font-size: 11px;
  color: var(--ink-soft);
  letter-spacing: .04em;
}

/* ------------------------------------------------------------------ tables */
.table {
  position: absolute;
  transform: translate(-50%, -50%);
  cursor: grab;
  touch-action: none;
}

.table.is-selected {
  z-index: 3;
}

.table.is-dragging {
  cursor: grabbing;
  z-index: 4;
}

.table__top {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fdf7ee, var(--table));
  border: 1.5px solid var(--table-line);
  box-shadow: 0 2px 6px rgba(80, 60, 35, .14);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  overflow: hidden;
  text-align: center;
}

.table.is-selected .table__top {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft), 0 2px 8px rgba(80, 60, 35, .2);
}

.table.is-overlapping .table__top {
  border-color: var(--danger);
  background: repeating-linear-gradient(45deg, #fbe9e7, #fbe9e7 6px, #f6dcd9 6px, #f6dcd9 12px);
}

.table__name {
  font-weight: 600;
  line-height: 1.1;
  padding: 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.table__count {
  color: var(--ink-soft);
  line-height: 1;
}

.chair {
  position: absolute;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px dashed #c3b8a6;
  background: #fff;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -.02em;
  transform: translate(-50%, -50%);
  transition: box-shadow .12s, transform .12s;
  overflow: hidden;
}

.chair.is-taken {
  border-style: solid;
  border-color: rgba(0, 0, 0, .12);
  color: #fff;
  cursor: grab;
}

.chair.is-drop {
  box-shadow: 0 0 0 3px var(--accent);
  transform: translate(-50%, -50%) scale(1.18);
}

.chair.is-highlight {
  box-shadow: 0 0 0 3px var(--ok);
  transform: translate(-50%, -50%) scale(1.25);
}

/* --------------------------------------------------------------- overlays */
.overlay {
  position: absolute;
  z-index: 4;
  display: flex;
  gap: 6px;
  align-items: center;
}

.overlay--bl {
  left: 14px;
  bottom: 14px;
}

.overlay--br {
  right: 14px;
  bottom: 14px;
}

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

.scalebar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 10px;
  box-shadow: var(--shadow);
  font-size: 11px;
  color: var(--ink-soft);
}

.scalebar__bar {
  display: block;
  height: 8px;
  border: 1px solid var(--ink-soft);
  border-top: none;
  background: linear-gradient(to right, var(--ink-soft) 1px, transparent 1px) 0 0/50% 100% no-repeat;
}

/* ------------------------------------------------------------- inspecteur */
.inspector {
  position: absolute;
  left: 14px;
  top: 14px;
  z-index: 4;
  width: 234px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
}

.inspector h3 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-soft);
}

.inspector label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--ink-soft);
}

.inspector label input[type="text"],
.inspector label input[type="number"] {
  width: 110px;
}

.inspector label input[type="range"] {
  width: 110px;
}

.inspector__actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}

.inspector__actions .btn {
  flex: 1;
  font-size: 12px;
  padding: 5px 6px;
}

/* ------------------------------------------------------------------ aside */
.sidebar {
  width: 320px;
  flex: none;
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar.is-drop {
  box-shadow: inset 0 0 0 3px var(--accent);
}

.sidebar__head {
  padding: 14px 16px 8px;
}

.sidebar__head h2 {
  margin: 0;
  font-size: 15px;
}

.stats {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--ink-soft);
}

.addguest {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 0 16px 12px;
}

.addguest input {
  width: 100%;
}

.addguest .btn {
  grid-column: 1 / -1;
}

.hint {
  grid-column: 1 / -1;
  color: var(--ink-soft);
  font-size: 11px;
}

.searchbox {
  padding: 0 16px 10px;
  border-bottom: 1px solid var(--line);
}

.searchbox input {
  width: 100%;
}

.lists {
  flex: 1;
  overflow: auto;
  padding: 10px 16px 16px;
}

.list-block+.list-block {
  margin-top: 18px;
}

.list-block h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-soft);
}

.count {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 20px;
  padding: 1px 7px;
  font-size: 11px;
  letter-spacing: 0;
}

.guest-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.guest {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: grab;
  touch-action: none;
}

.guest:hover {
  border-color: #d9c4b7;
  background: #fffaf6;
}

.guest__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}

.guest__name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.guest__meta {
  font-size: 11px;
  color: var(--ink-soft);
  white-space: nowrap;
}

.guest__del {
  border: none;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
  border-radius: 4px;
  opacity: 0;
}

.guest:hover .guest__del {
  opacity: 1;
}

.guest__del:hover {
  color: var(--danger);
}

.seated-table {
  margin-bottom: 12px;
}

.seated-table__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 0 5px;
  cursor: pointer;
}

.seated-table__head small {
  font-weight: 400;
  color: var(--ink-soft);
}

.empty {
  color: var(--ink-soft);
  font-size: 12px;
  margin: 2px 0;
}

.dropzone-hint {
  margin: 0;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--ink-soft);
}

/* ------------------------------------------------------------- drag ghost */
.drag-ghost {
  position: fixed;
  z-index: 999;
  pointer-events: none;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  box-shadow: 0 6px 18px rgba(60, 45, 30, .28);
  transform: translate(-50%, -140%);
  white-space: nowrap;
}

/* ------------------------------------------------------- écran de verrouillage */
.gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(51, 48, 44, .55);
  backdrop-filter: blur(3px);
}

.gate[hidden] {
  display: none;
}

.gate__box {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.gate__title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.gate__text {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
}

.gate__error {
  margin: 0;
  min-height: 16px;
  color: var(--danger);
  font-size: 12px;
}

/* ---------------------------------------------------------------- impression */
@media print {
  .topbar,
  .sidebar,
  .overlay,
  .inspector,
  .gate,
  .dropzone-hint {
    display: none !important;
  }

  body {
    background: #fff;
    overflow: visible;
  }

  .stage {
    position: static;
    overflow: visible;
  }

  .room {
    box-shadow: none;
  }
}
