:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-alt: #f9fafc;
  --border: #e3e7ee;
  --text: #1a1f2b;
  --text-muted: #6b7280;
  --accent: #4f6ef7;
  --accent-hover: #3d5ae0;
  --accent-soft: #eef1ff;
  --danger: #e5484d;
  --danger-hover: #cf3339;
  --success: #1f8a3c;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, 0.08), 0 1px 3px rgba(16, 24, 40, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

header h1 {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.logout-button {
  margin-left: auto;
}

nav {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 4px;
  border-radius: 999px;
}

nav a {
  text-decoration: none;
  color: var(--text-muted);
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

nav a:hover {
  color: var(--text);
}

nav a.active {
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

main {
  max-width: 980px;
  margin: 32px auto 64px;
  padding: 0 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 20px;
}

.card h2 {
  margin: 0 0 18px;
  font-size: 15px;
  font-weight: 700;
  padding-left: 10px;
  border-left: 3px solid var(--accent);
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 18px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

button:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

button:active {
  transform: translateY(0);
  box-shadow: none;
}

button:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

button.danger {
  background: var(--danger);
}

button.danger:hover {
  background: var(--danger-hover);
}

button.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 500;
}

button.secondary:hover {
  background: var(--bg);
  box-shadow: none;
}

table button {
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 500;
}

input, select {
  font: inherit;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.table-scroll {
  overflow-x: auto;
  margin: -4px -4px 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 480px;
}

th, td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody tr {
  transition: background 0.1s ease;
}

tbody tr:hover {
  background: var(--surface-alt);
}

tbody tr:last-child td {
  border-bottom: none;
}

.empty-state {
  color: var(--text-muted);
  font-size: 14px;
  padding: 24px 0;
  text-align: center;
}

.form-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 4px;
}

.form-row input, .form-row select {
  flex: 1;
  min-width: 120px;
}

.form-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-muted);
  white-space: nowrap;
}

.seat-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.direction-label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

.seat-grid {
  display: grid;
  gap: 8px;
  width: 100%;
}

.seat {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.seat:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  z-index: 1;
}

.seat.front-row {
  background: var(--accent-soft);
  border-color: #c9d3fb;
}

.seat-id {
  font-size: 10px;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.seat.empty {
  background: transparent;
  color: var(--text-muted);
  border-style: dashed;
  font-weight: 400;
}

.teacher-desk {
  width: 100%;
  max-width: 340px;
  background: linear-gradient(180deg, #e7eaf1, #dde1ea);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  box-shadow: inset 0 1px 2px rgba(16, 24, 40, 0.06);
}

.message {
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 16px;
  border-left: 3px solid transparent;
}

.message.error {
  background: #fdecea;
  color: var(--danger);
  border-left-color: var(--danger);
}

.message.success {
  background: #eaf6ec;
  color: var(--success);
  border-left-color: var(--success);
}

.message.warning {
  background: #fff6e5;
  color: #9a6b00;
  border-left-color: #d69e00;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid #c9d3fb;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-hover);
}

.login-main {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-md);
}

.login-card h2 {
  text-align: center;
  border-left: none;
  padding-left: 0;
  font-size: 18px;
  margin-bottom: 24px;
}

.login-form-row {
  flex-direction: column;
  align-items: stretch;
}

.login-form-row input,
.login-form-row button {
  width: 100%;
}

@media (max-width: 640px) {
  header {
    padding: 12px 16px;
  }

  main {
    padding: 0 16px;
    margin: 20px auto 48px;
  }

  .card {
    padding: 16px;
  }

  .seat {
    font-size: 11px;
    min-height: 44px;
    padding: 6px 3px;
  }

  .seat-id {
    font-size: 9px;
  }
}
