/* CodeForge — dense operator console, dark-first.
   Original design. No vendor UI kits.
   Tokens switch on [data-theme] and [data-density]. */

:root {
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* DARK (default) */
[data-theme="dark"] {
  --bg-0: #09090b;         /* page */
  --bg-1: #0f0f12;         /* cards */
  --bg-2: #16161b;         /* raised */
  --bg-3: #1d1d23;         /* hover */
  --bg-4: #26262e;         /* input bg */
  --line: #22222a;         /* hairline */
  --line-2: #2c2c36;
  --fg-0: #f4f4f5;         /* primary text */
  --fg-1: #d4d4d8;
  --fg-2: #a1a1aa;         /* secondary */
  --fg-3: #71717a;         /* muted */
  --muted-fg: #71717a;
  --accent: #f97316;       /* orange */
  --accent-soft: #f9731622;
  --accent-fg: #fed7aa;
  --ok: #22c55e;
  --ok-soft: #22c55e1f;
  --warn: #eab308;
  --warn-soft: #eab3081f;
  --danger: #ef4444;
  --danger-soft: #ef44441f;
  --info: #60a5fa;
  --info-soft: #60a5fa1f;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
}

/* LIGHT */
[data-theme="light"] {
  --bg-0: #fafaf9;
  --bg-1: #ffffff;
  --bg-2: #f5f5f4;
  --bg-3: #ededec;
  --bg-4: #e7e5e4;
  --line: #e5e5e4;
  --line-2: #d6d3d1;
  --fg-0: #0a0a0a;
  --fg-1: #27272a;
  --fg-2: #52525b;
  --fg-3: #71717a;
  --muted-fg: #a1a1aa;
  --accent: #ea580c;
  --accent-soft: #ea580c14;
  --accent-fg: #9a3412;
  --ok: #16a34a;
  --ok-soft: #16a34a14;
  --warn: #ca8a04;
  --warn-soft: #ca8a0414;
  --danger: #dc2626;
  --danger-soft: #dc262614;
  --info: #2563eb;
  --info-soft: #2563eb14;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
}

/* DENSITY */
[data-density="compact"] {
  --row-h: 30px;
  --pad-y: 7px;
  --pad-x: 10px;
  --gap: 8px;
  --font-sm: 11.5px;
  --font-md: 12.5px;
  --font-lg: 13.5px;
  --h1: 18px;
  --h2: 14px;
  --radius: 6px;
}
[data-density="comfortable"] {
  --row-h: 38px;
  --pad-y: 10px;
  --pad-x: 14px;
  --gap: 12px;
  --font-sm: 12px;
  --font-md: 13px;
  --font-lg: 14px;
  --h1: 20px;
  --h2: 15px;
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body, #root { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  font-size: var(--font-md);
  color: var(--fg-0);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11","ss01","ss03";
}

button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
.mono { font-family: var(--mono); font-feature-settings: normal; }

/* ── Layout ── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w, 240px) 1fr;
  grid-template-rows: 48px 1fr;
  height: 100vh;
}
.sidebar { grid-row: 1 / 3; border-right: 1px solid var(--line); background: var(--bg-1); }
.topbar { grid-column: 2; }
.main {
  grid-column: 2; grid-row: 2;
  overflow: auto;
  background: var(--bg-0);
}

.app.sidebar-collapsed-app { --sidebar-w: 56px; }

/* ── Sidebar ── */
.sidebar {
  display: flex; flex-direction: column;
  padding: 10px 10px 8px;
  gap: 10px;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 6px 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
}
.brand-mark { flex-shrink: 0; }
.brand-name { font-weight: 600; font-size: 13px; letter-spacing: -0.01em; }
.brand-sub { font-size: 10.5px; color: var(--fg-3); letter-spacing: 0.02em; }

.sidebar-nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }

.sidebar-group { display: flex; flex-direction: column; gap: 1px; padding-top: 6px; }
.sidebar-section {
  font-size: 10px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--fg-3);
  padding: 6px 8px 4px;
}
.sidebar-link {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 8px; border-radius: var(--radius);
  border: 0; background: transparent;
  color: var(--fg-1); font-size: var(--font-sm); font-weight: 500;
  text-align: left; position: relative;
  transition: background 0.08s, color 0.08s;
}
.sidebar-link:hover { background: var(--bg-2); color: var(--fg-0); }
.sidebar-link-active {
  background: var(--bg-2); color: var(--fg-0);
  box-shadow: inset 2px 0 0 var(--accent);
}
.sidebar-link-active::before {
  content: ""; position: absolute; left: -10px; top: 4px; bottom: 4px; width: 2px;
  background: var(--accent); border-radius: 0 2px 2px 0;
}
.sidebar-link > span:first-of-type { flex: 1; }
.sidebar-count {
  font-family: var(--mono); font-size: 10px; color: var(--fg-3);
  background: var(--bg-3); padding: 1px 6px; border-radius: 999px;
}
.sidebar-count-accent { color: var(--accent); background: var(--accent-soft); }

.sidebar-icons .sidebar-link { justify-content: center; padding: 8px; }
.sidebar-icons .sidebar-section { display: none; }
.sidebar-collapsed .sidebar-link { justify-content: center; }
.sidebar-collapsed .sidebar-brand { justify-content: center; }

.sidebar-foot { padding-top: 6px; border-top: 1px solid var(--line); }
.sidebar-user {
  display: flex; align-items: center; gap: 9px;
  padding: 6px;
}
.avatar {
  width: 26px; height: 26px; border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #c2410c);
  color: #fff; font-size: 10.5px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.user-name { font-size: var(--font-sm); font-weight: 500; }
.user-mail { font-size: 10.5px; color: var(--fg-3); }

/* ── Topbar ── */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-0);
  position: relative;
  z-index: 100;
  overflow: visible;
}
.topbar-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar-center { flex: 1; display: flex; justify-content: center; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.breadcrumbs { display: flex; align-items: center; gap: 6px; font-size: var(--font-sm); }
.crumb { color: var(--fg-3); }
.crumb:hover { color: var(--fg-0); }
.crumb-active { color: var(--fg-0); font-weight: 500; }
.crumb-sep { color: var(--fg-3); }

.search-box {
  display: flex; align-items: center; gap: 8px;
  width: 100%; max-width: 440px;
  padding: 6px 10px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--fg-3);
}
.search-box input {
  flex: 1; border: 0; outline: 0; background: transparent;
  color: var(--fg-0); font-size: var(--font-sm);
}
.search-box input::placeholder { color: var(--fg-3); }
.topbar-search-wrap {
  position: relative;
  width: 100%;
  max-width: 440px;
}
.topbar-search-wrap .search-box { max-width: none; }
.kbd {
  font-family: var(--mono); font-size: 10.5px;
  color: var(--fg-3);
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg-2);
}
button.kbd {
  cursor: pointer;
  line-height: 1.4;
}

.topbar-menu { position: relative; }
.topbar-popover {
  position: absolute;
  top: calc(100% + 8px);
  z-index: 200;
  width: min(420px, calc(100vw - 32px));
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: none;
}
.topbar-popover-open,
.topbar-menu .topbar-popover { display: block; }
.search-popover {
  left: 0;
  max-height: min(420px, calc(100vh - 72px));
  overflow-y: auto;
}
.notification-popover {
  right: 0;
  width: min(380px, calc(100vw - 32px));
  max-height: min(460px, calc(100vh - 72px));
  overflow-y: auto;
}
.popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-size: var(--font-sm);
  font-weight: 600;
}
.popover-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  color: var(--fg-1);
}
.popover-row:hover { background: var(--bg-2); }
.popover-row:last-child { border-bottom: 0; }
.popover-main {
  min-width: 0;
  flex: 1;
}
.popover-title {
  display: block;
  color: var(--fg-0);
  font-size: var(--font-sm);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.popover-sub {
  display: block;
  margin-top: 2px;
  color: var(--fg-3);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-result-row .badge { flex-shrink: 0; }
.notification-row {
  align-items: flex-start;
  justify-content: flex-start;
}
.notification-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  margin-top: 5px;
  flex: 0 0 auto;
}
.notification-time {
  color: var(--fg-3);
  font-family: var(--mono);
  font-size: 10.5px;
  white-space: nowrap;
  margin-left: 4px;
}
.popover-empty {
  padding: 14px 10px;
  color: var(--fg-3);
  font-size: var(--font-sm);
}

.env-chip {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--font-sm); color: var(--fg-2);
  padding: 5px 9px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.env-sep { color: var(--fg-3); }
.env-mono { font-family: var(--mono); font-size: 11px; color: var(--fg-2); }

.icon-btn {
  position: relative;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent;
  border-radius: var(--radius); color: var(--fg-2);
}
.icon-btn:hover { background: var(--bg-2); color: var(--fg-0); }
.icon-dot {
  position: absolute; top: 6px; right: 6px;
  width: 6px; height: 6px; border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--bg-0);
}
.lang-toggle {
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.04em;
  padding: 6px 9px;
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--fg-2);
}
.lang-toggle:hover { background: var(--bg-2); color: var(--fg-0); }
.logout-form { display: flex; margin: 0; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 11px;
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--fg-0);
  font-size: var(--font-sm); font-weight: 500;
  transition: all 0.08s;
}
.btn:hover { background: var(--bg-2); border-color: var(--line-2); }
.btn-primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.btn-primary:hover { background: #ea580c; border-color: #ea580c; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--fg-2); }
.btn-ghost:hover { background: var(--bg-2); color: var(--fg-0); }
.btn-danger { color: var(--danger); border-color: var(--line); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { padding: 4px 8px; font-size: 11.5px; }
.btn-xs { padding: 2px 7px; font-size: 11px; }

/* ── Cards / Section ── */
.page {
  padding: 20px 24px 40px;
  display: flex; flex-direction: column; gap: 20px;
  max-width: 1600px;
}
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.page-title {
  font-size: var(--h1); font-weight: 600; letter-spacing: -0.015em;
  margin: 0 0 3px;
}
.page-sub { font-size: var(--font-sm); color: var(--fg-3); }
.page-actions { display: flex; gap: 8px; align-items: center; }

.card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.card-title { font-size: var(--font-md); font-weight: 600; letter-spacing: -0.005em; }
.card-actions { display: flex; gap: 6px; align-items: center; }
.card-body { padding: 14px; }

.section { display: flex; flex-direction: column; gap: 10px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 4px;
}
.section-title { font-size: var(--h2); font-weight: 600; margin: 0; }
.section-right { display: flex; gap: 6px; align-items: center; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 7px;
  font-size: 11px; font-weight: 500;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-xs { padding: 1px 5px; font-size: 10px; }
.badge-neutral { background: var(--bg-3); color: var(--fg-2); border-color: var(--line); }
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-soft); }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-soft); }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-soft); }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-soft); }
.badge-info { background: var(--info-soft); color: var(--info); border-color: var(--info-soft); }

/* ── Tables ── */
.tbl { width: 100%; border-collapse: collapse; font-size: var(--font-sm); }
.tbl thead th {
  text-align: left; font-weight: 500;
  padding: 8px 14px;
  color: var(--fg-3); font-size: 11px;
  letter-spacing: 0.03em; text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  background: var(--bg-1);
  position: sticky; top: 0; z-index: 1;
}
.tbl tbody td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  color: var(--fg-1);
}
.tbl tbody tr:hover { background: var(--bg-2); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.td-mono { font-family: var(--mono); font-size: 11.5px; color: var(--fg-2); }
.td-title { color: var(--fg-0); font-weight: 500; }
.profile-limit-cell { min-width: 110px; }
.profile-limit-value {
  color: var(--fg-1);
  font-family: var(--mono);
  font-size: 11.5px;
  margin-bottom: 5px;
  white-space: nowrap;
}

/* ── KV rows ── */
.kv { display: flex; align-items: baseline; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: 0; }
.kv-k { width: 140px; flex-shrink: 0; color: var(--fg-3); font-size: var(--font-sm); }
.kv-v { flex: 1; color: var(--fg-0); font-size: var(--font-sm); word-break: break-word; }

/* ── Progress ── */
.progress {
  height: 4px; border-radius: 999px;
  background: var(--bg-3); overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%; background: var(--accent);
  transition: width 0.3s ease;
}
.progress[data-tone="ok"] .progress-fill { background: var(--ok); }
.progress[data-tone="warn"] .progress-fill { background: var(--warn); }

/* ── Stat tiles ── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat {
  padding: 14px; background: var(--bg-1);
  border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 6px;
}
.stat-label {
  font-size: 11px; color: var(--fg-3); font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.04em;
  display: flex; align-items: center; gap: 6px;
}
.stat-val {
  font-size: 24px; font-weight: 600; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat-sub { font-size: 11px; color: var(--fg-3); }
.stat-delta { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; }
.stat-delta-up { color: var(--ok); }
.stat-delta-down { color: var(--danger); }

/* ── Grids ── */
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-auto-200 { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }

/* ── Empty ── */
.empty {
  padding: 40px; text-align: center;
  color: var(--fg-3); font-size: var(--font-sm);
}
.empty-title { color: var(--fg-1); font-weight: 500; margin-bottom: 4px; }

/* ── Job card ── */
.job-card {
  padding: 12px 14px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 8px;
  transition: border-color 0.08s, background 0.08s;
  cursor: pointer;
}
.job-card:hover { border-color: var(--line-2); background: var(--bg-2); }
.job-card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 8px;
}
.job-card-title {
  font-size: var(--font-sm); font-weight: 500; color: var(--fg-0);
  line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.job-card-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--fg-3);
}
.job-card-meta > * { display: inline-flex; align-items: center; gap: 4px; }
.job-card-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  padding-top: 6px;
  border-top: 1px dashed var(--line);
}

.job-card-compact { padding: 8px 10px; gap: 4px; }
.job-card-compact .job-card-foot { border-top: 0; padding-top: 0; }

/* ── Kanban ── */
.kanban {
  display: grid;
  grid-template-columns: repeat(7, minmax(260px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.kanban-col {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  max-height: 72vh;
}
.kanban-col-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.kanban-col-title { display: flex; align-items: center; gap: 6px; font-size: var(--font-sm); font-weight: 600; }
.kanban-col-count {
  font-family: var(--mono); font-size: 11px; color: var(--fg-3);
  background: var(--bg-3); padding: 1px 6px; border-radius: 999px;
}
.kanban-col-body {
  padding: 8px; display: flex; flex-direction: column; gap: 8px;
  overflow-y: auto; flex: 1;
}

/* ── Timeline ── */
.timeline { display: flex; flex-direction: column; gap: 2px; }
.tl-item {
  display: grid; grid-template-columns: 18px 90px 1fr; gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
  align-items: flex-start;
}
.tl-item:last-child { border-bottom: 0; }
.tl-dot {
  width: 8px; height: 8px; margin-top: 5px;
  border-radius: 999px; background: var(--fg-3);
  box-shadow: 0 0 0 2px var(--bg-1);
  grid-column: 1;
}
.tl-dot-accent { background: var(--accent); }
.tl-dot-ok { background: var(--ok); }
.tl-dot-warn { background: var(--warn); }
.tl-dot-info { background: var(--info); }
.tl-time { font-family: var(--mono); font-size: 11px; color: var(--fg-3); }
.tl-body { font-size: var(--font-sm); color: var(--fg-1); line-height: 1.5; }
.tl-kind { font-family: var(--mono); font-size: 10.5px; color: var(--fg-3); text-transform: uppercase; letter-spacing: 0.03em; margin-right: 6px; }

/* ── Terminal ── */
.terminal {
  background: #07070a;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--mono); font-size: 11.5px;
  overflow: hidden;
  display: flex; flex-direction: column;
}
[data-theme="light"] .terminal { background: #0a0a0a; color: #f4f4f5; }
.terminal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid #1a1a22;
  background: #0f0f14;
  color: #a1a1aa;
}
.terminal-title { display: flex; align-items: center; gap: 8px; font-size: 11px; }
.terminal-body {
  padding: 10px 12px;
  max-height: 360px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
  color: #d4d4d8;
}
.tl-line { display: flex; gap: 10px; }
.tl-line .t { color: #52525b; flex-shrink: 0; }
.tl-line .src-agent { color: #f97316; }
.tl-line .src-stdout { color: #a1a1aa; }
.tl-line .src-stderr { color: #ef4444; }

.terminal-live {
  min-height: 420px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03), 0 18px 44px rgba(0,0,0,0.18);
}
.terminal-live-body {
  min-height: 360px;
  max-height: min(62vh, 640px);
  gap: 0;
  background:
    linear-gradient(180deg, rgba(249,115,22,0.06), transparent 90px),
    #07070a;
}
.terminal-led {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  display: inline-flex;
  box-shadow: 0 0 0 3px rgba(255,255,255,0.04);
}
.terminal-led-ok { background: #22c55e; box-shadow: 0 0 14px rgba(34,197,94,0.6); }
.terminal-led-warn { background: #f59e0b; box-shadow: 0 0 14px rgba(245,158,11,0.5); }
.terminal-led-danger { background: #ef4444; box-shadow: 0 0 14px rgba(239,68,68,0.5); }
.terminal-muted { color: #71717a; }
.terminal-line {
  display: grid;
  grid-template-columns: 64px minmax(54px, max-content) 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 2px 0;
  line-height: 1.55;
}
.terminal-time {
  color: #52525b;
  font-variant-numeric: tabular-nums;
}
.terminal-src {
  min-width: 54px;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.terminal-src-agent { color: #f97316; }
.terminal-src-stdout { color: #38bdf8; }
.terminal-src-stderr { color: #fb7185; }
.terminal-src-system { color: #a1a1aa; }
.terminal-text {
  min-width: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.terminal-text-normal { color: #d4d4d8; }
.terminal-text-error { color: #fca5a5; }
.terminal-text-warn { color: #fcd34d; }
.terminal-text-ok { color: #86efac; }
.terminal-empty {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #71717a;
  min-height: 180px;
}
.terminal-prompt {
  color: #f97316;
  font-weight: 600;
}

/* ── Agent tile ── */
.agent-tile {
  padding: 14px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 10px;
}
.agent-tile-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.agent-name { font-family: var(--mono); font-size: var(--font-sm); font-weight: 600; }
.agent-meta { font-size: 11px; color: var(--fg-3); font-family: var(--mono); }
.agent-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.agent-metric { display: flex; flex-direction: column; gap: 4px; }
.agent-metric-label { font-size: 10.5px; color: var(--fg-3); text-transform: uppercase; letter-spacing: 0.04em; }
.agent-metric-val { font-family: var(--mono); font-size: 11.5px; color: var(--fg-1); }
.mini-bar { height: 3px; background: var(--bg-3); border-radius: 999px; overflow: hidden; }
.mini-bar > div { height: 100%; background: var(--accent); }

/* ── Approvals / form ── */
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.form-label { font-size: 11.5px; color: var(--fg-2); font-weight: 500; }
.form-hint { font-size: 11px; color: var(--fg-3); }
.input, .textarea, .select {
  width: 100%;
  padding: 7px 10px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--fg-0);
  font-size: var(--font-sm);
  outline: none;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input-compact { padding: 5px 8px; min-width: 120px; }
.password-reset-input { width: 150px; }
.textarea { min-height: 72px; resize: vertical; font-family: inherit; }
.textarea-mono { font-family: var(--mono); font-size: 11.5px; }

.checkbox-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.checkbox {
  width: 14px; height: 14px; border-radius: 3px;
  border: 1px solid var(--line-2); background: var(--bg-1);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.checkbox-on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Tabs ── */
.tabs {
  display: flex; gap: 2px;
  border-bottom: 1px solid var(--line);
}
.tab {
  padding: 8px 12px; border: 0; background: transparent;
  color: var(--fg-2); font-size: var(--font-sm);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab-active { color: var(--fg-0); border-bottom-color: var(--accent); font-weight: 500; }
.tab:hover:not(.tab-active) { color: var(--fg-0); }

/* ── Steering controls ── */
.steer-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.steer-sep { width: 1px; height: 18px; background: var(--line); }

/* ── Wizard steps ── */
.steps { display: flex; gap: 12px; margin-bottom: 20px; }
.step {
  flex: 1;
  padding: 10px 12px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex; gap: 10px; align-items: center;
}
.step-n {
  width: 22px; height: 22px; border-radius: 999px;
  background: var(--bg-3); color: var(--fg-2);
  font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.step-active .step-n { background: var(--accent); color: #fff; }
.step-done .step-n { background: var(--ok); color: #fff; }
.step-label { font-size: var(--font-sm); color: var(--fg-1); font-weight: 500; }
.step-sub { font-size: 11px; color: var(--fg-3); }

/* ── Select pill row ── */
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  padding: 4px 9px; font-size: 11.5px;
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: 999px; color: var(--fg-1);
  display: inline-flex; align-items: center; gap: 5px;
}
.pill-active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── Project card ── */
.proj-card {
  padding: 16px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 12px;
}
.proj-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.proj-name { font-size: var(--font-lg); font-weight: 600; letter-spacing: -0.01em; }
.proj-key { font-family: var(--mono); font-size: 11px; color: var(--fg-3); }
.proj-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.proj-stat-val { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.proj-stat-lbl { font-size: 10.5px; color: var(--fg-3); text-transform: uppercase; letter-spacing: 0.04em; }

/* ── Helpers ── */
.row { display: flex; align-items: center; gap: 8px; }
.row-actions { justify-content: flex-end; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; }
.ml-auto { margin-left: auto; }
.muted { color: var(--fg-3); }
.text-sm { font-size: var(--font-sm); }
.text-xs { font-size: 11px; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
.divider { height: 1px; background: var(--line); margin: 12px 0; }
.divider-v { width: 1px; background: var(--line); align-self: stretch; }

/* ── Dropdowns / quick modal ── */
.cf-dropdown { position: relative; display: inline-flex; }
.cf-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 190px;
  padding: 6px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 30;
}
.cf-dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 8px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--fg-1);
  font-size: var(--font-sm);
  text-align: left;
}
.cf-dropdown-item:hover { background: var(--bg-2) !important; color: var(--fg-0) !important; }
.cf-dropdown-item-active { background: var(--accent-soft); color: var(--accent); }

.cf-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 58px 18px 18px;
  background: rgba(0,0,0,.38);
}
.quick-modal {
  width: min(520px, calc(100vw - 36px));
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.quick-modal-head,
.quick-modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.quick-modal-foot {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}
.quick-modal-title { font-size: var(--font-lg); font-weight: 600; }
.quick-modal-sub { margin-top: 2px; font-size: var(--font-sm); color: var(--fg-3); }
.quick-modal-body { padding: 14px; }
.quick-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.quick-alert {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 12px;
  border-radius: var(--radius);
  font-size: var(--font-sm);
  border: 1px solid transparent;
}
.quick-alert-danger { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-soft); }
.quick-alert-warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-soft); }
.quick-alert-ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-soft); }
.validation-message { color: var(--danger); font-size: 11px; }

/* Authentication */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(249,115,22,.08), transparent 34%),
    var(--bg-0);
}
.auth-panel {
  width: min(420px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-1);
  box-shadow: var(--shadow);
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.auth-title {
  margin: 0 0 3px;
  font-size: 18px;
  font-weight: 600;
}
.auth-sub {
  color: var(--fg-3);
  font-size: var(--font-sm);
}
.auth-form { display: flex; flex-direction: column; gap: 2px; }
.auth-submit { justify-content: center; width: 100%; margin-top: 4px; }

@media (max-width: 720px) {
  .cf-modal-backdrop { justify-content: center; padding-top: 54px; }
  .quick-form-grid { grid-template-columns: 1fr; gap: 0; }
  .password-reset-input { width: 100%; }
}
