:root {
  --bg: #fbfaf8;
  --panel: #ffffff;
  --ink: #221f1a;
  --muted: #6b645c;
  --line: #e3ddd4;
  --accent: #7a5c3e;
  --accent-soft: #f3ece4;
  --seat: #ffffff;
  --seat-full: #efe6db;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

header.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

header.top h1 {
  font-size: 17px;
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
}

header.top .sub {
  color: var(--muted);
  font-size: 13px;
}

main.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 260px;
  gap: 14px;
  padding: 14px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.panel h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 8px;
  font-weight: 600;
}

textarea, input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  font: inherit;
  color: inherit;
  background: #fff;
}

textarea { min-height: 110px; resize: vertical; }

button {
  font: inherit;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer;
}

button:hover { border-color: var(--accent); }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

button.primary:hover { filter: brightness(1.06); }

.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 10px;
}

#stage {
  position: relative;
  width: 1000px;
  height: 680px;
  max-width: 100%;
  background:
    linear-gradient(#00000005 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, #00000005 1px, transparent 1px) 0 0 / 40px 40px,
    #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  touch-action: none;
}

.table {
  position: absolute;
  background: var(--accent-soft);
  border: 1.5px solid #d9c9b6;
  cursor: grab;
  user-select: none;
}

.table.round { border-radius: 50%; }
.table.rect { border-radius: 10px; }
.table.head { border-radius: 10px; background: #f7efe0; }
.table.dragging { cursor: grabbing; box-shadow: 0 6px 20px #0000001f; }

.table .tag {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  color: #6d5c4a;
  white-space: nowrap;
  pointer-events: none;
}

.seat {
  position: absolute;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  border: 1.5px dashed #c3b6a4;
  background: var(--seat);
  font-size: 9px;
  line-height: 1;
  color: #5d4c3a;
  overflow: hidden;
}

.seat.full {
  border-style: solid;
  background: var(--seat-full);
  color: #3f3222;
  font-weight: 600;
}

.seat.sel { outline: 2px solid var(--accent); outline-offset: 1px; }

.chip {
  display: inline-block;
  margin: 0 4px 4px 0;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 13px;
  cursor: pointer;
}

.chip.sel { background: var(--accent); border-color: var(--accent); color: #fff; }

#stats { display: flex; gap: 10px; flex-wrap: wrap; }

.stat {
  min-width: 62px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 8px;
  text-align: center;
}

.stat b { display: block; font-size: 18px; line-height: 1.1; }
.stat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.muted { color: var(--muted); font-size: 13px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: #221f1a;
  color: #fff;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}

#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- content pages ---- */
header.top .brand { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
header.top .brand a { color: var(--ink); text-decoration: none; }
header.top nav a { margin-left: 14px; color: var(--ink); text-decoration: none; font-size: 14px; }
header.top nav a:hover { text-decoration: underline; }

.doc {
  max-width: 760px;
  margin: 26px auto 40px;
  padding: 0 18px;
}

.doc h1 {
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 14px;
}

.doc h2 { font-size: 20px; margin: 26px 0 10px; }
.doc h3 { font-size: 16px; margin: 20px 0 6px; }
.doc p { margin: 0 0 12px; }
.doc ul, .doc ol { margin: 0 0 14px; padding-left: 20px; }
.doc li { margin-bottom: 6px; }
.doc a { color: #6b4a2a; }

.cta {
  display: inline-block;
  background: var(--accent);
  color: #fff !important;
  text-decoration: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  margin: 6px 0 10px;
}

.cta:hover { filter: brightness(1.06); }

.foot {
  border-top: 1px solid var(--line);
  padding: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.foot a { color: var(--muted); }

@media (max-width: 1100px) {
  main.layout { grid-template-columns: 1fr; }
  #stage { width: 100%; height: 520px; }
}

@media print {
  @page { size: A4 landscape; margin: 8mm; }
  header.top, .panel, .toolbar, #toast, .noprint, .foot { display: none !important; }
  main.layout { display: block; padding: 0; }
  body { background: #fff; }
  #stage {
    width: 100%;
    height: auto;
    min-height: 520px;
    border: 0;
    background: none;
    zoom: 0.62;
  }
  .table { border-color: #999; background: #fff; }
  .seat { border-color: #999; }

  /* leyenda: nombres completos por mesa, solo al imprimir */
  #legend { display: block; break-before: page; color: #000; font-size: 10pt; }
  #legend h2 { font-size: 15pt; margin: 0 0 2mm; }
  #legend .legend-sub { font-size: 9pt; color: #444; margin: 0 0 5mm; }
  #legend .legend-grid { columns: 3; column-gap: 10mm; }
  #legend .legend-table { break-inside: avoid; margin: 0 0 5mm; }
  #legend h3 { font-size: 10.5pt; margin: 0 0 1mm; }
  #legend ul { margin: 0; padding-left: 4mm; }
  #legend li { font-size: 9.5pt; line-height: 1.35; }
  #legend li.empty { color: #777; font-style: italic; }
  #legend .legend-pending { font-size: 9.5pt; }
}
