:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --border: #e3e6ef;
  --text: #1b2033;
  --muted: #5d6478;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --ok: #059669;
  --ok-soft: #e7f7f1;
  --warn: #b45309;
  --warn-soft: #fff4e5;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --info: #2563eb;
  --info-soft: #e9f0ff;
  --shadow: 0 1px 2px rgba(20, 24, 40, .05), 0 4px 16px rgba(20, 24, 40, .05);
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1220;
    --surface: #171a2b;
    --surface-2: #1e2235;
    --border: #2a2f47;
    --text: #e8eaf3;
    --muted: #9aa1b8;
    --accent: #8b85ff;
    --accent-soft: #24264a;
    --ok: #34d399;
    --ok-soft: #12302a;
    --warn: #fbbf24;
    --warn-soft: #34290f;
    --danger: #f87171;
    --danger-soft: #3a1a1d;
    --info: #60a5fa;
    --info-soft: #172743;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1220;
  --surface: #171a2b;
  --surface-2: #1e2235;
  --border: #2a2f47;
  --text: #e8eaf3;
  --muted: #9aa1b8;
  --accent: #8b85ff;
  --accent-soft: #24264a;
  --ok: #34d399;
  --ok-soft: #12302a;
  --warn: #fbbf24;
  --warn-soft: #34290f;
  --danger: #f87171;
  --danger-soft: #3a1a1d;
  --info: #60a5fa;
  --info-soft: #172743;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86em; }
code { background: var(--surface-2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; }
pre { background: var(--surface-2); border: 1px solid var(--border); padding: 14px 16px; border-radius: 10px; overflow-x: auto; line-height: 1.5; }
pre code { background: none; border: 0; padding: 0; }

.wrap { max-width: 1140px; margin: 0 auto; padding: 0 16px; }

/* ---------- Top nav ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .wrap { display: flex; align-items: center; gap: 18px; height: 58px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #ec4899); color: #fff; font-size: 13px; font-weight: 800;
}
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  color: var(--muted); padding: 6px 10px; border-radius: 8px; font-size: 14px; white-space: nowrap;
}
.nav a:hover, .nav a.active { color: var(--text); background: var(--surface-2); text-decoration: none; }
.theme-btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer; font-size: 15px; flex: none;
}

/* ---------- Hero ---------- */
.hero { padding: 40px 0 8px; }
.eyebrow { color: var(--accent); font-weight: 600; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; }
.hero h1 { font-size: clamp(28px, 4.4vw, 42px); line-height: 1.15; margin: 8px 0 10px; letter-spacing: -.02em; }
.hero p.lead { color: var(--muted); font-size: 16.5px; max-width: 760px; margin: 0 0 18px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted); font-size: 13px;
}
.chip b { color: var(--text); font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow);
}
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn[aria-disabled="true"] { opacity: .55; pointer-events: none; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 28px 0 8px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
.stat .sub { color: var(--muted); font-size: 12.5px; }
.bar { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #ec4899); border-radius: 999px; transition: width .6s ease; }
.sync-note { color: var(--muted); font-size: 12.5px; margin-top: 6px; }

/* ---------- Sections ---------- */
section.block { padding: 40px 0 8px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.section-head h2 { font-size: 24px; margin: 0; letter-spacing: -.01em; }
.section-head p { color: var(--muted); margin: 4px 0 0; max-width: 720px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 18px 20px; }

/* ---------- Members ---------- */
.members { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.member { padding: 16px; cursor: pointer; transition: transform .15s ease, border-color .15s ease; text-align: left; font: inherit; color: inherit; }
.member:hover, .member:focus-visible { transform: translateY(-2px); border-color: var(--accent); outline: none; }
.member .avatar {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 16px;
}
.member .name { font-weight: 700; margin-top: 10px; line-height: 1.3; }
.member .mssv { color: var(--muted); font-size: 12.5px; }
.member .role { display: inline-block; margin-top: 8px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.member .focus { color: var(--muted); font-size: 12.5px; margin-top: 8px; line-height: 1.5; min-height: 56px; }
.member .mini { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 10px; }

/* ---------- Timeline ---------- */
.sprints { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.sprint { padding: 16px 18px; position: relative; overflow: hidden; }
.sprint.current { border-color: var(--accent); }
.sprint.current::before { content: "Đang diễn ra"; display: inline-block; margin-bottom: 6px; font-size: 11px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 2px 8px; border-radius: 999px; }
.sprint .dates { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.sprint h3 { margin: 4px 0 6px; font-size: 16px; line-height: 1.35; }
.sprint p { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.sprint .tlist { display: flex; flex-wrap: wrap; gap: 4px; }
.tchip { font-size: 11.5px; padding: 1px 7px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); cursor: pointer; }
.tchip.done { background: var(--ok-soft); color: var(--ok); border-color: transparent; }

/* ---------- Task filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  font: inherit; font-size: 13px; padding: 5px 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
}
.seg button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.filters select, .filters input {
  font: inherit; font-size: 13px; padding: 6px 10px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); min-width: 0;
}
.filters input { flex: 1 1 180px; }
.count { color: var(--muted); font-size: 13px; margin-left: auto; }

/* ---------- Task cards ---------- */
.tasks { display: grid; gap: 10px; }
details.task { padding: 0; }
details.task > summary { list-style: none; cursor: pointer; padding: 14px 18px; display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; }
details.task > summary::-webkit-details-marker { display: none; }
details.task[open] > summary { border-bottom: 1px solid var(--border); }
.tid { font-family: "JetBrains Mono", ui-monospace, monospace; font-weight: 700; font-size: 13px; color: var(--accent); background: var(--accent-soft); padding: 3px 8px; border-radius: 7px; }
.ttitle { font-weight: 600; line-height: 1.4; }
.tmeta { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.tmeta .who { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.badge { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.badge.done { background: var(--ok-soft); color: var(--ok); }
.badge.open { background: var(--surface-2); color: var(--muted); }
.badge.doing { background: var(--info-soft); color: var(--info); }
.badge.late { background: var(--danger-soft); color: var(--danger); }
.badge.none { background: var(--warn-soft); color: var(--warn); }
.tbody { padding: 16px 18px 18px; display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px 28px; }
.tbody h4 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tbody ul { margin: 0; padding-left: 18px; }
.tbody li { margin: 3px 0; }
.tbody .full { grid-column: 1 / -1; }
.tbody .syllabus { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; }
.tbody .links { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.labels { display: flex; flex-wrap: wrap; gap: 6px; }
.lbl { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 1px 9px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); background: var(--surface-2); }
.lbl .dot { width: 8px; height: 8px; }
.empty { text-align: center; color: var(--muted); padding: 30px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td.chap { font-weight: 600; }
td.chap small { display: block; color: var(--muted); font-weight: 400; }

/* ---------- Design ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rel { display: grid; grid-template-columns: 130px 1fr; gap: 6px 14px; font-size: 14px; }
.rel dt { font-weight: 600; }
.rel dd { margin: 0; color: var(--muted); }
.erd { overflow-x: auto; padding: 12px; }
.erd pre.mermaid { background: none; border: 0; padding: 0; margin: 0; min-width: 640px; text-align: center; }
.erd pre.mermaid svg { max-width: 100%; height: auto; }
.note { font-size: 13px; color: var(--muted); }
.tables-list td:first-child { font-family: "JetBrains Mono", ui-monospace, monospace; font-weight: 600; font-size: 13px; white-space: nowrap; }

/* ---------- Tech / conventions ---------- */
.tech { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tech .card h3 { margin: 0 0 6px; font-size: 15px; }
.tech .card p { margin: 0; color: var(--muted); font-size: 13.5px; }
.steps-list { counter-reset: s; list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.steps-list li { counter-increment: s; display: grid; grid-template-columns: 30px 1fr; gap: 10px; }
.steps-list li::before { content: counter(s); width: 26px; height: 26px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 13px; }

footer { color: var(--muted); font-size: 13px; padding: 40px 0 48px; border-top: 1px solid var(--border); margin-top: 48px; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .members { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sprints { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tech { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .members { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sprints, .grid-2, .tech { grid-template-columns: 1fr; }
  .tbody { grid-template-columns: 1fr; }
  details.task > summary { grid-template-columns: auto 1fr; }
  details.task > summary .badge { grid-column: 2; justify-self: start; }
  .rel { grid-template-columns: 1fr; }
  .rel dd { margin-bottom: 6px; }
  .brand span.txt { display: none; }
  .count { margin-left: 0; width: 100%; }
}
