:root {
  --navy: #0f2b46;
  --navy-dark: #091d30;
  --teal: #0e7490;
  --teal-light: #e0f2fe;
  --bg: #f4f6f9;
  --card: #ffffff;
  --border: #dfe5ec;
  --text: #1e293b;
  --muted: #5b6878;
  --green: #15803d;
  --green-bg: #dcfce7;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --red: #b91c1c;
  --red-bg: #fee2e2;
  --blue: #1d4ed8;
  --blue-bg: #dbeafe;
  --radius: 10px;
}

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

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: var(--navy);
  color: #fff;
  padding: 0 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 58px;
}
.brand {
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand small { font-weight: 400; opacity: 0.8; font-size: 12px; }
.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}
.nav a {
  color: rgba(255,255,255,0.86);
  padding: 7px 11px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 500;
}
.nav a:hover, .nav a.active {
  background: rgba(255,255,255,0.16);
  color: #fff;
  text-decoration: none;
}
.nav-sep {
  width: 1px;
  height: 18px;
  background: rgba(255,255,255,0.25);
  margin: 0 4px;
}
.user-box {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.container {
  max-width: 1180px;
  margin: 20px auto;
  padding: 0 16px 40px;
}

.banner {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
  border: 1px solid transparent;
}
.banner-warn { background: var(--amber-bg); border-color: #f59e0b; color: #78350f; }
.banner-danger { background: var(--red-bg); border-color: #ef4444; color: #7f1d1d; }
.banner-info { background: var(--blue-bg); border-color: #60a5fa; color: #1e3a8a; }
.banner-ok { background: var(--green-bg); border-color: #22c55e; color: #14532d; }

.cycle-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.cycle-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.cycle-tab {
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
}
.cycle-tab.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}
.cycle-tab:hover { text-decoration: none; border-color: var(--teal); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 900px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .grid-4 { grid-template-columns: 1fr; }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.card h2, .card h3 { margin: 0 0 10px; font-size: 16px; color: var(--navy); }
.muted { color: var(--muted); font-size: 13px; }

.progress {
  height: 8px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin: 6px 0;
}
.progress > span {
  display: block;
  height: 100%;
  background: var(--teal);
  border-radius: 999px;
}
.progress.pass > span { background: var(--green); }
.progress.fail > span { background: var(--red); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.b-green { background: var(--green-bg); color: var(--green); }
.b-amber { background: var(--amber-bg); color: var(--amber); }
.b-red { background: var(--red-bg); color: var(--red); }
.b-blue { background: var(--blue-bg); color: var(--blue); }
.b-gray { background: #e2e8f0; color: #334155; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: #f1f5f9; text-decoration: none; }
.btn-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-dark); color: #fff; }
.btn-teal { background: var(--teal); color: #fff; border-color: var(--teal); }
.btn-teal:hover { background: #0c627a; color: #fff; }
.btn-sm { padding: 4px 9px; font-size: 12.5px; }
.btn-danger { color: var(--red); border-color: #fca5a5; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
th, td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
th { background: #f8fafc; color: var(--navy); font-weight: 600; }
.table-wrap { overflow-x: auto; }

input[type="text"], input[type="email"], input[type="number"], input[type="date"], select, textarea {
  padding: 7px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 13.5px;
  font-family: inherit;
}
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.stat-num { font-size: 24px; font-weight: 700; color: var(--navy); }
.milestones { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.milestone {
  flex: 1 1 160px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
}
.crit-card {
  border-left: 4px solid var(--teal);
}
.crit-item {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  background: #fafcff;
}
.login-wrap {
  max-width: 440px;
  margin: 70px auto;
  padding: 28px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  text-align: center;
}
.footer {
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  padding: 16px;
  border-top: 1px solid var(--border);
  margin-top: 24px;
}

/* Instant Evidence Hover Preview Popover & Modal */
.pv-trigger {
  cursor: pointer;
}
.pv-popover {
  position: fixed;
  z-index: 1200;
  max-height: 78vh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(15, 43, 70, 0.22), 0 4px 12px rgba(15, 43, 70, 0.1);
  padding: 14px 16px;
  animation: pvFadeIn 110ms ease-out;
}
@keyframes pvFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.pv-head { margin-bottom: 10px; }
.pv-badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.pv-title { font-weight: 700; font-size: 14.5px; color: var(--navy); line-height: 1.35; }
.pv-sub { margin-top: 3px; font-size: 12.5px; }
.pv-warn {
  background: var(--amber-bg);
  color: #78350f;
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 12.5px;
  margin-bottom: 10px;
}
.pv-dl {
  display: grid;
  grid-template-columns: minmax(115px, auto) 1fr;
  gap: 4px 10px;
  margin: 0 0 10px;
  font-size: 13px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
.pv-dl dt { color: var(--muted); font-weight: 500; }
.pv-dl dd { margin: 0; color: var(--text); font-weight: 600; word-break: break-word; }
.pv-media {
  margin: 8px 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #f1f5f9;
}
.pv-media-img img {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  background: #fff;
}
.pv-media-pdf iframe {
  display: block;
  width: 100%;
  height: 260px;
  border: 0;
  background: #fff;
}
.pv-media-pdf-lg iframe {
  height: 62vh;
}
.pv-rules { margin-bottom: 8px; font-size: 12.5px; }
.pv-rule.ok { color: var(--green); }
.pv-rule.fail { color: var(--amber); }
.pv-excerpt {
  font-size: 12.5px;
  color: var(--muted);
  background: #f8fafc;
  border-left: 3px solid var(--teal);
  padding: 6px 9px;
  border-radius: 4px;
  margin-bottom: 10px;
  line-height: 1.45;
}
.pv-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.pv-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1400;
  background: rgba(9, 29, 48, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.pv-modal-backdrop[hidden] { display: none; }
.pv-modal {
  position: relative;
  width: min(860px, 96vw);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.pv-modal .pv-media-img img { max-height: 62vh; }
.pv-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 15px;
  color: var(--text);
}
.pv-modal-close:hover { background: #f1f5f9; }

/* Floating round-trip sync toast after clicking "Cập nhật trên daotao" */
.sync-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1300;
  max-width: min(560px, calc(100vw - 32px));
  background: var(--navy);
  color: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(9, 29, 48, 0.32);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
}
.sync-toast[hidden] { display: none; }

/* Action-oriented Dashboard layout */
.hero-card { padding: 14px 18px; }
.step-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}
@media (max-width: 780px) {
  .step-strip { grid-template-columns: 1fr; }
}
.step-box {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text);
  transition: border-color 120ms, background 120ms;
}
.step-box:hover {
  text-decoration: none;
  border-color: var(--teal);
  background: #f0f9ff;
}
.step-box.step-done { border-color: #86efac; background: #f0fdf4; }
.step-box.step-active { border-color: #93c5fd; background: #eff6ff; }
.step-kicker { font-size: 12px; font-weight: 600; color: var(--teal); text-transform: uppercase; letter-spacing: 0.02em; }
.step-val { font-size: 15.5px; font-weight: 700; color: var(--navy); margin: 2px 0; }

.grid-main {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 16px;
}
@media (max-width: 900px) {
  .grid-main { grid-template-columns: 1fr; }
}

.todo-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  background: #fafcff;
}
.todo-row:last-child { margin-bottom: 0; }
.todo-text { min-width: 0; flex: 1; }
.todo-title { font-size: 14px; line-height: 1.4; }
.todo-action {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}
.todo-action .btn { white-space: nowrap; }
@media (max-width: 600px) {
  .todo-row { flex-direction: column; align-items: flex-start; }
}

.elig-list { display: flex; flex-direction: column; gap: 8px; }
.elig-row {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafcff;
}

.std-card {
  display: block;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  background: #fff;
  transition: border-color 120ms, box-shadow 120ms;
}
.std-card:hover {
  text-decoration: none;
  border-color: var(--teal);
  box-shadow: 0 4px 12px rgba(14, 116, 144, 0.1);
}

.std-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 8px;
  padding: 7px 12px;
  background: #e2e8f0;
  color: var(--navy);
  border-radius: 8px;
  font-size: 14.5px;
  scroll-margin-top: 120px;
}
.std-section-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
}

/* Visual Checklist 25 criteria — Sticky toolbar + color-coded compact accordion */
.chk-toolbar {
  position: sticky;
  top: 0;
  z-index: 900;
  background: rgba(244, 246, 249, 0.96);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 14px;
  box-shadow: 0 4px 14px rgba(15, 43, 70, 0.06);
}
.chk-toolbar-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.chk-std-jumps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.std-pill {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--muted);
}
.std-pill.has {
  border-color: #86efac;
  background: #f0fdf4;
  color: var(--green);
}
.std-pill:hover { text-decoration: none; border-color: var(--teal); color: var(--navy); }
.chk-toolbar-filters {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.filter-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.fpill {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}
.fpill.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}
.chk-search {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  width: 185px;
  background: #fff;
}

.crit-acc {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid #cbd5e1;
  border-radius: 9px;
  margin-bottom: 8px;
  scroll-margin-top: 120px;
  transition: border-color 120ms, box-shadow 120ms;
}
.crit-acc[hidden] { display: none; }
.crit-acc.crit-ok { border-left-color: #16a34a; }
.crit-acc.crit-warn { border-left-color: #d97706; }
.crit-acc.crit-empty { border-left-color: #cbd5e1; background: #fbfcfe; }
.crit-acc[open] {
  background: #fff;
  box-shadow: 0 3px 10px rgba(15, 43, 70, 0.05);
}

.crit-acc-head {
  list-style: none;
  cursor: pointer;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.crit-acc-head::-webkit-details-marker { display: none; }
.crit-head-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1;
}
.crit-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-ok { background: #16a34a; }
.dot-warn { background: #d97706; }
.dot-empty { background: #cbd5e1; }

.crit-code-pill {
  font-size: 12px;
  font-weight: 700;
  color: var(--navy);
  background: #eef2f6;
  padding: 2px 8px;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}
.crit-title-wrap { min-width: 0; flex: 1; }
.crit-title-text {
  font-weight: 600;
  font-size: 14px;
  color: var(--navy);
  line-height: 1.35;
}
.crit-meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  margin-top: 2px;
  font-size: 12px;
}
.src-chip {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: #f1f5f9;
  color: #475569;
}
.src-daotao { background: #e0f2fe; color: #0369a1; }
.src-gvtb { background: #eef2ff; color: #4338ca; }

.crit-head-right {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}
.score-pill {
  background: var(--green-bg);
  color: var(--green);
  font-weight: 700;
  font-size: 12.5px;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.quick-act {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 6px;
  white-space: nowrap;
}
.quick-upload { background: #eef2ff; color: #3730a3; }
.quick-daotao { background: #e0f2fe; color: #0e7490; }
.quick-muted { background: #f1f5f9; color: var(--muted); max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
.chev { color: var(--muted); font-size: 12px; transition: transform 140ms; }
.crit-acc[open] .chev { transform: rotate(180deg); }

.crit-acc-body {
  padding: 0 14px 12px;
  border-top: 1px solid #eef2f6;
}
.crit-body-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 9px 0 8px;
}
.crit-items-list { display: flex; flex-direction: column; gap: 7px; margin-bottom: 10px; }
.crit-item-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafcff;
}
.crit-item-info { min-width: 0; flex: 1; }
.crit-item-top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.crit-item-title { font-size: 14px; color: var(--text); }
.crit-item-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.crit-item-actions .btn { white-space: nowrap; }

.upload-box {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 10px 12px;
}
.upload-box-head { font-size: 13px; color: var(--navy); margin-bottom: 4px; }

.extra-acc { padding: 12px 16px; }
.extra-acc-head {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  color: var(--navy);
}
.extra-acc-head::-webkit-details-marker { display: none; }

@media (max-width: 720px) {
  .crit-acc-head { flex-direction: column; align-items: flex-start; }
  .crit-head-right { width: 100%; justify-content: flex-end; }
  .crit-item-row { flex-direction: column; }
  .quick-muted { display: none; }
}

/* Unified Unit + Simulation 2-mode switcher */
.mode-switch {
  display: inline-flex;
  background: #e2e8f0;
  padding: 3px;
  border-radius: 9px;
  gap: 2px;
}
.mode-tab {
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.mode-tab:hover { text-decoration: none; color: var(--navy); }
.mode-tab.active {
  background: #fff;
  color: var(--navy);
  box-shadow: 0 1px 3px rgba(15, 43, 70, 0.12);
}

/* Inline 2-way daotao attachment trigger */
.inline-attach-btn {
  display: inline-block;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--teal);
  list-style: none;
}
.inline-attach-btn::-webkit-details-marker { display: none; }
.inline-attach-btn:hover { text-decoration: underline; }

/* Preview loading state & multi-attachment switcher */
.pv-media-img { position: relative; min-height: 120px; }
.pv-spinner {
  padding: 28px 14px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}
.pv-media-img.pv-loading img { opacity: 0; height: 0; }
.pv-caption {
  padding: 4px 8px;
  font-size: 11.5px;
  color: var(--muted);
  background: #f8fafc;
  border-top: 1px solid var(--border);
  text-align: center;
}
.pv-att-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
}
.pv-att-tab {
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 12px;
  cursor: pointer;
}
.pv-att-tab.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}
.pv-pdf-switch { margin-bottom: 8px; text-align: center; }
