/* ================================================================
   ATLAS COMMAND v6 — Clean, flat, Google-inspired
   White base, minimal borders, no gradients, no glow
   ================================================================ */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg-base: #f8f9fa;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-elevated: #f1f3f4;
    --bg-hover: #f1f3f4;
    --border: #e0e0e0;
    --border-strong: #dadce0;
    --text-primary: #202124;
    --text-secondary: #3c4043;
    --text-muted: #5f6368;
    --text-faint: #9aa0a6;
    --accent: #1a73e8;
    --accent-light: #4285f4;
    --green: #1e8e3e;
    --blue: #1a73e8;
    --orange: #e8710a;
    --red: #d93025;
    --cyan: #007b83;
    --radius-sm: 8px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(60,64,67,0.1);
    --shadow-md: 0 1px 3px rgba(60,64,67,0.15), 0 1px 2px rgba(60,64,67,0.1);
    --shadow-lg: 0 2px 6px rgba(60,64,67,0.15), 0 1px 3px rgba(60,64,67,0.1);
    --transition: 0.15s ease;
}

body {
    font-family: 'Google Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-base);
    color: var(--text-primary); min-height: 100vh;
    overflow-x: hidden; -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}
a { color: inherit; text-decoration: none; }

/* -- Sidebar + Top Bar Layout ------------------------------------ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px; flex-shrink: 0;
    background: #202124; color: #e8eaed;
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 100;
}
.sidebar-logo {
    padding: 20px 20px 16px; display: flex; align-items: center; gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo-icon {
    width: 32px; height: 32px; border-radius: 8px;
    background: var(--accent); display: flex; align-items: center;
    justify-content: center; font-size: 14px; font-weight: 800; color: #fff;
}
.sidebar-logo-text { font-size: 13px; font-weight: 700; letter-spacing: 1.5px; color: #e8eaed; }
.sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; border-radius: 6px;
    font-size: 13px; font-weight: 500; color: #9aa0a6;
    transition: all var(--transition); cursor: pointer;
}
.sidebar-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.7; }
.sidebar-link:hover { background: rgba(255,255,255,0.08); color: #e8eaed; }
.sidebar-link:hover svg { opacity: 1; }
.sidebar-link.active { background: rgba(26,115,232,0.15); color: #8ab4f8; font-weight: 600; }
.sidebar-link.active svg { opacity: 1; color: #8ab4f8; }
.sidebar-footer {
    padding: 14px 16px; border-top: 1px solid rgba(255,255,255,0.08);
    font-size: 10px; color: #5f6368;
}
.sidebar-kbd {
    display: inline-flex; padding: 2px 6px; border-radius: 4px;
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
    font-size: 10px; color: #9aa0a6; cursor: pointer; margin-top: 6px;
}
.sidebar-kbd:hover { border-color: #8ab4f8; color: #8ab4f8; }

.main-content { flex: 1; margin-left: 220px; }

.top-bar {
    display: flex; align-items: center; justify-content: flex-end;
    padding: 0 24px; height: 52px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 90;
    gap: 16px;
}
.system-clock { font-size: 13px; color: var(--text-muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.last-sync { font-size: 11px; color: var(--text-faint); font-weight: 400; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-dot.online { background: var(--green); }

/* Legacy app-bar (hide, replaced by sidebar+topbar) */
.app-bar { display: none; }

/* -- Stats Row --------------------------------------------------- */
.stats-row {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 12px; padding: 20px 24px;
}
.stat-card {
    border-radius: var(--radius-sm);
    padding: 16px 18px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    transition: all var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
a.stat-clickable { text-decoration: none; color: inherit; cursor: pointer; display: block; transition: all 0.15s; }
a.stat-clickable:hover { border-color: var(--accent); }
.stat-card.purple { border-left: 3px solid var(--accent); }
.stat-card.green { border-left: 3px solid var(--green); }
.stat-card.blue { border-left: 3px solid var(--blue); }
.stat-card.orange { border-left: 3px solid var(--orange); }
.stat-card.cyan { border-left: 3px solid var(--cyan); }
.stat-card.red { border-left: 3px solid var(--red); }
.stat-label {
    font-size: 11px; font-weight: 500;
    color: var(--text-muted); margin-bottom: 6px;
}
.stat-value { font-size: 28px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.5px; }
.stat-sub { font-size: 11px; color: var(--text-faint); margin-top: 2px; }

/* -- Pixel Office ------------------------------------------------ */
.office-section { padding: 0 24px 24px; }
.office-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 12px;
}
.office-toggle-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px; font-size: 12px; font-weight: 500;
    color: var(--text-muted); background: var(--bg-surface);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    cursor: pointer; transition: all var(--transition);
}
.office-toggle-btn:hover { border-color: var(--accent); color: var(--accent); }
.office-toggle-btn .chevron {
    display: inline-block; transition: transform 0.3s ease;
    font-size: 10px;
}
.office-toggle-btn.collapsed .chevron { transform: rotate(-90deg); }
.office-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    overflow: hidden;
}
.office-card.hidden { display: none; }

/* -- Main Layout ------------------------------------------------- */
.main-grid { display: grid; grid-template-columns: 1fr 300px; gap: 0; min-height: 500px; }
.agent-panel { padding: 0 24px 24px; }
.section-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; padding: 0;
}
.section-title {
    font-size: 13px; font-weight: 600; letter-spacing: 0.3px;
    color: var(--text-secondary); text-transform: uppercase;
}
.section-badge {
    font-size: 11px; font-weight: 600; padding: 3px 10px;
    border-radius: 4px;
    background: var(--bg-elevated);
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.last-updated { font-size: 11px; color: var(--text-faint); }

/* -- Compact Agent Rows (War Room) ------------------------------- */
.compact-agent-list { display: flex; flex-direction: column; gap: 1px; }
.compact-agent-row {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; border-radius: var(--radius-sm);
    background: var(--bg-surface); border: 1px solid var(--border);
    cursor: pointer; transition: all var(--transition);
    position: relative;
}
.compact-agent-row::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    background: var(--row-color, var(--accent));
}
.compact-agent-row:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
}
.compact-agent-row .mini-avatar {
    width: 32px; height: 32px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 700; color: white; flex-shrink: 0;
}
.compact-agent-row .row-info { flex: 1; min-width: 0; }
.compact-agent-row .row-name { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.compact-agent-row .row-role { font-size: 11px; color: var(--text-muted); }
.compact-agent-row .row-task {
    flex: 2; font-size: 12px; color: var(--text-muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.compact-agent-row .row-stats {
    display: flex; gap: 16px; font-size: 11px; color: var(--text-faint); flex-shrink: 0;
}
.compact-agent-row .row-stats .val { font-weight: 700; color: var(--text-primary); }

/* -- Status Badges (shared) -------------------------------------- */
.agent-status-badge {
    font-size: 10px; font-weight: 600; padding: 3px 10px;
    border-radius: 4px; text-transform: uppercase; letter-spacing: 0.3px;
    flex-shrink: 0;
}
.status-idle { background: #e8f0fe; color: var(--blue); }
.status-working { background: #e6f4ea; color: var(--green); }
.status-paused { background: #fef7e0; color: var(--orange); }
.status-error { background: #fce8e6; color: var(--red); }
.status-offline { background: var(--bg-elevated); color: var(--text-faint); }

/* -- Status dots ------------------------------------------------- */
.status-dot-inline {
    width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0;
}
.status-dot-inline.dot-running { background: var(--green); }
.status-dot-inline.dot-queued { background: var(--blue); }
.status-dot-inline.dot-pending { background: var(--text-faint); }
.status-dot-inline.dot-completed { background: var(--accent); }
.status-dot-inline.dot-failed { background: var(--red); }

/* -- Activity Panel ---------------------------------------------- */
.activity-panel {
    background: var(--bg-surface);
    border-left: 1px solid var(--border);
    display: flex; flex-direction: column; max-height: calc(100vh - 200px);
    overflow: hidden; min-width: 0;
}
.activity-header {
    padding: 14px 16px; border-bottom: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 10px; flex-shrink: 0;
}
.activity-header-top {
    display: flex; align-items: center; justify-content: space-between;
}
.filter-pills { display: flex; gap: 4px; flex-wrap: wrap; }
.filter-pill {
    padding: 5px 12px; font-size: 11px; font-weight: 500;
    border-radius: 4px; cursor: pointer; border: 1px solid var(--border);
    background: transparent; color: var(--text-muted);
    transition: all var(--transition);
}
.filter-pill:hover { border-color: var(--accent); color: var(--accent); }
.filter-pill.active {
    background: var(--accent); color: #fff;
    border-color: var(--accent);
}
.activity-list { flex: 1; overflow-y: auto; padding: 8px 12px; }
.activity-item {
    display: flex; gap: 10px; padding: 8px 6px;
    border-radius: var(--radius-sm); transition: all var(--transition);
}
.activity-item:hover { background: var(--bg-hover); }
.activity-item .mini-avatar {
    width: 28px; height: 28px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-size: 9px; font-weight: 700; color: white; flex-shrink: 0;
}
.activity-item .activity-content { flex: 1; min-width: 0; }
.activity-item .activity-msg { font-size: 12px; color: var(--text-secondary); line-height: 1.5; word-break: break-word; }
.activity-item .activity-time { font-size: 10px; color: var(--text-faint); margin-top: 4px; font-weight: 500; }

/* -- Monitor Strip ----------------------------------------------- */
.monitor-strip {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 12px; padding: 20px 24px;
    background: var(--bg-surface); border-top: 1px solid var(--border);
}
.monitor-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 14px 16px;
    display: flex; align-items: center; gap: 12px;
    transition: all var(--transition);
}
.monitor-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.monitor-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.monitor-dot.ok { background: var(--green); }
.monitor-dot.warning { background: var(--orange); }
.monitor-dot.error { background: var(--red); }
.monitor-dot.unknown { background: var(--text-faint); }
.monitor-info { flex: 1; }
.monitor-name { font-size: 13px; font-weight: 700; color: var(--text-primary); }
.monitor-schedule { font-size: 10px; color: var(--text-faint); margin-top: 2px; font-weight: 500; }

/* -- Detail Panel (right slide) ---------------------------------- */
.detail-panel-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.15); backdrop-filter: blur(4px); z-index: 200;
}
.detail-panel-overlay.active { display: block; }
.detail-panel {
    position: fixed; top: 0; right: -460px; width: 440px; height: 100vh;
    background: var(--bg-surface); border-left: 1px solid var(--border);
    box-shadow: -8px 0 40px rgba(0,0,0,0.12); z-index: 201;
    overflow-y: auto; transition: right 0.3s cubic-bezier(0.4,0,0.2,1);
}
.detail-panel.open { right: 0; }
.detail-panel-close {
    position: absolute; top: 16px; right: 16px;
    width: 32px; height: 32px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--bg-elevated);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 14px; color: var(--text-muted);
    transition: all var(--transition); z-index: 1;
}
.detail-panel-close:hover { border-color: var(--red); color: var(--red); }
.detail-panel-body { padding: 28px; }
.detail-panel-hero {
    display: flex; align-items: center; gap: 18px; margin-bottom: 24px;
}
.detail-panel-avatar {
    width: 48px; height: 48px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700; color: white; flex-shrink: 0;
}
.detail-panel-name { font-size: 22px; font-weight: 800; color: var(--text-primary); }
.detail-panel-role { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.detail-panel-personality {
    font-size: 13px; color: var(--text-faint); font-style: italic;
    line-height: 1.5; margin-bottom: 24px; padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}
.detail-panel-stats {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 24px;
}
.detail-panel-stat {
    background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 14px; text-align: center;
}
.detail-panel-stat-val { font-size: 22px; font-weight: 800; color: var(--text-primary); }
.detail-panel-stat-label {
    font-size: 10px; font-weight: 600; color: var(--text-faint);
    text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px;
}
.detail-panel-tasks-title {
    font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.5px; margin-bottom: 12px;
}
.detail-panel-task-item {
    display: flex; align-items: center; gap: 10px; padding: 10px 0;
    border-bottom: 1px solid var(--border); font-size: 13px;
}
.detail-panel-task-item:last-child { border-bottom: none; }
.detail-panel-task-title {
    flex: 1; color: var(--text-secondary); overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
}

/* -- Task List Page ---------------------------------------------- */
.task-page { padding: 20px 24px; }
.task-page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.task-page-title { display: flex; align-items: center; gap: 12px; }
.task-page-title h1 {
    font-size: 22px; font-weight: 800; color: var(--text-primary);
    letter-spacing: -0.3px;
}

/* Summary Strip */
.summary-strip {
    display: flex; gap: 6px; margin-bottom: 20px; flex-wrap: wrap;
}
.summary-box {
    padding: 6px 14px; font-size: 12px; font-weight: 600;
    border-radius: 8px; cursor: pointer; transition: all var(--transition);
    border: 1px solid transparent;
}
.summary-box:hover { transform: translateY(-1px); }
.summary-box.active { border-color: currentColor; }
.summary-box.sb-running { background: #dcfce7; color: var(--green); }
.summary-box.sb-queued { background: #dbeafe; color: var(--blue); }
.summary-box.sb-pending { background: #f1f3f8; color: var(--text-muted); }
.summary-box.sb-completed { background: #ede9fe; color: var(--accent); }
.summary-box.sb-failed { background: #fee2e2; color: var(--red); }

/* Filter Bar */
.filter-bar {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    margin-bottom: 20px;
}
.filter-group { display: flex; gap: 4px; align-items: center; }
.filter-group-label {
    font-size: 10px; font-weight: 700; color: var(--text-faint);
    text-transform: uppercase; letter-spacing: 0.5px; margin-right: 4px;
}
.filter-bar .filter-pill {
    padding: 5px 12px; font-size: 11px; font-weight: 500;
    border-radius: 4px; cursor: pointer; border: 1px solid var(--border);
    background: transparent; color: var(--text-muted);
    transition: all var(--transition);
}
.filter-bar .filter-pill:hover { border-color: var(--accent); color: var(--accent); }
.filter-bar .filter-pill.active {
    background: var(--accent); color: #fff;
    border-color: var(--accent);
}
.filter-search {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 12px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--bg-surface);
    transition: all var(--transition); margin-left: auto;
}
.filter-search:focus-within { border-color: var(--accent); }
.filter-search svg { flex-shrink: 0; color: var(--text-faint); }
.filter-search input {
    border: none; outline: none; background: transparent;
    font-size: 13px; color: var(--text-primary); width: 180px;
    font-family: inherit;
}
.filter-search input::placeholder { color: var(--text-faint); }
.filter-counter { font-size: 12px; color: var(--text-faint); font-weight: 500; }

/* Agent Dropdown */
.agent-dropdown {
    padding: 6px 12px; font-size: 11px; font-weight: 500;
    border-radius: 4px; border: 1px solid var(--border);
    background: var(--bg-surface); color: var(--text-muted);
    cursor: pointer; font-family: inherit;
    transition: all var(--transition); appearance: none;
    padding-right: 28px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239ca2be'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}
.agent-dropdown:focus { border-color: var(--accent); outline: none; }

/* Collapsible Headers */
.collapsible-header {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; cursor: pointer; user-select: none;
    border-radius: var(--radius-sm); transition: all var(--transition);
    position: sticky; top: 52px; z-index: 10; margin-bottom: 2px;
}
.collapsible-header:hover { filter: brightness(0.97); }
.collapsible-header .chevron {
    font-size: 10px; transition: transform 0.25s ease; flex-shrink: 0;
}
.collapsible-header.collapsed .chevron { transform: rotate(-90deg); }
.collapsible-header .group-title {
    font-size: 12px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.5px;
}
.collapsible-header .group-count {
    font-size: 11px; font-weight: 700; padding: 2px 8px;
    border-radius: 12px; background: rgba(255,255,255,0.6);
}
.collapsible-body { overflow: hidden; transition: max-height 0.3s ease; }
.collapsible-body.collapsed { max-height: 0 !important; overflow: hidden; }

.ch-running { background: #e6f4ea; color: var(--green); }
.ch-queued { background: #e8f0fe; color: var(--blue); }
.ch-pending { background: var(--bg-elevated); color: var(--text-muted); }
.ch-completed { background: #e8f0fe; color: var(--accent); }
.ch-failed { background: #fce8e6; color: var(--red); }

/* Task List Row */
.task-list-row {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px; border-bottom: 1px solid var(--border);
    cursor: pointer; transition: all var(--transition);
    background: var(--bg-surface);
}
.task-list-row:hover {
    background: var(--bg-hover); transform: translateX(2px);
}
.task-list-row:last-child { border-bottom: none; }
.task-list-row .priority-badge {
    font-size: 9px; font-weight: 700; padding: 3px 8px;
    border-radius: 6px; text-transform: uppercase; letter-spacing: 0.3px;
    flex-shrink: 0;
}
.priority-critical { background: #fce8e6; color: var(--red); }
.priority-high { background: #fef7e0; color: var(--orange); }
.priority-medium { background: #e8f0fe; color: var(--blue); }
.priority-low { background: #f1f3f8; color: var(--text-muted); }
.task-list-row .task-title-text {
    flex: 1; font-size: 13px; font-weight: 600; color: var(--text-primary);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.task-list-row .category-tag {
    font-size: 10px; font-weight: 600; padding: 3px 10px;
    border-radius: 8px; background: var(--bg-elevated); color: var(--text-muted);
    flex-shrink: 0; border: 1px solid var(--border);
}
.task-list-row .task-agent {
    display: flex; align-items: center; gap: 6px; flex-shrink: 0;
}
.task-list-row .task-agent .micro-avatar {
    width: 22px; height: 22px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-size: 7px; font-weight: 800; color: white;
}
.task-list-row .task-agent-name { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.task-list-row .task-age { font-size: 11px; color: var(--text-faint); flex-shrink: 0; min-width: 50px; text-align: right; }

/* Task detail in side panel */
.task-detail-section { margin-bottom: 20px; }
.task-detail-label {
    font-size: 10px; font-weight: 700; color: var(--text-faint);
    text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px;
}
.task-detail-desc {
    font-size: 13px; color: var(--text-secondary); line-height: 1.6;
    background: var(--bg-elevated); padding: 14px; border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.task-detail-result {
    font-size: 12px; color: var(--text-secondary); line-height: 1.5;
    background: var(--bg-elevated); padding: 14px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); max-height: 200px; overflow-y: auto;
    white-space: pre-wrap;
}
.task-detail-error {
    font-size: 12px; color: var(--red); line-height: 1.5;
    background: #fef2f2; padding: 14px; border-radius: var(--radius-sm);
    border: 1px solid #fecaca;
}
.task-detail-meta {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.task-detail-meta-item {
    background: var(--bg-elevated); border: 1px solid var(--border);
    padding: 10px 12px; border-radius: 8px;
}
.task-detail-meta-val { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.task-detail-meta-label { font-size: 10px; color: var(--text-faint); margin-top: 2px; }

/* -- Agent Detail Page ------------------------------------------- */
.agent-detail-page { padding: 24px 28px; }
.agent-detail-page .section-header { padding: 0; margin-bottom: 24px; }
.agent-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.agent-detail-card {
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}
.agent-detail-card:hover { box-shadow: var(--shadow-md); }
.agent-detail-card .agent-hero {
    display: flex; align-items: center; gap: 20px;
    padding: 24px; border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
}
.agent-avatar-lg {
    width: 64px; height: 64px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 800; color: white; flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(0,0,0,0.15);
}
.agent-hero-info { flex: 1; }
.agent-hero-name { font-size: 22px; font-weight: 800; color: var(--text-primary); }
.agent-hero-role { font-size: 13px; color: var(--text-muted); font-weight: 500; margin-top: 4px; }
.agent-hero-personality { font-size: 12px; color: var(--text-faint); margin-top: 6px; font-style: italic; line-height: 1.5; }
.agent-detail-stats {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 1px; background: var(--border);
}
.agent-detail-stat {
    background: var(--bg-surface); padding: 16px 14px; text-align: center;
}
.agent-detail-stat-val { font-size: 20px; font-weight: 800; color: var(--text-primary); }
.agent-detail-stat-label {
    font-size: 10px; font-weight: 600; color: var(--text-faint);
    text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px;
}
.agent-detail-tasks-header {
    font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.5px; padding: 14px 20px 8px;
}
.agent-task-list { padding: 0 20px 16px; }
.agent-task-item {
    display: flex; align-items: center; gap: 10px; padding: 10px 0;
    border-bottom: 1px solid var(--border); font-size: 13px;
}
.agent-task-item:last-child { border-bottom: none; }
.agent-task-item:hover { background: var(--bg-hover); margin: 0 -10px; padding-left: 10px; padding-right: 10px; border-radius: var(--radius-sm); }
.agent-task-title { flex: 1; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Task detail expand panel */
.task-detail-panel {
    max-height: 0; overflow: hidden; transition: max-height 0.25s ease;
    background: var(--bg-elevated); border-radius: 8px; margin: 0 0 4px 0;
}
.task-detail-panel.open { border: 1px solid var(--border); margin: 6px 0 8px 0; }
.task-detail-desc {
    padding: 14px 16px 10px; font-size: 13px; line-height: 1.5;
    color: var(--text-primary); white-space: pre-wrap; word-break: break-word;
}
.task-detail-meta {
    padding: 0 16px 14px; display: flex; flex-wrap: wrap; gap: 16px;
    font-size: 11px; color: var(--text-muted);
}
.task-detail-meta strong { color: var(--text-secondary); }
.task-detail-error { color: var(--red); }

/* Task Chat */
.task-chat-section { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 16px; }
.task-chat-log {
    background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 8px;
    min-height: 60px; max-height: 300px; overflow-y: auto; padding: 12px; margin: 8px 0;
}
.task-chat-log:empty::before {
    content: 'Type a message below to talk to Atlas about this task...';
    color: var(--text-faint); font-size: 12px; font-style: italic;
}
.chat-msg { margin-bottom: 12px; }
.chat-msg:last-child { margin-bottom: 0; }
.chat-msg-who { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 3px; }
.chat-user .chat-msg-who { color: var(--accent); }
.chat-atlas .chat-msg-who { color: var(--green); }
.chat-msg-text { font-size: 13px; line-height: 1.5; color: var(--text-primary); word-break: break-word; }
.chat-msg-text code { background: rgba(0,0,0,0.06); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.chat-thinking { color: var(--text-muted); font-style: italic; animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.chat-error .chat-msg-text { color: var(--red); font-size: 12px; }
.task-chat-input-wrap { display: flex; gap: 8px; }
.task-chat-input {
    flex: 1; background: var(--bg-surface); border: 1px solid var(--border); border-radius: 8px;
    padding: 10px 14px; font-size: 13px; color: var(--text-primary); outline: none;
    font-family: inherit;
}
.task-chat-input:focus { border-color: var(--accent); }
.task-chat-input:disabled { opacity: 0.5; }
.task-chat-send {
    padding: 10px 20px; background: var(--accent); color: white; border: none;
    border-radius: 8px; font-size: 12px; font-weight: 600; cursor: pointer;
    transition: background 0.15s;
}
.task-chat-send:hover { background: var(--accent-light); }

.agent-task-more {
    text-align: center; padding: 12px; font-size: 12px;
    color: var(--accent); cursor: pointer; font-weight: 700;
    transition: all var(--transition);
}
.agent-task-more:hover { color: var(--accent-light); background: rgba(124,58,237,0.04); }

.task-badge {
    font-size: 10px; font-weight: 700; padding: 3px 10px;
    border-radius: 8px; text-transform: uppercase; letter-spacing: 0.3px;
    flex-shrink: 0;
}
.event-task_pending { background: #f1f3f8; color: var(--text-muted); }
.event-task_queued { background: #dbeafe; color: var(--blue); }
.event-task_running { background: #dcfce7; color: var(--green); }
.event-task_completed { background: #ede9fe; color: var(--accent); }
.event-task_failed { background: #fee2e2; color: var(--red); }

/* -- Scraper Page ------------------------------------------------ */
.scraper-page { padding: 24px 28px; }
.scraper-page .section-header { padding: 0; margin-bottom: 24px; }
.scraper-pipeline {
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); margin-bottom: 20px; overflow: hidden;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
}
.scraper-pipeline:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.scraper-pipeline-header {
    display: flex; align-items: center; gap: 18px; padding: 20px 24px;
    cursor: pointer; user-select: none;
    transition: all var(--transition);
}
.scraper-pipeline-header:hover { background: var(--bg-hover); }
.scraper-pipeline-header .chevron {
    font-size: 10px; transition: transform 0.25s ease; flex-shrink: 0;
    color: var(--text-faint);
}
.scraper-pipeline-header.collapsed .chevron { transform: rotate(-90deg); }
.scraper-pipeline-icon {
    width: 46px; height: 46px; border-radius: 13px;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 800; color: white; letter-spacing: 0.5px; flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(0,0,0,0.15);
}
.scraper-pipeline-info { flex: 1; min-width: 0; }
.scraper-pipeline-name { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.scraper-pipeline-client { font-size: 12px; color: var(--text-muted); margin-top: 2px; font-weight: 500; }
.scraper-pipeline-stats { display: flex; gap: 8px; flex-shrink: 0; }
.scraper-stat-badge {
    font-size: 10px; font-weight: 700; padding: 5px 12px;
    border-radius: 8px; text-transform: uppercase;
}
.scraper-stat-badge.scraper-done { background: #dcfce7; color: var(--green); }
.scraper-stat-badge.scraper-active { background: #dbeafe; color: var(--blue); }
.scraper-stat-badge.scraper-blocked { background: #fee2e2; color: var(--red); }
.scraper-overall-progress { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.scraper-task-list {
    padding: 10px 24px 20px; border-top: 1px solid var(--border);
    overflow: hidden; transition: max-height 0.3s ease, padding 0.3s ease;
}
.scraper-task-list.collapsed { max-height: 0 !important; padding-top: 0; padding-bottom: 0; overflow: hidden; }
.scraper-task-row {
    display: flex; align-items: center; gap: 16px; padding: 12px 0;
    border-bottom: 1px solid var(--border);
    transition: all var(--transition);
}
.scraper-task-row:last-child { border-bottom: none; }
.scraper-task-row:hover { background: var(--bg-hover); margin: 0 -10px; padding-left: 10px; padding-right: 10px; border-radius: var(--radius-sm); }
.scraper-task-row.blocked-row { background: rgba(220,38,38,0.03); }
.scraper-task-row.has-results:hover { background: rgba(26,115,232,0.04); border-color: rgba(26,115,232,0.15); }
.results-link-hint { font-size: 11px; color: var(--accent); font-weight: 500; opacity: 0; transition: opacity 0.15s; margin-left: 6px; }
.scraper-task-row.has-results:hover .results-link-hint { opacity: 1; }
.scraper-status-badge {
    width: 40px; height: 28px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 9px; font-weight: 800; letter-spacing: 0.3px; flex-shrink: 0;
}
.scraper-status-badge.scraper-done { background: #dcfce7; color: var(--green); }
.scraper-status-badge.scraper-active { background: #dbeafe; color: var(--blue); }
.scraper-status-badge.scraper-blocked { background: #fee2e2; color: var(--red); }
.scraper-status-badge.scraper-pending { background: #f1f3f8; color: var(--text-muted); }
.scraper-status-badge.scraper-not_started { background: #f1f3f8; color: var(--text-muted); }
.scraper-task-info { flex: 1; min-width: 0; }
.scraper-task-name { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.scraper-task-notes {
    font-size: 11px; color: var(--text-faint); margin-top: 3px;
    line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    cursor: default; transition: all var(--transition);
}
.scraper-task-notes.expanded { white-space: normal; }
.scraper-progress-wrap { display: flex; align-items: center; gap: 10px; flex-shrink: 0; width: 160px; }
.scraper-progress-bar {
    flex: 1; height: 7px; background: #e8ecf4;
    border-radius: 4px; overflow: hidden;
}
.scraper-progress-bar-lg { height: 9px; width: 100px; }
.scraper-progress-fill { height: 100%; border-radius: 4px; transition: width 0.6s ease; }
.scraper-progress-pct { font-size: 11px; font-weight: 700; color: var(--text-muted); width: 35px; text-align: right; }

/* -- Command Palette --------------------------------------------- */
.cmd-palette-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.3); backdrop-filter: blur(8px);
    z-index: 500; align-items: flex-start; justify-content: center;
    padding-top: 20vh;
}
.cmd-palette-overlay.active { display: flex; }
.cmd-palette {
    width: 520px; max-width: 92vw; max-height: 400px;
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    overflow: hidden; display: flex; flex-direction: column;
    animation: cmdPaletteIn 0.15s ease;
}
@keyframes cmdPaletteIn { from { opacity: 0; transform: scale(0.96) translateY(-8px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.cmd-palette-input-wrap {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.cmd-palette-input-wrap svg { flex-shrink: 0; color: var(--text-faint); }
.cmd-palette-input {
    flex: 1; border: none; outline: none; background: transparent;
    font-size: 15px; color: var(--text-primary); font-family: inherit;
}
.cmd-palette-input::placeholder { color: var(--text-faint); }
.cmd-palette-results {
    flex: 1; overflow-y: auto; padding: 8px;
}
.cmd-palette-group-label {
    font-size: 10px; font-weight: 700; color: var(--text-faint);
    text-transform: uppercase; letter-spacing: 0.5px;
    padding: 8px 12px 4px;
}
.cmd-palette-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: 8px; cursor: pointer;
    transition: all 0.1s ease;
}
.cmd-palette-item:hover, .cmd-palette-item.selected {
    background: var(--bg-hover);
}
.cmd-palette-item.selected { outline: 2px solid var(--accent); outline-offset: -2px; }
.cmd-palette-item-icon {
    width: 28px; height: 28px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; flex-shrink: 0;
}
.cmd-palette-item-text { flex: 1; font-size: 13px; font-weight: 500; color: var(--text-primary); }
.cmd-palette-item-sub { font-size: 11px; color: var(--text-faint); }
.cmd-palette-empty {
    padding: 20px; text-align: center; font-size: 13px; color: var(--text-faint);
}

/* -- Skeleton Loader --------------------------------------------- */
.skeleton {
    background: linear-gradient(90deg, #e0e0e0 25%, #f1f3f4 50%, #e0e0e0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease infinite;
    border-radius: 8px;
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.skeleton-row { height: 48px; margin-bottom: 4px; border-radius: 8px; }
.skeleton-card { height: 120px; border-radius: var(--radius-md); }
.skeleton-stat { height: 100px; border-radius: var(--radius-md); }

/* -- Buttons ----------------------------------------------------- */
.btn {
    padding: 8px 18px; font-size: 12px; font-weight: 600; border: none;
    border-radius: 4px; cursor: pointer; letter-spacing: 0.3px;
    transition: all var(--transition); text-transform: uppercase;
    display: inline-flex; align-items: center; gap: 8px;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: #1557b0; }
.btn-secondary { background: var(--bg-surface); border: 1px solid var(--border-strong); color: var(--text-secondary); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

/* -- Empty State ------------------------------------------------- */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-faint); font-size: 13px; font-weight: 500; }

/* -- Scrollbar --------------------------------------------------- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.2); }

/* -- Animations -------------------------------------------------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: translateX(0); } }
.stat-card { animation: fadeUp 0.4s ease both; }
.stat-card:nth-child(1) { animation-delay: 0s; }
.stat-card:nth-child(2) { animation-delay: 0.05s; }
.stat-card:nth-child(3) { animation-delay: 0.1s; }
.stat-card:nth-child(4) { animation-delay: 0.15s; }
.stat-card:nth-child(5) { animation-delay: 0.2s; }
.stat-card:nth-child(6) { animation-delay: 0.25s; }
.compact-agent-row { animation: fadeUp 0.35s ease both; }
.compact-agent-row:nth-child(1) { animation-delay: 0.05s; }
.compact-agent-row:nth-child(2) { animation-delay: 0.08s; }
.compact-agent-row:nth-child(3) { animation-delay: 0.11s; }
.compact-agent-row:nth-child(4) { animation-delay: 0.14s; }
.compact-agent-row:nth-child(5) { animation-delay: 0.17s; }
.compact-agent-row:nth-child(6) { animation-delay: 0.20s; }
.compact-agent-row:nth-child(7) { animation-delay: 0.23s; }
.activity-item { animation: slideIn 0.3s ease both; }
.monitor-card { animation: fadeUp 0.35s ease both; }
.monitor-card:nth-child(1) { animation-delay: 0.05s; }
.monitor-card:nth-child(2) { animation-delay: 0.1s; }
.monitor-card:nth-child(3) { animation-delay: 0.15s; }
.monitor-card:nth-child(4) { animation-delay: 0.2s; }
.agent-detail-card { animation: fadeUp 0.4s ease both; }
.agent-detail-card:nth-child(odd) { animation-delay: 0.05s; }
.agent-detail-card:nth-child(even) { animation-delay: 0.15s; }
.scraper-pipeline { animation: fadeUp 0.4s ease both; }
.task-list-row { animation: slideIn 0.2s ease both; }

/* -- Responsive -------------------------------------------------- */
@media (max-width: 1200px) {
    .stats-row { grid-template-columns: repeat(3, 1fr); }
    .agent-detail-grid { grid-template-columns: 1fr; }
    .monitor-strip { grid-template-columns: repeat(2, 1fr); }
    .scraper-progress-wrap { width: 120px; }
}
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .main-grid { grid-template-columns: 1fr; }
    .activity-panel { max-height: 400px; border-left: none; border-top: 1px solid var(--border); }
    .stats-row { grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 16px; }
    .agent-detail-grid { grid-template-columns: 1fr; }
    .monitor-strip { grid-template-columns: 1fr; }
    .agent-panel { padding: 0 16px 16px; }
    .task-page { padding: 16px; }
    .scraper-page { padding: 16px; }
    .agent-detail-page { padding: 16px; }
    .office-section { padding: 0 16px 16px; }
    .scraper-progress-wrap { width: 100px; }
    .scraper-pipeline-header { flex-wrap: wrap; gap: 12px; }
    .detail-panel { width: 100vw; right: -100vw; }
    .filter-bar { flex-direction: column; align-items: flex-start; }
    .filter-search { margin-left: 0; width: 100%; }
    .filter-search input { width: 100%; }
    .task-page-header { flex-direction: column; align-items: flex-start; }
    .agent-detail-stats { grid-template-columns: repeat(2, 1fr); }
    .agent-detail-card .agent-hero { flex-direction: column; text-align: center; }
    .summary-strip { flex-wrap: wrap; }
    .compact-agent-row .row-task { display: none; }
    .task-list-row .category-tag { display: none; }
}
@media (max-width: 480px) {
    .stats-row { grid-template-columns: 1fr; }
    .stat-card { padding: 16px; }
    .stat-value { font-size: 28px; }
}

/* -- Dismiss Button (completed tasks) -------------------------------- */
.dismiss-btn {
    display: none;
    align-items: center; justify-content: center;
    width: 22px; height: 22px;
    border: none; border-radius: 6px;
    background: rgba(220, 38, 38, 0.08);
    color: var(--red);
    font-size: 16px; font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, transform 0.15s;
    flex-shrink: 0;
    margin-left: auto;
    line-height: 1;
}
.dismiss-btn:hover {
    background: var(--red);
    color: white;
}
.task-list-row:hover .dismiss-btn,
.agent-task-item:hover .dismiss-btn,
.detail-panel-task-item:hover .dismiss-btn {
    display: inline-flex;
}
.dismissed-toggle {
    display: none;
    align-items: center; gap: 4px;
    padding: 4px 12px;
    border: 1px dashed var(--border-strong);
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.dismissed-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-secondary);
}
