:root{
  --bg:#f4f7fb;
  --card:#ffffff;
  --text:#0f172a;
  --muted:#64748b;
  --border:#e2e8f0;
  --shadow: 0 10px 25px rgba(2,6,23,.08);
  --r:16px;
  --brand:#2563eb;
  --brand2:#1e88e5;
  --ok:#16a34a;
}
*{box-sizing:border-box}
body{margin:0; font-family:system-ui, -apple-system, Segoe UI, Roboto, Arial; background:var(--bg); color:var(--text)}
a{color:inherit; text-decoration:none}
.container{max-width:1200px; margin:18px auto; padding:0 14px;}
.card{background:var(--card); border:1px solid var(--border); border-radius:var(--r); box-shadow:var(--shadow); padding:14px;}
.topbar{
  position:sticky; top:0; z-index:20;
  display:flex; justify-content:space-between; align-items:center;
  padding:12px 14px; background:#fff; border-bottom:1px solid var(--border);
}
.brand{font-weight:800}
.actions{display:flex; gap:10px; align-items:center}
.btn{
  display:inline-flex; align-items:center; justify-content:center;
  padding:10px 12px; border-radius:12px; border:1px solid var(--border);
  background:linear-gradient(180deg, rgba(37,99,235,.12), rgba(37,99,235,.06));
  cursor:pointer; font-weight:700;
}
.btn:hover{filter:brightness(.98)}
.btn.ghost{background:#fff}
.btn.small{padding:8px 10px; border-radius:12px; font-weight:700}
.muted{color:var(--muted)}
.alert{padding:10px 12px; border:1px solid #fecaca; background:#fff1f2; border-radius:12px; color:#991b1b; margin:10px 0}
.form label{display:block; font-weight:700; margin:8px 0 6px}
input, textarea, select{
  width:100%; padding:10px 12px; border-radius:12px;
  border:1px solid var(--border); outline:none;
}
input:focus, textarea:focus, select:focus{border-color:rgba(37,99,235,.5); box-shadow:0 0 0 4px rgba(37,99,235,.12)}
.grid2{display:grid; grid-template-columns:1fr 1fr; gap:14px}
@media(max-width:980px){.grid2{grid-template-columns:1fr}}

.table{width:100%; border-collapse:separate; border-spacing:0 8px}
.table th{font-size:12px; color:var(--muted); text-align:left; padding:0 8px}
.table td{background:#fff; border:1px solid var(--border); padding:10px 8px}
.table tr td:first-child{border-top-left-radius:12px;border-bottom-left-radius:12px}
.table tr td:last-child{border-top-right-radius:12px;border-bottom-right-radius:12px}

.chip{display:inline-flex; padding:4px 10px; border-radius:999px; border:1px solid var(--border); font-size:12px; color:var(--muted); background:#fff}
.chip.ok{color:var(--ok); border-color:rgba(22,163,74,.25); background:rgba(22,163,74,.08)}

.map-layout{display:grid; grid-template-columns:360px 1fr; gap:14px; align-items:start}
@media(max-width:1100px){.map-layout{grid-template-columns:1fr}}

.sidebar .row{display:flex; gap:10px; align-items:center}
.sidebar .mini{display:block; font-size:12px; color:var(--muted); margin-bottom:4px; font-weight:700}
.hint{margin:12px 0; padding:10px; border:1px dashed var(--border); border-radius:12px; color:var(--muted); font-size:13px; line-height:1.35}

.subject-list{display:flex; flex-direction:column; gap:10px; margin-top:12px; max-height:65vh; overflow:auto; padding-right:4px}
.subject-item{
  border:1px solid var(--border); border-radius:14px;
  padding:10px; background:#fff;
  display:flex; flex-direction:column; gap:6px;
  cursor:grab;
}
.subject-item:active{cursor:grabbing}
.subject-top{display:flex; justify-content:space-between; gap:10px; align-items:flex-start}
.subject-code{font-weight:800}
.subject-name{font-weight:700}
.badge{font-size:12px; color:var(--muted); border:1px solid var(--border); padding:3px 8px; border-radius:999px}
.badge.cat-CHUNG{background:rgba(37,99,235,.08)}
.badge.cat-COSO{background:rgba(14,165,233,.08)}
.badge.cat-CHUYENNGANH{background:rgba(245,158,11,.10)}
.badge.cat-TUYCHON{background:rgba(34,197,94,.10)}

.canvas{position:relative; min-height:78vh; overflow:hidden}
.canvas-head{display:flex; justify-content:space-between; align-items:center; margin-bottom:10px}
.zones-wrap{
  display:grid;
  grid-template-columns:repeat(2, minmax(320px, 1fr));
  gap:12px;
}
@media(max-width:1200px){.zones-wrap{grid-template-columns:1fr}}
.zone{
  position:relative;
  border:1px solid var(--border);
  border-radius:14px;
  min-height:220px;
  background:linear-gradient(180deg, rgba(2,6,23,.02), rgba(2,6,23,.00));
  overflow:hidden;
}
.zone-head{
  padding:10px 12px;
  display:flex; justify-content:space-between; align-items:center;
  border-bottom:1px solid var(--border);
  background:#fff;
}
.zone-title{font-weight:900}
.zone-body{
  position:relative;
  height:220px;
}
.zone-drop-hint{
  position:absolute; inset:10px;
  border:1px dashed rgba(100,116,139,.35);
  border-radius:12px;
  display:flex; align-items:center; justify-content:center;
  color:var(--muted);
  pointer-events:none;
}

.card-node{
  position:absolute;
  width:210px;
  border:1px solid var(--border);
  border-radius:14px;
  background:#fff;
  box-shadow:0 10px 18px rgba(2,6,23,.08);
  padding:10px;
  cursor:grab;
  user-select:none;
}
.card-node:active{cursor:grabbing}
.card-node.selected{outline:3px solid rgba(37,99,235,.25)}
.node-title{font-weight:900}
.node-sub{font-size:12px; color:var(--muted); margin-top:4px; display:flex; gap:8px; flex-wrap:wrap}

.tooltip{
  position:fixed;
  max-width:360px;
  background:#0f172a;
  color:#fff;
  padding:10px 12px;
  border-radius:12px;
  font-size:13px;
  box-shadow:0 10px 25px rgba(2,6,23,.35);
  z-index:9999;
}
.tooltip b{color:#fff}
.svg-overlay{
  position:absolute; inset:0;
  pointer-events:none;
}
.edge-hit{
  pointer-events:auto;
  cursor:pointer;
}