:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #e2e6ec;
  --text: #1f2733;
  --muted: #6b7684;
  --accent: #2f6df6;
  --accent-dark: #1f52c9;
  --ok: #12854a;
  --ok-bg: #e7f7ee;
  --danger: #d93a3f;
  --danger-bg: #fdecec;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --radius: 12px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 16px;
}

code { background: #eef1f5; padding: 1px 5px; border-radius: 4px; font-size: .88em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.strong { font-weight: 600; }
.left { text-align: left; }
.center { text-align: center; }

/* ---------- Topbar ---------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 30;
}
.topbar-inner {
  max-width: 1100px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.brand {
  font-weight: 700; font-size: 1.05rem; color: var(--text);
  text-decoration: none; margin-right: auto;
}
.nav-toggle {
  display: none; background: none; border: 1px solid var(--border);
  border-radius: 8px; font-size: 1.2rem; padding: 4px 10px; cursor: pointer;
}
.nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.nav a { color: var(--accent); text-decoration: none; font-size: .92rem; }
.nav a:hover { text-decoration: underline; }
.nav .who { color: var(--muted); font-size: .85rem; }
.nav .danger-link { color: var(--danger); }

/* ---------- Layout ---------- */
main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
main.center-page {
  min-height: calc(100vh - 120px);
  display: flex; align-items: center; justify-content: center;
}
.page-title { margin: 0 0 4px; font-size: 1.4rem; }
.section-title { margin: 24px 0 10px; font-size: 1.05rem; }
.panel .section-title:first-child { margin-top: 0; }
.crumb { margin: 0 0 8px; font-size: .88rem; }
.row-between {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.panel {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin: 16px 0;
  box-shadow: var(--shadow);
}
.panel.narrow { width: 100%; max-width: 420px; margin: 0 auto; }
.stack { display: flex; flex-direction: column; gap: 12px; align-items: center; margin-top: 20px; }
.stack-inline { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.plain-list { margin: 0; padding-left: 18px; }
.plain-list li { margin: 4px 0; }

/* ---------- Flash ---------- */
.flashes { margin-bottom: 16px; }
.flash {
  padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; font-size: .92rem;
  border: 1px solid transparent;
}
.flash-ok { background: var(--ok-bg); color: var(--ok); border-color: #bfe6d1; }
.flash-error { background: var(--danger-bg); color: var(--danger); border-color: #f5c6c7; }
.flash-message { background: #eef2ff; color: var(--accent-dark); border-color: #cfd9fb; }

/* ---------- Form ---------- */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 5px; }
.field input, .field select, .comment, .copy-row input, .inline-form input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font: inherit; background: #fff; color: var(--text);
}
.field input:focus, .field select:focus, .comment:focus { outline: none; border-color: var(--accent); }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row .field { flex: 1 1 220px; margin-bottom: 14px; }
.form-row .narrow-field { flex: 0 1 160px; }
.check-inline { display: flex; align-items: center; gap: 8px; font-size: .92rem; margin: 10px 0 16px; }
.check-inline input { width: 18px; height: 18px; }
.fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin: 8px 0 16px; }
.fieldset legend { font-size: .85rem; font-weight: 600; padding: 0 6px; }
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filter-row select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; }

.user-picker { display: flex; flex-wrap: wrap; gap: 8px; max-height: 260px; overflow-y: auto; }
.user-chip { position: relative; cursor: pointer; }
.user-chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.user-chip span {
  display: inline-block; padding: 7px 12px; border: 1px solid var(--border);
  border-radius: 999px; font-size: .88rem; background: #fff; transition: all .12s;
}
.user-chip em { color: var(--muted); font-style: normal; font-size: .78rem; }
.user-chip input:checked + span {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.user-chip input:checked + span em { color: #dbe6ff; }

.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row input { flex: 1 1 auto; font-size: .85rem; font-family: ui-monospace, Menlo, Consolas, monospace; }

/* ---------- Button ---------- */
.btn {
  display: inline-block; background: #fff; color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 20px; font-size: .95rem; font-weight: 600;
  cursor: pointer; text-decoration: none; text-align: center;
  transition: background .12s, border-color .12s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn-block { display: block; width: 100%; }
.btn-small { padding: 6px 12px; font-size: .82rem; border-radius: 8px; }
.btn-danger { color: var(--danger); border-color: #f0c2c3; }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.link { color: var(--accent); text-decoration: none; }
.link:hover { text-decoration: underline; }
.danger-zone { border-color: #f0c2c3; }

/* ---------- Pill / badge ---------- */
.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: .75rem; font-weight: 600;
}
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-off { background: #eef1f5; color: var(--muted); }
.pill-admin { background: #eef2ff; color: var(--accent-dark); }
.badge {
  display: inline-block; background: #eef2ff; color: var(--accent-dark);
  font-weight: 600; font-size: .8rem; padding: 2px 10px; border-radius: 999px;
}

/* ---------- Progress bar ---------- */
.bar {
  height: 8px; background: #e7ebf1; border-radius: 999px; overflow: hidden;
  margin: 8px 0;
}
.bar.mini { height: 6px; min-width: 70px; margin: 4px 0; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 999px; }

/* ---------- Stat / score grid ---------- */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px; margin: 16px 0;
}
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; text-align: center; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 2px;
}
.stat-num { font-size: 1.6rem; font-weight: 700; }
.stat-label { font-size: .8rem; color: var(--muted); }

.score-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px;
}
.score-tile {
  background: #f8fafc; border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; text-align: center; display: flex; flex-direction: column; gap: 2px;
}
.score-val { font-size: 1.5rem; font-weight: 700; color: var(--accent-dark); }
.score-label { font-size: .8rem; color: var(--muted); }

/* ---------- Task cards ---------- */
.task-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px;
}
.task-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); text-decoration: none; color: inherit;
  display: flex; flex-direction: column; gap: 4px;
  transition: border-color .12s, box-shadow .12s;
}
.task-card:hover { border-color: var(--accent); box-shadow: 0 4px 14px rgba(47,109,246,.14); }
.task-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.task-name { font-weight: 700; }
.task-card .btn { margin-top: 10px; }

/* ---------- Rating card ---------- */
.eval-head { margin-bottom: 18px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; margin-bottom: 18px; box-shadow: var(--shadow);
  transition: box-shadow .15s, border-color .15s;
}
.card.missing { border-color: #e5484d; box-shadow: 0 0 0 3px rgba(229,72,77,.18); }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.card-index { font-size: .8rem; color: var(--muted); }

.transcript {
  font-size: 1.1rem; font-weight: 500; margin: 6px 0 12px; padding: 12px 14px;
  background: #f8fafc; border-left: 3px solid var(--accent); border-radius: 6px;
  word-break: break-word;
}
.player { width: 100%; margin-bottom: 14px; }
.player-mini { width: 170px; max-width: 100%; height: 34px; }

.criteria { display: flex; flex-direction: column; gap: 12px; }
.criterion {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.criterion-label { font-size: .92rem; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.info {
  position: relative; cursor: help; color: var(--muted); font-size: .85rem;
  border: 1px solid var(--border); border-radius: 50%;
  width: 20px; height: 20px; display: inline-flex;
  align-items: center; justify-content: center; outline: none; flex: none;
}
.tooltip {
  position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%) translateY(4px); z-index: 50;
  min-width: 220px; max-width: min(320px, 80vw);
  background: #1f2733; color: #f4f6f9; padding: 10px 12px; border-radius: 8px;
  box-shadow: 0 6px 20px rgba(16,24,40,.25);
  font-size: .82rem; font-weight: 400; line-height: 1.45; text-align: left;
  white-space: normal; opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .12s, transform .12s;
}
.tooltip::after {
  content: ""; position: absolute; top: 100%; left: 50%;
  transform: translateX(-50%); border: 6px solid transparent; border-top-color: #1f2733;
}
.tooltip-line { display: block; }
.tooltip-line + .tooltip-line { margin-top: 3px; }
.info:hover .tooltip, .info:focus .tooltip {
  opacity: 1; visibility: visible; transform: translateX(-50%) translateY(0);
}

.score-buttons { display: flex; gap: 6px; }
.score { position: relative; cursor: pointer; }
.score input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.score span {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border: 1px solid var(--border); border-radius: 8px;
  font-weight: 600; color: var(--muted); background: #fff; transition: all .12s;
}
.score:hover span { border-color: var(--accent); color: var(--accent); }
.score input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }

.comment { margin-top: 14px; resize: vertical; }

.submit-bar {
  position: sticky; bottom: 0; padding: 14px 0;
  background: linear-gradient(to top, var(--bg) 65%, rgba(244,246,249,0));
}

/* ---------- Done page ---------- */
.check {
  width: 64px; height: 64px; margin: 0 auto 16px;
  background: var(--ok-bg); color: var(--ok); border-radius: 50%;
  font-size: 2rem; display: flex; align-items: center; justify-content: center;
}

/* ---------- Table ---------- */
.table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); margin: 12px 0;
}
.data-table { width: 100%; border-collapse: collapse; min-width: 640px; }
.data-table th, .data-table td {
  padding: 11px 14px; text-align: center; border-bottom: 1px solid var(--border);
  font-size: .88rem; white-space: nowrap;
}
.data-table th { background: #f8fafc; font-weight: 600; color: var(--muted); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table td.left, .data-table th.left { text-align: left; }
.data-table .row-done { background: #fbfefc; }
.cell-text { white-space: normal; max-width: 380px; min-width: 200px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.inline-form { display: flex; gap: 4px; align-items: center; margin: 0; }
.inline-form input { width: 130px; padding: 6px 10px; font-size: .82rem; }

.comment-list { list-style: none; margin: 0; padding: 0; }
.comment-list li { border-bottom: 1px solid var(--border); padding: 10px 0; }
.comment-list li:last-child { border-bottom: none; }
.comment-list p { margin: 6px 0 0; }

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  body { font-size: 15px; }
  main { padding: 16px 12px 48px; }
  .nav-toggle { display: block; }
  .nav {
    display: none; width: 100%; flex-direction: column;
    align-items: flex-start; gap: 10px; padding-top: 10px;
    border-top: 1px solid var(--border); margin-top: 8px;
  }
  .nav.open { display: flex; }
  .panel { padding: 14px; }
  .criterion { flex-direction: column; align-items: flex-start; gap: 6px; }
  .score-buttons { width: 100%; gap: 8px; }
  .score { flex: 1 1 0; }
  .score span { width: 100%; height: 46px; }
  .transcript { font-size: 1rem; }
  .stat-num { font-size: 1.35rem; }
  .form-row .field, .form-row .narrow-field { flex: 1 1 100%; }
  .actions { justify-content: flex-start; }
}

/* --- Bộ chọn ngôn ngữ trên thanh điều hướng --- */
.lang-select {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: .85rem;
  max-width: 160px;
}
@media (max-width: 720px) {
  .lang-select { width: 100%; max-width: none; }
}
