/* ============================================================================
   Command Center - the unified executive home for CAMPUSLIVE Agent Studio.
   Strict LIGHT theme - blue (#2563eb / var(--acc)) - NO gradients - NO glows.
   Reuses styles.css tokens (--acc, --t-*, --line, --surface, --green/amber/red,
   --fs-*, --shadow-*). Frosted chrome only on the header (inherited from .topbar).
   Standalone executive page - mirrors intelligence.css / swarm.css conventions.
   ============================================================================ */

body { background: var(--bg); }

.cc-topbar { z-index: 40; }

/* Spinner + ghost helpers (mirrors intelligence.css so the page is self-contained) */
.dl-spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--acc-tint); border-top-color: var(--acc);
  display: inline-block; animation: cc-spin 0.7s linear infinite;
}
@keyframes cc-spin { to { transform: rotate(360deg); } }
.btn.is-busy { opacity: 0.65; pointer-events: none; }

/* ── Header quick links + refresh ──────────────────────────────────────────── */
.cc-quicklinks { display: inline-flex; align-items: center; gap: 6px; }
.cc-ql {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 11px; border-radius: 9px;
  background: var(--surface); color: var(--t-2);
  border: 1px solid var(--line); text-decoration: none;
  font-size: var(--fs-12); font-weight: 600; white-space: nowrap;
  transition: color .12s, background .12s, border-color .12s;
}
.cc-ql:hover { color: var(--acc-ink); background: var(--acc-soft); border-color: var(--acc-tint); }
.cc-ql svg { color: var(--acc); }
.cc-refresh-btn { gap: 6px; height: 32px; margin-left: 4px; }

/* ── Shell ─────────────────────────────────────────────────────────────────── */
.cc-shell {
  max-width: 1240px; margin: 0 auto;
  padding: 20px 18px 44px;
  min-height: calc(100vh - 52px - 30px); box-sizing: border-box;
}
.cc-loading {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 80px 16px; color: var(--t-4); font-size: var(--fs-13); font-weight: 500;
}
.cc-content { display: flex; flex-direction: column; gap: 18px; }

/* ── (1) HERO KPI STRIP ─────────────────────────────────────────────────────── */
.cc-hero {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px;
}
.cc-kpi {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 15px 15px; box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden; min-width: 0;
}
.cc-kpi::before {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; border-radius: 3px 0 0 3px;
  background: var(--line-strong);
}
.cc-kpi-success::before { background: var(--green); }
.cc-kpi-blue::before    { background: var(--acc); }
.cc-kpi-danger::before  { background: var(--red); }
.cc-kpi-count::before   { background: var(--t-3); }

.cck-icon {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center; background: var(--surface-3); color: var(--t-3);
}
.cc-kpi-success .cck-icon { background: var(--green-soft); color: var(--green); }
.cc-kpi-blue    .cck-icon { background: var(--acc-soft);   color: var(--acc); }
.cc-kpi-danger  .cck-icon { background: var(--red-soft);   color: var(--red); }
.cc-kpi-count   .cck-icon { background: var(--acc-soft);   color: var(--acc); }

.cck-body { min-width: 0; }
.cck-label { font-size: var(--fs-11); font-weight: 700; color: var(--t-3); text-transform: uppercase; letter-spacing: 0.03em; }
.cck-value { font-size: 22px; font-weight: 800; color: var(--t-1); line-height: 1.12; margin-top: 4px; letter-spacing: -0.02em; white-space: nowrap; }
.cck-cur { font-size: var(--fs-12); font-weight: 700; color: var(--t-3); margin-right: 2px; }
.cck-of { font-size: var(--fs-13); font-weight: 700; color: var(--t-4); margin-left: 2px; }
.cc-kpi-success .cck-value { color: #047857; }
.cc-kpi-danger  .cck-value { color: #b45309; }
.cck-sub { font-size: var(--fs-11); color: var(--t-4); margin-top: 4px; line-height: 1.3; }

/* ── (2) CARD GRID ──────────────────────────────────────────────────────────── */
.cc-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px;
}
.cc-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow-sm);
  padding: 16px 18px 16px; display: flex; flex-direction: column; min-width: 0;
}
.cc-card-wide { grid-column: 1 / -1; }

.cc-card-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.cch-titlewrap { min-width: 0; }
.cc-card-title {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: var(--fs-15); font-weight: 800; color: var(--t-1); margin: 0; letter-spacing: -0.01em;
}
.cc-card-title svg { color: var(--acc); }
.cc-card-sub { font-size: var(--fs-12); color: var(--t-3); margin: 3px 0 0; }

.cc-card-link {
  margin-left: auto; display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--fs-12); font-weight: 700; color: var(--acc-ink);
  text-decoration: none; padding: 5px 9px; border-radius: 8px;
  background: var(--acc-soft); border: 1px solid var(--acc-tint); white-space: nowrap;
  transition: background .12s;
}
.cc-card-link:hover { background: var(--acc-tint); }
.cc-card-link svg { flex-shrink: 0; }

.cc-count-badge {
  margin-left: auto; flex-shrink: 0;
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px;
  display: inline-grid; place-items: center;
  font-size: var(--fs-12); font-weight: 800; color: var(--acc-ink);
  background: var(--acc-soft); border: 1px solid var(--acc-tint);
}

/* Honest empty states */
.cc-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 26px 16px; text-align: center;
  color: var(--t-4); font-size: var(--fs-13); font-weight: 500;
}

/* ── Value and risk (findings) ──────────────────────────────────────────────── */
.cc-findings { display: flex; flex-direction: column; }
.ccf-row {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 11px 0; border-bottom: 1px solid var(--line);
}
.ccf-row:last-child { border-bottom: 0; }
.ccf-dot { flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; background: var(--t-4); }
.ccf-dot-high { background: var(--red); }
.ccf-dot-medium { background: var(--amber); }
.ccf-dot-low { background: var(--acc); }
.ccf-main { min-width: 0; flex: 1; }
.ccf-title { font-size: var(--fs-13); font-weight: 600; color: var(--t-1); line-height: 1.35; }
.ccf-meta { display: flex; align-items: center; gap: 8px; margin-top: 5px; flex-wrap: wrap; }
.ccf-dept {
  font-size: var(--fs-11); font-weight: 700; color: var(--t-3);
  background: var(--surface-3); border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px;
}
.ccf-impact {
  font-size: var(--fs-11); font-weight: 800; border-radius: 6px; padding: 2px 7px; white-space: nowrap;
}
.ccf-impact-aed   { color: #b45309; background: var(--amber-soft); border: 1px solid color-mix(in srgb, var(--amber) 28%, transparent); }
.ccf-impact-days  { color: var(--acc-ink); background: var(--acc-soft); border: 1px solid var(--acc-tint); }
.ccf-impact-count { color: var(--t-2); background: var(--surface-3); border: 1px solid var(--line); }
.ccf-impact-dir   { color: var(--t-3); background: var(--surface-3); border: 1px dashed var(--line-strong); text-transform: uppercase; letter-spacing: 0.03em; }

/* ── Proactive alerts ───────────────────────────────────────────────────────── */
.cc-alerts { display: flex; flex-direction: column; }
.cca-row { display: flex; align-items: flex-start; gap: 11px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cca-row:last-child { border-bottom: 0; }
.cca-dot { flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; }
.cca-dot-red { background: var(--red); }
.cca-dot-amber { background: var(--amber); }
.cca-dot-blue { background: var(--acc); }
.cca-main { min-width: 0; }
.cca-title { font-size: var(--fs-13); font-weight: 600; color: var(--t-1); line-height: 1.35; }
.cca-sub { font-size: var(--fs-12); color: var(--t-3); margin-top: 3px; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ── Agent fleet health ─────────────────────────────────────────────────────── */
.cc-fleet { display: flex; flex-direction: column; gap: 12px; }
.cc-fleet-rollup { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.ccfr-stat {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 10px 6px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface-2);
}
.ccfr-num { font-size: 22px; font-weight: 800; color: var(--t-1); letter-spacing: -0.02em; }
.ccfr-lbl { font-size: var(--fs-11); font-weight: 600; color: var(--t-3); }
.ccfr-good .ccfr-num  { color: #047857; }
.ccfr-good  { background: var(--green-soft); border-color: color-mix(in srgb, var(--green) 22%, transparent); }
.ccfr-warn .ccfr-num  { color: #b45309; }
.ccfr-warn  { background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 26%, transparent); }
.ccfr-total .ccfr-num { color: var(--acc-ink); }
.ccfr-total { background: var(--acc-soft); border-color: var(--acc-tint); }

.cc-fleet-bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; border: 1px solid var(--line); }
.ccfb-good { display: block; height: 100%; background: var(--green); border-radius: 999px; width: 0; transition: width .4s ease; }

.cc-fleet-list { display: flex; flex-direction: column; gap: 6px; }
.ccfl-row { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); }
.ccfl-kind {
  font-size: var(--fs-11); font-weight: 800; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 2px 7px; border-radius: 6px; flex-shrink: 0;
}
.ccfl-kind-best  { color: #047857; background: var(--green-soft); border: 1px solid color-mix(in srgb, var(--green) 24%, transparent); }
.ccfl-kind-worst { color: #b45309; background: var(--amber-soft); border: 1px solid color-mix(in srgb, var(--amber) 26%, transparent); }
.ccfl-name { font-size: var(--fs-13); font-weight: 600; color: var(--t-1); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ccfl-pct { margin-left: auto; font-size: var(--fs-12); font-weight: 800; flex-shrink: 0; }
.ccfl-pct-good { color: #047857; }
.ccfl-pct-mid  { color: var(--t-2); }
.ccfl-pct-warn { color: #b45309; }
.ccfl-none { font-size: var(--fs-12); color: var(--t-4); padding: 4px 2px; line-height: 1.4; }

/* ── Approvals ──────────────────────────────────────────────────────────────── */
.cc-approvals { display: flex; flex-direction: column; }
.ccap-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ccap-row:last-child { border-bottom: 0; }
.ccap-ico { flex-shrink: 0; margin-top: 1px; color: var(--acc); }
.ccap-main { min-width: 0; }
.ccap-title { font-size: var(--fs-13); font-weight: 600; color: var(--t-1); line-height: 1.35; }
.ccap-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 3px; font-size: var(--fs-11); color: var(--t-3); }
.ccap-when { color: var(--t-4); }
.ccap-impact { font-weight: 700; color: var(--t-2); font-variant-numeric: tabular-nums; }
.ccap-route { color: var(--acc); font-weight: 600; }
.ccap-fin { color: var(--amber); font-weight: 700; background: var(--amber-soft, #fef3c7); border: 1px solid #fde68a; border-radius: 5px; padding: 1px 6px; }
.ccap-more { display: inline-block; margin-top: 10px; font-size: var(--fs-12); font-weight: 700; color: var(--acc); text-decoration: none; }
.ccap-more:hover { text-decoration: underline; }

/* ── Recent activity ────────────────────────────────────────────────────────── */
.cc-activity { display: flex; flex-direction: column; }
.ccact-row { display: flex; align-items: flex-start; gap: 11px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.ccact-row:last-child { border-bottom: 0; }
.ccact-dot { flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; }
.ccact-dot-green { background: var(--green); }
.ccact-dot-red { background: var(--red); }
.ccact-dot-blue { background: var(--acc); }
.ccact-main { min-width: 0; flex: 1; }
.ccact-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ccact-kind { font-size: var(--fs-13); font-weight: 600; color: var(--t-1); }
.ccact-cap { font-size: var(--fs-12); font-weight: 600; color: var(--acc-ink); background: var(--acc-soft); border: 1px solid var(--acc-tint); border-radius: 6px; padding: 1px 7px; }
.ccact-meta { display: flex; align-items: center; gap: 8px; margin-top: 3px; font-size: var(--fs-11); color: var(--t-4); }
.ccact-agent { font-weight: 700; color: var(--t-3); font-family: 'JetBrains Mono', monospace; }

/* ── LLM usage and quota (B2) ──────────────────────────────────────────────── */
.cc-quota-table { display: flex; flex-direction: column; gap: 8px; }
.ccq-row {
  display: grid; grid-template-columns: 1fr auto auto auto auto auto; align-items: center;
  gap: 14px; padding: 10px 12px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line);
}
.ccq-row.ccq-killed { background: var(--red-soft, #fee2e2); border-color: color-mix(in srgb, var(--red) 26%, transparent); }
.ccq-name { min-width: 0; }
.ccq-tenant { font-size: var(--fs-13); font-weight: 700; color: var(--t-1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ccq-sub { font-size: var(--fs-11); color: var(--t-4); margin-top: 2px; }
.ccq-stat { text-align: right; min-width: 74px; }
.ccq-stat-num { font-size: var(--fs-14); font-weight: 800; color: var(--t-1); font-variant-numeric: tabular-nums; display: block; }
.ccq-stat-lbl { font-size: var(--fs-10); color: var(--t-4); text-transform: uppercase; letter-spacing: 0.03em; }
.ccq-badge {
  font-size: var(--fs-11); font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}
.ccq-badge-unlimited { color: var(--t-3); background: var(--surface-3); border: 1px solid var(--line); }
.ccq-badge-capped { color: var(--acc-ink); background: var(--acc-soft); border: 1px solid var(--acc-tint); }
.ccq-badge-off { color: #b91c1c; background: var(--red-soft, #fee2e2); border: 1px solid color-mix(in srgb, var(--red) 30%, transparent); }
.ccq-kill { display: flex; align-items: center; gap: 8px; justify-self: end; }
.ccq-kill-lbl { font-size: var(--fs-11); font-weight: 700; color: var(--t-3); }
.ccq-edit-btn {
  font-size: var(--fs-11); font-weight: 700; color: var(--acc); background: none; border: 1px solid var(--acc-tint);
  border-radius: 7px; padding: 4px 9px; cursor: pointer; transition: background .12s;
}
.ccq-edit-btn:hover { background: var(--acc-soft); }
.ccq-edit-panel {
  grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  padding: 10px; margin-top: 4px; border-top: 1px dashed var(--line);
}
.ccq-edit-field { display: flex; flex-direction: column; gap: 3px; }
.ccq-edit-field label { font-size: var(--fs-10); color: var(--t-4); text-transform: uppercase; letter-spacing: 0.03em; }
.ccq-edit-field input {
  width: 130px; font-size: var(--fs-13); padding: 5px 8px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--surface-1); color: var(--t-1);
}
.ccq-edit-save {
  font-size: var(--fs-12); font-weight: 700; color: #fff; background: var(--acc); border: none;
  border-radius: 7px; padding: 6px 14px; cursor: pointer;
}
.ccq-edit-save:hover { background: var(--acc-hover, var(--acc)); }
@media (max-width: 880px) {
  .ccq-row { grid-template-columns: 1fr auto; grid-template-areas: "name kill" "stats stats"; }
  .ccq-name { grid-area: name; }
  .ccq-kill { grid-area: kill; }
}

/* ── Fail-closed ────────────────────────────────────────────────────────────── */
.cc-forbidden {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 70px 20px; text-align: center;
}
.ccfb-orb {
  width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center;
  background: var(--acc-soft); border: 1px solid var(--acc-tint);
}
.ccfb-h { font-size: var(--fs-18); font-weight: 800; color: var(--t-1); margin: 4px 0 0; }
.ccfb-p { font-size: var(--fs-13); color: var(--t-3); margin: 0 0 6px; max-width: 360px; }

/* ── Status footer ──────────────────────────────────────────────────────────── */
.cc-status-footer .sf-dot { background: var(--green); }
.cc-status-footer .sf-dot.err { background: var(--red); }

/* ── RTL niceties (mirror intelligence.css) ─────────────────────────────────── */
[dir="rtl"] .cc-kpi::before { inset: 0 0 0 auto; border-radius: 0 3px 3px 0; }
[dir="rtl"] .cck-cur { margin-right: 0; margin-left: 2px; }
[dir="rtl"] .cc-card-link, [dir="rtl"] .cc-count-badge { margin-left: 0; margin-right: auto; }
[dir="rtl"] .ccfl-pct { margin-left: 0; margin-right: auto; }
[dir="rtl"] .cc-refresh-btn { margin-left: 0; margin-right: 4px; }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .cc-hero { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 880px) {
  .cc-grid { grid-template-columns: 1fr; }
  .cc-card-wide { grid-column: auto; }
}
@media (max-width: 620px) {
  .cc-hero { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cc-quicklinks .cc-ql span { display: none; }
}
