:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --success: #16a34a;
  --error: #dc2626;
  --warn: #d97706;
}
* { box-sizing: border-box; }
body {
  margin: 0; padding: 0;
  /* Font emoji phai nam trong stack, khong thi Windows fallback lung tung va emoji
     bi lech baseline / ra o vuong. */
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif,
               'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji';
  background: var(--bg);
  color: var(--text);
}
header {
  padding: 24px 32px 8px;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  color: white;
  position: relative;
}
header h1 { margin: 0; font-size: 22px; }
.subtitle { margin: 4px 0 16px; font-size: 13px; opacity: 0.85; }

.health-badge {
  position: absolute;
  top: 24px; right: 32px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(255,255,255,0.2);
  color: white;
  cursor: help;
  max-width: 380px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.health-badge.ok { background: #16a34a; }
.health-badge.fail { background: #dc2626; }
.tabs {
  display: flex; gap: 4px;
  padding: 0 32px;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  border-bottom: 1px solid #00000020;
  flex-wrap: wrap;
}
.tab {
  background: rgba(255,255,255,0.15);
  color: white;
  border: none;
  padding: 10px 20px;
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}
.tab.active { background: var(--bg); color: var(--text); }

.panel {
  display: none;
  padding: 24px 32px;
  max-width: 1200px;
}
.panel.active { display: block; }
.panel h2 { margin-top: 0; }
.hint { color: var(--muted); font-size: 13px; }

.row {
  display: flex; gap: 12px; align-items: center;
  margin-bottom: 12px; flex-wrap: wrap;
}
.row label { font-size: 13px; font-weight: 500; min-width: 90px; }
input, select, textarea {
  padding: 8px 10px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
}

button {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  background: var(--primary);
  color: white;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
button:hover:not(:disabled) { background: var(--primary-dark); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.danger { background: var(--error); }

.props-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.props-grid .field { display: flex; flex-direction: column; gap: 4px; }
.props-grid label { font-size: 12px; color: var(--muted); }
.props-grid label .req { color: var(--error); }
.props-grid input, .props-grid select { width: 100%; }

/* ===== Manage tab ===== */
.mng-layout { display: flex; gap: 16px; align-items: flex-start; }
.mng-left { flex: 0 0 40%; min-width: 300px; display: flex; flex-direction: column; gap: 10px; }
.mng-right { flex: 1; min-width: 0; }
.mng-search { flex: 1; }

.mng-list {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  max-height: 240px;
  overflow-y: auto;
}
.mng-list-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
}
.mng-list-item:last-child { border-bottom: none; }
.mng-list-item:hover { background: #f1f5f9; }
.mng-list-item.active { background: #ede9fe; color: var(--primary-dark); font-weight: 600; }
.mng-list-item .mid { color: var(--muted); font-size: 11px; font-weight: 400; white-space: nowrap; }
.mng-list-empty { padding: 14px; color: var(--muted); font-size: 13px; }

.mng-graph-wrap {
  border: 1px solid var(--border); border-radius: 8px; background: #fafbff; overflow: hidden;
}
.mng-graph-title { padding: 6px 12px; font-size: 12px; font-weight: 600; border-bottom: 1px solid var(--border); background: #fff; }
.mng-graph { height: 300px; }

.mng-right .mng-empty {
  color: var(--muted); font-size: 14px; padding: 40px 24px; text-align: center;
  border: 1px dashed var(--border); border-radius: 8px;
}
.mng-node-head { display: flex; align-items: baseline; gap: 10px; margin: 4px 0 8px; }
.mng-node-head .badge {
  background: var(--primary); color: #fff; font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 10px;
}

@media (max-width: 860px) {
  .mng-layout { flex-direction: column; }
  .mng-left { flex: 1 1 auto; width: 100%; }
}

.rel-block {
  margin: 8px 0;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.rel-block .row { margin-bottom: 8px; }
.rel-block button.remove { background: var(--error); margin-left: auto; }

.actions { margin: 16px 0; display: flex; gap: 8px; }

.result-box {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--panel);
  border-left: 4px solid var(--border);
  border-radius: 4px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 400px;
  overflow-y: auto;
}
.result-box.ok { border-left-color: var(--success); }
.result-box.err { border-left-color: var(--error); }
.result-box.warn { border-left-color: var(--warn); }

table {
  width: 100%; border-collapse: collapse;
  margin-top: 12px;
  background: var(--panel);
  border-radius: 8px;
  overflow: hidden;
}
th, td {
  padding: 10px 12px;
  text-align: left;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
th { background: #f1f5f9; font-weight: 600; }
.status-pill {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}
.status-committed { background: #dcfce7; color: var(--success); }
.status-pending { background: #fef3c7; color: var(--warn); }
.status-restored { background: #dbeafe; color: #1d4ed8; }
.status-failed { background: #fee2e2; color: var(--error); }

/* Quick Query bar */
.quick-query-bar {
  margin-top: 16px;
  padding: 14px 18px;
  background: #f0f4f8;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
}
.quick-query-bar h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: #334155;
}
.qq-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.qq-row:last-child { margin-bottom: 0; }
.qq-row label {
  min-width: 170px;
  font-size: 13px;
  font-weight: 500;
  color: #475569;
}
.qq-row select {
  flex: 1;
  max-width: 320px;
  padding: 5px 8px;
  border: 1px solid #94a3b8;
  border-radius: 4px;
  font-size: 13px;
}
.qq-row button {
  padding: 5px 16px;
  background: #4f46e5;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
}
.qq-row button:hover { background: #4338ca; }

#viz-canvas {
  width: 100%;
  border-radius: 8px;
  margin-top: 16px;
  overflow: hidden;
}

/* Dark graph canvas — AuraDB style */
#viz-net {
  width: 100%;
  height: 580px;
  background: #1a202c;
  border: 1px solid #2d3748;
  border-radius: 0 0 8px 8px;
}

/* vis-network navigation buttons override */
.vis-navigation .vis-button { filter: invert(1) brightness(0.7); }

/* Legend bar */
.viz-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: #171923;
  border: 1px solid #2d3748;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  font-size: 12px;
  font-family: monospace;
}
.legend-stat { color: #a0aec0; }
.legend-stat strong { color: #e2e8f0; }
.legend-sep { color: #4a5568; margin: 0 2px; }
.legend-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  border: 1.5px solid #718096;
  background: rgba(255,255,255,0.05);
  color: #e2e8f0;
  cursor: default;
}
.legend-pill strong { color: #fff; }
.legend-rel {
  color: #718096;
  font-size: 11px;
}
.legend-rel strong { color: #a0aec0; }

/* vis tooltip override */
.vis-tooltip {
  background: transparent !important;
  border: none !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6) !important;
  padding: 0 !important;
}

/* ========== Graph/Table toggle ========== */
.viz-mode-toggle {
  display: flex;
  border: 2px solid var(--primary);
  border-radius: 6px;
  overflow: hidden;
}
.mode-btn {
  padding: 6px 18px;
  border: none;
  border-radius: 0;
  background: white;
  color: var(--primary);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.mode-btn.active {
  background: var(--primary);
  color: white;
}
.mode-btn:hover:not(.active) { background: #eef2ff; }

/* ========== Viz workspace (graph + detail panel side by side) ========== */
.viz-workspace {
  display: flex;
  gap: 0;
  margin-top: 16px;
}
.viz-main { flex: 1; min-width: 0; }

/* ========== Node detail panel (right side) ========== */
.node-detail-panel {
  width: 340px;
  min-width: 340px;
  background: #1a202c;
  border: 1px solid #2d3748;
  border-left: 3px solid #4f46e5;
  border-radius: 0 8px 8px 0;
  display: flex;
  flex-direction: column;
  max-height: 660px;
  overflow: hidden;
}
.node-detail-panel.hidden { display: none; }
.ndp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #2d3748;
  background: #171923;
}
.ndp-header h3 {
  margin: 0;
  font-size: 14px;
  color: #e2e8f0;
}
.ndp-header button {
  background: transparent;
  color: #a0aec0;
  font-size: 18px;
  padding: 2px 8px;
  border-radius: 4px;
}
.ndp-header button:hover { background: #2d3748; color: #fff; }

#ndp-content {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: #e2e8f0;
}
#ndp-content .hint { color: #718096; }

.ndp-label-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 12px;
}
.ndp-section {
  margin-bottom: 14px;
}
.ndp-section h4 {
  margin: 0 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #63b3ed;
}
.ndp-prop-table {
  width: 100%;
  border-collapse: collapse;
}
.ndp-prop-table td {
  padding: 4px 8px;
  border-bottom: 1px solid #2d3748;
  font-size: 12px;
  vertical-align: top;
}
.ndp-prop-table td:first-child {
  color: #a0aec0;
  width: 100px;
  font-weight: 500;
}
.ndp-prop-table td:last-child { color: #e2e8f0; word-break: break-word; }

.ndp-conn {
  padding: 6px 8px;
  margin-bottom: 4px;
  background: #2d3748;
  border-radius: 4px;
  font-size: 11px;
}
.ndp-conn .conn-type {
  color: #68d391;
  font-weight: 600;
}
.ndp-conn .conn-dir {
  color: #a0aec0;
  font-size: 10px;
}
.ndp-conn .conn-target {
  color: #90cdf4;
}
.ndp-conn-props {
  margin-top: 3px;
  color: #a0aec0;
  font-size: 10px;
}

/* ========== Table view ========== */
.viz-table-container {
  max-height: 580px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.table-section { padding: 16px; }
.table-section h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--primary);
}
.table-section + .table-section {
  border-top: 2px solid var(--border);
}
.viz-table-container table { margin-top: 0; }
.viz-table-container th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef2ff;
  font-size: 12px;
  color: var(--primary-dark);
  white-space: nowrap;
}
.viz-table-container td {
  font-size: 12px;
  font-family: ui-monospace, monospace;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.viz-table-container tr:hover td { background: #f8fafc; }
.viz-table-container tr.table-row-clickable { cursor: pointer; }
.viz-table-container tr.table-row-clickable:hover td { background: #eef2ff; }

/* ========== Export Data tab ========== */
.export-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 16px;
}
@media (max-width: 900px) {
  .export-grid { grid-template-columns: 1fr; }
}

.export-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
}
.export-card h3 {
  margin: 0 0 4px;
  font-size: 15px;
  color: var(--primary-dark);
}
.export-card .hint { margin-top: 0; margin-bottom: 8px; }

.export-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.export-checklist {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}
.export-check-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.export-check-item:hover { border-color: var(--primary); background: #eef2ff; }
.export-check-item input[type="checkbox"] { margin: 0; }
.export-check-item .count {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

.export-preview {
  position: sticky;
  top: 16px;
  align-self: start;
}
.export-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #1e293b;
  border-radius: 8px 8px 0 0;
  border: 1px solid #334155;
  border-bottom: none;
}
.export-preview-header h3 {
  margin: 0;
  font-size: 13px;
  color: #94a3b8;
}
.export-preview-header button {
  padding: 4px 12px;
  font-size: 12px;
  background: #334155;
  color: #e2e8f0;
}
.export-preview-header button:hover { background: #475569; }

.export-output {
  margin: 0;
  padding: 16px;
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-top: none;
  border-radius: 0 0 8px 8px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 520px;
  overflow-y: auto;
  min-height: 200px;
}

/* ========== Roadmap tab ========== */
.roadmap-header h2 {
  margin: 0 0 4px;
  font-size: 24px;
  color: var(--primary-dark);
}
.roadmap-subtitle {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 20px;
  line-height: 1.5;
}

/* --- Thanh thiết lập --- */
.rm-setup {
  padding: 14px 18px;
  margin-bottom: 18px;
  background: linear-gradient(135deg, #eef2ff, #faf5ff);
  border: 1px solid #ddd6fe;
  border-radius: 14px;
}
.rm-setup-row {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.rm-field { min-width: 190px; }
.rm-field-grow { flex: 1; min-width: 240px; }
.rm-field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #4338ca;
  margin-bottom: 5px;
  letter-spacing: 0.01em;
}
.rm-field select {
  width: 100%;
  padding: 9px 10px;
  font-size: 14px;
  border-radius: 9px;
  border: 1px solid #c7d2fe;
  background: #fff;
  color: var(--text);
}
.rm-field select:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.rm-setup-hint {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--error);
}
.rm-setup-hint[hidden] { display: none; }
.roadmap-gen-btn {
  padding: 10px 20px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.1s, box-shadow 0.2s;
}
.roadmap-gen-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}

/* Khung chứa track */
.roadmap-canvas {
  width: 100%;
  min-height: 420px;
  border-radius: 14px;
}

/* Empty state */
.roadmap-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
  background: linear-gradient(180deg, #f0f4ff 0%, #faf5ff 100%);
  border: 2px dashed var(--border);
  border-radius: 12px;
  min-height: 400px;
}
.res-icon { font-size: 56px; margin-bottom: 12px; }
.roadmap-empty-state h3 {
  margin: 0 0 8px;
  font-size: 20px;
  color: var(--text);
}
.roadmap-empty-state p {
  font-size: 15px;
  max-width: 400px;
  line-height: 1.6;
}
.rm-howto {
  max-width: 460px; margin: 4px 0 0; padding-left: 22px;
  text-align: left; font-size: 13.5px; line-height: 1.65; color: var(--muted);
}
.rm-howto li { margin-bottom: 7px; }
.rm-howto strong { color: var(--text); }

/* ===== Hero: tên lộ trình + vòng tiến độ + câu dẫn ===== */
.rm-hero {
  display: flex; flex-wrap: wrap; gap: 20px; align-items: center;
  padding: 18px 22px; margin-bottom: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 5px solid var(--primary);
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(15,23,42,0.05);
}
.rm-hero-id { flex: 1; min-width: 240px; }
.rm-hero-kind {
  display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--primary); background: #eef2ff;
  padding: 3px 9px; border-radius: 999px;
}
.rm-hero-name { margin: 7px 0 0; font-size: 21px; font-weight: 800; color: var(--text); line-height: 1.25; }
.rm-hero-who { margin-top: 5px; font-size: 13px; color: var(--muted); font-weight: 600; }
.rm-hero-line { margin-top: 9px; font-size: 14px; font-weight: 600; color: #4338ca; line-height: 1.45; }
.rm-hero-sub  { font-size: 12.5px; font-weight: 500; color: var(--muted); margin-top: 3px; }
.rm-hero-stats { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 12.5px; color: var(--text); }
.rm-hero-stats b { font-weight: 800; }
.rm-stat { display: inline-flex; align-items: center; gap: 5px; }
.rm-stat i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; font-style: normal; }
.rm-stat i.done { background: #16a34a; }
.rm-stat i.prog { background: #d97706; }
.rm-stat i.todo { background: #94a3b8; }

/* Vòng tròn tiến độ */
.rm-ring { position: relative; width: 104px; height: 104px; flex: 0 0 auto; }
.rm-ring svg { transform: rotate(-90deg); display: block; }
.rm-ring-track { stroke: #e2e8f0; }
.rm-ring-fill  { stroke: url(#rmRingGrad); stroke-linecap: round; transition: stroke-dashoffset 0.8s cubic-bezier(0.4,0,0.2,1); }
.rm-ring-text {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1px;
}
.rm-ring-pct { font-size: 24px; font-weight: 800; color: var(--primary); line-height: 1; }
.rm-ring-cap { font-size: 10.5px; color: var(--muted); font-weight: 700; letter-spacing: 0.03em; }

/* Cảnh báo: vì sao lộ trình xám hết */
.rm-notice {
  margin-top: 10px; padding: 10px 13px;
  background: #fffbeb; border: 1px solid #fcd34d; border-left: 4px solid #d97706;
  border-radius: 9px; font-size: 12.5px; line-height: 1.55; color: #78350f;
}
.rm-notice code {
  padding: 1px 5px; background: #fef3c7; border-radius: 4px;
  font-family: ui-monospace, monospace; font-size: 11.5px;
}

/* CTA khi chưa chọn học viên */
.rm-hero-cta {
  flex: 0 0 auto; max-width: 260px; padding: 12px 14px;
  background: #f8fafc; border: 1px dashed var(--border); border-radius: 10px;
  font-size: 12.5px; color: var(--muted); line-height: 1.5;
}
.rm-hero-cta button {
  margin-top: 7px; padding: 6px 12px; font-size: 12.5px; font-weight: 700;
  border: 1px solid var(--primary); background: #fff; color: var(--primary);
  border-radius: 8px; cursor: pointer;
}
.rm-hero-cta button:hover { background: var(--primary); color: #fff; }

/* ===== Thanh công cụ ===== */
.rm-tools {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  padding: 10px 14px; margin-bottom: 12px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
}
.rm-tools-left, .rm-tools-right { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rm-search {
  width: 210px; padding: 7px 11px; font-size: 13px;
  border: 1px solid var(--border); border-radius: 999px; background: #f8fafc; color: var(--text);
}
.rm-search:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; background: #fff; }
.rm-chip {
  padding: 6px 12px; font-size: 12.5px; font-weight: 700;
  border: 1px solid var(--border); background: #f8fafc; color: var(--muted);
  border-radius: 999px; cursor: pointer; transition: all 0.15s;
}
.rm-chip:hover { border-color: var(--primary); color: var(--primary); }
.rm-chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.rm-tool-btn {
  padding: 6px 11px; font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  border-radius: 8px; cursor: pointer; transition: all 0.15s;
}
.rm-tool-btn:hover { border-color: var(--primary); color: var(--primary); }
.rm-tool-btn.is-on { background: #eef2ff; border-color: var(--primary); color: var(--primary); }
.rm-tools-note { font-size: 12px; color: var(--muted); font-weight: 600; }

/* Huong dan doc lo trinh */
.rm-guide {
  margin: -4px 0 12px;
  padding: 0 14px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.rm-guide summary {
  padding: 10px 0; cursor: pointer;
  font-size: 13px; font-weight: 700; color: var(--primary);
  list-style-position: inside;
}
.rm-guide summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
.rm-guide[open] summary { border-bottom: 1px solid var(--border); }
.rm-guide ul { margin: 10px 0 12px; padding-left: 20px; }
.rm-guide li { font-size: 12.5px; line-height: 1.65; color: var(--text); margin-bottom: 5px; }
.rm-gd-sw {
  display: inline-block; width: 11px; height: 11px; border-radius: 3px;
  margin-right: 3px; vertical-align: -1px;
}
.rm-gd-sw.done { background: #16a34a; }
.rm-gd-sw.prog { background: #d97706; }
.rm-gd-sw.todo { background: #cbd5e1; }
.rm-gd-sw.lock { background: #dc2626; }

/* ===== Track: cột sống + các chặng ===== */
.rm-track {
  position: relative;
  padding: 6px 0 6px 46px;
}
.rm-track::before {
  content: ''; position: absolute; left: 16px; top: 18px; bottom: 30px; width: 2px;
  background: linear-gradient(180deg, #c7d2fe 0%, #ddd6fe 55%, #e2e8f0 100%);
  border-radius: 2px;
}
.rm-links { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1; overflow: visible; }
/* Duong noi giua cac bac: net lien manh, bo goc tron (stroke-linejoin) cho gon gang.
   Truoc day dung net dut + duong cong bezier -> nhieu duong dan vao nhau nhin roi mat. */
.rm-link {
  fill: none; stroke: #cbd5e1; stroke-width: 1.6;
  stroke-linejoin: round; stroke-linecap: round;
  transition: stroke 0.15s, opacity 0.15s, stroke-width 0.15s;
}
.rm-link.is-hot { stroke: #e11d48; stroke-width: 2.4; opacity: 1; }
.rm-track.is-focused .rm-link:not(.is-hot) { opacity: 0.12; }

.rm-stage { position: relative; margin-bottom: 22px; z-index: 2; }
.rm-stage-head {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 8px 12px 8px 4px; background: none; border: none; cursor: pointer;
  text-align: left; border-radius: 10px; transition: background 0.15s;
}
.rm-stage-head:hover { background: #f1f5f9; }
.rm-stage-head:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.rm-stage-idx {
  position: absolute; left: -46px; top: 4px;
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800; color: var(--muted);
  background: #fff; border: 2px solid var(--border);
  transition: all 0.2s;
}
.rm-stage.is-complete .rm-stage-idx { background: #16a34a; border-color: #16a34a; color: #fff; }
.rm-stage.is-current  .rm-stage-idx { background: var(--primary); border-color: var(--primary); color: #fff;
  box-shadow: 0 0 0 4px rgba(79,70,229,0.15); }
.rm-stage-name { font-size: 15px; font-weight: 800; color: var(--text); }
.rm-stage-kind { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.rm-stage-bar { flex: 1; max-width: 200px; height: 6px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.rm-stage-bar i { display: block; height: 100%; background: linear-gradient(90deg, #6366f1, #4f46e5); border-radius: 999px; transition: width 0.6s ease; }
.rm-stage.is-complete .rm-stage-bar i { background: linear-gradient(90deg, #22c55e, #16a34a); }
.rm-stage-count { font-size: 12.5px; font-weight: 700; color: var(--muted); min-width: 46px; }
/* Mui ten thu/mo ve bang border, khong dung glyph (U+25BE lech baseline tren Windows). */
.rm-stage-caret {
  margin-left: auto; width: 0; height: 0;
  border-left: 5px solid transparent; border-right: 5px solid transparent;
  border-top: 6px solid var(--muted);
  transition: transform 0.2s;
}
.rm-stage[aria-expanded="false"] .rm-stage-caret { transform: rotate(-90deg); }
.rm-stage-body { padding-top: 4px; }
.rm-stage-body[hidden] { display: none; }
/* Mang le trai: cho duong noi giua cac bac chay doc ma khong de len the nao. */
.rm-stage.is-tree .rm-stage-body { padding-left: 44px; }
/* 34px = 13 (le) + 2x9 (3 lan) + 3 du — hep hon la duong chay ra ngoai khung. */
@media (max-width: 720px) { .rm-stage.is-tree .rm-stage-body { padding-left: 34px; } }
.rm-stage-empty { padding: 10px 4px; font-size: 12.5px; color: var(--muted); font-style: italic; }

.rm-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 11px; }

/* ---- Nhanh: dau nhanh CHINH LA the ky nang, ben duoi la kien thuc nen ---- */
.rm-branch { margin: 14px 0 6px; max-width: 560px; }
.rm-branch[hidden] { display: none; }
.rm-branch + .rm-branch { padding-top: 14px; border-top: 1px dashed #e2e8f0; }

/* ---- KY NANG vs KIEN THUC: phai tach duoc chi bang cai liec mat ----
   Ky nang = cot moc, phai NANG len: cao hon, nen trang, bo goc vuong hon,
   co dai gay o canh trai. Kien thuc = vat lieu, phai LUI xuong: nho hon,
   nen xam nhat, bo goc tron hon, vien net dut. */
.rm-card-target {
  padding: 15px 16px 15px 15px; border-radius: 12px;
  border-left-width: 6px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(15, 23, 42, .07);
}
.rm-card-target .rm-card-title { font-size: 15px; font-weight: 800; letter-spacing: -.01em; }
/* dai gay doc canh trai — dau hieu "day la cot moc cua nhanh".
   Mau bam theo TRANG THAI, dung cung bang mau voi vien trai. */
.rm-card-target::before {
  content: ''; position: absolute; left: -6px; top: 50%; transform: translateY(-50%);
  width: 6px; height: 28px; border-radius: 3px; background: #cbd5e1;
}
.rm-card-target.is-done::before   { background: #16a34a; }
.rm-card-target.is-prog::before   { background: #d97706; }
.rm-card-target.is-locked::before { background: #dc2626; }
.rm-card-target:hover { box-shadow: 0 6px 20px rgba(15, 23, 42, .12); }

/* Kien thuc: lui hon mot bac de khong tranh cho voi ky nang */
.rm-card.is-know:not(.rm-card-target) {
  padding: 9px 12px 9px 10px; border-radius: 14px;
  background: #fbfcfe; border-left-width: 3px;
}
.rm-card.is-know:not(.rm-card-target) .rm-card-title { font-size: 12.5px; font-weight: 600; }
.rm-card.is-know:not(.rm-card-target) .rm-card-ico { width: 17px; height: 17px; font-size: 10px; }

.rm-branch-dep {
  margin: 7px 0 0 13px; font-size: 11.5px; color: #64748b;
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px;
  padding: 4px 10px; display: inline-block;
}
.rm-branch-needs { margin: 9px 0 0 13px; padding-left: 15px; border-left: 2px dashed #cbd5e1; }
.rm-branch-needs.is-empty {
  border-left-color: #bbf7d0; color: #15803d; font-size: 11.5px; padding: 3px 0 3px 15px;
}
.rm-branch-needs-cap {
  display: block; font-size: 10.5px; font-weight: 800; letter-spacing: .06em;
  color: #94a3b8; text-transform: uppercase; margin-bottom: 7px;
}
.rm-branch-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.rm-step-node { position: relative; }
.rm-step-node[hidden] { display: none; }
.rm-refchip {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font-size: 11.5px; color: #475569; background: #f8fafc;
  border: 1px dashed #cbd5e1; border-radius: 8px; padding: 5px 10px; font-weight: 600;
}
.rm-refchip:hover { background: #f1f5f9; border-color: #94a3b8; }
.rm-refchip span { font-weight: 400; color: #94a3b8; }

/* Mốc "bạn đang ở đây" */
.rm-here {
  display: flex; align-items: center; gap: 10px; margin: 0 0 20px;
}
.rm-here[hidden], .rm-goal[hidden], .rm-stage[hidden], .rm-nomatch[hidden] { display: none; }
.rm-here::before, .rm-here::after {
  content: ''; flex: 1; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, #a5b4fc, transparent);
}
.rm-here span {
  padding: 5px 14px; font-size: 12px; font-weight: 800; letter-spacing: 0.04em;
  color: #fff; background: linear-gradient(135deg, #4f46e5, #7c3aed);
  border-radius: 999px; white-space: nowrap;
  box-shadow: 0 2px 10px rgba(79,70,229,0.3);
}
/* ===== Đích đến — TÁCH HẲN khỏi track, không phải một chặng nữa ===== */
.rm-goal {
  position: relative; display: flex; align-items: center; gap: 16px;
  margin-top: 30px; padding: 20px 22px; border-radius: 16px;
  border: 1px solid #e2e8f0;
  background: linear-gradient(135deg, #f8fafc, #eef2ff);
}
.rm-goal[hidden] { display: none; }
/* đường kẻ ngắt: từ đây trở xuống không còn là việc phải học nữa */
.rm-goal::before {
  content: ''; position: absolute; left: 8%; right: 8%; top: -16px; height: 2px;
  background: repeating-linear-gradient(90deg, #cbd5e1 0 7px, transparent 7px 15px);
}
.rm-goal-medal {
  flex: none; width: 58px; height: 58px; border-radius: 50%; font-size: 27px;
  display: flex; align-items: center; justify-content: center;
  background: #fff; border: 2px solid #e2e8f0;
}
.rm-goal-body { flex: 1; min-width: 0; }
.rm-goal-cap {
  font-size: 10.5px; font-weight: 800; letter-spacing: .1em; color: #94a3b8; text-transform: uppercase;
}
.rm-goal-name { font-size: 18px; font-weight: 800; color: #0f172a; margin-top: 3px; }
.rm-goal-note { font-size: 12.5px; color: #475569; margin-top: 5px; }
.rm-goal-meter { margin-top: 11px; }
.rm-goal-meter-bar { height: 8px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
.rm-goal-meter-bar i {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #6366f1, #22c55e);
  transition: width .5s cubic-bezier(.4, 0, .2, 1);
}
.rm-goal-meter-cap { margin-top: 6px; font-size: 11.5px; color: #64748b; }

/* Cán đích: đổi hẳn tông, có ánh vàng — phải thấy rõ đây là khoảnh khắc khác mọi ngày */
.rm-goal.is-reached {
  border-color: #fcd34d;
  background: linear-gradient(135deg, #fffbeb, #fef3c7);
  box-shadow: 0 6px 26px rgba(245, 158, 11, .22);
}
.rm-goal.is-reached::before {
  background: repeating-linear-gradient(90deg, #fcd34d 0 7px, transparent 7px 15px);
}
.rm-goal.is-reached .rm-goal-medal {
  border-color: #f59e0b; background: #fffdf5;
  animation: rmGoalPop .5s cubic-bezier(.34, 1.56, .64, 1);
}
.rm-goal.is-reached .rm-goal-cap { color: #b45309; }
.rm-goal.is-reached .rm-goal-note { color: #92400e; font-weight: 600; }
@keyframes rmGoalPop {
  0% { transform: scale(.5) rotate(-18deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .rm-goal.is-reached .rm-goal-medal { animation: none; }
  .rm-goal-meter-bar i { transition: none; }
}

/* ===== Card một mục học ===== */
.rm-card {
  position: relative; display: flex; gap: 10px; width: 100%; text-align: left;
  padding: 11px 13px 11px 11px;
  background: var(--panel); border: 1px solid var(--border);
  border-left: 4px solid #cbd5e1; border-radius: 11px; cursor: pointer;
  font: inherit; color: inherit;
  transition: transform 0.12s, box-shadow 0.15s, border-color 0.15s, opacity 0.15s;
}
.rm-card:hover { transform: translateY(-2px); box-shadow: 0 5px 18px rgba(15,23,42,0.09); }
.rm-card:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.rm-card[hidden] { display: none; }
.rm-card.is-done   { border-left-color: #16a34a; background: #f6fdf8; }
.rm-card.is-prog   { border-left-color: #d97706; background: #fffdf5; }
.rm-card.is-todo   { border-left-color: #cbd5e1; }
.rm-card.is-locked { border-left-color: #dc2626; border-color: #fecaca; background: #fffbfb; }
/* Vien trai da danh cho TRANG THAI, nen loai muc phan biet bang net vien + do dam tieu de:
   kien thuc = net dut (thu bo tro), ky nang = net lien, tieu de dam hon (dich can dat). */
.rm-card.is-know { border-top-style: dashed; border-right-style: dashed; border-bottom-style: dashed; }
.rm-card.is-skill .rm-card-title { font-weight: 800; }
.rm-card.is-sel    { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.15); }
.rm-track.is-focused .rm-card:not(.is-hot) { opacity: 0.35; }
.rm-card.is-hot { border-color: #fda4af; }
.rm-card-flash { animation: rmFlash 1.4s ease; }
@keyframes rmFlash {
  0%, 100% { box-shadow: 0 0 0 0 rgba(79,70,229,0); }
  25%      { box-shadow: 0 0 0 5px rgba(79,70,229,0.28); }
}
.rm-card-ico {
  flex: 0 0 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; color: #fff; background: #94a3b8;
}
.rm-card.is-done .rm-card-ico   { background: #16a34a; }
.rm-card.is-prog .rm-card-ico   { background: #d97706; }
.rm-card.is-locked .rm-card-ico { background: #dc2626; }
/* "Dang hoc": cham trang giua vong tron cam — ve bang CSS thay cho ky tu U+25D0. */
.rm-card.is-prog .rm-card-ico::after {
  content: ''; width: 8px; height: 8px; border-radius: 50%; background: #fff;
}
.rm-card-main { flex: 1; min-width: 0; }
.rm-card-title {
  display: block; font-size: 13.5px; font-weight: 700; color: var(--text);
  line-height: 1.35; overflow-wrap: anywhere;
}
.rm-card.is-done .rm-card-title { color: #14532d; }
.rm-card-sub { display: block; margin-top: 3px; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.rm-card-prog { display: flex; align-items: center; gap: 7px; margin-top: 7px; }
.rm-card-bar { display: block; flex: 1; height: 5px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.rm-card-bar i { display: block; height: 100%; border-radius: 999px; background: #d97706; }
.rm-card-pct { flex: none; font-size: 11px; font-weight: 700; color: #b45309; font-variant-numeric: tabular-nums; }
.rm-card.is-done .rm-card-bar i { background: #16a34a; }
.rm-card.is-done .rm-card-pct { color: #15803d; }
.rm-card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.rm-card-lock { display: block; margin-top: 6px; font-size: 11.5px; font-weight: 600; color: #b91c1c; line-height: 1.4; }
.rm-card-res  { display: block; margin-top: 6px; font-size: 11px; color: #0f766e; }
.rm-card-star { position: absolute; top: 8px; right: 9px; font-size: 11px; }

/* Skeleton khi đang tải */
.rm-skel-stage { margin-bottom: 22px; }
.rm-skel-line { height: 14px; width: 180px; border-radius: 6px; margin-bottom: 12px; }
.rm-skel-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 11px; }
.rm-skel-card { height: 84px; border-radius: 11px; }
.rm-skel-line, .rm-skel-card {
  background: linear-gradient(90deg, #eef2f7 25%, #e2e8f0 37%, #eef2f7 63%);
  background-size: 400% 100%;
  animation: rmShimmer 1.3s ease infinite;
}
@keyframes rmShimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* Trạng thái lỗi / rỗng sau khi lọc */
.rm-error {
  padding: 28px 20px; text-align: center; border: 1px solid #fecaca;
  background: #fff5f5; border-radius: 12px; color: #b91c1c;
}
.rm-error button {
  margin-top: 10px; padding: 7px 16px; font-weight: 700; font-size: 13px;
  border: 1px solid #dc2626; background: #fff; color: #dc2626; border-radius: 8px; cursor: pointer;
}
.rm-nomatch { padding: 30px 20px; text-align: center; color: var(--muted); font-size: 14px; }

/* ===== Roadmap dashboard: cây (trái) + panel (phải) ===== */
.roadmap-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 16px;
  align-items: start;
}
@media (max-width: 1024px) {
  .roadmap-dashboard { grid-template-columns: 1fr; }
}
.roadmap-dashboard .roadmap-canvas { min-height: 0; }

/* Panel bên phải */
.roadmap-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
}
@media (max-width: 1024px) {
  .roadmap-panel { position: static; max-height: none; }
}
.rm-panel-who {
  font-size: 13px; font-weight: 600; color: var(--primary-dark);
  padding-bottom: 10px; margin-bottom: 12px; border-bottom: 1px solid var(--border);
}

/* Thanh tiến độ tổng */
.rm-progress { margin-bottom: 14px; }
.rm-progress-top { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.rm-progress-pct { font-size: 30px; font-weight: 800; color: var(--primary); line-height: 1; }
.rm-progress-count { font-size: 13px; color: var(--muted); font-weight: 600; }
.rm-progress-bar { height: 12px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.rm-progress-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #22c55e, #16a34a);
  transition: width 0.6s ease;
}
.rm-dist { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; font-size: 12px; color: var(--text); }
.rm-dist-item { display: flex; align-items: center; gap: 5px; }
.rm-swatch { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.rm-swatch.done { background: #22c55e; }
.rm-swatch.prog { background: #f59e0b; }
.rm-swatch.todo { background: #94a3b8; }

/* Headline động lực */
.rm-headline {
  background: linear-gradient(135deg, #eef2ff, #f5f3ff);
  border: 1px solid #ddd6fe; border-radius: 10px;
  padding: 12px 14px; font-size: 14px; font-weight: 600; color: #4338ca;
  margin-bottom: 14px; line-height: 1.45;
}
.rm-headline-sub { font-size: 12.5px; font-weight: 500; color: #6d28d9; margin-top: 4px; }

.rm-section { margin-bottom: 16px; }
.rm-section h4 {
  margin: 0 0 10px; font-size: 14px; color: var(--text);
  display: flex; align-items: center; gap: 6px;
}

/* --- Panel ở chế độ CHI TIẾT một mục --- */
.rm-back {
  display: inline-flex; align-items: center; gap: 5px; margin-bottom: 12px;
  padding: 5px 11px; font-size: 12.5px; font-weight: 700;
  border: 1px solid var(--border); background: #f8fafc; color: var(--muted);
  border-radius: 999px; cursor: pointer;
}
.rm-back:hover { border-color: var(--primary); color: var(--primary); }
.rm-detail-title { margin: 0 0 4px; font-size: 17px; font-weight: 800; color: var(--text); line-height: 1.3; }
.rm-detail-kind { font-size: 12px; font-weight: 700; color: var(--muted); }
.rm-detail-badges { display: flex; flex-wrap: wrap; gap: 5px; margin: 10px 0; }
.rm-detail-desc {
  font-size: 13px; line-height: 1.55; color: var(--text);
  padding: 10px 12px; background: #f8fafc; border-radius: 9px; margin-bottom: 12px;
}
.rm-detail-desc.muted { color: var(--muted); font-style: italic; }
.rm-detail-row { display: flex; gap: 8px; margin-top: 8px; font-size: 12.5px; align-items: baseline; }
.rm-detail-k { flex: 0 0 96px; color: var(--muted); font-weight: 700; }
.rm-detail-v { flex: 1; color: var(--text); }
.rm-detail-v.muted { color: #94a3b8; }
.rm-linkbtn {
  padding: 3px 9px; margin: 0 4px 4px 0; font-size: 12px; font-weight: 600;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  border-radius: 7px; cursor: pointer;
}
.rm-linkbtn:hover { border-color: var(--primary); color: var(--primary); }
.rm-linkbtn.locked { border-color: #fecaca; color: #b91c1c; background: #fff5f5; }

/* Step cards "Học tiếp theo" */
.rm-step {
  display: flex; gap: 10px; padding: 11px 12px; margin-bottom: 9px; width: 100%;
  text-align: left; font: inherit; cursor: pointer;
  background: #f8fafc; border: 1px solid var(--border); border-radius: 10px;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.rm-step:hover { border-color: var(--primary); box-shadow: 0 2px 10px rgba(79,70,229,0.08); }
.rm-step:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.rm-step-num {
  flex: 0 0 24px; height: 24px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.rm-step-body { flex: 1; min-width: 0; }
.rm-step-title { font-size: 14px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rm-type-tag { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 6px; }
.rm-type-tag.skill { background: #dbeafe; color: #1d4ed8; }
.rm-type-tag.know { background: #d1fae5; color: #047857; }
.rm-step-badges { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0; }
.rm-badge { font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 999px; }
/* Loai muc: ky nang (dac, vien lien) vs kien thuc (rong, vien dut) */
.rm-badge.type.is-skill { background: #e0e7ff; color: #3730a3; }
.rm-badge.type.is-know  { background: #d1fae5; color: #047857; }
.rm-badge.imp-essential { background: #fee2e2; color: #b91c1c; }
.rm-badge.imp-important { background: #fef3c7; color: #b45309; }
.rm-badge.imp-optional  { background: #e2e8f0; color: #475569; }
.rm-badge.ready  { background: #dcfce7; color: #15803d; }
.rm-badge.locked { background: #fee2e2; color: #dc2626; }
.rm-badge.diff   { background: #ede9fe; color: #6d28d9; }
.rm-badge.st-done { background: #dcfce7; color: #15803d; }
.rm-badge.st-prog { background: #fef3c7; color: #b45309; }
.rm-badge.st-todo { background: #e2e8f0; color: #475569; }
.rm-badge.kind    { background: #e0f2fe; color: #0369a1; }
.rm-step-why { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.rm-step-res { font-size: 11.5px; color: #0f766e; }
.rm-step-res.muted { color: #94a3b8; }
.rm-all-done { text-align: center; padding: 20px; font-size: 15px; font-weight: 600; color: #15803d; }

/* ===== Guided Build ===== */
.rb-layout { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
.rb-card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 16px; margin-bottom: 16px;
}
.rb-card h3 { margin: 0 0 12px; font-size: 15px; }
.rb-focus-name { color: var(--primary); }

.rb-side {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 16px; position: sticky; top: 16px;
}
.rb-side h3 { margin: 0 0 4px; font-size: 15px; }
.rb-count { font-weight: 400; font-size: 12px; color: var(--muted); }
.rb-tree { max-height: 420px; overflow-y: auto; margin: 12px 0; }

.rb-node {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px; margin-bottom: 3px; border-radius: 6px;
  border: 1px solid var(--border); background: #fff;
  cursor: pointer; font-size: 12px;
}
.rb-node:hover { border-color: var(--primary); }
.rb-node.focused { border-color: var(--primary); background: #eef2ff; }
.rb-via { color: var(--muted); font-size: 10px; white-space: nowrap; }
.rb-node-label {
  background: #eef2ff; color: var(--primary-dark);
  padding: 1px 6px; border-radius: 4px; font-size: 10px; font-weight: 600;
}
.rb-node-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rb-node-id { color: var(--muted); font-size: 10px; }
.rb-del {
  background: transparent; color: var(--muted); border: none;
  padding: 0 4px; font-size: 15px; line-height: 1; cursor: pointer;
}
.rb-del:hover:not(:disabled) { background: transparent; color: var(--error); }

.rb-sugg { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; overflow: hidden; }
.rb-sugg-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; background: #f8fafc; border-bottom: 1px solid var(--border); font-size: 13px;
}
.rb-arrow { color: var(--primary); font-weight: 700; }
.rb-rel, .rb-child {
  font-size: 10px; padding: 2px 7px; border-radius: 10px; font-weight: 600;
}
.rb-rel { background: #ede9fe; color: #6d28d9; }
.rb-child { background: #dcfce7; color: #15803d; margin-left: auto; }
.rb-sugg-body { padding: 12px; }
.rb-sugg-body .props-grid { margin-bottom: 10px; }
.rb-relprop-title { grid-column: 1/-1; font-size: 11px; font-weight: 600; color: var(--warn); }
.rb-rel-props { border-top: 1px dashed var(--border); padding-top: 10px; }

@media (max-width: 1100px) {
  .rb-layout { grid-template-columns: 1fr; }
  .rb-side { position: static; }
}

/* ===== Guided Build — graph view ===== */
.rb-graph {
  height: 380px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafbfc;
}
.rb-graph-legend {
  display: flex; flex-wrap: wrap; gap: 14px;
  margin-bottom: 8px; font-size: 11px; color: var(--muted);
}
.rb-lg { display: inline-flex; align-items: center; gap: 5px; }
.rb-sw { width: 14px; height: 10px; border-radius: 3px; border: 2px solid; display: inline-block; }
.rb-sw-root  { background: #4f46e5; border-color: #3730a3; }
.rb-sw-exist { background: #fff;    border-color: #94a3b8; }
.rb-sw-draft { background: #dcfce7; border-color: #16a34a; }
.rb-sw-ghost { background: #fef3c7; border-color: #d97706; border-style: dashed; }

.rb-form-box {
  margin-top: 12px;
  border: 2px solid var(--primary);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}
.rb-form-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 10px 12px;
  background: #eef2ff; border-bottom: 1px solid var(--border);
}
.rb-form-head strong { font-size: 14px; }
.rb-form-head .hint { margin-left: 8px; }
.rb-form-close {
  background: transparent; color: var(--muted); border: none;
  font-size: 20px; line-height: 1; padding: 0 4px; cursor: pointer;
}
.rb-form-close:hover:not(:disabled) { background: transparent; color: var(--error); }
#rb-form-body { padding: 12px; }
#rb-form-body .props-grid { margin-bottom: 10px; }

.rb-graph-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 6px;
}
.rb-graph-bar .hint { margin: 0; }
.rb-addrel-btn { font-size: 12px; padding: 6px 12px; white-space: nowrap; }

.rb-rel-hint {
  margin-top: 6px; padding: 8px 12px;
  background: #eef2ff; border-left: 3px solid var(--primary);
  border-radius: 4px; font-size: 12px; font-weight: 500; color: var(--primary-dark);
}
.rb-rel-hint.warn {
  background: #fef3c7; border-left-color: var(--warn); color: #92400e;
}
.rb-graph.rb-picking { border-color: var(--primary); border-width: 2px; cursor: crosshair; }

.rb-draft-graph {
  height: 230px; margin: 8px 0 10px;
  border: 1px solid var(--border); border-radius: 6px; background: #fafbfc;
}
.rb-draft-empty {
  display: flex; align-items: center; justify-content: center;
  height: 100%; font-size: 12px; color: var(--muted);
}

/* ===== Nút phóng to graph toàn màn hình ===== */
.graph-zoom-wrap { position: relative; }
.graph-zoom-btn {
  position: absolute; top: 8px; right: 8px; z-index: 30;
  width: 32px; height: 32px; padding: 0;
  font-size: 16px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.92); color: #334155;
  border: 1px solid var(--border); border-radius: 6px; cursor: pointer;
}
.graph-zoom-btn:hover { background: #fff; border-color: var(--primary); color: var(--primary); }
.graph-zoom-fs {
  position: fixed; inset: 0; z-index: 999;
  background: #fff; padding: 12px;
}
.graph-zoom-fs .rb-graph,
.graph-zoom-fs .rb-draft-graph,
.graph-zoom-fs #viz-net {
  height: 100%; margin: 0;
}
.graph-zoom-fs .graph-zoom-btn { top: 20px; right: 20px; }
.graph-zoom-lock { overflow: hidden; }

/* Fullscreen guided build = workspace: legend / hint / thanh nút / form nổi
   trên graph, thao tác y như ngoài */
.graph-zoom-fs .rb-graph-legend {
  position: absolute; top: 20px; left: 24px; z-index: 25; margin: 0;
  background: rgba(255, 255, 255, 0.95); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px;
}
.graph-zoom-fs .rb-rel-hint {
  position: absolute; top: 64px; left: 24px; z-index: 25;
  max-width: 440px; margin: 0;
}
.graph-zoom-fs .rb-graph-bar {
  position: absolute; bottom: 20px; left: 24px; z-index: 25; margin: 0;
  background: rgba(255, 255, 255, 0.95); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px;
}
.graph-zoom-fs .rb-form-box {
  position: absolute; top: 64px; right: 24px; z-index: 25; margin: 0;
  width: 400px; max-height: calc(100% - 96px); overflow-y: auto;
  background: #fff; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

/* ================= Identity bar + Review workflow ================= */
.identity-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 10px; font-size: 13px;
}
.identity-label { font-weight: 700; color: var(--muted); }
.identity-bar select { padding: 5px 8px; border-radius: 8px; font-size: 13px; }
.identity-current { color: var(--muted); }
.identity-current .warn-text { color: #b45309; font-weight: 600; }
body.role-expert header { box-shadow: inset 0 -3px 0 #f59e0b; }

.review-badge {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px;
  background: #ef4444; color: #fff; border-radius: 999px; font-size: 11px;
  font-weight: 700; text-align: center; line-height: 18px;
}

.expert-note { margin: 10px 0; }
.expert-note label { display: block; font-size: 12px; font-weight: 600; color: #b45309; margin-bottom: 4px; }
.expert-note textarea { width: 100%; border-radius: 8px; padding: 8px; border: 1px solid #fcd34d; background: #fffbeb; }

/* Review layout */
.review-layout { display: grid; grid-template-columns: minmax(0,1fr) 400px; gap: 16px; align-items: start; }
@media (max-width: 1024px) { .review-layout { grid-template-columns: 1fr; } }
.review-filter { align-items: center; gap: 8px; }
.rv-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.rv-item {
  padding: 10px 12px; border: 1px solid var(--border); border-left: 4px solid #94a3b8;
  border-radius: 10px; background: var(--panel); cursor: pointer; transition: box-shadow .15s;
}
.rv-item:hover { box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.rv-item.rv-st-pending  { border-left-color: #f59e0b; }
.rv-item.rv-st-approved { border-left-color: #22c55e; }
.rv-item.rv-st-rejected { border-left-color: #ef4444; }
.rv-item-top { display: flex; justify-content: space-between; font-size: 12px; }
.rv-kind { font-weight: 700; color: var(--primary-dark); }
.rv-status { color: var(--muted); }
.rv-summary { font-size: 14px; font-weight: 600; margin: 4px 0 2px; }
.rv-meta { font-size: 11.5px; color: var(--muted); }

.review-side { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 16px; }
.rv-detail, .rv-experts-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px;
}
.rv-detail-head { display: flex; justify-content: space-between; margin-bottom: 8px; }
.rv-detail-sum { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.rv-note { background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: 8px 10px; margin: 8px 0; font-size: 13px; }
.rv-pl { font-size: 13px; margin: 10px 0; }
.rv-pl ul { margin: 4px 0 10px; padding-left: 18px; }
.rv-pl li { margin: 2px 0; word-break: break-word; }
.rv-pl-json { background: #0f172a; color: #e2e8f0; padding: 10px; border-radius: 8px; font-size: 12px; overflow-x: auto; }
.rv-actions { display: flex; gap: 10px; margin-top: 12px; }
.rv-approve-btn { background: #16a34a; color: #fff; border: none; padding: 9px 16px; border-radius: 9px; font-weight: 700; cursor: pointer; }
.rv-approve-btn:hover { background: #15803d; }
.rv-approve-btn:disabled { opacity: .6; cursor: default; }
.ok-text { color: #15803d; font-size: 12.5px; margin-top: 6px; }
.err-text { color: #dc2626; font-size: 12.5px; margin-top: 6px; }

.rv-experts-card h3 { margin: 0 0 10px; font-size: 15px; }
.rv-expert-add { gap: 6px; margin-bottom: 10px; }
.rv-expert-add input { flex: 1; min-width: 0; padding: 6px 8px; border-radius: 8px; }
.rv-experts { display: flex; flex-direction: column; gap: 6px; }
.rv-exp-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; padding: 4px 0; border-bottom: 1px dashed var(--border); }
.rv-exp-row code { background: #f1f5f9; padding: 1px 5px; border-radius: 5px; font-size: 11px; }
.rv-exp-del { padding: 3px 10px; font-size: 12px; }

/* ================= Login overlay + identity buttons ================= */
.login-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
}
.login-card {
  background: #fff; border-radius: 16px; padding: 32px 28px;
  width: 340px; max-width: 90vw; box-shadow: 0 20px 60px rgba(0,0,0,.3);
  display: flex; flex-direction: column;
}
.login-card h2 { margin: 0 0 4px; font-size: 22px; color: var(--primary-dark); }
.login-sub { margin: 0 0 18px; font-size: 13px; color: var(--muted); }
.login-card label { font-size: 12px; font-weight: 600; color: var(--text); margin: 8px 0 4px; }
.login-card input { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 8px; }
.login-card button {
  margin-top: 18px; padding: 11px; background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff; border: none; border-radius: 10px; font-size: 15px; font-weight: 600; cursor: pointer;
}
.login-card button:disabled { opacity: .6; }
.login-error { color: #fecaca; background: #7f1d1d; margin-top: 12px; padding: 8px 10px;
  border-radius: 8px; font-size: 13px; min-height: 0; }
.login-error:empty { display: none; }

.identity-bar { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 13px; }
.identity-current { color: #fff; }
.identity-current .id-email { opacity: .8; font-size: 12px; }
.idbtn {
  padding: 4px 12px; font-size: 12px; background: rgba(255,255,255,.2);
  color: #fff; border: 1px solid rgba(255,255,255,.35); border-radius: 8px; cursor: pointer;
}
.idbtn:hover { background: rgba(255,255,255,.3); }
body.role-expert header { box-shadow: inset 0 -3px 0 #f59e0b; }

.rv-expert-add { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.rv-expert-add input { flex: 1 1 45%; min-width: 0; padding: 6px 8px; border-radius: 8px; }
.rv-expert-add select { flex: 1 1 45%; min-width: 0; padding: 6px 8px; border-radius: 8px; }
.rv-expert-add select[hidden] { display: none; }
.rv-role-tag {
  font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
  vertical-align: 1px;
}
.rv-role-expert { background: #ede9fe; color: #6d28d9; }
.rv-role-user   { background: #dbeafe; color: #1d4ed8; }
.rv-warn { font-size: 11px; font-weight: 700; color: var(--error); }

/* ================= Giỏ "Lô đề xuất" (batch) ================= */
.batch-panel {
  position: fixed; right: 18px; bottom: 18px; z-index: 500;
  width: 340px; max-width: 92vw; background: #fff;
  border: 2px solid #7c3aed; border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.22); overflow: hidden;
}
.batch-head {
  background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff;
  padding: 10px 14px; font-weight: 700; font-size: 14px; cursor: pointer;
  display: flex; justify-content: space-between; align-items: center;
}
.batch-caret { transition: transform .2s; }
.batch-panel.collapsed .batch-body { display: none; }
.batch-panel.collapsed .batch-caret { transform: rotate(-90deg); }
.batch-body { padding: 12px 14px; }
.batch-list { max-height: 200px; overflow-y: auto; margin-bottom: 10px; }
.batch-op {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  font-size: 13px; padding: 6px 8px; border: 1px solid var(--border);
  border-radius: 8px; margin-bottom: 6px; background: #f8fafc;
}
.batch-rm { background: none; color: #dc2626; padding: 0 6px; font-weight: 700; }
.batch-rm:hover { background: #fee2e2; }
.batch-body textarea { width: 100%; border-radius: 8px; padding: 8px; border: 1px solid #ddd6fe; }
.batch-actions { display: flex; gap: 8px; margin-top: 8px; }
.batch-actions button { flex: 1; }
#batch-submit { background: #16a34a; }
#batch-submit:hover:not(:disabled) { background: #15803d; }

/* ================= "Đề xuất của tôi" ================= */
.myreq-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; max-width: 760px; }
.myreq-item {
  padding: 12px 14px; border: 1px solid var(--border); border-left: 4px solid #94a3b8;
  border-radius: 10px; background: var(--panel);
}
.myreq-item.rv-st-pending  { border-left-color: #f59e0b; }
.myreq-item.rv-st-approved { border-left-color: #22c55e; }
.myreq-item.rv-st-rejected { border-left-color: #ef4444; }
.myreq-note { font-size: 13px; color: var(--muted); margin: 4px 0; }
.myreq-ops { margin: 6px 0; padding-left: 20px; font-size: 13px; }
.myreq-ops li { margin: 2px 0; }
.myreq-resp { margin-top: 8px; padding: 8px 10px; border-radius: 8px; font-size: 13px; font-weight: 600; }
.myreq-resp.ok { background: #dcfce7; color: #15803d; }
.myreq-resp.reject { background: #fee2e2; color: #b91c1c; }

/* ================= Diễn giải thay đổi (op cards trong Review) ================= */
.op-list { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.op-card { border: 1px solid var(--border); border-left: 4px solid #94a3b8; border-radius: 10px; padding: 10px 12px; background: #f8fafc; }
.op-card.op-add    { border-left-color: #22c55e; }
.op-card.op-edit   { border-left-color: #f59e0b; }
.op-card.op-delete { border-left-color: #ef4444; }
.op-title { font-weight: 700; font-size: 13.5px; margin-bottom: 6px; }
.op-sub { font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 4px; }
.op-card ul { margin: 4px 0 6px; padding-left: 18px; font-size: 13px; }
.op-card li { margin: 2px 0; word-break: break-word; }
.op-card code { background: #eef2ff; padding: 0 4px; border-radius: 4px; font-size: 12px; overflow-wrap: anywhere; }
.op-card, .op-del, .op-card li { overflow-wrap: anywhere; word-break: break-word; }
.op-del { font-size: 13px; }
.op-diff { width: 100%; table-layout: fixed; border-collapse: collapse; margin-top: 6px; font-size: 12.5px; }
.op-diff th, .op-diff td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; vertical-align: top;
  overflow-wrap: anywhere; word-break: break-word; }
.op-diff th:first-child, .op-diff td:first-child { width: 90px; }
.op-diff th { background: #eef2ff; font-size: 11.5px; }
.op-diff td.old { color: #b91c1c; text-decoration: line-through; background: #fef2f2; }
.op-diff td.new { color: #15803d; background: #f0fdf4; font-weight: 600; }
.op-diff td.new.del { color: #b91c1c; text-decoration: none; background: #fef2f2; font-weight: 400; }
