:root {
    --bg-dark: #050505; /* Deep cyber black */
    --bg-surface: rgba(22, 27, 34, 0.6);
    --bg-surface2: rgba(31, 36, 40, 0.6);
    --bg-card: rgba(20, 25, 32, 0.6);
    --bg-card-alt: rgba(30, 41, 59, 0.5);
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --text-faint: #475569;
    --text-secondary: #cbd5e1;
    --border-color: rgba(255, 255, 255, 0.05);
    --border-strong: rgba(255, 255, 255, 0.1);
    --primary: #3b82f6;
    --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    --secondary-gradient: linear-gradient(135deg, #10b981 0%, #3b82f6 100%);
    --border: rgba(255, 255, 255, 0.05);
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    --glass-blur: blur(12px);
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 13px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 0;
    max-width: 100%;
    margin: 0;
}

#app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

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

/* ── Left Sidebar ──────────────────────────────────────── */
#main-sidebar {
    display: flex;
    flex-direction: column;
    width: 160px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    background: rgba(10, 12, 18, 0.6);
    padding: 8px 6px;
    overflow-y: auto;
    scrollbar-width: none;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
}

.sidebar-bottom {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.sidebar-divider {
    height: 1px;
    background: var(--border);
    margin: 6px 4px;
}

.btn-repair {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 14px;
    opacity: 0.4;
    width: 100%;
    text-align: left;
    transition: opacity 0.2s;
}
.btn-repair:hover { opacity: 0.8; background: rgba(255,255,255,0.04); }

.logo {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.logo h1 {
    font-size: 16px;
    font-weight: 800;
    background: var(--secondary-gradient);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
}

.ver {
    font-size: 10px;
    opacity: 0.5;
    -webkit-text-fill-color: var(--text-secondary);
}

.project-header-box {
    background: rgba(254, 243, 199, 0.05);
    /* Very light amber/yellow */
    border: 1px solid rgba(251, 191, 36, 0.2);
    border-radius: var(--radius-lg);
    padding: 16px 24px;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.project-sel-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.project-label {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-primary);
}

.project-meta-info {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-secondary);
    text-align: right;
    line-height: 1.4;
}

.project-meta-info b {
    color: #94a3b8;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: transparent;
    border: none;
    border-left: 2px solid transparent;
    color: var(--text-secondary);
    padding: 9px 10px 9px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    text-align: left;
}

.tab-btn .nav-icon {
    font-size: 15px;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.tab-btn .nav-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    background: rgba(88, 166, 255, 0.08);
    color: #58a6ff;
    border-left-color: #58a6ff;
    font-weight: 600;
}

/* Sub-Navigation */
.sub-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
}

main {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    box-shadow: var(--shadow);
}

.section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
    margin-bottom: 20px;
}

.ca-sub-title {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.mt-24 {
    margin-top: 24px;
}

.mb-16 {
    margin-bottom: 16px;
}

.gap-24 {
    gap: 24px;
}

.items-center {
    align-items: center;
}

.row {
    display: flex;
}

.col {
    flex: 1;
}

.rounded-md {
    border-radius: 8px;
}

.p-20 {
    padding: 20px;
}

.bg-card-alt {
    background: var(--bg-card-alt);
}

/* Lists & Items */
.ca-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ca-list-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid transparent;
}

.ca-list-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--primary);
}

.ca-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    color: #4ade80;
}

.ca-meta {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Builder Grid */
.builder-logs-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.log-card {
    background: #000;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.log-head {
    background: #1a1a1a;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

.log-pane {
    height: 200px;
    padding: 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: #4ade80;
    overflow-y: auto;
}

/* Status Pills */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.status-pill {
    padding: 4px 12px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 800;
}

.status-idle {
    background: rgba(148, 163, 184, 0.1);
    color: #94a3b8;
}

.status-running {
    background: rgba(34, 197, 94, 0.1);
    color: #4ade80;
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.2);
}

/* Forms */
input,
select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
}

input:focus {
    border-color: var(--primary);
    outline: none;
}

.input-full {
    width: 100%;
}

.input-group {
    margin-bottom: 12px;
}

.input-group label {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

/* Terminal */
.terminal {
    background: #000;
    height: 500px;
    border-radius: 8px;
    padding: 16px;
    font-family: 'JetBrains Mono', monospace;
    color: #4ade80;
    overflow-y: auto;
}

.log-ts {
    color: #64748b;
    margin-right: 8px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    border: none;
    transition: 0.2s;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.btn-warning {
    background: rgba(251, 146, 60, 0.15);
    color: #fb923c;
    border-color: rgba(251, 146, 60, 0.3);
}

.btn-danger {
    background: #ef4444;
    color: white;
}

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

/* Table */
table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 12px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-secondary);
}

td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

/* Toggle Switch */
.ca-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
}

.ca-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.ca-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #475569;
    transition: .4s;
    border-radius: 22px;
}

.ca-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.ca-slider {
    background-color: #22c55e;
    /* Green */
}

input:focus+.ca-slider {
    box-shadow: 0 0 1px #22c55e;
}

input:checked+.ca-slider:before {
    transform: translateX(22px);
}

/* Table styles for users */
.ca-table {
    width: 100%;
    border-collapse: collapse;
}

.ca-table th {
    text-align: left;
    padding: 12px 8px;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.ca-table td {
    padding: 12px 8px;
    font-size: 13px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.ca-table tr:last-child td {
    border-bottom: none;
}

.ellipsis {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

/* Premium Modal Styles */
.ca-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.2s ease-out;
}

.ca-modal-box {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 400px;
    animation: slideUp 0.3s ease-out;
}

.ca-modal-large {
    max-width: 900px !important;
}

.ca-modal-body {
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 24px;
    text-align: center;
    line-height: 1.5;
}

.ca-modal-actions {
    display: flex;
    gap: 12px;
}

.ca-modal-actions button {
    flex: 1;
    padding: 10px;
    font-weight: 600;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Dashboard Toggles */
.toggle-wrap {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
    cursor: pointer;
}

.toggle-wrap input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #334155;
    transition: .3s;
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked+.toggle-slider {
    background-color: #22c55e;
}

input:checked+.toggle-slider:before {
    transform: translateX(22px);
}
/* ── KB Viewer / Chunk accordion ─────────────────────────────────────────── */
summary::-webkit-details-marker { display: none; }
details.chunk-accordion[open] .details-chevron { transform: rotate(180deg); }
@keyframes fadeIn { from { opacity: 0; backdrop-filter: blur(0px); } to { opacity: 1; backdrop-filter: blur(8px); } }
.ca-spin { animation: ca-spin 1.5s linear infinite; }
@keyframes ca-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes kb-spin { to { transform: rotate(360deg); } }
#kb-ingest-ai-logs::-webkit-scrollbar { width: 6px; }
#kb-ingest-ai-logs::-webkit-scrollbar-track { background: transparent; }
#kb-ingest-ai-logs::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }

/* API Testing animations */
@keyframes at-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.at-pulse { animation: at-pulse 1.2s ease-in-out infinite; }

@keyframes at-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.at-spin { animation: at-spin 1s linear infinite; display: inline-block; }

/* Jira board type badge (clickable) */
.jira-type-badge {
  font-size: 9px; padding: 3px 8px; border-radius: 4px;
  font-weight: 600; flex-shrink: 0; cursor: pointer;
  border: none; outline: none; font-family: inherit;
  transition: filter 0.12s, transform 0.1s;
  user-select: none;
}
.jira-type-badge:hover  { filter: brightness(1.25); }
.jira-type-badge:active { transform: scale(0.93); filter: brightness(0.9); }
.jira-type-badge.scrum  { background: rgba(34,197,94,0.12); color: #4ade80; }
.jira-type-badge.kanban { background: rgba(251,191,36,0.12); color: #fbbf24; }
.jira-type-badge.unknown{ background: rgba(255,255,255,0.06); color: #94a3b8; }

/* ─── Hook Pills (report view — matches overlay visual style) ─── */
.ca-hook-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: default;
  transition: all 0.2s ease;
  border: 1px solid rgba(255,255,255,0.07);
  max-width: 100%;
  min-width: 0;
}
.ca-hook-pill:hover { filter: brightness(1.15); }
.ca-hook-pill__icon { font-size: 13px; flex-shrink: 0; line-height: 1; }
.ca-hook-pill__label { font-size: 10px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; line-height: 1.3; flex: 1; }
.ca-hook-pill__actions { display: flex; gap: 1px; flex-shrink: 0; margin-left: 2px; opacity: 0.4; transition: opacity 0.12s; }
.ca-hook-pill:hover .ca-hook-pill__actions { opacity: 1; }
.ca-hook-pill__btn { width: 22px; height: 22px; border-radius: 4px; border: none; background: transparent; cursor: pointer; font-size: 12px; padding: 0; display: flex; align-items: center; justify-content: center; transition: background 0.1s, color 0.1s; line-height: 1; color: inherit; opacity: 0.8; }
.ca-hook-pill__btn:hover { opacity: 1; background: rgba(255,255,255,0.1); }
.ca-hook-pill__btn--del:hover { background: rgba(239,68,68,0.2); color: #f87171; }
.ca-hook-pill--wait   { background: rgba(56,189,248,0.08); border-color: rgba(56,189,248,0.15); color: #bae6fd; }
.ca-hook-pill--parse  { background: rgba(168,85,247,0.08); border-color: rgba(168,85,247,0.15); color: #e9d5ff; }
.ca-hook-pill--assert { background: rgba(245,158,11,0.08); border-color: rgba(245,158,11,0.15); color: #fde68a; }
.ca-hook-pill--idle   { background: rgba(20,184,166,0.08); border-color: rgba(20,184,166,0.15); color: #99f6e4; }
.ca-hook-pill--time   { background: rgba(236,72,153,0.08); border-color: rgba(236,72,153,0.15); color: #fbcfe8; }
.ca-hook-pill--regex  { background: rgba(16,185,129,0.08); border-color: rgba(16,185,129,0.15); color: #a7f3d0; }
.ca-hook-pill--api    { background: rgba(59,130,246,0.08); border-color: rgba(59,130,246,0.15); color: #bfdbfe; }
.ca-hook-pill--elemcheck { background: rgba(99,102,241,0.12); border-color: rgba(99,102,241,0.25); color: #a5b4fc; }
.ca-hook-pill--elemcheck .ca-hook-pill__icon { color: #a5b4fc; }

/* ─── Hook Config Modal (report view) ─── */
.ca-hook-config__field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ca-hook-config__label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: #94a3b8; }
.ca-hook-config__input { width: 100%; padding: 6px 10px; font-size: 12px; background: rgba(255,255,255,0.04); border: 1px solid rgba(148,163,184,0.12); border-radius: 7px; color: #e2e8f0; outline: none; font-family: 'SF Mono',Monaco,monospace; transition: border-color 0.12s; box-sizing: border-box; resize: vertical; }
.ca-hook-config__input:focus { border-color: rgba(59,130,246,0.5); }
.ca-hook-config__input::placeholder { color: #475569; font-weight: 400; }
.ca-hook-config__select { width: 100%; padding: 6px 10px; font-size: 12px; background: rgba(255,255,255,0.04); border: 1px solid rgba(148,163,184,0.12); border-radius: 7px; color: #e2e8f0; outline: none; cursor: pointer; transition: border-color 0.12s; box-sizing: border-box; }
.ca-hook-config__select:focus { border-color: rgba(59,130,246,0.5); }
.ca-hook-config__row { display: flex; gap: 8px; align-items: flex-start; }
.ca-hook-config__row .ca-hook-config__field { flex: 1; }
.ca-hook-config__divider { height: 1px; background: rgba(148,163,184,0.1); margin: 4px 0; }
.ca-hook-config__sub-title { font-size: 10px; font-weight: 700; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.04em; }
.ca-hook-config__body { display: flex; flex-direction: column; gap: 8px; }

/* ─── Element Check property grid ─── */
.ca-ec-selector-row { display: flex; gap: 6px; align-items: center; }
.ca-ec-selector-input { flex: 1; min-width: 0; }
.ca-ec-prop-group { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.ca-ec-prop-group__label { font-size: 9px; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: 0.05em; }
.ca-ec-props { display: grid; gap: 4px; }
.ca-ec-props--state { grid-template-columns: repeat(3, 1fr); }
.ca-ec-props--value { grid-template-columns: repeat(4, 1fr); }
.ca-ec-prop { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 4px 5px; border-radius: 7px; border: 1px solid rgba(148,163,184,0.1); background: rgba(255,255,255,0.02); color: #64748b; cursor: pointer; transition: background 0.12s, color 0.12s, border-color 0.12s; }
.ca-ec-prop:hover { background: rgba(99,102,241,0.08); border-color: rgba(99,102,241,0.2); color: #a5b4fc; }
.ca-ec-prop--active { background: rgba(99,102,241,0.16); border-color: rgba(99,102,241,0.45); color: #a5b4fc; }
.ca-ec-prop__icon { font-size: 14px; line-height: 1; font-style: normal; }
.ca-ec-prop__label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.ca-ec-ops { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.ca-ec-op { padding: 4px 9px; border-radius: 20px; border: 1px solid rgba(148,163,184,0.12); background: rgba(255,255,255,0.03); color: #64748b; font-size: 10px; font-weight: 600; cursor: pointer; transition: background 0.1s, color 0.1s, border-color 0.1s; white-space: nowrap; }
.ca-ec-op:hover { background: rgba(99,102,241,0.1); border-color: rgba(99,102,241,0.25); color: #a5b4fc; }
.ca-ec-op--active { background: rgba(99,102,241,0.18); border-color: rgba(99,102,241,0.5); color: #c4b5fd; font-weight: 700; }

@keyframes pulse-green {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

@keyframes pulse-red {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.health-dot-green {
    background: #22c55e !important;
    animation: pulse-green 2s infinite;
}

.health-dot-red {
    background: #ef4444 !important;
    animation: pulse-red 1.5s infinite;
}
