:root {
  --primary: #0891b2;
  --primary-dark: #0e7490;
  --accent: #0d9488;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --success: #16a34a;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.06);
  --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px;
}

/* ---------- header ---------- */
header.site-header {
  background: linear-gradient(135deg, var(--primary-dark), var(--accent));
  color: #fff;
  padding: 28px 0;
  box-shadow: var(--shadow);
}

header.site-header .container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

header.site-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

header.site-header p {
  opacity: 0.9;
  font-size: 0.95rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.topbar .brand a {
  color: #fff;
  text-decoration: none;
  font-size: 1rem;
  font-weight: 600;
  opacity: 0.9;
}

.topbar .brand a:hover { opacity: 1; }

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.card h2 {
  font-size: 1.1rem;
  margin-bottom: 16px;
  color: var(--text);
}

/* ---------- forms ---------- */
label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, transform .05s;
  font-family: inherit;
}

.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #0f766e; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

.btn-ghost { background: transparent; color: var(--primary); border: 1px solid var(--border); }
.btn-ghost:hover { background: #f8fafc; }

.btn-sm { padding: 6px 12px; font-size: 0.85rem; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

/* ---------- class selector ---------- */
.selector-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.selector-bar select {
  max-width: 220px;
}

/* ---------- schedule grid ---------- */
.grid-wrap { overflow-x: auto; }

table.schedule {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
}

table.schedule th, table.schedule td {
  border: 1px solid var(--border);
  padding: 12px;
  text-align: center;
  vertical-align: top;
  font-size: 0.9rem;
}

table.schedule thead th {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  position: sticky;
  top: 0;
}

table.schedule thead th.time-col { background: var(--primary-dark); min-width: 110px; }

table.schedule tbody th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.cell-subject {
  font-weight: 700;
  color: var(--primary-dark);
}

.cell-teacher {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 2px;
}

.cell-room {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.75rem;
  background: #ecfeff;
  color: var(--primary-dark);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.cell-empty { color: #cbd5e1; }

/* ---------- admin ---------- */
.login-wrap {
  max-width: 400px;
  margin: 60px auto;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.tab {
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
  transition: all .15s;
}

.tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.item-list { display: flex; flex-direction: column; gap: 8px; }

.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  flex-wrap: wrap;
}

.item-row .item-info { flex: 1; min-width: 180px; }

.item-row .item-info .title { font-weight: 600; }
.item-row .item-info .sub { font-size: 0.82rem; color: var(--muted); }

.item-actions { display: flex; gap: 6px; }

.section-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.notice {
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.notice-info { background: #e0f2fe; color: #075985; }
.notice-error { background: #fee2e2; color: #991b1b; }
.notice-success { background: #dcfce7; color: #166534; }

.hidden { display: none !important; }

.admin-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.schedule-form select {
  margin-bottom: 0;
}

@media (max-width: 600px) {
  .container { padding: 14px; }
  header.site-header h1 { font-size: 1.3rem; }
  .form-row { grid-template-columns: 1fr; }
}
