:root {
  --bg: #f6f3ee;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #667085;
  --primary: #2f5d62;
  --primary-dark: #24494d;
  --primary-soft: #edf5f4;
  --accent: #b7791f;
  --border: #ded7cc;
  --line: #ebe5dc;
  --warn: #fff7ed;
  --warn-border: #f3c58f;
  --ok: #eef8f1;
  --ok-border: #b7dfc2;
  --shadow: 0 10px 26px rgba(31, 41, 51, .06);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
}

.site-header {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 26px 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}
.eyebrow {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  margin: 0 0 8px;
}
h1 {
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1.15;
  margin: 0 0 10px;
  font-weight: 700;
}
h2 { margin: 0; font-size: 21px; }
h3 { margin: 0 0 12px; font-size: 17px; }
.subtitle {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}
.summary-card {
  min-width: 250px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fbfaf8;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  overflow: hidden;
}
.summary-card div {
  padding: 14px 12px;
  text-align: center;
  border-left: 1px solid var(--line);
}
.summary-card div:first-child { border-left: 0; }
.summary-card span { display: block; font-size: 24px; font-weight: 700; color: var(--primary); }
.summary-card small { color: var(--muted); }

.layout {
  max-width: 1180px;
  margin: 22px auto 40px;
  padding: 0 22px;
  display: grid;
  gap: 16px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.full { overflow: hidden; }
.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.section-title.compact { margin-bottom: 6px; }
.step {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex: 0 0 auto;
}
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.top-space { margin-top: 12px; }
label {
  display: grid;
  gap: 7px;
  color: #475467;
  font-weight: 600;
}
input, select {
  width: 100%;
  border: 1px solid #cfc7bd;
  border-radius: 8px;
  padding: 10px 11px;
  font-size: 15px;
  color: var(--text);
  background: #fff;
  outline: none;
}
input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 93, 98, .12);
}
.check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.check-row label { display: flex; align-items: center; gap: 8px; }
.check-row input { width: auto; }
.info-box {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid #d8c29d;
  background: #fffaf1;
  border-radius: 9px;
  color: #5f4b2d;
  line-height: 1.5;
}
.hint { color: var(--muted); line-height: 1.55; margin-top: 0; }
.upload-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.upload-card {
  background: #fcfbf8;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
}
.upload-card p { color: var(--muted); line-height: 1.5; }
code { background: #f0ebe3; padding: 2px 6px; border-radius: 5px; font-size: .92em; }
.action-panel { display: flex; justify-content: space-between; gap: 18px; align-items: center; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
button {
  border: 0;
  background: var(--primary);
  color: #fff;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background .14s ease, opacity .14s ease;
}
button:hover { background: var(--primary-dark); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.secondary { background: #475467; }
button.secondary:hover { background: #344054; }
button.ghost { background: var(--primary-soft); color: var(--primary); padding: 9px 12px; }
button.ghost:hover { background: #dfeeed; }
.message { margin-top: 12px; color: var(--muted); }
.message.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; padding: 12px; border-radius: 8px; }
.message.ok { background: var(--ok); color: #166534; border: 1px solid var(--ok-border); padding: 12px; border-radius: 8px; }
.message.warn { background: var(--warn); color: #9a3412; border: 1px solid var(--warn-border); padding: 12px; border-radius: 8px; }
.tabs { display: flex; gap: 8px; padding-bottom: 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tab { background: #f0ebe3; color: #475467; }
.tab.active { background: var(--primary); color: white; }
.table-wrap { max-height: 520px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; margin-top: 14px; }
table { border-collapse: collapse; width: 100%; min-width: 780px; font-size: 14px; }
th, td { border-bottom: 1px solid var(--line); padding: 10px 12px; text-align: left; vertical-align: top; }
th { position: sticky; top: 0; background: #f7f4ef; z-index: 1; font-weight: 700; color: #344054; }
tr:nth-child(even) td { background: #fdfbf8; }
.badge { display: inline-block; background: var(--primary-soft); color: var(--primary); padding: 4px 8px; border-radius: 999px; font-weight: 700; }
.warn-list { display: grid; gap: 10px; margin-top: 14px; }
.warn-item { padding: 12px; border-radius: 8px; background: var(--warn); border: 1px solid var(--warn-border); }
.empty { color: var(--muted); padding: 18px; }
footer { max-width: 1180px; margin: 0 auto 30px; padding: 0 22px; color: var(--muted); }

@media (max-width: 880px) {
  .header-inner, .action-panel { flex-direction: column; align-items: stretch; }
  .summary-card, .grid.two, .upload-grid { grid-template-columns: 1fr; }
  .actions { justify-content: flex-start; }
}


/* v1.5: Header/mobile overflow fixes */
html, body { width: 100%; max-width: 100%; overflow-x: hidden; }
.site-header { width: 100%; }
.header-copy { min-width: 0; }
.eyebrow, h1, .subtitle { overflow-wrap: anywhere; }
.summary-card { flex: 0 0 auto; }

@media (max-width: 560px) {
  body { font-size: 14px; }
  .header-inner {
    padding: 20px 14px 18px;
    gap: 16px;
  }
  .eyebrow {
    font-size: 11px;
    line-height: 1.45;
    letter-spacing: .015em;
    word-break: normal;
  }
  h1 {
    font-size: clamp(28px, 9vw, 36px);
    line-height: 1.08;
  }
  .subtitle {
    font-size: 15px;
    line-height: 1.5;
  }
  .summary-card {
    width: 100%;
    min-width: 0;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .summary-card div { padding: 11px 8px; }
  .summary-card span { font-size: 22px; }
  .layout {
    margin-top: 14px;
    padding: 0 12px;
    gap: 12px;
  }
  .panel {
    padding: 18px 14px;
    border-radius: 10px;
  }
  h2 { font-size: 19px; }
  input, select { font-size: 16px; }
  .tabs { gap: 6px; }
  .tab { padding: 9px 11px; }
}

/* v1.7: cấu hình course chung */
.course-config {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fcfbf8;
}
.course-config-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 12px;
}
.course-config h3 { margin: 0 0 6px; }
textarea {
  width: 100%;
  min-height: 125px;
  resize: vertical;
  border: 1px solid #cfc7bd;
  border-radius: 8px;
  padding: 10px 11px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: #fff;
  outline: none;
  font-family: Consolas, "Courier New", monospace;
}
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(47, 93, 98, .12);
}
.small-note { font-size: 13px; margin-bottom: 0; }

@media (max-width: 700px) {
  .course-config-head { flex-direction: column; }
  .course-config-head button { width: 100%; }
}

/* v2.0 one-page data-entry upgrade */
.compact-header .header-inner { padding-top: 20px; padding-bottom: 20px; }
.layout.one-page { gap: 14px; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}
.section-head h2 { margin-bottom: 4px; }
.mini-actions, .import-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.file-like {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 8px;
  padding: 9px 12px;
  font-weight: 700;
  cursor: pointer;
  border: 0;
  white-space: nowrap;
}
.file-like:hover { background: #dfeeed; }
button.danger, button.ghost.danger { color: #a23a28; background: #fff1ed; }
button.danger:hover, button.ghost.danger:hover { background: #ffe2da; }
.import-row {
  align-items: stretch;
  margin-bottom: 12px;
}
.import-row textarea {
  min-height: 52px;
  flex: 1 1 420px;
  font-family: "Segoe UI", Arial, sans-serif;
}
.editor-wrap { margin-top: 8px; }
.editor-table-wrap { max-height: 420px; }
.editor-table td[contenteditable="true"] {
  background: #fff;
  min-width: 90px;
  cursor: text;
}
.editor-table td[contenteditable="true"]:focus {
  outline: 2px solid rgba(47,93,98,.25);
  outline-offset: -2px;
  background: #fffdf8;
}
.editor-table th.row-no, .editor-table td.row-no {
  min-width: 44px;
  text-align: center;
  color: var(--muted);
  background: #f7f4ef;
  position: sticky;
  left: 0;
  z-index: 2;
}
.editor-table th.row-no { z-index: 3; }
.editor-table td[data-field="email"], .editor-table td[data-field="course_shortname"], .editor-table td[data-field="cohort_id"] { min-width: 190px; }
.editor-table td[data-field="course_name"] { min-width: 240px; }
.editor-table td[data-field="ho"], .editor-table td[data-field="ten"] { min-width: 120px; }
.editor-table td[data-field^="course"] { min-width: 74px; text-align: center; }
.mini-delete {
  background: #f3eee6;
  color: #8a3a2b;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
}
.mini-delete:hover { background: #eadbd2; }
.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 10;
  box-shadow: 0 -8px 24px rgba(31,41,51,.08);
}

@media (max-width: 980px) {
  .grid.three { grid-template-columns: 1fr; }
  .section-head, .action-panel { flex-direction: column; align-items: stretch; }
  .mini-actions { justify-content: flex-start; }
  .import-row { flex-direction: column; }
}

@media (max-width: 560px) {
  .sticky-actions { position: static; }
  .file-like, .mini-actions button, .import-row button { width: 100%; }
}

/* v2.1: layout and spreadsheet-paste fixes */
.layout, .panel, .section-head, .import-row, .editor-wrap, .table-wrap {
  min-width: 0;
  max-width: 100%;
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}
.section-head h2 { margin-bottom: 6px; }
.mini-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex: 0 0 auto;
}
.import-row {
  display: grid;
  grid-template-columns: auto minmax(280px, 1fr) auto;
  gap: 10px;
  align-items: stretch;
  margin: 12px 0 12px;
}
.import-row textarea {
  width: 100%;
  min-width: 0;
  min-height: 52px;
  max-height: 140px;
  resize: vertical;
  border: 1px solid #cfc7bd;
  border-radius: 8px;
  padding: 10px 11px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
}
.file-like {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  padding: 10px 12px;
  cursor: pointer;
  white-space: nowrap;
}
.editor-wrap { overflow: hidden; }
.editor-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.editor-table {
  width: max-content;
  min-width: 100%;
  table-layout: fixed;
}
.editor-table th,
.editor-table td {
  min-width: 110px;
  max-width: 220px;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}
.editor-table th.row-no,
.editor-table td.row-no {
  min-width: 46px;
  width: 46px;
  max-width: 46px;
  text-align: center;
  color: var(--muted);
  background: #faf7f2;
}
.editor-table td[contenteditable="true"] {
  cursor: text;
  background: #fff;
}
.editor-table td[contenteditable="true"]:focus {
  outline: 2px solid rgba(47, 93, 98, .45);
  outline-offset: -2px;
  background: #fbfffe;
}
.mini-delete {
  padding: 4px 8px;
  border-radius: 6px;
  background: #f4e7e7;
  color: #9b1c1c;
}
.mini-delete:hover { background: #ecd1d1; }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; }

@media (max-width: 880px) {
  .section-head,
  .import-row {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }
  .mini-actions { justify-content: flex-start; }
  .import-row button,
  .import-row .file-like { width: 100%; }
}

/* v2.2: username/password counter settings */
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.counter-grid input { font-family: Consolas, "Courier New", monospace; }
.counter-note { margin: 10px 0 0; }
@media (max-width: 980px) { .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .grid.four { grid-template-columns: 1fr; } }
