:root {
    --bg: #0f1117;
    --bg-surface: #1a1d27;
    --bg-card: #232734;
    --bg-hover: #2a2f3e;
    --border: #2e3348;
    --text: #e1e4ed;
    --text-muted: #8b8fa3;
    --accent: #6c5ce7;
    --accent-hover: #7d6ff0;
    --green: #00b894;
    --orange: #fdcb6e;
    --red: #e17055;
    --blue: #74b9ff;
    --purple: #a29bfe;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-brand {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    height: 46px;
    width: auto;
}

.sidebar-brand-text {
    font-family: 'Inter', sans-serif;
    font-size: 2.4rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.5px;
}

.login-logo-img {
    height: 72px;
    width: auto;
}

.org-switcher {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}
.org-switcher-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 6px;
    padding-left: 2px;
}
.org-switcher-control {
    position: relative;
}
.org-switcher select {
    width: 100%;
    padding: 8px 32px 8px 10px;
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    line-height: 1.4;
}
.org-switcher select:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
}
.org-switcher select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(108, 92, 231, 0.2);
}
.org-switcher select option {
    background: var(--bg-card);
    color: var(--text);
    padding: 8px 10px;
    font-size: 0.85rem;
}
.org-switcher-chevron {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    stroke: var(--text-muted);
    pointer-events: none;
}
.org-badge {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.org-badge-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}
.org-badge-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
}

.sidebar-nav {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.sidebar-nav a, .sidebar-nav button {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius);
    transition: all 0.15s;
    font-size: 0.9rem;
    border: none;
    background: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
}

.sidebar-nav a:hover, .sidebar-nav button:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.sidebar-nav a.active {
    background: var(--accent);
    color: white;
}

.sidebar-nav a.active .nav-icon {
    stroke: white;
}

/* Nav icons */
.nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke: var(--text-muted);
    transition: stroke 0.15s;
}

.sidebar-nav a:hover .nav-icon,
.sidebar-nav button:hover .nav-icon {
    stroke: var(--text);
}

/* Nav groups */
.nav-group {
    margin-top: 4px;
}

.nav-group-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius);
    transition: all 0.15s;
    font-size: 0.9rem;
    border: none;
    background: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
}

.nav-group-toggle:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.nav-group-label {
    flex: 1;
    font-weight: 500;
    letter-spacing: 0.01em;
}

.nav-group-chevron {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    stroke: var(--text-muted);
    transition: transform 0.2s ease;
}

.nav-group-toggle.collapsed .nav-group-chevron {
    transform: rotate(-90deg);
}

.nav-group-items {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding-left: 8px;
}

.nav-group-items a {
    font-size: 0.85rem;
    padding: 8px 12px;
}

.nav-group-items .nav-icon {
    width: 16px;
    height: 16px;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
}

.sidebar-user {
    padding: 0 4px;
    font-size: 0.85rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 24px 32px;
    min-height: 100vh;
    min-width: 0;
    overflow-x: hidden;
}

/* Page header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.page-header > .flex {
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.15s;
    text-decoration: none;
}

.btn:hover { background: var(--bg-hover); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--red); border-color: var(--red); color: white; }
.btn-danger:hover { opacity: 0.9; }
.btn-success { background: var(--green); border-color: var(--green); color: white; }
.btn-success:hover { opacity: 0.9; }
.btn-sm { padding: 5px 10px; font-size: 0.8rem; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--bg-hover); }
.btn-ghost-active { background: var(--bg-hover); border-color: var(--border); color: var(--text); }

/* Cards */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
}

.tab {
    padding: 8px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 0.95rem;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.tab:hover {
    color: var(--text);
}

.tab-active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

/* Tables */
.table-wrap {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 12px 16px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

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

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-card); }

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 500;
}

.form-group label .required {
    color: var(--red);
}

.form-group.field-invalid input,
.form-group.field-invalid select,
.form-group.field-invalid textarea {
    border-color: var(--red);
}

.field-error {
    display: block;
    color: var(--red);
    font-size: 0.8rem;
    margin-top: 4px;
}

.checkbox-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px;
}

.checkbox-item {
    display: flex !important;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

.checkbox-item:hover { background: var(--hover); }

.checkbox-item input[type="checkbox"] {
    width: auto;
    margin: 0;
}

input[type="text"], input[type="password"], input[type="email"],
input[type="number"], input[type="date"], textarea, select {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
    transition: border-color 0.15s;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
}

textarea { resize: vertical; min-height: 80px; }

select {
    cursor: pointer;
    appearance: auto;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-task { background: rgba(116,185,255,0.15); color: var(--blue); }
.badge-bug { background: rgba(225,112,85,0.15); color: var(--red); }
.badge-story { background: rgba(108,92,231,0.15); color: var(--accent); }
.badge-active { background: rgba(0,184,148,0.15); color: var(--green); }
.badge-inactive { background: rgba(139,143,163,0.15); color: var(--text-muted); }
.badge-agent { background: rgba(253,203,110,0.15); color: var(--orange); }

/* Status badges */
.status { padding: 3px 10px; border-radius: 12px; font-size: 0.8rem; font-weight: 500; }
.status-backlog { background: rgba(139,143,163,0.1); color: var(--text-muted); }
.status-todo { background: rgba(139,143,163,0.15); color: var(--text-muted); }
.status-inprogress { background: rgba(116,185,255,0.15); color: var(--blue); }
.status-done { background: rgba(0,184,148,0.15); color: var(--green); }
.status-blocked { background: rgba(225,112,85,0.15); color: var(--red); }
.status-archived { background: rgba(139,143,163,0.08); color: #636880; }

/* Conversation status pills */
.conv-status { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.03em; }
.conv-status-waiting { background: rgba(253,203,110,0.15); color: var(--orange); }
.conv-status-agent { background: rgba(116,185,255,0.15); color: var(--blue); }
.conv-status-resolved { background: rgba(0,184,148,0.15); color: var(--green); }

/* Board */
.board {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 16px;
    min-height: calc(100vh - 140px);
}

.board-column {
    min-width: 300px;
    width: 300px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
}

.board-column-header {
    padding: 14px 16px;
    font-weight: 600;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.board-column-count {
    background: var(--bg-card);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.board-column-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.board-column-dot.status-backlog { background: #636880; }
.board-column-dot.status-todo { background: var(--text-muted); }
.board-column-dot.status-inprogress { background: var(--blue); }
.board-column-dot.status-done { background: var(--green); }
.board-column-dot.status-blocked { background: var(--red); }
.board-column-dot.status-archived { background: #4a4e5e; }

.board-column-body {
    flex: 1;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
}

.board-column-empty {
    text-align: center;
    padding: 24px 12px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-style: italic;
}

/* Board grouping */
.board-group {
    margin-bottom: 4px;
}

.board-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px;
    margin-bottom: 4px;
    border-radius: 4px;
    background: var(--bg-hover);
    border-left: 3px solid var(--accent);
}

.board-group-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.board-group-count {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--bg-surface);
    padding: 1px 6px;
    border-radius: 8px;
}

.group-by-select {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.8rem;
    cursor: pointer;
}

.group-by-select:hover {
    border-color: var(--accent);
}

.light-mode .group-by-select {
    background: #fff;
    border-color: #d0d5dd;
    color: #1a1a2e;
}

.ticket-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    cursor: grab;
    transition: all 0.15s;
    position: relative;
}

.ticket-card:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.ticket-card:active {
    cursor: grabbing;
}

.ticket-card-dragging {
    opacity: 0.4;
    border-color: var(--accent);
}

.ticket-card-drop-target {
    border-color: var(--accent);
    border-style: dashed;
    border-width: 2px;
    background: rgba(108,92,231,0.08);
}

.board-column-drop-target {
    background: rgba(108,92,231,0.04);
    outline: 2px dashed var(--accent);
    outline-offset: -2px;
}

.ticket-card-title {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 8px;
    line-height: 1.3;
}

.ticket-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.ticket-card-priority {
    font-weight: 600;
    color: var(--text-muted);
}

.ticket-card-age {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 3px;
    letter-spacing: 0.02em;
}

.age-fresh {
    color: var(--text-muted);
    background: transparent;
}

.age-warn {
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.12);
}

.age-stale {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.12);
}

.light-mode .age-warn {
    color: #d97706;
    background: rgba(217, 119, 6, 0.1);
}

.light-mode .age-stale {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.1);
}

.ticket-card-subs {
    color: var(--text-muted);
}

.ticket-card-estimate {
    background: var(--accent);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 8px;
    white-space: nowrap;
}

.board-column-points {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
}

.ticket-card-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    color: white;
    font-weight: 600;
}

.ticket-card-avatar-empty {
    background: var(--bg-hover);
    color: var(--text-muted);
}

/* Modal */
.modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    z-index: 1001;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

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

/* Description Editor */
.description-editor {
    margin-bottom: 16px;
}

.description-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.description-editor-header label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0;
}

.description-editor-tabs {
    display: inline-flex;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.description-tab {
    padding: 2px 12px;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.description-tab:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.description-tab.active {
    color: var(--text);
    background: var(--bg-card);
    font-weight: 600;
}

.description-preview {
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
    line-height: 1.6;
    min-height: 60px;
    overflow-y: auto;
}

.description-expanded-preview {
    flex: 1;
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.95rem;
    line-height: 1.6;
    overflow-y: auto;
}

.description-expand-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 2px 8px;
}

.description-expand-btn:hover {
    color: var(--accent);
}

.description-expanded-backdrop {
    z-index: 1100;
}

.description-expanded-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    width: 90%;
    max-width: 900px;
    height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    z-index: 1101;
}

.description-expanded-textarea {
    flex: 1;
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
    line-height: 1.6;
    resize: none;
}

.description-expanded-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

/* Login page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: var(--bg);
}

.login-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 4px;
}

.login-card h1 {
    font-size: 1.8rem;
    margin-bottom: 0;
    color: var(--accent);
    font-weight: 700;
    letter-spacing: -0.5px;
}

.login-subtitle {
    color: var(--text-muted);
    margin-bottom: 4px !important;
    font-size: 0.78rem !important;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.login-card p {
    color: var(--text-muted);
    margin-bottom: 28px;
    font-size: 0.9rem;
}

.login-card .form-group {
    margin-bottom: 20px;
}

.login-card input[type="text"],
.login-card input[type="password"] {
    padding: 12px 14px;
    font-size: 0.95rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    color: var(--text);
    transition: border-color 0.15s;
}

.login-card input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(108,92,231,0.15);
}

.login-card .btn {
    padding: 12px 16px;
    font-size: 0.95rem;
    margin-top: 8px;
}

.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 16px;
}

.alert-error {
    background: rgba(225,112,85,0.15);
    color: var(--red);
    border: 1px solid rgba(225,112,85,0.3);
}

.alert-success {
    background: rgba(0,184,148,0.15);
    color: var(--green);
    border: 1px solid rgba(0,184,148,0.3);
}

.alert-warning {
    background: rgba(253,203,110,0.12);
    color: var(--orange);
    border: 1px solid rgba(253,203,110,0.25);
}

.alert-info {
    background: rgba(116,185,255,0.12);
    color: var(--blue);
    border: 1px solid rgba(116,185,255,0.25);
}

/* Two-Factor Auth */
.tfa-container {
    max-width: 560px;
}

.tfa-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
}

.tfa-card + .tfa-card {
    margin-top: 16px;
}

.tfa-card h3 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.tfa-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 20px;
    line-height: 1.5;
}

.tfa-card ul {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0 0 20px 20px;
    line-height: 1.8;
}

.tfa-status-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 10px 20px;
    margin: 20px 0;
    font-size: 0.9rem;
}

.tfa-status-label {
    color: var(--text-muted);
}

.tfa-status-value-active {
    color: var(--green);
    font-weight: 500;
}

.tfa-status-value-warn {
    color: var(--red);
    font-weight: 500;
}

.tfa-qr-wrap {
    display: flex;
    justify-content: center;
    margin: 24px 0;
}

.tfa-qr-wrap img {
    width: 220px;
    height: 220px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.tfa-manual-key {
    display: block;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 14px 16px;
    border-radius: var(--radius);
    font-size: 1rem;
    letter-spacing: 3px;
    word-break: break-all;
    text-align: center;
    color: var(--text);
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    margin-bottom: 24px;
}

.tfa-code-input {
    max-width: 220px;
    font-size: 1.3em !important;
    letter-spacing: 6px;
    text-align: center;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* 2FA login verification page inputs */
.tfa-login-code {
    width: 100%;
    font-size: 1.8rem !important;
    letter-spacing: 12px;
    text-align: center;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    padding: 16px 14px !important;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
}

.tfa-login-code:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(108,92,231,0.15);
}

.tfa-login-code::placeholder {
    letter-spacing: 12px;
    color: var(--text-muted);
    opacity: 0.4;
}

.tfa-login-recovery {
    width: 100%;
    font-size: 1.4rem !important;
    letter-spacing: 3px;
    text-align: center;
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    padding: 16px 14px !important;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    text-transform: uppercase;
}

.tfa-login-recovery:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(108,92,231,0.15);
}

.tfa-login-recovery::placeholder {
    letter-spacing: 3px;
    color: var(--text-muted);
    opacity: 0.4;
    text-transform: uppercase;
}

.tfa-login-toggle {
    margin-top: 20px;
    text-align: center;
}

.tfa-login-toggle a {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-decoration: none;
    transition: color 0.15s;
}

.tfa-login-toggle a:hover {
    color: var(--accent);
}

.tfa-recovery-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 20px;
    border-radius: var(--radius);
    margin: 16px 0 20px;
}

.tfa-recovery-grid code {
    font-size: 0.95rem;
    letter-spacing: 1.5px;
    color: var(--text);
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    padding: 6px 0;
}

.tfa-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.tfa-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text-muted);
    cursor: pointer;
    margin-bottom: 20px;
}

.tfa-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

.tfa-step-hint {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 16px;
}

.tfa-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

/* Profile Page */
.profile-layout {
    max-width: 640px;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.profile-section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.profile-section-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.profile-section-icon {
    width: 20px;
    height: 20px;
    color: var(--accent);
    flex-shrink: 0;
}

.profile-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
}

.profile-field {
    margin-bottom: 16px;
}

.profile-field:last-of-type {
    margin-bottom: 0;
}

.profile-field label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 4px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-field-value {
    font-size: 0.95rem;
    padding: 8px 0;
}

.profile-field-value.readonly {
    color: var(--text-muted);
}

.profile-field-value.muted {
    color: var(--text-muted);
    font-style: italic;
}

.profile-field input {
    width: 100%;
    max-width: 360px;
}

.profile-actions {
    display: flex;
    gap: 8px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.profile-2fa-status {
    margin-bottom: 16px;
}

.profile-2fa-status p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 12px;
    line-height: 1.5;
}

.profile-2fa-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.profile-2fa-badge.enabled {
    background: rgba(0,184,148,0.12);
    color: var(--green);
    border: 1px solid rgba(0,184,148,0.25);
}

.profile-2fa-badge.disabled {
    background: rgba(225,112,85,0.12);
    color: var(--red);
    border: 1px solid rgba(225,112,85,0.25);
}

.profile-2fa-action-card {
    margin-top: 16px;
    padding: 20px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.profile-2fa-action-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.profile-2fa-action-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 16px;
    line-height: 1.5;
}

.badge-role {
    background: rgba(108,92,231,0.12);
    color: var(--accent);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid rgba(108,92,231,0.25);
}

/* Sidebar user link */
.sidebar-user-link {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text);
    padding: 4px 0;
    transition: color 0.15s;
}

.sidebar-user-link:hover {
    color: var(--accent);
}

.sidebar-user-avatar {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
}

.sidebar-user-link:hover .sidebar-user-avatar {
    opacity: 1;
    color: var(--accent);
}

/* Comments */
.comment {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.comment:last-child { border-bottom: none; }

.comment-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.comment-author { font-weight: 600; }
.comment-date { color: var(--text-muted); font-size: 0.8rem; }
.comment-body { font-size: 0.9rem; line-height: 1.5; }

/* Ticket detail */
.ticket-detail {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 24px;
}

.ticket-detail-main { min-width: 0; }

.ticket-detail-sidebar .card {
    margin-bottom: 16px;
}

/* Ticket detail tabs */
.ticket-tabs {
    display: flex;
    gap: 2px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.ticket-tabs::-webkit-scrollbar { display: none; }

.ticket-tab {
    padding: 10px 18px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ticket-tab:hover {
    color: var(--text);
}

.ticket-tab-active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.ticket-tab-badge {
    font-size: 0.75rem;
    padding: 1px 7px;
    border-radius: 10px;
    background: var(--bg-surface);
    color: var(--text-muted);
    font-weight: 600;
}

.ticket-tab-active .ticket-tab-badge {
    background: rgba(108, 92, 231, 0.15);
    color: var(--accent);
}

.ticket-tab-content {
    min-height: 300px;
}

/* Activity log items inside ticket detail */
.ticket-activity-item {
    display: flex;
    gap: 8px;
    align-items: baseline;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}
.ticket-activity-item:last-child { border-bottom: none; }
.ticket-activity-user { font-weight: 600; white-space: nowrap; }
.ticket-activity-desc { color: var(--text-muted); flex: 1; }
.ticket-activity-time { color: var(--text-muted); white-space: nowrap; font-size: 0.8rem; }

.detail-field {
    margin-bottom: 16px;
}

.detail-field label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
    display: block;
}

.detail-field-value {
    font-size: 0.9rem;
}

/* Sub-tickets */
.subticket-list {
    margin-top: 16px;
}

.subticket-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.subticket-item:hover { background: var(--bg-card); }

/* Utility */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.w-full { width: 100%; }
.hidden { display: none; }

/* Project grid */
.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.project-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: all 0.15s;
}

.project-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.project-card h3 {
    font-size: 1.1rem;
    margin-bottom: 6px;
}

.project-card p {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 12px;
}

.project-card-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 12px;
}

.project-card-stats .status {
    font-size: 0.7rem;
    padding: 2px 8px;
}

.project-card-footer {
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.project-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.project-card-header h3 {
    flex: 1;
    min-width: 0;
}

.btn-favorite {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius);
    color: var(--text-muted);
    transition: all 0.15s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.btn-favorite:hover {
    color: #f5a623;
    background: rgba(245, 166, 35, 0.1);
}

.btn-favorite.active {
    color: #f5a623;
}

.btn-favorite.active:hover {
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
}

.favorites-separator {
    border: none;
    border-top: 1px solid var(--border);
    margin: 24px 0 8px 0;
}

.section-heading {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 0 0 12px 0;
}

.section-heading-collapsible {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

.section-heading-collapsible:hover {
    color: var(--text);
}

.section-heading-count {
    font-weight: 400;
    font-size: 0.8rem;
}

.collapse-chevron {
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.collapse-chevron.collapsed {
    transform: rotate(-90deg);
}

.table-section-row td {
    padding: 12px 8px;
    border-bottom: 1px solid var(--border);
}

.table-section-row:hover td {
    background: var(--bg-hover);
}

/* View toggle */
.view-toggle {
    display: flex;
    gap: 2px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2px;
}

.view-toggle .btn {
    padding: 4px 8px;
    min-width: unset;
}


/* Loading */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-muted);
}

/* Copy button for API keys */
.key-display {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    font-family: 'Cascadia Code', 'Fira Code', monospace;
    font-size: 0.85rem;
    word-break: break-all;
    margin: 12px 0;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Sidebar logout */
.sidebar-footer > button {
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.15s;
}

.sidebar-footer > button:hover {
    background: rgba(225,112,85,0.1);
    border-color: var(--red);
    color: var(--red);
}

/* Confirmation button pulse */
.btn-danger:active {
    transform: scale(0.98);
}

/* Labels */
.label-chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    border: 1px solid transparent;
    background: rgba(139,143,163,0.15);
    color: var(--text-muted);
    white-space: nowrap;
}

.ticket-card-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}

.ticket-labels-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 4px;
}

/* Board filters */
.board-filters {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    padding: 12px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.filter-chip:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.filter-chip-active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.filter-chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Label picker */
.label-picker {
    margin-top: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px 0;
}

.label-picker-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s;
    color: var(--text) !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    font-weight: normal !important;
}

.label-picker-item:hover {
    background: var(--bg-hover);
}

.label-picker-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.label-picker-create {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-top: 1px solid var(--border);
}

.label-picker-input {
    flex: 1;
    padding: 4px 8px !important;
    font-size: 0.85rem !important;
    min-width: 0;
}

.label-picker-color {
    width: 28px !important;
    height: 28px;
    padding: 0 !important;
    border: 1px solid var(--border) !important;
    border-radius: 4px;
    cursor: pointer;
    background: transparent;
}

/* Markdown content */
.markdown-content p { margin-bottom: 8px; }
.markdown-content p:last-child { margin-bottom: 0; }
.markdown-content h2, .markdown-content h3, .markdown-content h4 { margin-top: 12px; }

.markdown-content code {
    background: var(--bg-card);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
    font-family: 'Cascadia Code', 'Fira Code', monospace;
}

.markdown-content pre {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    overflow-x: auto;
    margin: 8px 0;
}

.markdown-content pre code {
    background: transparent;
    padding: 0;
    font-size: 0.85rem;
}

.markdown-content strong { font-weight: 700; }
.markdown-content em { font-style: italic; }
.markdown-content del { text-decoration: line-through; color: var(--text-muted); }

.markdown-content ul {
    margin: 4px 0;
    padding-left: 20px;
}

.markdown-content li {
    margin-bottom: 2px;
}

.markdown-content a {
    color: var(--accent);
    text-decoration: none;
}

.markdown-content a:hover {
    text-decoration: underline;
}

/* Board search */
.board-search-input {
    width: 200px;
    padding: 6px 12px !important;
    font-size: 0.85rem !important;
}

/* Bulk action bar */
.bulk-action-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    margin-bottom: 12px;
    font-size: 0.85rem;
}

.bulk-action-count {
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
}

.bulk-action-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.bulk-select {
    width: auto !important;
    min-width: 140px;
    padding: 6px 10px !important;
    font-size: 0.85rem !important;
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    color: var(--text) !important;
    border-radius: var(--radius);
}

.bulk-select option {
    background: var(--bg-card);
    color: var(--text);
}

/* Ticket card top row */
.ticket-card-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

/* Ticket card selection checkbox */
.ticket-card-check {
    width: 18px;
    height: 18px;
    min-width: 18px;
    border-radius: 4px;
    border: 1.5px solid var(--text-muted);
    background: transparent;
    color: white;
    font-size: 0.65rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.5;
    transition: opacity 0.15s, background 0.15s, border-color 0.15s;
    padding: 0;
    line-height: 1;
}

.ticket-card:hover .ticket-card-check {
    opacity: 0.8;
}

.ticket-card-check:hover {
    border-color: var(--accent);
    opacity: 1 !important;
}

.ticket-card-check.checked {
    background: var(--accent);
    border-color: var(--accent);
    opacity: 1;
}

.ticket-card-selected {
    border-color: var(--accent) !important;
    background: rgba(108,92,231,0.06);
}

/* Column select-all checkbox */
.column-select-all {
    width: 18px;
    height: 18px;
    min-width: 18px;
    border-radius: 4px;
    border: 1.5px solid var(--text-muted);
    background: transparent;
    color: white;
    font-size: 0.65rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    transition: opacity 0.15s, background 0.15s, border-color 0.15s;
    padding: 0;
    line-height: 1;
}

.column-select-all:hover {
    border-color: var(--accent);
    opacity: 1;
}

.column-select-all.checked {
    background: var(--accent);
    border-color: var(--accent);
    opacity: 1;
}

/* Board column collapsed */
.board-column-collapsed {
    min-width: 48px !important;
    width: 48px !important;
    cursor: pointer;
}

.board-column-collapsed .board-column-header {
    writing-mode: vertical-lr;
    text-orientation: mixed;
    padding: 16px 8px;
    justify-content: center;
    gap: 8px;
}

/* Ticket card blocked indicator */
.ticket-card-blocked {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    background: rgba(225,112,85,0.15);
    color: var(--red);
    margin-bottom: 6px;
}

/* Ticket card due date */
.ticket-card-due {
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 0.7rem;
    font-weight: 500;
}

.due-overdue {
    background: rgba(225,112,85,0.15);
    color: var(--red);
}

.due-soon {
    background: rgba(253,203,110,0.15);
    color: var(--orange);
}

.due-normal {
    background: rgba(139,143,163,0.1);
    color: var(--text-muted);
}

/* Mention chip */
.mention-chip {
    display: inline;
    padding: 1px 6px;
    border-radius: 8px;
    background: rgba(108,92,231,0.15);
    color: var(--accent);
    font-weight: 600;
    font-size: 0.85em;
}

/* Status Timeline */
.status-timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
    position: relative;
    padding-left: 16px;
}

.status-timeline-entry {
    display: flex;
    gap: 12px;
    position: relative;
    padding-bottom: 16px;
}

.status-timeline-entry:last-child { padding-bottom: 0; }

.status-timeline-entry::before {
    content: '';
    position: absolute;
    left: 5px;
    top: 12px;
    bottom: -4px;
    width: 2px;
    background: var(--border);
}

.status-timeline-entry:last-child::before { display: none; }

.status-timeline-dot {
    width: 12px;
    height: 12px;
    min-width: 12px;
    border-radius: 50%;
    margin-top: 4px;
    background: var(--accent);
    z-index: 1;
}

.status-timeline-dot.status-done { background: var(--green); }
.status-timeline-dot.status-inprogress { background: var(--blue); }
.status-timeline-dot.status-blocked { background: var(--red); }
.status-timeline-dot.status-todo { background: var(--orange); }
.status-timeline-dot.status-backlog { background: var(--text-muted); }
.status-timeline-dot.status-archived { background: var(--text-muted); }

.status-timeline-content {
    flex: 1;
}

.status-timeline-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-timeline-duration {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.status-timeline-current {
    color: var(--accent);
    font-weight: 600;
}

/* Light mode override (default is dark) */
body.light-mode {
    --bg: #f5f6fa;
    --bg-surface: #ffffff;
    --bg-card: #f0f1f5;
    --bg-hover: #e8e9ef;
    --border: #d1d5db;
    --text: #1f2937;
    --text-muted: #6b7280;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

body.light-mode ::-webkit-scrollbar-thumb { background: #c0c4cc; }
body.light-mode ::-webkit-scrollbar-thumb:hover { background: #9ca0a8; }

body.light-mode .org-switcher select {
    background: #fff;
    border-color: #d0d5dd;
    color: #1f2937;
}
body.light-mode .org-switcher select:hover {
    background: #f9fafb;
}
body.light-mode .org-switcher select option {
    background: #fff;
    color: #1f2937;
}

/* Webhooks */
.webhook-event-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.webhook-event-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--text) !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    font-weight: normal !important;
}

.webhook-event-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.webhook-filter-list {
    max-height: 200px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px 0;
}

.webhook-delivery {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.webhook-delivery:last-child { border-bottom: none; }

.delivery-success { border-left: 3px solid var(--green); }
.delivery-fail { border-left: 3px solid var(--red); }

.webhook-events-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.webhook-event-row {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px 8px;
}

.webhook-status-filter {
    padding: 8px 8px 8px 32px;
}

.webhook-status-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.status-chip {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 12px;
    font-size: 0.78rem;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s;
}

.status-chip:hover {
    border-color: var(--accent);
}

.status-chip-active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Timezone searchable dropdown */
.tz-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 300px;
    max-height: 240px;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 100;
    margin-top: 2px;
}

.tz-dropdown-item {
    padding: 6px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--text);
}

.tz-dropdown-item:hover {
    background: var(--bg-hover);
}

.tz-dropdown-selected {
    background: rgba(108,92,231,0.15);
    color: var(--accent);
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    max-width: 400px;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 0.85rem;
    line-height: 1.4;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: auto;
}

.toast-message {
    flex: 1;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
    opacity: 0.6;
    transition: opacity 0.15s ease;
}

.toast-close:hover {
    opacity: 1;
    color: var(--text);
}

.toast-show {
    opacity: 1;
    transform: translateX(0);
}

.toast-hide {
    opacity: 0;
    transform: translateX(40px);
}

.toast-status {
    border-left: 3px solid var(--accent);
}

.toast-info {
    border-left: 3px solid var(--blue);
}

.toast-assign {
    border-left: 3px solid var(--orange);
}

.toast-comment {
    border-left: 3px solid var(--green);
}

body.light-mode .toast {
    background: #fff;
    border-color: #e0e0e0;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

/* Notification Bell */
.sidebar-footer-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.sidebar-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    position: relative;
}

/* Theme Toggle */
.theme-toggle-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.theme-toggle-btn:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.btn.theme-toggle-btn {
    padding: 5px 8px;
}

/* Dark mode (default): show sun icon */
.theme-icon-sun { display: inline-block; }
.theme-icon-moon { display: none; }

/* Light mode: show moon icon */
body.light-mode .theme-icon-sun { display: none; }
body.light-mode .theme-icon-moon { display: inline-block; }

.notification-bell-icon {
    position: relative;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.notification-bell-icon:hover {
    background: var(--bg-hover);
    color: var(--text);
}

.notification-badge {
    position: absolute;
    top: 0;
    right: -2px;
    background: var(--red);
    color: white;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 10px;
    min-width: 14px;
    text-align: center;
    line-height: 1.3;
    pointer-events: none;
}

.notification-overlay {
    position: fixed;
    inset: 0;
    z-index: 199;
}

.notification-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 340px;
    max-height: 480px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 -4px 24px rgba(0,0,0,0.4);
    z-index: 200;
    margin-bottom: 4px;
    display: flex;
    flex-direction: column;
}

.notification-dropdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.9rem;
}

.notification-dropdown-header .btn-link {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0;
}

.notification-dropdown-header .btn-link:hover {
    text-decoration: underline;
}

.notification-list {
    overflow-y: auto;
    max-height: 400px;
}

.notification-item {
    display: flex;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border);
}

.notification-item:last-child { border-bottom: none; }
.notification-item:hover { background: var(--bg-hover); }
.notification-item.unread { background: rgba(108,92,231,0.06); }

.notification-type-icon {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    margin-top: 2px;
}

.notif-assigned { background: rgba(253,203,110,0.15); color: var(--orange); }
.notif-status { background: rgba(116,185,255,0.15); color: var(--blue); }
.notif-commented { background: rgba(0,184,148,0.15); color: var(--green); }
.notif-mentioned { background: rgba(108,92,231,0.15); color: var(--accent); }
.notif-other { background: rgba(139,143,163,0.15); color: var(--text-muted); }

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

.notification-title {
    font-size: 0.85rem;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.notification-message {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notification-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.notification-loading, .notification-empty {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Activity Feed Page */
.activity-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.activity-feed {
    display: flex;
    flex-direction: column;
}

.activity-date-header {
    padding: 12px 0 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.activity-item {
    display: flex;
    gap: 12px;
    padding: 12px 8px;
    border-bottom: 1px solid rgba(46,51,72,0.5);
    transition: background 0.15s;
}

.activity-item:hover { background: var(--bg-card); border-radius: var(--radius); }

.activity-icon {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    margin-top: 2px;
}

.action-created { background: rgba(0,184,148,0.15); color: var(--green); }
.action-status { background: rgba(116,185,255,0.15); color: var(--blue); }
.action-assigned { background: rgba(253,203,110,0.15); color: var(--orange); }
.action-commented { background: rgba(108,92,231,0.15); color: var(--accent); }
.action-other { background: rgba(139,143,163,0.15); color: var(--text-muted); }

.activity-content {
    flex: 1;
    min-width: 0;
}

.activity-main {
    font-size: 0.9rem;
    line-height: 1.4;
}

.activity-actor {
    font-weight: 600;
}

.activity-verb {
    color: var(--text-muted);
}

.activity-ticket-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.activity-ticket-link:hover { text-decoration: underline; }

.activity-detail {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 4px;
    font-size: 0.85rem;
}

.activity-old-value {
    color: var(--text-muted);
    text-decoration: line-through;
}

.activity-new-value {
    color: var(--green);
    font-weight: 500;
}

.activity-meta {
    display: flex;
    gap: 12px;
    margin-top: 2px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.activity-project {
    font-weight: 500;
}

/* Project Settings */
.project-settings-form {
    max-width: 600px;
}

.project-settings-add-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.project-settings-inline-input {
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 4px 8px;
    color: var(--text);
    width: 100%;
    transition: border-color 0.15s;
}

.project-settings-inline-input:hover,
.project-settings-inline-input:focus {
    border-color: var(--border);
    background: var(--bg);
}

.project-settings-inline-select {
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius);
    padding: 4px 8px;
    color: var(--text);
    width: 100%;
    transition: border-color 0.15s;
}

.project-settings-inline-select:hover,
.project-settings-inline-select:focus {
    border-color: var(--border);
    background: var(--bg);
}

.project-settings-danger-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    gap: 24px;
}

.empty-state {
    text-align: center;
    padding: 24px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

.form-actions {
    display: flex;
    gap: 8px;
}

/* Responsive — small laptops */
@media (max-width: 1200px) {
    .main-content { padding: 16px 20px; }
    .page-header { gap: 8px; }
}

/* Responsive — tablets / small screens */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .ticket-detail { grid-template-columns: 1fr; }
    .board { min-height: auto; }
    .board-column { min-width: 260px; width: 260px; }
    .toast-container { left: 16px; right: 16px; max-width: unset; }
    .ticket-tab { padding: 8px 12px; font-size: 0.85rem; }
    .chat-page { margin: -16px; height: calc(100vh - 32px); }
}

/* Attachments */
.attachments-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.attachment-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    transition: border-color 0.15s;
}

.attachment-card:hover {
    border-color: var(--accent);
}

.attachment-preview {
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    overflow: hidden;
}

.attachment-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.attachment-icon-preview {
    background: var(--bg);
}

.attachment-file-icon {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.attachment-info {
    padding: 8px 10px;
}

.attachment-name {
    display: block;
    color: var(--accent);
    font-size: 0.85rem;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attachment-name:hover {
    text-decoration: underline;
}

.attachment-meta {
    display: flex;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.attachment-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    opacity: 0;
    background: rgba(0,0,0,0.6) !important;
    color: var(--red) !important;
    font-size: 0.75rem;
    padding: 2px 6px !important;
    border-radius: 4px;
    transition: opacity 0.15s;
}

.attachment-card:hover .attachment-delete {
    opacity: 1;
}

/* Drop zone */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
}

.drop-zone:hover,
.drop-zone-active {
    border-color: var(--accent);
    background: rgba(108, 92, 231, 0.05);
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.drop-zone-icon {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(108, 92, 231, 0.15);
    margin-bottom: 4px;
}

.btn-link {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    padding: 0;
    font-size: inherit;
    text-decoration: underline;
}

.btn-link:hover {
    color: var(--accent-hover);
}

.text-danger {
    color: var(--red);
}

/* Comment attachments */
.comment-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.comment-attachment-image {
    display: block;
    max-width: 300px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
}

.comment-attachment-image img {
    display: block;
    max-width: 100%;
    max-height: 200px;
    object-fit: contain;
}

.comment-attachment-file {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--accent);
    text-decoration: none;
    font-size: 0.85rem;
}

.comment-attachment-file:hover {
    border-color: var(--accent);
}

/* Checklist */
.checklist-progress-bar {
    height: 6px;
    background: var(--bg-surface);
    border-radius: 3px;
    overflow: hidden;
}

.checklist-progress-fill {
    height: 100%;
    background: var(--success, #27ae60);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 4px;
    border-bottom: 1px solid var(--border);
}

.checklist-item:last-of-type {
    border-bottom: none;
}

.checklist-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    cursor: pointer;
    font-size: 0.9rem;
}

.checklist-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--success, #27ae60);
    cursor: pointer;
    flex-shrink: 0;
}

.checklist-checked {
    text-decoration: line-through;
    color: var(--text-muted);
}

.checklist-delete {
    opacity: 0;
    color: var(--danger) !important;
    font-size: 0.75rem !important;
    padding: 0 4px !important;
    transition: opacity 0.15s;
}

.checklist-item:hover .checklist-delete {
    opacity: 1;
}

.checklist-add {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Time Tracking */
.time-entries-list {
    margin-bottom: 8px;
}

.time-entry-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 4px;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.time-entry-item:last-of-type {
    border-bottom: none;
}

.time-entry-main {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.time-entry-user {
    font-weight: 600;
    white-space: nowrap;
    font-size: 0.85rem;
}

.time-entry-desc {
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.time-entry-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.time-entry-duration {
    font-weight: 600;
    color: var(--accent);
    white-space: nowrap;
    font-size: 0.85rem;
}

.time-entry-date {
    color: var(--text-muted);
    font-size: 0.8rem;
    white-space: nowrap;
}

.time-entry-add {
    display: flex;
    gap: 8px;
    align-items: center;
}

.time-entry-item:hover .checklist-delete {
    opacity: 1;
}

/* Custom Fields */
.custom-field-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 4px;
    border-bottom: 1px solid var(--border);
}

.custom-field-item:last-of-type {
    border-bottom: none;
}

.custom-field-key {
    font-weight: 600;
    font-size: 0.85rem;
    min-width: 100px;
    color: var(--text-muted);
}

.custom-field-value-group {
    flex: 1;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.custom-field-value {
    font-size: 0.9rem;
    word-break: break-word;
}

.custom-field-copy {
    opacity: 0;
    font-size: 0.75rem !important;
    padding: 0 4px !important;
    transition: opacity 0.15s;
    color: var(--text-muted) !important;
    cursor: pointer;
    flex-shrink: 0;
}

.custom-field-item:hover .custom-field-copy {
    opacity: 1;
}

.custom-field-item:hover .checklist-delete {
    opacity: 1;
}

.custom-field-add {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Search Page */
.search-page {
    max-width: 900px;
    margin: 0 auto;
}

.search-bar {
    position: relative;
    margin-bottom: 16px;
}

.search-input {
    width: 100%;
    padding: 14px 44px 14px 16px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1.1rem;
    outline: none;
    transition: border-color 0.2s;
}

.search-input:focus {
    border-color: var(--accent);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px 8px;
    border-radius: 4px;
}

.search-clear:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.search-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-summary {
    padding: 8px 0 16px;
    font-size: 0.9rem;
}

.search-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.search-result-item {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
}

.search-result-item:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.search-result-type-badge {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.type-ticket {
    background: rgba(108, 92, 231, 0.2);
    color: var(--accent);
}

.type-comment {
    background: rgba(116, 185, 255, 0.2);
    color: var(--blue);
}

.search-result-content {
    flex: 1;
    min-width: 0;
}

.search-result-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.search-result-title {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-status {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    flex-shrink: 0;
}

.search-result-description {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-match {
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--bg-surface);
    padding: 6px 10px;
    border-radius: 4px;
    margin-bottom: 6px;
    line-height: 1.4;
}

.search-result-match mark {
    background: rgba(253, 203, 110, 0.3);
    color: var(--orange);
    padding: 1px 2px;
    border-radius: 2px;
}

.search-result-meta {
    display: flex;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.search-result-project {
    color: var(--accent);
    font-weight: 500;
}

.search-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.search-empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

/* Status badge colors for search */
.status-done { background: rgba(0, 184, 148, 0.15); color: var(--green); }
.status-inprogress { background: rgba(116, 185, 255, 0.15); color: var(--blue); }
.status-blocked { background: rgba(225, 112, 85, 0.15); color: var(--red); }
.status-archived { background: rgba(139, 143, 163, 0.15); color: var(--text-muted); }
.status-default { background: rgba(108, 92, 231, 0.15); color: var(--accent); }

/* Light mode overrides for search */
body.light-mode .search-result-match mark {
    background: rgba(253, 203, 110, 0.5);
    color: #7d5a00;
}

/* Command Palette */
.cmd-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
    z-index: 2000;
    backdrop-filter: blur(2px);
}

.cmd-palette {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 16px 64px rgba(0,0,0,0.5);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 60vh;
}

.cmd-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.cmd-search-icon {
    color: var(--text-muted);
    font-size: 1rem;
    flex-shrink: 0;
}

.cmd-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 1rem;
    outline: none;
    padding: 0;
    min-width: 0;
}

.cmd-input::placeholder {
    color: var(--text-muted);
}

.cmd-esc {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    flex-shrink: 0;
}

.cmd-results {
    flex: 1;
    overflow-y: auto;
    padding: 6px 0;
}

.cmd-section-label {
    padding: 8px 16px 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.cmd-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.1s;
}

.cmd-item:hover,
.cmd-item-selected {
    background: var(--bg-hover);
}

.cmd-item-icon {
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    background: var(--bg-card);
    color: var(--text-muted);
}

.cmd-type-task { background: rgba(116,185,255,0.15); color: var(--blue); }
.cmd-type-bug { background: rgba(225,112,85,0.15); color: var(--red); }
.cmd-type-story { background: rgba(108,92,231,0.15); color: var(--accent); }

.cmd-item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cmd-item-label {
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cmd-item-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-left: auto;
    flex-shrink: 0;
    padding-left: 12px;
}

.cmd-item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.cmd-item-meta .status {
    font-size: 0.7rem;
    padding: 1px 6px;
}

.cmd-item-project {
    color: var(--accent);
    font-weight: 500;
}

.cmd-empty {
    padding: 24px 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.cmd-footer {
    display: flex;
    gap: 16px;
    padding: 8px 16px;
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.cmd-footer kbd {
    font-size: 0.65rem;
    padding: 1px 4px;
    border-radius: 3px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    margin-right: 2px;
}

/* WIP Limits */
.board-column-header.wip-at {
    border-bottom: 2px solid var(--orange);
}

.board-column-header.wip-over {
    border-bottom: 2px solid var(--red);
    background: rgba(225,112,85,0.06);
}

.wip-count-at {
    background: rgba(253,203,110,0.2) !important;
    color: var(--orange) !important;
    font-weight: 700;
}

.wip-count-over {
    background: rgba(225,112,85,0.2) !important;
    color: var(--red) !important;
    font-weight: 700;
}

.wip-warning-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--bg-surface);
    border: 2px solid var(--red);
    border-radius: var(--radius);
    color: var(--red);
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    z-index: 5000;
    animation: wip-toast-in 0.3s ease;
}

@keyframes wip-toast-in {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.status-list {
    max-height: 300px;
    overflow-y: auto;
}

.status-list button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.wip-limit-row {
    padding: 4px 0;
}

.wip-limit-row input[type="number"] {
    text-align: center;
}

body.light-mode .wip-warning-toast {
    background: #fff;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

body.light-mode .board-column-header.wip-over {
    background: rgba(225,112,85,0.08);
}

/* My Work page */
.mywork-filters {
    display: flex;
    gap: 8px;
    align-items: center;
}

.mywork-summary {
    display: flex;
    gap: 24px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
}

.mywork-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.mywork-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.mywork-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mywork-group {
    margin-bottom: 20px;
}

.mywork-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.mywork-group-header h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.mywork-group-count {
    background: var(--bg-hover);
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 1px 7px;
    border-radius: 10px;
    font-weight: 600;
}

.mywork-ticket-list {
    display: flex;
    flex-direction: column;
}

.mywork-ticket {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    transition: background 0.15s;
}

.mywork-ticket:hover {
    background: var(--bg-hover);
}

.mywork-ticket:last-child {
    border-bottom: none;
}

.mywork-ticket-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.mywork-ticket-type {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    flex-shrink: 0;
}

.mywork-ticket-type.type-task { background: var(--accent); color: #fff; }
.mywork-ticket-type.type-bug { background: var(--red); color: #fff; }
.mywork-ticket-type.type-story { background: var(--green); color: #fff; }

.mywork-ticket-title {
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mywork-ticket-title:hover {
    color: var(--accent);
}

.mywork-ticket-labels {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.mywork-label {
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 3px;
    background: var(--bg-hover);
    color: var(--text-muted);
}

.mywork-ticket-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.mywork-estimate {
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 600;
}

.mywork-due {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.mywork-due.overdue {
    color: var(--red);
    font-weight: 600;
}

.mywork-checklist {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.mywork-project {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-hover);
    padding: 2px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

.mywork-status-select {
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
    min-width: 110px;
}

.mywork-status-select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Light mode overrides */
body.light-mode .mywork-summary {
    background: #fff;
}

body.light-mode .mywork-ticket:hover {
    background: #f5f5f5;
}

body.light-mode .mywork-status-select {
    background: #fff;
}

/* Automations */
.automations-layout {
    max-width: 900px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.automations-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.automations-controls .project-select {
    flex: 1;
    max-width: 300px;
    padding: 0.5rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
}

.automation-form-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.automation-form-card h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-grid .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0;
}

.form-grid label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
    padding: 0.5rem 0.75rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
}

.form-grid textarea {
    resize: vertical;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem !important;
    color: var(--text) !important;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.form-error {
    color: var(--red);
    font-size: 0.85rem;
    margin-top: 0.75rem;
}

.automation-rules-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.automation-rule-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
}

.automation-rule-card.disabled {
    opacity: 0.55;
}

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

.rule-name {
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rule-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.rule-status-dot.active {
    background: var(--green);
}

.rule-status-dot.inactive {
    background: var(--text-muted);
}

.rule-actions {
    display: flex;
    gap: 0.5rem;
}

.rule-actions .btn-icon {
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    cursor: pointer;
}

.rule-actions .btn-icon:hover {
    color: var(--text);
    border-color: var(--accent);
}

.rule-actions .btn-icon.danger:hover {
    color: var(--red);
    border-color: var(--red);
}

.rule-description {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.rule-trigger-badge,
.rule-action-badge {
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

.rule-trigger-badge {
    background: rgba(108, 92, 231, 0.15);
    color: var(--accent);
    border: 1px solid rgba(108, 92, 231, 0.3);
}

.rule-action-badge {
    background: rgba(0, 184, 148, 0.15);
    color: var(--green);
    border: 1px solid rgba(0, 184, 148, 0.3);
}

.rule-arrow {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.rule-stats {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Light mode overrides for automations */
body.light-mode .automation-form-card,
body.light-mode .automation-rule-card {
    background: #fff;
}

body.light-mode .form-grid input,
body.light-mode .form-grid select,
body.light-mode .form-grid textarea,
body.light-mode .automations-controls .project-select {
    background: #fff;
}

body.light-mode .rule-actions .btn-icon {
    background: #f5f5f5;
}

/* SLA Health */
.sla-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: 600;
    margin-right: 6px;
}

.sla-ontrack {
    background: rgba(0, 184, 148, 0.15);
    color: var(--green);
}

.sla-atrisk {
    background: rgba(253, 203, 110, 0.15);
    color: var(--orange);
}

.sla-breached {
    background: rgba(225, 112, 85, 0.15);
    color: var(--red);
}

.sla-policy-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.sla-policy-row:last-child {
    border-bottom: none;
}

.sla-priority-label {
    font-weight: 600;
    min-width: 80px;
}

.sla-policy-row label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9em;
    color: var(--text-muted);
}

.sla-policy-row input[type="number"] {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 4px 8px;
}

/* Light mode SLA */
body.light-mode .sla-ontrack {
    background: rgba(0, 184, 148, 0.1);
}

body.light-mode .sla-atrisk {
    background: rgba(253, 203, 110, 0.15);
}

body.light-mode .sla-breached {
    background: rgba(225, 112, 85, 0.1);
}

body.light-mode .sla-policy-row input[type="number"] {
    background: #fff;
}

/* ==================== Chat Page ==================== */
.chat-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 48px);
    max-width: 100%;
    margin: -24px -32px;
    padding: 0;
}

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

.chat-header h1 { font-size: 1.25rem; font-weight: 600; }

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-provider-select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius);
    padding: 8px 12px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 28px;
}

.chat-provider-select:hover {
    border-color: var(--text-muted);
    color: var(--text);
}

.chat-provider-select:focus {
    outline: none;
    border-color: var(--accent);
}

.chat-header-actions .btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius);
    padding: 8px 14px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.chat-header-actions .btn:hover {
    border-color: var(--text-muted);
    color: var(--text);
}

.chat-header-actions .btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    min-height: 38px;
    width: 38px;
    height: 38px;
    padding: 0 !important;
    font-size: 0;
    line-height: 1;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    gap: 12px;
    color: var(--text-muted);
}

.chat-empty-icon { opacity: 0.4; }
.chat-empty h2 { font-size: 1.3rem; color: var(--text); }

.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.chat-msg {
    display: flex;
    gap: 12px;
    max-width: 85%;
}

.chat-msg-user { align-self: flex-end; flex-direction: row-reverse; }
.chat-msg-assistant { align-self: flex-start; }

.chat-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
    text-transform: uppercase;
}

.chat-msg-user .chat-msg-avatar {
    background: var(--accent);
    color: #fff;
}

.chat-msg-assistant .chat-msg-avatar {
    background: var(--green);
    color: #fff;
}

.chat-msg-content {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    min-width: 0;
}

.chat-msg-user .chat-msg-content {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.chat-msg-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--green);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-msg-text {
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-msg-text pre {
    background: var(--bg);
    border-radius: 6px;
    padding: 8px 12px;
    margin: 8px 0;
    overflow-x: auto;
    font-size: 0.85rem;
}

.chat-msg-text code {
    background: rgba(255,255,255,0.1);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.85em;
}

.chat-msg-text pre code {
    background: none;
    padding: 0;
}

.chat-msg-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.chat-msg-user .chat-msg-time { color: rgba(255,255,255,0.6); }

.chat-typing {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

.chat-input-area {
    display: flex;
    gap: 10px;
    padding: 16px 24px;
    margin: 0 68px 12px 68px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-surface);
}

.chat-input-area textarea {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 12px 14px;
    font-size: 0.9rem;
    font-family: inherit;
    resize: none;
    min-height: 44px;
    max-height: 120px;
}

.chat-input-area textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

.chat-send-btn:hover:not(:disabled) { background: var(--accent-hover); }
.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Light mode */
body.light-mode .chat-msg-content { background: #f0f1f5; border-color: #dde0e8; }
body.light-mode .chat-msg-user .chat-msg-content { background: var(--accent); border-color: var(--accent); }
body.light-mode .chat-msg-text pre { background: #e8e9ed; }
body.light-mode .chat-provider-select { background: #fff; }
body.light-mode .chat-header-actions .btn { background: #fff; }

/* ==================== Telegram Mappings Page ==================== */
.mapping-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.mapping-info { display: flex; flex-direction: column; gap: 2px; }
.mapping-telegram { font-weight: 600; }
.mapping-user { color: var(--text-muted); font-size: 0.85rem; }

body.light-mode .mapping-card { background: #fff; border-color: #dde0e8; }

/* ============================================================
   FLOWS
   ============================================================ */

/* Flows List */
.flow-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

.flow-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color 0.15s;
}

.flow-card:hover { border-color: var(--accent); }

.flow-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flow-card-title {
    font-weight: 600;
    font-size: 1.05rem;
    cursor: pointer;
    color: var(--text);
}

.flow-card-title:hover { color: var(--accent); }

.flow-card-description {
    font-size: 0.85rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.flow-card-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
}

.flow-card-stats {
    display: flex;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.flow-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.flow-card-actions .btn {
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.78rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.flow-card-actions .btn:hover {
    background: var(--bg-surface);
    border-color: var(--accent);
    color: var(--text);
}

.flow-card-actions .btn.text-danger:hover {
    border-color: var(--danger);
    color: var(--danger);
}

.flow-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.flow-status-draft { background: var(--bg-hover); color: var(--text-muted); }
.flow-status-active { background: rgba(0,184,148,0.15); color: var(--green); }
.flow-status-paused { background: rgba(253,203,110,0.15); color: var(--orange); }
.flow-status-archived { background: var(--bg-hover); color: var(--text-muted); }

.flow-trigger-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    background: rgba(108,92,231,0.15);
    color: var(--accent);
}

/* Flow Metrics - inline card metrics */
.flow-card-metrics {
    display: flex;
    gap: 10px;
    font-size: 0.78rem;
    padding-top: 4px;
}

.flow-metric {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 6px;
    border-radius: 8px;
    background: var(--bg-hover);
}

.metric-good { color: var(--green); }
.metric-warn { color: var(--orange); }
.metric-bad { color: var(--danger); }

.flow-filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.flow-filter-bar select {
    min-width: 130px;
    max-width: 180px;
}

.flow-search-input {
    min-width: 180px;
    max-width: 260px;
}

.flow-type-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--bg-hover);
    white-space: nowrap;
}

/* Flow Metrics Page */
.metrics-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    text-align: center;
}

.metric-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.2;
}

.metric-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metrics-status-bar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 24px;
    background: var(--bg-hover);
}

.status-bar-segment { min-width: 2px; }
.status-completed { background: var(--green); }
.status-failed { background: var(--danger); }
.status-cancelled { background: var(--text-muted); }
.status-running { background: var(--accent); }

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 24px 0 12px;
    color: var(--text);
}

.metrics-table-container {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.metrics-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.metrics-table th {
    text-align: left;
    padding: 10px 14px;
    background: var(--bg-hover);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.metrics-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}

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

.metrics-table-row { cursor: pointer; }
.metrics-table-row:hover { background: var(--bg-hover); }

.flow-name-cell {
    font-weight: 500;
    color: var(--text);
}

/* Daily bar chart */
.daily-metrics-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 120px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
    padding: 12px;
}

.daily-bar-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    min-width: 12px;
}

.daily-bar-stack {
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    border-radius: 3px 3px 0 0;
    overflow: hidden;
    margin-top: auto;
}

.daily-bar-success { background: var(--green); }
.daily-bar-failure { background: var(--danger); }
.daily-bar-other { background: var(--text-muted); opacity: 0.4; }

.daily-bar-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 4px;
    white-space: nowrap;
}

/* Recent errors */
.recent-errors-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.error-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 3px solid var(--danger);
    border-radius: 8px;
    padding: 10px 14px;
}

.error-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.error-node-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 0.75rem;
    background: rgba(214,48,49,0.12);
    color: var(--danger);
}

.error-message {
    font-size: 0.85rem;
    color: var(--text);
    word-break: break-word;
}

/* Flow Editor Layout */
.flow-editor-layout {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 0px);
    margin: -24px;
}

.flow-editor-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 10;
}

.flow-editor-toolbar-left,
.flow-editor-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.flow-name-input {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text);
    font-size: 1.1rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    width: 300px;
}

.flow-name-input:focus {
    border-color: var(--accent);
    outline: none;
    background: var(--bg-card);
}

.flow-editor-main {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* Node Palette */
.flow-node-palette {
    width: 200px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    padding: 12px;
    overflow-y: auto;
    flex-shrink: 0;
    transition: width 0.2s ease, opacity 0.2s ease, padding 0.2s ease;
}

/* Unpinned sidebar — collapsed until hovered */
.flow-node-palette.palette-unpinned {
    width: 36px;
    padding: 12px 6px;
    overflow: hidden;
}
.flow-node-palette.palette-unpinned .palette-sections,
.flow-node-palette.palette-unpinned .palette-search,
.flow-node-palette.palette-unpinned .palette-header h3 {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}
.flow-node-palette.palette-unpinned:hover {
    width: 200px;
    padding: 12px;
    overflow-y: auto;
}
.flow-node-palette.palette-unpinned:hover .palette-sections,
.flow-node-palette.palette-unpinned:hover .palette-search,
.flow-node-palette.palette-unpinned:hover .palette-header h3 {
    opacity: 1;
    pointer-events: auto;
}

/* Palette header with pin button */
.palette-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.palette-header h3 {
    font-size: 0.9rem;
    margin: 0;
    color: var(--text-muted);
}
.palette-pin-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    line-height: 1;
    opacity: 0.5;
    transition: opacity 0.15s, transform 0.15s;
}
.palette-pin-btn:hover { opacity: 1; }
.pin-icon { font-size: 0.85rem; display: inline-block; transform: rotate(45deg); }
.pin-icon.pinned { transform: rotate(0deg); opacity: 1; }

/* Palette search */
.palette-search {
    margin-bottom: 10px;
}
.palette-search input {
    width: 100%;
    padding: 5px 8px;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-card);
    color: var(--text);
}
.palette-search input:focus {
    border-color: var(--accent);
    outline: none;
}

.palette-section { margin-bottom: 12px; }

/* Collapsible group label */
.palette-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 6px;
    letter-spacing: 0.05em;
}
.palette-label-collapsible {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 4px;
}
.palette-label-collapsible:hover {
    color: var(--text);
}
.palette-collapse-icon {
    font-size: 0.6rem;
    width: 10px;
    text-align: center;
}

.palette-node {
    display: block;
    width: 100%;
    padding: 6px 10px;
    margin-bottom: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.8rem;
    cursor: pointer;
    text-align: left;
    transition: all 0.15s;
}

.palette-node:hover { border-color: var(--accent); background: var(--bg-hover); }

.palette-trigger { border-left: 3px solid var(--green); }
.palette-agent { border-left: 3px solid var(--accent); }
.palette-wait { border-left: 3px solid var(--orange); }
.palette-action { border-left: 3px solid var(--blue); }
.palette-logic { border-left: 3px solid #e17055; }
.palette-data { border-left: 3px solid #1abc9c; }
.palette-log { border-left: 3px solid #a29bfe; }
.palette-error { border-left: 3px solid #f39c12; }
.palette-roundtable { border-left: 3px solid #f1c40f; }
.palette-system { border-left: 3px solid #636e72; }

/* Flow Canvas */
.flow-canvas {
    flex: 1;
    background: var(--bg);
    position: relative;
    overflow: hidden;
    cursor: grab;
}

.flow-canvas svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* SVG Nodes */
.flow-node { cursor: move; }

.flow-node .node-body {
    fill: var(--bg-card);
    stroke: var(--border);
    stroke-width: 1.5;
    transition: stroke 0.15s;
}

.flow-node:hover .node-body { stroke: var(--accent); }
.flow-node .node-selected {
    stroke: var(--accent);
    stroke-width: 2.5;
    filter: drop-shadow(0 0 6px var(--accent)) drop-shadow(0 0 2px var(--accent));
    fill: color-mix(in srgb, var(--accent) 8%, var(--bg-card));
}

.flow-node-trigger .node-body { stroke: var(--green); }
.flow-node-agent .node-body { stroke: var(--accent); }
.flow-node-wait .node-body { stroke: var(--orange); }
.flow-node-logic .node-body { stroke: var(--red); }
.flow-node-action .node-body { stroke: var(--blue); }
.flow-node-data .node-body { stroke: var(--teal, #1abc9c); }
.flow-node-log .node-body { stroke: #a29bfe; }
.flow-node-error .node-body { stroke: #f39c12; }
.flow-node-roundtable .node-body { stroke: #f1c40f; }
.flow-node-system .node-body { stroke: #636e72; }

/* Node execution state visualization */
@keyframes node-pulse {
    0%, 100% { stroke-opacity: 1; filter: drop-shadow(0 0 4px var(--blue)); }
    50% { stroke-opacity: 0.5; filter: drop-shadow(0 0 12px var(--blue)); }
}

.node-exec-running {
    stroke: var(--blue) !important;
    stroke-width: 2.5 !important;
    animation: node-pulse 1.5s ease-in-out infinite;
}

.node-exec-completed {
    stroke: var(--green) !important;
    stroke-width: 2.5 !important;
    filter: drop-shadow(0 0 6px var(--green));
    fill: color-mix(in srgb, var(--green) 6%, var(--bg-card)) !important;
}

.node-exec-failed {
    stroke: var(--red) !important;
    stroke-width: 2.5 !important;
    filter: drop-shadow(0 0 6px var(--red));
    fill: color-mix(in srgb, var(--red) 6%, var(--bg-card)) !important;
}

.node-exec-waiting {
    stroke: var(--orange) !important;
    stroke-width: 2.5 !important;
    filter: drop-shadow(0 0 6px var(--orange, #f39c12));
    fill: color-mix(in srgb, var(--orange, #f39c12) 6%, var(--bg-card)) !important;
}

/* Ports */
.port {
    fill: var(--bg-surface);
    stroke: var(--text-muted);
    stroke-width: 1.5;
    cursor: crosshair;
    transition: all 0.15s;
}

.port:hover {
    fill: var(--accent);
    stroke: var(--accent);
    r: 9;
}

.port-true { stroke: var(--green); }
.port-false { stroke: var(--red); }

/* Connections */
.flow-connection { cursor: default; }
.connection-hit-area { stroke: transparent; }

/* Connection delete button - circle with X at midpoint */
.connection-delete-btn { cursor: pointer; opacity: 0; transition: opacity 0.15s; }
.flow-connection:hover .connection-delete-btn { opacity: 1; }
.conn-delete-circle {
    fill: var(--bg-surface, #2d3436);
    stroke: var(--red, #e17055);
    stroke-width: 1.5;
}
.connection-delete-btn:hover .conn-delete-circle {
    fill: var(--red, #e17055);
    stroke: var(--red, #e17055);
}
.connection-delete-btn:hover text {
    fill: #fff !important;
}

/* Port snap highlight when dragging a connection */
.port-snap-active {
    fill: var(--accent, #6c5ce7) !important;
    stroke: var(--accent, #6c5ce7) !important;
    r: 12 !important;
    filter: drop-shadow(0 0 6px var(--accent, #6c5ce7));
    transition: all 0.1s ease-out;
}

.node-delete { cursor: pointer; opacity: 0; transition: opacity 0.15s; }
.flow-node:hover .node-delete { opacity: 1; }

/* Zoom Controls */
.flow-zoom-controls {
    position: absolute;
    bottom: 16px;
    left: 16px;
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    z-index: 10;
}

.flow-zoom-btn {
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
}

.flow-zoom-btn:hover { background: var(--bg-hover); }

.flow-zoom-level {
    font-size: 12px;
    color: var(--text-muted);
    min-width: 40px;
    text-align: center;
    user-select: none;
}

/* Minimap */
.flow-minimap {
    position: absolute;
    bottom: 16px;
    right: 16px;
    width: 200px;
    height: 130px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    z-index: 10;
    opacity: 0.85;
    transition: opacity 0.2s;
}

.flow-minimap:hover { opacity: 1; }

.flow-minimap svg {
    width: 100%;
    height: 100%;
    display: block;
}

.minimap-viewport {
    pointer-events: none;
}

/* Selection bar */
.flow-selection-bar {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--accent);
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text);
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Node Properties Panel */
.flow-node-properties {
    width: 320px;
    background: var(--bg-surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
}

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

.properties-header h3 { font-size: 0.95rem; }

.properties-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Retry Config */
.retry-config {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.retry-summary {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    padding: 4px 0;
}

.retry-summary:hover {
    color: var(--text);
}

.retry-fields {
    margin-top: 8px;
}

/* Timeout Config */
.timeout-config {
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid var(--border);
}

/* SetVariable Rows */
.set-variable-row {
    display: flex;
    gap: 6px;
    align-items: flex-end;
    padding: 8px;
    margin-bottom: 6px;
    background: var(--bg);
    border-radius: 6px;
    border: 1px solid var(--border);
}

.set-variable-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

.set-variable-row .form-group label {
    font-size: 10px;
    margin-bottom: 2px;
}

.set-variable-row .btn {
    flex-shrink: 0;
    align-self: center;
    color: var(--red);
}

/* TransformData Rows */
.transform-row {
    padding: 8px;
    margin-bottom: 6px;
    background: var(--bg);
    border-radius: 6px;
    border: 1px solid var(--border);
}

.transform-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.transform-index {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
}

.transform-row .form-group {
    margin-bottom: 6px;
}

.transform-row .form-group label {
    font-size: 10px;
    margin-bottom: 2px;
}

.transform-row .btn {
    color: var(--red);
}

.transform-help {
    margin-top: 8px;
}

/* Expression Helper */
.expression-helper {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.expression-helper-header {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.expression-helper > small {
    display: block;
    margin-bottom: 8px;
}

.expression-group {
    margin-bottom: 8px;
}

.expression-group-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.expression-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 4px 8px;
    margin-bottom: 2px;
    background: var(--bg-hover);
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    text-align: left;
    font-size: 11px;
    color: var(--text);
    transition: all 0.1s;
}

.expression-chip:hover {
    border-color: var(--accent);
    background: var(--bg-surface);
}

.expression-chip[draggable="true"] {
    cursor: grab;
}

.expression-chip-dragging {
    opacity: 0.5;
    border-color: var(--accent);
}

.expression-drop-target {
    outline: 2px solid var(--accent) !important;
    outline-offset: -2px;
    background: color-mix(in srgb, var(--accent) 10%, transparent) !important;
}

.expression-key {
    color: var(--accent);
    font-weight: 600;
    white-space: nowrap;
}

.expression-syntax {
    color: var(--text-muted);
    font-family: monospace;
    font-size: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Flow Executions */
.execution-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.execution-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    cursor: pointer;
    transition: border-color 0.15s;
}

.execution-card:hover,
.execution-card.selected { border-color: var(--accent); }

.execution-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.execution-card-meta {
    display: flex;
    gap: 16px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.execution-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.execution-status-running { background: rgba(116,185,255,0.15); color: var(--blue); }
.execution-status-completed { background: rgba(0,184,148,0.15); color: var(--green); }
.execution-status-failed { background: rgba(225,112,85,0.15); color: var(--red); }
.execution-status-waiting { background: rgba(253,203,110,0.15); color: var(--orange); }
.execution-status-cancelled { background: var(--bg-hover); color: var(--text-muted); }
.execution-status-pending { background: var(--bg-hover); color: var(--text-muted); }
.execution-status-skipped { background: var(--bg-hover); color: var(--text-muted); }
.execution-status-simulating { background: rgba(162,155,254,0.15); color: var(--purple); }

/* Dry run badge */
.badge-dryrun {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    background: rgba(162,155,254,0.2);
    color: var(--purple);
    border: 1px solid rgba(162,155,254,0.3);
}
.badge-dryrun.badge-sm {
    padding: 0 4px;
    font-size: 0.6rem;
}

/* Dry run button styling */
.btn-dryrun {
    border: 1px dashed var(--purple) !important;
    color: var(--purple) !important;
}
.btn-dryrun:hover:not(:disabled) {
    background: rgba(162,155,254,0.1) !important;
}

.execution-error {
    color: var(--red);
    font-size: 0.85rem;
    margin-top: 4px;
    padding: 6px 8px;
    background: rgba(225,112,85,0.08);
    border-radius: 4px;
}

.execution-card.expanded {
    border-radius: var(--radius) var(--radius) 0 0;
    border-bottom-color: transparent;
}

.execution-detail-inline {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    margin: -1px 0 8px 0;
    padding: 16px;
    animation: inline-expand 150ms ease-out;
}

@keyframes inline-expand {
    from { opacity: 0; }
    to { opacity: 1; }
}

.execution-detail-body {
    max-height: 500px;
    overflow-y: auto;
}

.expand-indicator {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.execution-detail-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 16px;
    font-size: 0.85rem;
}

.node-execution-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.node-execution-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 14px;
    cursor: pointer;
    transition: border-color 0.15s;
}
.node-execution-card:hover { border-color: var(--accent); }
.node-execution-card.expanded { border-color: var(--accent); }

.node-execution-detail {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.node-execution-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.node-execution-name { font-weight: 500; font-size: 0.85rem; }

.node-execution-data {
    margin-top: 6px;
}

.node-execution-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.node-execution-data pre {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 8px;
    font-size: 0.8rem;
    overflow-x: auto;
    max-height: 200px;
    overflow-y: auto;
    color: var(--text);
}

.node-execution-error {
    color: var(--red);
    font-size: 0.8rem;
    margin-top: 4px;
}

.node-execution-time { font-size: 0.75rem; margin-top: 4px; }

/* Inline Execution History Panel */
.flow-history-panel {
    padding: 0;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
    max-height: 350px;
    display: flex;
    flex-direction: column;
}
.flow-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.flow-history-actions {
    display: flex;
    gap: 4px;
}
.flow-history-body {
    overflow-y: auto;
    padding: 8px;
    flex: 1;
    min-height: 0;
}

.history-execution-card {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.15s;
    background: var(--bg-card);
}
.history-execution-card:hover { border-color: var(--accent); }
.history-execution-card.replaying {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 8%, var(--bg-card));
    border-radius: 6px 6px 0 0;
    border-bottom-color: transparent;
    margin-bottom: 0;
}
.history-execution-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.history-exec-time { font-size: 0.75rem; }
.history-execution-meta {
    display: flex;
    gap: 12px;
    font-size: 0.75rem;
    margin-top: 2px;
}
.history-exec-error {
    color: var(--red);
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.approval-actions {
    display: flex;
    gap: 8px;
    margin-top: 6px;
}

/* Replay Detail Section (inline beneath clicked execution) */
.history-replay-detail-inline {
    background: var(--bg);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 6px 6px;
    margin: -1px 0 4px 0;
    padding: 8px;
    animation: inline-expand 150ms ease-out;
}
.history-replay-detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 4px;
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.history-node-card {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    margin-bottom: 4px;
    cursor: pointer;
    background: var(--bg);
    transition: all 0.15s;
}
.history-node-card:hover { border-color: var(--accent); }
.history-node-card.selected {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 6%, var(--bg));
}
.history-node-header {
    display: flex;
    align-items: center;
    gap: 6px;
}
.history-node-name { font-weight: 500; font-size: 0.8rem; }
.history-node-type { font-size: 0.7rem; }
.history-node-timing { font-size: 0.7rem; margin-top: 2px; }
.history-retry-badge {
    background: var(--orange, #f39c12);
    color: #fff;
    padding: 0 4px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 600;
    margin-left: 4px;
}

.history-node-detail {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
}
.history-node-data { margin-bottom: 6px; }
.history-node-data.error { color: var(--red); }
.history-node-data-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 2px;
}
.history-node-data pre {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    max-height: 120px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    margin: 0;
}

/* Node replay status overlay on canvas */
.flow-node .node-replay-completed {
    stroke: var(--green) !important;
    stroke-width: 2.5;
    fill: color-mix(in srgb, var(--green) 8%, var(--bg-card));
}
.flow-node .node-replay-failed {
    stroke: var(--red) !important;
    stroke-width: 2.5;
    fill: color-mix(in srgb, var(--red) 8%, var(--bg-card));
}
.flow-node .node-replay-skipped {
    stroke: var(--text-muted) !important;
    stroke-width: 1.5;
    stroke-dasharray: 4 2;
    opacity: 0.6;
}
.flow-node .node-replay-running {
    stroke: var(--blue) !important;
    stroke-width: 2.5;
    fill: color-mix(in srgb, var(--blue) 8%, var(--bg-card));
}
.flow-node .node-replay-waiting {
    stroke: var(--orange, #f39c12) !important;
    stroke-width: 2.5;
    fill: color-mix(in srgb, var(--orange, #f39c12) 8%, var(--bg-card));
}
.flow-node .node-replay-pending {
    opacity: 0.4;
}

/* Toolbar hamburger menu */
.toolbar-menu-wrapper {
    position: relative;
}
.toolbar-hamburger {
    font-size: 1.1rem;
    line-height: 1;
    padding: 5px 8px;
}
.toolbar-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 99;
}
.toolbar-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    min-width: 180px;
    padding: 4px 0;
    z-index: 100;
}
.toolbar-menu-item {
    display: block;
    width: 100%;
    padding: 8px 16px;
    background: none;
    border: none;
    color: var(--text);
    font-size: 0.85rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.1s;
}
.toolbar-menu-item:hover {
    background: var(--bg-hover);
}
body.light-mode .toolbar-dropdown-menu {
    background: #fff;
    border-color: #dde0e8;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

/* Flow editor toolbar buttons — always visible, not ghost-on-idle */
.flow-editor-toolbar-right .btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
}
.flow-editor-toolbar-right .btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}
.flow-editor-toolbar-right .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Active button style for toolbar */
.flow-editor-toolbar-right .btn.active {
    background: color-mix(in srgb, var(--accent) 15%, transparent);
    border-color: var(--accent);
    color: var(--accent);
}

/* Light mode overrides for flows */
body.light-mode .flow-card { background: #fff; border-color: #dde0e8; }
body.light-mode .flow-card-actions .btn { background: #f0f1f5; border-color: #dde0e8; }
body.light-mode .flow-card-actions .btn:hover { background: #fff; }
body.light-mode .flow-canvas { background: #fafbfc; }
body.light-mode .flow-node .node-body { fill: #fff; stroke: #dde0e8; }
body.light-mode .flow-node .node-selected { fill: color-mix(in srgb, var(--accent) 6%, #fff); }
body.light-mode .flow-node-palette { background: #f5f6f8; }
body.light-mode .flow-editor-toolbar { background: #f5f6f8; }
body.light-mode .flow-editor-toolbar-right .btn { background: #fff; border-color: #dde0e8; }
body.light-mode .flow-editor-toolbar-right .btn:hover { background: #eef0f4; border-color: var(--accent); }
body.light-mode .flow-node-properties { background: #f5f6f8; }
body.light-mode .flow-name-input:focus { background: #fff; }
body.light-mode .palette-node { background: #fff; border-color: #dde0e8; }
body.light-mode .flow-zoom-controls { background: #fff; border-color: #dde0e8; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
body.light-mode .flow-minimap { background: #fff; border-color: #dde0e8; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
body.light-mode .flow-selection-bar { background: #fff; border-color: var(--accent); box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
body.light-mode .execution-card { background: #fff; border-color: #dde0e8; }
body.light-mode .execution-detail-inline { background: #f8f9fb; border-color: #dde0e8; }
body.light-mode .history-replay-detail-inline { background: #f8f9fb; border-color: #dde0e8; }
body.light-mode .node-exec-completed { fill: color-mix(in srgb, var(--green) 6%, #fff) !important; }
body.light-mode .node-exec-failed { fill: color-mix(in srgb, var(--red) 6%, #fff) !important; }
body.light-mode .node-exec-waiting { fill: color-mix(in srgb, var(--orange, #f39c12) 6%, #fff) !important; }
body.light-mode .node-execution-card { background: #f5f6f8; }
body.light-mode .node-execution-data pre { background: #fff; border-color: #dde0e8; }
body.light-mode .flow-history-panel { background: #f5f6f8; }
body.light-mode .history-execution-card { background: #fff; border-color: #dde0e8; }
body.light-mode .history-node-card { background: #fff; border-color: #dde0e8; }
body.light-mode .history-node-data pre { background: #fff; border-color: #dde0e8; }
body.light-mode .flow-node .node-replay-completed { fill: color-mix(in srgb, var(--green) 6%, #fff); }
body.light-mode .flow-node .node-replay-failed { fill: color-mix(in srgb, var(--red) 6%, #fff); }
body.light-mode .flow-node .node-replay-running { fill: color-mix(in srgb, var(--blue) 6%, #fff); }
body.light-mode .flow-node .node-replay-waiting { fill: color-mix(in srgb, var(--orange, #f39c12) 6%, #fff); }

/* Webhook URL group */
.webhook-url-group {
    display: flex;
    gap: 4px;
    align-items: center;
}
.webhook-url-group input {
    flex: 1;
    font-family: monospace;
    font-size: 0.75rem;
}

/* Flow Validation Panel */
.flow-validation-panel {
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    max-height: 200px;
    overflow-y: auto;
}
.flow-validation-panel.has-errors { background: rgba(231, 76, 60, 0.08); }
.flow-validation-panel.has-warnings { background: rgba(241, 196, 15, 0.08); }
.validation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.validation-icon {
    display: inline-flex;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    margin-right: 6px;
    vertical-align: middle;
}
.validation-icon.error { background: var(--red); color: #fff; }
.validation-icon.warning { background: var(--orange, #f39c12); color: #fff; }
.validation-items { display: flex; flex-direction: column; gap: 3px; }
.validation-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 3px 8px;
    border-radius: 4px;
    cursor: pointer;
}
.validation-item:hover { background: var(--bg-hover); }
.validation-severity {
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    flex-shrink: 0;
}
.validation-item.error .validation-severity { background: var(--red); color: #fff; }
.validation-item.warning .validation-severity { background: var(--orange, #f39c12); color: #fff; }
.validation-message { font-size: 12px; }
body.light-mode .flow-validation-panel.has-errors { background: rgba(231, 76, 60, 0.06); }
body.light-mode .flow-validation-panel.has-warnings { background: rgba(241, 196, 15, 0.06); }

/* Flow Variables Panel */
.flow-variables-panel {
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    background: rgba(52, 152, 219, 0.06);
    font-size: 13px;
    max-height: 250px;
    overflow-y: auto;
}
.flow-variables-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.flow-variables-header code {
    font-size: 11px;
    background: var(--bg-hover);
    padding: 1px 5px;
    border-radius: 3px;
}
.flow-variables-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.flow-variable-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.flow-variable-row .form-group {
    flex: 1;
    margin-bottom: 0;
}
.flow-variable-row .form-group label {
    font-size: 10px;
    margin-bottom: 2px;
}
.flow-variable-row .form-group input {
    font-size: 12px;
    padding: 4px 8px;
}
.flow-variable-row .btn {
    flex-shrink: 0;
    align-self: flex-end;
    margin-bottom: 2px;
}
.flow-settings-divider {
    border-top: 1px solid var(--border-color);
    margin: 8px 0;
}

/* Flow Settings Panel */
.flow-settings-panel {
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    background: rgba(155, 89, 182, 0.06);
    max-height: 300px;
    overflow-y: auto;
    font-size: 13px;
}
.flow-settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.flow-settings-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.flow-settings-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.flow-settings-row .form-group {
    flex: 1;
    margin-bottom: 0;
}
.flow-settings-row .form-group label {
    font-size: 10px;
    margin-bottom: 2px;
}
.flow-settings-row .form-group input,
.flow-settings-row .form-group select {
    font-size: 12px;
    padding: 4px 8px;
}
.flow-settings-row .form-group small {
    font-size: 10px;
}
.btn-settings-gear {
    font-size: 16px;
    padding: 2px 6px;
    line-height: 1;
}

/* Condition Node Help */
.condition-help { margin-top: 6px; }
.condition-help details summary { cursor: pointer; font-size: 12px; user-select: none; }
.condition-operators { padding: 8px 0 4px; }
.operator-group { margin-bottom: 6px; }
.operator-group-label { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 2px; font-weight: 600; }
.operator-group code { font-size: 11px; background: var(--bg-hover); padding: 1px 5px; border-radius: 3px; margin-right: 4px; display: inline-block; margin-bottom: 2px; }
.operator-examples { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--border); }
.operator-examples code { font-size: 11px; background: var(--bg-hover); padding: 1px 4px; border-radius: 3px; }

/* RoundTable Seat Rows */
.roundtable-seat-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px;
    margin-bottom: 8px;
    background: var(--bg);
    border-radius: 6px;
    border: 1px solid var(--border);
    border-left: 3px solid #f1c40f;
    position: relative;
}
.roundtable-seat-row .form-group { margin-bottom: 0; }
.roundtable-seat-row .form-group label { font-size: 10px; margin-bottom: 2px; }
.roundtable-seat-row > .btn { position: absolute; top: 4px; right: 4px; color: var(--red); }
.roundtable-seat-row textarea { min-height: 40px; }
.seat-type-badge {
    display: inline-block;
    font-size: 9px;
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 600;
    text-transform: uppercase;
}
.seat-type-badge.llm { background: var(--accent); color: white; }
.seat-type-badge.external { background: #f1c40f; color: #000; }
body.light-mode .roundtable-seat-row { background: #fff; }

/* ── Containers Page ── */
.container-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
    gap: 16px;
}

.container-card {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.container-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.container-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

.container-status-created { background: rgba(139,143,163,0.1); color: var(--text-muted); }
.container-status-starting { background: rgba(116,185,255,0.15); color: var(--blue); }
.container-status-awaitingauth { background: rgba(253,203,110,0.2); color: var(--orange); }
.container-status-running { background: rgba(0,184,148,0.15); color: var(--green); }
.container-status-stopping { background: rgba(253,203,110,0.15); color: var(--orange); }
.container-status-stopped { background: rgba(139,143,163,0.1); color: var(--text-muted); }
.container-status-error { background: rgba(225,112,85,0.15); color: var(--red); }

.container-card-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.container-detail-row {
    display: flex;
    gap: 8px;
    font-size: 0.85rem;
    align-items: baseline;
}

.container-detail-row .text-muted {
    min-width: 100px;
    flex-shrink: 0;
}

.container-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    flex-wrap: wrap;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.btn-icon {
    width: 14px;
    height: 14px;
    display: inline-block;
    vertical-align: -2px;
    margin-right: 4px;
}

/* ── Terminal Modal ── */
.terminal-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90vw;
    max-width: 1000px;
    height: 70vh;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

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

.terminal-body {
    flex: 1;
    padding: 8px;
    overflow: hidden;
}

.terminal-body .xterm {
    height: 100%;
}

.terminal-body .xterm-viewport {
    overflow-y: auto;
}

/* ── Log Viewer ── */
.log-viewer {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    background: #0f1117;
    color: #e1e4ed;
}

.log-line {
    white-space: pre-wrap;
    word-break: break-all;
}

.log-line:hover {
    background: rgba(108, 92, 231, 0.08);
}

/* ── Checkbox list (container create) ── */
.checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 240px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.checkbox-item:hover {
    background: rgba(108, 92, 231, 0.08);
}

.checkbox-item input[type="checkbox"] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
}

/* ── Step indicator chips ── */
.label-chip-active {
    background: rgba(108, 92, 231, 0.2) !important;
    color: var(--accent) !important;
    font-weight: 600;
}

/* Light mode overrides */
body.light-mode .container-card-actions { border-top-color: var(--border); }
body.light-mode .terminal-modal { background: #1a1d27; } /* Keep terminal dark even in light mode */
body.light-mode .log-viewer { background: #1a1d27; color: #e1e4ed; } /* Keep logs dark in light mode */
body.light-mode .checkbox-list { border-color: var(--border); }
