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

/* === COLOR SYSTEM === */
:root {
  /* Light Mode (default) */
  --bg-primary: #f8f7f4;
  --bg-secondary: #efeee9;
  --bg-tertiary: #e5e4df;
  --panel: #ffffff;
  --border: #d4d3ce;
  --gold: #a08030;
  --gold-dim: #c9b87a;
  --text-primary: #1a1a1a;
  --text-secondary: #6b6b6b;
  --muted: #8a8a80;
  
  /* Knights */
  --merlin: #7c3aed;
  --morgana: #dc2626;
  --percival: #16a34a;
  --lancelot: #2563eb;
  --galahad: #71717a;
  
  /* Status */
  --success: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  
  /* Legacy aliases */
  --bg: var(--bg-primary);
  --bg2: var(--bg-secondary);
  --bg3: var(--bg-tertiary);
  --text: var(--text-primary);
  --accent: var(--gold);
}

/* Dark Mode */
[data-theme="dark"] {
  --bg-primary: #08080f;
  --bg-secondary: #0f0f1a;
  --bg-tertiary: #161625;
  --panel: #1a1a2e;
  --border: #2a2a45;
  --gold: #c9a84c;
  --gold-dim: #6b5a2a;
  --text-primary: #e0d8c8;
  --text-secondary: #a0a0a0;
  --muted: #6b6580;
}

/* System preference fallback */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-primary: #08080f;
    --bg-secondary: #0f0f1a;
    --bg-tertiary: #161625;
    --panel: #1a1a2e;
    --border: #2a2a45;
    --gold: #c9a84c;
    --gold-dim: #6b5a2a;
    --text-primary: #e0d8c8;
    --text-secondary: #a0a0a0;
    --muted: #6b6580;
  }
}

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

html, body { 
  height: 100%; 
  font-family: 'JetBrains Mono', monospace; 
  background: var(--bg-primary); 
  color: var(--text-primary); 
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

@media (min-width: 768px) {
  html, body { font-size: 13px; overflow: hidden; }
}

/* === LAYOUT === */
#app { 
  display: flex; 
  flex-direction: column;
  min-height: 100vh;
}

@media (min-width: 768px) {
  #app { flex-direction: row; height: 100vh; }
}

/* === HEADER MOBILE === */
.mobile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.mobile-header h1 {
  font-size: 16px;
  color: var(--gold);
  letter-spacing: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle, .menu-toggle, .notification-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
  width: 44px;
  height: 44px;
  border-radius: 4px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle:hover, .menu-toggle:hover, .notification-toggle:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.notification-toggle.active {
  background: rgba(34, 197, 94, 0.1);
  border-color: var(--success);
  color: var(--success);
}

.notification-toggle.pending {
  animation: pulse 1s infinite;
}

@media (min-width: 768px) {
  .mobile-header { display: none; }
  .menu-toggle { display: none; }
}

/* === SIDEBAR === */
#sidebar {
  width: 100%;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: none;
  flex-direction: column;
  padding: 16px 0;
  overflow-y: auto;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 200;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}

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

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 150;
}

.sidebar-overlay.active {
  display: block;
}

@media (min-width: 768px) {
  #sidebar {
    display: flex;
    position: relative;
    transform: none;
    width: 220px;
    min-width: 220px;
    height: auto;
  }
  .sidebar-overlay { display: none !important; }
}

.sidebar-header {
  padding: 0 16px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-header h1 { font-size: 16px; color: var(--gold); letter-spacing: 2px; }
.sidebar-header .subtitle { font-size: 10px; color: var(--muted); margin-top: 2px; }

.sidebar-close {
  display: flex;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
}

@media (min-width: 768px) {
  .sidebar-close { display: none; }
}

/* Desktop header actions in sidebar */
.sidebar-actions {
  display: none;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

@media (min-width: 768px) {
  .sidebar-actions { display: flex; }
}

.sidebar-vitals {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; 
  flex-direction: column; 
  gap: 8px;
}

.vital { display: flex; justify-content: space-between; align-items: center; min-height: 28px; }
.vital-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.vital-value { font-size: 12px; color: var(--text-primary); font-weight: 500; }
.vital-value.gold { color: var(--gold); }
.vital-value.green { color: var(--success); }
.vital-value.warn { color: var(--warn); }

.sidebar-insight {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
}
.sidebar-insight .label { color: var(--gold); font-size: 9px; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 4px; }

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

.nav-item {
  display: flex; 
  align-items: center; 
  gap: 10px;
  padding: 14px 16px;
  cursor: pointer;
  color: var(--muted); 
  transition: all 0.15s;
  border-left: 2px solid transparent;
  font-size: 14px;
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
}

@media (min-width: 768px) {
  .nav-item { padding: 10px 16px; font-size: 12px; min-height: auto; }
}

.nav-item:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.nav-item.active { color: var(--gold); border-left-color: var(--gold); background: rgba(201,168,76,0.05); }
.nav-item .icon { font-size: 16px; width: 24px; text-align: center; }

@media (min-width: 768px) {
  .nav-item .icon { font-size: 14px; width: 20px; }
}

/* KNIGHTS mini status */
.sidebar-knights {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.knights-label { font-size: 9px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; margin-bottom: 8px; }
.knight-mini { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; font-size: 11px; min-height: 32px; }
.knight-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); transition: all 0.3s; flex-shrink: 0; }
.knight-dot.idle { background: var(--muted); }
.knight-dot.thinking { background: var(--warn); box-shadow: 0 0 6px var(--warn); animation: pulse 1s infinite; }
.knight-dot.error { background: var(--danger); }

/* === MAIN === */
#main { 
  flex: 1; 
  overflow-y: auto;
  display: flex; 
  flex-direction: column;
}

@media (min-width: 768px) {
  #main { overflow: hidden; }
}

/* MODULE HEADER */
.module-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  display: flex; 
  align-items: center; 
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}

@media (min-width: 768px) {
  .module-header { padding: 16px 24px; position: relative; }
}

.module-header h2 { font-size: 14px; color: var(--text-primary); letter-spacing: 1px; }
.module-header .module-icon { font-size: 18px; }

/* MODULE CONTENT */
.module { display: none; flex: 1; overflow-y: auto; padding: 16px; }
.module.active { display: block; }

@media (min-width: 768px) {
  .module { padding: 24px; }
}

/* === CARDS === */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 16px;
}

.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; 
  align-items: center; 
  gap: 8px;
  font-size: 11px; 
  color: var(--gold); 
  text-transform: uppercase; 
  letter-spacing: 1px;
}

.card-body { padding: 16px; }

/* === GRID — Mobile First === */
.grid-2, .grid-3 { 
  display: flex;
  flex-direction: column;
  gap: 16px; 
}

@media (min-width: 768px) {
  .grid-2 { display: grid; grid-template-columns: 1fr 1fr; }
  .grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; }
}

/* === TABLES === */
table { width: 100%; border-collapse: collapse; }
th { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; padding: 8px; text-align: left; border-bottom: 1px solid var(--border); }
td { padding: 10px 8px; border-bottom: 1px solid rgba(255,255,255,0.04); font-size: 12px; }
tr:last-child td { border-bottom: none; }

/* === TASKS === */
.task-item { 
  display: flex; 
  align-items: center; 
  gap: 8px; 
  padding: 10px 0; 
  border-bottom: 1px solid rgba(255,255,255,0.04); 
  flex-wrap: wrap;
}
.task-item:last-child { border: none; }
.task-id { font-size: 10px; color: var(--muted); width: 40px; flex-shrink: 0; }
.task-title { flex: 1; font-size: 13px; min-width: 0; }
.task-done .task-title { text-decoration: line-through; color: var(--muted); }

.task-done-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid rgba(34,197,94,0.3);
  color: rgba(34,197,94,0.5);
  border-radius: 3px;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.task-done-btn:hover {
  background: rgba(34,197,94,0.15);
  border-color: rgba(34,197,94,0.7);
  color: #22c55e;
}

/* === ALERTS === */
.alert { padding: 12px 14px; border-radius: 4px; font-size: 13px; margin-bottom: 10px; border-left: 3px solid; }
.alert-warn { background: rgba(245,158,11,0.08); border-color: var(--warn); color: var(--warn); }
.alert-info { background: rgba(139,92,246,0.08); border-color: var(--merlin); color: #a78bfa; }

/* === PIPELINE === */
.pipeline-form { 
  display: flex; 
  flex-direction: column;
  gap: 8px; 
  margin-bottom: 16px; 
}

@media (min-width: 768px) {
  .pipeline-form { flex-direction: row; }
}

.pipeline-form input {
  flex: 1; 
  background: var(--bg-tertiary); 
  border: 1px solid var(--border);
  color: var(--text-primary); 
  padding: 12px 14px; 
  font-family: inherit; 
  font-size: 16px;
  border-radius: 4px; 
  outline: none;
}

@media (min-width: 768px) {
  .pipeline-form input { font-size: 13px; padding: 10px 14px; }
}

.pipeline-form input:focus { border-color: var(--gold); }

/* === BUTTONS === */
button {
  background: var(--bg-tertiary); 
  border: 1px solid var(--border);
  color: var(--text-primary); 
  padding: 12px 16px; 
  font-family: inherit; 
  font-size: 14px;
  cursor: pointer; 
  border-radius: 4px; 
  transition: all 0.15s;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}

@media (min-width: 768px) {
  button { padding: 8px 16px; font-size: 12px; min-height: auto; }
}

button:hover { border-color: var(--gold); color: var(--gold); }
button.primary { background: rgba(201,168,76,0.1); border-color: var(--gold); color: var(--gold); }

/* === STAGE LIST === */
.stage-list { display: flex; flex-direction: column; gap: 8px; }
.stage-item {
  display: flex; 
  align-items: flex-start; 
  gap: 12px;
  padding: 12px 14px; 
  background: var(--bg-tertiary); 
  border-radius: 4px;
  border-left: 3px solid var(--border);
}
.stage-item.done { border-left-color: var(--success); }
.stage-item.active { border-left-color: var(--warn); animation: pulse-border 1s infinite; }
.stage-item.retry { border-left-color: var(--danger); }
.stage-num { font-size: 10px; color: var(--muted); width: 20px; padding-top: 2px; }
.stage-content { flex: 1; min-width: 0; }
.stage-knight { font-size: 11px; color: var(--gold); margin-bottom: 4px; }
.stage-output { font-size: 11px; color: var(--muted); line-height: 1.5; max-height: 80px; overflow: hidden; word-break: break-word; }

/* === SEARCH === */
.search-wrap { 
  display: flex; 
  flex-direction: column;
  gap: 8px; 
  margin-bottom: 16px; 
}

@media (min-width: 768px) {
  .search-wrap { flex-direction: row; }
}

.search-wrap input { 
  flex: 1; 
  background: var(--bg-tertiary); 
  border: 1px solid var(--border); 
  color: var(--text-primary); 
  padding: 12px 14px; 
  font-family: inherit; 
  font-size: 16px; 
  border-radius: 4px; 
  outline: none; 
}

@media (min-width: 768px) {
  .search-wrap input { font-size: 13px; }
}

.search-wrap input:focus { border-color: var(--gold); }
.search-result { padding: 12px 14px; background: var(--bg-tertiary); border-radius: 4px; margin-bottom: 8px; border-left: 3px solid var(--gold-dim); }
.search-file { font-size: 10px; color: var(--gold); margin-bottom: 4px; }
.search-snippet { font-size: 12px; color: var(--muted); line-height: 1.5; }

/* === SKY / ASPECTS === */
.aspect { font-size: 12px; padding: 6px 0; color: var(--muted); }
.aspect strong { color: var(--text-primary); }
.aspect .trine { color: var(--success); }
.aspect .square { color: var(--danger); }
.aspect .conj { color: var(--gold); }
.aspect .opp { color: var(--danger); }
.aspect .sext { color: var(--percival); }

/* === CRON TOGGLE === */
.cron-enabled { color: var(--success); }
.cron-disabled { color: var(--muted); }
.toggle-btn { padding: 6px 12px; font-size: 11px; }

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* === ANIMATIONS === */
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes pulse-border { 0%,100% { border-left-color: var(--warn); } 50% { border-left-color: transparent; } }

/* === PIPELINE HISTORY === */
.pipeline-row { 
  padding: 10px 12px; 
  background: var(--bg-tertiary); 
  border-radius: 4px; 
  margin-bottom: 6px; 
  cursor: pointer; 
  display: flex; 
  align-items: center; 
  gap: 10px; 
}
.pipeline-row:hover { border: 1px solid var(--border); }
.pipeline-status { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.pipeline-status.done { background: var(--success); }
.pipeline-status.running { background: var(--warn); animation: pulse 1s infinite; }
.pipeline-status.error { background: var(--danger); }
.pipeline-topic { flex: 1; font-size: 12px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pipeline-time { font-size: 10px; color: var(--muted); flex-shrink: 0; }

/* === ACTIVITY FEED === */
.activity-item {
  display: flex; 
  align-items: flex-start; 
  gap: 10px;
  padding: 10px 12px; 
  border-radius: 4px; 
  margin-bottom: 4px;
  background: var(--bg-tertiary); 
  transition: background 0.3s;
}
.activity-new { background: rgba(201,168,76,0.12); }
.activity-icon { font-size: 14px; width: 20px; flex-shrink: 0; padding-top: 1px; }
.activity-content { flex: 1; min-width: 0; }
.activity-title { font-size: 13px; color: var(--text-primary); }
.activity-detail { font-size: 11px; color: var(--muted); margin-top: 2px; word-break: break-word; }
.activity-time { font-size: 10px; color: var(--muted); white-space: nowrap; padding-top: 2px; flex-shrink: 0; }

/* === KNIGHT CARDS === */
.knight-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px 8px;
  text-align: center;
  transition: border-color 0.3s;
}
.knight-card:hover { border-color: rgba(201,168,76,0.4); }
.knight-card.active { border-color: var(--success); }
.knight-card .kc-icon { font-size: 22px; margin-bottom: 4px; }
.knight-card .kc-name { font-size: 11px; font-weight: 600; margin-bottom: 2px; }
.knight-card .kc-model { font-size: 9px; color: var(--muted); margin-bottom: 4px; }
.knight-card .kc-status { font-size: 9px; padding: 2px 6px; border-radius: 2px; display: inline-block; }
.knight-card .kc-last { font-size: 9px; color: var(--muted); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Knight cards grid - mobile friendly */
#knight-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

@media (min-width: 768px) {
  #knight-cards { grid-template-columns: repeat(5, 1fr); gap: 10px; }
}

/* === NOTIFICATION BADGE === */
.notification-badge {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--gold);
  color: var(--bg-primary);
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 1000;
  animation: slideIn 0.3s ease;
  cursor: pointer;
  max-width: calc(100vw - 40px);
}

.notification-badge.hidden { display: none; }

@keyframes slideIn {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* === RESPONSIVE TWEAKS === */
@media (max-width: 767px) {
  /* Stack 4-column grids to 2 on mobile */
  [style*="grid-template-columns: repeat(4"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  
  /* Full width tables scroll */
  .card-body { overflow-x: auto; }
  
  /* Smaller section headers */
  .card-header { font-size: 10px; }
  
  /* Transits - full width */
  #hand-transits-hoje > div { padding: 10px !important; }
}

/* === INPUTS & SELECTS === */
select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 12px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 14px;
  min-height: 44px;
  -webkit-appearance: none;
  cursor: pointer;
}

@media (min-width: 768px) {
  select { font-size: 12px; padding: 6px 10px; min-height: auto; }
}

input[type="text"], input[type="search"], input[type="email"] {
  font-size: 16px;
}

@media (min-width: 768px) {
  input[type="text"], input[type="search"], input[type="email"] {
    font-size: 13px;
  }
}

/* === A2UI CANVAS FIX === */
#rt-canvas {
  max-width: 100%;
  height: auto !important;
}

/* === SAFE AREA (notch devices) === */
@supports (padding: env(safe-area-inset-bottom)) {
  .mobile-header {
    padding-top: calc(12px + env(safe-area-inset-top));
  }
  
  #sidebar {
    padding-top: calc(16px + env(safe-area-inset-top));
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
  
  .module {
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
}

/* Subagent badge on knight cards */
.subagent-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 12px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
  animation: fadeIn 0.3s ease;
}
.subagent-badge .pulse {
  animation: pulse 1.5s infinite;
  margin-right: 4px;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.knight-card { position: relative; }

/* === DISCOVER === */
.discover-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.discover-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 160px;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.discover-card:hover {
  border-color: var(--gold);
  transform: translateY(-2px);
}

.discover-card .discover-source {
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}

.discover-card .discover-title {
  font-size: 14px;
  color: var(--text-primary);
  text-decoration: none;
  line-height: 1.4;
}

.discover-card .discover-title:hover {
  color: var(--gold);
}

.discover-card .discover-excerpt {
  font-size: 12px;
  color: var(--text-secondary);
  flex: 1;
  margin: 0;
}

.discover-card .discover-meta {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Discover Filters */
.discover-filter {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 3px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.discover-filter:hover {
  border-color: var(--gold-dim);
  color: var(--text-primary);
}

.discover-filter.active {
  background: rgba(201,168,76,0.2);
  border-color: rgba(201,168,76,0.4);
  color: var(--gold);
}

/* === ENHANCED KNIGHT CARDS v2 === */
.knights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.knight-card-v2 {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  transition: all 0.2s;
}

.knight-card-v2:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.knight-card-v2.active {
  background: rgba(34, 197, 94, 0.05);
  border-color: var(--success);
}

.kc-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.kc-icon-v2 {
  font-size: 28px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  border-radius: 50%;
}

.kc-info {
  flex: 1;
}

.kc-name-v2 {
  font-weight: 600;
  font-size: 16px;
}

.kc-model-v2 {
  font-size: 11px;
  color: var(--muted);
  font-family: monospace;
}

.kc-status-v2 {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 12px;
  font-weight: 500;
}

.kc-role {
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 6px;
}

.kc-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 10px;
}

.kc-caps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.kc-cap {
  font-size: 10px;
  padding: 3px 8px;
  background: var(--bg-tertiary);
  border-radius: 10px;
  color: var(--text-secondary);
}

.kc-current {
  font-size: 11px;
  padding: 8px;
  background: rgba(245, 158, 11, 0.1);
  border-radius: 4px;
  color: #f59e0b;
  margin-bottom: 8px;
  border-left: 2px solid #f59e0b;
}

.kc-history {
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 10px;
}

.kc-hist-item {
  font-size: 11px;
  color: var(--muted);
  padding: 4px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kc-hist-time {
  display: inline-block;
  width: 28px;
  color: var(--text-secondary);
  font-family: monospace;
}

/* === KNIGHT THINKING PULSE === */
.knight-thinking {
  animation: knight-pulse 1.5s ease-in-out infinite;
  border-color: #f59e0b !important;
}

@keyframes knight-pulse {
  0%, 100% { 
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
  }
  50% { 
    box-shadow: 0 0 20px 5px rgba(245, 158, 11, 0.2);
  }
}

/* === QUEST CELEBRATION === */
@keyframes celebration {
  0% { transform: scale(1); }
  50% { transform: scale(1.02); box-shadow: 0 0 30px rgba(201, 168, 76, 0.5); }
  100% { transform: scale(1); }
}

.quest-complete {
  animation: celebration 0.6s ease-out;
  border-color: var(--accent) !important;
}

/* === QUEST CARDS === */
.quest-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
  transition: all 0.3s;
}

.quest-card:hover {
  border-color: var(--accent);
}

.quest-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.quest-area {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  color: white;
  font-weight: 600;
  text-transform: uppercase;
}

.quest-title {
  font-weight: 600;
  font-size: 14px;
}

.quest-progress {
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 10px;
}

.quest-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #f59e0b);
  transition: width 0.3s;
}

.quest-stages {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.quest-stage {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  font-size: 12px;
}

.quest-stage.done {
  background: rgba(34, 197, 94, 0.1);
}

.quest-stage.active {
  background: rgba(245, 158, 11, 0.15);
  animation: stage-pulse 1s ease-in-out infinite;
}

@keyframes stage-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.quest-stage-icon {
  font-size: 14px;
}

.quest-stage-status {
  font-size: 11px;
}

.quest-complete-badge {
  margin-top: 10px;
  text-align: center;
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
}

/* === FOCUS WIDGET === */
#focus-widget {
  margin: 16px;
  margin-bottom: 0;
}

.focus-card {
  background: linear-gradient(135deg, var(--panel), var(--bg-tertiary));
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px;
  transition: all 0.3s;
}

.focus-card.good-timing {
  border-color: var(--success);
  background: linear-gradient(135deg, var(--panel), rgba(34, 197, 94, 0.05));
}

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

.focus-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.5px;
}

.focus-timing-good {
  font-size: 11px;
  color: var(--success);
  background: rgba(34, 197, 94, 0.1);
  padding: 3px 10px;
  border-radius: 10px;
}

.focus-quest {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 10px;
}

.focus-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}

.focus-area {
  background: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: 4px;
}

.focus-suggestion {
  font-size: 13px;
  margin-bottom: 14px;
  color: var(--text-secondary);
}

.focus-action {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: var(--bg-primary);
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.focus-action:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.focus-empty {
  text-align: center;
  padding: 24px;
  color: var(--muted);
}

/* === CALENDAR EVENTS === */
.cal-event {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s;
}

.cal-event:last-child {
  border-bottom: none;
}

.cal-event:hover {
  background: var(--bg-tertiary);
}

.cal-event.cal-today {
  background: rgba(201, 168, 76, 0.08);
  border-left: 3px solid var(--accent);
  padding-left: 9px;
}

.cal-time {
  font-size: 12px;
  color: var(--muted);
  min-width: 90px;
}

.cal-title {
  flex: 1;
  font-size: 13px;
  margin-left: 12px;
}

/* === OPS TELEMETRY HUB === */
.ops-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.ops-status {
  font-weight: 600;
  font-size: 14px;
}

.ops-status.ops-healthy { color: var(--success); }
.ops-status.ops-warning { color: #f59e0b; }
.ops-status.ops-error { color: var(--error); }

.ops-counts {
  display: flex;
  gap: 12px;
}

.ops-count {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
}

.ops-count.healthy { background: rgba(34, 197, 94, 0.1); color: var(--success); }
.ops-count.warning { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }
.ops-count.error { background: rgba(239, 68, 68, 0.1); color: var(--error); }

.ops-problems {
  margin-top: 10px;
}

.ops-job {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  margin-bottom: 6px;
  border-radius: 4px;
  font-size: 12px;
}

.ops-job.ops-warning { background: rgba(245, 158, 11, 0.08); }
.ops-job.ops-error { background: rgba(239, 68, 68, 0.08); }

.ops-job-name { flex: 1; }
.ops-job-detail { color: var(--muted); font-size: 11px; }

/* === KNIGHT CARDS MINI === */
.knight-cards-grid {
  display: flex;
  gap: 10px;
  padding: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.knight-card-mini {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 80px;
}

.knight-card-mini:hover {
  border-color: var(--knight-color, var(--accent));
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.knight-card-mini.selected {
  border-color: var(--knight-color, var(--accent));
  background: rgba(201, 168, 76, 0.1);
}

.knight-card-mini.thinking {
  animation: knight-mini-pulse 1.5s ease-in-out infinite;
}

@keyframes knight-mini-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
  50% { box-shadow: 0 0 15px 3px rgba(245, 158, 11, 0.3); }
}

.kcm-icon {
  font-size: 24px;
  margin-bottom: 4px;
}

.kcm-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.kcm-status {
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
}

/* === CELEBRATION CONFETTI === */
.celebration-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.confetti {
  position: absolute;
  top: -10px;
  left: var(--x);
  width: 10px;
  height: 10px;
  background: var(--color);
  animation: confetti-fall 2s ease-out forwards;
  animation-delay: var(--delay);
  opacity: 0;
}

@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* === ROUND TABLE REFINEMENTS === */
#mod-tavola .module-header h2 {
  font-size: 18px;
  letter-spacing: 1px;
}

#mod-tavola .card {
  border-color: rgba(201, 168, 76, 0.2);
}

#mod-tavola .card-header {
  border-bottom-color: rgba(201, 168, 76, 0.15);
}

/* === RT ACTIVITY FEED === */
.rt-activity-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

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

.rt-act-icon {
  font-size: 14px;
}

.rt-act-text {
  flex: 1;
  color: var(--text);
}

.rt-act-time {
  color: var(--muted);
  font-size: 11px;
}

/* === KNIGHT HISTORY MODAL === */
.knight-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
}

.knight-modal {
  background: var(--panel);
  border: 2px solid var(--knight-color, var(--accent));
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  max-height: 80vh;
  overflow: hidden;
  animation: modal-appear 0.2s ease-out;
}

@keyframes modal-appear {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.km-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: rgba(0,0,0,0.2);
  border-bottom: 1px solid var(--border);
}

.km-icon {
  font-size: 32px;
}

.km-name {
  font-size: 20px;
  font-weight: 600;
  flex: 1;
}

.km-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
}

.km-close:hover {
  color: var(--text);
}

.km-stats {
  display: flex;
  justify-content: space-around;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.km-stat {
  text-align: center;
}

.km-stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--knight-color, var(--accent));
}

.km-stat-label {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.km-history-title {
  padding: 12px 16px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.km-history {
  max-height: 200px;
  overflow-y: auto;
  padding: 0 16px;
}

.km-history-item {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

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

.km-hist-time {
  color: var(--muted);
  min-width: 100px;
  font-size: 11px;
}

.km-hist-title {
  flex: 1;
  color: var(--text);
}

.km-dispatch {
  width: calc(100% - 32px);
  margin: 16px;
  padding: 12px;
  background: var(--knight-color, var(--accent));
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.km-dispatch:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* === GAMIFICATION BADGES === */
.knight-card-v2 {
  position: relative;
}

.knight-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--accent);
  color: var(--bg-primary);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.knight-streak {
  position: absolute;
  bottom: 8px;
  right: 8px;
  font-size: 14px;
}

/* === AI CATEGORY HIGHLIGHT === */
.discover-card[data-category="ai"] {
  border-left: 3px solid #8b5cf6;
}

.discover-card[data-category="ai"] .discover-source {
  color: #8b5cf6;
}

.discover-filter[data-cat="ai"] {
  background: rgba(139, 92, 246, 0.1);
}

.discover-filter[data-cat="ai"]:hover,
.discover-filter[data-cat="ai"].active {
  background: rgba(139, 92, 246, 0.2);
  border-color: #8b5cf6;
}
