/*
  CISOToolkit v2 — HUD / Sci-Fi FUI Interface
  Tactical dark theme · Cyan accent · Monospace type system
*/
@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Fira+Code:wght@300;400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-base:      #010b14;
  --bg-surface:   #040f1c;
  --bg-elevated:  #071525;
  --bg-overlay:   #0c1e32;

  --border-faint: rgba(0,212,255,.07);
  --border-soft:  rgba(0,212,255,.14);
  --border-mid:   rgba(0,212,255,.26);

  --text-primary:   #b8d8f0;
  --text-secondary: #3e7a9a;
  --text-muted:     #1a3e5e;

  --accent:       #00d4ff;
  --accent-dim:   rgba(0,212,255,.09);
  --accent-glow:  rgba(0,212,255,.25);
  --green:        #00e676;
  --red:          #ff3d5a;

  --font-ui:   'Fira Code', 'JetBrains Mono', monospace;
  --font-mono: 'Share Tech Mono', monospace;

  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 6px;
  --shadow-lg: 0 24px 64px rgba(0,0,0,.92), 0 0 0 1px var(--border-soft), 0 0 40px rgba(0,212,255,.04);
  --shadow-md: 0 8px 28px rgba(0,0,0,.7), 0 0 0 1px var(--border-faint);

  /* CMMI heat scale — preserved */
  --color-nodata:   #0e1f30;
  --color-n1:       #ef4444;
  --color-n2:       #f97316;
  --color-n3:       #fbbf24;
  --color-n4:       #a3e635;
  --color-n5:       #16a34a;
  --n1-color:       #ef4444;
  --n5-color:       #16a34a;
  --color-critical: #ef4444;

  --radius: var(--radius-md);
  --shadow: var(--shadow-md);
}

html { font-size: 16px; }

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

/* Grid atmosphere */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0,212,255,.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,212,255,.022) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* Typography */
h1 { font-size: 1.6rem; font-weight: 400; font-family: var(--font-mono); letter-spacing: .06em; }
h2 { font-size: 1.2rem; font-weight: 400; font-family: var(--font-mono); letter-spacing: .04em; }
h3 { font-size: 1rem;   font-weight: 400; font-family: var(--font-mono); letter-spacing: .04em; }
p  { color: var(--text-secondary); }

/* Layout */
.app-container { display: flex; flex-direction: column; min-height: 100vh; position: relative; z-index: 1; }

/* ── Topbar ────────────────────────────────────────────────────────────────── */
.topbar {
  height: 64px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1.5rem;
  background: linear-gradient(180deg, #030c16 0%, var(--bg-surface) 100%);
  border-bottom: 1px solid var(--border-soft);
  box-shadow: 0 0 30px rgba(0,212,255,.06), 0 4px 24px rgba(0,0,0,.5);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(0,212,255,.2) 10%,
    var(--accent) 40%,
    #00ffcc 50%,
    var(--accent) 60%,
    rgba(0,212,255,.2) 90%,
    transparent 100%
  );
  box-shadow: 0 0 12px rgba(0,212,255,.6), 0 0 24px rgba(0,212,255,.3);
}

.topbar::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0,212,255,.12) 40%, rgba(0,212,255,.12) 60%, transparent);
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  text-decoration: none;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: .96rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  flex-shrink: 0;
  transition: opacity .15s;
}
.brand:hover { opacity: .85; }
.brand:hover .brand-mark { box-shadow: 0 0 0 1px var(--border-mid), 0 0 24px rgba(0,212,255,.5); }

.brand-mark {
  width: 34px; height: 34px;
  background: linear-gradient(145deg, #011428 0%, #012540 50%, #01334f 100%);
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  box-shadow: 0 0 0 1px rgba(0,212,255,.3), 0 0 14px rgba(0,212,255,.2), 0 2px 8px rgba(0,0,0,.5);
  transition: box-shadow .2s;
}

.topbar-brand {
  display: flex; align-items: center; gap: .6rem;
  font-family: var(--font-mono); font-weight: 400;
  font-size: .88rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-primary); text-decoration: none;
}
.topbar-brand .shield {
  width: 28px; height: 28px;
  background: linear-gradient(145deg, #011428 0%, #01334f 100%);
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  box-shadow: 0 0 0 1px rgba(0,212,255,.3), 0 0 12px rgba(0,212,255,.18);
}

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

/* Nav */
.topbar-nav { display: flex; align-items: center; gap: 2px; }
.topbar-nav a {
  display: flex; align-items: center; gap: .3rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: .84rem;
  font-family: var(--font-mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: .38rem .9rem;
  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(--accent-dim); }
.topbar-nav a.active {
  color: var(--accent);
  background: rgba(0,212,255,.08);
  box-shadow: inset 0 0 0 1px rgba(0,212,255,.15);
}
.topbar-nav a.active::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 15%; right: 15%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  box-shadow: 0 0 5px var(--accent);
}

.topbar-spacer { flex: 1; }

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

/* Live badge */
.live-badge {
  display: flex; align-items: center; gap: .4rem;
  font-size: .72rem;
  font-family: var(--font-mono);
  letter-spacing: .14em;
  color: #00e676;
  background: rgba(0,230,118,.07);
  border: 1px solid rgba(0,230,118,.22);
  border-radius: 2px;
  padding: .2rem .6rem;
}
.live-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #00e676;
  box-shadow: 0 0 6px #00e676, 0 0 12px rgba(0,230,118,.5);
  animation: pulse 2.5s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

/* Avatar */
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
}
.topbar-user {
  display: flex; align-items: center; gap: .55rem;
  color: var(--text-secondary);
  font-size: .84rem; font-family: var(--font-mono);
}

.btn-logout {
  background: none;
  border: 1px solid var(--border-soft);
  color: var(--text-muted);
  font-size: .72rem;
  font-family: var(--font-mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: .24rem .62rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .15s;
}
.btn-logout:hover { border-color: rgba(255,61,90,.4); color: #ff7a90; background: rgba(255,61,90,.07); }

/* Main */
.main { flex: 1; padding: 1.5rem 2rem; width: 100%; position: relative; z-index: 1; }

/* 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: 2px;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent), 0 0 16px rgba(0,212,255,.4);
}
.page-header-text { display: flex; flex-direction: column; gap: .08rem; }
.page-header-framework {
  font-size: .72rem; font-family: var(--font-mono);
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent); opacity: .7;
}
.page-header-title {
  font-size: 1.05rem; font-family: var(--font-mono);
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-primary); line-height: 1.2;
}

/* Cards with corner brackets */
.card {
  background: linear-gradient(160deg, var(--bg-elevated) 0%, rgba(4,15,28,.98) 100%);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-md), inset 0 1px 0 rgba(0,212,255,.04);
  position: relative;
}
.card::before {
  content: none;
}
.card::after {
  content: none;
}

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

/* ── Filters / 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: .82rem; font-family: var(--font-mono);
  color: var(--text-secondary); text-transform: uppercase; letter-spacing: .08em;
}
.filter-group select, .filter-group input {
  background: var(--bg-base);
  border: 1px solid var(--border-soft);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: .52rem .85rem;
  font-size: .94rem; 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 2px rgba(0,212,255,.1), 0 0 8px rgba(0,212,255,.08);
}
.filter-group input[type=text] { min-width: 220px; }
.filter-group input::placeholder { color: var(--text-muted); }

.btn-reset {
  background: var(--bg-elevated);
  border: 1px solid var(--border-soft);
  color: var(--text-secondary);
  padding: .52rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .8rem; font-family: var(--font-mono);
  letter-spacing: .06em; text-transform: uppercase;
  align-self: flex-end;
  transition: all .15s;
}
.btn-reset:hover { color: var(--accent); border-color: var(--border-mid); background: var(--accent-dim); box-shadow: 0 0 8px rgba(0,212,255,.1); }

.table-wrapper { overflow-x: auto; border-radius: var(--radius-md); border: 1px solid var(--border-soft); }

table, .kri-table { width: 100%; border-collapse: collapse; font-size: .96rem; font-family: var(--font-ui); }
thead th {
  background: var(--bg-elevated);
  padding: .62rem 1rem;
  text-align: left;
  font-size: .78rem; font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--accent);
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap; position: sticky; top: 0;
  opacity: .8;
}
tbody tr { border-bottom: 1px solid var(--border-faint); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(0,212,255,.03); }
tbody td { padding: .58rem 1rem; vertical-align: middle; }

.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; }

.td-code { font-family: var(--font-mono); font-size: .76rem; color: var(--accent); }
.td-code span, .td-code { background: rgba(0,212,255,.06); padding: .13rem .36rem; border-radius: 2px; display: inline-block; }
.td-desc { max-width: 300px; color: var(--text-secondary); font-size: .84rem; line-height: 1.4; }
.td-kri  { max-width: 220px; font-size: .84rem; }
.td-value { text-align: center; font-weight: 400; font-family: var(--font-mono); }
.td-date  { color: var(--text-secondary); font-size: .82rem; font-family: var(--font-mono); }
.td-actions { text-align: center; white-space: nowrap; min-width: 90px; }

.kri-badge {
  display: inline-block; padding: .16rem .46rem;
  border-radius: 2px; font-size: .68rem; font-family: var(--font-mono);
  color: white; letter-spacing: .04em;
}
.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: #0a1628; }
.kri-badge.n4      { background: var(--color-n4); color: #0a1628; }
.kri-badge.n5      { background: var(--color-n5); }

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

.btn-ex-link {
  background: none; border: none; color: var(--accent);
  font-size: .76rem; font-family: var(--font-mono);
  cursor: pointer; padding: .16rem .28rem; border-radius: var(--radius-sm);
  text-decoration: underline; text-decoration-color: rgba(0,212,255,.3);
  transition: all .15s; white-space: nowrap;
}
.btn-ex-link:hover { color: #00ffcc; background: rgba(0,212,255,.08); }
.btn-ex-link:disabled { color: var(--text-muted); text-decoration: none; cursor: default; }

.btn-icon {
  background: var(--bg-elevated); border: 1px solid var(--border-soft);
  color: var(--text-secondary); width: 28px; height: 28px;
  border-radius: var(--radius-sm); cursor: pointer; font-size: .8rem;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.btn-icon:hover { background: var(--accent); border-color: var(--accent); color: #000; box-shadow: 0 0 10px rgba(0,212,255,.4); }
.btn-icon.btn-delete:hover { background: var(--red); border-color: var(--red); color: white; }
.btn-icon.btn-icon-add { color: var(--accent); border-color: var(--border-mid); }
.btn-icon.btn-icon-add:hover { background: var(--accent); color: #000; }

.table-empty {
  text-align: center; padding: 3rem 1rem;
  color: var(--text-muted); font-family: var(--font-mono); letter-spacing: .04em;
}

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

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  border-top: 2px solid rgba(0,212,255,.4);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 520px;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
  position: relative;
}
.modal::before {
  content: none;
}
@keyframes slideUp { from{transform:translateY(16px);opacity:0} to{transform:translateY(0);opacity:1} }

.modal-header {
  padding: 1.1rem 1.4rem .9rem;
  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: .88rem; margin-bottom: .2rem; font-family: var(--font-mono); letter-spacing: .06em; text-transform: uppercase; }
.modal-header p  { font-size: .78rem; color: var(--text-secondary); line-height: 1.4; }
.modal-close {
  background: none; border: 1px solid var(--border-soft);
  color: var(--text-secondary); font-size: 1rem; cursor: pointer;
  line-height: 1; padding: .2rem .35rem;
  border-radius: var(--radius-sm); transition: all .15s;
  font-family: var(--font-mono);
}
.modal-close:hover { color: #ff7a90; background: rgba(255,61,90,.1); border-color: rgba(255,61,90,.35); }

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

/* Forms */
.form-group { margin-bottom: .95rem; }
.form-group label {
  display: block; font-size: .72rem; font-family: var(--font-mono);
  color: var(--text-secondary); text-transform: uppercase;
  letter-spacing: .08em; margin-bottom: .36rem;
}
.field-readonly {
  width: 100%; background: var(--bg-base);
  border: 1px solid var(--border-faint);
  color: var(--text-secondary); border-radius: var(--radius-sm);
  padding: .48rem .7rem; font-size: .82rem; font-family: var(--font-ui);
  min-height: 2.4rem; 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: .55rem .8rem;
  font-size: .88rem; 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 2px rgba(0,212,255,.1), 0 0 8px rgba(0,212,255,.08);
}
.form-group .hint { font-size: .7rem; color: var(--text-muted); margin-top: .3rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }

.info-box {
  background: rgba(0,212,255,.06);
  border: 1px solid rgba(0,212,255,.18);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius-sm); padding: .7rem .95rem; margin-bottom: .95rem;
}
.info-box .info-label {
  font-size: .62rem; font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: .1em; color: var(--accent); margin-bottom: .2rem;
}
.info-box .info-value { font-size: .82rem; color: var(--text-primary); line-height: 1.4; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  padding: .52rem 1.1rem; border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; font-size: .82rem; font-family: var(--font-mono);
  letter-spacing: .08em; text-transform: uppercase; transition: all .15s;
}
.btn-primary {
  padding: .52rem 1.1rem; border-radius: var(--radius-sm); cursor: pointer;
  font-family: var(--font-mono); font-size: .82rem; letter-spacing: .08em; text-transform: uppercase;
  background: rgba(0,212,255,.1); border: 1px solid rgba(0,212,255,.4); color: var(--accent); transition: all .15s;
}
.btn-primary:hover {
  background: rgba(0,212,255,.18); border-color: var(--accent); color: #fff;
  box-shadow: 0 0 12px rgba(0,212,255,.25), 0 0 24px rgba(0,212,255,.1);
}
.btn-secondary {
  padding: .52rem 1.1rem; border-radius: var(--radius-sm); cursor: pointer;
  font-family: var(--font-mono); font-size: .82rem; letter-spacing: .08em; text-transform: uppercase;
  background: var(--bg-elevated); border: 1px solid var(--border-soft); color: var(--text-secondary); transition: all .15s;
}
.btn-secondary:hover { color: var(--accent); border-color: var(--border-mid); background: var(--accent-dim); }
.btn-danger {
  padding: .52rem 1.1rem; border-radius: var(--radius-sm); cursor: pointer;
  font-family: var(--font-mono); font-size: .82rem; letter-spacing: .08em; text-transform: uppercase;
  background: rgba(255,61,90,.1); border: 1px solid rgba(255,61,90,.35); color: #ff7a90; transition: all .15s;
}
.btn-danger:hover { background: rgba(255,61,90,.2); border-color: rgba(255,61,90,.6); box-shadow: 0 0 10px rgba(255,61,90,.2); }
.btn:disabled, .btn-primary:disabled, .btn-secondary:disabled, .btn-danger:disabled { opacity: .4; cursor: not-allowed; }
.btn-sm { padding: .2rem .52rem !important; font-size: .66rem !important; }
.hm-hud .btn-sm { padding: .32rem .72rem !important; font-size: .8rem !important; }

/* ── HUD selector / scratch ────────────────────────────────────────────────── */
.hud-scenario { display: flex; align-items: center; gap: .5rem; margin-right: .75rem; }
.hud-scenario select {
  background: var(--bg-elevated); border: 1px solid var(--border-soft);
  color: var(--text-secondary); border-radius: var(--radius-sm);
  padding: .32rem .7rem; font-size: .82rem; font-family: var(--font-mono);
  letter-spacing: .04em; cursor: pointer;
}
.hud-scenario select:focus { outline: none; border-color: var(--accent); }

.hud-heatmap-title { display: flex; align-items: center; margin-right: .75rem; }
.hud-heatmap-title.hidden { display: none; }
.hud-heatmap-title-text {
  font-size: .72rem; font-family: var(--font-mono); letter-spacing: .04em;
  color: var(--text-primary); background: var(--bg-elevated);
  border: 1px solid var(--border-mid); border-radius: var(--radius-sm);
  padding: .2rem .58rem; max-width: 220px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.hud-scratch { display: flex; align-items: center; margin-right: .5rem; }

#scratch-name-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.72);
  z-index: 300; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
}
#scratch-name-modal.hidden { display: none; }
.scratch-name-box {
  background: var(--bg-elevated); border: 1px solid var(--border-mid);
  border-top: 2px solid rgba(0,212,255,.4); border-radius: var(--radius-lg);
  padding: 1.5rem 1.75rem; width: min(380px, calc(100vw - 2rem));
  display: flex; flex-direction: column; gap: 1rem;
  box-shadow: var(--shadow-lg); position: relative;
}
.scratch-name-label {
  font-size: .82rem; font-family: var(--font-mono); letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-primary); margin: 0;
}
.scratch-name-input {
  background: var(--bg-surface); border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: .85rem; font-family: var(--font-ui);
  padding: .42rem .6rem; width: 100%;
}
.scratch-name-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 8px rgba(0,212,255,.1); }
.scratch-name-actions { display: flex; justify-content: flex-end; gap: .5rem; }

/* Role badges */
.role-badge {
  display: inline-block; padding: .12rem .46rem;
  border-radius: 2px; font-size: .66rem; font-family: var(--font-mono);
  letter-spacing: .06em; text-transform: uppercase; border: 1px solid transparent;
}
.role-admin { background: rgba(0,212,255,.12); color: var(--accent); border-color: rgba(0,212,255,.25); }
.role-ciso  { background: rgba(100,200,255,.06); color: var(--text-secondary); border-color: var(--border-soft); }
.role-user  { background: rgba(100,200,255,.06); color: var(--text-secondary); border-color: var(--border-soft); }
.role-demo  { background: rgba(255,195,0,.1); color: #ffd060; border-color: rgba(255,195,0,.25); }

/* Admin dialog */
.admin-dialog {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--border-mid);
  border-top: 2px solid rgba(0,212,255,.35);
  border-radius: var(--radius-md);
  padding: 1.75rem; min-width: 340px;
  color: var(--text-primary); box-shadow: var(--shadow-lg);
}
.admin-dialog::backdrop { background: rgba(0,0,0,.7); backdrop-filter: blur(6px); }
.dialog-title { margin: 0 0 .5rem; font-size: .85rem; font-family: var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }

/* 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: var(--radius-sm); padding: .68rem 1rem;
  font-size: .78rem; font-family: var(--font-mono);
  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: 2px solid var(--green); }
.toast.error   { border-left: 2px solid var(--red); }

/* ── Login ────────────────────────────────────────────────────────────────── */
.login-page {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--bg-base);
  padding: 1rem; position: relative; overflow: hidden;
}
.login-page::after {
  content: '';
  position: fixed; inset: 0;
  background: repeating-linear-gradient(
    to bottom, transparent 0px, transparent 3px,
    rgba(0,212,255,.006) 3px, rgba(0,212,255,.006) 4px
  );
  pointer-events: none; z-index: 0;
}

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg);
  padding: 2.5rem; width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg), 0 0 60px rgba(0,212,255,.04);
  position: relative; z-index: 1;
}
.login-card::before {
  content: none;
}
.login-card::after {
  content: none;
}

.login-logo { display: flex; align-items: center; gap: .75rem; margin-bottom: 2rem; }
.login-logo .shield {
  width: 44px; height: 44px;
  background: linear-gradient(145deg, #011428 0%, #01334f 100%);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); font-size: 1.4rem;
  box-shadow: 0 0 0 1px rgba(0,212,255,.3), 0 0 20px rgba(0,212,255,.2), 0 2px 12px rgba(0,0,0,.5);
}
.login-logo .brand-text {
  font-size: 1.05rem; font-family: var(--font-mono);
  letter-spacing: .1em; text-transform: uppercase; color: var(--text-primary);
}
.login-logo .brand-sub {
  font-size: .64rem; font-family: var(--font-mono);
  color: var(--accent); letter-spacing: .14em; text-transform: uppercase; opacity: .7;
}
.login-title { font-size: 1.3rem; font-family: var(--font-mono); margin-bottom: .5rem; }
.login-subtitle { color: var(--text-secondary); margin-bottom: 1.75rem; font-size: .88rem; }

.login-error {
  background: rgba(255,61,90,.1); border: 1px solid rgba(255,61,90,.35);
  color: #ff9aaa; border-radius: var(--radius-sm);
  padding: .58rem .82rem; font-size: .8rem; font-family: var(--font-mono);
  margin-bottom: 1rem; display: none;
}
.btn-login { width: 100%; padding: .68rem; font-size: .82rem; margin-top: .5rem; letter-spacing: .1em; }

.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: .52rem; color: var(--text-muted);
  font-size: .72rem; font-family: var(--font-mono);
  letter-spacing: .1em; text-transform: uppercase;
  cursor: pointer; transition: color .15s, border-color .15s;
}
.auth-tab.active { color: var(--accent); border-bottom-color: var(--accent); text-shadow: 0 0 8px rgba(0,212,255,.4); }

.auth-divider {
  display: flex; align-items: center; gap: .75rem;
  margin: 1.25rem 0; color: var(--text-muted);
  font-size: .68rem; font-family: var(--font-mono); letter-spacing: .1em;
}
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--border-soft); }

.btn-demo {
  width: 100%; padding: .6rem; font-size: .76rem;
  background: transparent; border: 1px solid var(--border-soft);
  color: var(--text-secondary); border-radius: var(--radius-sm);
  cursor: pointer; font-family: var(--font-mono);
  letter-spacing: .08em; text-transform: uppercase; transition: all .15s;
}
.btn-demo:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); box-shadow: 0 0 10px rgba(0,212,255,.1); }
.btn-demo:disabled { opacity: .4; cursor: not-allowed; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,212,255,.4); }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .hm-page-header {
    width: 100%;
    padding-bottom: .4rem;
    border-bottom: 1px solid var(--border-faint);
    margin-bottom: .2rem;
  }
  .hud-spacer { display: none; }
}

@media (max-width: 640px) {
  .topbar { padding: 0 .75rem; gap: .5rem; }
  .brand span, .topbar-brand span { display: none; }
  .topbar-nav a { padding: .38rem .48rem; font-size: .68rem; }
  .live-badge { display: none; }
  .main { padding: .75rem; }
  .page-header { margin-bottom: .75rem; }
  .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%; }
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 600px; }
  .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: .72rem; }
  .form-row { grid-template-columns: 1fr !important; }
  .hm-hud { padding: .4rem .75rem; row-gap: .3rem; }
  .hm-page-header .page-header-title { font-size: .88rem; }
  .hm-page-header .page-header-framework { font-size: .62rem; }
  .hm-legend { margin-left: 0; }
}

/* ════════════════════════════════════════════════════════
   HEATMAP DASHBOARD — HUD Edition
   ════════════════════════════════════════════════════════ */

.app {
  display: flex; flex-direction: column;
  height: 100vh; overflow: hidden;
  position: relative; z-index: 1;
}
.app::before {
  content: ''; position: fixed; top: -15vh; left: -10vw;
  width: 60vw; height: 60vh;
  background: radial-gradient(ellipse at top left, rgba(0,212,255,.025) 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(0,230,118,.015) 0%, transparent 65%);
  pointer-events: none; z-index: 0;
}

.hm-page-header { margin-bottom: 0; padding-left: .85rem; padding-right: 1.1rem; flex-shrink: 0; }
.hm-page-header .page-header-framework { font-size: .72rem; letter-spacing: .12em; }
.hm-page-header .page-header-title { font-size: 1.05rem; letter-spacing: .06em; }

@keyframes hm-pulse-n1 { 0%,100%{opacity:1} 50%{opacity:.58} }
@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)} }

/* Subbar */
.hm-subbar {
  flex-shrink: 0; height: 30px;
  display: flex; align-items: center; gap: .5rem;
  padding: 0 1.25rem;
  background: rgba(1,11,20,.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: .7rem; font-family: var(--font-mono); overflow: hidden;
}
.hm-subbar .bc-item {
  color: rgba(0,212,255,.7); cursor: pointer; padding: .14rem .36rem;
  border-radius: 2px; transition: background .12s, color .12s;
  white-space: nowrap; letter-spacing: .04em;
}
.hm-subbar .bc-item:hover { background: var(--accent-dim); color: var(--accent); }
.hm-subbar .bc-item.current { color: var(--text-primary); cursor: default; }
.hm-subbar .bc-sep { color: var(--text-muted); font-size: .62rem; padding: 0 .1rem; }
.hm-subbar #hint {
  font-size: .62rem; font-family: var(--font-mono);
  color: var(--text-muted); letter-spacing: .06em; white-space: nowrap; font-style: italic;
}

/* HUD strip */
.hm-hud {
  flex-shrink: 0; height: auto; min-height: 64px;
  display: flex; align-items: center; flex-wrap: wrap;
  padding: .45rem 1.25rem;
  background: linear-gradient(180deg, #020c18 0%, #010b14 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-size: 1.05rem; letter-spacing: .1em;
  color: var(--text-primary); line-height: 1;
  animation: hm-counter-in .5s ease both;
}
.hud-val--n1  { color: #ef4444; text-shadow: 0 0 8px rgba(239,68,68,.5); }
.hud-val--avg { color: var(--accent); text-shadow: 0 0 8px rgba(0,212,255,.4); }
.hud-lbl {
  font-size: .72rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--text-muted); white-space: nowrap; font-family: var(--font-mono);
}
.hud-divider { width: 1px; height: 20px; background: var(--border-soft); margin: 0 1.1rem 0 0; flex-shrink: 0; }
.hud-spacer  { flex: 1; min-width: 0; }

/* Legend */
.hm-legend { display: flex; align-items: center; gap: .55rem; padding-right: .75rem; margin-left: 1.25rem; }
.hm-legend-item {
  display: flex; align-items: center; gap: .32rem;
  font-size: .76rem; font-family: var(--font-mono);
  color: var(--text-secondary); letter-spacing: .05em; white-space: nowrap;
}
.hm-legend-swatch { width: 13px; height: 13px; border-radius: 2px; flex-shrink: 0; }
.hm-swatch-n1 { background: #ef4444; box-shadow: 0 0 5px rgba(239,68,68,.8); }
.hm-swatch-n2 { background: #f97316; box-shadow: 0 0 5px rgba(249,115,22,.7); }
.hm-swatch-n3 { background: #fbbf24; box-shadow: 0 0 5px rgba(251,191,36,.65); }
.hm-swatch-n4 { background: #a3e635; box-shadow: 0 0 5px rgba(163,230,53,.65); }
.hm-swatch-n5 { background: #16a34a; box-shadow: 0 0 5px rgba(22,163,74,.7); }
.hm-swatch-nd { background: #0f2a40; border: 1px solid var(--border-mid); }

/* Export */
.hm-export-wrap { display: flex; align-items: center; gap: .35rem; }
.hm-export-wrap select {
  font-family: var(--font-mono); font-size: .8rem;
  background: var(--bg-elevated); border: 1px solid var(--border-soft);
  color: var(--text-secondary); border-radius: var(--radius-sm);
  padding: .3rem .5rem; cursor: pointer; outline: none; letter-spacing: .04em;
}
.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: .8rem;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-secondary); background: var(--bg-elevated);
  border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  padding: .3rem .7rem; cursor: pointer; transition: all .15s;
}
.btn-hm-export:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); box-shadow: 0 0 8px rgba(0,212,255,.15); }

/* Canvas row */
.hm-canvas-row {
  flex: 1; min-height: 0;
  display: flex; flex-direction: row; overflow: hidden;
  padding: .6rem .85rem; gap: .6rem;
  background: var(--bg-base);
}

#chart {
  flex: 1; min-width: 0;
  border-radius: var(--radius-md); overflow: hidden;
  position: relative; background: #010810;
  box-shadow: 0 0 0 1px var(--border-soft), 0 0 60px rgba(0,0,0,.7), inset 0 0 0 1px rgba(0,212,255,.02);
  transition: flex .35s cubic-bezier(.4,0,.2,1);
}
#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-md); z-index: 3;
}

.node--n1 rect.cell-fill { animation: hm-pulse-n1 2.2s ease-in-out infinite; }
.hm-node:hover rect.cell-fill { filter: brightness(1.2) saturate(1.1); cursor: pointer; }

/* KRI 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: 340px; }
.kri-panel-inner {
  width: 340px; height: 100%;
  display: flex; flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  border-top: 2px solid rgba(0,212,255,.3);
  border-radius: var(--radius-md); overflow: hidden;
  box-shadow: var(--shadow-md), 0 0 30px rgba(0,0,0,.4);
  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: .7rem .9rem .6rem;
  border-bottom: 1px solid var(--border-faint);
  background: var(--bg-elevated);
}
.kri-panel-badge {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono); font-size: .62rem; letter-spacing: .08em;
  padding: .12rem .4rem; border-radius: 2px; margin-bottom: .26rem; color: #000;
}
.kri-panel-title { font-size: .76rem; font-family: var(--font-mono); color: var(--text-primary); letter-spacing: .04em; line-height: 1.25; }
.kri-panel-sub   { font-size: .64rem; color: var(--text-secondary); font-family: var(--font-mono); margin-top: .18rem; line-height: 1.3; }
.kri-panel-close {
  background: none; border: 1px solid var(--border-soft); color: var(--text-muted);
  width: 22px; height: 22px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: .75rem; font-family: var(--font-mono);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: all .15s;
}
.kri-panel-close:hover { border-color: rgba(255,61,90,.4); color: #ff7a90; background: rgba(255,61,90,.07); }

.kri-panel-body { flex: 1; overflow-y: auto; padding: .55rem .7rem; display: flex; flex-direction: column; gap: .45rem; }
.kri-panel-body::-webkit-scrollbar { width: 3px; }
.kri-panel-body::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 1px; }

.kp-card {
  border-left: 2px solid var(--border-mid); background: var(--bg-elevated);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: .55rem .7rem; position: relative;
  transition: background .15s, border-color .15s;
}
.kp-card:hover { background: var(--bg-overlay); border-left-color: var(--accent); }
.kp-card-name { font-size: .76rem; font-family: var(--font-ui); color: var(--text-primary); margin-bottom: .16rem; line-height: 1.3; }
.kp-card-desc { font-size: .66rem; color: var(--text-secondary); margin-bottom: .13rem; line-height: 1.45; }
.kp-card-formula { font-size: .62rem; color: var(--text-muted); font-family: var(--font-mono); font-style: italic; margin-bottom: .26rem; }
.kp-card-footer { display: flex; align-items: center; gap: .4rem; margin-top: .26rem; }
.kp-score-badge { font-family: var(--font-mono); font-size: .68rem; padding: .07rem .4rem; border-radius: 20px; line-height: 1; }
.kp-cmmi-label { font-size: .62rem; color: var(--text-muted); font-family: var(--font-mono); }
.kp-saved-by { font-size: .58rem; color: var(--text-muted); font-family: var(--font-mono); margin-left: auto; }
.kp-owner { display: flex; align-items: center; gap: .4rem; margin-top: .38rem; font-size: .66rem; color: var(--text-muted); font-family: var(--font-mono); }
.kp-owner-label { color: var(--text-secondary); }
.kp-owner-btn { opacity: 0; background: none; border: none; color: var(--accent); cursor: pointer; font-size: .66rem; padding: 0 .14rem; line-height: 1; transition: opacity .15s; }
.kp-card:hover .kp-owner-btn { opacity: 1; }
.kp-edit-btn {
  position: absolute; top: .44rem; right: .44rem;
  background: none; border: 1px solid var(--border-faint); color: var(--text-muted);
  width: 20px; height: 20px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: .66rem;
  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: .72rem; font-family: var(--font-mono); font-style: italic; letter-spacing: .04em; padding: 1.5rem 0; }
.kp-add-btn {
  display: flex; align-items: center; justify-content: center; gap: .35rem;
  width: 100%; font-size: .68rem; font-family: var(--font-mono); letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent); background: var(--accent-dim);
  border: 1px dashed rgba(0,212,255,.25); border-radius: var(--radius-sm);
  padding: .48rem; cursor: pointer; transition: all .15s; margin-top: .2rem;
}
.kp-add-btn:hover { background: rgba(0,212,255,.14); border-color: rgba(0,212,255,.45); box-shadow: 0 0 8px rgba(0,212,255,.1); }

/* Tooltip */
#hm-tooltip {
  position: fixed; pointer-events: none; display: none;
  background: linear-gradient(145deg, #020e1c 0%, #010810 100%);
  border: 1px solid var(--border-mid); border-radius: var(--radius-md);
  padding: .52rem .72rem; max-width: 280px; z-index: 999;
  box-shadow: 0 8px 32px rgba(0,0,0,.8), 0 0 0 1px rgba(0,212,255,.06);
  font-size: .74rem; font-family: var(--font-ui); line-height: 1.5;
}

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

#hm-owner-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.72);
  z-index: 300; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
}
#hm-owner-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(0,212,255,.4);
  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), 0 0 50px rgba(0,212,255,.04);
  overflow: hidden; position: relative;
}
.hm-modal-box::before {
  content: none;
}
.hm-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .82rem 1.1rem .68rem;
  border-bottom: 1px solid var(--border-faint); flex-shrink: 0;
}
.hm-modal-title { font-size: .84rem; font-family: var(--font-mono); color: var(--accent); letter-spacing: .08em; text-transform: uppercase; }
.hm-modal-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: .78rem; font-family: var(--font-mono);
  display: flex; align-items: center; justify-content: center; transition: all .15s;
}
.hm-modal-close:hover { border-color: rgba(255,61,90,.4); color: #ff7a90; background: rgba(255,61,90,.07); }

.hm-modal-body { flex: 1; overflow-y: auto; padding: .88rem 1.1rem; }
.hm-modal-body::-webkit-scrollbar { width: 3px; }
.hm-modal-body::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 1px; }
.hm-modal-footer {
  display: flex; align-items: center; justify-content: flex-end;
  gap: .5rem; padding: .68rem 1.1rem;
  border-top: 1px solid var(--border-faint); flex-shrink: 0;
}

.hm-ctx-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: .36rem .68rem;
  padding: .52rem .82rem;
  background: rgba(0,0,0,.3); border-radius: var(--radius-sm);
  margin-bottom: .82rem;
  border: 1px solid var(--border-faint); border-left: 2px solid rgba(0,212,255,.18);
}
.hm-ctx-label { font-size: .56rem; font-family: var(--font-mono); color: var(--text-muted); text-transform: uppercase; letter-spacing: .12em; margin-bottom: .07rem; }
.hm-ctx-val   { font-size: .74rem; color: var(--text-secondary); font-family: var(--font-mono); }

.form-input {
  width: 100%; background: var(--bg-base);
  border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  color: var(--text-primary); padding: .5rem .7rem;
  font-size: .86rem; font-family: inherit; outline: none; box-sizing: border-box;
}
.form-input:focus { border-color: rgba(0,212,255,.5); box-shadow: 0 0 0 2px rgba(0,212,255,.08); }

.hm-cmmi-box {
  background: rgba(0,0,0,.3); border: 1px solid var(--border-faint);
  border-radius: var(--radius-sm); padding: .5rem .7rem;
  font-size: .86rem; font-family: var(--font-mono);
  color: var(--text-muted); min-height: 2.1rem;
  display: flex; align-items: center; letter-spacing: .06em;
}
.hm-owner-row {
  display: flex; align-items: center; gap: .75rem; margin-top: .7rem;
  padding: .5rem .7rem; background: var(--bg-base);
  border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
}
.hm-owner-display { flex: 1; font-size: .82rem; font-family: var(--font-mono); color: var(--text-secondary); }
.hm-owner-row button:disabled, #hm-owner-modal button:disabled { opacity: .35; cursor: not-allowed; }

.hm-history-box { margin-top: .7rem; border: 1px solid var(--border-faint); border-radius: var(--radius-sm); overflow: hidden; }
.hm-history-title {
  font-size: .62rem; font-family: var(--font-mono);
  letter-spacing: .12em; text-transform: uppercase; color: var(--text-muted);
  padding: .36rem .6rem; background: rgba(0,0,0,.25);
  border-bottom: 1px solid var(--border-faint);
}
.hm-history-row { display: flex; justify-content: space-between; align-items: center; padding: .27rem .6rem; border-bottom: 1px solid var(--border-faint); font-size: .7rem; font-family: var(--font-mono); }
.hm-history-row:last-child { border-bottom: none; }

.kp-score-bar { height: 2px; border-radius: 1px; background: var(--border-faint); margin-top: .36rem; overflow: hidden; }
.kp-score-bar-fill { height: 100%; border-radius: 1px; transition: width .6s ease; }

/* Heatmap stat cards (legacy compat) */
.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-family: var(--font-mono); color: var(--accent); line-height: 1; }
.stat-card .stat-label { font-size: .72rem; color: var(--text-secondary); margin-top: .25rem; }

/* ════════════════════════════════════════════════════════
   THEME: DARK-MODE  (data-theme="dark")
   Professional dark, no cyberpunk effects
   ════════════════════════════════════════════════════════ */

[data-theme="dark"] {
  --bg-base:      #0d1117;
  --bg-surface:   #161b22;
  --bg-elevated:  #21262d;
  --bg-overlay:   #30363d;

  --border-faint: rgba(240,246,252,.06);
  --border-soft:  rgba(240,246,252,.1);
  --border-mid:   rgba(240,246,252,.18);

  --text-primary:   #e6edf3;
  --text-secondary: #8b949e;
  --text-muted:     #484f58;

  --accent:       #58a6ff;
  --accent-dim:   rgba(88,166,255,.1);
  --accent-glow:  rgba(88,166,255,.2);
  --green:        #3fb950;
  --red:          #f85149;

  --font-ui:   system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, 'Cascadia Code', 'Consolas', monospace;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
}

/* Body background — remove grid atmosphere */
[data-theme="dark"] body::before { display: none; }

/* Topbar — clean, no glow line */
[data-theme="dark"] .topbar {
  background: #161b22;
  box-shadow: 0 1px 0 rgba(240,246,252,.1);
}
[data-theme="dark"] .topbar::before {
  background: linear-gradient(90deg, transparent 0%, rgba(88,166,255,.35) 40%, rgba(88,166,255,.35) 60%, transparent 100%);
  box-shadow: none;
}
[data-theme="dark"] .topbar::after { display: none; }

/* Brand mark */
[data-theme="dark"] .brand-mark {
  background: #21262d;
  box-shadow: 0 0 0 1px rgba(88,166,255,.25);
}

/* Card — remove corner brackets */
[data-theme="dark"] .card {
  background: #161b22;
  border-color: rgba(240,246,252,.1);
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
[data-theme="dark"] .card::before,
[data-theme="dark"] .card::after { display: none; }

/* Page header accent line */
[data-theme="dark"] .page-header::before {
  background: #58a6ff;
  box-shadow: none;
}

/* HUD strip */
[data-theme="dark"] .hm-hud {
  background: #161b22;
  border-bottom-color: rgba(240,246,252,.1);
}
[data-theme="dark"] .hud-val { color: #e6edf3; text-shadow: none; }
[data-theme="dark"] .hud-val--n1 { text-shadow: none; }
[data-theme="dark"] .hud-val--avg { text-shadow: none; }
[data-theme="dark"] .hm-subbar { background: #161b22; border-bottom-color: rgba(240,246,252,.06); }

/* Live dot — no glow */
[data-theme="dark"] .live-dot {
  box-shadow: none;
}

/* Nav links */
[data-theme="dark"] .topbar-nav a.active {
  box-shadow: none;
}
[data-theme="dark"] .topbar-nav a.active::after {
  box-shadow: none;
}

/* Buttons */
[data-theme="dark"] .btn-primary {
  background: rgba(88,166,255,.12);
  border-color: rgba(88,166,255,.4);
  color: #58a6ff;
}
[data-theme="dark"] .btn-primary:hover {
  background: rgba(88,166,255,.22);
  border-color: #58a6ff;
  box-shadow: none;
}

/* Modals */
[data-theme="dark"] .modal {
  background: #161b22;
  border-color: rgba(240,246,252,.15);
  border-top-color: rgba(88,166,255,.4);
}
[data-theme="dark"] .modal::before { display: none; }
[data-theme="dark"] .hm-modal-box { background: #161b22; }
[data-theme="dark"] .hm-modal-box::before { display: none; }

/* Filters */
[data-theme="dark"] .filter-group select,
[data-theme="dark"] .filter-group input {
  background: #21262d;
  border-color: rgba(240,246,252,.12);
}
[data-theme="dark"] .filter-group select:focus,
[data-theme="dark"] .filter-group input:focus {
  border-color: #58a6ff;
  box-shadow: 0 0 0 2px rgba(88,166,255,.1);
}

/* Table */
[data-theme="dark"] thead th { background: #21262d; }
[data-theme="dark"] tbody tr:hover { background: rgba(88,166,255,.04); }

/* #chart scanlines — remove */
[data-theme="dark"] #chart::after { display: none; }

/* Login card */
[data-theme="dark"] .login-page::after { display: none; }

/* Admin dialog */
[data-theme="dark"] .admin-dialog {
  background: #161b22;
  border-top-color: rgba(88,166,255,.35);
  border-color: rgba(240,246,252,.15);
}

/* Theme selector UI */
.theme-selector {
  display: flex; gap: 1rem; flex-wrap: wrap;
}
.theme-card {
  flex: 1; min-width: 200px;
  border: 2px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  cursor: pointer; background: var(--bg-base);
  transition: all .18s;
  position: relative;
}
.theme-card:hover { border-color: var(--accent); background: var(--accent-dim); }
.theme-card.active {
  border-color: var(--accent);
  background: var(--accent-dim);
  box-shadow: 0 0 0 1px var(--accent), 0 0 20px rgba(0,212,255,.08);
}
.theme-card-name {
  font-size: .82rem; font-family: var(--font-mono);
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-primary); margin-bottom: .3rem;
}
.theme-card-desc {
  font-size: .74rem; color: var(--text-secondary); line-height: 1.45;
}
.theme-card-badge {
  position: absolute; top: .6rem; right: .7rem;
  font-size: .6rem; font-family: var(--font-mono); letter-spacing: .1em;
  text-transform: uppercase; background: var(--accent); color: #000;
  border-radius: 2px; padding: .12rem .36rem;
  display: none;
}
.theme-card.active .theme-card-badge { display: block; }

/* ── Theme toggle button (topbar) ───────────────────────────────────────────── */
.theme-btn-wrap {
  position: relative;
}
.theme-toggle-btn {
  display: flex; align-items: center; gap: .4rem;
  font-size: .72rem; font-family: var(--font-mono);
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid rgba(0,212,255,.25);
  border-radius: 2px;
  padding: .2rem .6rem;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.theme-toggle-btn:hover {
  background: rgba(0,212,255,.15);
  border-color: var(--accent);
}
.theme-chevron {
  transition: transform .18s;
}
.theme-btn-wrap.open .theme-chevron {
  transform: rotate(180deg);
}
.theme-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 148px;
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,.45), 0 0 0 1px rgba(0,212,255,.08);
  z-index: 200;
  overflow: hidden;
}
.theme-btn-wrap.open .theme-dropdown { display: block; }
.theme-opt {
  display: flex; align-items: center; gap: .55rem;
  width: 100%; padding: .5rem .8rem;
  font-size: .72rem; font-family: var(--font-mono);
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-secondary);
  background: transparent; border: none;
  cursor: pointer;
  transition: background .13s, color .13s;
  text-align: left;
}
.theme-opt:hover { background: var(--accent-dim); color: var(--text-primary); }
.theme-opt.active { color: var(--accent); }
.theme-opt.active .theme-opt-dot { box-shadow: 0 0 6px currentColor; }
.theme-opt-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.theme-opt-dot.futuristic { background: #00d4ff; }
.theme-opt-dot.dark       { background: #58a6ff; }

[data-theme="dark"] .theme-toggle-btn {
  color: #58a6ff;
  background: rgba(88,166,255,.1);
  border-color: rgba(88,166,255,.3);
}
[data-theme="dark"] .theme-toggle-btn:hover {
  background: rgba(88,166,255,.18);
  border-color: #58a6ff;
}

/* ── Nav dropdown (Admin ▾) ─────────────────────────────────────────────────── */
.nav-dropdown-wrap { position: relative; display: inline-flex; align-items: center; }
.nav-dropdown-trigger {
  display: flex; align-items: center; gap: .3rem;
  color: var(--text-secondary);
  font-size: .84rem; font-family: var(--font-mono);
  letter-spacing: .08em; text-transform: uppercase;
  padding: .38rem .9rem;
  border-radius: var(--radius-sm);
  transition: color .15s, background .15s;
  cursor: pointer; white-space: nowrap;
  background: transparent; border: none;
  position: relative;
}
.nav-dropdown-trigger:hover,
.nav-dropdown-wrap:hover .nav-dropdown-trigger { color: var(--text-primary); background: var(--accent-dim); }
.nav-dropdown-trigger.active {
  color: var(--accent);
  background: rgba(0,212,255,.08);
  box-shadow: inset 0 0 0 1px rgba(0,212,255,.15);
}
.nav-dropdown-trigger.active::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 15%; right: 15%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  box-shadow: 0 0 5px var(--accent);
}
.nav-dropdown-chevron { transition: transform .18s; }
.nav-dropdown-wrap:hover .nav-dropdown-chevron { transform: rotate(180deg); }
.nav-dropdown {
  display: none;
  position: absolute;
  top: 100%; left: 0;
  padding-top: 4px;
  min-width: 130px;
  background: var(--bg-surface);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,.45), 0 0 0 1px rgba(0,212,255,.08);
  z-index: 200; overflow: hidden;
}
.nav-dropdown-wrap:hover .nav-dropdown { display: block; }
.nav-dropdown a {
  display: block;
  padding: .5rem .9rem;
  font-size: .8rem; font-family: var(--font-mono);
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background .13s, color .13s;
  white-space: nowrap;
}
.nav-dropdown a:hover { background: var(--accent-dim); color: var(--text-primary); }
