:root {
  --bg: #edf7ff;
  --bg-soft: #f6fbff;
  --card: #ffffff;
  --line: #c8deef;
  --text: #1d425e;
  --muted: #5f7e95;
  --accent: #5eaee0;
  --danger: #c94e5e;
  --success: #1f8d70;
  --shadow: 0 14px 34px rgba(64, 123, 167, 0.15);
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(138, 197, 236, 0.25), transparent 42%),
    radial-gradient(circle at bottom left, rgba(203, 233, 253, 0.55), transparent 42%),
    var(--bg);
}

button,
input { font: inherit; }

button {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.55rem 1rem;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  transition: 0.2s ease;
}

button:hover { transform: translateY(-1px); }
button:disabled { opacity: 0.6; cursor: not-allowed; }

button.secondary {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

button.danger {
  background: #fff;
  border-color: #f0c4cb;
  color: var(--danger);
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  background: #fff;
  color: var(--text);
}

input:focus {
  outline: 2px solid #cae8fb;
  border-color: #9ccbeb;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.login-card {
  width: min(420px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 2rem;
}

.login-card h1 { margin: 0; font-size: 1.8rem; }
.login-card p { color: var(--muted); margin: 0.6rem 0 1.2rem; }

.login-form { display: grid; gap: 0.9rem; }
.login-form label { display: grid; gap: 0.4rem; font-size: 0.95rem; }
.form-error { color: var(--danger); margin: 0; }

.planner-page {
  padding: 1.4rem;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem 1.2rem;
  box-shadow: var(--shadow);
}

.topbar h1 { margin: 0; }
.topbar-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.save-status { margin: 0.25rem 0 0; font-size: 0.9rem; color: var(--muted); }
.save-status[data-state="saved"] { color: var(--success); }
.save-status[data-state="error"] { color: var(--danger); }

.notice { margin: 0.75rem 0 0; color: var(--text); font-size: 0.92rem; }

.planner-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.tables-area,
.guest-sidebar {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}

.section-head h2,
.section-head h3 { margin: 0; }
.section-head p { margin: 0; color: var(--muted); font-size: 0.92rem; }
.section-head-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

.tables-grid { display: grid; gap: 0.95rem; }

.table-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.8rem;
  background: var(--bg-soft);
  overflow: hidden;
}

.table-controls {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.7rem;
  align-items: end;
  margin-bottom: 0.75rem;
}

.table-controls label { font-size: 0.85rem; color: var(--muted); }
.table-controls label input { margin-top: 0.25rem; width: 125px; }

.table-topdown {
  margin-top: 0.2rem;
  border: 1px dashed #c2ddec;
  border-radius: 14px;
  background: linear-gradient(180deg, #fafdff, #f3f9fe);
  min-height: 430px;
  display: grid;
  place-items: center;
  position: relative;
  padding: 0.8rem;
}

.table-seats-ring {
  position: relative;
  width: min(100%, 560px);
  aspect-ratio: 1;
}

.table-center {
  position: absolute;
  width: 185px;
  height: 185px;
  border-radius: 18px;
  border: 1px solid #a7cee7;
  background: #ffffff;
  display: grid;
  place-items: center;
  text-align: center;
  color: #1e4b6a;
  padding: 0.8rem;
  font-weight: 600;
  box-shadow: inset 0 0 0 6px rgba(185, 220, 241, 0.35);
}

.seat.seat-topdown {
  position: absolute;
  top: var(--y);
  left: var(--x);
  width: 118px;
  min-height: 88px;
  border: 1px solid #b9d8ec;
  border-radius: 12px;
  background: #fff;
  padding: 0.5rem;
  display: grid;
  gap: 0.35rem;
  align-content: space-between;
  transform: translate(-50%, -50%);
}

.seat.seat-topdown.over {
  border-color: #61aede;
  box-shadow: 0 0 0 2px rgba(117, 179, 220, 0.2);
}

.seat-number { font-size: 0.8rem; color: var(--muted); }
.seat-empty { font-size: 0.92rem; color: #7f97aa; }

.guest-sidebar { display: grid; align-content: start; gap: 0.8rem; }
.guest-add { display: grid; grid-template-columns: 1fr auto; gap: 0.5rem; }
.guest-search { margin-bottom: 0.2rem; }

.guest-list-wrapper {
  border: 1px dashed #afcfe4;
  border-radius: 12px;
  padding: 0.7rem;
  min-height: 240px;
  background: #fcfeff;
}

.guest-list-wrapper.over {
  border-color: #61aede;
  box-shadow: inset 0 0 0 2px rgba(117, 179, 220, 0.2);
}

.guest-list-wrapper h3 { margin: 0 0 0.7rem; font-size: 0.95rem; color: var(--muted); }
.guest-list { display: grid; gap: 0.45rem; }

.guest-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.45rem;
}

.guest-chip {
  border-radius: 999px;
  border: 1px solid #9fcbe8;
  background: #e8f6ff;
  color: #1e4b6a;
  padding: 0.36rem 0.64rem;
  font-size: 0.84rem;
  cursor: grab;
  white-space: nowrap;
}

.guest-chip.dragging { opacity: 0.55; }

@media (max-width: 1080px) {
  .planner-layout { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .topbar { padding: 0.85rem; }
  .table-controls { grid-template-columns: 1fr; }
  .table-controls label input { width: 100%; }
  .guest-row { grid-template-columns: 1fr; }

  .table-topdown {
    min-height: 350px;
  }

  .table-seats-ring {
    width: min(100%, 420px);
  }

  .table-center {
    width: 140px;
    height: 140px;
    font-size: 0.92rem;
  }

  .seat.seat-topdown {
    width: 96px;
    min-height: 78px;
    font-size: 0.9rem;
  }
}
