:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --border: #e7e9f0;
  --text: #1e2233;
  --muted: #6b7280;
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-soft: #eef0ff;
  --success: #10b981;
  --success-soft: #ecfdf5;
  --danger: #ef4444;
  --warn: #f59e0b;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 8px 24px rgba(16,24,40,.06);
}
* { box-sizing: border-box; }
body {
  font-family: 'Inter', system-ui, 'Segoe UI', Roboto, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  pointer-events: none;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}

body::before {
  width: min(74vw, 720px);
  aspect-ratio: 1 / 1;
  left: 50%;
  top: 54%;
  transform: translate(-50%, -50%);
  background-image: url("assets/olympus-watermark.png");
  opacity: .055;
  z-index: 0;
}

header,
.tab-panel {
  position: relative;
}

.tab-panel { z-index: 1; }

/* ---- Header / top bar ---- */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px 0;
  position: sticky;
  top: 0;
  z-index: 10;
}
body.student-page header { padding-bottom: 16px; }
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  font-size: 0;
  border-radius: 14px;
  background-color: #0756ad;
  background-image: url("assets/olympus-corner.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 116%;
  box-shadow: 0 7px 18px rgba(7,86,173,.32), 0 0 0 1px rgba(255,255,255,.68) inset;
  flex-shrink: 0;
}
header h1 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.02em; }
header .sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.badge-soft {
  font-size: 11px; font-weight: 600; color: var(--primary-dark);
  background: var(--primary-soft); padding: 2px 8px; border-radius: 20px;
  vertical-align: middle; margin-left: 4px;
}

.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.header-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.student-link {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--primary-dark);
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.student-link:hover { background: var(--primary-soft); }
.theme-toggle {
  border: 1px solid var(--border); background: var(--surface);
  width: 42px; height: 42px; border-radius: 12px; font-size: 18px;
  display: grid; place-items: center; flex-shrink: 0;
  transition: background .15s, transform .1s;
}
.theme-toggle:hover { background: var(--primary-soft); transform: translateY(-1px); }

/* ---- Tabs (segmented) ---- */
.tabs { display: flex; gap: 4px; margin-top: 16px; }
.tab {
  border: none; background: none; cursor: pointer;
  padding: 12px 18px; font-size: 14px; font-weight: 500;
  color: var(--muted); border-bottom: 2px solid transparent;
  border-radius: 8px 8px 0 0;
}
.tab:hover { color: var(--text); background: #fafafe; }
.tab.active { color: var(--primary-dark); border-bottom-color: var(--primary); font-weight: 600; }

.system-nav { align-items: flex-end; flex-wrap: wrap; gap: 12px; }
.system-nav-title {
  align-self: center;
  font-weight: 800;
  color: var(--text);
  padding: 0 10px 10px 0;
  letter-spacing: -.01em;
}
.system-nav-group {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 5px 7px 0;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  background: #fbfcff;
}
.system-nav-group > span {
  align-self: center;
  margin: 0 6px 8px 2px;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}
.system-nav .tab { padding: 10px 13px; }

.tab-panel { display: none; padding: 28px; max-width: 1200px; }
.tab-panel.active { display: block; }
.hidden { display: none !important; }

/* ---- Card ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
  max-width: 960px;
}
.login-card { max-width: 380px; }
.student-card { max-width: 760px; }
.card h2 { margin: 0 0 6px; font-size: 18px; }

label { display: block; margin: 14px 0; font-size: 13px; font-weight: 500; color: #374151; }
input, select {
  width: 100%; padding: 11px 12px; margin-top: 6px;
  border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; font-family: inherit; background: #fcfcfe;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15); background: #fff;
}
button { cursor: pointer; font-family: inherit; }
button.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; border: none; padding: 12px 20px; border-radius: 10px;
  font-size: 14px; font-weight: 600; margin-top: 10px;
  box-shadow: 0 6px 14px rgba(99,102,241,.3);
  transition: transform .1s, box-shadow .15s;
}
button.primary:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(99,102,241,.4); }
button.primary:active { transform: translateY(0); }
button.link { background: none; border: none; color: var(--primary-dark); font-weight: 500; }
button.link:hover { text-decoration: underline; }
button.secondary {
  background: var(--surface);
  color: var(--primary-dark);
  border: 1px solid #c7c9f7;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  margin: 10px 0 0 8px;
}
button.secondary:hover { background: var(--primary-soft); }

.class-checklist {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin: 6px 0 14px;
}
.class-checklist.has-sectors { grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); }
.student-sector-title {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  cursor: pointer;
}
.student-sector-title:first-child { margin-top: 0; }
.student-sector-title:hover {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-color: #c7c9f7;
}
.student-sector-title .sector-title-main { display: flex; align-items: center; gap: 7px; min-width: 0; }
.student-sector-title .sector-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.class-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fcfcfe;
  cursor: pointer;
}
.class-check:hover { background: var(--primary-soft); border-color: #c7c9f7; }
.class-check input[type=checkbox] { width: auto; margin: 0; accent-color: var(--primary); }
.lookup-block { margin-top: 18px; }

.hint { font-size: 13px; color: var(--muted); }
.hint code, code { background: var(--primary-soft); color: var(--primary-dark); padding: 2px 7px; border-radius: 6px; font-size: 12px; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; }
.msg { font-size: 13px; min-height: 18px; }
.msg.ok { color: var(--success); }
.msg.err { color: var(--danger); }

/* ---- Dashboard ---- */
.dash-top {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 18px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 18px; box-shadow: var(--shadow);
}
.dash-body { display: flex; gap: 18px; align-items: flex-start; }

.classes-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; width: 250px;
  flex-shrink: 0; box-shadow: var(--shadow);
}
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.panel-head h3 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.panel-tools { display: flex; align-items: center; gap: 6px; }
.panel-wide-action { margin: -4px 0 12px; }
.bulk-open-btn { width: 100%; justify-content: center; }
.sector-add-btn {
  border: 1px solid #c7c9f7;
  background: var(--surface);
  color: var(--primary-dark);
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 12px;
  line-height: 1;
  font-weight: 700;
  white-space: nowrap;
}
.sector-add-btn:hover { background: var(--primary-soft); border-color: var(--primary); }
.icon-btn {
  border: 1px solid var(--border); background: var(--surface);
  width: 30px; height: 30px; border-radius: 8px; font-size: 14px; line-height: 1;
  display: grid; place-items: center; color: var(--muted);
}
.icon-btn:hover { background: var(--primary-soft); color: var(--primary-dark); border-color: #c7c9f7; }
.icon-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.cls-right { display: flex; align-items: center; }
.cls-edit,
.cls-del {
  border: none; color: #fff; width: 22px; height: 22px;
  border-radius: 6px; font-size: 13px; line-height: 1; display: grid; place-items: center;
}
.cls-edit { background: var(--primary); margin-right: 5px; }
.cls-edit:hover,
.cls-del:hover { filter: brightness(1.1); }
.cls-del { background: var(--danger); }
#class-list { list-style: none; padding: 0; margin: 0; }
#class-list li {
  padding: 11px 14px; border-radius: 10px; cursor: pointer; margin-bottom: 4px;
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 500; border: 1px solid transparent; transition: background .12s;
}
#class-list li:hover { background: #f7f8fc; }
#class-list li.selected {
  background: var(--primary-soft); color: var(--primary-dark);
  border-color: #dcdcfb; font-weight: 600;
}
.sector-title {
  cursor: pointer !important;
  margin: 12px 0 5px !important;
  padding: 3px 2px !important;
  border: none !important;
  background: transparent !important;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800 !important;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.sector-title:hover { color: var(--primary-dark); }
.sector-title.collapsed { margin-bottom: 6px !important; }
.sector-title:first-child { margin-top: 0 !important; }
.sector-title .sector-title-main { display: flex; align-items: center; gap: 6px; min-width: 0; }
.sector-toggle {
  border: none;
  background: transparent;
  color: var(--primary-dark);
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 12px;
  line-height: 1;
  flex-shrink: 0;
  transition: background .15s, transform .12s;
}
.sector-title:hover .sector-toggle { background: var(--primary-soft); }
.sector-title .sector-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sector-count {
  color: var(--primary-dark);
  background: var(--primary-soft);
  border-radius: 999px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 800;
}
.sector-edit {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--primary-dark);
  width: 22px;
  height: 22px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-size: 12px;
  line-height: 1;
  margin-left: auto;
}
.sector-edit:hover { background: var(--primary-soft); border-color: #c7c9f7; }
.badge { background: var(--warn); color: #fff; border-radius: 20px; font-size: 11px; font-weight: 600; padding: 2px 8px; }
.add-class { margin-top: 14px; display: flex; gap: 6px; }
.add-class input { margin: 0; }
.add-class button {
  white-space: nowrap; border: 1px solid var(--primary); background: #fff;
  color: var(--primary-dark); border-radius: 10px; padding: 0 14px; font-weight: 600;
}
.add-class button:hover { background: var(--primary-soft); }

.sector-editor {
  margin-top: 12px;
  padding: 13px;
  border: 1px solid #c7c9f7;
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff, #f8f8ff);
  box-shadow: 0 10px 24px rgba(99,102,241,.12);
}
.sector-editor h4 { margin: 0 0 8px; font-size: 13px; }
.sector-editor label { margin: 9px 0; }
.sector-editor .sector-class-list {
  display: grid;
  gap: 6px;
  margin: 8px 0 10px;
  max-height: 220px;
  overflow: auto;
}
.sector-editor .sector-class-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 8px 9px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
}
.sector-editor .sector-class-check input { width: auto; margin: 0; accent-color: var(--primary); }
.sector-editor .sector-editor-actions { display: flex; gap: 8px; justify-content: flex-end; }
.sector-editor .sector-save,
.sector-editor .sector-cancel {
  border-radius: 9px;
  padding: 8px 11px;
  font-size: 12px;
  font-weight: 700;
}
.sector-editor .sector-save { border: none; background: var(--primary); color: #fff; }
.sector-editor .sector-cancel { border: 1px solid var(--border); background: var(--surface); color: var(--muted); }

.class-detail {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; flex: 1;
  box-shadow: var(--shadow); min-width: 0;
}
/* Thanh trượt ngang của bảng nằm ngay trên khung gợi ý */
.schedule-scroll { overflow-x: auto; padding-bottom: 4px; }
.placeholder { color: #9ca3af; }
.detail-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.detail-head h3 { margin: 0; font-size: 18px; }
.detail-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn-del-class {
  background: var(--surface); color: var(--danger); border: 1px solid #fecaca;
  border-radius: 10px; padding: 7px 14px; font-size: 13px; font-weight: 500;
}
.btn-del-class:hover { background: #fef2f2; }
.btn-edit {
  background: var(--surface); color: var(--primary-dark); border: 1px solid #c7c9f7;
  border-radius: 10px; padding: 7px 14px; font-size: 13px; font-weight: 600;
}
.btn-edit:hover { background: var(--primary-soft); }
.btn-edit.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-current {
  background: var(--surface); color: #6b6b00; border: 1px solid #d4d40a;
  border-radius: 10px; padding: 7px 14px; font-size: 13px; font-weight: 600;
}
.btn-current:hover, .btn-current.active { background: rgba(253, 253, 10); color: #3f3f00; border-color: #d4d40a; }
.btn-export {
  background: var(--surface); color: #047857; border: 1px solid #a7f3d0;
  border-radius: 10px; padding: 7px 14px; font-size: 13px; font-weight: 600;
}
.btn-export:hover { background: #ecfdf5; border-color: #34d399; }
.btn-download-excel { color: #1d4ed8; border-color: #93c5fd; }
.btn-download-excel:hover { background: #eff6ff; border-color: #60a5fa; }
.btn-export-image { color: #b45309; border-color: #fcd34d; }
.btn-export-image:hover { background: #fffbeb; border-color: #f59e0b; }
.btn-export.export-error { color: var(--danger); border-color: #fecaca; background: #fef2f2; }
.btn-export:disabled { opacity: .65; cursor: wait; }
.image-export-overlay {
  position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center;
  padding: 18px; background: rgba(15, 23, 42, .52); backdrop-filter: blur(3px);
}
.image-export-dialog {
  width: min(430px, 100%); padding: 22px; border: 1px solid var(--border);
  border-radius: 16px; background: var(--surface); box-shadow: 0 24px 70px rgba(15,23,42,.28);
}
.image-export-dialog h3 { margin: 0 0 4px; font-size: 18px; }
.image-export-dialog .hint { margin: 0 0 12px; }
.image-export-dialog label { color: var(--text); }
.image-color-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.image-color-fields label { margin-top: 6px; }
.image-color-fields input[type=color] {
  height: 44px; padding: 4px; cursor: pointer; background: var(--surface);
}
.image-title-preview {
  display: flex; align-items: center; justify-content: center; min-height: 34px;
  margin-top: 14px; padding: 5px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 16px; font-weight: 900; text-align: center;
  text-shadow: 0 1px 0 rgba(255,255,255,.35), 0 2px 3px rgba(0,0,0,.22);
}
.image-day-preview {
  display: flex; align-items: center; justify-content: center; min-height: 32px;
  margin-top: 6px; padding: 5px 12px; border: 1px solid var(--border);
  border-radius: 8px; color: #111827; font-size: 13px; font-weight: 900;
  text-align: center;
}
.image-export-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 17px; }
.image-export-actions button { border-radius: 9px; padding: 9px 14px; font-weight: 700; }
.image-export-actions .image-export-cancel { border: 1px solid var(--border); background: var(--surface); color: var(--muted); }
.image-export-actions .primary { margin: 0; }
.current-hint { color: #6b6b00; }
.readonly-note { padding: 9px 12px; border-left: 3px solid var(--primary); background: var(--primary-soft); }

/* Cột thao tác + nút xoá học sinh */
.act-cell { padding: 4px !important; }
.student-row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
}
.student-name-wrap {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  white-space: nowrap;
}
.student-name-main-row {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.student-name-text { font-weight: 700; }
.student-submit-date {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.15;
}
.student-name-cell { min-width: 180px; }
.btn-del-stu {
  border: none; background: #fef2f2; color: var(--danger); width: 24px; height: 24px;
  border-radius: 6px; font-size: 13px; line-height: 1; display: grid; place-items: center;
}
.btn-del-stu:hover { background: var(--danger); color: #fff; }

/* Ô tick trong edit mode */
.cell-edit { cursor: pointer; }
.cell-edit input[type=checkbox] { width: auto; margin: 0; transform: scale(1.2); cursor: pointer; accent-color: var(--primary); }

/* Danh sách Lớp Cũ */
.archived-list { list-style: none; padding: 0; margin: 16px 0 0; }
.archived-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border: 1px solid var(--border); background: var(--bg);
  border-radius: 12px; margin-bottom: 8px; font-weight: 500;
}
.archived-item .acts button { margin-left: 6px; border-radius: 8px; border: none; padding: 7px 14px; font-weight: 600; color: #fff; }

/* ---- Bảng lịch ---- */
table.schedule { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
table.schedule th, table.schedule td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 7px 9px; text-align: center; }
table.schedule thead th { background: #fafbfe; font-weight: 600; color: #374151; }
table.schedule thead tr:first-child th { border-top: 1px solid var(--border); }
table.schedule th:first-child, table.schedule td:first-child { border-left: 1px solid var(--border); }
table.schedule td.name { text-align: left; font-weight: 600; white-space: nowrap; }
.busy { background: #fee2e2; color: #b91c1c; font-weight: 700; }
.other-class-slot { background: #2563eb !important; color: #ffffff !important; font-weight: 900; letter-spacing: .01em; }
.free { color: #d1d5db; }
.current-slot, td.current-slot, tr.summary td.current-slot {
  background: rgba(253, 253, 10) !important;
  color: #3f3f00 !important;
  font-weight: 700;
}
.current-picker { cursor: pointer; }
.current-picker input, .student-current-slot input { width: auto; margin: 0; accent-color: #d97706; }
.student-current-slot input:disabled { opacity: .55; cursor: not-allowed; }
.current-row td { border-top: 2px solid #d4d40a; border-bottom-color: #d4d40a !important; }
tr.summary td { background: #f3f4f6; font-weight: 700; }
td.best { background: #d1fae5 !important; color: #065f46; }
table.schedule th.zero-slot,
table.schedule td.zero-slot {
  background: #d1fae5;
  color: #065f46;
  font-weight: 700;
}
td.worst { color: #b91c1c; }

/* ---- Gợi ý ---- */
.recommend {
  margin-top: 18px; padding: 16px 18px;
  background: var(--success-soft); border: 1px solid #a7f3d0; border-radius: 12px;
}
.rec-title { font-weight: 600; color: #065f46; margin-bottom: 8px; }
.rec-line { padding: 3px 0; color: #047857; }
.rec-line b { display: inline-block; min-width: 34px; color: #065f46; }

/* ---- Chinh ca dong bo ---- */
.bulk-sessions-card { max-width: 1050px; }
.bulk-sessions-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 20px; margin-bottom: 12px;
}
.bulk-sessions-head .hint { margin-bottom: 0; }
.bulk-select-actions { display: flex; gap: 7px; flex-shrink: 0; }
.bulk-select-actions button {
  border: 1px solid #c7c9f7; background: var(--surface); color: var(--primary-dark);
  border-radius: 9px; padding: 8px 11px; font-size: 12px; font-weight: 700;
}
.bulk-select-actions button:hover { background: var(--primary-soft); }
.bulk-class-list { display: grid; gap: 14px; margin-top: 20px; }
.bulk-sector {
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
  background: #fcfcfe;
}
.bulk-sector-title {
  display: flex; align-items: center; gap: 9px; margin: 0; padding: 10px 13px;
  background: #f8fafc; border-bottom: 1px solid var(--border);
  color: var(--primary-dark); font-weight: 800; text-transform: uppercase;
  letter-spacing: .04em;
}
.bulk-sector-title input, .bulk-class-item input { width: auto; margin: 0; accent-color: var(--primary); }
.bulk-sector-title small { margin-left: auto; color: var(--muted); font-weight: 600; text-transform: none; letter-spacing: 0; }
.bulk-sector-classes {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px; padding: 12px;
}
.bulk-class-item {
  display: flex; align-items: center; gap: 8px; margin: 0; padding: 9px 10px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--surface);
  cursor: pointer;
}
.bulk-class-item:hover { background: var(--primary-soft); border-color: #c7c9f7; }
.bulk-save-row { display: flex; align-items: center; gap: 14px; margin-top: 18px; }
.bulk-save-row .primary { margin: 0; }

/* ---- Chờ duyệt ---- */
.teacher-add-student {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 160px auto;
  gap: 8px;
  align-items: center;
  margin-top: 18px;
}
.teacher-add-student input { margin: 0; }
.teacher-add-student button {
  border: 1px solid var(--primary);
  background: #fff;
  color: var(--primary-dark);
  border-radius: 10px;
  padding: 0 14px;
  min-height: 39px;
  font-weight: 600;
  white-space: nowrap;
}
.teacher-add-student button:hover { background: var(--primary-soft); }
.teacher-add-student button:disabled { opacity: .65; cursor: wait; }
.teacher-add-student .msg { grid-column: 1 / -1; margin: 0; }

.class-sessions-editor {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fafbfe;
}
.class-sessions-editor label { margin: 0 0 8px; }
.class-sessions-editor button {
  border: 1px solid var(--primary);
  background: #fff;
  color: var(--primary-dark);
  border-radius: 10px;
  padding: 9px 14px;
  font-weight: 600;
}
.lookup-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.lookup-head h3 { margin: 0; }
.lookup-result { margin-top: 12px; }
.lookup-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}
.lookup-actions .btn-send-change { min-width: 150px; }

.pending-box { margin-top: 22px; }
.pending-box h4 { margin: 0 0 10px; font-size: 14px; }
.pending-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border: 1px solid #fde68a; background: #fffbeb;
  border-radius: 10px; margin-bottom: 8px;
}
.pending-item em { color: var(--warn); font-style: normal; font-weight: 600; }
.pending-item .acts button { margin-left: 6px; border-radius: 8px; border: none; padding: 6px 12px; font-weight: 600; color: #fff; }
.pending-student-title { display: flex; flex-direction: column; gap: 2px; }
.pending-student-title > small:first-of-type { color: var(--muted); font-weight: 600; }
.pending-time { color: #92400e; font-size: 11px; font-weight: 700; }
.btn-approve { background: var(--success); }
.btn-reject { background: var(--danger); }

/* ---- Tài khoản giáo viên ---- */
.accounts-layout { display: grid; grid-template-columns: 280px minmax(0, 680px); gap: 18px; align-items: start; }
.accounts-list-card, .account-detail-card { width: 100%; padding: 20px; }
.account-list { list-style: none; padding: 0; margin: 16px 0 0; }
.account-list li {
  display: flex; flex-direction: column; gap: 3px; padding: 11px 12px; margin-bottom: 5px;
  border: 1px solid transparent; border-radius: 8px; cursor: pointer;
}
.account-list li:hover { background: var(--bg); }
.account-list li.selected { background: var(--primary-soft); border-color: #c7c9f7; color: var(--primary-dark); }
.account-list small { color: var(--muted); font-size: 12px; }
.account-create { padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.account-create-fields { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 10px; }
.account-create-fields label { margin-bottom: 0; }
.account-assignment { padding-top: 20px; }
.assignment-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.assignment-head h2, .assignment-head p { margin: 0; }
.assignment-head p { margin-top: 4px; color: var(--muted); }
.account-assignment h3 { margin: 22px 0 10px; font-size: 14px; }
.assignment-classes { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }

/* ---- Grid học sinh ---- */
.grid-wrap { overflow-x: auto; margin: 18px 0; }
table.grid { border-collapse: separate; border-spacing: 0; }
table.grid th, table.grid td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 9px 12px; text-align: center; }
table.grid th:first-child, table.grid td:first-child { border-left: 1px solid var(--border); }
table.grid thead th { border-top: 1px solid var(--border); }
table.grid th { background: #fafbfe; font-size: 13px; font-weight: 600; }
table.grid tbody th { background: #fff; text-align: left; }
table.grid input[type=checkbox] { width: auto; margin: 0; transform: scale(1.3); cursor: pointer; accent-color: var(--primary); }

@media (max-width: 760px) {
  .dash-body { flex-direction: column; }
  .classes-panel { width: 100%; }
  .tab-panel { padding: 18px; }
  .teacher-add-student { grid-template-columns: 1fr; }
  .teacher-add-student button { min-height: 42px; }
  .accounts-layout { grid-template-columns: 1fr; }
  .account-create-fields { grid-template-columns: 1fr; }
  .bulk-sessions-head { flex-direction: column; }
  .bulk-sector-classes { grid-template-columns: 1fr; }
  .bulk-save-row { align-items: stretch; flex-direction: column; }
  body::before { width: 92vw; top: 58%; opacity: .045; }
}

/* ===================== DARK MODE ===================== */
body.dark {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2a2e3c;
  --text: #e5e7eb;
  --muted: #98a1b3;
  --primary: #818cf8;
  --primary-dark: #a5b4fc;
  --primary-soft: #262a3d;
  --success: #34d399;
  --success-soft: #10261f;
  --danger: #f87171;
  --warn: #fbbf24;
  --shadow: 0 1px 2px rgba(0,0,0,.5), 0 8px 24px rgba(0,0,0,.55);
}
body.dark::before { opacity: .075; }
body.dark input, body.dark select { background: #12141c; color: var(--text); }
body.dark .class-check { background: #12141c; }
body.dark .class-check:hover { background: #20242f; }
body.dark .student-sector-title { background: #12141c; }
body.dark .student-sector-title:hover { background: var(--primary-soft); border-color: #3d4361; }
body.dark .tab:hover { background: #20242f; }
body.dark #class-list li:hover { background: #20242f; }
body.dark table.schedule thead th,
body.dark table.grid th { background: #20242f; color: #cbd5e1; }
body.dark table.grid tbody th { background: var(--surface); color: var(--text); }
body.dark .busy { background: #43232a; color: #fca5a5; }
body.dark .other-class-slot { background: #2563eb !important; color: #ffffff !important; }
body.dark .current-slot, body.dark td.current-slot, body.dark tr.summary td.current-slot { background: rgba(253, 253, 10) !important; color: #3f3f00 !important; }
body.dark .free { color: #3a3f4f; }
body.dark tr.summary td { background: #20242f; }
body.dark td.best { background: #10362a !important; color: #6ee7b7; }
body.dark table.schedule th.zero-slot,
body.dark table.schedule td.zero-slot { background: #10362a; color: #6ee7b7; }
body.dark .recommend { background: #0f2a20; border-color: #1f6f54; }
body.dark .rec-title, body.dark .rec-line b { color: #6ee7b7; }
body.dark .rec-line { color: #34d399; }
body.dark .pending-item { background: #2a2515; border-color: #5a4a16; }
body.dark .pending-item em { color: #fbbf24; }
body.dark .pending-time { color: #fbbf24; }
body.dark .class-sessions-editor { background: #12141c; }
body.dark .btn-del-class:hover,
body.dark .icon-btn:hover { background: #3a1f22; }
body.dark .icon-btn:hover { background: var(--primary-soft); color: var(--primary-dark); border-color: #3d4361; }
body.dark .btn-del-stu { background: #2a1d20; }
body.dark .archived-item { background: #12141c; }
body.dark .sector-editor { background: #12141c; border-color: #3d4361; }
body.dark .sector-editor .sector-class-check { background: #1a1d27; }
body.dark .btn-export:hover { background: #10261f; }
body.dark .btn-export-image:hover { background: #2a2515; }
body.dark .bulk-sector { background: #12141c; }
body.dark .bulk-sector-title { background: #20242f; }
body.dark .bulk-class-item { background: #1a1d27; }
body.dark .bulk-class-item:hover { background: var(--primary-soft); border-color: #3d4361; }

.btn-transfer { background: #2563eb; }
.btn-pending-toggle {
  background: #f59e0b !important;
  min-width: 30px;
  padding-left: 8px !important;
  padding-right: 8px !important;
}
.pending-item-wrap { margin-bottom: 8px; }
.pending-item-wrap .pending-item { margin-bottom: 0; }
.pending-detail {
  margin-top: 6px;
  padding: 9px 12px;
  border: 1px dashed #fbbf24;
  border-radius: 9px;
  background: #fff7ed;
  color: #92400e;
  font-size: 12px;
  line-height: 1.45;
}
.pending-busy-summary { margin-bottom: 8px; font-weight: 700; }
.pending-schedule-scroll { overflow-x: auto; }
.pending-schedule-table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 420px;
  font-size: 12px;
}
.pending-schedule-table th,
.pending-schedule-table td {
  border-right: 1px solid #fed7aa;
  border-bottom: 1px solid #fed7aa;
  padding: 6px 8px;
  text-align: center;
}
.pending-schedule-table th:first-child,
.pending-schedule-table td:first-child { border-left: 1px solid #fed7aa; }
.pending-schedule-table thead th { border-top: 1px solid #fed7aa; background: #ffedd5; color: #7c2d12; }
.pending-schedule-table tbody th { background: #fff7ed; color: #9a3412; font-weight: 800; }
.pending-schedule-table .pending-busy-cell { background: #fee2e2; color: #b91c1c; font-weight: 900; }
.pending-schedule-table .pending-free-cell { background: #ffffff; color: #cbd5e1; }
.btn-manage-stu {
  border: none;
  background: var(--primary-soft);
  color: var(--primary-dark);
  width: 24px;
  height: 24px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1;
  display: grid;
  place-items: center;
  margin: 0;
}
.btn-manage-stu:hover { background: var(--primary); color: #fff; }
.current-subject {
  min-width: 86px;
  width: 92px;
  margin: 5px auto 0;
  padding: 5px 6px;
  font-size: 11px;
  text-align: center;
}
.mini-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, .5);
  backdrop-filter: blur(3px);
}
.mini-dialog {
  width: min(520px, 100%);
  max-height: min(720px, 92vh);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 24px 70px rgba(15,23,42,.28);
}
.mini-dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.mini-dialog-head h3 { margin: 0; font-size: 17px; }
.mini-dialog-close {
  border: none;
  background: #f3f4f6;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  font-size: 20px;
}
.mini-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.mini-dialog-actions button { border-radius: 9px; padding: 9px 14px; font-weight: 700; }
.mini-cancel { border: 1px solid var(--border); background: var(--surface); color: var(--muted); }
.mini-class-list { display: grid; gap: 10px; margin-top: 10px; }
.mini-class-sector {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: #fafbfe;
}
.mini-class-sector h4 { margin: 0 0 8px; font-size: 13px; }
.mini-class-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 4px 8px 4px 0;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.mini-class-check input { width: auto; margin: 0; accent-color: var(--primary); }
.final-schedule-card { max-width: 1180px; }
.final-class-block { margin-top: 18px; }
.final-class-block h3 { margin: 0 0 8px; font-size: 16px; }
.final-schedule-table .final-subject-cell { min-width: 92px; text-transform: none; }
.tab-trash { margin-left: auto; padding-left: 14px; padding-right: 14px; }
body.dark .pending-detail { background: #2a2515; border-color: #5a4a16; color: #fbbf24; }
body.dark .pending-schedule-table th,
body.dark .pending-schedule-table td { border-color: #5a4a16; }
body.dark .pending-schedule-table thead th,
body.dark .pending-schedule-table tbody th { background: #3a2f13; color: #fbbf24; }
body.dark .pending-schedule-table .pending-busy-cell { background: #43232a; color: #fca5a5; }
body.dark .pending-schedule-table .pending-free-cell { background: #1a1d27; color: #4b5563; }
body.dark .mini-dialog, body.dark .mini-class-check { background: var(--surface); }
body.dark .mini-class-sector, body.dark .mini-dialog-close { background: #12141c; }

/* Weekly schedule planner */
.schedule-directory { display: grid; gap: 12px; margin-top: 10px; }
.schedule-sector {
  border: 1px solid var(--border);
  border-radius: 13px;
  overflow: hidden;
  background: var(--surface);
}
.schedule-sector-head {
  width: 100%;
  border: 0;
  border-radius: 0;
  background: #f8fafc;
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 14px;
  text-align: left;
}
.schedule-sector-head:hover { background: var(--primary-soft); }
.schedule-sector-head small { margin-left: auto; color: var(--muted); }
.schedule-sector-classes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 9px;
  padding: 12px;
}
.schedule-class-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}
.schedule-class-link:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
  background: var(--primary-soft);
}
.planner-topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.planner-topbar h2 { margin: 0; font-size: 22px; }
.planner-topbar p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.planner-week-actions {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-left: auto;
}
.planner-week-actions label { margin: 0; font-size: 11px; }
.planner-week-actions select { min-width: 210px; margin: 4px 0 0; padding: 8px; }
.planner-new-week {
  border: 0;
  border-radius: 10px;
  padding: 9px 14px;
  background: linear-gradient(135deg, var(--primary), #2563eb);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(79,70,229,.22);
}
.planner-new-week:hover { transform: translateY(-1px); box-shadow: 0 9px 20px rgba(79,70,229,.3); }
.planner-copy-url {
  border: 1px solid #c7c9f7;
  border-radius: 10px;
  padding: 8px 12px;
  background: var(--surface);
  color: var(--primary-dark);
  font-weight: 700;
}
.planner-copy-url.copy-confirmed,
#public-copy-url.copy-confirmed {
  border-color: #22c55e;
  background: #dcfce7;
  color: #166534;
  box-shadow: 0 0 0 3px rgba(34,197,94,.14);
}
.planner-meta {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fafbfe;
}
.planner-meta label { margin: 0; min-width: 220px; }
.planner-meta input { margin: 5px 0 0; }
.planner-range { color: var(--muted); padding-bottom: 9px; }
.lesson-builder {
  margin: 14px 0;
  padding: 13px;
  border: 1px solid #c7c9f7;
  border-radius: 13px;
  background: var(--primary-soft);
}
.lesson-builder-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.lesson-builder-head span { color: var(--muted); font-size: 12px; }
.lesson-number-help {
  margin-top: 10px;
  padding: 10px 12px;
  border-left: 4px solid var(--primary);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  line-height: 1.55;
}
.lesson-start-fields {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.lesson-start-fields label { margin: 0; width: 125px; font-size: 11px; }
.lesson-start-fields input { margin: 4px 0 0; padding: 8px; }
.lesson-config-locked label { opacity: .58; }
.lesson-palette { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 12px; }
.lesson-token {
  min-width: 58px;
  border: 2px solid transparent;
  color: #111827;
  font-weight: 900;
  cursor: grab;
  box-shadow: 0 4px 12px rgba(15,23,42,.1);
}
.lesson-token:active { cursor: grabbing; }
.lesson-token.selected { border-color: #111827; transform: translateY(-2px); }
.lesson-s { background: #38bdf8; }
.lesson-w { background: #fbbf24; }
.lesson-lr { background: #86d451; }
.lesson-mt { background: #f9a8d4; }
.lesson-ft { background: #c4b5fd; }
.lesson-review { min-width: 82px; background: #fda4af; }
.planner-help { color: var(--muted); font-size: 12px; }
.week-planner { table-layout: auto; min-width: max-content; }
.week-planner th { min-width: 68px; }
.planner-session-label {
  display: inline-block;
  min-width: 48px;
  padding: 4px 3px;
  text-align: center;
  font-weight: 800;
  white-space: nowrap;
}
.week-slot {
  min-width: 68px;
  min-height: 72px;
  height: 72px;
  position: relative;
  cursor: pointer;
  user-select: none;
  font-weight: 900;
  font-size: 14px;
  transition: transform .12s ease, box-shadow .12s ease;
}
.week-slot:hover { transform: translateY(-1px); box-shadow: inset 0 0 0 2px var(--primary); }
.week-slot.current-slot { background: rgba(253, 253, 10) !important; color: #3f3f00 !important; }
.week-slot.has-lesson { font-size: 16px; letter-spacing: .02em; }
.slot-lesson { display: block; font-weight: 900; }
.slot-edit-btn {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 21px;
  height: 21px;
  padding: 0;
  border: 1px solid rgba(63,63,0,.25);
  border-radius: 6px;
  background: rgba(255,255,255,.76);
  color: #555500;
  font-size: 11px;
  line-height: 1;
  opacity: .45;
}
.week-slot:hover .slot-edit-btn { opacity: 1; }
.slot-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 5px;
  font-size: 9px;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: 0;
  white-space: normal;
}
.slot-location { color: #713f12; font-weight: 800; }
.slot-note {
  max-width: 105px;
  margin: auto;
  color: #52525b;
  overflow-wrap: anywhere;
}
.mini-dialog textarea {
  width: 100%;
  margin-top: 5px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  resize: vertical;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.public-schedule-card { max-width: 1500px; margin: 0 auto; }
.public-schedule-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.public-schedule-title h2 { margin: 0; font-size: 24px; }
.public-schedule-title p { margin: 4px 0 0; color: var(--muted); }
.public-week-slot { cursor: default; }
.public-week-slot:hover { transform: none; box-shadow: none; }
.public-readonly-note { margin-top: 14px; text-align: right; }
.planner-save-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-top: 15px;
}
.planner-save-row .msg { margin: 0; }
body.dark .schedule-sector-head,
body.dark .planner-meta { background: #20242f; }
body.dark .schedule-class-link { background: #1a1d27; }
body.dark .lesson-builder { background: #20213a; border-color: #3d4361; }

@media (max-width: 760px) {
  .planner-week-actions { width: 100%; margin-left: 0; flex-wrap: wrap; }
  .planner-week-actions label { flex: 1; }
  .planner-week-actions select { width: 100%; min-width: 0; }
  .schedule-sector-classes { grid-template-columns: 1fr; }
  .planner-save-row { align-items: stretch; flex-direction: column; }
}

.bulk-sessions-panel {
  margin: 14px 0 18px;
  max-width: none;
}
.trash-section-title {
  margin: 18px 0 8px;
  font-size: 16px;
  color: var(--primary-dark);
}
.deleted-submission-item span:first-child {
  line-height: 1.45;
}


.schedule-overview-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 18px;
}
.overview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.overview-head h3, .schedule-directory-head h3 { margin: 0 0 4px; }
.overview-actions { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; }
.overview-actions label { margin: 0; font-weight: 700; color: var(--muted); font-size: 12px; }
.overview-actions input { min-width: 150px; }
.overview-actions button {
  border: none; border-radius: 10px; padding: 10px 14px; font-weight: 800;
  background: var(--primary); color: #fff; cursor: pointer;
}
.overview-grid { table-layout: fixed; min-width: 1180px; }
.overview-grid th, .overview-grid td { padding: 5px 7px; min-width: 54px; height: 28px; }
.overview-grid thead th { background: #fdeaa6; color: #111827; font-weight: 900; }
.overview-grid .overview-room { background: #fb923c; color: #111827; }
.overview-grid .overview-corner { width: 130px; background: #fef08a; vertical-align: top; }
.overview-corner label { display: grid; gap: 5px; font-size: 12px; text-align: left; }
.overview-corner input { width: 110px; padding: 6px; border: 1px solid #d1d5db; border-radius: 6px; }
.overview-corner small { display: block; margin-top: 6px; color: #374151; }
.overview-session, .overview-ca { background: #22d3ee !important; color: #064e5f !important; font-weight: 900; }
.overview-row-label { background: #ffffff !important; color: #111827 !important; font-size: 12px; white-space: nowrap; }
.overview-gio { background: #ffedd5; }
.overview-lop { background: #dcfce7; color: #166534; font-weight: 900; }
.overview-ky-nang { background: #fef3c7; }
.overview-ghi-chu { background: #ffffff; }
.overview-cell[contenteditable="true"] { outline: 2px solid transparent; cursor: text; }
.overview-cell[contenteditable="true"]:focus { outline-color: var(--primary); background: #eef2ff !important; }
.schedule-directory-head { margin: 4px 0 12px; }
body.dark .system-nav-group, body.dark .schedule-overview-card { background: var(--surface); border-color: #30364a; }
body.dark .overview-grid .overview-row-label { background: #111827 !important; color: #e5e7eb !important; }
body.dark .overview-ghi-chu { background: #111827; }


/* ---- Owner schedule overview v2 ---- */
.overview-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  gap: 14px;
  align-items: start;
}
.overview-table-wrap { padding-bottom: 8px; }
.overview-side { display: grid; gap: 12px; }
.overview-mini-box {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  min-height: 150px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.45);
}
.overview-note-box {
  aspect-ratio: 1 / .82;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.overview-note-box label { display: grid; gap: 7px; font-size: 12px; font-weight: 900; color: #111827; }
.overview-note-box input:not(.mini-color) {
  width: 100%; border: 1px solid rgba(17,24,39,.18); border-radius: 9px;
  padding: 8px; font-weight: 800; background: rgba(255,255,255,.78);
}
.overview-note-box b { color: #111827; font-size: 18px; }
.mini-color { width: 36px; height: 28px; padding: 0; border: none; background: transparent; }
.overview-legend-box { background: #f8fafc; }
.legend-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.legend-head button {
  width: 28px; height: 28px; border-radius: 9px; border: none;
  background: var(--primary); color: #fff; font-size: 18px; font-weight: 900; cursor: pointer;
}
.legend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.legend-item {
  display: grid; grid-template-columns: 42px 1fr 26px;
  gap: 5px; align-items: center;
  border: 1px solid rgba(17,24,39,.14); border-radius: 10px; padding: 6px;
}
.legend-item input { min-width: 0; border: none; border-radius: 6px; padding: 5px; background: rgba(255,255,255,.78); font-size: 12px; }
.legend-item .legend-code { font-weight: 900; text-align: center; }
.legend-item .legend-color { width: 24px; height: 24px; padding: 0; background: transparent; }
.overview-color-picker { display: flex; align-items: center; gap: 7px; }
.overview-color-picker input { width: 38px; min-width: 38px; height: 34px; padding: 0; }
.overview-selected-cell { box-shadow: inset 0 0 0 3px #2563eb !important; }
.overview-grid .overview-room { background: #fb923c; color: #111827; }
.overview-grid .overview-lop { background: #22c55e; color: #052e16; font-weight: 900; }
.overview-grid .overview-ky-nang { background: #fef3c7; font-weight: 800; }
@media (max-width: 980px) {
  .overview-layout { grid-template-columns: 1fr; }
  .overview-side { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
}
body.dark .overview-legend-box { background: #111827; }
body.dark .legend-item input, body.dark .overview-note-box input:not(.mini-color) { background: rgba(255,255,255,.85); color: #111827; }


/* ---- Owner schedule overview v3: compact side boxes + bulk edit panel ---- */
.overview-layout {
  grid-template-columns: minmax(0, 1fr) 156px;
  gap: 10px;
}
.overview-table-wrap { width: 100%; }
.overview-grid {
  table-layout: auto;
  width: max-content;
  min-width: 100%;
}
.overview-grid th,
.overview-grid td {
  min-width: 34px;
  width: auto;
  max-width: none;
  padding: 4px 6px;
  height: 24px;
  white-space: nowrap;
  vertical-align: middle;
}
.overview-grid td.overview-cell {
  background: #ffffff;
  color: #111827;
  font-weight: 700;
}
.overview-grid .overview-gio {
  background: #ffedd5 !important;
  color: #111827;
}
.overview-grid .overview-lop.has-value {
  background: #22c55e;
  color: #052e16;
  font-weight: 900;
}
.overview-grid .overview-ky-nang.has-value {
  background: #fef3c7;
  color: #111827;
  font-weight: 900;
}
.overview-grid .overview-ghi-chu.has-value {
  background: #ffffff;
  color: #111827;
}
.overview-side {
  align-content: start;
  gap: 8px;
}
.overview-mini-box {
  min-height: 0;
  padding: 8px;
  border-radius: 12px;
}
.overview-note-box {
  aspect-ratio: auto;
  min-height: 104px;
  max-height: 128px;
  justify-content: center;
  gap: 6px;
}
.overview-note-box label {
  gap: 4px;
  font-size: 11px;
}
.overview-note-box input:not(.mini-color) {
  padding: 5px 6px;
  font-size: 12px;
}
.overview-note-box b {
  font-size: 13px;
  line-height: 1.2;
}
.overview-legend-box {
  padding: 8px;
}
.legend-head { margin-bottom: 6px; }
.legend-table {
  display: grid;
  gap: 4px;
}
.legend-header,
.legend-item {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 4px;
  align-items: stretch;
}
.legend-header span {
  font-size: 10px;
  font-weight: 900;
  color: var(--muted);
}
.legend-item {
  border: 1px solid rgba(17,24,39,.14);
  border-radius: 8px;
  padding: 4px;
}
.legend-item input {
  width: 100%;
  min-width: 0;
  border: none;
  border-radius: 5px;
  padding: 4px;
  background: rgba(255,255,255,.78);
  color: inherit;
  font-size: 11px;
}
.legend-item .legend-code {
  font-weight: 900;
  text-align: center;
}
.overview-edit-panel {
  position: sticky;
  top: 8px;
  z-index: 20;
  display: grid;
  gap: 9px;
  max-width: 680px;
  margin: 0 0 12px auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.overview-edit-panel.hidden { display: none; }
.overview-edit-panel-head,
.overview-panel-row,
.overview-panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.overview-edit-panel-head { justify-content: space-between; }
.overview-edit-panel label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  font-weight: 900;
  color: var(--muted);
}
.overview-edit-panel input[type="text"],
.overview-edit-panel input:not([type]) {
  min-width: 220px;
}
.overview-edit-panel input {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 7px 9px;
}
.overview-edit-panel input[type="color"] {
  width: 44px;
  min-width: 44px;
  height: 34px;
  padding: 2px;
}
.overview-palette {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.overview-palette button,
.overview-panel-actions button {
  border: 1px solid rgba(17,24,39,.14);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}
.overview-panel-actions button:first-child {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
}
.overview-panel-actions button:last-child {
  background: #f8fafc;
  color: #111827;
}
.overview-selected-cell {
  box-shadow: inset 0 0 0 3px #2563eb, 0 0 0 2px rgba(37,99,235,.18) !important;
}
.overview-editing .overview-cell,
.overview-editing .overview-selectable-box {
  cursor: pointer;
}
body.dark .overview-grid td.overview-cell { background: #111827; color: #e5e7eb; }
body.dark .overview-grid .overview-gio { background: #7c2d12 !important; color: #ffedd5; }
body.dark .overview-grid .overview-lop.has-value { background: #16a34a; color: #052e16; }
body.dark .overview-grid .overview-ky-nang.has-value { background: #a16207; color: #111827; }
body.dark .overview-edit-panel { background: var(--surface); }
@media (max-width: 980px) {
  .overview-layout { grid-template-columns: 1fr; }
  .overview-side { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}


/* ---- Owner overview v4: weeks, full-cell customization, CS2 marker ---- */
.overview-body.hidden { display: none; }
.overview-actions select {
  min-width: 140px;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
}
.overview-actions #overview-new-week,
.overview-actions #overview-toggle {
  background: #eef2ff;
  color: #1d4ed8;
  border: 1px solid #c7d2fe;
}
.overview-grid .overview-room-cs2,
.overview-grid .overview-room-col-cs2 {
  background: #fdfd0a !important;
  color: #111827 !important;
}
.overview-grid .overview-room-col-cs2.overview-lop.has-value {
  background: #22c55e !important;
  color: #052e16 !important;
}
.overview-grid .overview-room-col-cs2.overview-ky-nang.has-value {
  background: #fef3c7 !important;
  color: #111827 !important;
}
.overview-grid .overview-header-cell,
.overview-grid .overview-day-header,
.overview-grid .overview-room,
.overview-grid .overview-session,
.overview-grid .overview-ca,
.overview-grid .overview-row-label {
  user-select: none;
}
.overview-edit-panel input#overview-edit-width,
.overview-edit-panel input#overview-edit-height {
  min-width: 90px;
  width: 90px;
}
.overview-collapsed .overview-head { margin-bottom: 0; }
.overview-collapsed .overview-edit-panel { display: none; }
body.dark .overview-actions select { background: #111827; color: #e5e7eb; border-color: #30364a; }
body.dark .overview-actions #overview-new-week,
body.dark .overview-actions #overview-toggle { background: #172554; color: #bfdbfe; border-color: #1d4ed8; }


/* ---- Owner overview v5: drag resize rows/columns ---- */
.overview-editing .overview-cell {
  position: relative;
  overflow: visible;
}
.overview-col-resizer,
.overview-row-resizer {
  position: absolute;
  z-index: 8;
  display: block;
  opacity: 0;
  transition: opacity .12s ease, background .12s ease;
}
.overview-col-resizer {
  top: 0;
  right: -3px;
  width: 7px;
  height: 100%;
  cursor: col-resize;
}
.overview-row-resizer {
  left: 0;
  bottom: -3px;
  width: 100%;
  height: 7px;
  cursor: row-resize;
}
.overview-editing .overview-cell:hover > .overview-col-resizer,
.overview-editing .overview-cell:hover > .overview-row-resizer,
.overview-editing .overview-selected-cell > .overview-col-resizer,
.overview-editing .overview-selected-cell > .overview-row-resizer {
  opacity: 1;
}
.overview-editing .overview-cell:hover > .overview-col-resizer,
.overview-editing .overview-selected-cell > .overview-col-resizer {
  background: rgba(37, 99, 235, .35);
}
.overview-editing .overview-cell:hover > .overview-row-resizer,
.overview-editing .overview-selected-cell > .overview-row-resizer {
  background: rgba(37, 99, 235, .25);
}
.overview-day-header { white-space: nowrap; }


/* ---- Floating edit panel shared by overview + homeroom ---- */
.overview-edit-panel.cell-panel-floating,
.overview-edit-panel.cell-panel-docked,
.overview-edit-panel.overview-panel-docked,
.overview-edit-panel.homeroom-panel-docked {
  z-index: 1000;
}
.overview-edit-panel.cell-panel-floating {
  position: absolute;
  max-width: min(420px, calc(100vw - 24px));
  margin: 0;
}
.overview-edit-panel.cell-panel-docked,
.overview-edit-panel.overview-panel-docked,
.overview-edit-panel.homeroom-panel-docked {
  position: sticky;
  top: 8px;
  margin: 0 0 12px auto;
}

/* ---- Homeroom record book ---- */
.homeroom-root { display: grid; gap: 14px; }
.homeroom-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #f8fafc;
}
.homeroom-toolbar label {
  display: grid;
  gap: 5px;
  font-size: 12px;
  font-weight: 900;
  color: var(--muted);
}
.homeroom-toolbar select {
  min-width: 220px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
}
.homeroom-record-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.homeroom-record-tab {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 13px;
  background: var(--surface);
  color: var(--text);
  font-weight: 900;
  cursor: pointer;
}
.homeroom-record-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.homeroom-record { display: grid; gap: 12px; }
.homeroom-record-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.homeroom-record-head h3 { margin: 0 0 4px; }
.homeroom-record-head button {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--primary);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}
.homeroom-grid {
  table-layout: auto;
  width: max-content;
  min-width: 100%;
}
.homeroom-grid th,
.homeroom-grid td {
  min-width: 46px;
  height: 28px;
  padding: 5px 7px;
  white-space: nowrap;
  text-align: center;
  vertical-align: middle;
  position: relative;
}
.homeroom-grid tbody td:nth-child(3),
.homeroom-grid tbody th:nth-child(3) {
  text-align: left;
  min-width: 170px;
}
.homeroom-cell { cursor: default; }
.homeroom-editing .homeroom-cell { cursor: pointer; overflow: visible; }
.homeroom-selected-cell {
  box-shadow: inset 0 0 0 3px #2563eb, 0 0 0 2px rgba(37,99,235,.18) !important;
}
body.dark .homeroom-toolbar { background: #111827; border-color: #30364a; }
body.dark .homeroom-toolbar select,
body.dark .homeroom-record-tab { background: #1a1d27; border-color: #30364a; color: #e5e7eb; }


/* ---- Homeroom spreadsheet axes + sticky A/B columns ---- */
.homeroom-grid thead th {
  position: sticky;
  top: 0;
  z-index: 13;
}
.homeroom-grid .homeroom-corner,
.homeroom-grid .homeroom-row-header {
  position: sticky;
  left: 0;
  z-index: 12;
  width: 42px;
  min-width: 42px;
  max-width: 42px;
  background-clip: padding-box;
}
.homeroom-grid .homeroom-corner { top: 0; z-index: 16; }
.homeroom-grid tbody th:nth-child(2),
.homeroom-grid tbody td:nth-child(2) {
  position: sticky;
  left: 42px;
  z-index: 9;
  min-width: 46px;
  background-clip: padding-box;
}
.homeroom-grid tbody th:nth-child(3),
.homeroom-grid tbody td:nth-child(3) {
  position: sticky;
  left: 88px;
  z-index: 8;
  background-clip: padding-box;
}
.homeroom-grid tbody td:nth-child(2):not([style*="background"]),
.homeroom-grid tbody td:nth-child(3):not([style*="background"]) {
  background: #ffffff;
}


/* ---- Direct cell editing + auto wrap ---- */
.overview-grid .overview-cell,
.homeroom-grid th,
.homeroom-grid td {
  white-space: normal !important;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.25;
}
.overview-editing .overview-cell[contenteditable="true"],
.homeroom-editing .homeroom-cell[contenteditable="true"] {
  cursor: text;
  caret-color: var(--primary);
}
.overview-editing .overview-cell[contenteditable="true"]:focus,
.homeroom-editing .homeroom-cell[contenteditable="true"]:focus {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}
.overview-col-resizer,
.overview-row-resizer {
  user-select: none;
}


/* ---- Homeroom record actions + Excel-like shortcuts ---- */
.homeroom-record-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.homeroom-record-actions button {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 900;
  cursor: pointer;
}
#homeroom-add-lesson {
  background: #eef2ff;
  color: #1d4ed8;
  border: 1px solid #c7d2fe;
}
body.dark #homeroom-add-lesson {
  background: #172554;
  color: #bfdbfe;
  border-color: #1d4ed8;
}

.homeroom-record-actions .btn-export {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}
.homeroom-record-actions .btn-download-excel {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}
.homeroom-record-actions .btn-export-image {
  background: #fff7ed;
  color: #c2410c;
  border-color: #fed7aa;
}
.homeroom-record-actions .homeroom-danger-action {
  background: #fff1f2;
  color: #be123c;
  border: 1px solid #fecdd3;
}
.homeroom-record-actions button:hover { filter: brightness(.96); transform: translateY(-1px); }
.homeroom-record-actions button:disabled { opacity: .65; cursor: wait; transform: none; }

.homeroom-export-dialog { width: min(560px, calc(100vw - 28px)); }
.homeroom-export-select-actions {
  display: flex;
  gap: 8px;
  margin: 10px 0;
}
.homeroom-export-select-actions button {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 7px 10px;
  background: var(--surface);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}
.homeroom-export-lessons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 8px;
  max-height: min(44vh, 360px);
  overflow: auto;
  padding: 2px;
}
.homeroom-export-lessons label {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.homeroom-export-lessons label:has(input:checked) {
  border-color: #60a5fa;
  background: #eff6ff;
  box-shadow: inset 0 0 0 1px #93c5fd;
}
.homeroom-export-lessons input { width: 17px; height: 17px; accent-color: #2563eb; }
.homeroom-export-lessons span { font-weight: 900; }
.homeroom-export-lessons small { color: var(--muted); }
body.dark .homeroom-record-actions .btn-export { background: #052e2b; color: #6ee7b7; border-color: #047857; }
body.dark .homeroom-record-actions .btn-download-excel { background: #172554; color: #bfdbfe; border-color: #1d4ed8; }
body.dark .homeroom-record-actions .btn-export-image { background: #431407; color: #fdba74; border-color: #c2410c; }
body.dark .homeroom-record-actions .homeroom-danger-action { background: #4c0519; color: #fda4af; border-color: #be123c; }
body.dark .homeroom-export-lessons label:has(input:checked) { background: #172554; border-color: #3b82f6; }

/* ---- Excel-like homeroom sheet ---- */
.homeroom-formula-bar {
  display: grid;
  grid-template-columns: 76px 38px minmax(220px, 1fr);
  align-items: stretch;
  min-height: 36px;
  border: 1px solid #b8b8b8;
  background: #fff;
  color: #1f2937;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.homeroom-edit-panel.homeroom-panel-docked {
  position: static !important;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  width: 100%;
  max-width: none;
  margin: 0 !important;
  padding: 8px 10px;
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
  overflow: hidden;
}
.homeroom-edit-panel.homeroom-panel-docked > label,
.homeroom-edit-panel.homeroom-panel-docked > small { display: none; }
.homeroom-edit-panel.homeroom-panel-docked .overview-edit-panel-head {
  min-width: 92px;
  display: grid;
  gap: 2px;
}
.homeroom-edit-panel.homeroom-panel-docked .overview-panel-row,
.homeroom-edit-panel.homeroom-panel-docked .overview-palette,
.homeroom-edit-panel.homeroom-panel-docked .overview-panel-actions { flex-wrap: nowrap; }
.homeroom-edit-panel.homeroom-panel-docked .overview-panel-row { flex: 0 1 auto; }
.homeroom-edit-panel.homeroom-panel-docked input#homeroom-edit-width,
.homeroom-edit-panel.homeroom-panel-docked input#homeroom-edit-height {
  width: 84px;
  min-width: 84px;
}
.homeroom-edit-panel.homeroom-panel-docked .overview-palette {
  flex: 1 1 360px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.homeroom-edit-panel.homeroom-panel-docked .overview-palette button { white-space: nowrap; }
.homeroom-edit-panel.homeroom-panel-docked .overview-panel-actions { margin-left: auto; }
.homeroom-formula-bar output,
.homeroom-formula-bar .homeroom-fx {
  display: grid;
  place-items: center;
  border-right: 1px solid #d1d5db;
  font: 600 13px Arial, sans-serif;
}
.homeroom-formula-bar output { background: #f8fafc; }
.homeroom-formula-bar .homeroom-fx { color: #16834b; font-style: italic; font-weight: 800; }
.homeroom-formula-bar input {
  min-width: 0;
  border: 0;
  border-radius: 0;
  padding: 7px 10px;
  background: #fff;
  color: #111827;
  font: 13px Arial, sans-serif;
  outline: none;
}
.homeroom-formula-bar input:focus { box-shadow: inset 0 0 0 2px #21a366; }
.homeroom-sheet-scroll {
  border: 1px solid #aeb4bd;
  background: #fff;
  max-height: min(72vh, 760px);
  position: relative;
}
.homeroom-grid { font-family: Arial, sans-serif; border-collapse: separate; border-spacing: 0; }
.homeroom-grid .homeroom-axis-row th,
.homeroom-grid .homeroom-row-header {
  height: 24px;
  padding: 2px 6px;
  border: 0;
  border-right: 1px solid #b8bec7;
  border-bottom: 1px solid #b8bec7;
  background: #e9ecef !important;
  color: #374151 !important;
  text-align: center !important;
  font: 600 12px Arial, sans-serif;
  user-select: none;
  cursor: default;
}
.homeroom-grid .homeroom-col-header { min-width: 46px; }
.homeroom-grid .homeroom-axis-row .homeroom-col-header:nth-child(2) {
  left: 42px;
  z-index: 15;
}
.homeroom-grid .homeroom-axis-row .homeroom-col-header:nth-child(3) {
  left: 88px;
  z-index: 14;
}
.homeroom-grid .homeroom-axis-active,
.homeroom-grid .homeroom-col-header:hover,
.homeroom-grid .homeroom-row-header:hover,
.homeroom-grid .homeroom-corner:hover {
  background: #d7e9df !important;
  color: #107c41 !important;
}
.homeroom-grid .homeroom-cell {
  border: 0;
  border-right: 1px solid #c9cdd2;
  border-bottom: 1px solid #c9cdd2;
  outline: none;
}
.homeroom-editing .homeroom-cell:not(.homeroom-cell-editing) { caret-color: transparent; cursor: cell; }
.homeroom-editing .homeroom-cell-editing {
  cursor: text;
  caret-color: #111827;
  box-shadow: inset 0 0 0 2px #107c41 !important;
}
.homeroom-selected-cell {
  box-shadow: inset 0 0 0 2px #107c41 !important;
  position: relative;
  z-index: 6;
}
.homeroom-context-menu {
  position: fixed;
  z-index: 5000;
  width: 230px;
  padding: 6px;
  border: 1px solid #c7ccd1;
  border-radius: 5px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(15,23,42,.22);
}
.homeroom-context-menu button {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 3px;
  padding: 9px 10px;
  background: transparent;
  color: #1f2937;
  text-align: left;
  font: 13px Arial, sans-serif;
  cursor: pointer;
}
.homeroom-context-menu button:hover { background: #e8f3ed; color: #107c41; }
.homeroom-context-menu span { display: block; height: 1px; margin: 5px 3px; background: #e5e7eb; }
body.dark .homeroom-formula-bar,
body.dark .homeroom-formula-bar input,
body.dark .homeroom-context-menu { background: #171a22; color: #e5e7eb; border-color: #3b4252; }
body.dark .homeroom-formula-bar output { background: #111827; }
body.dark .homeroom-formula-bar input { color: #e5e7eb; }
body.dark .homeroom-grid .homeroom-axis-row th,
body.dark .homeroom-grid .homeroom-row-header { background: #252a34 !important; color: #d1d5db !important; border-color: #454b58; }
body.dark .homeroom-context-menu button { color: #e5e7eb; }
body.dark .homeroom-context-menu button:hover { background: #123528; color: #6ee7b7; }
@media (max-width: 680px) {
  .homeroom-formula-bar { grid-template-columns: 58px 32px minmax(150px, 1fr); }
  .homeroom-record-actions { gap: 6px; }
  .homeroom-record-actions button { padding: 8px 10px; font-size: 12px; }
}

/* ---- Student code chip + banner ---- */
.student-code-chip {
  display: inline-block;
  padding: 1px 8px;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font: 700 11px/1.7 ui-monospace, 'Cascadia Mono', Consolas, monospace;
  letter-spacing: .06em;
  white-space: nowrap;
}
body.dark .student-code-chip { background: #23264a; border-color: #40449a; color: #b3b8ff; }

.student-code-banner {
  margin: 0 0 14px;
  padding: 10px 14px;
  border: 1px dashed var(--primary);
  border-radius: 12px;
  background: var(--primary-soft);
  font-size: 13px;
}
.student-code-banner .student-code-chip { font-size: 13px; padding: 2px 10px; margin: 0 2px; }
.student-code-banner a { color: var(--primary-dark); font-weight: 600; }
body.dark .student-code-banner { background: #191c33; border-color: #4649b0; color: #d5d8f5; }
body.dark .student-code-banner a { color: #b3b8ff; }

/* ---- Hồ sơ học sinh tab ---- */
.profiles-head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.profiles-search-row { display: flex; gap: 8px; margin: 10px 0 4px; }
.profiles-search-row input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.profiles-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  margin-top: 12px;
  align-items: start;
}
.profiles-results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 65vh; overflow: auto; }
.profile-result {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color .15s, box-shadow .15s;
}
.profile-result:hover { border-color: var(--primary); }
.profile-result.active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.profile-result-name { font-weight: 600; }
.profile-result-meta { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; }
.profile-result-classes { color: var(--muted); font-size: 12px; }
.profile-detail {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  background: var(--surface);
  min-height: 220px;
}
.profile-student-head { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; align-items: flex-start; }
.profile-student-head h3 { margin: 0 0 4px; font-size: 20px; }
.profile-code-box { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.profile-code-label { font-size: 12px; color: var(--muted); }
.profile-code-value { font-size: 15px; padding: 4px 12px; }
.profile-classes-line { margin: 10px 0 2px; font-size: 13px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.profile-class-chip { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; font-size: 12px; }
.profile-section { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.profile-section h4 { margin: 0 0 10px; }
.profile-field-row { display: grid; grid-template-columns: 210px 1fr; gap: 10px; align-items: center; margin-bottom: 8px; }
.profile-field-label { font-size: 13px; font-weight: 500; }
.profile-parent-flag { color: var(--success); font-weight: 700; margin-left: 6px; font-size: 11px; }
.profile-field-input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  width: 100%;
}
.profile-save-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.profile-timeline { list-style: none; margin: 0 0 0 6px; padding: 0 0 0 18px; border-left: 2px solid var(--primary-soft); display: flex; flex-direction: column; gap: 10px; }
.profile-timeline-item { position: relative; font-size: 13px; }
.profile-timeline-item::before { content: ''; position: absolute; left: -24px; top: 4px; width: 9px; height: 9px; border-radius: 50%; background: var(--primary); }
.profile-timeline-item.event-completed::before { background: var(--success); }
.profile-timeline-item.event-removed::before,
.profile-timeline-item.event-transferred::before { background: var(--warn); }
.profile-timeline-date { color: var(--muted); margin-right: 8px; font-size: 12px; }
.profile-timeline-label small { color: var(--muted); }
.field-manage-row { display: grid; grid-template-columns: 1fr 96px 1fr auto auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.field-manage-row input[type="text"],
.field-manage-row select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  min-width: 0;
}
.fm-visible { display: flex; align-items: center; gap: 5px; font-size: 12px; white-space: nowrap; }
.fm-delete { border: 0; background: transparent; color: var(--danger); font-size: 18px; cursor: pointer; padding: 2px 6px; }
@media (max-width: 860px) {
  .profiles-layout { grid-template-columns: 1fr; }
  .profiles-results { max-height: 300px; }
}
@media (max-width: 640px) {
  .profile-field-row { grid-template-columns: 1fr; gap: 4px; }
  .field-manage-row { grid-template-columns: 1fr 96px; }
}
body.dark .profile-result,
body.dark .profile-detail,
body.dark .profile-field-input,
body.dark .profiles-search-row input,
body.dark .field-manage-row input[type="text"],
body.dark .field-manage-row select { background: #171a22; border-color: #3b4252; color: #e5e7eb; }
body.dark .profile-result.active { box-shadow: 0 0 0 2px #23264a; }
body.dark .profile-class-chip { background: #23264a; color: #b3b8ff; }
body.dark .profile-timeline { border-left-color: #2c3050; }

/* ---- Olympus Portal (parent page, cyber theme) ---- */
body.portal-page {
  /* Đè bảng màu chung để mọi thành phần dùng lại (bảng, checkbox, msg...)
     tự khoác tông cyber mà không phải style lại từng cái. */
  --bg: #06070f;
  --surface: rgba(15,18,38,.78);
  --border: rgba(99,102,241,.3);
  --text: #dfe3ff;
  --muted: #c3c9f0;
  --primary: #818cf8;
  --primary-dark: #a5b4fc;
  --primary-soft: rgba(99,102,241,.18);
  --success: #34d399;
  --danger: #fb7185;
  --warn: #fbbf24;
  background: #06070f;
  color: #dfe3ff;
  font-size: 15px;
}
body.portal-page::before { opacity: .05; filter: invert(1) brightness(1.4); }
.portal-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(600px 420px at 12% -5%, rgba(99,102,241,.28), transparent 60%),
    radial-gradient(720px 480px at 105% 15%, rgba(34,211,238,.16), transparent 62%),
    radial-gradient(620px 620px at 50% 115%, rgba(139,92,246,.18), transparent 60%);
}
.portal-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(99,102,241,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(99,102,241,.06) 1px, transparent 1px);
  background-size: 42px 42px;
  -webkit-mask-image: radial-gradient(70% 60% at 50% 20%, #000 0%, transparent 100%);
  mask-image: radial-gradient(70% 60% at 50% 20%, #000 0%, transparent 100%);
}
.portal-shell {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 0 auto;
  padding: 44px 18px 30px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
body.portal-page header.portal-hero {
  background: transparent;
  border-bottom: 0;
  padding: 0;
  position: static;
  top: auto;
  z-index: auto;
}
.portal-hero { text-align: center; margin-bottom: 6px; }
.portal-logo {
  width: 74px;
  height: 74px;
  margin: 0 auto 12px;
  background: url('assets/olympus-corner.png') center/contain no-repeat;
  filter: drop-shadow(0 0 18px rgba(99,102,241,.55));
}
.portal-title { margin: 0; font-size: clamp(26px, 6vw, 38px); font-weight: 800; letter-spacing: .18em; color: #f2f4ff; }
.portal-title span {
  background: linear-gradient(90deg, #818cf8, #22d3ee);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.portal-sub { margin: 6px 0 0; color: #c3c9f0; letter-spacing: .08em; font-size: 13px; text-transform: uppercase; }
.portal-card {
  background: rgba(15,18,38,.78);
  border: 1px solid rgba(99,102,241,.32);
  border-radius: 18px;
  padding: 20px 22px;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: 0 0 0 1px rgba(6,8,20,.4), 0 18px 50px rgba(3,5,16,.55), inset 0 1px 0 rgba(148,163,255,.08);
}
.portal-label { display: block; font-size: 12px; letter-spacing: .22em; text-transform: uppercase; color: #c3c9f0; margin-bottom: 10px; }
.parent-code-row { display: flex; gap: 10px; }
#parent-code {
  flex: 1;
  min-width: 0;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid rgba(99,102,241,.45);
  background: rgba(5,7,18,.85);
  color: #eef0ff;
  font: 700 20px/1.2 ui-monospace, 'Cascadia Mono', Consolas, monospace;
  letter-spacing: .24em;
  text-transform: uppercase;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
#parent-code::placeholder { color: #8c95cb; letter-spacing: .16em; }
#parent-code:focus { border-color: #22d3ee; box-shadow: 0 0 0 3px rgba(34,211,238,.18), 0 0 24px rgba(34,211,238,.25); }
#btn-parent-lookup {
  padding: 0 22px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(120deg, #6366f1, #22d3ee);
  color: #04060f;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: .04em;
  cursor: pointer;
  transition: filter .2s, transform .1s;
}
#btn-parent-lookup:hover { filter: brightness(1.12); }
#btn-parent-lookup:active { transform: translateY(1px); }
#btn-parent-lookup:disabled { opacity: .6; cursor: wait; }
.portal-hint { margin: 12px 0 0; color: #aeb5e4; font-size: 13px; }
.portal-msg { margin: 10px 0 0; min-height: 18px; font-size: 13px; }
.portal-msg.err { color: #fb7185; }
.parent-result { display: flex; flex-direction: column; gap: 18px; }
.parent-student-card { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.parent-student-main h2 { margin: 0 0 6px; font-size: 26px; color: #f5f6ff; }
.parent-student-dob { margin: 0; color: #c3c9f0; font-size: 13px; }
.parent-student-code { text-align: right; display: flex; flex-direction: column; gap: 4px; }
.parent-student-code span { font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: #aeb5e4; }
.parent-student-code b {
  font: 800 24px/1 ui-monospace, 'Cascadia Mono', Consolas, monospace;
  letter-spacing: .16em;
  color: #7dd3fc;
  text-shadow: 0 0 18px rgba(34,211,238,.5);
}
.portal-section-title {
  margin: 0 0 14px;
  font-size: 13px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: #a5b4fc;
  display: flex;
  align-items: center;
  gap: 10px;
}
.portal-section-title::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, rgba(129,140,248,.5), transparent); }
.parent-profile-grid { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.parent-profile-item { border: 1px solid rgba(99,102,241,.25); border-radius: 12px; padding: 10px 14px; background: rgba(10,12,28,.65); }
.parent-profile-item dt { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: #aeb5e4; margin: 0 0 4px; }
.parent-profile-item dd { margin: 0; font-size: 17px; font-weight: 700; color: #e8ebff; }
.parent-class-block { border: 1px solid rgba(99,102,241,.22); border-radius: 14px; padding: 14px 16px; background: rgba(10,12,28,.5); margin-bottom: 12px; }
.parent-class-block:last-child { margin-bottom: 0; }
.parent-class-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.parent-class-head h4 { margin: 0; font-size: 18px; color: #c7d2fe; }
.parent-class-head span { font-size: 12px; color: #aeb5e4; }
.parent-slot-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.parent-slot-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(99,102,241,.1);
  border: 1px solid rgba(99,102,241,.18);
  font-size: 14px;
}
.parent-slot-day { font-weight: 700; color: #a5b4fc; min-width: 88px; }
.parent-slot-session { padding: 2px 10px; border-radius: 999px; background: rgba(34,211,238,.14); color: #67e8f9; font-weight: 700; font-size: 12px; }
.parent-slot-lesson { font-weight: 700; color: #f0f2ff; }
.parent-slot-location { color: #c3c9f0; font-size: 12px; }
.parent-slot-note { color: #fbbf24; font-size: 12px; }
.portal-empty { color: #aeb5e4; margin: 0; font-size: 14px; }
.parent-timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.parent-timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: linear-gradient(180deg, #6366f1, rgba(34,211,238,.6));
}
.parent-timeline-item { position: relative; padding: 0 0 18px 32px; }
.parent-timeline-item:last-child { padding-bottom: 0; }
.parent-timeline-dot {
  position: absolute;
  left: 0;
  top: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #10131f;
  border: 3px solid #6366f1;
}
.parent-timeline-item.status-done .parent-timeline-dot { border-color: #34d399; box-shadow: 0 0 12px rgba(52,211,153,.6); }
.parent-timeline-item.status-now .parent-timeline-dot { border-color: #22d3ee; animation: parentPulse 1.8s infinite; }
.parent-timeline-item.status-moved .parent-timeline-dot { border-color: #fbbf24; }
.parent-timeline-item.status-left .parent-timeline-dot { border-color: #64748b; }
.parent-timeline-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.parent-timeline-head b { font-size: 17px; color: #eef0ff; }
.parent-status-badge {
  padding: 2px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  background: rgba(99,102,241,.2);
  color: #a5b4fc;
}
.status-done .parent-status-badge { background: rgba(52,211,153,.16); color: #6ee7b7; }
.status-now .parent-status-badge { background: rgba(34,211,238,.16); color: #67e8f9; }
.status-moved .parent-status-badge { background: rgba(251,191,36,.15); color: #fcd34d; }
.status-left .parent-status-badge { background: rgba(100,116,139,.2); color: #94a3b8; }
.parent-timeline-dates { margin-top: 4px; color: #aeb5e4; font-size: 12px; }
.portal-footer {
  text-align: center;
  color: #9ba3d6;
  font-size: 12px;
  letter-spacing: .08em;
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin-top: 6px;
}
.portal-footer a { color: #818cf8; text-decoration: none; }
.portal-footer a:hover { text-decoration: underline; }
.portal-footer-dot { font-size: 7px; color: #5f6899; }
@keyframes parentPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(34,211,238,.45); }
  50% { box-shadow: 0 0 20px rgba(34,211,238,.9); }
}
@media (max-width: 560px) {
  .portal-shell { padding-top: 30px; }
  .portal-card { padding: 16px; }
  .parent-code-row { flex-direction: column; }
  #btn-parent-lookup { padding: 13px 22px; }
  .parent-student-card { flex-direction: column; align-items: flex-start; }
  .parent-student-code { text-align: left; }
}

/* ---- Olympus Portal (student page) ----
   Trang học sinh dùng chung khung portal-* với trang phụ huynh; khối này chỉ
   khoác tông cyber cho các thành phần dùng lại (checklist lớp, bảng tích buổi
   bận, bảng lịch tra cứu). Đặt sau khối dark mode để thắng về thứ tự. */
.portal-field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.portal-field { display: block; margin: 0; }
body.portal-page .portal-label { margin-bottom: 8px; }
body.portal-page .portal-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(99,102,241,.42);
  background: rgba(5,7,18,.85);
  color: #eef0ff;
  font-size: 15px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
body.portal-page .portal-input::placeholder { color: #8c95cb; }
body.portal-page .portal-input:focus {
  border-color: #22d3ee;
  box-shadow: 0 0 0 3px rgba(34,211,238,.18), 0 0 24px rgba(34,211,238,.2);
}
body.portal-page .portal-hint { margin-top: 14px; }

.portal-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
body.portal-page .portal-btn {
  padding: 13px 26px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(120deg, #6366f1, #22d3ee);
  color: #04060f;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: .03em;
  cursor: pointer;
  transition: filter .2s, transform .1s;
}
body.portal-page .portal-btn:hover { filter: brightness(1.12); }
body.portal-page .portal-btn:active { transform: translateY(1px); }
body.portal-page .portal-btn:disabled { opacity: .55; cursor: wait; }
body.portal-page .portal-btn.ghost {
  background: rgba(99,102,241,.12);
  border: 1px solid rgba(99,102,241,.42);
  color: #c7d2fe;
}
body.portal-page .portal-btn.ghost:hover { background: rgba(99,102,241,.22); }

/* Checklist lớp */
body.portal-page .class-check {
  background: rgba(10,12,28,.6);
  border-color: rgba(99,102,241,.25);
  border-radius: 12px;
  color: #dfe3ff;
  transition: background .2s, border-color .2s, box-shadow .2s;
}
body.portal-page .class-check:hover { background: rgba(99,102,241,.16); border-color: rgba(34,211,238,.45); }
body.portal-page .class-check input[type=checkbox] { accent-color: #22d3ee; }
body.portal-page .class-check:has(input:checked) {
  background: rgba(99,102,241,.22);
  border-color: rgba(34,211,238,.55);
  box-shadow: 0 0 0 1px rgba(34,211,238,.22), 0 0 18px rgba(34,211,238,.12);
}
body.portal-page .student-sector-title {
  background: rgba(99,102,241,.1);
  border-color: rgba(99,102,241,.25);
  color: #a5b4fc;
}
body.portal-page .student-sector-title:hover {
  background: rgba(99,102,241,.2);
  border-color: rgba(34,211,238,.45);
  color: #c7d2fe;
}
body.portal-page .placeholder { color: #aeb5e4; }

/* Bảng tích buổi bận + bảng lịch tra cứu */
body.portal-page .grid-wrap { margin: 0; }
body.portal-page table.grid th,
body.portal-page table.grid td,
body.portal-page table.schedule th,
body.portal-page table.schedule td { border-color: rgba(99,102,241,.22); }
body.portal-page table.grid th,
body.portal-page table.schedule thead th {
  background: rgba(99,102,241,.14);
  color: #c7d2fe;
}
body.portal-page table.grid tbody th { background: rgba(10,12,28,.55); color: #e8ebff; }
body.portal-page table.grid td { background: rgba(6,8,20,.3); }
body.portal-page table.grid input[type=checkbox] { accent-color: #22d3ee; }
body.portal-page table.schedule td { background: rgba(6,8,20,.3); }
body.portal-page table.schedule td.name { color: #e8ebff; }
body.portal-page tr.summary td { background: rgba(99,102,241,.12); color: #c7d2fe; }
body.portal-page .free { color: #5f6899; }

/* Kết quả tra cứu */
.portal-result-card:has(#lookup-result:empty) { display: none; }

/* ---- Trò chơi từ vựng ---- */
.vocab-game-card {
  overflow: hidden;
  position: relative;
  background:
    radial-gradient(circle at 92% 4%, rgba(34, 211, 238, .13), transparent 30%),
    radial-gradient(circle at 8% 92%, rgba(129, 140, 248, .12), transparent 32%),
    var(--card);
}
.vocab-eyebrow {
  display: block;
  margin-bottom: 6px;
  color: #0891b2;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .22em;
}
.vocab-stats {
  min-width: 82px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(99, 102, 241, .08);
  text-align: center;
}
.vocab-stats strong { display: block; color: var(--primary); font-size: 20px; }
.vocab-stats span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.vocab-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) minmax(170px, 1fr) minmax(190px, 1fr) auto;
  gap: 12px;
  margin: 18px 0;
  align-items: end;
}
.vocab-controls label,
.attendance-filters label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.vocab-controls select,
.attendance-filters select {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 34px 8px 11px;
  background: var(--card);
  color: var(--text);
}
.vocab-stage { display: grid; justify-items: center; gap: 16px; padding: 8px 0 4px; }
.vocab-flashcard {
  width: min(680px, 100%);
  min-height: 330px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 11px;
  padding: 34px;
  border: 1px solid rgba(99, 102, 241, .32);
  border-radius: 24px;
  background:
    linear-gradient(145deg, rgba(255,255,255,.96), rgba(238,242,255,.98));
  color: #111827;
  box-shadow: 0 22px 55px rgba(49, 46, 129, .13), inset 0 1px 0 #fff;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s, border-color .2s;
}
.vocab-flashcard:hover { transform: translateY(-2px); border-color: #22d3ee; box-shadow: 0 26px 65px rgba(8,145,178,.18); }
.vocab-flashcard.revealed { border-color: rgba(16,185,129,.55); }
.vocab-card-label {
  color: #6366f1;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .18em;
  text-transform: uppercase;
}
#vocab-prompt { max-width: 100%; font-size: clamp(30px, 5vw, 52px); line-height: 1.08; text-align: center; overflow-wrap: anywhere; }
.vocab-ipa { color: #64748b; font: 500 17px/1.5 Georgia, serif; }
.vocab-answer { max-width: 580px; color: #047857; font-size: 22px; font-weight: 800; text-align: center; }
.vocab-example { max-width: 590px; color: #475569; font-size: 14px; line-height: 1.55; text-align: center; }
.vocab-answer,
.vocab-example { opacity: 0; transform: translateY(5px); transition: opacity .18s, transform .18s; }
.vocab-flashcard.revealed .vocab-answer,
.vocab-flashcard.revealed .vocab-example { opacity: 1; transform: none; }
.vocab-flip-hint { margin-top: 8px; color: #94a3b8; font-size: 11px; }
.vocab-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; }
.vocab-owner-divider { width: 1px; height: 30px; background: var(--border); margin: 0 3px; }
.vocab-manage-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.vocab-manage-form label { display: flex; flex-direction: column; gap: 5px; }
.vocab-manage-wide { grid-column: 1 / -1; }
.vocab-known { border-color: rgba(16,185,129,.42); color: #047857; background: rgba(16,185,129,.09); }
.vocab-known.active { color: white; background: #10b981; }
body.dark .vocab-flashcard {
  border-color: rgba(129,140,248,.38);
  background: linear-gradient(145deg, rgba(23,28,58,.98), rgba(12,16,38,.99));
  color: #f8fafc;
  box-shadow: 0 25px 65px rgba(0,0,0,.36);
}
body.dark .vocab-ipa { color: #a5b4fc; }
body.dark .vocab-answer { color: #6ee7b7; }
body.dark .vocab-example { color: #cbd5e1; }

/* ---- Bảng công ---- */
.attendance-card { min-height: 420px; }
.attendance-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.attendance-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 220px)) 1fr;
  align-items: end;
  gap: 10px;
  margin: 16px 0;
}
.attendance-root { overflow: auto; border: 1px solid var(--border); border-radius: 14px; }
.attendance-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.attendance-table th,
.attendance-table td {
  min-width: 0;
  padding: 6px 7px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--card);
  white-space: nowrap;
}
.attendance-table th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: color-mix(in srgb, var(--primary-soft) 75%, var(--card));
  color: var(--text);
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.attendance-table tr:last-child td { border-bottom: 0; }
.attendance-table th:last-child,
.attendance-table td:last-child { border-right: 0; }
.attendance-table .attendance-class {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 68px;
  font-weight: 800;
  color: var(--primary);
}
.attendance-table th.attendance-class { z-index: 6; }
.attendance-table input,
.attendance-table select {
  width: auto;
  min-width: 0;
  max-width: 100%;
  min-height: 32px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 5px 7px;
  background: transparent;
  color: var(--text);
}
.attendance-table .attendance-date-input { width: 126px; }
.attendance-table .attendance-time-input,
.attendance-table input[type="time"] { width: 88px; }
.attendance-table .attendance-period-input { width: 58px; }
.attendance-table .attendance-teacher-select { width: 145px; }
.attendance-table select[data-field="status"] { width: 104px; }
.attendance-table input[data-field="note"] { width: 210px; }
.attendance-table .attendance-sync { min-width: 48px; }
.attendance-table input:focus,
.attendance-table select:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--bg);
  box-shadow: 0 0 0 2px var(--primary-soft);
}
.attendance-table .attendance-sync {
  text-align: center;
  font-weight: 800;
  background: rgba(16,185,129,.08);
  color: #047857;
}
.attendance-table .attendance-absent.has-absence {
  background: rgba(239,68,68,.1);
  color: #b91c1c;
}
.attendance-empty { padding: 44px 20px; text-align: center; color: var(--muted); }

/* ---- Chỉnh thông tin gốc của hồ sơ ---- */
.profile-identity-editor {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(150px, 210px) auto;
  gap: 9px;
  align-items: end;
  margin: 14px 0 2px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
}
.profile-identity-editor label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
.profile-identity-editor input { width: 100%; }
.slot-dialog-grid { display: grid; grid-template-columns: 1fr 1.3fr; gap: 10px; }
.slot-dialog-grid label { display: flex; flex-direction: column; gap: 5px; }
.slot-time { color: #0369a1; }
.slot-teacher { color: #6d28d9; }

@media (max-width: 820px) {
  .vocab-controls { grid-template-columns: 1fr 1fr; }
  .attendance-filters { grid-template-columns: 1fr 1fr; }
  .profile-identity-editor { grid-template-columns: 1fr; }
  .vocab-manage-form,
  .slot-dialog-grid { grid-template-columns: 1fr; }
  .vocab-manage-wide { grid-column: auto; }
}
@media (max-width: 520px) {
  .vocab-controls,
  .attendance-filters { grid-template-columns: 1fr; }
  .vocab-flashcard { min-height: 300px; padding: 24px 16px; }
}
body.portal-page .lookup-result { margin-top: 0; }
body.portal-page .lookup-head h3 { color: #eef0ff; }
body.portal-page .lookup-block { margin-top: 0; }
body.portal-page .lookup-block + .lookup-block { margin-top: 22px; }
body.portal-page .student-code-banner {
  background: rgba(99,102,241,.14);
  border-color: rgba(99,102,241,.38);
  color: #dfe3ff;
}
body.portal-page .student-code-banner a { color: #67e8f9; }
body.portal-page .student-code-chip {
  background: rgba(34,211,238,.16);
  color: #7dd3fc;
  border-color: rgba(34,211,238,.4);
}
body.portal-page .btn-send-change {
  background: linear-gradient(120deg, #6366f1, #22d3ee);
  border: 0;
  color: #04060f;
  font-weight: 800;
}

@media (max-width: 560px) {
  .portal-field-grid { grid-template-columns: 1fr; }
  .portal-actions { flex-direction: column; }
  body.portal-page .portal-btn { width: 100%; }
}
