*{box-sizing:border-box}
body{margin:0;font-family:Arial,sans-serif;background:#f4f7fb;color:#1f2937}
body.mobile-nav-open{overflow:hidden}
a{text-decoration:none}
.app-shell{display:flex;min-height:100vh}
.sidebar{width:280px;flex:0 0 280px;background:#111827;color:#fff;padding:24px 16px;display:flex;flex-direction:column;gap:24px}
.sidebar-backdrop{display:none}
.sidebar-mobile-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px}
.sidebar-close{display:none;border:none;background:rgba(255,255,255,.08);color:#fff;width:40px;height:40px;border-radius:12px;font-size:28px;line-height:1;cursor:pointer}
.brand{display:flex;align-items:center;gap:12px}
.brand-logo{width:48px;height:48px;border-radius:12px;background:#2563eb;display:flex;align-items:center;justify-content:center;font-size:24px}
.brand h2{margin:0;font-size:20px}
.brand p{margin:4px 0 0;color:#9ca3af;font-size:13px}
.sidebar-nav{display:flex;flex-direction:column;gap:8px}
.nav-group{display:grid;gap:8px}
.nav-group + .nav-group{margin-top:8px;padding-top:10px;border-top:1px solid rgba(255,255,255,.08)}
.nav-group-label{padding:0 12px;font-size:11px;font-weight:800;letter-spacing:.08em;text-transform:uppercase;color:#9ca3af}
.nav-link{color:#e5e7eb;padding:12px 14px;border-radius:10px;transition:.2s;display:flex;align-items:center;gap:10px;min-width:0}
.nav-link-icon{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;flex-shrink:0}
.nav-link-icon svg{width:18px;height:18px;stroke:currentColor;stroke-width:1.8;fill:none;stroke-linecap:round;stroke-linejoin:round}
.nav-link > span:last-child{min-width:0;white-space:nowrap}
.nav-link-badge{margin-left:auto;display:inline-flex;align-items:center;justify-content:center;min-width:22px;height:22px;padding:0 7px;border-radius:999px;background:#fef3c7;color:#92400e;font-size:11px;font-weight:800}
.nav-link:hover{background:#1f2937}
.nav-link.is-active{background:linear-gradient(135deg,#2563eb,#1d4ed8);color:#fff;box-shadow:0 10px 20px rgba(37,99,235,.24)}
.nav-link.is-active .nav-link-badge{background:rgba(255,255,255,.18);color:#fff}
.danger-link:hover{background:#7f1d1d}
.main-content{flex:1;padding:24px}
.topbar{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:start;gap:16px;margin-bottom:24px}
.topbar-title{display:flex;align-items:flex-start;gap:14px;flex:1;min-width:0}
.topbar-heading{display:grid;gap:6px;min-width:0}
.topbar h1{margin:0 0 6px;font-size:28px}
.topbar p{margin:0;color:#6b7280}
.topbar-user{justify-self:end;min-width:0}
.mobile-nav-toggle{display:none;flex-direction:column;justify-content:center;gap:5px;width:46px;height:46px;border:none;border-radius:14px;background:#111827;box-shadow:0 8px 18px rgba(15,23,42,.14);cursor:pointer;flex-shrink:0}
.mobile-nav-toggle span{display:block;width:20px;height:2px;margin:0 auto;border-radius:999px;background:#fff}
.student-mobile-shortcuts{display:none}
.student-mobile-shortcut{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:38px;padding:0 12px;border-radius:999px;background:#fff;color:#1f2937;border:1px solid #dbe4f0;font-size:13px;font-weight:700;box-shadow:0 6px 14px rgba(15,23,42,.06)}
.student-mobile-shortcut--primary{background:#eff6ff;border-color:#bfdbfe;color:#1d4ed8}
.student-mobile-shortcut__badge{display:inline-flex;align-items:center;justify-content:center;min-width:20px;height:20px;padding:0 6px;border-radius:999px;background:#1d4ed8;color:#fff;font-size:11px;font-weight:800}
.user-badge{background:#fff;padding:12px 16px;border-radius:14px;box-shadow:0 4px 14px rgba(0,0,0,.06);text-align:right}
.user-badge strong{display:block}
.user-badge span{color:#6b7280;font-size:13px}
.user-badge__mobile{display:none}
.alert{padding:14px 16px;border-radius:12px;margin-bottom:16px;font-weight:600}
.alert-error{background:#fee2e2;color:#991b1b}
.alert-success{background:#dcfce7;color:#166534}
.dashboard-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:16px}
.card{background:#fff;border-radius:16px;padding:20px;box-shadow:0 6px 20px rgba(0,0,0,.05)}
.card h3{margin-top:0}
.btn{display:inline-flex;align-items:center;justify-content:center;border:none;background:#e5e7eb;color:#111827;padding:10px 16px;border-radius:10px;cursor:pointer;font-weight:600}
.btn-primary{background:#2563eb;color:#fff}
.btn-warning{background:#f59e0b;color:#fff}
.btn-danger{background:#dc2626;color:#fff}
.btn-sm{padding:8px 12px;font-size:13px}
.btn-block{width:100%}
.page-actions{margin-bottom:16px}
.form-grid{display:grid;gap:16px}
.form-group label{display:block;margin-bottom:8px;font-weight:700}
.form-group input,.form-group textarea,.form-group select{width:100%;padding:12px 14px;border:1px solid #d1d5db;border-radius:10px;background:#fff;outline:none}
.form-actions{display:flex;gap:12px;flex-wrap:wrap;margin-top:10px}
.table-responsive{overflow-x:auto}
.table{width:100%;border-collapse:collapse}
.table th,.table td{padding:14px 12px;border-bottom:1px solid #e5e7eb;text-align:left;vertical-align:top}
.table th{background:#f9fafb;font-size:14px}
.action-group{display:flex;gap:8px;flex-wrap:wrap}
.badge{display:inline-block;padding:6px 10px;border-radius:999px;font-size:12px;font-weight:700}
.badge-easy{background:#dcfce7;color:#166534}
.badge-medium{background:#fef3c7;color:#92400e}
.badge-hard{background:#fee2e2;color:#991b1b}
.fen-cell{max-width:320px;word-break:break-word;font-family:monospace}
.detail-card{display:grid;gap:14px}
.detail-row{display:grid;grid-template-columns:180px 1fr;gap:12px;padding-bottom:12px;border-bottom:1px solid #eef2f7}
.detail-label{font-weight:700;color:#374151}
.break-all{word-break:break-word}
.text-center{text-align:center}
.auth-page{min-height:100vh;display:grid;place-items:center;padding:24px;background:linear-gradient(135deg,#eff6ff,#f8fafc)}
.auth-card{width:100%;max-width:460px;background:#fff;padding:28px;border-radius:18px;box-shadow:0 10px 30px rgba(0,0,0,.08)}
.auth-note{margin-top:18px;text-align:center}
.solve-layout{display:grid;grid-template-columns:1.1fr .9fr;gap:20px}
.board-box{width:100%;max-width:520px;margin-top:16px}
.solve-tools{display:flex;gap:12px;margin-top:16px;flex-wrap:wrap}
.result-box{min-height:52px;margin-bottom:16px;padding:14px 16px;border-radius:12px;background:#f3f4f6;font-weight:600}
.result-box.success{background:#dcfce7;color:#166534}
.result-box.error{background:#fee2e2;color:#991b1b}
.fen-text{font-family:monospace;word-break:break-word}
.checkbox-list{display:grid;gap:10px;max-height:420px;overflow:auto;padding:8px 0}
.checkbox-item{display:flex;align-items:center;gap:10px;padding:10px 12px;border:1px solid #e5e7eb;border-radius:10px;background:#fff}
.checkbox-item input{width:auto}
.mini-list{display:grid;gap:8px;max-height:280px;overflow:auto;margin-top:12px}
.mini-list-item{padding:10px 12px;border:1px solid #e5e7eb;border-radius:10px;background:#fff}
.progress-wrap{margin:12px 0 16px}
.progress-bar{width:100%;height:14px;background:#e5e7eb;border-radius:999px;overflow:hidden}
.progress-bar-fill{height:100%;width:0%;background:#2563eb;transition:width .25s ease}
.progress-percent-text{margin-top:8px;font-weight:700}
.step-list{display:grid;gap:8px;margin-top:12px}
.step-item{padding:10px 12px;border-radius:10px;border:1px solid #d1d5db;background:#fff}
.step-student{border-left:4px solid #2563eb}
.step-engine{border-left:4px solid #9ca3af}
.step-done{background:#dcfce7;border-color:#86efac}
.step-current{background:#dbeafe;border-color:#60a5fa}
.filter-grid{display:grid;grid-template-columns:repeat(4,minmax(180px,1fr));gap:16px;align-items:end}
@media (max-width:992px){
  .dashboard-grid{grid-template-columns:1fr}
  .main-content{padding:16px}
  .detail-row{grid-template-columns:1fr}
  .topbar{flex-direction:column;align-items:stretch}
  .topbar-title{align-items:flex-start}
  .topbar-heading{width:100%}
  .solve-layout{grid-template-columns:1fr}
  .board-box{max-width:100%}
  .filter-grid{grid-template-columns:1fr}
  .sidebar:not(.sidebar--student-mobile){display:none}
  .sidebar--student-mobile{display:flex;position:fixed;inset:0 auto 0 0;z-index:1200;width:min(86vw,320px);max-width:320px;transform:translateX(-100%);transition:transform .24s ease,box-shadow .24s ease;padding:18px 16px 24px;overflow-y:auto}
  .sidebar--student-mobile.is-open{transform:translateX(0);box-shadow:0 24px 48px rgba(0,0,0,.24)}
  .sidebar--student-mobile .sidebar-close{display:inline-flex;align-items:center;justify-content:center}
  .sidebar--student-mobile .nav-group + .nav-group{margin-top:12px;padding-top:12px}
  .sidebar-backdrop{position:fixed;inset:0;z-index:1190;border:none;background:rgba(15,23,42,.42);padding:0;cursor:pointer}
  .sidebar-backdrop.is-open{display:block}
  .mobile-nav-toggle{display:inline-flex}
  .student-mobile-shortcuts{display:flex;gap:8px;flex-wrap:wrap}
  .user-badge--student{display:flex;align-items:center;justify-content:space-between;gap:10px;text-align:left}
  .user-badge--student strong{font-size:15px}
  .user-badge--student .user-badge__desktop{display:none}
  .user-badge--student .user-badge__mobile{display:block;font-size:12px;line-height:1.35}
}

/* V21-V32 responsive + workspace */
.two-cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stats-grid { display:grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom:16px; }
.stat-card { background:#fff; border-radius:16px; padding:16px; box-shadow:0 10px 25px rgba(15,23,42,.06); }
.stat-label { display:block; color:#64748b; font-size:13px; margin-bottom:6px; }
.bullet-list { padding-left:18px; display:grid; gap:8px; }
.lesson-card { border:1px solid #e2e8f0; border-radius:14px; padding:12px 14px; margin-bottom:12px; }
.filter-card { margin-bottom:16px; }
.filter-grid { display:grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap:10px; }
.filter-grid input, .filter-grid select { width:100%; }
.compact-table td, .compact-table th { font-size:13px; }
.stack-form { display:grid; gap:12px; }
.stack-form textarea, .stack-form input, .stack-form select { width:100%; }
.badge-danger { background:#fee2e2; color:#b91c1c; }
.badge-warning { background:#fef3c7; color:#92400e; }
.badge-medium { background:#e0e7ff; color:#4338ca; }
@media (max-width: 1100px) {
  .stats-grid, .filter-grid, .two-cols { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 760px) {
  .stats-grid, .filter-grid, .two-cols, .dashboard-grid { grid-template-columns: 1fr; }
  .main-content { padding: 14px; }
  .card { border-radius: 14px; }
  .table-responsive { overflow-x: auto; }
  .action-group { flex-wrap: wrap; }
}

cg-board {
  /* background-color: transparent   !important;
  background-image: url('/images/board/svg/brown.svg') !important; */
  /* background-size: cover !important; */
  /* background-repeat: no-repeat !important; */
}

/* ====== BOARD THEME OVERRIDE ====== */

.cg-wrap {
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.25);
}

/* reset nền cũ */
cg-board {
  background: none !important;
  position: absolute;
  inset: 0;
}

/* nền bàn cờ mới */
cg-board::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url('/images/board/svg/brown.svg');
  background-size: cover;
  background-repeat: no-repeat;
  border-radius: inherit;
  z-index: 0;
}


.cg-board cg-board {
    border-radius: 12px;
    overflow: hidden;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    transform: translateZ(0);
}
