:root {
  --bg-top: #f4f5eb;
  --bg-bottom: #d9e8e2;
  --surface: #fffdf5;
  --surface-soft: #f7fbf8;
  --ink: #223033;
  --muted: #5a6c70;
  --line: #bed1ca;
  --accent: #2d6e62;
  --accent-strong: #1f534a;
  --danger: #b34f41;
  --success: #2f7f49;
  --table-fill: #f4e3c6;
  --table-line: #d4b17f;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Avenir Next", "Gill Sans", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background: linear-gradient(155deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  position: relative;
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  pointer-events: none;
  border-radius: 999px;
  opacity: 0.3;
  z-index: -1;
}

body::before {
  width: 38rem;
  height: 38rem;
  background: radial-gradient(circle at center, #f0c58f 0%, transparent 64%);
  top: -12rem;
  left: -10rem;
}

body::after {
  width: 30rem;
  height: 30rem;
  background: radial-gradient(circle at center, #9bc7bc 0%, transparent 68%);
  bottom: -10rem;
  right: -8rem;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.45rem, 2.4vw, 2rem);
  line-height: 1.15;
}

h2 {
  font-size: 1.2rem;
}

label {
  font-weight: 650;
  color: var(--ink);
}

.app-shell {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0 2.5rem;
  display: grid;
  gap: 1rem;
}

.card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 8px 30px rgba(30, 48, 46, 0.08);
}

.topbar {
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.eyebrow {
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.top-nav {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.link-button,
.btn,
.btn-row {
  border: 0;
  border-radius: 10px;
  font: inherit;
  font-weight: 650;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.16s ease, background-color 0.16s ease, color 0.16s ease;
}

.link-button,
.btn {
  padding: 0.68rem 1rem;
}

.btn-row {
  padding: 0.52rem 0.68rem;
  font-size: 0.92rem;
}

.link-button,
.btn,
.btn-row {
  background: var(--accent);
  color: #f7fffb;
}

.link-button:hover,
.btn:hover,
.btn-row:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.link-button[aria-current="page"],
.link-button.is-active {
  background: #f7fffb;
  color: var(--accent-strong);
  border: 1px solid var(--accent);
  box-shadow: inset 0 0 0 1px rgba(45, 110, 98, 0.18);
  transform: none;
}

.link-button[aria-current="page"]:hover,
.link-button.is-active:hover {
  background: #f7fffb;
  color: var(--accent-strong);
  transform: none;
}

.btn-row.secondary {
  background: #365c70;
}

.btn-row.danger {
  background: var(--danger);
}

button:disabled,
.btn-row:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

input,
select {
  width: 100%;
  border: 1px solid #a8beb6;
  border-radius: 10px;
  padding: 0.62rem 0.72rem;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45, 110, 98, 0.2);
}

.controls-card {
  padding: 1rem 1.2rem;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.controls-row label {
  min-width: 3rem;
}

.controls-row select {
  width: min(340px, 100%);
}

.group-size-input {
  width: 6.2rem;
}

.status {
  min-height: 1.25rem;
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.94rem;
}

.status.error {
  color: var(--danger);
}

.status.success {
  color: var(--success);
}

.seating-card {
  padding: 1rem;
}

.groups-card {
  padding: 1rem;
}

.groups-stage {
  min-height: 320px;
}

.groups-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.8rem;
}

.group-column {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fdfef9;
  padding: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.group-header {
  margin: 0;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.group-count {
  font-size: 0.84rem;
  color: var(--muted);
  font-weight: 650;
}

.group-list {
  min-height: 110px;
  border: 1px dashed #bdd0c9;
  border-radius: 12px;
  background: #f7fbf8;
  padding: 0.55rem;
  display: grid;
  gap: 0.45rem;
  align-content: start;
}

.group-list.is-drop-target {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(45, 110, 98, 0.2);
  background: #eef8f3;
}

.group-student {
  border: 1px solid #9fb7af;
  border-radius: 10px;
  padding: 0.5rem 0.58rem;
  background: #ffffff;
  box-shadow: 0 3px 8px rgba(42, 62, 57, 0.12);
  font-weight: 650;
  cursor: grab;
  user-select: none;
}

.group-student.is-dragging {
  opacity: 0.45;
}

.group-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 0.45rem 0.3rem;
}

.seating-stage {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 20px;
  min-height: 420px;
  height: min(68vh, 620px);
  background:
    radial-gradient(circle at 50% 16%, #ffffff 0%, #f1f7f3 55%, #e9f1ed 100%);
  overflow: hidden;
}

.seating-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(27, 55, 50, 0.06) 1px, transparent 1px);
  background-size: 16px 16px;
  opacity: 0.2;
}

.center-table {
  position: absolute;
  transform: translate(-50%, -50%);
  width: clamp(170px, 24vw, 250px);
  height: clamp(90px, 13vw, 120px);
  border-radius: 999px;
  background: linear-gradient(145deg, #fff4e0 0%, var(--table-fill) 100%);
  border: 2px solid var(--table-line);
  box-shadow: 0 10px 25px rgba(97, 75, 42, 0.2);
  color: #5b472e;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.04em;
  z-index: 2;
}

.seats-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
}

.seat {
  position: absolute;
  transform: translate(-50%, -50%);
  width: clamp(92px, 12vw, 118px);
  min-height: 74px;
  border-radius: 14px;
  border: 1px solid #8ea89f;
  background: linear-gradient(170deg, #ffffff 0%, #edf6f1 100%);
  box-shadow: 0 6px 14px rgba(34, 58, 52, 0.16);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  text-align: center;
  padding: 0.45rem 0.55rem;
  cursor: grab;
  user-select: none;
  animation: seat-pop 0.24s ease;
}

.seat:active {
  cursor: grabbing;
}

.seat-number {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #536a62;
  font-weight: 700;
}

.seat-name {
  font-size: 0.96rem;
  line-height: 1.2;
  word-break: break-word;
  font-weight: 700;
}

.seat.is-drop-target {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45, 110, 98, 0.23);
}

.seat.is-dragging {
  opacity: 0.45;
}

.hidden {
  display: none !important;
}

.empty-state,
.empty-inline {
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 1rem;
  color: var(--muted);
  background: var(--surface-soft);
}

.empty-state {
  text-align: center;
  padding: 1.25rem;
}

.manager-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.panel {
  padding: 1rem 1.1rem;
}

.inline-form {
  display: grid;
  gap: 0.5rem;
}

.input-row {
  display: flex;
  gap: 0.55rem;
}

.input-row input {
  flex: 1;
}

.list-stack {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}

.list-row {
  display: grid;
  gap: 0.5rem;
  align-items: center;
  border: 1px solid var(--line);
  background: #fefef9;
  border-radius: 12px;
  padding: 0.55rem;
}

.class-row {
  grid-template-columns: auto 1fr auto auto;
}

.student-row {
  grid-template-columns: auto 1fr auto auto;
}

.list-row.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(45, 110, 98, 0.18);
}

.row-input {
  width: 100%;
}

.row-tag {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.selected-class-name {
  margin-top: 0.28rem;
  margin-bottom: 0.76rem;
  color: var(--muted);
  font-weight: 650;
}

.animate-up {
  opacity: 0;
  transform: translateY(10px);
  animation: rise-up 0.42s ease forwards;
}

.delay-1 {
  animation-delay: 0.08s;
}

.delay-2 {
  animation-delay: 0.16s;
}

@keyframes rise-up {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes seat-pop {
  from {
    opacity: 0;
    transform: translate(-50%, -46%);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

@media (max-width: 900px) {
  .manager-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(1100px, calc(100% - 1rem));
  }

  .controls-row,
  .input-row {
    flex-direction: column;
    align-items: stretch;
  }

  .class-row,
  .student-row {
    grid-template-columns: 1fr;
  }

  .btn-row {
    width: 100%;
  }

  .row-tag {
    letter-spacing: 0.05em;
  }
}
