:root {
  --bg: #f4f2ee; --card: #fff; --ink: #1d1f24; --muted: #6b6f78; --line: #e6e3dd;
  --accent: #23395d; --lux: #a8822f; --lux-bg: #f7efdc; --danger: #b3261e;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); }
h1, h2, h3 { margin: 0 0 .4rem; line-height: 1.2; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.05rem; } h3 { font-size: .95rem; }
.muted { color: var(--muted); margin: 0; }
.error { color: var(--danger); margin: .6rem 0 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1.25rem; margin-bottom: 1rem; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 8px; background: var(--accent); color: #fff; padding: .65rem 1rem; }
button.link { background: none; color: var(--accent); padding: 0; }
button.danger { color: var(--danger); }
input[type=password] { font: inherit; width: 100%; padding: .65rem .8rem; border: 1px solid var(--line); border-radius: 8px; margin: .8rem 0; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login .card { width: 100%; max-width: 340px; }
.login button { width: 100%; }

.top { display: flex; justify-content: space-between; align-items: center; padding: .9rem 1.5rem; background: var(--accent); color: #fff; }
.top .brand { font-weight: 700; letter-spacing: .02em; }
.top button.link { color: #fff; opacity: .85; }

.layout { display: grid; grid-template-columns: 300px 1fr; gap: 1rem; padding: 1.5rem; max-width: 1440px; margin: 0 auto; }
@media (max-width: 800px) { .layout { grid-template-columns: 1fr; padding: 1rem; } .layout section { order: -1; } }

.drop { display: flex; flex-direction: column; align-items: center; gap: .4rem; padding: 1.4rem; margin-top: .6rem; border: 2px dashed var(--line); border-radius: 10px; cursor: pointer; color: var(--muted); }
.drop:hover { border-color: var(--accent); color: var(--accent); }
.drop svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.drop input { display: none; }

.history { list-style: none; margin: 0; padding: 0; }
.history li a { display: block; padding: .55rem .6rem; border-radius: 8px; color: inherit; text-decoration: none; }
.history li a span { display: block; color: var(--muted); font-size: .85rem; }
.history li.active a, .history li a:hover { background: var(--bg); }

.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .6rem; margin-top: 1rem; }
.stats div { background: var(--bg); border-radius: 10px; padding: .7rem .9rem; }
.stats b { display: block; font-size: 1.5rem; }
.stats span { color: var(--muted); font-size: .85rem; }
.stats .lux { background: var(--lux-bg); }
@media (max-width: 500px) { .stats { grid-template-columns: repeat(2, 1fr); } }

table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--line); padding: .4rem .5rem; }
table.list td { border-bottom: 1px solid var(--line); padding: .5rem; }
table.list .n { text-align: right; width: 90px; }
table.list td.lux { color: var(--lux); font-weight: 600; }

.tables { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .6rem; }
.table { border: 1px solid var(--line); border-radius: 10px; padding: .8rem; }
.table p { margin: .2rem 0; display: flex; justify-content: space-between; }
.table p span { color: var(--muted); }

table.plan td.lux { color: var(--lux); font-weight: 600; }
table.plan .note { display: block; font-size: .78rem; color: var(--muted); font-weight: 400; }
table.plan tr.row4 td:first-child { color: var(--danger); }
table.plan tr.luxrow td { background: repeating-linear-gradient(135deg, #fbd3e6 0 6px, #fde8f2 6px 12px); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
@media print {
  .top, aside, .bookings, .head form, .head button { display: none !important; }
  body { background: #fff; }
  .layout { display: block; padding: 0; }
  .card { border: 0; padding: 0; }
  table.list td { padding: .3rem .5rem; }
}

/* Floor grid */
.plan-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .8rem; }
.plan-head h1 span { display: block; font-size: .9rem; font-weight: 400; color: var(--muted); margin-top: .2rem; }
.plan-head .actions { display: flex; gap: 1rem; }
.floor { display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: minmax(44px, auto); grid-auto-flow: dense; gap: 4px; }
.cell { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .6rem; padding: .4rem .6rem; background: var(--card); border: 1px solid var(--line); border-radius: 6px; }
.cell b { font-variant-numeric: tabular-nums; }
.cell .pax { font-weight: 700; }
.cell.free { background: transparent; color: #b5b2ab; border-style: dashed; }
.floor.three { grid-template-columns: repeat(3, 1fr); }
.cell { white-space: nowrap; min-width: 0; }
.cell .name { overflow: hidden; text-overflow: ellipsis; }
.floor-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
@media (max-width: 700px) {
  .layout { padding: .5rem; }
  .floor, .floor.three { grid-template-columns: repeat(var(--cols, 4), minmax(142px, 1fr)); gap: 3px; }
  .floor.three { --cols: 3; }
  .cell { gap: .3rem; padding: .35rem .4rem; font-size: .8rem; }
  .cell b { font-size: .72rem; }
}
@media print {
  .plan-head .actions { display: none; }
  .floor { gap: 7px; grid-auto-rows: minmax(36px, auto); }
  .cell { border-color: #999; }
}
.floor .cell[data-src] { cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.cell.dragging { opacity: .35; }
.cell.target { outline: 2px solid var(--accent); outline-offset: 1px; }
.cell.ghost { box-shadow: 0 8px 24px rgba(0,0,0,.18); cursor: grabbing; }
body.saving .floor { opacity: .6; pointer-events: none; }
.cell .star { width: 1em; height: 1em; vertical-align: -.12em; margin-right: .25em; fill: currentColor; }
.plan-head h1 { font-size: 1.05rem; font-weight: 600; }

/* Not seated + linking */
.unseated { margin-top: 1rem; padding: .8rem; border: 2px dashed var(--line); border-radius: 8px; }
.unseated h2 { font-size: .9rem; margin-bottom: .5rem; }
.unseated.empty { display: none; }
body.dragging .unseated.empty { display: block; }
.unseated.target { border-color: var(--accent); background: #fff; }
.unseated .hint { color: var(--muted); font-size: .85rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; gap: .6rem; align-items: center; padding: .35rem .6rem; background: var(--card); border: 1px solid var(--line); border-radius: 6px; white-space: nowrap; cursor: grab; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.chip .pax { font-weight: 700; }
.chip .star { width: 1em; height: 1em; vertical-align: -.12em; margin-right: .25em; fill: currentColor; }
.chip.ghost { box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.linkbar { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: center; padding: .6rem .8rem; margin-bottom: .6rem; background: var(--accent); color: #fff; border-radius: 8px; }
.linkbar[hidden] { display: none; }
.linkbar span { flex: 1; min-width: 200px; }
.linkbar button.link { color: #fff; font-weight: 600; }
.linkbar button:disabled { opacity: .4; cursor: default; }
body.linking .floor .cell { cursor: pointer; }
.cell.selected { outline: 3px solid var(--accent); outline-offset: -1px; }
@media print { .linkbar, .unseated.empty { display: none !important; } }

/* New list + add guests */
.newlist summary { list-style: none; cursor: pointer; }
.newlist summary::-webkit-details-marker { display: none; }
.newlist summary h2 { margin: 0; }
.newlist summary h2::after { content: "+"; float: right; color: var(--muted); font-weight: 400; }
.newlist[open] summary h2::after { content: "\2212"; }
.newlist form { display: grid; gap: .6rem; margin-top: .8rem; }
.newlist .seg { display: flex; gap: 1rem; }
.newlist .row { display: flex; gap: .5rem; }
.newlist input[type=date], .newlist input[type=time], .addguest input[type=text], .addguest input[type=number] { font: inherit; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 8px; min-width: 0; }
.newlist .row input { flex: 1; }
.addguest { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .6rem; margin-bottom: .6rem; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.addguest[hidden] { display: none; }
.addguest input[type=text] { flex: 1; min-width: 140px; }
.addguest input[type=number] { width: 4.5rem; }
.addguest button { padding: .5rem 1rem; }
.chip form { display: inline; margin: 0; }
.chip .remove { background: none; color: var(--muted); padding: 0 .1rem; font-size: 1.1rem; line-height: 1; }
.chip .remove:hover { color: var(--danger); }
@media print { .addguest, .chip .remove { display: none !important; } }
