/* ============================================================
   BusyBee Brain Control Center — Main Stylesheet
   Dark theme dashboard with gold accent
   ============================================================ */

/* ── Custom Properties ──────────────────────────────────────── */
:root {
  /* Colors */
  --bg-body:          #0d0d1a;
  --bg-sidebar:       #111122;
  --bg-card:          #181830;
  --bg-card-hover:    #1e1e3a;
  --bg-input:         #0f0f22;
  --bg-overlay:       rgba(13, 13, 26, 0.85);

  --border-subtle:    rgba(255, 255, 255, 0.06);
  --border-card:      rgba(255, 255, 255, 0.06);
  --border-focus:     rgba(245, 197, 24, 0.5);

  --text-primary:     #f0f0f8;
  --text-secondary:   #8888aa;
  --text-muted:       #555577;
  --text-inverse:     #0d0d1a;

  --gold:             #f5c518;
  --gold-dark:        #c9a010;
  --gold-dim:         rgba(245, 197, 24, 0.15);
  --gold-glow:        rgba(245, 197, 24, 0.3);

  --green:            #22c55e;
  --green-dim:        rgba(34, 197, 94, 0.15);
  --red:              #ef4444;
  --red-dim:          rgba(239, 68, 68, 0.15);
  --orange:           #f97316;
  --orange-dim:       rgba(249, 115, 22, 0.15);
  --blue:             #60a5fa;
  --blue-dim:         rgba(96, 165, 250, 0.15);
  --purple:           #a78bfa;
  --purple-dim:       rgba(167, 139, 250, 0.15);

  /* Layout */
  --sidebar-width:    220px;
  --header-height:    60px;
  --content-padding:  24px;
  --card-radius:      12px;
  --radius-sm:        6px;
  --radius-md:        8px;
  --radius-lg:        12px;
  --radius-xl:        16px;
  --radius-full:      9999px;

  /* Typography */
  --font-sans:        system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:        'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  --text-xs:          0.7rem;
  --text-sm:          0.8125rem;
  --text-base:        0.9375rem;
  --text-lg:          1.0625rem;
  --text-xl:          1.25rem;
  --text-2xl:         1.5rem;
  --text-3xl:         1.875rem;

  --weight-normal:    400;
  --weight-medium:    500;
  --weight-semibold:  600;
  --weight-bold:      700;

  /* Shadows */
  --shadow-sm:        0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md:        0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg:        0 8px 24px rgba(0, 0, 0, 0.6);
  --shadow-gold:      0 0 20px rgba(245, 197, 24, 0.2);
  --shadow-glow:      0 0 30px rgba(245, 197, 24, 0.15);

  /* Transitions */
  --transition-fast:  120ms ease;
  --transition-base:  200ms ease;
  --transition-slow:  300ms ease;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-normal);
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-body);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

img, svg {
  display: block;
  max-width: 100%;
}

ul, ol {
  list-style: none;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--weight-semibold);
  line-height: 1.3;
  color: var(--text-primary);
}

/* ── Scrollbar Styling ──────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-body);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

::-webkit-scrollbar-corner {
  background: var(--bg-body);
}

/* ── Layout: App Shell ──────────────────────────────────────── */
.app {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar::-webkit-scrollbar {
  width: 3px;
}

/* Sidebar Header / Logo */
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.bee-logo {
  width: 36px;
  height: 36px;
  background: var(--gold);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  clip-path: polygon(50% 0%, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
  box-shadow: var(--shadow-gold);
  position: relative;
}

.bee-logo-icon {
  font-size: 18px;
  line-height: 1;
}

.sidebar-brand {
  min-width: 0;
}

.sidebar-brand-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.02em;
}

.sidebar-brand-sub {
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
}

/* Sidebar Nav */
.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.sidebar-section {
  margin-bottom: 4px;
}

.sidebar-section-label {
  font-size: 0.625rem;
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 10px 16px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  border-radius: 0;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  transition: background var(--transition-fast), color var(--transition-fast);
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--gold-dim);
  color: var(--gold);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--gold);
  border-radius: 0 2px 2px 0;
}

.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon {
  opacity: 1;
}

.nav-badge {
  margin-left: auto;
  background: var(--gold);
  color: var(--text-inverse);
  font-size: 0.625rem;
  font-weight: var(--weight-bold);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  line-height: 1.6;
}

.nav-badge.red {
  background: var(--red);
  color: #fff;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-version {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-align: center;
}

/* ── Main Content ───────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ── Page Body ──────────────────────────────────────────────── */
.page-body {
  flex: 1;
  padding: 24px 28px;
  overflow-y: auto;
  min-height: 0;
}

.page-section.active {
  display: block;
}

/* ── Top Header Bar ─────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-height);
  background: rgba(13, 13, 26, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 var(--content-padding);
  gap: 16px;
}

.topbar-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
}

.topbar-subtitle {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: var(--weight-normal);
  margin-top: 1px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* System Health Badge */
.health-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.health-badge.all-green {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, 0.25);
}

.health-badge.degraded {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.health-badge.warning {
  background: var(--orange-dim);
  color: var(--orange);
  border: 1px solid rgba(249, 115, 22, 0.25);
}

.health-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.health-badge.all-green .health-badge-dot {
  animation: pulse-green 2s ease-in-out infinite;
}

/* JA Bootstrap Button */
.btn-ja-bootstrap {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--gold);
  color: var(--text-inverse);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: background var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.btn-ja-bootstrap:hover {
  background: var(--gold-dark);
  box-shadow: var(--shadow-gold);
  transform: translateY(-1px);
}

.btn-ja-bootstrap:active {
  transform: translateY(0);
  box-shadow: none;
}

/* ── Page Content ───────────────────────────────────────────── */
.page-content {
  padding: var(--content-padding);
  flex: 1;
}

.page-section {
  margin-bottom: 32px;
  display: none;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.section-title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title-icon {
  color: var(--gold);
  font-size: 14px;
}

.section-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ── Card Base ──────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--card-radius);
  padding: 20px;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.1);
}

.card-sm {
  padding: 14px 16px;
}

.card-lg {
  padding: 28px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 8px;
}

.card-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.card-subtitle {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Status Dots ────────────────────────────────────────────── */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.green  { background: var(--green); }
.status-dot.red    { background: var(--red); }
.status-dot.orange { background: var(--orange); }
.status-dot.blue   { background: var(--blue); }
.status-dot.gold   { background: var(--gold); }
.status-dot.muted  { background: var(--text-muted); }

.status-dot.pulse-green {
  background: var(--green);
  animation: pulse-green 2s ease-in-out infinite;
}

.status-dot.pulse-gold {
  background: var(--gold);
  animation: pulse-gold 2s ease-in-out infinite;
}

/* ── Layer Health Grid ──────────────────────────────────────── */
.layer-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}

.layer-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color var(--transition-base), transform var(--transition-fast);
  cursor: default;
}

.layer-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
}

.layer-card.healthy {
  border-color: rgba(34, 197, 94, 0.2);
}

.layer-card.error {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.04);
}

.layer-card.warning {
  border-color: rgba(249, 115, 22, 0.2);
}

.layer-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.layer-name {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.layer-status-label {
  font-size: 0.625rem;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: var(--radius-full);
}

.layer-status-label.ok      { background: var(--green-dim);  color: var(--green); }
.layer-status-label.fail    { background: var(--red-dim);    color: var(--red); }
.layer-status-label.warn    { background: var(--orange-dim); color: var(--orange); }
.layer-status-label.idle    { background: var(--border-subtle); color: var(--text-muted); }

.layer-metric {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  line-height: 1;
}

.layer-metric-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ── Mission Kanban ─────────────────────────────────────────── */
.kanban-scroll {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 8px;
  scroll-snap-type: x mandatory;
}

.kanban-scroll::-webkit-scrollbar {
  height: 5px;
}

.kanban-col {
  min-width: 280px;
  width: 280px;
  flex-shrink: 0;
  scroll-snap-align: start;
}

.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 0 2px;
}

.kanban-col-title {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.kanban-count {
  background: var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.625rem;
  font-weight: var(--weight-bold);
  padding: 1px 7px;
  border-radius: var(--radius-full);
}

.kanban-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kanban-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color var(--transition-base), box-shadow var(--transition-fast);
}

.kanban-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow-md);
}

.kanban-card.priority-high {
  border-left: 3px solid var(--red);
}

.kanban-card.priority-med {
  border-left: 3px solid var(--orange);
}

.kanban-card.priority-low {
  border-left: 3px solid var(--blue);
}

.kanban-card-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  margin-bottom: 6px;
  line-height: 1.4;
}

.kanban-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-xs);
  color: var(--text-muted);
  flex-wrap: wrap;
}

.kanban-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-size: 0.625rem;
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--border-subtle);
  color: var(--text-muted);
}

.kanban-tag.gold   { background: var(--gold-dim);   color: var(--gold); }
.kanban-tag.green  { background: var(--green-dim);  color: var(--green); }
.kanban-tag.red    { background: var(--red-dim);    color: var(--red); }
.kanban-tag.blue   { background: var(--blue-dim);   color: var(--blue); }

/* ── Council Cards ──────────────────────────────────────────── */
.council-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

.council-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--card-radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color var(--transition-base);
}

.council-card:hover {
  border-color: rgba(255, 255, 255, 0.1);
}

.council-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: var(--gold-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.council-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.council-role {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.verdict-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.625rem;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  width: fit-content;
}

.verdict-badge.proceed {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.verdict-badge.flag {
  background: var(--orange-dim);
  color: var(--orange);
  border: 1px solid rgba(249, 115, 22, 0.2);
}

.verdict-badge.block {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.council-comment {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: 1.5;
  border-top: 1px solid var(--border-subtle);
  padding-top: 10px;
}

/* ── Memory Items ───────────────────────────────────────────── */
.memory-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.memory-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-base), background var(--transition-fast);
  cursor: pointer;
}

.memory-item:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.1);
}

.memory-icon {
  font-size: 14px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.memory-content {
  flex: 1;
  min-width: 0;
}

.memory-title {
  font-size: var(--text-sm);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.memory-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 1px;
}

.memory-score-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.memory-score-bar {
  width: 60px;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.memory-score-fill {
  height: 100%;
  background: var(--gold);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

.memory-score-val {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--gold);
  width: 28px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Iron Laws Checklist ────────────────────────────────────── */
.iron-laws-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.iron-law-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
}

.iron-law-check {
  width: 18px;
  height: 18px;
  border-radius: var(--radius-sm);
  background: var(--green-dim);
  border: 1px solid rgba(34, 197, 94, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.iron-law-check-icon {
  color: var(--green);
  font-size: 11px;
  line-height: 1;
}

.iron-law-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}

.iron-law-text strong {
  color: var(--text-primary);
  font-weight: var(--weight-semibold);
}

/* ── Autonomy Sliders ───────────────────────────────────────── */
.autonomy-controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.autonomy-control {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.autonomy-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.autonomy-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
}

.autonomy-value {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.autonomy-desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Custom Range Input */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
  position: relative;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: var(--radius-full);
  background: linear-gradient(to right, var(--gold) var(--range-pct, 50%), rgba(255, 255, 255, 0.08) var(--range-pct, 50%));
}

input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  border: none;
}

input[type="range"]::-moz-range-progress {
  height: 6px;
  background: var(--gold);
  border-radius: var(--radius-full);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--bg-card);
  box-shadow: 0 0 0 1px var(--gold), var(--shadow-gold);
  margin-top: -6px;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 0 0 1px var(--gold), 0 0 12px rgba(245, 197, 24, 0.5);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--bg-card);
  box-shadow: 0 0 0 1px var(--gold);
  cursor: pointer;
}

/* ── Stats Row ──────────────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--card-radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: var(--weight-medium);
}

.stat-value {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-value.gold   { color: var(--gold); }
.stat-value.green  { color: var(--green); }
.stat-value.red    { color: var(--red); }
.stat-value.blue   { color: var(--blue); }

.stat-change {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 2px;
}

.stat-change.up   { color: var(--green); }
.stat-change.down { color: var(--red); }
.stat-change.flat { color: var(--text-muted); }

/* ── Activity Feed ──────────────────────────────────────────── */
.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-dot-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 3px;
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.activity-line {
  width: 1px;
  flex: 1;
  background: var(--border-subtle);
  margin: 4px 0;
  min-height: 12px;
}

.activity-item:last-child .activity-line {
  display: none;
}

.activity-content {
  flex: 1;
  min-width: 0;
}

.activity-text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}

.activity-text strong {
  color: var(--text-primary);
  font-weight: var(--weight-semibold);
}

.activity-time {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 3px;
}

/* ── Log / Terminal ─────────────────────────────────────────── */
.log-panel {
  background: #090916;
  border: 1px solid var(--border-card);
  border-radius: var(--card-radius);
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.7;
  max-height: 320px;
  overflow-y: auto;
}

.log-line {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.log-ts {
  color: var(--text-muted);
  flex-shrink: 0;
  font-size: 0.75rem;
  padding-top: 1px;
}

.log-level {
  font-size: 0.625rem;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 5px;
  border-radius: 3px;
  flex-shrink: 0;
  margin-top: 2px;
}

.log-level.info  { background: var(--blue-dim);   color: var(--blue); }
.log-level.ok    { background: var(--green-dim);  color: var(--green); }
.log-level.warn  { background: var(--orange-dim); color: var(--orange); }
.log-level.error { background: var(--red-dim);    color: var(--red); }
.log-level.debug { background: var(--purple-dim); color: var(--purple); }

.log-msg {
  color: var(--text-secondary);
  word-break: break-word;
}

.log-msg .highlight {
  color: var(--gold);
}

/* ── Progress Bar ───────────────────────────────────────────── */
.progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--gold);
  transition: width var(--transition-slow);
}

.progress-fill.green  { background: var(--green); }
.progress-fill.red    { background: var(--red); }
.progress-fill.blue   { background: var(--blue); }
.progress-fill.orange { background: var(--orange); }

/* ── Data Table ─────────────────────────────────────────────── */
.data-table-wrap {
  overflow-x: auto;
  border-radius: var(--card-radius);
  border: 1px solid var(--border-card);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.data-table th {
  background: rgba(255, 255, 255, 0.03);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.data-table td strong {
  color: var(--text-primary);
  font-weight: var(--weight-medium);
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  border: none;
  cursor: pointer;
  transition: background var(--transition-fast), opacity var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  white-space: nowrap;
  line-height: 1;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--gold);
  color: var(--text-inverse);
}

.btn-primary:hover {
  background: var(--gold-dark);
  box-shadow: var(--shadow-gold);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-primary);
  border: 1px solid var(--border-card);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.11);
}

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.btn-sm {
  padding: 5px 10px;
  font-size: var(--text-xs);
}

.btn-lg {
  padding: 11px 20px;
  font-size: var(--text-base);
}

.btn-icon {
  padding: 7px;
  width: 32px;
  height: 32px;
  justify-content: center;
}

/* ── Badges / Pills ─────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: 1.5;
}

.badge-gold   { background: var(--gold-dim);   color: var(--gold); }
.badge-green  { background: var(--green-dim);  color: var(--green); }
.badge-red    { background: var(--red-dim);    color: var(--red); }
.badge-orange { background: var(--orange-dim); color: var(--orange); }
.badge-blue   { background: var(--blue-dim);   color: var(--blue); }
.badge-purple { background: var(--purple-dim); color: var(--purple); }
.badge-muted  { background: var(--border-subtle); color: var(--text-muted); }

/* ── Form Inputs ────────────────────────────────────────────── */
.input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-size: var(--text-sm);
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}

.input::placeholder {
  color: var(--text-muted);
}

select.input {
  cursor: pointer;
}

.input-group {
  display: flex;
  gap: 8px;
  align-items: center;
}

.form-label {
  display: block;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 6px;
}

/* ── Divider ────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 20px 0;
}

/* ── Tooltip ────────────────────────────────────────────────── */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #2a2a45;
  color: var(--text-primary);
  font-size: var(--text-xs);
  white-space: nowrap;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition-fast);
  z-index: 200;
  box-shadow: var(--shadow-md);
}

[data-tooltip]:hover::after {
  opacity: 1;
}

/* ── Loading Spinner ────────────────────────────────────────── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(245, 197, 24, 0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
  display: inline-block;
  flex-shrink: 0;
}

.spinner-sm {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

.spinner-lg {
  width: 28px;
  height: 28px;
  border-width: 3px;
}

/* ── Empty State ────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  gap: 12px;
}

.empty-state-icon {
  font-size: 36px;
  opacity: 0.4;
}

.empty-state-title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
}

.empty-state-desc {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 300px;
}

/* ── Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade-in 150ms ease;
}

.modal {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  animation: slide-up 180ms ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

.modal-close {
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast), background var(--transition-fast);
}

.modal-close:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.07);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
}

/* ── Notification Toast ─────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--card-radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  pointer-events: all;
  animation: slide-in-right 200ms ease;
  min-width: 280px;
  max-width: 380px;
}

.toast-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.toast-message {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  flex: 1;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.warning { border-left: 3px solid var(--orange); }
.toast.info    { border-left: 3px solid var(--blue); }

/* ── Tabs ───────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 20px;
}

.tab {
  padding: 9px 16px;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  white-space: nowrap;
}

.tab:hover {
  color: var(--text-secondary);
}

.tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

/* ── Key-Value Pairs ────────────────────────────────────────── */
.kv-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kv-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: var(--text-sm);
}

.kv-key {
  color: var(--text-muted);
  flex-shrink: 0;
}

.kv-val {
  color: var(--text-primary);
  font-weight: var(--weight-medium);
  text-align: right;
  word-break: break-all;
}

.kv-val.mono {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

/* ── Sparkline placeholder ──────────────────────────────────── */
.sparkline {
  width: 100%;
  height: 36px;
  display: flex;
  align-items: flex-end;
  gap: 2px;
}

.sparkline-bar {
  flex: 1;
  background: var(--gold-dim);
  border-radius: 2px 2px 0 0;
  min-height: 4px;
  transition: background var(--transition-fast);
}

.sparkline-bar:hover {
  background: var(--gold);
}

/* ── Utility Classes ────────────────────────────────────────── */
.flex         { display: flex; }
.flex-col     { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.items-end    { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-end  { justify-content: flex-end; }
.justify-center  { justify-content: center; }
.gap-2        { gap: 8px; }
.gap-3        { gap: 12px; }
.gap-4        { gap: 16px; }
.gap-6        { gap: 24px; }
.flex-1       { flex: 1; }
.min-w-0      { min-width: 0; }
.w-full       { width: 100%; }
.grid-2       { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid-3       { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-4       { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.truncate     { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.text-xs      { font-size: var(--text-xs); }
.text-sm      { font-size: var(--text-sm); }
.text-base    { font-size: var(--text-base); }
.text-lg      { font-size: var(--text-lg); }
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted   { color: var(--text-muted); }
.text-gold    { color: var(--gold); }
.text-green   { color: var(--green); }
.text-red     { color: var(--red); }
.text-orange  { color: var(--orange); }
.text-blue    { color: var(--blue); }
.font-medium  { font-weight: var(--weight-medium); }
.font-semibold { font-weight: var(--weight-semibold); }
.font-bold    { font-weight: var(--weight-bold); }
.font-mono    { font-family: var(--font-mono); }
.mt-1         { margin-top: 4px; }
.mt-2         { margin-top: 8px; }
.mt-3         { margin-top: 12px; }
.mt-4         { margin-top: 16px; }
.mb-1         { margin-bottom: 4px; }
.mb-2         { margin-bottom: 8px; }
.mb-3         { margin-bottom: 12px; }
.mb-4         { margin-bottom: 16px; }
.mb-6         { margin-bottom: 24px; }
.p-0          { padding: 0; }
.opacity-50   { opacity: 0.5; }
.opacity-70   { opacity: 0.7; }
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.hidden       { display: none !important; }

/* ── Animations ─────────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse-green {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
    opacity: 1;
  }
  50% {
    box-shadow: 0 0 0 5px rgba(34, 197, 94, 0);
    opacity: 0.85;
  }
}

@keyframes pulse-gold {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(245, 197, 24, 0.5);
    opacity: 1;
  }
  50% {
    box-shadow: 0 0 0 5px rgba(245, 197, 24, 0);
    opacity: 0.85;
  }
}

@keyframes pulse-red {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5);
    opacity: 1;
  }
  50% {
    box-shadow: 0 0 0 5px rgba(239, 68, 68, 0);
    opacity: 0.85;
  }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

@keyframes shimmer {
  0%   { background-position: -200% center; }
  100% { background-position: 200% center; }
}

.animate-spin         { animation: spin 700ms linear infinite; }
.animate-pulse-green  { animation: pulse-green 2s ease-in-out infinite; }
.animate-pulse-gold   { animation: pulse-gold 2s ease-in-out infinite; }
.animate-pulse-red    { animation: pulse-red 2s ease-in-out infinite; }
.animate-fade-in      { animation: fade-in 300ms ease; }

/* Skeleton loading */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0.04) 25%,
    rgba(255,255,255,0.09) 50%,
    rgba(255,255,255,0.04) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  border-radius: var(--radius-md);
}

/* ── Responsive — Tablet ────────────────────────────────────── */
@media (max-width: 1280px) {
  .layer-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .council-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1024px) {
  :root {
    --sidebar-width: 200px;
  }

  .council-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .layer-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ── Responsive — Mobile ────────────────────────────────────── */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 0px;
    --content-padding: 16px;
  }

  /* Sidebar collapses off-screen */
  .sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition-slow);
    width: 220px;
    box-shadow: var(--shadow-lg);
    z-index: 200;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Mobile overlay when sidebar open */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 190;
  }

  .sidebar.open ~ .sidebar-backdrop {
    display: block;
  }

  .main {
    margin-left: 0;
  }

  /* Mobile menu toggle */
  .mobile-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
  }

  .topbar {
    padding: 0 16px;
  }

  .layer-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .council-grid {
    grid-template-columns: 1fr 1fr;
  }

  .stats-row {
    grid-template-columns: 1fr 1fr;
  }

  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .topbar-title {
    font-size: var(--text-base);
  }

  .btn-ja-bootstrap span {
    display: none;
  }

  .toast-container {
    bottom: 16px;
    right: 16px;
    left: 16px;
  }

  .toast {
    min-width: 0;
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .layer-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .council-grid {
    grid-template-columns: 1fr;
  }

  .stats-row {
    grid-template-columns: 1fr;
  }

  .kanban-col {
    min-width: 260px;
    width: 260px;
  }

  .modal {
    padding: 20px;
  }
}

/* Mobile toggle hidden by default on desktop */
.mobile-menu-btn {
  display: none;
}

/* ── Print ──────────────────────────────────────────────────── */
@media print {
  .sidebar,
  .topbar,
  .btn,
  .modal-overlay,
  .toast-container {
    display: none !important;
  }

  .main {
    margin-left: 0;
  }

  body {
    background: #fff;
    color: #000;
  }
}
