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

html {
    scrollbar-width: thin;
    scrollbar-color: #334155 #0f172a;
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #0f172a; border-radius: 3px; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #475569; }

body {
    background: #0f172a;
    color: #f1f5f9;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Login ──────────────────────────────────────────────────────────── */

.login-wrap {
    width: 100%;
    padding: 1rem;
}

.login-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 14px;
    padding: 2.75rem 2.5rem 2.5rem;
    max-width: 400px;
    margin: 0 auto;
    box-shadow: 0 25px 60px rgba(0, 0, 0, .45);
}

.logo {
    display: block;
    height: 36px;
    margin: 0 auto 2.5rem;
}

.field {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    font-size: .8125rem;
    font-weight: 500;
    color: #94a3b8;
    margin-bottom: .375rem;
    letter-spacing: .02em;
    text-transform: uppercase;
}

input {
    width: 100%;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 7px;
    padding: .65rem .875rem;
    color: #f1f5f9;
    font-size: 1rem;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

input::placeholder { color: #475569; }

input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .2);
}

.error-box {
    background: #450a0a;
    border: 1px solid #7f1d1d;
    color: #fca5a5;
    border-radius: 7px;
    padding: .65rem .875rem;
    font-size: .875rem;
    margin-bottom: 1.25rem;
}

.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #064e3b;
    border: 1px solid #065f46;
    color: #86efac;
    border-radius: 7px;
    padding: 1rem 1.25rem;
    font-size: .875rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    max-width: 400px;
}

.notification p {
    margin: 0;
}

.hidden { display: none !important; }

button[type="submit"] {
    width: 100%;
    background: linear-gradient(135deg, #3b82f6, #06b6d4);
    color: #fff;
    border: none;
    border-radius: 7px;
    padding: .75rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s, transform .1s;
    margin-top: .25rem;
    letter-spacing: .01em;
}

button[type="submit"]:hover  { opacity: .9; }
button[type="submit"]:active { transform: scale(.99); }

button[type="submit"]:disabled {
    opacity: .5;
    cursor: not-allowed;
    transform: none;
}

/* ── Dashboard layout ───────────────────────────────────────────────── */

.dashboard-body {
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: #1e293b;
    border-right: 1px solid #334155;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    gap: 1.5rem;
}

.sidebar-logo {
    height: 28px;
    display: block;
    margin: 0 auto .5rem;
}

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

.nav-item {
    display: block;
    padding: .5rem .75rem;
    border-radius: 7px;
    color: #94a3b8;
    text-decoration: none;
    font-size: .9rem;
    font-weight: 500;
    transition: background .15s, color .15s;
}

.nav-item:hover { background: #334155; color: #f1f5f9; }
.nav-item.active { background: #0f172a; color: #38bdf8; }

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    font-size: .8125rem;
    color: #64748b;
}

.user-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-profile-btn {
    background: none;
    border: none;
    color: inherit;
    padding: .35rem .5rem;
    border-radius: 7px;
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: background .15s;
    display: flex;
    flex-direction: column;
    gap: .15rem;
}

.user-profile-btn:hover { background: #334155; }

.profile-edit-hint {
    font-size: .7rem;
    color: #475569;
    transition: color .15s;
}

.user-profile-btn:hover .profile-edit-hint { color: #94a3b8; }

.logout-btn {
    background: none;
    border: 1px solid #334155;
    color: #94a3b8;
    border-radius: 6px;
    padding: .35rem .6rem;
    font-size: .8rem;
    cursor: pointer;
    transition: border-color .15s, color .15s;
}

.logout-btn:hover { border-color: #ef4444; color: #ef4444; }

.btn-heartbeat {
    background: none;
    border: 1px solid #334155;
    color: #6366f1;
    border-radius: 6px;
    padding: .35rem .6rem;
    font-size: .8rem;
    cursor: pointer;
    transition: border-color .15s, color .15s;
    width: 100%;
    margin-bottom: .4rem;
}

.btn-heartbeat:hover    { border-color: #6366f1; }
.btn-heartbeat:disabled { opacity: .5; cursor: default; }

.main {
    flex: 1;
    padding: 2rem 2.5rem;
    overflow-y: auto;
}

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

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.section-header h1 {
    font-size: 1.375rem;
    font-weight: 600;
}

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

.btn-primary {
    background: linear-gradient(135deg, #3b82f6, #06b6d4);
    color: #fff;
    border: none;
    border-radius: 7px;
    padding: .55rem 1.1rem;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s;
}

.btn-primary:hover { opacity: .88; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-ghost {
    background: none;
    border: 1px solid #334155;
    color: #94a3b8;
    border-radius: 7px;
    padding: .5rem 1rem;
    font-size: .875rem;
    cursor: pointer;
    transition: border-color .15s, color .15s;
}

.btn-ghost:hover { border-color: #94a3b8; color: #f1f5f9; }

.btn-danger {
    background: none;
    border: 1px solid #7f1d1d;
    color: #f87171;
    border-radius: 7px;
    padding: .5rem 1rem;
    font-size: .875rem;
    cursor: pointer;
    transition: background .15s;
}

.btn-danger:hover { background: #450a0a; }

/* ── Filter bar ─────────────────────────────────────────────────────── */

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem;
    margin-bottom: 1.25rem;
}

.filter-btn {
    background: none;
    border: 1px solid #334155;
    color: #64748b;
    border-radius: 20px;
    padding: .3rem .8rem;
    font-size: .8rem;
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
}

.filter-btn:hover  { border-color: #64748b; color: #f1f5f9; }
.filter-btn.active { border-color: #38bdf8; color: #38bdf8; background: rgba(56,189,248,.08); }
.filter-btn--toggle { margin-left: auto; border-style: dashed; }
.filter-btn--toggle.active { border-style: solid; }

.filter-input {
    width: auto;
    min-width: 220px;
    font-size: .85rem;
    padding: .28rem .75rem;
    border-radius: 20px;
}

.filter-select {
    width: auto;
    font-size: .85rem;
    padding: .28rem .6rem;
    border-radius: 20px;
    border: 1px solid #334155;
    background: #1e293b;
    color: #f1f5f9;
    cursor: pointer;
}

/* ── Task list ──────────────────────────────────────────────────────── */

.tasks-list {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.task-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 9px;
    padding: .85rem 1.1rem;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

.task-row:hover { border-color: #475569; background: #253347; }

.task-row-main {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    min-width: 0;
}

.task-name {
    font-weight: 500;
    font-size: .9375rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-desc-preview {
    font-size: .8rem;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-row-badges {
    display: flex;
    gap: .4rem;
    flex-shrink: 0;
}

.empty-msg {
    color: #64748b;
    font-size: .9rem;
    padding: 1rem 0;
}

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

.badge {
    display: inline-block;
    border-radius: 20px;
    padding: .2rem .65rem;
    font-size: .75rem;
    font-weight: 600;
    letter-spacing: .02em;
    margin-left: .125rem;
    margin-right: .125rem;
}

.badge--type-human      { background: #1e3a5f; color: #7dd3fc; }
.badge--type-agent      { background: #3b1f5f; color: #c4b5fd; }
.badge--type-monitoring { background: #1f3a2a; color: #6ee7b7; }

.badge--state-TODO         { background: #1e293b; color: #94a3b8; border: 1px solid #334155; }
.badge--state-IN_EXECUTION { background: #1e3a5f; color: #38bdf8; }
.badge--state-ON_HOLD      { background: #3a2e0f; color: #fbbf24; }
.badge--state-BLOCKED      { background: #3a1f0f; color: #fb923c; }
.badge--state-DONE         { background: #1f3a2a; color: #4ade80; }
.badge--state-CANCELLED    { background: #2a1f1f; color: #94a3b8; }

.badge--priority-1 { background: #1e293b; color: #64748b; border: 1px solid #334155; }
.badge--priority-2 { background: #1e293b; color: #94a3b8; border: 1px solid #475569; }
.badge--priority-3 { background: #1e3a5f; color: #7dd3fc; }
.badge--priority-4 { background: #3a2e0f; color: #fbbf24; }
.badge--priority-5 { background: #4a1f1f; color: #f87171; }

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

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}

.modal.hidden { display: none !important; }

.modal-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 14px;
    padding: 2rem;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 60px rgba(0,0,0,.5);
    scrollbar-width: thin;
    scrollbar-color: #334155 #0f172a;
}

.modal-card--wide { max-width: 560px; }

.modal-card h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
}

textarea {
    width: 100%;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 7px;
    padding: .65rem .875rem;
    color: #f1f5f9;
    font-size: .9375rem;
    font-family: inherit;
    resize: vertical;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,.2);
}

select {
    width: 100%;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 7px;
    padding: .65rem .875rem;
    color: #f1f5f9;
    font-size: .9375rem;
    outline: none;
    cursor: pointer;
    transition: border-color .15s;
}

select:focus { border-color: #3b82f6; }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
    margin-top: 1.5rem;
}

/* ── Detail modal ───────────────────────────────────────────────────── */

.detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.detail-header h2 { font-size: 1.125rem; font-weight: 600; margin-bottom: .5rem; }

.detail-meta { display: flex; gap: .4rem; flex-wrap: wrap; }

.detail-desc {
    color: #94a3b8;
    font-size: .9rem;
    margin-bottom: 1.5rem;
    line-height: 1.6;
    min-height: 1.5rem;
}

.detail-transitions {
    border-top: 1px solid #334155;
    padding-top: 1.25rem;
    margin-bottom: 1.25rem;
}

.transitions-label {
    display: block;
    font-size: .8rem;
    color: #64748b;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: .6rem;
}

#transition-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.btn-transition {
    border: none;
    border-radius: 7px;
    padding: .45rem .9rem;
    font-size: .8375rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s;
}

.btn-transition:hover { opacity: .8; }

.btn-transition--IN_EXECUTION { background: #1e3a5f; color: #38bdf8; }
.btn-transition--ON_HOLD      { background: #3a2e0f; color: #fbbf24; }
.btn-transition--BLOCKED      { background: #3a1f0f; color: #fb923c; }
.btn-transition--DONE         { background: #1f3a2a; color: #4ade80; }
.btn-transition--CANCELLED    { background: #2a1f1f; color: #94a3b8; border: 1px solid #334155; }

.no-transitions { font-size: .875rem; color: #475569; }

.detail-footer {
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
    border-top: 1px solid #334155;
    padding-top: 1.25rem;
}

/* ── Task detail page ───────────────────────────────────────────────── */

.task-body {
    display: block;
    align-items: unset;
    justify-content: unset;
    background: #0f172a;
    min-height: 100vh;
}

.task-page {
    max-width: 780px;
    margin: 0 auto;
    padding: 0 1.5rem 3rem;
}

.task-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 0;
    border-bottom: 1px solid #1e293b;
    margin-bottom: 2rem;
}

.task-topbar-right {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.btn-back {
    background: none;
    border: none;
    color: #64748b;
    font-size: .9rem;
    cursor: pointer;
    padding: .35rem .5rem;
    border-radius: 6px;
    transition: color .15s, background .15s;
}

.btn-back:hover { color: #f1f5f9; background: #1e293b; }

.task-detail-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 14px;
    padding: 2rem;
}

.task-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 1.25rem;
}

.task-detail-title-block {
    display: flex;
    flex-direction: column;
    gap: .6rem;
    min-width: 0;
}

.task-detail-name {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    word-break: break-word;
}

.task-detail-badges {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}

.task-detail-actions {
    display: flex;
    gap: .5rem;
    flex-shrink: 0;
}

.task-detail-desc {
    color: #94a3b8;
    font-size: .9375rem;
    line-height: 1.7;
    margin-bottom: 2rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.no-desc { color: #475569; font-style: italic; }

.task-detail-transitions {
    border-top: 1px solid #334155;
    padding-top: 1.5rem;
    margin-bottom: 1.5rem;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.transition-buttons-row {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: .6rem;
}

/* ── Parent breadcrumb ──────────────────────────────────────────────── */

.task-parent-crumb {
    margin-bottom: 1rem;
}

.parent-link {
    font-size: .8375rem;
    color: #64748b;
    text-decoration: none;
    transition: color .15s;
}

.parent-link:hover { color: #38bdf8; }

/* ── Subtasks section ───────────────────────────────────────────────── */

.subtasks-section {
    border-top: 1px solid #334155;
    padding-top: 1.5rem;
    margin-bottom: 1.5rem;
}

.subtasks-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .75rem;
}

.btn-add-subtask {
    background: none;
    border: 1px solid #334155;
    color: #94a3b8;
    border-radius: 6px;
    padding: .25rem .65rem;
    font-size: .8rem;
    cursor: pointer;
    transition: border-color .15s, color .15s;
}

.btn-add-subtask:hover { border-color: #94a3b8; color: #f1f5f9; }

.subtasks-list {
    display: flex;
    flex-direction: column;
    gap: .35rem;
}

.subtask-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .6rem .875rem;
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 7px;
    text-decoration: none;
    color: inherit;
    transition: border-color .15s, background .15s;
}

.subtask-row:hover { border-color: #334155; background: #162032; }

.subtask-name {
    font-size: .9rem;
    color: #e2e8f0;
}

.subtasks-empty {
    font-size: .875rem;
    color: #475569;
}

/* ── Dependency row (inside subtask-row) ────────────────────────────── */

.dep-row {
    text-decoration: none;
    color: inherit;
    cursor: default;
}

.dep-name {
    text-decoration: none;
    color: #e2e8f0;
    transition: color .15s;
}

.dep-name:hover { color: #38bdf8; }

.dep-row-right {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-shrink: 0;
}

.dep-remove {
    background: none;
    border: none;
    color: #475569;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 .1rem;
    transition: color .15s;
}

.dep-remove:hover { color: #ef4444; }

/* ── Dependency modal list ───────────────────────────────────────────── */

.dep-modal-list {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    margin-bottom: .5rem;
}

.dep-modal-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .4rem .75rem;
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 6px;
}

.dep-modal-name {
    font-size: .875rem;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Dependency search dropdown ─────────────────────────────────────── */

.dep-search-wrap { position: relative; }

.dep-search-input {
    width: 100%;
    box-sizing: border-box;
    padding: .45rem .6rem;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 6px;
    color: #e2e8f0;
    font-size: .875rem;
}

.dep-search-input:focus { outline: none; border-color: #38bdf8; }

.dep-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 7px;
    overflow: hidden;
    z-index: 200;
    display: flex;
    flex-direction: column;
}

.dep-drop-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .5rem .75rem;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: background .12s;
}

.dep-drop-item:hover { background: #0f172a; }

.dep-drop-name {
    font-size: .875rem;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Dependency picker modal ────────────────────────────────────────── */

.modal-hint {
    font-size: .8375rem;
    color: #64748b;
    margin-bottom: 1rem;
    margin-top: -.5rem;
}

.dep-picker-list {
    max-height: 260px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: .3rem;
    margin-top: .5rem;
    margin-bottom: .75rem;
}

.dep-pick-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .55rem .875rem;
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 7px;
    cursor: pointer;
    text-align: left;
    color: inherit;
    width: 100%;
    transition: border-color .15s, background .15s;
}

.dep-pick-row:hover { border-color: #334155; background: #162032; }

.dep-pick-name {
    font-size: .9rem;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-detail-meta-footer {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    font-size: .8rem;
    color: #475569;
    border-top: 1px solid #334155;
    padding-top: 1.25rem;
}

.routine-detail-meta {
    display: flex;
    flex-direction: column;
    gap: .6rem;
    margin: 1.25rem 0;
    padding: 1rem 1.25rem;
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 8px;
}

.routine-meta-row {
    display: flex;
    align-items: baseline;
    gap: 1rem;
}

.routine-meta-label {
    font-size: .8rem;
    color: #64748b;
    min-width: 120px;
    flex-shrink: 0;
}

.routine-meta-value {
    font-size: .9rem;
    color: #cbd5e1;
}

code.routine-meta-value {
    font-family: 'Courier New', monospace;
    background: #1e293b;
    padding: .15rem .4rem;
    border-radius: 4px;
    font-size: .85rem;
}

/* ── Projects grid ──────────────────────────────────────────────────── */

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

.project-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    transition: border-color .15s;
    overflow: hidden;
}

.project-card:hover { border-color: #475569; }

.project-card-body {
    padding: 1.25rem 1.25rem .75rem;
    flex: 1;
}

.project-card-name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: .35rem;
    color: #f1f5f9;
}

.project-card-desc {
    font-size: .8375rem;
    color: #64748b;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.project-card-goals {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
    margin-top: .5rem;
}

.project-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 1.25rem;
    border-top: 1px solid #1e293b;
    background: #162032;
    gap: .5rem;
    flex-wrap: wrap;
}

.project-task-count {
    font-size: .8rem;
    color: #475569;
    white-space: nowrap;
}

.project-card-actions {
    display: flex;
    gap: .4rem;
}

.btn-card-action {
    background: none;
    border: 1px solid #334155;
    color: #94a3b8;
    border-radius: 6px;
    padding: .25rem .6rem;
    font-size: .775rem;
    cursor: pointer;
    transition: border-color .15s, color .15s;
    white-space: nowrap;
}

.btn-card-action:hover { border-color: #94a3b8; color: #f1f5f9; }

.btn-card-danger { border-color: #7f1d1d; color: #f87171; }
.btn-card-danger:hover { border-color: #ef4444; color: #ef4444; background: rgba(239,68,68,.08); }

/* ── Project badge ──────────────────────────────────────────────────── */

.badge--project {
    background: #1e2d40;
    color: #7dd3fc;
    border: 1px solid #1e4060;
    display: inline-flex;
    align-items: center;
    gap: .35rem;
}

.badge-clear {
    background: none;
    border: none;
    color: inherit;
    opacity: .6;
    cursor: pointer;
    font-size: .85em;
    line-height: 1;
    padding: 0;
    display: inline-flex;
    align-items: center;
}

.badge-clear:hover { opacity: 1; }

/* ── Users table ────────────────────────────────────────────────────── */

.users-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

.users-table thead th {
    text-align: left;
    font-size: .75rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: .6rem 1rem;
    border-bottom: 1px solid #334155;
}

.users-table tbody tr {
    border-bottom: 1px solid #1e293b;
    transition: background .12s;
}

.users-table tbody tr:last-child { border-bottom: none; }
.users-table tbody tr:hover { background: #1a2638; }

.users-table td {
    padding: .75rem 1rem;
    vertical-align: middle;
}

.users-table .row--inactive td { opacity: .5; }

.td-name  { font-weight: 500; }
.td-email { color: #94a3b8; }

.td-actions {
    display: flex;
    gap: .4rem;
    align-items: center;
}

.protected-label {
    font-size: .775rem;
    color: #475569;
    font-style: italic;
    white-space: nowrap;
}

.badge--role-admin  { background: #312e81; color: #a5b4fc; }
.badge--role-user   { background: #1e293b; color: #94a3b8; border: 1px solid #334155; }
.badge--active      { background: #1f3a2a; color: #4ade80; }
.badge--inactive    { background: #2a1f1f; color: #94a3b8; border: 1px solid #334155; }

.btn-card-enable {
    border-color: #166534;
    color: #4ade80;
}

.btn-card-enable:hover {
    border-color: #4ade80;
    color: #4ade80;
    background: rgba(74,222,128,.08);
}

/* ── Admin nav item ─────────────────────────────────────────────────── */

.nav-item--admin {
    margin-top: auto;
    border-top: 1px solid #334155;
    padding-top: .75rem;
    margin-top: .75rem;
}

/* ── Sidebar nav sections ───────────────────────────────────────────── */

.nav-section-label {
    display: block;
    padding: .75rem .75rem .25rem;
    font-size: .6875rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: #475569;
}

.nav-section-label:first-child {
    padding-top: .25rem;
}

.nav-divider {
    border: none;
    border-top: 1px solid #273447;
    margin: .375rem 0;
}

.sidebar-nav .nav-item {
    padding-left: 1.25rem;
}

.nav-item--disabled {
    opacity: .45;
    cursor: default;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: .4rem;
}

.wip-pill {
    display: inline-flex;
    align-items: center;
    padding: .1rem .4rem;
    border-radius: 4px;
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .04em;
    background: #334155;
    color: #94a3b8;
    line-height: 1.4;
}

/* ── Section title group ────────────────────────────────────────────── */

.section-title-group {
    display: flex;
    align-items: center;
    gap: .75rem;
}

/* ── Routines ───────────────────────────────────────────────────────── */

.routine-row {
    flex-wrap: wrap;
    gap: .5rem;
}

.routine-cron {
    font-family: monospace;
    font-size: .75rem;
    color: #64748b;
    margin-top: .15rem;
}

.routine-row-right {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}

.routine-next {
    font-size: .72rem;
    color: #64748b;
    white-space: nowrap;
}

.routine-no-task {
    font-size: .75rem;
    color: #475569;
}

.routine-actions {
    display: flex;
    gap: .35rem;
    margin-left: .25rem;
}

.field-hint {
    font-size: .72rem;
    color: #64748b;
    margin-top: .2rem;
    display: block;
}

.field--inline {
    display: flex;
    align-items: center;
}

.field--inline label {
    display: flex;
    align-items: center;
    gap: .4rem;
    cursor: pointer;
    margin-bottom: 0;
}

/* ── Tools ──────────────────────────────────────────────────────────── */

.modal-card--wide {
    width: min(680px, 95vw);
}

.code-textarea {
    font-family: monospace;
    font-size: .8rem;
    resize: vertical;
}

.field-row {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.field-row .field {
    flex: 1;
}

.td-desc {
    font-size: .78rem;
    color: #64748b;
}

.badge--type-script   { background: #1e293b; color: #94a3b8; border: 1px solid #334155; }
.badge--type-api_call { background: #1e3a4a; color: #67e8f9; border: 1px solid #0e7490; }
.badge--type-agent    { background: #2d1e4a; color: #c4b5fd; border: 1px solid #6d28d9; }

/* ── Tools (redesign) ───────────────────────────────────────────────── */

.code-input {
    font-family: monospace;
    font-size: .85rem;
}

.input-readonly {
    opacity: .55;
    cursor: default;
}

.input-with-action {
    display: flex;
    gap: .5rem;
}
.input-with-action input { flex: 1; min-width: 0; }
.btn-inline { flex-shrink: 0; padding: .4rem .75rem; font-size: .8rem; }

.tool-internal-name,
.tool-cmd-preview {
    font-family: monospace;
    font-size: .8rem;
    color: #94a3b8;
    background: #0f172a;
    padding: .1rem .35rem;
    border-radius: 3px;
}

.td-cmdline {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.badge--lang {
    background: #1e293b;
    color: #67e8f9;
    border: 1px solid #0e7490;
    font-family: monospace;
    font-size: .75rem;
}

.field-required {
    color: #f87171;
    font-size: .8rem;
}

.badge--queued      { background: #888; color: #fff; font-size: 0.7rem; }
.badge--scheduled   { background: #3a2e0f; color: #fbbf24; border: 1px solid #78490a; font-size: 0.7rem; }
.badge--internal    { background: #1e293b; color: #64748b; border: 1px solid #334155; font-size: .7rem; }
.badge--restricted  { background: #2d1a1a; color: #f87171; border: 1px solid #7f1d1d; font-size: .7rem; }
.badge--visible    { background: #1e293b; color: #6ee7b7; border: 1px solid #065f46; font-size: .7rem; }
.badge--different  { background: #2d1a1a; color: #f8ae71; border: 1px solid #7f5d1d; font-size: .7rem; }
.badge--subtask     { background: #1e293b; color: #94a3b8; border: 1px solid #334155; font-size: .7rem; }
.badge--goal        { background: #052e16; color: #6ee7b7; border: 1px solid #065f46; font-size: .7rem; }

/* ── Commands ───────────────────────────────────────────────────────── */

.commands-list {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    margin-top: .5rem;
}

.command-card {
    border: 1px solid #1e293b;
    border-radius: 6px;
    overflow: hidden;
}

.command-header {
    width: 100%;
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    padding: .55rem .75rem;
    background: #0f172a;
    border: none;
    cursor: pointer;
    text-align: left;
    color: inherit;
    font-size: .85rem;
}

.command-header:hover { background: #1e293b; }

.cmd-index {
    font-family: monospace;
    font-size: .78rem;
    color: #475569;
    min-width: 2rem;
}

.cmd-tool-name {
    color: #cbd5e1;
    font-size: .83rem;
}

.cmd-meta-item {
    font-size: .75rem;
    color: #64748b;
}

.cmd-chevron {
    margin-left: auto;
    font-size: .7rem;
    color: #475569;
}

.command-body {
    padding: .75rem 1rem;
    background: #080f1a;
    border-top: 1px solid #1e293b;
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.cmd-field { display: flex; flex-direction: column; gap: .2rem; }

.cmd-field-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #475569;
}

.cmd-field-value {
    margin: 0;
    font-family: monospace;
    font-size: .8rem;
    color: #94a3b8;
    white-space: pre-wrap;
    word-break: break-word;
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 4px;
    padding: .5rem .65rem;
    max-height: 200px;
    overflow-y: auto;
}

.step-desc {
    font-size: .85rem;
    color: #94a3b8;
    margin: 0 0 .75rem;
}

.step-command {
    border-top: 1px solid #1e293b;
    padding-top: .75rem;
    margin-top: .5rem;
}

.step-cmd-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .5rem;
    flex-wrap: wrap;
}

/* ── Tabs ──────────────────────────────────────────────────────────────────── */

.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #1e293b;
    margin: 1.25rem 0 0;
}

.tab-btn {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    padding: .55rem 1.1rem;
    font-size: .9rem;
    color: #64748b;
    cursor: pointer;
    transition: color .15s, border-color .15s;
}

.tab-btn:hover  { color: #e2e8f0; }
.tab-btn.active { color: #e2e8f0; border-bottom-color: #6366f1; font-weight: 600; }

.tab-panel { padding-top: .25rem; }

/* ── Executor modal & project nodes section ──────────────────────────── */

.executor-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #1e293b;
    margin: .25rem 0 0;
}

.executor-list {
    margin: .5rem 0 0;
}

#reorder-modal .modal-card { max-width: 780px; }

.reorder-row {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem 0;
    border-bottom: 1px solid #1e293b;
}
.reorder-row:last-child { border-bottom: none; }

.reorder-row-actions {
    display: flex;
    gap: .25rem;
    flex-shrink: 0;
}

.reorder-row-info {
    display: flex;
    align-items: center;
    gap: .45rem;
    flex-wrap: wrap;
    min-width: 0;
}

.executor-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .6rem 0;
    border-bottom: 1px solid #1e293b;
}
.executor-row:last-child { border-bottom: none; }

.executor-row-info {
    display: flex;
    align-items: center;
    gap: .45rem;
    flex-wrap: wrap;
    min-width: 0;
}

.executor-msg {
    font-size: .85rem;
    color: #64748b;
    padding: .6rem 0;
}

.executor-msg--error { color: #f87171; }

.executor-add-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-top: .875rem;
    padding-top: .875rem;
    border-top: 1px solid #1e293b;
}
.executor-add-row select { flex: 1; min-width: 0; }
.executor-add-row .btn-ghost { flex-shrink: 0; }

/* project-nodes section inside edit-project modal */
.executor-section-divider { border-top: 1px solid #334155; margin: 1.25rem 0 1rem; }
.executor-section-label   { font-size: .75rem; font-weight: 600; color: #64748b; text-transform: uppercase; letter-spacing: .05em; margin-bottom: .75rem; }
.executor-item            { display: flex; align-items: center; justify-content: space-between; padding: .4rem 0; border-bottom: 1px solid #1e293b; gap: .75rem; }
.executor-item:last-child { border-bottom: none; }
.executor-empty           { font-size: .85rem; color: #64748b; margin: .25rem 0 .75rem; }

/* ── Task title + state row ─────────────────────────────────────────────────── */

.task-title-state-row {
    display: flex;
    align-items: center;
    gap: .875rem;
    flex-wrap: wrap;
    margin-bottom: .75rem;
}

/* ── Task relations (pending subtasks) ──────────────────────────────────────── */

.task-relations {
    border-top: 1px solid #334155;
    padding-top: 1.25rem;
    margin-bottom: 1.5rem;
}

/* ── Execution history (chat-style timeline) ────────────────────────────────── */

.exec-history {
    border-top: 1px solid #334155;
    padding-top: 1.5rem;
    margin-top: .5rem;
    margin-bottom: 1rem;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.exec-timeline {
    display: flex;
    flex-direction: column;
    gap: .85rem;
    margin-bottom: 1.25rem;
}

.exec-empty {
    font-size: .875rem;
    color: #475569;
    text-align: center;
    padding: 1.25rem 0;
}

/* Chat rows */

.chat-row {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
}

.chat-row--left {
    align-self: flex-start;
    max-width: 82%;
}

.chat-row--right {
    align-self: flex-end;
    max-width: 82%;
}

.chat-row--tool {
    align-self: stretch;
}

.chat-row--milestone {
    align-self: center;
}

/* Avatars */

.chat-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .72rem;
    font-weight: 700;
    flex-shrink: 0;
    margin-top: .2rem;
}

.chat-avatar--user   { background: #3730a3; color: #a5b4fc; }
.chat-avatar--system { background: #0c4a6e; color: #38bdf8; font-size: .85rem; }

/* Chat bubbles */

.chat-bubble {
    border-radius: 12px;
    padding: .6rem .875rem;
    word-break: break-word;
    min-width: 0;
}

.chat-bubble--user   { background: #1e2d50; border: 1px solid #2d3f6b; }
.chat-bubble--system { background: #162032; border: 1px solid #1e293b; }
.chat-bubble--queued { border-style: dashed; }

.chat-meta {
    display: flex;
    align-items: center;
    gap: .45rem;
    margin-bottom: .3rem;
    flex-wrap: wrap;
}

.chat-meta--right { flex-direction: row-reverse; }

.chat-author {
    font-size: .75rem;
    font-weight: 600;
    color: #94a3b8;
}

.chat-dt {
    font-size: .7rem;
    color: #475569;
}

.chat-content {
    margin: 0;
    font-size: .875rem;
    color: #e2e8f0;
    word-break: break-word;
    line-height: 1.55;
}
.chat-content a { color: #38bdf8; text-decoration: underline; }
.chat-content a:hover { color: #7dd3fc; }
.chat-content ul { margin-left: 1em; }

/* Tool entry row */

.chat-tool-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #064e3b;
    color: #34d399;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
    flex-shrink: 0;
    margin-top: .35rem;
}

.chat-tool-card {
    flex: 1;
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 10px;
    overflow: hidden;
    min-width: 0;
}

.chat-tool-icon--failed               { background: #4c0519; color: #fca5a5; }
.chat-tool-card--failed               { border-color: #7f1d1d; }
.chat-tool-card--failed .chat-tool-name { color: #fca5a5; }

.chat-tool-header {
    display: flex;
    align-items: center;
    gap: .55rem;
    width: 100%;
    padding: .55rem .875rem;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    text-align: left;
    transition: background .12s;
}

.chat-tool-header:hover { background: #162032; }

.chat-tool-name {
    font-size: .875rem;
    font-weight: 600;
    color: #e2e8f0;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-tool-internal {
    font-size: .75rem;
    color: #64748b;
    flex-shrink: 0;
}

.tool-chevron {
    font-size: .7rem;
    color: #475569;
    flex-shrink: 0;
}

.chat-tool-body {
    border-top: 1px solid #1e293b;
    padding: .75rem .875rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.tool-field {
    display: flex;
    flex-direction: column;
    gap: .3rem;
}

.tool-field-label {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: #475569;
}

.tool-field-value {
    margin: 0;
    font-size: .79rem;
    background: #162032;
    border: 1px solid #1e293b;
    border-radius: 6px;
    padding: .45rem .65rem;
    color: #94a3b8;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: 'SFMono-Regular', 'Consolas', monospace;
}

.tool-popup-btn {
    align-self: flex-start;
    background: none;
    border: none;
    color: #38bdf8;
    font-size: .78rem;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}

.tool-popup-btn:hover { color: #7dd3fc; }

/* Milestone row (done subtask) */

.chat-milestone-icon {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #1f3a2a;
    color: #4ade80;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .72rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* State-change milestone variant */

.chat-row--state-change { align-self: flex-start; }

.chat-state-icon {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid #475569;
    flex-shrink: 0;
    margin: 0 6px;
}

.chat-state-arrow {
    font-size: .8rem;
    color: #475569;
}

.chat-state-by {
    font-size: .72rem;
    padding: .1rem .4rem;
    border-radius: 4px;
}

.chat-state-by--user   { background: #1e2a40; color: #7dd3fc; }
.chat-state-by--system { background: #1a2410; color: #86efac; }

.chat-milestone-body {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}

.chat-milestone-link {
    font-size: .875rem;
    color: #e2e8f0;
    text-decoration: none;
}

.chat-milestone-link:hover { color: #38bdf8; }

.chat-milestone-label {
    font-size: .8rem;
    color: #64748b;
    font-weight: 500;
}

/* Comment compose */

.comment-compose {
    border-top: 1px solid #1e293b;
    padding-top: .875rem;
    display: flex;
    flex-direction: column;
    gap: .35rem;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.comment-queue-hint { color: #888; font-size: 0.8rem; margin-top: 4px; }

.comment-compose-row {
    display: grid;
    grid-template-columns: 1fr 38px;
    gap: .4rem;
    align-items: end;
}

.comment-compose textarea {
    width: 100%;
    box-sizing: border-box;
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 8px;
    color: #e2e8f0;
    font-size: .875rem;
    padding: .6rem .75rem;
    resize: vertical;
    font-family: inherit;
    min-height: 72px;
    transition: border-color .15s;
}

.comment-compose textarea:focus {
    outline: none;
    border-color: #6366f1;
}

.btn-send {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #3b82f6, #06b6d4);
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .15s;
}

.btn-send:hover   { opacity: .85; }
.btn-send:disabled { opacity: .4; cursor: not-allowed; }

.btn-send svg {
    width: 16px;
    height: 16px;
    display: block;
}

/* "Open full" button inside tool cards */

.tool-open-btn {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    margin-top: .3rem;
    background: none;
    border: 1px solid #334155;
    color: #94a3b8;
    border-radius: 5px;
    padding: .2rem .55rem;
    font-size: .75rem;
    cursor: pointer;
    transition: border-color .15s, color .15s;
}

.tool-open-btn:hover { border-color: #64748b; color: #f1f5f9; }

/* ── Shared content viewer popup ─────────────────────────────────────────────── */

.content-viewer {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.content-viewer.hidden { display: none !important; }

.content-viewer-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 0;
    max-width: 740px;
    width: 94vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.content-viewer-tabs {
    display: flex;
    align-items: center;
    gap: 0;
    border-bottom: 1px solid #334155;
    padding: 0 .5rem;
    flex-shrink: 0;
}

.content-viewer-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: #64748b;
    cursor: pointer;
    font-size: .85rem;
    padding: .55rem .9rem .65rem;
    margin-bottom: -1px;
    transition: color .15s;
    white-space: nowrap;
}

.content-viewer-tab:hover { color: #f1f5f9; }
.content-viewer-tab.active { border-bottom-color: #3b82f6; color: #f1f5f9; font-weight: 600; }

.content-viewer-title {
    flex: 1;
    font-size: .78rem;
    color: #475569;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 .5rem;
}

.content-viewer-close {
    background: none;
    border: none;
    color: #64748b;
    font-size: 1.25rem;
    cursor: pointer;
    padding: .2rem .3rem;
    line-height: 1;
    flex-shrink: 0;
    margin-left: auto;
}

.content-viewer-close:hover { color: #f1f5f9; }

.content-viewer-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 1rem 1.25rem;
}

.content-viewer-pre {
    font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
    font-size: .82rem;
    color: #e2e8f0;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    line-height: 1.6;
}

.content-viewer-styled {
    color: #f1f5f9;
    font-size: .9rem;
    line-height: 1.65;
}

.content-viewer-styled ul,
.content-viewer-styled ol { padding-left: 1.5em; }
.content-viewer-styled li { margin-top: .25em; }
.content-viewer-styled a  { color: #38bdf8; }
.content-viewer-styled code {
    background: #0f172a;
    padding: .1em .4em;
    border-radius: 4px;
    font-family: 'SFMono-Regular', monospace;
    font-size: .85em;
}
.content-viewer-styled pre {
    background: #0f172a;
    padding: .75rem 1rem;
    border-radius: 6px;
    overflow-x: auto;
    font-size: .82rem;
    line-height: 1.5;
    margin: .5rem 0;
}
.content-viewer-styled table {
    border-collapse: collapse;
    width: 100%;
    font-size: .85rem;
}
.content-viewer-styled th,
.content-viewer-styled td { border: 1px solid #334155; padding: .3rem .7rem; }

.content-viewer-footer {
    display: flex;
    justify-content: flex-end;
    padding: .75rem 1.25rem;
    border-top: 1px solid #1e293b;
    flex-shrink: 0;
}

/* ── History tab ───────────────────────────────────────────────────────────── */

.history-section {
    margin: 1.5rem 0;
}

.history-section-title {
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #475569;
    margin: 0 0 .75rem;
}

/* Timeline */

.timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding-left: .75rem;
    border-left: 2px solid #1e293b;
}

.timeline-entry {
    display: flex;
    gap: .85rem;
    padding: .6rem 0;
    position: relative;
}

.timeline-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: .3rem;
    margin-left: -1.245rem;
}

.timeline-entry--comment .timeline-dot  { background: #6366f1; }
.timeline-entry--command .timeline-dot  { background: #10b981; }

.timeline-body { flex: 1; min-width: 0; }

.timeline-meta {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    margin-bottom: .3rem;
}

.timeline-author {
    font-size: .82rem;
    font-weight: 600;
    color: #cbd5e1;
}

.timeline-dt {
    font-size: .75rem;
    color: #475569;
}

.timeline-content {
    margin: 0;
    font-size: .88rem;
    color: #94a3b8;
    white-space: pre-wrap;
    word-break: break-word;
}

.timeline-output {
    margin: .35rem 0 0;
    font-size: .8rem;
    color: #94a3b8;
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 4px;
    padding: .4rem .6rem;
    max-height: 150px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Comment form */

.comment-form {
    display: flex;
    flex-direction: column;
    gap: .6rem;
}

.comment-form textarea {
    background: #0f172a;
    border: 1px solid #1e293b;
    border-radius: 6px;
    color: #e2e8f0;
    font-size: .88rem;
    padding: .6rem .75rem;
    resize: vertical;
    font-family: inherit;
}

.comment-form textarea:focus {
    outline: none;
    border-color: #6366f1;
}

.comment-form-actions { display: flex; justify-content: flex-end; }

/* ── Quill rich editor — dark theme ─────────────────────────────────── */

.rich-editor-wrap .ql-toolbar.ql-snow {
    background: #0f172a;
    border: 1px solid #334155;
    border-bottom: none;
    border-radius: 7px 7px 0 0;
    padding: .3rem .5rem;
}

.rich-editor-wrap .ql-container.ql-snow {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 0 0 7px 7px;
    font-family: inherit;
    font-size: .9rem;
}

.rich-editor-wrap .ql-editor {
    min-height: 120px;
    max-height: 300px;
    overflow-y: auto;
    color: #f1f5f9;
    padding: .65rem .875rem;
    line-height: 1.6;
}

.rich-editor-wrap .ql-editor.ql-blank::before {
    color: #475569;
    font-style: normal;
    left: .875rem;
}

/* Toolbar buttons & pickers */
.rich-editor-wrap .ql-snow .ql-stroke {
    stroke: #94a3b8;
    transition: stroke .15s;
}
.rich-editor-wrap .ql-snow .ql-fill,
.rich-editor-wrap .ql-snow .ql-stroke.ql-fill {
    fill: #94a3b8;
    transition: fill .15s;
}
.rich-editor-wrap .ql-snow button:hover .ql-stroke,
.rich-editor-wrap .ql-snow button.ql-active .ql-stroke,
.rich-editor-wrap .ql-snow .ql-picker-label:hover .ql-stroke,
.rich-editor-wrap .ql-snow .ql-picker-label.ql-active .ql-stroke {
    stroke: #f1f5f9;
}
.rich-editor-wrap .ql-snow button:hover .ql-fill,
.rich-editor-wrap .ql-snow button.ql-active .ql-fill {
    fill: #f1f5f9;
}

.rich-editor-wrap .ql-toolbar.ql-snow .ql-picker-label {
    color: #94a3b8;
    border-color: transparent;
}
.rich-editor-wrap .ql-toolbar.ql-snow .ql-picker-label:hover,
.rich-editor-wrap .ql-toolbar.ql-snow .ql-picker-label.ql-active {
    color: #f1f5f9;
}

/* Dropdown */
.rich-editor-wrap .ql-snow .ql-picker-options {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.rich-editor-wrap .ql-snow .ql-picker-item { color: #94a3b8; }
.rich-editor-wrap .ql-snow .ql-picker-item:hover,
.rich-editor-wrap .ql-snow .ql-picker-item.ql-selected { color: #f1f5f9; }

/* Inline code & blockquote inside editor */
.rich-editor-wrap .ql-editor code,
.rich-editor-wrap .ql-editor pre { background: #1e293b; color: #7dd3fc; border-radius: 4px; }
.rich-editor-wrap .ql-editor blockquote { border-left: 3px solid #334155; color: #94a3b8; }
.rich-editor-wrap .ql-editor a { color: #38bdf8; }

.comment-compose .rich-editor-wrap .ql-toolbar.ql-snow,
.comment-compose .rich-editor-wrap .ql-container.ql-snow {
    border-color: #1e293b;
}
.comment-compose .rich-editor-wrap .ql-editor { min-height: 72px; }
.comment-compose .rich-editor-wrap:focus-within .ql-toolbar.ql-snow,
.comment-compose .rich-editor-wrap:focus-within .ql-container.ql-snow {
    border-color: #6366f1;
}

/* ── Prompts page ────────────────────────────────────────────────────── */

.section-hint {
    color: #64748b;
    font-size: .875rem;
    margin: -.5rem 0 1.25rem;
}

.section-hint code {
    background: #1e293b;
    padding: .1em .35em;
    border-radius: 4px;
    font-size: .8rem;
    color: #94a3b8;
}

.settings-divider {
    border: none;
    border-top: 1px solid #1e293b;
    margin: 2rem 0 2rem;
}

.settings-cat-heading {
    font-size: 1.125rem;
    font-weight: 600;
    color: #f1f5f9;
    margin: 0 0 .5rem;
}

.settings-cat-desc {
    color: #64748b;
    font-size: .875rem;
    margin: 0 0 1.25rem;
}

.prompt-card {
    background: #111827;
    border: 1px solid #1e293b;
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.prompt-card-header { display: flex; flex-direction: column; gap: .25rem; }
.prompt-card-title  { font-size: 1rem; font-weight: 600; color: #f1f5f9; margin: 0; }
.prompt-card-key    { font-size: .75rem; color: #64748b; }
.prompt-card-desc   { font-size: .825rem; color: #94a3b8; margin: .25rem 0 0; }

.prompt-vars {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
}

.prompt-var code {
    background: #0f172a;
    border: 1px solid #1e3a5f;
    color: #7dd3fc;
    padding: .15em .5em;
    border-radius: 4px;
    font-size: .75rem;
    cursor: default;
}

.prompt-textarea {
    width: 100%;
    min-height: 320px;
    background: #0f172a;
    color: #e2e8f0;
    border: 1px solid #1e293b;
    border-radius: 7px;
    padding: .875rem 1rem;
    font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
    font-size: .8rem;
    line-height: 1.65;
    resize: vertical;
    box-sizing: border-box;
    transition: border-color .15s;
}

.prompt-textarea:focus {
    outline: none;
    border-color: #334155;
}

.prompt-actions {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.prompt-saved-msg {
    font-size: .825rem;
    color: #4ade80;
}

/* ── Rich text rendered display ─────────────────────────────────────── */

.rich-text { color: #e2e8f0; line-height: 1.6; }
.rich-text > *:first-child { margin-top: 0; }
.rich-text > *:last-child  { margin-bottom: 0; }
.rich-text p  { margin: .375rem 0; }
.rich-text h2 { font-size: 1rem;  font-weight: 600; margin: .875rem 0 .25rem; color: #f1f5f9; }
.rich-text h3 { font-size: .9rem; font-weight: 600; margin: .75rem  0 .2rem;  color: #f1f5f9; }
.rich-text ul, .rich-text ol { padding-left: 1.5rem; margin: .375rem 0; }
.rich-text li { margin: .2rem 0; }
.rich-text strong { color: #f1f5f9; }
.rich-text em { color: #cbd5e1; }
.rich-text code { background: #1e293b; padding: .1rem .35rem; border-radius: 4px; font-family: monospace; font-size: .82rem; color: #7dd3fc; border: 1px solid #334155; }
.rich-text pre  { background: #1e293b; padding: .75rem 1rem; border-radius: 7px; overflow-x: auto; border: 1px solid #334155; margin: .5rem 0; }
.rich-text pre code { background: none; border: none; padding: 0; }
.rich-text a { color: #38bdf8; text-decoration: none; }
.rich-text a:hover { text-decoration: underline; }
.rich-text blockquote { border-left: 3px solid #334155; padding-left: .875rem; color: #94a3b8; margin: .5rem 0; }

/* ── Dashboard stats section ─────────────────────────────────────────── */

.dash-refresh-hint {
    font-size: .8rem;
    color: #475569;
}

.dash-grid-full {
    margin-bottom: 1.5rem;
}

.dash-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.dash-card {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
}

.dash-card-title {
    font-size: .75rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .06em;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dash-chart-wrap {
    position: relative;
}

.dash-task-list {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    flex: 1;
}

.dash-task-item {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .45rem .75rem;
    border-radius: 6px;
    background: #0f172a;
    text-decoration: none;
    color: #f1f5f9;
    font-size: .875rem;
    transition: background .15s;
}

.dash-task-item:hover { background: #1e3a5f; }

.dash-task-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dash-task-time {
    font-size: .75rem;
    color: #475569;
    white-space: nowrap;
    flex-shrink: 0;
}

.dash-empty {
    color: #475569;
    font-size: .875rem;
    text-align: center;
    padding: 1.25rem 0;
}

.dash-view-all {
    font-size: .8rem;
    color: #38bdf8;
    text-decoration: none;
    transition: color .15s;
    white-space: nowrap;
}

.dash-view-all:hover { color: #7dd3fc; }

.badge--sm {
    font-size: .7rem;
    padding: .1rem .4rem;
    flex-shrink: 0;
}

/* Node heartbeat */

.dash-nodes-grid {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    flex: 1;
}

.dash-nodes-grid--row {
    flex-direction: row;
    flex-wrap: wrap;
    gap: .75rem;
}

.dash-node-box {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .5rem .75rem;
    border-radius: 6px;
    background: #0f172a;
    font-size: .875rem;
    width: 200px;
    height: 100px;
    flex: 0 0 200px;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: .4rem;
}

.node-name-row {
    display: flex;
    align-items: center;
    gap: .5rem;
    width: 100%;
    min-width: 0;
}

.node-status-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

.node-status-dot--green  { background: #4ade80; box-shadow: 0 0 5px #4ade8077; }
.node-status-dot--yellow { background: #fbbf24; box-shadow: 0 0 5px #fbbf2477; }
.node-status-dot--red    { background: #f87171; box-shadow: 0 0 5px #f8717177; }

.node-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #f1f5f9;
    font-weight: 500;
}

.node-last-seen {
    font-size: .75rem;
    color: #475569;
}

/* ── Dropdown menu (type picker) ─────────────────────────────────────── */

.dropdown-wrap {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 10px;
    min-width: 170px;
    z-index: 200;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
    padding: .25rem 0;
}

.dropdown-section-label {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: #475569;
    padding: .5rem .875rem .3rem;
}

.dropdown-item {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    color: #cbd5e1;
    font-size: .875rem;
    padding: .45rem .875rem;
    cursor: pointer;
    transition: background .12s, color .12s;
}

.dropdown-item:hover {
    background: #0f172a;
    color: #f1f5f9;
}

.dropdown-divider {
    border: none;
    border-top: 1px solid #334155;
    margin: .25rem 0;
}

/* ── Inbox ──────────────────────────────────────────────────────────────────── */

.inbox-unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: #ef4444;
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    padding: 0 4px;
    margin-left: .4rem;
    flex-shrink: 0;
}

.inbox-task {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    padding: .875rem 1rem;
    margin-bottom: .625rem;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

.inbox-task:hover {
    border-color: #475569;
    background: #253347;
}

.inbox-task-header {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .35rem;
}

.inbox-task-name {
    font-size: .9375rem;
    font-weight: 600;
    color: #f1f5f9;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inbox-unread-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: #3b82f6;
    color: #fff;
    font-size: .6875rem;
    font-weight: 700;
    padding: 0 5px;
    flex-shrink: 0;
}

.inbox-task-preview {
    color: #94a3b8;
    font-size: .8125rem;
    margin: 0 0 .25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.inbox-task-time {
    font-size: .75rem;
    color: #475569;
}

/* Inbox modal */

.inbox-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.inbox-modal-header h2 {
    margin: 0;
    flex: 1;
    min-width: 0;
}

.btn-sm {
    font-size: .8125rem;
    padding: .3rem .75rem;
}

.inbox-messages {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 1rem;
    padding-right: .25rem;
}

.inbox-message {
    background: #0f172a;
    border: 1px solid #273447;
    border-radius: 6px;
    padding: .75rem .875rem;
}

.inbox-message-time {
    font-size: .75rem;
    color: #475569;
    display: block;
    margin-bottom: .35rem;
}

.inbox-message-body {
    color: #cbd5e1;
    font-size: .875rem;
    margin: 0;
    word-break: break-word;
}

.inbox-message-body p,
.inbox-message-body ul,
.inbox-message-body ol { margin: .25rem 0; }
.inbox-message-body ul,
.inbox-message-body ol { margin-left: 1rem; }
.inbox-message-body p:first-child { margin-top: 0; }
.inbox-message-body p:last-child  { margin-bottom: 0; }

.inbox-delete-btn {
    margin-left: auto;
    padding: .2rem .45rem;
    line-height: 1;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    color: #ef4444;
    border-color: #7f1d1d;
}

.inbox-delete-btn:hover { border-color: #ef4444; background: rgba(239,68,68,.1); color: #f87171; }

/* ── Knowledge Base ─────────────────────────────────────────────────────────── */

.kb-delete-scope-btn {
    color: #ef4444;
    border-color: #7f1d1d;
}

.kb-delete-scope-btn:hover { border-color: #ef4444; background: rgba(239,68,68,.1); color: #f87171; }

.kb-sub-header {
    margin-top: 1.75rem;
    flex-wrap: wrap;
    gap: .75rem;
}

.kb-breadcrumb {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.kb-search-wrap {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-left: auto;
}

.kb-search-wrap input {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 7px;
    color: #f1f5f9;
    padding: .4rem .75rem;
    font-size: .875rem;
    width: 260px;
    outline: none;
}

.kb-search-wrap input:focus { border-color: #3b82f6; }

.kb-preview {
    color: #94a3b8;
    font-size: .8rem;
    margin-top: .25rem;
    line-height: 1.4;
}

.kb-date {
    color: #64748b;
    font-size: .78rem;
    margin-left: .5rem;
}

.kb-keywords-row {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin-bottom: .75rem;
}

.kb-keywords-inline {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin-top: .3rem;
}

.kb-result-group-label {
    color: #64748b;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: .4rem 0 .2rem;
}

.kb-summary-body {
    max-height: 60vh;
    overflow-y: auto;
    margin-top: .5rem;
    padding: .75rem;
    background: #0f172a;
    border-radius: 8px;
    border: 1px solid #334155;
    font-size: .9rem;
    line-height: 1.6;
}

#kb-add-modal .modal-card {
    width: min(760px, 95vw);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

#kb-add-modal .modal-card form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

#kb-add-modal .kb-add-fields {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

#kb-add-modal .rich-editor-wrap .ql-editor {
    min-height: 300px;
    max-height: 400px;
    overflow-y: auto;
}
