/* ── Google Fonts ────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

/* ── Reset & Variables ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-base:      #0a0e14;
  --bg-surface:   #111820;
  --bg-elevated:  #1a2230;
  --bg-overlay:   #222d3a;

  --border-faint: rgba(48,64,80,.55);
  --border-soft:  #1e2d3d;
  --border-mid:   #2e4055;

  --text-primary:   #e2eaf4;
  --text-secondary: #7a90a8;
  --text-muted:     #3d5068;

  --accent:       #4d9fff;
  --accent-dim:   rgba(77,159,255,.13);
  --green:  #2ea84a;
  --red:    #f04f45;

  --font-ui:   'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-lg: 0 20px 56px rgba(0,0,0,.75);
  --shadow-md: 0 6px 24px rgba(0,0,0,.5);

  /* CMMI heat colors (N1-N5, escala 0-100) */
  --color-nodata: #2e4055;
  --color-n1:     #ef4444;   /* 0-20  Inicial */
  --color-n2:     #f97316;   /* 21-40 Gestionado */
  --color-n3:     #fbbf24;   /* 41-60 Definido */
  --color-n4:     #a3e635;   /* 61-80 Cuantitativamente Gestionado */
  --color-n5:     #16a34a;   /* 81-100 En Optimización */

  /* legacy aliases — kept for backward compat */
  --radius: var(--radius-md);
  --shadow: var(--shadow-md);
}

html {
  font-size: 14px;
}

body {
  font-family: var(--font-ui);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ──────────────────────────────────────────────────────────────── */
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p  { color: var(--text-secondary); }

/* ── Layout ──────────────────────────────────────────────────────────────────── */
.app-container { display: flex; flex-direction: column; min-height: 100vh; }

/* ── Topbar ──────────────────────────────────────────────────────────────────── */
.topbar {
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1.5rem;
  background: linear-gradient(180deg, #131c27 0%, var(--bg-surface) 100%);
  border-bottom: 1px solid var(--border-soft);
  box-shadow: 0 1px 0 rgba(77,159,255,.08), 0 4px 24px rgba(0,0,0,.4);
  position: sticky;
  top: 0;
  z-index: 100;
  position: relative;
}

/* Accent line top */
.topbar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, #1a4a8a 15%, #4d9fff 45%, #60c0ff 55%, #1a9fff 75%, transparent 100%);
  opacity: .9;
}
/* Subtle bottom glow */
.topbar::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(77,159,255,.18) 40%, rgba(77,159,255,.18) 60%, transparent 100%);
}

/* ── Brand ── */
.brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 700;
  font-size: .95rem;
  letter-spacing: .02em;
  flex-shrink: 0;
}
.brand:hover { opacity: .85; }

.brand-mark {
  width: 30px; height: 30px;
  background: linear-gradient(145deg, #0d2d55 0%, #1453a0 50%, #4d9fff 100%);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  box-shadow: 0 0 0 1px rgba(77,159,255,.35), 0 0 18px rgba(77,159,255,.25), 0 2px 8px rgba(0,0,0,.4);
}

/* ── Topbar legacy brand (kept for heatmap.html .topbar-brand) ── */
.topbar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  text-decoration: none;
  letter-spacing: .02em;
}

.topbar-brand .shield {
  width: 28px;
  height: 28px;
  background: linear-gradient(145deg, #0d2d55 0%, #1453a0 50%, #4d9fff 100%);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  box-shadow: 0 0 0 1px rgba(77,159,255,.35), 0 0 12px rgba(77,159,255,.2);
}

/* ── Topbar divider ── */
.topbar-divider {
  width: 1px; height: 18px;
  background: var(--border-soft);
  flex-shrink: 0;
}

/* ── Nav ── */
.topbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 0;
}

.topbar-nav a {
  display: flex;
  align-items: center;
  gap: .3rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: .85rem;
  font-weight: 500;
  padding: .35rem .85rem;
  border-radius: var(--radius-sm);
  transition: color .15s, background .15s;
  white-space: nowrap;
  position: relative;
}

.topbar-nav a:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.topbar-nav a.active {
  color: var(--accent);
  background: rgba(77,159,255,.12);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(77,159,255,.15);
}

.topbar-nav a.active::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 15%; right: 15%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  border-radius: 2px 2px 0 0;
  opacity: .9;
}

.topbar-spacer { flex: 1; }

/* ── Topbar right ── */
.topbar-right {
  display: flex;
  align-items: center;
  gap: .85rem;
  font-size: .82rem;
  color: var(--text-secondary);
}

/* ── Live badge ── */
.live-badge {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: #3dd68c;
  background: rgba(46,168,74,.1);
  border: 1px solid rgba(46,168,74,.28);
  border-radius: 20px;
  padding: .25rem .7rem;
  box-shadow: 0 0 12px rgba(46,168,74,.08);
}

.live-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #3dd68c;
  box-shadow: 0 0 6px #3dd68c, 0 0 14px rgba(61,214,140,.5);
  animation: pulse 2.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

/* ── Avatar ── */
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--bg-elevated), var(--bg-overlay));
  border: 1px solid var(--border-mid);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem;
  color: var(--text-secondary);
  box-shadow: 0 0 0 1px rgba(77,159,255,.1);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: .55rem;
  color: var(--text-secondary);
  font-size: .85rem;
}

.btn-logout {
  background: none;
  border: 1px solid var(--border-soft);
  color: var(--text-muted);
  font-size: .78rem;
  font-family: var(--font-ui);
  padding: .28rem .7rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .15s;
  letter-spacing: .02em;
}
.btn-logout:hover {
  border-color: rgba(239,68,68,.4);
  color: #f87171;
  background: rgba(239,68,68,.07);
}

/* ── Main content ─────────────────────────────────────────────────────────────── */
.main { flex: 1; padding: 1.5rem 2rem; width: 100%; }

/* ── Page header ──────────────────────────────────────────────────────────────── */
.page-header {
  margin-bottom: 1.5rem;
  position: relative;
  padding-left: 1rem;
}
.page-header::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent) 0%, rgba(77,159,255,.3) 100%);
  border-radius: 3px;
  box-shadow: 0 0 8px rgba(77,159,255,.4);
}
.page-header-text {
  display: flex;
  flex-direction: column;
  gap: .08rem;
}
.page-header-framework {
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: .75;
}
.page-header-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: .01em;
  line-height: 1.2;
}

/* ── Cards ───────────────────────────────────────────────────────────────────── */
.card {
  background: linear-gradient(160deg, var(--bg-elevated) 0%, rgba(14,20,30,.95) 100%);
  border: 1px solid var(--border-soft);
  border-top: 1px solid rgba(77,159,255,.2);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: 0 0 0 1px var(--border-soft), inset 0 1px 0 rgba(77,159,255,.04);
}

/* ── Breadcrumb ──────────────────────────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: 1rem;
  font-size: .85rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
}
.breadcrumb-item {
  cursor: pointer;
  color: var(--accent);
  transition: color .15s;
}
.breadcrumb-item:hover { color: #3a8fe8; }
.breadcrumb-item.current { color: var(--text-primary); cursor: default; }
.breadcrumb-sep { color: var(--border-mid); }

/* ── Heat Map ────────────────────────────────────────────────────────────────── */
.heatmap-stats {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.stat-card {
  flex: 1;
  min-width: 140px;
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 1rem;
}
.stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}
.stat-card .stat-label {
  font-size: .78rem;
  color: var(--text-secondary);
  margin-top: .25rem;
}

.heatmap-container { margin-bottom: 1.5rem; }

.heatmap-level-title {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-secondary);
  margin-bottom: .75rem;
}

.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: .75rem;
}

.heatmap-cell {
  border-radius: var(--radius-md);
  padding: 1rem;
  cursor: pointer;
  position: relative;
  transition: transform .15s, box-shadow .15s;
  border: 2px solid transparent;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}
.heatmap-cell:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  border-color: rgba(255,255,255,.2);
}
.heatmap-cell.no-data { background: var(--color-nodata); }
.heatmap-cell.n1      { background: var(--color-n1); }
.heatmap-cell.n2      { background: var(--color-n2); }
.heatmap-cell.n3      { background: var(--color-n3); color: #1a2230; }
.heatmap-cell.n4      { background: var(--color-n4); color: #1a2230; }
.heatmap-cell.n5      { background: var(--color-n5); color: #fff; }

.heatmap-cell .cell-code {
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .05em;
  opacity: .85;
}
.heatmap-cell .cell-name {
  font-size: .8rem;
  font-weight: 600;
  line-height: 1.3;
  margin-top: .25rem;
}
.heatmap-cell .cell-value {
  margin-top: .5rem;
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1;
}
.heatmap-cell .cell-meta {
  font-size: .7rem;
  opacity: .75;
  margin-top: .25rem;
}
.heatmap-cell .cell-badge {
  position: absolute;
  top: .5rem;
  right: .5rem;
  background: rgba(0,0,0,.2);
  border-radius: 4px;
  padding: .1rem .35rem;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .03em;
}

.heatmap-cell.selected {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

/* Subcategory cells (smaller) */
.heatmap-cell.sub {
  min-height: 80px;
  cursor: pointer;
}
.heatmap-cell.sub:hover .cell-edit-btn { opacity: 1; }
.cell-edit-btn {
  position: absolute;
  bottom: .4rem;
  right: .4rem;
  opacity: 0;
  background: rgba(0,0,0,.3);
  border: none;
  color: white;
  border-radius: 4px;
  padding: .15rem .4rem;
  font-size: .7rem;
  cursor: pointer;
  transition: opacity .15s, background .15s;
}
.cell-edit-btn:hover { background: rgba(0,0,0,.5); }

/* Legend */
.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  flex-wrap: wrap;
  font-size: .78rem;
  color: var(--text-secondary);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: .4rem;
}
.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ── Data table ──────────────────────────────────────────────────────────────── */
.filters {
  display: flex;
  gap: .75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  align-items: flex-end;
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.filter-group label {
  font-size: .75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.filter-group select,
.filter-group input {
  background: var(--bg-base);
  border: 1px solid var(--border-soft);
  color: var(--text-primary);
  border-radius: 6px;
  padding: .45rem .75rem;
  font-size: .85rem;
  font-family: var(--font-ui);
  min-width: 160px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.filter-group select:focus,
.filter-group input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(77,159,255,.12);
}
.filter-group input[type=text] { min-width: 220px; }
.filter-group input::placeholder { color: var(--text-secondary); }

.btn-reset {
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  color: var(--text-secondary);
  padding: .45rem .9rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: .85rem;
  font-family: var(--font-ui);
  font-weight: 500;
  letter-spacing: .02em;
  align-self: flex-end;
  transition: background .15s, color .15s, box-shadow .15s;
}
.btn-reset:hover {
  color: var(--text-primary);
  background: var(--border-mid);
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
thead th {
  background: var(--bg-elevated);
  padding: .7rem 1rem;
  text-align: left;
  font-size: .75rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
tbody tr {
  border-bottom: 1px solid var(--border-faint);
  transition: background .1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-elevated); }
.btn-icon-del { color: var(--color-n1); border-color: var(--color-n1); }
.btn-icon-del:hover { background: var(--color-n1) !important; border-color: var(--color-n1) !important; color: white !important; }
tbody td {
  padding: .65rem 1rem;
  vertical-align: middle;
}
.td-code {
  font-family: var(--font-mono);
  font-size: .8rem;
  font-weight: 600;
  color: var(--accent);
}
.td-code span, .td-code {
  background: rgba(77,159,255,.08);
  padding: .15rem .4rem;
  border-radius: 3px;
  display: inline-block;
}
.td-desc {
  max-width: 300px;
  color: var(--text-secondary);
  font-size: .82rem;
  line-height: 1.4;
}
.td-kri { max-width: 220px; font-size: .82rem; }
.td-value { text-align: center; font-weight: 700; }
.td-date  { color: var(--text-secondary); font-size: .8rem; }
.td-actions { text-align: center; white-space: nowrap; min-width: 90px; }

.kri-badge {
  display: inline-block;
  padding: .2rem .5rem;
  border-radius: 5px;
  font-size: .75rem;
  font-weight: 700;
  color: white;
}
.kri-badge.no-data { background: var(--color-nodata); }
.kri-badge.n1      { background: var(--color-n1); }
.kri-badge.n2      { background: var(--color-n2); }
.kri-badge.n3      { background: var(--color-n3); color: #1a2230; }
.kri-badge.n4      { background: var(--color-n4); color: #1a2230; }
.kri-badge.n5      { background: var(--color-n5); color: #fff; }

.no-data-text { color: var(--text-secondary); font-style: italic; font-size: .8rem; }

.btn-ex-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: .8rem;
  cursor: pointer;
  padding: .2rem .3rem;
  border-radius: 4px;
  text-decoration: underline;
  transition: color .15s, background .15s;
  white-space: nowrap;
}
.btn-ex-link:hover  { color: #3a8fe8; background: rgba(77,159,255,.1); }
.btn-ex-link:disabled { color: var(--text-secondary); text-decoration: none; cursor: default; }

.btn-icon {
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  color: var(--text-secondary);
  width: 30px;
  height: 30px;
  border-radius: 6px;
  cursor: pointer;
  font-size: .85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-icon:hover            { background: var(--accent); border-color: var(--accent); color: white; }
.btn-icon.btn-delete:hover { background: var(--color-critical); border-color: var(--color-critical); }
.btn-icon.btn-icon-add     { color: var(--accent); border-color: var(--accent); font-size: 1.1rem; }
.btn-icon.btn-icon-add:hover { background: var(--accent); color: white; }

.table-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
}

/* ── Modal ───────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  backdrop-filter: blur(4px);
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-top: 2px solid rgba(77,159,255,.25);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  padding: 1.25rem 1.5rem 1rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-soft);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}
.modal-header .modal-title { flex: 1; }
.modal-header h2 { font-size: 1rem; margin-bottom: .2rem; }
.modal-header p  { font-size: .8rem; color: var(--text-secondary); line-height: 1.4; }
.modal-close {
  background: none;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  padding: .2rem .35rem;
  border-radius: var(--radius-sm);
  transition: color .15s, background .15s, border-color .15s;
}
.modal-close:hover {
  color: var(--text-primary);
  background: var(--bg-overlay);
  border-color: var(--border-soft);
}

.modal-body { padding: 1.25rem 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-soft);
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
}

.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  font-size: .78rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .4rem;
}
.field-readonly {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border-faint);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: .5rem .75rem;
  font-size: .85rem;
  font-family: var(--font-ui);
  min-height: 2.5rem;
  display: flex;
  align-items: center;
}

.form-group input,
.form-group textarea {
  width: 100%;
  background: var(--bg-base);
  border: 1px solid var(--border-mid);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: .6rem .85rem;
  font-size: .9rem;
  font-family: var(--font-ui);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  resize: vertical;
}
.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(77,159,255,.1);
}
.form-group .hint {
  font-size: .75rem;
  color: var(--text-secondary);
  margin-top: .3rem;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
}

.info-box {
  background: rgba(77,159,255,.08);
  border: 1px solid rgba(77,159,255,.2);
  border-radius: 6px;
  padding: .75rem 1rem;
  margin-bottom: 1rem;
}
.info-box .info-label {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--accent);
  margin-bottom: .2rem;
}
.info-box .info-value {
  font-size: .85rem;
  color: var(--text-primary);
  line-height: 1.4;
}

/* ── Buttons ──────────────────────────────────────────────────────────────────── */
.btn {
  padding: .55rem 1.1rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: .88rem;
  font-weight: 600;
  transition: background .15s, opacity .15s;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: #3a8fe8; }
.btn-secondary {
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  color: var(--text-secondary);
}
.btn-secondary:hover { color: var(--text-primary); background: var(--border-mid); }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { opacity: .85; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: .25rem .6rem; font-size: .75rem; }

/* ── Role badges ──────────────────────────────────────────────────────────── */
.role-badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.role-admin  { background: rgba(77,159,255,.18); color: var(--accent); }
.role-ciso   { background: rgba(255,255,255,.07); color: var(--text-secondary); }
.role-demo   { background: rgba(255,200,0,.12); color: #f5c842; }

/* ── Admin dialog ─────────────────────────────────────────────────────────── */
.admin-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 1.75rem;
  min-width: 340px;
  color: var(--text-primary);
}
.admin-dialog::backdrop { background: rgba(0,0,0,.55); }
.dialog-title { margin: 0 0 .5rem; font-size: 1rem; font-weight: 600; }

/* ── Toast ──────────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: .75rem 1.1rem;
  font-size: .85rem;
  display: flex;
  align-items: center;
  gap: .6rem;
  min-width: 220px;
  box-shadow: var(--shadow-md);
  animation: fadeIn .2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }

/* ── Login ───────────────────────────────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-base);
  padding: 1rem;
}
.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 2rem;
}
.login-logo .shield {
  width: 44px;
  height: 44px;
  background: linear-gradient(145deg, #0d2d55 0%, #1453a0 50%, #4d9fff 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 0 0 1px rgba(77,159,255,.35), 0 0 24px rgba(77,159,255,.25), 0 2px 12px rgba(0,0,0,.5);
}
.login-logo .brand-text { font-size: 1.2rem; font-weight: 700; }
.login-logo .brand-sub  { font-size: .75rem; color: var(--text-secondary); }
.login-title { font-size: 1.4rem; font-weight: 700; margin-bottom: .5rem; }
.login-subtitle { color: var(--text-secondary); margin-bottom: 1.75rem; font-size: .9rem; }
.login-error {
  background: rgba(220,38,38,.15);
  border: 1px solid rgba(220,38,38,.4);
  color: #fca5a5;
  border-radius: 6px;
  padding: .65rem .9rem;
  font-size: .85rem;
  margin-bottom: 1rem;
  display: none;
}
.btn-login {
  width: 100%;
  padding: .75rem;
  font-size: .95rem;
  margin-top: .5rem;
}

/* Auth tabs */
.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 1.75rem;
}
.auth-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: .6rem;
  color: var(--text-secondary);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.auth-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Auth divider + demo button */
.auth-divider {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 1.25rem 0;
  color: var(--text-secondary);
  font-size: .78rem;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-soft);
}
.btn-demo {
  width: 100%;
  padding: .65rem;
  font-size: .88rem;
  background: transparent;
  border: 1px solid var(--border-mid);
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-family: var(--font-ui);
  transition: border-color .15s, color .15s;
}
.btn-demo:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}
.btn-demo:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* ── Scrollbar ───────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  /* ── Topbar ── */
  .topbar { padding: 0 .75rem; gap: .5rem; }
  .topbar-brand span { display: none; }
  .brand span { display: none; }
  .topbar-nav a { padding: .4rem .5rem; font-size: .8rem; }
  .topbar-user span > span { display: none; }
  .live-badge { display: none; }

  /* ── Main ── */
  .main { padding: .75rem; }
  .page-header { margin-bottom: .75rem; }
  .page-header-title { font-size: .95rem; }

  /* ── Stats ── */
  .heatmap-stats { gap: .4rem; margin-bottom: .75rem; }
  .stat-card { min-width: 0; flex: 1 1 calc(50% - .4rem); padding: .6rem .75rem; }
  .stat-card .stat-value { font-size: 1.3rem; }
  .stat-card .stat-label { font-size: .7rem; }

  /* ── Filters ── */
  .filters { flex-direction: column; gap: .5rem; }
  .filter-group { width: 100%; }
  .filter-group select,
  .filter-group input { width: 100%; min-width: 0; }
  .btn-reset { width: 100%; justify-content: center; }

  /* ── Export bar (heatmap) ── */
  #exportFormat { flex: 1; }

  /* ── Table → tarjetas en móvil ── */
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 600px; }

  /* ── Modal ── */
  .modal { margin: .5rem; width: calc(100vw - 1rem); max-width: none !important; }
  .modal-body { padding: .75rem; }
  .modal-footer { padding: .75rem; gap: .4rem; flex-wrap: wrap; }
  .modal-footer .btn { flex: 1; min-width: 0; font-size: .82rem; }
  .form-row { grid-template-columns: 1fr !important; }

  /* ── Heatmap chart ── */
  #treemapChart { height: calc(100vh - 280px) !important; min-height: 340px; }

  /* ── Drilldown modal context grid ── */
  .modal [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}


/* ════════════════════════════════════════════════════════════════════════════
   HEATMAP DASHBOARD — Stunning Edition
   ════════════════════════════════════════════════════════════════════════════ */

/* Full-screen app shell (heatmap page) */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

/* Ambient SOC atmosphere */
.app::before {
  content: '';
  position: fixed;
  top: -15vh; left: -10vw;
  width: 60vw; height: 60vh;
  background: radial-gradient(ellipse at top left, rgba(77,159,255,.04) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}
.app::after {
  content: '';
  position: fixed;
  bottom: -20vh; right: -10vw;
  width: 50vw; height: 50vh;
  background: radial-gradient(ellipse at bottom right, rgba(22,163,74,.025) 0%, transparent 65%);
  pointer-events: none;
  z-index: 0;
}

/* ── Page header inside HUD strip (compact variant) ─────────────────────── */
.hm-page-header {
  margin-bottom: 0;
  padding-left: .85rem;
  padding-right: 1.1rem;
  flex-shrink: 0;
}
.hm-page-header .page-header-framework {
  font-size: .58rem;
  letter-spacing: .09em;
}
.hm-page-header .page-header-title {
  font-size: .88rem;
  letter-spacing: 0;
}

/* ── Animations ─────────────────────────────────────────────────────────── */
@keyframes hm-pulse-n1 {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.62; }
}

@keyframes hm-slide-in {
  from { transform: translateX(8px); opacity: 0; }
  to   { transform: translateX(0);   opacity: 1; }
}

@keyframes hm-counter-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Sub-bar (breadcrumb) ────────────────────────────────────────────────── */
.hm-subbar {
  flex-shrink: 0;
  height: 32px;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: 0 1.25rem;
  background: rgba(6,9,14,.98);
  border-bottom: 1px solid var(--border-faint);
  position: relative;
  z-index: 5;
}

.hm-subbar #breadcrumb {
  display: flex;
  align-items: center;
  gap: .1rem;
  flex: 1;
  font-size: .75rem;
  overflow: hidden;
}

.hm-subbar .bc-item {
  color: rgba(77,159,255,.75);
  cursor: pointer;
  padding: .18rem .4rem;
  border-radius: 3px;
  transition: background .12s, color .12s;
  white-space: nowrap;
  font-weight: 500;
  letter-spacing: .01em;
}
.hm-subbar .bc-item:hover { background: var(--accent-dim); color: var(--accent); }
.hm-subbar .bc-item.current { color: var(--text-primary); cursor: default; font-weight: 600; }
.hm-subbar .bc-sep { color: var(--text-muted); font-size: .7rem; padding: 0 .1rem; }
.hm-subbar #hint {
  font-size: .68rem;
  color: var(--text-muted);
  letter-spacing: .03em;
  white-space: nowrap;
  font-style: italic;
}

/* ── HUD strip ───────────────────────────────────────────────────────────── */
.hm-hud {
  flex-shrink: 0;
  height: 44px;
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  background: linear-gradient(180deg, #0e1520 0%, #090d13 100%);
  border-bottom: 1px solid var(--border-faint);
  gap: 0;
  position: relative;
  z-index: 4;
}

.hud-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding-right: 1.1rem;
  gap: 1px;
}

.hud-val {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  letter-spacing: .05em;
  line-height: 1;
  animation: hm-counter-in .5s ease both;
}

.hud-val--n1  { color: #ef4444; }
.hud-val--avg { color: var(--accent); }

.hud-lbl {
  font-size: .56rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  font-family: var(--font-mono);
}

.hud-divider {
  width: 1px;
  height: 22px;
  background: var(--border-faint);
  margin: 0 1.1rem 0 0;
  flex-shrink: 0;
}

.hud-spacer { flex: 1; min-width: 0; }

/* ── HUD legend ─────────────────────────────────────────────────────────── */
.hm-legend {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding-right: .75rem;
}

.hm-legend-item {
  display: flex;
  align-items: center;
  gap: .3rem;
  font-size: .64rem;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.hm-legend-swatch {
  width: 9px; height: 9px;
  border-radius: 2px;
  flex-shrink: 0;
}
.hm-swatch-n1 { background: #ef4444; box-shadow: 0 0 5px rgba(239,68,68,.75); }
.hm-swatch-n2 { background: #f97316; box-shadow: 0 0 5px rgba(249,115,22,.65); }
.hm-swatch-n3 { background: #fbbf24; box-shadow: 0 0 5px rgba(251,191,36,.60); }
.hm-swatch-n4 { background: #a3e635; box-shadow: 0 0 5px rgba(163,230,53,.60); }
.hm-swatch-n5 { background: #16a34a; box-shadow: 0 0 5px rgba(22,163,74,.65); }
.hm-swatch-nd { background: #2e4055; border: 1px solid #3d5068; }

/* ── Export button (HUD) ────────────────────────────────────────────────── */
.hm-export-wrap {
  display: flex;
  align-items: center;
  gap: .4rem;
}

.hm-export-wrap select {
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 600;
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: .22rem .4rem;
  cursor: pointer;
  outline: none;
}

.hm-export-wrap select:hover { border-color: var(--accent); color: var(--text-primary); }

.btn-hm-export {
  display: flex;
  align-items: center;
  gap: .3rem;
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  padding: .22rem .6rem;
  cursor: pointer;
  transition: all .15s;
}
.btn-hm-export:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(77,159,255,.07);
}

/* ── Canvas row: treemap + KRI panel ────────────────────────────────────── */
.hm-canvas-row {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  padding: .65rem .9rem .65rem .9rem;
  gap: .65rem;
  background: var(--bg-base);
}

/* ── Treemap chart container ─────────────────────────────────────────────── */
#chart {
  flex: 1;
  min-width: 0;
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  background: #070b10;
  box-shadow:
    0 0 0 1px rgba(30,45,61,.8),
    0 0 60px rgba(0,0,0,.55),
    inset 0 0 0 1px rgba(77,159,255,.03);
  transition: flex .35s cubic-bezier(.4,0,.2,1);
}

/* Scanline CRT overlay */
#chart::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 3px,
    rgba(0,0,0,.03) 3px,
    rgba(0,0,0,.03) 4px
  );
  pointer-events: none;
  border-radius: var(--radius-lg);
  z-index: 3;
}

/* ── N1 critical pulse on SVG rects ─────────────────────────────────────── */
.node--n1 rect.cell-fill {
  animation: hm-pulse-n1 2.2s ease-in-out infinite;
}

/* ── Node hover ─────────────────────────────────────────────────────────── */
.hm-node:hover rect.cell-fill {
  filter: brightness(1.18) saturate(1.12);
  cursor: pointer;
}

/* ── KRI side panel ──────────────────────────────────────────────────────── */
.kri-panel-wrap {
  width: 0;
  flex-shrink: 0;
  overflow: hidden;
  transition: width .32s cubic-bezier(.4,0,.2,1);
}

.kri-panel-wrap.open {
  width: 348px;
}

.kri-panel-inner {
  width: 348px;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  border-top: 2px solid rgba(77,159,255,.22);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md), 0 0 40px rgba(0,0,0,.35);
  animation: hm-slide-in .32s cubic-bezier(.4,0,.2,1) both;
}

.kri-panel-header {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .5rem;
  padding: .75rem 1rem .65rem;
  border-bottom: 1px solid var(--border-faint);
  background: linear-gradient(180deg, var(--bg-elevated) 0%, var(--bg-surface) 100%);
}

.kri-panel-badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .06em;
  padding: .15rem .45rem;
  border-radius: 3px;
  margin-bottom: .3rem;
  color: #000;
}

.kri-panel-title {
  font-size: .82rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: .01em;
  line-height: 1.25;
}

.kri-panel-sub {
  font-size: .7rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  margin-top: .2rem;
  line-height: 1.3;
}

.kri-panel-close {
  background: none;
  border: 1px solid var(--border-soft);
  color: var(--text-muted);
  width: 24px; height: 24px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .8rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all .15s;
}
.kri-panel-close:hover { border-color: rgba(239,68,68,.4); color: #f87171; background: rgba(239,68,68,.07); }

.kri-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: .6rem .75rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.kri-panel-body::-webkit-scrollbar { width: 4px; }
.kri-panel-body::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 2px; }
.kri-panel-body::-webkit-scrollbar-track { background: transparent; }

/* KRI cards inside panel */
.kp-card {
  border-left: 3px solid var(--border-mid);
  background: var(--bg-elevated);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: .6rem .75rem;
  position: relative;
  transition: background .15s;
}
.kp-card:hover { background: var(--bg-overlay); }

.kp-card-name {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: .2rem;
  line-height: 1.3;
}

.kp-card-desc {
  font-size: .72rem;
  color: var(--text-secondary);
  margin-bottom: .15rem;
  line-height: 1.45;
}

.kp-card-formula {
  font-size: .68rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-style: italic;
  margin-bottom: .3rem;
}

.kp-card-footer {
  display: flex;
  align-items: center;
  gap: .45rem;
  margin-top: .3rem;
}

.kp-score-badge {
  font-family: var(--font-mono);
  font-size: .74rem;
  font-weight: 700;
  padding: .1rem .45rem;
  border-radius: 20px;
  line-height: 1;
}

.kp-cmmi-label {
  font-size: .68rem;
  color: var(--text-muted);
  font-weight: 500;
}

.kp-saved-by {
  font-size: .64rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-left: auto;
}

.kp-edit-btn {
  position: absolute;
  top: .5rem; right: .5rem;
  background: none;
  border: 1px solid var(--border-faint);
  color: var(--text-muted);
  width: 22px; height: 22px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .72rem;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}
.kp-card:hover .kp-edit-btn { display: flex; }
.kp-edit-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

.kp-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: .8rem;
  font-style: italic;
  padding: 1.5rem 0;
}

.kp-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  width: 100%;
  font-size: .78rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px dashed rgba(77,159,255,.3);
  border-radius: var(--radius-md);
  padding: .55rem;
  cursor: pointer;
  transition: all .15s;
  margin-top: .25rem;
}
.kp-add-btn:hover { background: rgba(77,159,255,.18); border-color: rgba(77,159,255,.5); }

/* ── Tooltip ─────────────────────────────────────────────────────────────── */
#hm-tooltip {
  position: fixed;
  pointer-events: none;
  display: none;
  background: linear-gradient(145deg, #0f1923 0%, #0a1018 100%);
  border: 1px solid #1e3048;
  border-radius: var(--radius-md);
  padding: .6rem .8rem;
  max-width: 280px;
  z-index: 999;
  box-shadow: 0 8px 32px rgba(0,0,0,.7), 0 0 0 1px rgba(77,159,255,.06);
  font-size: .78rem;
  line-height: 1.5;
}

/* ── KRI edit modal (for heatmap page) ──────────────────────────────────── */
#hm-kri-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
#hm-kri-modal.hidden { display: none; }

.hm-modal-box {
  background: linear-gradient(170deg, var(--bg-elevated) 0%, var(--bg-surface) 100%);
  border: 1px solid var(--border-mid);
  border-top: 2px solid rgba(77,159,255,.35);
  border-radius: var(--radius-lg);
  width: min(560px, calc(100vw - 2rem));
  max-height: calc(100vh - 4rem);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.hm-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .9rem 1.2rem .75rem;
  border-bottom: 1px solid var(--border-faint);
  flex-shrink: 0;
}

.hm-modal-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: .01em;
}

.hm-modal-close {
  background: none;
  border: 1px solid var(--border-soft);
  color: var(--text-muted);
  width: 26px; height: 26px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .85rem;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.hm-modal-close:hover { border-color: rgba(239,68,68,.4); color: #f87171; background: rgba(239,68,68,.07); }

.hm-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.2rem;
}
.hm-modal-body::-webkit-scrollbar { width: 4px; }
.hm-modal-body::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 2px; }

.hm-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .5rem;
  padding: .75rem 1.2rem;
  border-top: 1px solid var(--border-faint);
  flex-shrink: 0;
}

.hm-ctx-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .4rem .75rem;
  padding: .6rem .9rem;
  background: rgba(0,0,0,.2);
  border-radius: var(--radius-md);
  margin-bottom: .9rem;
  border: 1px solid var(--border-faint);
}
.hm-ctx-label {
  font-size: .62rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: .1rem;
}
.hm-ctx-val {
  font-size: .78rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.hm-history-box {
  margin-top: .75rem;
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.hm-history-title {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: .4rem .65rem;
  background: rgba(0,0,0,.2);
  border-bottom: 1px solid var(--border-faint);
}
.hm-history-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .3rem .65rem;
  border-bottom: 1px solid var(--border-faint);
  font-size: .74rem;
}
.hm-history-row:last-child { border-bottom: none; }

/* ── Score bar (inside KRI card) ─────────────────────────────────────────── */
.kp-score-bar {
  height: 3px;
  border-radius: 2px;
  background: var(--border-faint);
  margin-top: .4rem;
  overflow: hidden;
}
.kp-score-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width .6s ease;
}
