* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: -apple-system, "Segoe UI", Roboto, sans-serif; background: #f6f6f3; color: #1f1f1f; }

.app-shell { display: flex; height: 100vh; }

.sidebar { width: 220px; flex: none; background: #1f2430; color: #d8dae0; display: flex; flex-direction: column; padding: 16px 0; }
.sidebar .brand { font-size: 13px; font-weight: 700; color: #fff; padding: 0 18px 16px; border-bottom: 1px solid #333a4a; margin-bottom: 10px; }
.nav-btn { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; background: none; border: none; color: #b6bac6; padding: 12px 18px; font-size: 14.5px; font-weight: 500; cursor: pointer; border-left: 3px solid transparent; }
.nav-btn:hover { background: #262c3a; color: #fff; }
.nav-btn.active { background: #262c3a; color: #fff; border-left-color: #2563eb; font-weight: 600; }
.nav-btn .ico { font-size: 15px; }
.nav-badge { margin-left: auto; background: #dc2626; color: #fff; font-size: 10px; font-weight: 700; border-radius: 999px; padding: 1px 6px; }

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
header { padding: 14px 24px; border-bottom: 1px solid #e5e5e0; background: #fff; display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px; flex: none; }
header h1 { margin: 0; font-size: 16px; }
header .src { font-size: 11.5px; color: #888; }
main.content { padding: 20px 24px 60px; overflow-y: auto; flex: 1; }
.tab-panel { display: none; max-width: 1280px; margin: 0 auto; }
.tab-panel.active { display: block; }

.banner { background: #fff7e6; border: 1px solid #f1d68a; border-radius: 8px; padding: 10px 14px; font-size: 12.5px; color: #6b4c00; margin-bottom: 18px; line-height: 1.6; }
.banner b { color: #8a5c00; }
.banner.info { background: #eef2ff; border-color: #c7d2fe; color: #3730a3; }
.banner.info b { color: #312e81; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 20px; }
.card { background: #fff; border: 1px solid #e5e5e0; border-radius: 10px; padding: 12px 14px; }
.card .num { font-size: 20px; font-weight: 700; }
.card .lbl { font-size: 11.5px; color: #777; margin-top: 2px; }
.card.warn .num { color: #b45309; }
.card.bad .num { color: #b91c1c; }
.card.good .num { color: #166534; }

.mission-bars { background: #fff; border: 1px solid #e5e5e0; border-radius: 10px; padding: 14px 16px; margin-bottom: 20px; }
.mission-bars h2 { font-size: 13px; margin: 0 0 10px; color: #444; }
.mbar-row { display: grid; grid-template-columns: 190px 1fr 46px; align-items: center; gap: 8px; font-size: 12px; margin-bottom: 6px; }
.mbar-track { background: #f0f0eb; border-radius: 5px; height: 14px; overflow: hidden; }
.mbar-fill { height: 100%; background: #2563eb; border-radius: 5px; }
.mbar-fill.role-HERO { background: #dc2626; }
.mbar-fill.role-CORE { background: #2563eb; }
.mbar-fill.role-SUPPORT { background: #7c3aed; }
.mbar-fill.unmapped { background: #d1d5db; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.mode-toggle { display: inline-flex; border: 1px solid #d8d8d2; border-radius: 7px; overflow: hidden; }
.mode-toggle .mode-btn { border: none; background: #fff; padding: 9px 16px; font-size: 14px; font-weight: 600; color: #555; cursor: pointer; }
.mode-toggle .mode-btn + .mode-btn { border-left: 1px solid #d8d8d2; }
.mode-toggle .mode-btn.active { background: #2563eb; color: #fff; }
.toolbar input[type=text] { flex: 1; min-width: 180px; padding: 7px 10px; border: 1px solid #d8d8d2; border-radius: 6px; font-size: 13px; }
.toolbar select { padding: 7px 8px; border: 1px solid #d8d8d2; border-radius: 6px; font-size: 12.5px; background: #fff; }
.toolbar .count { font-size: 12px; color: #777; margin-left: auto; }

.save-bar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid #e5e5e0; border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; }
.save-bar .status { font-size: 12px; color: #777; }
.btn { border: none; border-radius: 7px; padding: 10px 18px; font-size: 14.5px; font-weight: 600; cursor: pointer; }
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:disabled { background: #c7d2fe; cursor: default; }
.btn-primary:not(:disabled):hover { background: #1d4ed8; }

table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #e5e5e0; border-radius: 10px; overflow: hidden; font-size: 12.5px; }
thead th { background: #fafaf7; text-align: left; padding: 8px 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .02em; color: #666; border-bottom: 1px solid #e5e5e0; white-space: nowrap; }
tbody td { padding: 7px 10px; border-bottom: 1px solid #f0f0ea; vertical-align: top; }
tbody tr:hover { background: #fbfbf8; }
tbody tr.flag { background: #fff5f5; }
tbody tr.flag:hover { background: #fdeaea; }
tbody tr.dirty { background: #eef6ff; }
.badge { display: inline-block; font-size: 10.5px; padding: 1px 7px; border-radius: 999px; font-weight: 600; }
.badge.high { background: #dcfce7; color: #166534; }
.badge.medium { background: #fef9c3; color: #854d0e; }
.badge.low { background: #fee2e2; color: #991b1b; }
.badge.flag { background: #fee2e2; color: #991b1b; }
.badge.exclude { background: #e5e7eb; color: #4b5563; }
.badge.yes { background: #dcfce7; color: #166534; }
.badge.no { background: #fee2e2; color: #991b1b; }
select.edit { font-size: 12px; padding: 3px 4px; border: 1px solid #d8d8d2; border-radius: 5px; width: 100%; }
textarea.edit-note { font-size: 12px; padding: 4px 6px; border: 1px solid #d8d8d2; border-radius: 5px; width: 100%; min-height: 32px; resize: vertical; font-family: inherit; }
.note { color: #888; font-size: 11px; }
.num-cell { text-align: right; font-variant-numeric: tabular-nums; }

.guide-jump { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; position: sticky; top: 0; z-index: 4; background: #f6f6f3; padding: 4px 0; }
.guide-jump button { border: 1px solid #d8d8d2; background: #fff; border-radius: 999px; padding: 6px 13px; font-size: 12px; font-weight: 600; color: #333; cursor: pointer; }
.guide-jump button:hover { background: #eef2ff; border-color: #c7d2fe; color: #312e81; }
.loctype-card { display: inline-block; border: 1px solid #e5e5e0; border-radius: 8px; padding: 8px 12px; margin: 0 8px 8px 0; font-size: 12px; background: #fafaf7; }
.loctype-card b { display: block; font-size: 12.5px; margin-bottom: 2px; }
.guide-block { background: #fff; border: 1px solid #e5e5e0; border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
.guide-block h2 { font-size: 21px; font-weight: 800; margin: 0 0 14px; color: #1d4ed8; text-decoration: underline; text-decoration-thickness: 2.5px; text-underline-offset: 5px; text-decoration-color: #93c5fd; }
.guide-block h3 { font-size: 15.5px; font-weight: 700; color: #1e293b; }
.guide-block .cluster-header { font-size: 15px; font-weight: 700; color: #fff; background: #475569; padding: 8px 14px; border-radius: 6px; margin: 4px 0; }
.guide-block p { font-size: 12.5px; line-height: 1.7; color: #444; margin: 0 0 8px; }
.guide-block table { font-size: 14.5px; }
.guide-block td, .guide-block th { padding: 10px 12px; line-height: 1.6; }
.guide-block thead th { font-size: 12px; }
.guide-block .note { font-size: 14.5px; color: #555; }
.guide-block p.note { font-size: 13px; }
.role-chip { display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: 11px; font-weight: 700; color: #fff; margin-right: 6px; }
.role-chip.HERO { background: #dc2626; }
.role-chip.CORE { background: #2563eb; }
.role-chip.SUPPORT { background: #7c3aed; }
.role-chip.DISCOVERY { background: #059669; }
.role-chip.OUT { background: #9ca3af; }
.v2-warn { background: #fff7ed; border: 1px solid #fdba74; border-radius: 8px; padding: 10px 14px; margin: 10px 0; font-size: 13.5px; }
.v2-tag { display:inline-block; font-size:10px; font-weight:700; padding:1px 6px; border-radius:4px; margin-left:6px; vertical-align:middle; }
.v2-tag.new { background:#dcfce7; color:#166534; }
.v2-tag.renamed { background:#e0e7ff; color:#3730a3; }

.todo-section { background: #fff; border: 1px solid #e5e5e0; border-radius: 10px; padding: 14px 16px; margin-bottom: 18px; }
.todo-section h2 { font-size: 13px; margin: 0 0 4px; }
.todo-section .sub { font-size: 11.5px; color: #888; margin-bottom: 10px; }

.badge.DRAFT { background: #fef9c3; color: #854d0e; }
.badge.APPROVED { background: #dcfce7; color: #166534; }
.sp-section { background: #fff; border: 1px solid #e5e5e0; border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
.sp-section h2 { font-size: 14px; margin: 0 0 4px; }
.sp-section .sub { font-size: 12px; color: #888; margin-bottom: 12px; }
.sp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 16px; }
.sp-field { display: flex; flex-direction: column; gap: 4px; }
.sp-field.wide { grid-column: 1 / -1; }
.sp-field label { font-size: 12px; font-weight: 600; color: #333; }
.sp-field input, .sp-field select, .sp-field textarea { padding: 7px 9px; border: 1px solid #d8d8d2; border-radius: 6px; font-size: 13px; font-family: inherit; }
.sp-field textarea { min-height: 60px; resize: vertical; }
.sp-field .hint { font-size: 12px; color: #7a6a3f; background: #fffaf0; border-left: 3px solid #f1d68a; padding: 6px 9px; border-radius: 4px; line-height: 1.55; margin: 2px 0 6px; }
.sp-fixture-row, .sp-mission-row { display: grid; grid-template-columns: 1.4fr 1fr 0.8fr auto; gap: 8px; align-items: center; margin-bottom: 6px; }
.sp-fixture-row input { padding: 6px 8px; border: 1px solid #d8d8d2; border-radius: 5px; font-size: 12.5px; }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-danger:hover { background: #fecaca; }
.btn-ghost { background: #f0f0ec; color: #333; }
.btn-ghost:hover { background: #e5e5e0; }
#spListTbody tr { cursor: pointer; }
#spListTbody tr:hover { background: #f7f7f5; }
.checkbox-group { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; border: 1px solid #d8d8d2; border-radius: 6px; background: #fff; max-height: 130px; overflow-y: auto; }
.checkbox-group label { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 400; background: #f5f5f2; padding: 4px 8px; border-radius: 5px; cursor: pointer; white-space: nowrap; }
.checkbox-group input { width: auto; margin: 0; }
.sp5-thead th { font-size: 13.5px !important; font-weight: 800 !important; color: #111 !important; background: #eef2ff; }
.sp-lm-box { background: #fff; border: 1px solid #e5e5e0; border-radius: 8px; padding: 14px 16px; margin-bottom: 16px; }
.sp-lm-box h3 { font-size: 17px; font-weight: 800; margin: 0 0 8px; color: #111; }
.sp-lm-result { margin-top: 10px; background: #ecfdf5; border: 1px solid #6ee7b7; border-radius: 6px; padding: 8px 12px; font-size: 13px; font-weight: 600; color: #065f46; }
.sp-benchmark-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.sp-benchmark-table th { text-align: center; font-size: 12px; font-weight: 800; color: #1e293b; padding: 8px; border-bottom: 2px solid #d8d8d2; }
.sp-benchmark-table th:first-child { text-align: left; }
.sp-benchmark-table td { padding: 7px 8px; border-bottom: 1px solid #f0f0ec; text-align: center; }
.sp-benchmark-table td:first-child { text-align: left; font-size: 14.5px; font-weight: 700; color: #111; }
.sp-benchmark-table input { width: 80px; padding: 4px 6px; border: 1px solid #d8d8d2; border-radius: 4px; font-size: 12.5px; text-align: center; }

/* Man hinh hep (dien thoai) - sidebar 220px co dinh chiem gan nua man
   hinh, doi sang thanh dieu huong ngang cuon duoc o tren, noi dung xuong
   duoi chiem full-width. */
@media (max-width: 720px) {
  .app-shell { flex-direction: column; height: auto; min-height: 100vh; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 8px 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .sidebar .brand { display: none; }
  .sidebar nav { display: flex; flex-direction: row; gap: 2px; padding: 0 8px; }
  .nav-btn { width: auto; white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; padding: 8px 12px; }
  .nav-btn.active { border-left-color: transparent; border-bottom-color: #2563eb; }
  .main-area { overflow: visible; }
  header { padding: 10px 14px; }
  main.content { padding: 14px 14px 40px; }
  .sp-grid { grid-template-columns: 1fr; }
  .sp-fixture-row { grid-template-columns: 1fr; }
}
