/* ── COMMAND CENTER · HUD ─────────────────────────────────────────── */

:root {
  color-scheme: dark;
  --bg:        #04070a;
  --bg-panel:  rgba(8, 18, 26, 0.72);
  --grid:      rgba(34, 211, 238, 0.045);
  --cyan:      #22d3ee;
  --cyan-dim:  rgba(34, 211, 238, 0.42);
  --cyan-ghost:rgba(34, 211, 238, 0.12);
  --amber:     #fbbf24;
  --red:       #f43f5e;
  --green:     #34d399;
  --text:      #cbe9f2;
  --text-dim:  #6d8e9c;
  --edge:      rgba(34, 211, 238, 0.22);
  --glow:      0 0 12px rgba(34, 211, 238, 0.35);
  --mono:      "JetBrains Mono", "Cascadia Mono", Consolas, "SF Mono", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 28px 64px;
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 48px 48px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.02em;
}

/* ── Atmosphere overlays ──────────────────────────────────────────── */

.scanlines, .vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9000;
}

.scanlines {
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.22) 3px,
    rgba(0, 0, 0, 0.22) 4px
  );
  opacity: 0.5;
}

.vignette {
  background: radial-gradient(ellipse at 50% 40%, transparent 45%, rgba(0, 0, 0, 0.75) 100%);
}

/* ── Corner brackets ──────────────────────────────────────────────── */

.bracket { position: relative; }

.bracket::before,
.bracket::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 1px solid var(--cyan);
  opacity: 0.75;
  pointer-events: none;
}

.bracket::before {
  top: -1px; left: -1px;
  border-right: none;
  border-bottom: none;
}

.bracket::after {
  bottom: -1px; right: -1px;
  border-left: none;
  border-top: none;
}

/* ── Boot sequence ────────────────────────────────────────────────── */

.boot {
  position: fixed;
  inset: 0;
  z-index: 9500;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease;
}

.boot.done {
  opacity: 0;
  pointer-events: none;
}

.boot-inner { width: min(520px, 80vw); }

.boot-mark {
  font-size: 44px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--cyan);
  text-shadow: var(--glow);
  margin-bottom: 20px;
  animation: flicker 2.2s infinite;
}

.boot-log {
  font-size: 12px;
  color: var(--cyan-dim);
  line-height: 1.9;
  min-height: 160px;
}

.boot-log div::before { content: "› "; color: var(--cyan); }
.boot-log .ok { color: var(--green); }

@keyframes flicker {
  0%, 92%, 100% { opacity: 1; }
  94% { opacity: 0.45; }
  96% { opacity: 1; }
  97% { opacity: 0.6; }
}

/* ── Top bar ──────────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
  margin: 28px 0 24px;
  padding: 16px 20px;
  background: var(--bg-panel);
  border: 1px solid var(--edge);
  backdrop-filter: blur(2px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--cyan);
  text-shadow: var(--glow);
  padding: 6px 10px;
  border: 1px solid var(--cyan-dim);
}

.topbar h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.26em;
  color: var(--text);
}

.brand-sub {
  margin-top: 3px;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--text-dim);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  gap: 10px;
}

/* ── System status strip ──────────────────────────────────────────── */

.sysstrip {
  display: flex;
  gap: 26px;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 92px;
}

.stat-label {
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--text-dim);
}

.stat-value {
  font-size: 15px;
  color: var(--cyan);
  text-shadow: var(--glow);
  font-variant-numeric: tabular-nums;
}

.meter {
  display: block;
  height: 3px;
  background: var(--cyan-ghost);
  overflow: hidden;
}

.meter i {
  display: block;
  height: 100%;
  background: var(--cyan);
  box-shadow: var(--glow);
  transition: width 0.6s ease;
}

.stat.warn .stat-value { color: var(--amber); text-shadow: 0 0 12px rgba(251, 191, 36, 0.4); }
.stat.warn .meter i    { background: var(--amber); box-shadow: 0 0 12px rgba(251, 191, 36, 0.4); }
.stat.crit .stat-value { color: var(--red); text-shadow: 0 0 12px rgba(244, 63, 94, 0.4); }
.stat.crit .meter i    { background: var(--red); box-shadow: 0 0 12px rgba(244, 63, 94, 0.4); }

/* ── Section header ───────────────────────────────────────────────── */

.section-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 16px;
}

.section-title {
  font-size: 10px;
  letter-spacing: 0.28em;
  color: var(--cyan);
}

.rule {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--edge), transparent);
}

.section-count {
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--text-dim);
}

/* ── Buttons ──────────────────────────────────────────────────────── */

button {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  padding: 9px 16px;
  background: transparent;
  color: var(--cyan);
  border: 1px solid var(--cyan-dim);
  cursor: pointer;
  transition: background 0.16s, box-shadow 0.16s, color 0.16s;
}

button:hover {
  background: var(--cyan-ghost);
  box-shadow: var(--glow);
}

button.primary {
  background: var(--cyan-ghost);
  border-color: var(--cyan);
  color: #e6fbff;
}

button.primary:hover {
  background: rgba(34, 211, 238, 0.26);
}

/* ── Project grid ─────────────────────────────────────────────────── */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 18px;
}

.card {
  position: relative;
  padding: 16px 18px 14px;
  background: var(--bg-panel);
  border: 1px solid var(--edge);
  backdrop-filter: blur(2px);
  transition: border-color 0.2s, box-shadow 0.2s;
  animation: fadeUp 0.4s ease both;
}

.card:hover {
  border-color: var(--cyan-dim);
  box-shadow: 0 0 22px rgba(34, 211, 238, 0.12);
}

.card::before,
.card::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  border: 1px solid var(--cyan);
  opacity: 0.6;
  pointer-events: none;
}

.card::before { top: -1px; left: -1px; border-right: none; border-bottom: none; }
.card::after  { bottom: -1px; right: -1px; border-left: none; border-top: none; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.card-title {
  font-size: 14px;
  letter-spacing: 0.1em;
  color: #e6fbff;
  text-transform: uppercase;
}

.card-path {
  margin-top: 3px;
  font-size: 10px;
  color: var(--text-dim);
  word-break: break-all;
}

/* ── Badges ───────────────────────────────────────────────────────── */

.badge {
  flex-shrink: 0;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 4px 8px;
  border: 1px solid currentColor;
  white-space: nowrap;
}

.badge.clean   { color: var(--green); }
.badge.dirty   { color: var(--amber); }
.badge.missing { color: var(--red); }

/* ── Git lines ────────────────────────────────────────────────────── */

.git-line {
  margin-top: 12px;
  font-size: 11px;
  color: var(--cyan);
  letter-spacing: 0.08em;
}

.git-line::before {
  content: "⑂ ";
  opacity: 0.7;
}

.commit-line {
  margin-top: 5px;
  font-size: 10px;
  color: var(--text-dim);
  line-height: 1.5;
  border-left: 1px solid var(--edge);
  padding-left: 8px;
}

/* ── Inputs ───────────────────────────────────────────────────────── */

input[type="text"],
input[type="date"] {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--edge);
  padding: 7px 9px;
  outline: none;
  transition: border-color 0.16s, box-shadow 0.16s;
}

input[type="text"]:focus,
input[type="date"]:focus {
  border-color: var(--cyan);
  box-shadow: var(--glow);
}

input::placeholder { color: var(--text-dim); opacity: 0.7; }

/* dark calendar icon */
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(70%) sepia(60%) saturate(600%) hue-rotate(140deg);
  cursor: pointer;
}

.card .desc {
  width: 100%;
  margin-top: 12px;
}

/* ── Tasks ────────────────────────────────────────────────────────── */

.tasks { margin-top: 12px; }

.task-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 0;
  font-size: 11px;
  border-bottom: 1px solid rgba(34, 211, 238, 0.07);
}

.task-row span { flex: 1; word-break: break-word; }

.task-row.done span {
  text-decoration: line-through;
  color: var(--text-dim);
}

.task-row input[type="checkbox"] {
  appearance: none;
  width: 13px;
  height: 13px;
  border: 1px solid var(--cyan-dim);
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
}

.task-row input[type="checkbox"]:checked {
  border-color: var(--green);
}

.task-row input[type="checkbox"]:checked::after {
  content: "✕";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--green);
}

.task-row [data-del] {
  padding: 0 5px;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.16s, color 0.16s;
}

.task-row:hover [data-del] { opacity: 1; }

.task-row [data-del]:hover {
  color: var(--red);
  background: transparent;
  box-shadow: none;
}

.task-add { margin-top: 9px; }
.task-add input { width: 100%; }

/* ── Card footer / deadlines ──────────────────────────────────────── */

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  padding-top: 11px;
  border-top: 1px solid var(--edge);
}

.deadline {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.deadline.ok      { color: var(--text-dim); }
.deadline.soon    { color: var(--amber); }
.deadline.overdue {
  color: var(--red);
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

.deadline-edit { width: 130px; }

/* ── Scan panel ───────────────────────────────────────────────────── */

.panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 8000;
  width: min(620px, 90vw);
  max-height: 72vh;
  overflow-y: auto;
  padding: 20px 22px;
  background: rgba(6, 14, 20, 0.97);
  border: 1px solid var(--cyan-dim);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.9), 0 0 30px rgba(34, 211, 238, 0.12);
}

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

.panel-header h2 {
  margin: 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2em;
  color: var(--cyan);
}

.panel-header button {
  border: none;
  font-size: 18px;
  line-height: 1;
  padding: 0 6px;
  color: var(--text-dim);
}

.panel-header button:hover {
  color: var(--red);
  background: transparent;
  box-shadow: none;
}

.scan-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid rgba(34, 211, 238, 0.07);
  font-size: 12px;
}

.scan-item small {
  display: block;
  margin-top: 3px;
  font-size: 10px;
  color: var(--text-dim);
}

/* ── Modal ────────────────────────────────────────────────────────── */

.modal {
  position: fixed;
  inset: 0;
  z-index: 8500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 5, 8, 0.8);
  backdrop-filter: blur(3px);
}

.modal-content {
  width: min(430px, 90vw);
  padding: 24px 26px;
  background: rgba(6, 14, 20, 0.98);
  border: 1px solid var(--cyan-dim);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.9), 0 0 30px rgba(34, 211, 238, 0.12);
}

.modal-content h2 {
  margin: 0 0 20px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.2em;
  color: var(--cyan);
}

.modal-content label {
  display: block;
  margin-bottom: 14px;
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--text-dim);
}

.modal-content label input {
  display: block;
  width: 100%;
  margin-top: 6px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

/* ── Misc ─────────────────────────────────────────────────────────── */

.empty {
  grid-column: 1 / -1;
  padding: 44px;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--text-dim);
  border: 1px dashed var(--edge);
}

.hidden { display: none !important; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.3); }
::-webkit-scrollbar-thumb { background: var(--cyan-ghost); }
::-webkit-scrollbar-thumb:hover { background: var(--cyan-dim); }

@media (max-width: 820px) {
  body { padding: 0 14px 40px; }
  .topbar { gap: 18px; }
  .topbar-actions { margin-left: 0; }
  .sysstrip { gap: 18px; }
}


/* ===== control plane panel ===== */
#controlPlane {
  position: static;
  transform: none;
  width: auto;
  max-height: none;
  overflow: visible;
  z-index: auto;
  margin: 24px 28px 8px;
  padding: 16px 20px;
}
.cp-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.cp-actions { display: flex; gap: 12px; align-items: center; }
.cp-updated { opacity: .6; font-size: .75rem; }
.cp-grid { display: grid; grid-template-columns: repeat(4, 1fr) 1.5fr; gap: 10px; margin-bottom: 14px; }
.cp-cell { display: flex; flex-direction: column; padding: 10px; background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.08); }
.cp-label { font-size: .7rem; opacity: .6; letter-spacing: .1em; }
.cp-value { font-size: 1.4rem; font-weight: 700; }
.cp-runs { width: 100%; border-collapse: collapse; font-size: .8rem; }
.cp-runs th { text-align: left; opacity: .55; letter-spacing: .1em; font-size: .68rem; padding: 4px 8px; border-bottom: 1px solid rgba(255,255,255,.15); }
.cp-runs td { padding: 4px 8px; border-bottom: 1px solid rgba(255,255,255,.05); }
.ks-on { color: #ff5252; font-weight: 700; }
.ks-off { color: #69f0ae; font-weight: 700; }
#ksToggle { cursor: pointer; }

.cp-models { margin-bottom: 14px; }
.cp-models-head { display: flex; justify-content: space-between; margin-bottom: 6px; }
.cp-current { opacity: .7; font-size: .75rem; }
.cp-models-row { display: flex; gap: 10px; }
.cp-models-row select {
  flex: 1;
  color-scheme: dark;
  background: rgba(8, 18, 26, 0.9);
  color: var(--text);
  border: 1px solid var(--edge);
  padding: 6px;
  font-family: var(--mono);
  font-size: .8rem;
}
.cp-models-row select:focus { outline: 1px solid var(--cyan-dim); box-shadow: var(--glow); }
.cp-models-row select option {
  background: #08121a;
  color: var(--text);
}
.cp-models-row select option:checked,
.cp-models-row select option:hover {
  background: var(--cyan-ghost);
  color: var(--cyan);
}
.cp-models-row button { cursor: pointer; }

.chat-log { height: 46vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.chat-msg { padding: 8px 12px; border: 1px solid rgba(255,255,255,.08); background: rgba(255,255,255,.03); font-size: .82rem; white-space: pre-wrap; }
.chat-you { align-self: flex-end; border-color: var(--cyan-dim); background: var(--cyan-ghost); max-width: 85%; }
.chat-ai { align-self: flex-start; max-width: 92%; }
.chat-sys { align-self: center; opacity: .55; font-size: .72rem; border: none; background: none; }
.chat-input-row { display: flex; gap: 8px; }
.chat-input-row input { flex: 1; }
#chatBtn { cursor: pointer; }

.card-actions { display: flex; gap: 8px; margin-top: 10px; }
.card-actions button { flex: 1; font-family: var(--mono); font-size: .7rem; padding: 7px 4px; cursor: pointer;
  background: rgba(255,255,255,.04); color: var(--text); border: 1px solid var(--edge); border-radius: 4px; }
.card-actions button:hover { border-color: var(--cyan-dim); box-shadow: var(--glow); }
.card-actions button:disabled { opacity: .5; cursor: wait; }

.activity-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 10px; }
.activity-h { font-family: var(--mono); font-size: .65rem; color: var(--cyan-dim); letter-spacing: .1em; margin-bottom: 6px; }
.activity-list { font-family: var(--mono); font-size: .68rem; color: var(--text); max-height: 240px; overflow-y: auto; scrollbar-width: thin; }
.act-row { display: flex; gap: 8px; padding: 4px 0; border-bottom: 1px solid rgba(255,255,255,.04); align-items: baseline; }
.act-id { color: var(--cyan-dim); min-width: 34px; }
.act-kind { color: #7dd3fc; min-width: 50px; }
.act-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .85; }
.act-status { min-width: 52px; text-align: right; }
.act-at { color: #94a3b8; }
.st-done { color: #4ade80; } .st-pending { color: #facc15; } .st-running { color: #7dd3fc; } .st-failed { color: #f87171; }
.act-empty { opacity: .4; padding: 6px 0; }

.logs-filters { display: flex; gap: 6px; margin: 8px 0; }
.log-filter { font-family: var(--mono); font-size: .62rem; padding: 3px 9px; cursor: pointer;
  background: transparent; color: var(--text); border: 1px solid var(--edge); border-radius: 3px; }
.log-filter.active { border-color: var(--cyan-dim); color: var(--cyan-dim); box-shadow: var(--glow); }
.logs-list { max-height: 320px; overflow-y: auto; }
.log-row { display: flex; gap: 8px; padding: 3px 0; border-bottom: 1px solid rgba(255,255,255,.04); font-size: .66rem; align-items: baseline; }
.log-src { color: #a78bfa; min-width: 52px; }
.log-kind { min-width: 110px; }
.log-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .85; }

.logs-list::-webkit-scrollbar, .activity-list::-webkit-scrollbar { width: 6px; }
.logs-list::-webkit-scrollbar-thumb, .activity-list::-webkit-scrollbar-thumb { background: var(--edge); border-radius: 3px; }
