:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --shadow: 0 8px 24px rgba(17, 24, 39, 0.06);
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Sukhumvit Set', 'Noto Sans Thai', system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}

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

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

.auth-header { text-align: center; margin-bottom: 24px; }
.auth-header h1 { margin: 0 0 4px; font-size: 28px; color: var(--primary); }
.auth-subtitle { margin: 0; color: var(--muted); }

.auth-form { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 14px; color: var(--muted); }
.field input {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}
.field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn {
  font: inherit;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); }

.form-error {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
}

.auth-footer {
  margin-top: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.app-header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.app-header h1 { margin: 0; font-size: 20px; color: var(--primary); }
.app-header-right { display: flex; align-items: center; gap: 12px; }
.teacher-name { color: var(--muted); font-size: 14px; }

.app-main {
  max-width: 960px;
  margin: 24px auto;
  padding: 0 24px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 8px; }
.card + .card { margin-top: 24px; }
.muted { color: var(--muted); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

.field select {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.form-success {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
}

.role-badge {
  display: inline-block;
  background: rgba(37, 99, 235, 0.15);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  margin-left: 8px;
  vertical-align: middle;
}

.role-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}
.role-tag.role-admin { background: rgba(37, 99, 235, 0.15); color: var(--primary); }
.role-tag.role-teacher { background: #f3f4f6; color: var(--text); }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.data-table th { font-size: 13px; color: var(--muted); font-weight: 600; }
.data-table tr:last-child td { border-bottom: none; }

.field textarea {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  resize: vertical;
}
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.schedule-toggle { display: flex; flex-direction: column; gap: 12px; }
.checkbox-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; color: var(--text);
  cursor: pointer;
}
.checkbox-row input { width: 16px; height: 16px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab {
  font: inherit;
  background: transparent;
  border: none;
  padding: 8px 14px;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab-active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.message-row {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.message-row:last-child { border-bottom: none; }
.message-row-header {
  display: flex; gap: 12px; flex-wrap: wrap;
  align-items: center;
  font-size: 13px;
  margin-bottom: 6px;
}
.message-body {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.5;
}

.status-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}
.status-tag.status-sent { background: #ecfdf5; color: #047857; }
.status-tag.status-scheduled { background: #fef3c7; color: #92400e; }
.status-tag.status-failed { background: #fef2f2; color: var(--danger); }
