:root {
  --bg: #0c0d10;
  --bg-2: #141519;
  --panel: #17181d;
  --line: #2a2c34;
  --text: #eceef2;
  --muted: #8b90a0;
  --red: #e02535;
  --red-dim: #7d1721;
  --green: #21c07a;
  --amber: #f0b429;
  --radius: 14px;
  --font: 'Helvetica Neue', Inter, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

/* Class-based `display` would otherwise win over the UA rule for [hidden]. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

button, input { font-family: inherit; font-size: 1rem; }

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

.eyebrow {
  margin: 0;
  font-size: .72rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--red);
  font-weight: 700;
}

/* ------------------------------------------------------------------ buttons */

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: .62rem 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: #f43142; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-ghost:hover { color: var(--text); border-color: #40434f; }
.btn-danger { background: transparent; color: var(--red); border-color: var(--red-dim); }
.btn-danger:hover { background: rgba(224, 37, 53, .12); }
.btn-block { width: 100%; margin-top: .4rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* -------------------------------------------------------------------- login */

.login {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 1.5rem;
  background:
    radial-gradient(900px 480px at 50% -8%, rgba(224, 37, 53, .16), transparent 70%),
    var(--bg);
}

.login-card {
  width: min(400px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 2.2rem 1.9rem;
  box-shadow: 0 30px 70px rgba(0, 0, 0, .55);
}

.logo {
  margin: .35rem 0 .25rem;
  font-size: 2.1rem;
  line-height: 1.05;
  letter-spacing: -.02em;
  font-weight: 800;
  font-style: italic;
  text-transform: uppercase;
}

.login-sub { margin: 0 0 1.6rem; color: var(--muted); font-size: .88rem; }

label {
  display: block;
  margin: 1rem 0 .4rem;
  font-size: .78rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: .72rem .85rem;
  outline: none;
}
input:focus { border-color: var(--red); }

.error { color: #ff7b86; font-size: .85rem; min-height: 1.2em; margin: .7rem 0 0; }

/* ------------------------------------------------------------------- topbar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .8rem 1.2rem;
  border-bottom: 1px solid var(--line);
  background: rgba(12, 13, 16, .85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand { display: flex; align-items: center; gap: .7rem; }
.brand-mark { font-size: 1.3rem; }
.brand strong { display: block; font-style: italic; text-transform: uppercase; letter-spacing: -.01em; }
.brand-sub { display: block; font-size: .75rem; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: .8rem; }
.who { font-size: .85rem; color: var(--muted); }
.who b { color: var(--text); }

/* ------------------------------------------------------------------- layout */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1rem;
  padding: 1rem 1.2rem 2rem;
  align-items: start;
}

.map-panel, .side-block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.map-panel { padding: .9rem; }

.map-head {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .7rem;
}

.legend { display: flex; gap: .5rem; flex-wrap: wrap; }
.chip {
  font-size: .74rem;
  padding: .28rem .6rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}
.chip::before { content: ''; width: 9px; height: 9px; border-radius: 3px; }
.chip-free::before { background: #3a3d47; }
.chip-mine::before { background: var(--green); }
.chip-taken::before { background: var(--red); }

.counters { display: flex; gap: 1rem; font-size: .78rem; color: var(--muted); }
.counters b { color: var(--text); font-size: .95rem; }

.map-wrap {
  background: #fbfbfc;
  border-radius: 10px;
  padding: .5rem;
  overflow: auto;
}
#map {
  width: 100%;
  height: auto;
  max-height: calc(100vh - 190px);
  display: block;
  margin: 0 auto;
  touch-action: manipulation;
}

/* --------------------------------------------------------------- map pieces */

.wall { fill: none; stroke: #10131a; stroke-width: 5; stroke-linejoin: round; }
.step { fill: #d6d8de; stroke: #b9bcc6; stroke-width: 1.5; }
.room { fill: #fff; stroke: #10131a; stroke-width: 3.5; }
.room-label { font: 700 21px var(--font); fill: #10131a; text-anchor: middle; letter-spacing: .06em; }
.zone-label { font: italic 800 40px var(--font); fill: #8c2029; text-anchor: middle; }
.exit-label { font: 600 18px var(--font); fill: #10131a; text-anchor: middle; }

.seat { fill: #fff; stroke: #9aa0ad; stroke-width: 2; }
.table-shape { stroke: #10131a; stroke-width: 3; fill: #fff; transition: fill .18s ease; }
.table-num { font: 700 26px var(--font); text-anchor: middle; dominant-baseline: central; pointer-events: none; }

.table-g { cursor: pointer; }
.table-g:hover .table-shape { fill: #ffe9eb; }
.table-g:focus { outline: none; }
.table-g:focus-visible .table-shape { stroke: var(--red); stroke-width: 5; }

.is-mine .table-shape { fill: var(--green); stroke: #147a4c; }
.is-mine .table-num { fill: #fff; }
.is-mine .seat { fill: #d6f5e6; stroke: #4bbd8c; }
.is-mine:hover .table-shape { fill: #1ba86a; }

.is-taken .table-shape { fill: var(--red); stroke: #8c1420; }
.is-taken .table-num { fill: #fff; }
.is-taken .seat { fill: #ffdde0; stroke: #d4838c; }
.is-taken:hover .table-shape { fill: #c81f2d; }

.holder { font: 600 17px var(--font); text-anchor: middle; fill: #10131a; pointer-events: none; }

/* --------------------------------------------------------------------- side */

.side { display: grid; gap: .8rem; position: sticky; top: 4.4rem; }
.side-block { padding: 1rem; }
.side-block h2 {
  margin: 0 0 .8rem;
  font-size: .8rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.count {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .05rem .5rem;
  color: var(--text);
}

.res-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; max-height: 55vh; overflow: auto; }
.res-list li {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .55rem .6rem;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: .87rem;
  cursor: pointer;
}
.res-list li:hover { border-color: #43464f; }
.res-list li.mine { border-color: rgba(33, 192, 122, .45); }
.res-tag {
  min-width: 2.3rem;
  text-align: center;
  font-weight: 700;
  background: var(--red);
  color: #fff;
  border-radius: 7px;
  padding: .18rem 0;
  font-size: .8rem;
}
.res-list li.mine .res-tag { background: var(--green); }
.res-body { min-width: 0; }
.res-body strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-body span { color: var(--muted); font-size: .78rem; }
.empty { color: var(--muted); font-size: .85rem; padding: .4rem 0; }

.hint { color: var(--muted); font-size: .78rem; line-height: 1.5; margin: 0 .2rem; }

/* -------------------------------------------------------------------- modal */

.dialog {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 18px;
  padding: 1.4rem;
  width: min(400px, calc(100vw - 2rem));
  box-shadow: 0 30px 70px rgba(0, 0, 0, .6);
}
.dialog::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(3px); }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.dialog-head h2 { margin: .2rem 0 0; font-size: 1.5rem; font-style: italic; text-transform: uppercase; }
.seats-badge {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .3rem .7rem;
  font-size: .78rem;
  color: var(--muted);
  white-space: nowrap;
}
.taken-note {
  margin-top: 1rem;
  padding: .7rem .8rem;
  border-radius: 10px;
  background: rgba(224, 37, 53, .1);
  border: 1px solid var(--red-dim);
  font-size: .87rem;
  line-height: 1.5;
}
.dialog-foot { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1.2rem; }
.dialog-foot .btn-danger { margin-right: auto; }

/* -------------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  background: #fff;
  color: #101216;
  padding: .7rem 1.1rem;
  border-radius: 999px;
  font-size: .87rem;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .4);
  z-index: 50;
}

/* ------------------------------------------------------------------ mobile */

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; }
  .res-list { max-height: none; }
  .map-wrap { padding: .25rem; }
}

/* On phones keep the plan at a size where a table is still a comfortable tap
   target, and let it scroll sideways instead of shrinking. */
@media (max-width: 760px) {
  #map { min-width: 680px; max-height: none; }
}

@media (max-width: 560px) {
  .topbar { padding: .7rem .8rem; }
  .layout { padding: .7rem .8rem 2rem; }
  .who { display: none; }
  .counters { width: 100%; }
}
