/* =====================================================================
   ERIKA COMMAND COCKPIT  v2  —  matches reference design
   Dark navy · colored-border cards · avatar team rows · drill-down panels
   ===================================================================== */

:root {
  /* Section accent palette */
  --ck-blue:    #2563eb;
  --ck-cyan:    #06b6d4;
  --ck-purple:  #7c3aed;
  --ck-green:   #16a34a;
  --ck-amber:   #d97706;
  --ck-teal:    #0891b2;
  --ck-red:     #dc2626;
  --ck-emerald: #059669;
  /* Layout */
  --ck-radius: 12px;
  --ck-nav-h:  62px;
  /* Shorthand aliases (dashboard vars may differ) */
  --ck-border-base: #1e2d3d;
}

/* ── No sidebar — centered cockpit column ──────────────────────────── */
.sidebar { display: none !important; }
.app-body { flex-direction: column; }
.main-content {
  max-width: 1040px; width: 100%; margin: 0 auto;
  padding-bottom: calc(var(--ck-nav-h) + env(safe-area-inset-bottom) + 12px);
}
.mobile-nav { display: flex !important; }

/* ── Header ─────────────────────────────────────────────────────────── */
.header {
  position: sticky; top: 0; z-index: 95;
  padding-top: calc(8px + env(safe-area-inset-top));
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.user-chip { cursor: pointer; }

/* ── Card border / glow themes ─────────────────────────────────────── */
/* cockpit.js adds .ck-theme-X to .panel and .zone elements */
.ck-theme-blue   { border-top: 2px solid var(--ck-blue) !important; }
.ck-theme-cyan   { border-top: 2px solid var(--ck-cyan) !important; box-shadow: 0 0 28px rgba(6,182,212,.09) !important; }
.ck-theme-purple { border-top: 2px solid var(--ck-purple) !important; }
.ck-theme-green  { border-top: 2px solid var(--ck-green) !important; }
.ck-theme-amber  { border-top: 2px solid var(--ck-amber) !important; }
.ck-theme-teal   { border-top: 2px solid var(--ck-teal) !important; }

/* Accent dot in panel/zone headers */
.ck-theme-blue   .panel-header::before,
.ck-theme-blue   .zone-label::before  { content:""; display:inline-block; width:7px;height:7px;border-radius:50%;background:var(--ck-blue);margin-right:7px;vertical-align:middle;flex-shrink:0; }
.ck-theme-cyan   .panel-header::before,
.ck-theme-cyan   .zone-label::before  { content:""; display:inline-block; width:7px;height:7px;border-radius:50%;background:var(--ck-cyan);margin-right:7px;vertical-align:middle;flex-shrink:0; }
.ck-theme-purple .panel-header::before,
.ck-theme-purple .zone-label::before  { content:""; display:inline-block; width:7px;height:7px;border-radius:50%;background:var(--ck-purple);margin-right:7px;vertical-align:middle;flex-shrink:0; }
.ck-theme-green  .panel-header::before,
.ck-theme-green  .zone-label::before  { content:""; display:inline-block; width:7px;height:7px;border-radius:50%;background:var(--ck-green);margin-right:7px;vertical-align:middle;flex-shrink:0; }
.ck-theme-amber  .panel-header::before,
.ck-theme-amber  .zone-label::before  { content:""; display:inline-block; width:7px;height:7px;border-radius:50%;background:var(--ck-amber);margin-right:7px;vertical-align:middle;flex-shrink:0; }
.ck-theme-teal   .panel-header::before,
.ck-theme-teal   .zone-label::before  { content:""; display:inline-block; width:7px;height:7px;border-radius:50%;background:var(--ck-teal);margin-right:7px;vertical-align:middle;flex-shrink:0; }

/* ── Details chip ───────────────────────────────────────────────────── */
.ck-detail {
  margin-left: auto; display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 700; letter-spacing: .4px;
  color: var(--ck-cyan); background: rgba(6,182,212,.12);
  border: 1px solid rgba(6,182,212,.28); padding: 4px 9px; border-radius: 999px;
  cursor: pointer; white-space: nowrap; transition: transform .12s, background .12s;
}
.ck-detail:hover  { background: rgba(6,182,212,.22); }
.ck-detail:active { transform: scale(.93); }
.zone-label .ck-detail { margin-left: 8px; }

/* ── PWA install nudge bar ──────────────────────────────────────────── */
.ck-pwa-bar {
  position: fixed;
  bottom: calc(var(--ck-nav-h) + env(safe-area-inset-bottom) + 10px);
  left: 50%; transform: translateX(-50%) translateY(16px);
  max-width: 480px; width: calc(100% - 32px);
  background: #0f1a2e;
  border: 1px solid rgba(6,182,212,.35);
  border-top: 2px solid var(--ck-cyan);
  border-radius: var(--ck-radius); padding: 11px 14px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.6);
  z-index: 9000; opacity: 0;
  transition: opacity .3s ease, transform .3s ease;
  pointer-events: none;
}
.ck-pwa-bar.show {
  opacity: 1; transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
.ck-pwa-text {
  flex: 1; font-size: 12.5px; color: var(--text-muted); line-height: 1.55;
}
.ck-pwa-text b { color: #e2e8f0; }
.ck-pwa-install { font-size: 11px; padding: 6px 13px; white-space: nowrap; flex-shrink: 0; }
.ck-pwa-dismiss {
  background: none; border: none; color: var(--text-muted);
  font-size: 15px; cursor: pointer; padding: 2px 4px; flex-shrink: 0;
  line-height: 1; transition: color .15s;
}
.ck-pwa-dismiss:hover { color: #e2e8f0; }

/* ── Erika console ──────────────────────────────────────────────────── */
.erika-chat {
  margin-top: 12px;
  border: 1px solid rgba(6,182,212,.25);
  border-top: 2px solid var(--ck-cyan);
  border-radius: var(--ck-radius);
  background: radial-gradient(110% 70% at 50% -10%, rgba(6,182,212,.08), transparent 60%), var(--card, #12121c);
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0,0,0,.25), 0 8px 32px rgba(0,0,0,.35), 0 0 40px rgba(6,182,212,.06);
}
.erika-chat-head {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  font-size: 11px; font-weight: 800; letter-spacing: .7px; color: var(--text, #e8e8f0);
}
.erika-chat-head::before { content:""; display:inline-block; width:7px;height:7px;border-radius:50%;background:var(--ck-cyan);margin-right:4px; }
.ec-live {
  display: inline-flex; align-items: center; gap: 5px;
  margin-left: auto; font-size: 10px; color: var(--text-muted, #9a9aae); font-weight: 600;
}
.ec-live::before {
  content:""; width:6px; height:6px; border-radius:50%;
  background: #4ade80; box-shadow: 0 0 8px #4ade80;
  animation: ckpulse 2s infinite;
}
@keyframes ckpulse { 0%,100%{opacity:1}50%{opacity:.3} }
.erika-chat-log {
  min-height: 170px; max-height: 44vh; overflow-y: auto;
  padding: 12px; display: flex; flex-direction: column; gap: 10px;
  -webkit-overflow-scrolling: touch;
}
.ec-hint { color: var(--text-muted, #9a9aae); font-size: 12px; line-height: 1.65;
  background: rgba(255,255,255,.025); border: 1px dashed rgba(255,255,255,.1); border-radius: 10px; padding: 12px; }
.ec-msg { display: flex; flex-direction: column; max-width: 88%; }
.ec-msg-user      { align-self: flex-end;  align-items: flex-end; }
.ec-msg-assistant { align-self: flex-start; align-items: flex-start; }
.ec-bubble {
  padding: 9px 12px; border-radius: 14px; font-size: 13.5px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
}
.ec-msg-user .ec-bubble { background: var(--ck-cyan); color: #04111a; font-weight: 500; border-bottom-right-radius: 4px; }
.ec-msg-assistant .ec-bubble { background: rgba(255,255,255,.06); color: var(--text, #e8e8f0); border: 1px solid rgba(255,255,255,.1); border-bottom-left-radius: 4px; }
.ec-bubble.ec-code { font-family: ui-monospace,"SF Mono",Menlo,monospace; font-size: 11.5px; background: #070a12; border-color: #1e2d3d; color: #cfe8ff; max-height: 300px; overflow: auto; }
.ec-meta { font-size: 9.5px; color: var(--text-dim, #6a6a80); margin-top: 3px; padding: 0 4px; }
.ec-typing { display: inline-flex; gap: 4px; align-items: center; }
.ec-typing span { width:6px;height:6px;border-radius:50%;background:var(--text-muted,#9a9aae); animation:ecblink 1.2s infinite both; }
.ec-typing span:nth-child(2){ animation-delay:.2s } .ec-typing span:nth-child(3){ animation-delay:.4s }
@keyframes ecblink { 0%,80%,100%{opacity:.25;transform:translateY(0)}40%{opacity:1;transform:translateY(-3px)} }
.erika-chat-controls { display:flex; align-items:center; gap:6px; padding:8px 10px 0; flex-wrap:wrap; }
.ec-mode-btn { font-size:11px;font-weight:700;letter-spacing:.3px;padding:6px 12px;border-radius:999px;cursor:pointer;background:transparent;color:var(--text-muted,#9a9aae);border:1px solid rgba(255,255,255,.1); }
.ec-mode-btn.active { background:var(--ck-cyan);color:#04111a;border-color:var(--ck-cyan); }
.ec-attach { margin-left:0;display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:10px;cursor:pointer;font-size:16px;background:rgba(255,255,255,.05);border:1px solid rgba(255,255,255,.1); }
.ec-attach:active { transform:scale(.92); }
.erika-chat-input-row { display:flex;align-items:flex-end;gap:8px;padding:8px 10px 10px; }
.ec-input { flex:1;resize:none;min-height:40px;max-height:130px;background:#070a12;color:var(--text,#e8e8f0);border:1px solid rgba(255,255,255,.1);border-radius:12px;padding:10px 12px;font-size:14px;font-family:inherit;line-height:1.4; }
.ec-input:focus { outline:none;border-color:var(--ck-cyan); }
.ec-send { flex-shrink:0;width:44px;height:44px;border-radius:12px;cursor:pointer;background:var(--ck-cyan);color:#04111a;border:none;font-size:18px;font-weight:700;display:flex;align-items:center;justify-content:center; }
.ec-send:active { transform:scale(.92); }
.ec-send:disabled { opacity:.5;cursor:default; }

/* ── Team Leaders — avatar rows ─────────────────────────────────────── */
#leaders-list { display: none !important; }
#leaders-cockpit { display: flex; flex-direction: column; }
.ck-leader-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px; cursor: pointer;
  transition: background .12s ease; -webkit-tap-highlight-color: transparent;
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.ck-leader-row:last-child { border-bottom: none; }
.ck-leader-row:hover  { background: rgba(255,255,255,.04); }
.ck-leader-row:active { background: rgba(255,255,255,.08); }
.ck-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: #fff; letter-spacing: .5px;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.ck-avatar-lg {
  width: 60px; height: 60px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800; color: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
.ck-leader-info { flex: 1; min-width: 0; }
.ck-leader-name { font-size: 13px; font-weight: 600; color: var(--text, #e2e8f0); line-height: 1.3; }
.ck-leader-role { font-size: 10.5px; color: var(--text-muted, #9a9aae); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ck-status-good { color: #4ade80; font-size: 10.5px; font-weight: 700; white-space: nowrap; }
.ck-status-risk { color: #f59e0b; font-size: 10.5px; font-weight: 700; white-space: nowrap; }
.ck-status-bad  { color: #f87171; font-size: 10.5px; font-weight: 700; white-space: nowrap; }
.ck-leader-mets { display: flex; gap: 10px; font-size: 10px; color: var(--text-dim, #6a6a80); }
.ck-leader-mets b { color: var(--text, #e2e8f0); font-size: 11.5px; font-weight: 700; }
.ck-arr { color: var(--text-dim, #6a6a80); font-size: 18px; margin-left: auto; flex-shrink: 0; }

/* ── Task rows (inside drill-down panels) ───────────────────────────── */
.ck-task-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 10px; cursor: pointer; border: 1px solid rgba(255,255,255,.07);
  margin-bottom: 7px; transition: background .12s; -webkit-tap-highlight-color: transparent;
}
.ck-task-row:hover  { background: rgba(255,255,255,.04); }
.ck-task-row:active { background: rgba(255,255,255,.08); }
.ck-task-info { flex: 1; min-width: 0; }
.ck-task-title { font-size: 13px; font-weight: 600; color: var(--text, #e2e8f0);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ck-task-meta { font-size: 11px; color: var(--text-muted, #9a9aae); margin-top: 2px; }

/* ── Full-screen drill-down navigation panels ───────────────────────── */
.ck-fullpanel {
  position: fixed; inset: 0; z-index: 500; display: flex; flex-direction: column;
  background: var(--surface, #0f0f1a);
  transform: translateX(100%); transition: transform .26s cubic-bezier(.4,0,.2,1);
  padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
  overflow: hidden;
}
.ck-fullpanel.open { transform: none; }
.ck-fullpanel-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,.08); flex-shrink: 0;
}
.ck-back {
  width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1);
  color: var(--text, #e2e8f0); font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.ck-back:active { transform: scale(.9); }
.ck-fp-hinfo { flex: 1; min-width: 0; }
.ck-fp-sub { font-size: 9.5px; font-weight: 800; letter-spacing: 1.2px; color: var(--text-dim, #6a6a80); }
.ck-fp-title { font-size: 17px; font-weight: 700; color: var(--text, #e2e8f0);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ck-fullpanel-body { flex: 1; overflow-y: auto; padding: 16px; -webkit-overflow-scrolling: touch; }

/* Avatar row in panel header */
.ck-fp-avatar-row { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.ck-fp-name { font-size: 20px; font-weight: 700; color: var(--text, #e2e8f0); }
.ck-fp-role { font-size: 13px; color: var(--text-muted, #9a9aae); margin-top: 3px; }

/* Metrics grid (2×N inside panel) */
.ck-kv-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 20px; }
.ck-kv-cell { background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px; padding: 10px 12px; }
.ck-kv-label { font-size: 9.5px; font-weight: 800; letter-spacing: .8px; color: var(--text-dim, #6a6a80); }
.ck-kv-val { font-size: 22px; font-weight: 700; color: var(--text, #e2e8f0); margin-top: 4px; }
.ck-fp-actions { margin-top: 22px; display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Detail slide-over (card detail) ────────────────────────────────── */
.detail-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 300;
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
}
.detail-backdrop.open { opacity: 1; pointer-events: auto; }
.detail-panel {
  position: fixed; top: 0; right: 0; height: 100%; width: min(540px, 96vw);
  background: var(--surface, #0f0f1a); border-left: 1px solid rgba(255,255,255,.08);
  z-index: 301; display: flex; flex-direction: column;
  transform: translateX(102%); transition: transform .24s cubic-bezier(.4,0,.2,1);
  padding-top: env(safe-area-inset-top);
}
.detail-panel.open { transform: none; }
.dp-header { display:flex;align-items:center;gap:10px;padding:14px 16px;border-bottom:1px solid rgba(255,255,255,.07);flex-shrink:0; }
.dp-header-info { min-width:0; }
.dp-type { font-size:9px;font-weight:800;letter-spacing:1.4px;color:var(--ck-cyan); }
.dp-title { font-size:16px;font-weight:700;color:var(--text,#e8e8f0);overflow:hidden;text-overflow:ellipsis;white-space:nowrap; }
.dp-close { margin-left:auto;flex-shrink:0;width:40px;height:40px;border-radius:10px;background:rgba(255,255,255,.05);border:1px solid rgba(255,255,255,.1);color:var(--text-muted,#9a9aae);font-size:18px;cursor:pointer;display:flex;align-items:center;justify-content:center; }
.dp-body { flex:1;overflow-y:auto;padding:14px 16px;-webkit-overflow-scrolling:touch; }
.dp-footer { flex-shrink:0;padding:12px 16px calc(12px + env(safe-area-inset-bottom));border-top:1px solid rgba(255,255,255,.07);display:flex;gap:8px;flex-wrap:wrap; }
.dp-footer:empty { display:none; }
.ck-why { background:rgba(6,182,212,.08);border:1px solid rgba(6,182,212,.22);border-radius:10px;padding:10px 12px;margin-bottom:14px;font-size:12.5px;line-height:1.6;color:var(--text,#e8e8f0); }
.ck-sec { font-size:9px;font-weight:800;letter-spacing:1.2px;color:var(--text-dim,#6a6a80);margin:16px 0 8px;padding-bottom:5px;border-bottom:1px solid rgba(255,255,255,.07); }
.ck-row { border:1px solid rgba(255,255,255,.08);border-radius:10px;padding:10px 12px;margin-bottom:8px;background:rgba(255,255,255,.02); }
.ck-row-top { display:flex;align-items:baseline;gap:8px; }
.ck-row-title { font-size:13px;font-weight:600;color:var(--text,#e8e8f0);flex:1; }
.ck-badge { font-size:9.5px;font-weight:700;padding:2px 8px;border-radius:999px;background:rgba(255,255,255,.08);color:var(--text-muted,#9a9aae);white-space:nowrap; }
.ck-badge.warn { background:rgba(245,158,11,.2);color:#f59e0b; }
.ck-badge.bad  { background:rgba(220,38,38,.2);color:#f87171; }
.ck-badge.good { background:rgba(74,222,128,.18);color:#4ade80; }
.ck-kv { display:grid;grid-template-columns:96px 1fr;gap:3px 10px;margin-top:7px;font-size:11.5px; }
.ck-kv dt { color:var(--text-dim,#6a6a80); } .ck-kv dd { color:var(--text,#e8e8f0);margin:0;word-break:break-word; }
.ck-next { margin-top:8px;font-size:11.5px;color:var(--ck-cyan);line-height:1.5; }
.ck-muted { color:var(--text-muted,#9a9aae);font-size:12px;padding:10px 0; }
.ck-err   { color:#f87171;font-size:12.5px;padding:10px 0; }
.dp-btn { flex:1;min-width:130px;text-align:center;padding:11px 14px;border-radius:10px;font-size:12.5px;font-weight:700;cursor:pointer;border:1px solid rgba(255,255,255,.1);background:rgba(255,255,255,.05);color:var(--text,#e8e8f0); }
.dp-btn.primary { background:var(--ck-cyan);color:#04111a;border-color:var(--ck-cyan); }
.dp-btn:active { transform:scale(.97); }
.detail-panel.open ~ .mobile-nav { display:none !important; }

/* ── Life Wiki recent ──────────────────────────────────────────────── */
#lifewiki-recent-list { display:flex;flex-direction:column;gap:7px;margin:4px 0 8px; }
.lw-item { display:flex;gap:8px;align-items:flex-start; }
.lw-dot  { width:6px;height:6px;border-radius:50%;background:var(--ck-green);margin-top:6px;flex-shrink:0; }
.lw-item-body { min-width:0; }
.lw-item-title { font-size:12px;color:var(--text,#e2e8f0);line-height:1.4;overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical; }
.lw-item-meta  { font-size:10px;color:var(--text-dim,#6a6a80);margin-top:1px;text-transform:capitalize; }

/* ── Global drag-and-drop overlay ──────────────────────────────────── */
.drop-overlay { position:fixed;inset:0;z-index:600;display:none;align-items:center;justify-content:center;background:rgba(5,20,26,.82);backdrop-filter:blur(4px); }
.drop-overlay.show { display:flex; }
.drop-inner { border:3px dashed var(--ck-cyan);border-radius:20px;padding:48px 64px;font-size:18px;font-weight:700;color:var(--ck-cyan);text-align:center;pointer-events:none; }

/* ── Phone ─────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .erika-chat-log { max-height: 38vh; }
  .detail-panel { width: 100vw; }
  .ck-fullpanel-head { padding: 12px; }
  .header-title-sub { display: none; }
}
