/* ============== DESIGN SYSTEM ============== */
:root {
    /* Colors - Light Mode */
    --bg-primary: #FAFAFA;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #F3F4F6;
    --bg-hover: #E5E7EB;

    --text-primary: #1F2937;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;

    --border-color: #E5E7EB;
    --border-light: #F3F4F6;

    --accent: #3B82F6;
    --accent-hover: #2563EB;
    --accent-light: rgba(59, 130, 246, 0.1);

    --success: #10B981;
    --success-light: rgba(16, 185, 129, 0.1);
    --danger: #EF4444;
    --danger-light: rgba(239, 68, 68, 0.1);

    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-8: 48px;

    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
    --font-xs: 12px;
    --font-sm: 13px;
    --font-base: 14px;
    --font-md: 16px;
    --font-lg: 20px;
    --font-xl: 24px;

    /* Border radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);

    /* Branch colors */
    --branch-1: #6366F1;
    --branch-2: #EC4899;
    --branch-3: #F59E0B;
    --branch-4: #10B981;
    --branch-5: #3B82F6;
    --branch-6: #8B5CF6;
    --branch-7: #EF4444;
    --branch-8: #14B8A6;
    --branch-9: #F97316;
    --branch-10: #06B6D4;
    --branch-11: #84CC16;
    --branch-12: #E11D48;

    /* Aliases for agents system + missing vars */
    --text: var(--text-primary);
    --card-bg: var(--bg-secondary);
    --radius: var(--radius-md);
    --border: var(--border-color);
    --primary: var(--accent);
    --bg: var(--bg-primary);
    --primary-bg: var(--accent-light);
    --success-bg: var(--success-light);
    --muted-bg: var(--bg-tertiary);
    --success-text: var(--success);
    --muted-text: var(--text-muted);
}

[data-theme="dark"] {
    --bg-primary: #0F0F0F;
    --bg-secondary: #171717;
    --bg-tertiary: #1F1F1F;
    --bg-hover: #2A2A2A;

    --text-primary: #F3F4F6;
    --text-secondary: #9CA3AF;
    --text-muted: #6B7280;

    --border-color: #2D2D2D;
    --border-light: #252525;

    --accent-light: rgba(59, 130, 246, 0.15);
    --success-light: rgba(16, 185, 129, 0.15);
    --danger-light: rgba(239, 68, 68, 0.15);

    /* Dark mode overrides for agent aliases */
    --text: var(--text-primary);
    --border: var(--border-color);
    --bg: var(--bg-primary);
    --card-bg: var(--bg-secondary);
    --primary-bg: var(--accent-light);
    --success-bg: rgba(16, 185, 129, 0.15);
    --muted-bg: #1F1F1F;
    --success-text: #10B981;
    --muted-text: #6B7280;
}

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

body {
    font-family: var(--font-family);
    font-size: var(--font-base);
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
}

/* ============== LAYOUT ============== */
#app {
    min-height: 100vh;
}

.screen {
    display: none;
}

.screen.active {
    display: flex;
}

.hidden {
    display: none !important;
}

/* ============== LOCK SCREEN ============== */
#lock-screen {
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
}

.lock-container {
    background: var(--bg-secondary);
    padding: var(--space-8);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    max-width: 380px;
    width: 90%;
}

.lock-logo {
    text-align: center;
    margin-bottom: var(--space-6);
}

.logo-icon-lock {
    width: 56px;
    height: 56px;
    margin: 0 auto var(--space-4);
    background: var(--accent);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: var(--font-lg);
}

.lock-logo h1 {
    font-size: var(--font-xl);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.lock-logo .subtitle {
    font-size: var(--font-sm);
    color: var(--text-muted);
}

.auth-form h2 {
    font-size: var(--font-md);
    font-weight: 600;
    margin-bottom: var(--space-4);
    text-align: center;
}

.form-hint {
    font-size: var(--font-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-4);
    text-align: center;
}

.form-switch {
    text-align: center;
    margin-top: var(--space-4);
    font-size: var(--font-sm);
    color: var(--text-muted);
}

.form-hint-invite {
    text-align: center;
    margin-top: var(--space-4);
    font-size: var(--font-sm);
    color: var(--text-muted);
    opacity: 0.7;
}

.invite-welcome {
    text-align: center;
    font-size: var(--font-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-4);
}

/* Honeypot fields - invisible to humans */
.hp-field {
    position: absolute;
    left: -9999px;
    top: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

.form-switch a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.form-switch a:hover {
    text-decoration: underline;
}

.form-group {
    margin-bottom: var(--space-4);
}

.form-group label {
    display: block;
    font-size: var(--font-sm);
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-size: var(--font-base);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: border-color 0.15s ease;
}

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

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.error-message {
    background: var(--danger-light);
    color: var(--danger);
    padding: var(--space-3);
    border-radius: var(--radius-sm);
    font-size: var(--font-sm);
    margin-bottom: var(--space-4);
}

/* ============== BUTTONS ============== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-sm);
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

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

.btn-full {
    width: 100%;
    padding: var(--space-3) var(--space-4);
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-close {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: var(--font-md);
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.btn-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ============== MAIN APP ============== */
#main-app {
    display: flex;
    height: 100vh;
}

/* ============== SIDEBAR ============== */
.sidebar {
    width: 220px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    transition: width 0.2s ease;
}

/* Sidebar collapsed */
.sidebar.collapsed {
    width: 52px;
    overflow: hidden;
}
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-edit-header,
.sidebar.collapsed .nav-apps-title,
.sidebar.collapsed .nav-apps-add,
.sidebar.collapsed .user-name,
.sidebar.collapsed .user-settings-icon,
.sidebar.collapsed .nav-vis-toggle,
.sidebar.collapsed .nav-drag-handle,
.sidebar.collapsed .notification-bell,
.sidebar.collapsed .nav-app-name {
    display: none !important;
}
.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 10px 0;
}
.sidebar.collapsed .nav-icon {
    margin: 0;
}
.sidebar.collapsed .logo {
    justify-content: center;
}
.sidebar.collapsed .logo-icon {
    display: none !important;
}
.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 12px 4px;
}
.sidebar.collapsed .user-info {
    justify-content: center;
    padding: 8px 0;
}
.sidebar.collapsed .user-avatar {
    margin: 0;
}
.sidebar.collapsed .nav-apps-section {
    display: none;
}
.sidebar.collapsed .sidebar-footer .nav-item {
    justify-content: center;
}

/* Collapse button */
.sidebar-collapse-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}
.sidebar-collapse-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.sidebar.collapsed .sidebar-collapse-btn {
    transform: rotate(180deg);
    margin: 0 auto;
}

.sidebar-header {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-light);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: var(--font-xs);
}

.logo-text {
    font-size: var(--font-base);
    font-weight: 600;
    color: var(--text-primary);
}

.nav {
    flex: 1;
    padding: var(--space-2);
}

/* Nav edit header */
.nav-edit-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 12px 6px;
}
.nav-edit-header .nav-edit-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
}
.nav-edit-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    transition: all 0.15s;
}
.nav-edit-toggle:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.nav-edit-toggle.active { color: var(--accent); background: var(--accent-light); }

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: var(--font-sm);
    font-weight: 500;
    text-align: left;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    margin-bottom: 2px;
    position: relative;
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-light);
    color: var(--accent);
}

/* Nav item hidden by user prefs */
.nav-item.nav-hidden { display: none; }

/* Edit mode controls */
.nav-drag-handle, .nav-vis-toggle {
    display: none;
}
.nav.edit-mode .nav-drag-handle {
    display: flex;
    align-items: center;
    cursor: grab;
    color: var(--text-muted);
    font-size: 11px;
    padding: 0 2px;
    user-select: none;
    flex-shrink: 0;
}
.nav.edit-mode .nav-drag-handle:active { cursor: grabbing; }
.nav.edit-mode .nav-vis-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--danger-light);
    color: var(--danger);
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
    transition: all 0.15s;
    border: none;
}
.nav.edit-mode .nav-vis-toggle:hover { background: var(--danger); color: #fff; }
.nav.edit-mode .nav-vis-toggle.off {
    background: var(--success-light);
    color: var(--success);
}
.nav.edit-mode .nav-vis-toggle.off:hover { background: var(--success); color: #fff; }
.nav.edit-mode .nav-item.nav-hidden {
    display: flex;
    opacity: 0.45;
}
.nav.edit-mode .nav-item {
    border: 1px dashed transparent;
}
.nav-item.drag-over {
    border-top: 2px solid var(--accent);
}

.nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-xs);
    font-weight: 600;
}

.nav-label {
    flex: 1;
}

/* ============== ASSISTANT TABS BAR ============== */
.assistant-tabs-bar {
    display: none;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--card-bg, var(--bg-secondary));
}
.assistant-tabs-bar.visible {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 8px;
    padding-bottom: 8px;
}
.assistant-tabs-title {
    font-weight: 600;
    font-size: 1rem;
    margin-right: 16px;
    color: var(--text-primary);
}
.assistant-tabs {
    display: flex;
    gap: 6px;
}
.assistant-tabs .btn {
    white-space: nowrap;
    font-size: 0.82rem;
    padding: 5px 14px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}
.assistant-tabs .btn:hover {
    background: var(--bg-hover, var(--bg-tertiary));
    color: var(--text-primary);
}
.assistant-tabs .btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.sidebar-footer {
    padding: var(--space-2);
    border-top: 1px solid var(--border-light);
}
.user-info-clickable {
    cursor: pointer;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}
.user-info-clickable:hover {
    background: var(--bg-tertiary);
}
.user-settings-icon {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.15s;
}
.user-info-clickable:hover .user-settings-icon {
    opacity: 1;
}

/* ============== MAIN CONTENT ============== */
.main {
    flex: 1;
    padding: var(--space-6);
    overflow-y: auto;
    background: var(--bg-primary);
}

.section {
    display: none;
}

.section.active {
    display: block;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-5);
}

.section-title {
    font-size: var(--font-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.section-date {
    font-size: var(--font-sm);
    color: var(--text-muted);
    margin-left: var(--space-4);
}

/* ============== CARDS ============== */
.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--space-4);
}

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-4);
}

.card-title {
    font-size: var(--font-sm);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-4);
}

/* ============== TASKS ============== */
.task-list, .task-list-full {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.task-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    transition: background 0.15s ease;
}

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

.task-checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 11px;
    color: transparent;
    transition: all 0.15s ease;
    margin-top: 1px;
}

.task-checkbox:hover {
    border-color: var(--accent);
}

.task-checkbox.checked {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

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

.task-title {
    font-size: var(--font-base);
    font-weight: 500;
    color: var(--text-primary);
}

.task-title.completed {
    color: var(--text-muted);
    text-decoration: line-through;
}

.task-meta {
    font-size: var(--font-xs);
    color: var(--text-muted);
    margin-top: 2px;
}

.task-delete {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-1);
    font-size: var(--font-sm);
    transition: all 0.15s ease;
}

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

.task-delete:hover {
    color: var(--danger);
}

/* ============== HABITS ============== */
.habit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-4);
}

.habit-card {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.habit-check {
    width: 40px;
    height: 40px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: var(--font-sm);
    color: transparent;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.habit-check:hover {
    border-color: var(--success);
}

.habit-check.completed {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.habit-info {
    flex: 1;
}

.habit-name {
    font-size: var(--font-base);
    font-weight: 500;
}

.habit-streak {
    font-size: var(--font-sm);
    color: var(--text-muted);
    margin-top: 2px;
}

/* ============== CALENDAR ============== */
.calendar-nav {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

#calendar-month {
    font-size: var(--font-base);
    font-weight: 500;
    min-width: 140px;
    text-align: center;
}

.calendar-grid {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
}

.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    margin-bottom: var(--space-2);
}

.calendar-day-name {
    text-align: center;
    font-size: var(--font-xs);
    font-weight: 500;
    color: var(--text-muted);
    padding: var(--space-2);
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-sm);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s ease;
}

.calendar-day:hover {
    background: var(--bg-tertiary);
}

.calendar-day.today {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 600;
}

.calendar-day.selected {
    background: var(--accent);
    color: white;
}

.calendar-day.other-month {
    color: var(--text-muted);
}

.day-events {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-4);
}

.day-events h3 {
    font-size: var(--font-sm);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-4);
}

/* ============== EVENTS ============== */
.event-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-2);
    border-left: 3px solid var(--accent);
}

.event-time {
    font-size: var(--font-sm);
    font-weight: 600;
    color: var(--accent);
    min-width: 45px;
}

.event-content {
    flex: 1;
}

.event-title {
    font-size: var(--font-base);
    font-weight: 500;
}

.event-desc {
    font-size: var(--font-sm);
    color: var(--text-secondary);
    margin-top: 2px;
}

.event-item-small {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-2);
}

.event-time-small {
    font-size: var(--font-xs);
    font-weight: 600;
    color: var(--accent);
    min-width: 40px;
}

.event-desc-small {
    font-size: var(--font-xs);
    color: var(--text-muted);
    margin-top: 2px;
}

/* ============== FINANCE ============== */
.finance-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

.summary-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-4);
}

.summary-label {
    font-size: var(--font-xs);
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: var(--space-2);
}

.summary-value {
    font-size: var(--font-lg);
    font-weight: 600;
}

.summary-value.income {
    color: var(--success);
}

.summary-value.expense {
    color: var(--danger);
}

.summary-value.balance {
    color: var(--text-primary);
}

.transaction-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.transaction-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.transaction-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-sm);
    font-weight: 600;
}

.transaction-icon.income {
    background: var(--success-light);
    color: var(--success);
}

.transaction-icon.expense {
    background: var(--danger-light);
    color: var(--danger);
}

.transaction-info {
    flex: 1;
}

.transaction-desc {
    font-size: var(--font-base);
    font-weight: 500;
}

.transaction-date {
    font-size: var(--font-xs);
    color: var(--text-muted);
}

.transaction-amount {
    font-size: var(--font-base);
    font-weight: 600;
}

.transaction-amount.income {
    color: var(--success);
}

.transaction-amount.expense {
    color: var(--danger);
}

/* Period bar */
.finance-period-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
    flex-wrap: wrap;
    gap: var(--space-3);
}

.period-toggle {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 3px;
}

.period-btn {
    padding: 6px 16px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
    font-size: var(--font-sm);
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.15s ease;
}

.period-btn.active {
    background: var(--accent);
    color: white;
}

.period-nav {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.period-arrow {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    background: var(--bg-secondary);
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    transition: all 0.15s ease;
}

.period-arrow:hover {
    background: var(--bg-hover);
}

#finance-period-label {
    font-weight: 600;
    font-size: var(--font-base);
    min-width: 140px;
    text-align: center;
}

.summary-sub {
    font-size: var(--font-xs);
    color: var(--text-muted);
    margin-top: 2px;
}

/* Category breakdown */
.category-breakdown {
    margin-bottom: var(--space-5);
}

.category-breakdown-title {
    font-size: var(--font-sm);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: var(--space-3);
}

.category-bar-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 5px 0;
}

.category-bar-emoji {
    font-size: 16px;
    width: 22px;
    text-align: center;
}

.category-bar-name {
    min-width: 90px;
    font-size: var(--font-sm);
    font-weight: 500;
}

.category-bar-track {
    flex: 1;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    min-width: 50px;
}

.category-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--danger);
    transition: width 0.4s ease;
}

.category-bar-amount {
    min-width: 70px;
    text-align: right;
    font-weight: 600;
    font-size: var(--font-sm);
}

.category-bar-percent {
    min-width: 36px;
    text-align: right;
    color: var(--text-muted);
    font-size: var(--font-xs);
}

/* Transaction day headers */
.transaction-day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-2) 0;
    border-bottom: 2px solid var(--border-color);
    margin-top: var(--space-4);
    font-weight: 600;
    font-size: var(--font-sm);
    color: var(--text-muted);
}

.transaction-day-header:first-child {
    margin-top: 0;
}

.transaction-day-sum {
    font-weight: 600;
}

.transaction-day-sum.positive {
    color: var(--success);
}

.transaction-day-sum.negative {
    color: var(--danger);
}

.recurring-indicator {
    font-size: 12px;
    color: var(--accent);
    margin-left: 4px;
}

/* Recurring section */
.recurring-section {
    margin-top: var(--space-6);
    border-top: 2px solid var(--border-color);
    padding-top: var(--space-4);
}

.recurring-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
}

.recurring-title {
    font-size: var(--font-base);
    font-weight: 600;
}

.recurring-summary {
    display: flex;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
    font-size: var(--font-sm);
    flex-wrap: wrap;
}

.recurring-summary-item {
    padding: var(--space-2) var(--space-3);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.recurring-summary-item.income {
    border-left: 3px solid var(--success);
}

.recurring-summary-item.expense {
    border-left: 3px solid var(--danger);
}

.recurring-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-2);
}

.recurring-item-emoji {
    font-size: 20px;
    width: 32px;
    text-align: center;
}

.recurring-item-info {
    flex: 1;
}

.recurring-item-desc {
    font-weight: 500;
    font-size: var(--font-sm);
}

.recurring-item-freq {
    font-size: var(--font-xs);
    color: var(--text-muted);
}

.recurring-item-amount {
    font-weight: 600;
    font-size: var(--font-base);
}

.recurring-item-amount.income {
    color: var(--success);
}

.recurring-item-amount.expense {
    color: var(--danger);
}

/* Emoji picker for categories */
.emoji-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: var(--space-2);
}

.emoji-option {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    background: var(--bg-tertiary);
}

.emoji-option:hover {
    border-color: var(--border-color);
    transform: scale(1.1);
}

.emoji-option.selected {
    border-color: var(--accent);
    background: var(--accent-light);
}

/* ============== DIARY ============== */
.diary-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.diary-entry {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-4);
}

.diary-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.diary-mood {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-xs);
    font-weight: 600;
    background: var(--bg-tertiary);
}

.diary-date {
    font-size: var(--font-sm);
    color: var(--text-muted);
}

.diary-content {
    font-size: var(--font-base);
    line-height: 1.6;
    white-space: pre-wrap;
}

/* ============== REMINDERS ============== */
.reminder-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.reminder-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.reminder-icon {
    width: 36px;
    height: 36px;
    background: var(--accent-light);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-xs);
    font-weight: 600;
    color: var(--accent);
}

.reminder-info {
    flex: 1;
}

.reminder-title {
    font-size: var(--font-base);
    font-weight: 500;
}

.reminder-time {
    font-size: var(--font-xs);
    color: var(--text-muted);
}

/* ============== STRUKTURYZATOR ============== */
.structures-layout {
    display: flex;
    gap: var(--space-5);
    height: calc(100vh - 140px);
}

.structures-sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    overflow-y: auto;
    flex-shrink: 0;
    position: relative;
    transition: width 0.2s ease, padding 0.2s ease;
}

/* Strukturyzator sidebar collapse */
.struct-sidebar-collapse {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 11px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    z-index: 2;
}
.struct-sidebar-collapse:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.structures-sidebar.collapsed {
    width: 40px;
    padding: 8px 2px;
    overflow-x: hidden;
    overflow-y: auto;
}
.structures-sidebar.collapsed .sidebar-header,
.structures-sidebar.collapsed .sidebar-divider,
.structures-sidebar.collapsed h3,
.structures-sidebar.collapsed .structure-item-meta,
.structures-sidebar.collapsed .structure-item-color,
.structures-sidebar.collapsed .btn-delete-small,
.structures-sidebar.collapsed .schema-name,
.structures-sidebar.collapsed .schema-del,
.structures-sidebar.collapsed .btn-icon,
.structures-sidebar.collapsed .empty-state,
.structures-sidebar.collapsed .ws-structures-label {
    display: none !important;
}
.structures-sidebar.collapsed .struct-sidebar-collapse {
    position: static;
    transform: rotate(180deg);
    margin: 0 auto 6px;
}
/* Items show as single-letter circles */
.structures-sidebar.collapsed .structure-item,
.structures-sidebar.collapsed .struct-schema-item {
    padding: 0;
    margin: 2px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: auto;
    border: none;
    background: none;
}
.structures-sidebar.collapsed .structure-item-title {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    background: var(--bg-tertiary);
    overflow: hidden;
    text-overflow: clip;
    white-space: nowrap;
    color: var(--text-primary);
}
.structures-sidebar.collapsed .structure-item:hover .structure-item-title,
.structures-sidebar.collapsed .struct-schema-item:hover .schema-icon {
    background: var(--primary);
    color: #fff;
}
.structures-sidebar.collapsed .struct-schema-item .schema-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    border-radius: 6px;
    background: var(--bg-tertiary);
}
/* Collapsed sidebar sections still visible */
.structures-sidebar.collapsed .sidebar-section {
    padding: 0;
    margin: 0;
}
.structures-sidebar.collapsed .structures-list,
.structures-sidebar.collapsed .main-problems-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

/* Initial letter - hidden when expanded, visible when collapsed */
.struct-initial { display: none; }
.structures-sidebar.collapsed .struct-initial { display: inline !important; }
.structures-sidebar.collapsed .struct-full-title { display: none !important; }

.structures-sidebar h3 {
    font-size: var(--font-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-4);
}

.structures-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.structure-item {
    padding: var(--space-3);
    padding-left: var(--space-4);
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
    border-left: 4px solid var(--border-color);
}

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

.structure-item.active {
    background: var(--accent-light);
    border-left-color: var(--accent);
}

/* Kolorowy pasek dla głównych problemów */
.main-problem-item[data-color="1"] { border-left-color: var(--branch-1); }
.main-problem-item[data-color="2"] { border-left-color: var(--branch-2); }
.main-problem-item[data-color="3"] { border-left-color: var(--branch-3); }
.main-problem-item[data-color="4"] { border-left-color: var(--branch-4); }
.main-problem-item[data-color="5"] { border-left-color: var(--branch-5); }
.main-problem-item[data-color="6"] { border-left-color: var(--branch-6); }
.main-problem-item[data-color="7"] { border-left-color: var(--branch-7); }
.main-problem-item[data-color="8"] { border-left-color: var(--branch-8); }
.main-problem-item[data-color="9"] { border-left-color: var(--branch-9); }
.main-problem-item[data-color="10"] { border-left-color: var(--branch-10); }
.main-problem-item[data-color="11"] { border-left-color: var(--branch-11); }
.main-problem-item[data-color="12"] { border-left-color: var(--branch-12); }

.main-problem-item.active[data-color="1"] { background: rgba(99, 102, 241, 0.1); }
.main-problem-item.active[data-color="2"] { background: rgba(236, 72, 153, 0.1); }
.main-problem-item.active[data-color="3"] { background: rgba(245, 158, 11, 0.1); }
.main-problem-item.active[data-color="4"] { background: rgba(16, 185, 129, 0.1); }
.main-problem-item.active[data-color="5"] { background: rgba(59, 130, 246, 0.1); }
.main-problem-item.active[data-color="6"] { background: rgba(139, 92, 246, 0.1); }
.main-problem-item.active[data-color="7"] { background: rgba(239, 68, 68, 0.1); }
.main-problem-item.active[data-color="8"] { background: rgba(20, 184, 166, 0.1); }
.main-problem-item.active[data-color="9"] { background: rgba(249, 115, 22, 0.1); }
.main-problem-item.active[data-color="10"] { background: rgba(6, 182, 212, 0.1); }
.main-problem-item.active[data-color="11"] { background: rgba(132, 204, 22, 0.1); }
.main-problem-item.active[data-color="12"] { background: rgba(225, 29, 72, 0.1); }

.structure-item-title {
    font-size: var(--font-sm);
    font-weight: 500;
    padding-right: 24px;
}

.structure-item-meta {
    font-size: var(--font-xs);
    color: var(--text-muted);
    margin-top: 2px;
}

.btn-delete-small {
    position: absolute;
    right: var(--space-2);
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: var(--font-xs);
    padding: var(--space-1);
    opacity: 0;
    transition: all 0.15s ease;
}

.structure-item:hover .btn-delete-small {
    opacity: 1;
}

.btn-delete-small:hover {
    color: var(--danger);
}

.structures-main {
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-5);
    overflow: auto;
}

.structure-view {
    min-height: 100%;
}

/* Tree - Horizontal Layout */
.tree-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-6) var(--space-4);
    min-height: 300px;
}

.tree-root {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.tree-node-box {
    padding: var(--space-3) var(--space-5);
    background: var(--bg-tertiary);
    border: 3px solid var(--border-color);
    border-radius: var(--radius-md);
    min-width: 120px;
    max-width: 180px;
    text-align: center;
    position: relative;
    cursor: pointer;
    transition: all 0.15s ease;
}

.tree-node-box:hover {
    background: var(--bg-hover);
}

.tree-node-box.root {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    font-weight: 600;
    min-width: 160px;
}

.tree-node-box.completed {
    background: var(--success-light);
    border-color: var(--success);
}

.tree-node-box.completed .tree-node-text {
    text-decoration: line-through;
    color: var(--text-muted);
}

.tree-node-box.root.completed {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.tree-node-box.root.completed .tree-node-text {
    color: white;
}

.tree-node-text {
    font-size: var(--font-sm);
    word-break: break-word;
}

/* Branch colors - border + colored background */
.tree-node-box[data-color="1"] { border-color: var(--branch-1); background: rgba(99, 102, 241, 0.12); }
.tree-node-box[data-color="2"] { border-color: var(--branch-2); background: rgba(236, 72, 153, 0.12); }
.tree-node-box[data-color="3"] { border-color: var(--branch-3); background: rgba(245, 158, 11, 0.12); }
.tree-node-box[data-color="4"] { border-color: var(--branch-4); background: rgba(16, 185, 129, 0.12); }
.tree-node-box[data-color="5"] { border-color: var(--branch-5); background: rgba(59, 130, 246, 0.12); }
.tree-node-box[data-color="6"] { border-color: var(--branch-6); background: rgba(139, 92, 246, 0.12); }
.tree-node-box[data-color="7"] { border-color: var(--branch-7); background: rgba(239, 68, 68, 0.12); }
.tree-node-box[data-color="8"] { border-color: var(--branch-8); background: rgba(20, 184, 166, 0.12); }
.tree-node-box[data-color="9"] { border-color: var(--branch-9); background: rgba(249, 115, 22, 0.12); }
.tree-node-box[data-color="10"] { border-color: var(--branch-10); background: rgba(6, 182, 212, 0.12); }
.tree-node-box[data-color="11"] { border-color: var(--branch-11); background: rgba(132, 204, 22, 0.12); }
.tree-node-box[data-color="12"] { border-color: var(--branch-12); background: rgba(225, 29, 72, 0.12); }

.tree-node-box[data-color="1"]:hover { background: rgba(99, 102, 241, 0.2); }
.tree-node-box[data-color="2"]:hover { background: rgba(236, 72, 153, 0.2); }
.tree-node-box[data-color="3"]:hover { background: rgba(245, 158, 11, 0.2); }
.tree-node-box[data-color="4"]:hover { background: rgba(16, 185, 129, 0.2); }
.tree-node-box[data-color="5"]:hover { background: rgba(59, 130, 246, 0.2); }
.tree-node-box[data-color="6"]:hover { background: rgba(139, 92, 246, 0.2); }
.tree-node-box[data-color="7"]:hover { background: rgba(239, 68, 68, 0.2); }
.tree-node-box[data-color="8"]:hover { background: rgba(20, 184, 166, 0.2); }
.tree-node-box[data-color="9"]:hover { background: rgba(249, 115, 22, 0.2); }
.tree-node-box[data-color="10"]:hover { background: rgba(6, 182, 212, 0.2); }
.tree-node-box[data-color="11"]:hover { background: rgba(132, 204, 22, 0.2); }
.tree-node-box[data-color="12"]:hover { background: rgba(225, 29, 72, 0.2); }

.tree-node-box[data-color="1"].completed { background: rgba(99, 102, 241, 0.25); }
.tree-node-box[data-color="2"].completed { background: rgba(236, 72, 153, 0.25); }
.tree-node-box[data-color="3"].completed { background: rgba(245, 158, 11, 0.25); }
.tree-node-box[data-color="4"].completed { background: rgba(16, 185, 129, 0.25); }
.tree-node-box[data-color="5"].completed { background: rgba(59, 130, 246, 0.25); }
.tree-node-box[data-color="6"].completed { background: rgba(139, 92, 246, 0.25); }
.tree-node-box[data-color="7"].completed { background: rgba(239, 68, 68, 0.25); }
.tree-node-box[data-color="8"].completed { background: rgba(20, 184, 166, 0.25); }
.tree-node-box[data-color="9"].completed { background: rgba(6, 182, 212, 0.25); }
.tree-node-box[data-color="10"].completed { background: rgba(6, 182, 212, 0.25); }
.tree-node-box[data-color="11"].completed { background: rgba(132, 204, 22, 0.25); }
.tree-node-box[data-color="12"].completed { background: rgba(225, 29, 72, 0.25); }

.btn-delete-node {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 18px;
    height: 18px;
    border-radius: var(--radius-full);
    background: var(--danger);
    color: white;
    border: none;
    font-size: 10px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tree-node-box:hover .btn-delete-node,
.tree-node:hover > .tree-node-box .btn-delete-node {
    opacity: 1;
}

.btn-add-branch {
    position: absolute;
    right: -28px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    border: 1px dashed var(--border-color);
    color: var(--text-muted);
    font-size: var(--font-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    z-index: 10;
}

.tree-node-box:hover .btn-add-branch,
.btn-add-branch:hover {
    opacity: 1;
}

.btn-add-branch:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.tree-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.tree-root {
    position: relative;
}

/* Kontener dzieci - układ poziomy z połączeniami */
.tree-children {
    display: flex;
    justify-content: center;
    gap: var(--space-4);
    margin-top: 40px; /* Przestrzeń na linie: 20px w dół + 20px w górę */
    position: relative;
    padding-top: 0;
}

/* ========== LINIE DRZEWA - KOLOROWE ========== */

/*
   Struktura linii:

       [Rodzic]
           |        <- ::after na rodzicu (pionowa w dół)
       ----+----    <- ::before na .tree-children (pozioma)
       |   |   |    <- ::before na każdym dziecku (pionowa w górę)
      [A] [B] [C]
*/

/* 1. Linia PIONOWA W DÓŁ od ROOT - NEUTRALNA */
.tree-root.has-children > .tree-node-box::after {
    content: '';
    position: absolute;
    bottom: -21px;
    left: 50%;
    width: 3px;
    height: 21px;
    transform: translateX(-50%);
    border-radius: 0 0 6px 6px;
    background: var(--border-color);
}

/* 1b. Linia PIONOWA W DÓŁ od węzła do jego dzieci - KOLOROWA */
.tree-node.has-children > .tree-node-box::after {
    content: '';
    position: absolute;
    bottom: -21px;
    left: 50%;
    width: 3px;
    height: 21px;
    transform: translateX(-50%);
    border-radius: 0 0 6px 6px;
    background: var(--text-muted);
}

/* 2. Linia POZIOMA łącząca dzieci - NEUTRALNA (szara) */
.tree-children::before {
    content: '';
    position: absolute;
    top: -21px;
    height: 3px;
    border-radius: 6px;
    background: var(--border-color);
    left: var(--h-line-left, 50%);
    width: var(--h-line-width, 0px);
    transform: none;
}

/* 3. Linia PIONOWA W GÓRĘ od dziecka - KOLOROWA z zaokrągleniem */
.tree-children > .tree-node::before {
    content: '';
    position: absolute;
    top: -21px;
    left: 50%;
    width: 3px;
    height: 21px;
    transform: translateX(-50%);
    border-radius: 6px 6px 0 0;
    background: var(--text-muted);
}

/* 4. Kropka/węzeł na połączeniu - pokazuje rozgałęzienie */
.tree-children > .tree-node::after {
    content: '';
    position: absolute;
    top: -23px;
    left: 50%;
    width: 8px;
    height: 8px;
    transform: translateX(-50%);
    border-radius: 50%;
    background: var(--text-muted);
    border: 2px solid var(--bg-secondary);
    z-index: 5;
}

/* ===== KOLORY - linia pionowa w dół od węzła (NIE od root) ===== */
/* Root ma neutralną linię w dół, ale węzły wewnętrzne mają kolorowe */
.tree-node.has-children > .tree-node-box[data-color="1"]::after { background: var(--branch-1) !important; }
.tree-node.has-children > .tree-node-box[data-color="2"]::after { background: var(--branch-2) !important; }
.tree-node.has-children > .tree-node-box[data-color="3"]::after { background: var(--branch-3) !important; }
.tree-node.has-children > .tree-node-box[data-color="4"]::after { background: var(--branch-4) !important; }
.tree-node.has-children > .tree-node-box[data-color="5"]::after { background: var(--branch-5) !important; }
.tree-node.has-children > .tree-node-box[data-color="6"]::after { background: var(--branch-6) !important; }
.tree-node.has-children > .tree-node-box[data-color="7"]::after { background: var(--branch-7) !important; }
.tree-node.has-children > .tree-node-box[data-color="8"]::after { background: var(--branch-8) !important; }
.tree-node.has-children > .tree-node-box[data-color="9"]::after { background: var(--branch-9) !important; }
.tree-node.has-children > .tree-node-box[data-color="10"]::after { background: var(--branch-10) !important; }
.tree-node.has-children > .tree-node-box[data-color="11"]::after { background: var(--branch-11) !important; }
.tree-node.has-children > .tree-node-box[data-color="12"]::after { background: var(--branch-12) !important; }

/* ===== KOLORY - linia pionowa w górę od dziecka ===== */
.tree-children > .tree-node[data-line-color="1"]::before { background: var(--branch-1) !important; }
.tree-children > .tree-node[data-line-color="2"]::before { background: var(--branch-2) !important; }
.tree-children > .tree-node[data-line-color="3"]::before { background: var(--branch-3) !important; }
.tree-children > .tree-node[data-line-color="4"]::before { background: var(--branch-4) !important; }
.tree-children > .tree-node[data-line-color="5"]::before { background: var(--branch-5) !important; }
.tree-children > .tree-node[data-line-color="6"]::before { background: var(--branch-6) !important; }
.tree-children > .tree-node[data-line-color="7"]::before { background: var(--branch-7) !important; }
.tree-children > .tree-node[data-line-color="8"]::before { background: var(--branch-8) !important; }
.tree-children > .tree-node[data-line-color="9"]::before { background: var(--branch-9) !important; }
.tree-children > .tree-node[data-line-color="10"]::before { background: var(--branch-10) !important; }
.tree-children > .tree-node[data-line-color="11"]::before { background: var(--branch-11) !important; }
.tree-children > .tree-node[data-line-color="12"]::before { background: var(--branch-12) !important; }

/* ===== KOLORY - kropka na połączeniu (taki sam kolor jak gałąź) ===== */
.tree-children > .tree-node[data-line-color="1"]::after { background: var(--branch-1) !important; }
.tree-children > .tree-node[data-line-color="2"]::after { background: var(--branch-2) !important; }
.tree-children > .tree-node[data-line-color="3"]::after { background: var(--branch-3) !important; }
.tree-children > .tree-node[data-line-color="4"]::after { background: var(--branch-4) !important; }
.tree-children > .tree-node[data-line-color="5"]::after { background: var(--branch-5) !important; }
.tree-children > .tree-node[data-line-color="6"]::after { background: var(--branch-6) !important; }
.tree-children > .tree-node[data-line-color="7"]::after { background: var(--branch-7) !important; }
.tree-children > .tree-node[data-line-color="8"]::after { background: var(--branch-8) !important; }
.tree-children > .tree-node[data-line-color="9"]::after { background: var(--branch-9) !important; }
.tree-children > .tree-node[data-line-color="10"]::after { background: var(--branch-10) !important; }
.tree-children > .tree-node[data-line-color="11"]::after { background: var(--branch-11) !important; }
.tree-children > .tree-node[data-line-color="12"]::after { background: var(--branch-12) !important; }

/* Linia pozioma jest ZAWSZE neutralna (szara) - nie kolorowa */
/* Dzięki temu widać wyraźnie osobne kolorowe gałęzie */

/* Color picker */
.color-picker {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-2);
}

.color-option {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.selected {
    border-color: var(--text-primary);
}

.color-option[data-color="1"] { background: var(--branch-1); }
.color-option[data-color="2"] { background: var(--branch-2); }
.color-option[data-color="3"] { background: var(--branch-3); }
.color-option[data-color="4"] { background: var(--branch-4); }
.color-option[data-color="5"] { background: var(--branch-5); }
.color-option[data-color="6"] { background: var(--branch-6); }
.color-option[data-color="7"] { background: var(--branch-7); }
.color-option[data-color="8"] { background: var(--branch-8); }
.color-option[data-color="9"] { background: var(--branch-9); }
.color-option[data-color="10"] { background: var(--branch-10); }
.color-option[data-color="11"] { background: var(--branch-11); }
.color-option[data-color="12"] { background: var(--branch-12); }

.color-picker-large {
    justify-content: center;
    gap: var(--space-3);
    max-width: 300px;
}

.color-picker-large .color-option {
    width: 36px;
    height: 36px;
}

/* Color dot indicator on branch */
.color-dot {
    position: absolute;
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: transform 0.15s ease;
    border: 2px solid var(--bg-secondary);
}

.color-dot:hover {
    transform: translateY(-50%) scale(1.2);
}

.color-dot[data-color="1"] { background: var(--branch-1); }
.color-dot[data-color="2"] { background: var(--branch-2); }
.color-dot[data-color="3"] { background: var(--branch-3); }
.color-dot[data-color="4"] { background: var(--branch-4); }
.color-dot[data-color="5"] { background: var(--branch-5); }
.color-dot[data-color="6"] { background: var(--branch-6); }
.color-dot[data-color="7"] { background: var(--branch-7); }
.color-dot[data-color="8"] { background: var(--branch-8); }
.color-dot[data-color="9"] { background: var(--branch-9); }
.color-dot[data-color="10"] { background: var(--branch-10); }
.color-dot[data-color="11"] { background: var(--branch-11); }
.color-dot[data-color="12"] { background: var(--branch-12); }

/* ============== SIDEBAR SECTIONS ============== */
.sidebar-section {
    margin-bottom: var(--space-3);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
}

.sidebar-header h3 {
    margin: 0;
}

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

.ws-structures-label {
    color: var(--accent) !important;
    font-size: var(--font-xs) !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ws-structure-item {
    border-left: 3px solid var(--accent);
}

.btn-icon {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    background: var(--accent);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--accent-hover);
}

/* ============== MAIN PROBLEMS (Sieć Powiązań) ============== */
.main-problems-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

/* Node pin badge */
.pin-badge {
    position: absolute;
    top: -6px;
    left: -6px;
    font-size: 10px;
    cursor: pointer;
}

/* Weight badge (I, II, III) */
.weight-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 9px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    z-index: 5;
}

.weight-badge.weight-1 {
    background: var(--danger); /* Czerwony - najważniejsze */
}

.weight-badge.weight-2 {
    background: var(--branch-3); /* Pomarańczowy - średnie */
}

.weight-badge.weight-3 {
    background: var(--text-muted); /* Szary - najmniej ważne */
}

/* Weight picker in modal */
.weight-picker {
    display: flex;
    gap: var(--space-2);
}

.weight-option {
    width: 40px;
    height: 36px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.15s ease;
    background: var(--bg-tertiary);
}

.weight-option:hover {
    border-color: var(--accent);
}

.weight-option.selected {
    border-color: var(--accent);
    background: var(--accent);
    color: white;
}

.weight-option[data-weight="1"].selected {
    background: var(--danger);
    border-color: var(--danger);
}

.weight-option[data-weight="2"].selected {
    background: var(--branch-3);
    border-color: var(--branch-3);
}

.weight-option[data-weight="3"].selected {
    background: var(--text-muted);
    border-color: var(--text-muted);
}

/* ============== PROBLEM VIEW ============== */
.problem-view {
    padding: var(--space-4);
}

.problem-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
    border-left: 5px solid;
}

.problem-header[data-color="1"] { background: rgba(99, 102, 241, 0.1); border-left-color: var(--branch-1); }
.problem-header[data-color="2"] { background: rgba(236, 72, 153, 0.1); border-left-color: var(--branch-2); }
.problem-header[data-color="3"] { background: rgba(245, 158, 11, 0.1); border-left-color: var(--branch-3); }
.problem-header[data-color="4"] { background: rgba(16, 185, 129, 0.1); border-left-color: var(--branch-4); }
.problem-header[data-color="5"] { background: rgba(59, 130, 246, 0.1); border-left-color: var(--branch-5); }
.problem-header[data-color="6"] { background: rgba(139, 92, 246, 0.1); border-left-color: var(--branch-6); }
.problem-header[data-color="7"] { background: rgba(239, 68, 68, 0.1); border-left-color: var(--branch-7); }
.problem-header[data-color="8"] { background: rgba(20, 184, 166, 0.1); border-left-color: var(--branch-8); }
.problem-header[data-color="9"] { background: rgba(249, 115, 22, 0.1); border-left-color: var(--branch-9); }
.problem-header[data-color="10"] { background: rgba(6, 182, 212, 0.1); border-left-color: var(--branch-10); }
.problem-header[data-color="11"] { background: rgba(132, 204, 22, 0.1); border-left-color: var(--branch-11); }
.problem-header[data-color="12"] { background: rgba(225, 29, 72, 0.1); border-left-color: var(--branch-12); }

.problem-header h2 {
    margin: 0;
    font-size: var(--font-lg);
}

.problem-pins-list h3 {
    font-size: var(--font-sm);
    color: var(--text-muted);
    margin-bottom: var(--space-3);
}

.pin-card {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-2);
    border-left: 3px solid;
    position: relative;
}

.pin-card[data-color="1"] { border-left-color: var(--branch-1); }
.pin-card[data-color="2"] { border-left-color: var(--branch-2); }
.pin-card[data-color="3"] { border-left-color: var(--branch-3); }
.pin-card[data-color="4"] { border-left-color: var(--branch-4); }
.pin-card[data-color="5"] { border-left-color: var(--branch-5); }
.pin-card[data-color="6"] { border-left-color: var(--branch-6); }
.pin-card[data-color="7"] { border-left-color: var(--branch-7); }
.pin-card[data-color="8"] { border-left-color: var(--branch-8); }
.pin-card[data-color="9"] { border-left-color: var(--branch-9); }
.pin-card[data-color="10"] { border-left-color: var(--branch-10); }
.pin-card[data-color="11"] { border-left-color: var(--branch-11); }
.pin-card[data-color="12"] { border-left-color: var(--branch-12); }

.pin-card-icon {
    font-size: var(--font-lg);
}

.pin-card-content {
    flex: 1;
}

.pin-card-title {
    font-weight: 500;
}

.pin-card-meta {
    font-size: var(--font-xs);
    color: var(--text-muted);
    margin-top: 2px;
}

.pin-card .btn-delete-small {
    position: static;
    transform: none;
    opacity: 0;
}

.pin-card:hover .btn-delete-small {
    opacity: 1;
}

/* Pin source info in tree view */
.pin-source {
    display: block;
    font-size: var(--font-xs);
    color: var(--text-muted);
    margin-top: 2px;
}

/* ============== CONNECTION MODE ============== */
.header-buttons {
    display: flex;
    gap: var(--space-2);
}

#connection-mode-btn.active {
    background: var(--accent);
    color: white;
}

.tree-node-box.connection-source {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(99, 102, 241, 0); }
}

.tree-node-box.connection-target {
    cursor: crosshair;
}

.tree-node-box.connection-target:hover {
    outline: 2px dashed var(--accent);
    outline-offset: 2px;
}

.connection-mode-hint {
    text-align: center;
    padding: var(--space-3);
    background: var(--accent-light);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
    font-size: var(--font-sm);
    color: var(--accent);
}

/* ============== SVG CONNECTIONS ============== */
.tree-container {
    position: relative;
}

.connections-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.connections-svg path {
    pointer-events: stroke;
    cursor: pointer;
}

.connection-line {
    fill: none;
    stroke-linecap: round;
}

.connection-line[data-color="1"] { stroke: var(--branch-1); }
.connection-line[data-color="2"] { stroke: var(--branch-2); }
.connection-line[data-color="3"] { stroke: var(--branch-3); }
.connection-line[data-color="4"] { stroke: var(--branch-4); }
.connection-line[data-color="5"] { stroke: var(--branch-5); }
.connection-line[data-color="6"] { stroke: var(--branch-6); }
.connection-line[data-color="7"] { stroke: var(--branch-7); }
.connection-line[data-color="8"] { stroke: var(--branch-8); }
.connection-line[data-color="9"] { stroke: var(--branch-9); }
.connection-line[data-color="10"] { stroke: var(--branch-10); }
.connection-line[data-color="11"] { stroke: var(--branch-11); }
.connection-line[data-color="12"] { stroke: var(--branch-12); }

.connection-line[data-strength="1"] { stroke-width: 2px; }
.connection-line[data-strength="2"] { stroke-width: 3.5px; }
.connection-line[data-strength="3"] { stroke-width: 5px; }

.connection-line:hover {
    filter: brightness(1.2);
    stroke-width: 5px !important;
}

.connection-line.selected {
    stroke-dasharray: 5, 3;
    animation: dashMove 0.5s linear infinite;
}

@keyframes dashMove {
    to { stroke-dashoffset: -8; }
}

.connection-label {
    font-size: 10px;
    fill: var(--text-muted);
    pointer-events: none;
}

/* Connection arrowhead markers */
.connections-svg marker path {
    fill: inherit;
}

/* Context menu for nodes */
.context-menu {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1001;
    min-width: 180px;
    padding: var(--space-2) 0;
}

.context-menu-item {
    padding: var(--space-2) var(--space-4);
    cursor: pointer;
    font-size: var(--font-sm);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.context-menu-item:hover {
    background: var(--bg-hover);
}

.context-menu-divider {
    height: 1px;
    background: var(--border-light);
    margin: var(--space-2) 0;
}

.context-menu-submenu {
    padding-left: var(--space-4);
}

.context-menu-submenu .context-menu-item {
    font-size: var(--font-xs);
}

/* Btn small */
.btn-sm,
.btn-small {
    padding: var(--space-1) var(--space-2);
    font-size: var(--font-xs);
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: white;
    border: none;
    cursor: pointer;
}

.btn-sm:hover,
.btn-small:hover {
    background: var(--accent-hover);
}

/* ============== SETTINGS ============== */
.settings-content {
    max-width: 480px;
}

/* Profile settings page */
.settings-profile-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    max-width: 600px;
}
.settings-profile-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 600;
    flex-shrink: 0;
}
.settings-profile-name {
    font-size: var(--font-lg);
    font-weight: 600;
    color: var(--text-primary);
}
.settings-profile-email {
    font-size: var(--font-sm);
    color: var(--text-secondary);
    margin-top: 2px;
}
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
    max-width: 600px;
}
.settings-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
}
.settings-card-wide {
    grid-column: 1 / -1;
    max-width: 400px;
}
.settings-card-title {
    font-size: var(--font-sm);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}
.settings-card .setting-item .input {
    width: 100%;
    max-width: 260px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: var(--font-sm);
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--border-light);
}

.setting-item label {
    font-size: var(--font-base);
    font-weight: 500;
}

.setting-item select {
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: var(--font-sm);
}

/* ============== MODAL ============== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    max-width: 520px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-light);
}

.modal-header h2 {
    font-size: var(--font-md);
    font-weight: 600;
}

#modal-body {
    padding: var(--space-5);
}

/* ============== EMPTY STATE ============== */
.empty-state {
    text-align: center;
    padding: var(--space-6);
    color: var(--text-muted);
    font-size: var(--font-sm);
}

.empty-state-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto var(--space-3);
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-md);
    color: var(--text-muted);
}

/* ============== MOOD SELECTOR ============== */
.mood-selector {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-2);
}

.mood-option {
    cursor: pointer;
}

.mood-option input[type="radio"] {
    display: none;
}

.mood-label {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: var(--font-sm);
    border: 2px solid var(--border-color);
    transition: all 0.15s ease;
    background: var(--bg-tertiary);
}

.mood-option input[type="radio"]:checked + .mood-label {
    border-color: var(--accent);
    background: var(--accent);
    color: white;
}

/* ============== RESPONSIVE ============== */
@media (max-width: 900px) {
    .structures-layout {
        flex-direction: column;
        height: auto;
    }

    .structures-sidebar {
        width: 100%;
        max-height: 180px;
    }

    .finance-summary {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    #main-app {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .nav {
        display: flex;
        overflow-x: auto;
        padding: var(--space-2);
    }

    .nav-item {
        flex-direction: column;
        padding: var(--space-2) var(--space-3);
        font-size: var(--font-xs);
        min-width: max-content;
    }

    .sidebar-footer {
        display: flex;
        border-top: none;
        padding: var(--space-2);
    }

    .main {
        padding: var(--space-4);
    }

    .content-grid {
        grid-template-columns: 1fr;
    }
}

/* ============== WORKSPACE ============== */

.workspace-list {
    display: grid;
    gap: 12px;
}

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

.workspace-card:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

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

.workspace-card-header h3 {
    margin: 0;
    font-size: 1.1em;
}

.workspace-card-meta {
    display: flex;
    gap: 16px;
    color: var(--text-secondary);
    font-size: 0.85em;
    align-items: center;
}

.workspace-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.workspace-header h3 {
    margin: 0;
    flex: 1;
}

.workspace-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.workspace-tabs .btn.active {
    background: var(--accent);
    color: white;
}

.workspace-tab-content {
    min-height: 200px;
}

/* Online indicators */
.online-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #10B981;
    border-radius: 50%;
    margin-right: 4px;
    animation: pulse-online 2s ease-in-out infinite;
}

.offline-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    margin-right: 4px;
}

@keyframes pulse-online {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.online-indicators {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85em;
    color: #10B981;
}

/* Member list */
.member-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 8px;
}

.member-item .badge {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 0.75em;
    text-transform: uppercase;
}

.badge {
    background: var(--accent);
    color: white;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 0.75em;
}

/* Remote cursor indicator */
.remote-cursor {
    position: absolute;
    top: -20px;
    right: 4px;
    background: #8B5CF6;
    color: white;
    font-size: 0.65em;
    padding: 1px 6px;
    border-radius: 4px;
    white-space: nowrap;
    animation: fadeIn 0.2s ease;
    z-index: 10;
    pointer-events: none;
}

/* Toast notifications */
.toast-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 10000;
    font-size: 0.9em;
    max-width: 300px;
}

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

/* Small buttons */
.btn-xs {
    padding: 2px 8px;
    font-size: 0.75em;
    border-radius: 4px;
}

.btn-danger {
    background: var(--danger);
    color: white;
    border: none;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8em;
}

.btn-danger:hover {
    opacity: 0.9;
}

/* Structure items in workspace */
.workspace-tab-content .structure-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 8px;
}

.workspace-tab-content .structure-item:hover {
    border-color: var(--accent);
}

/* Workspace empty state */
.workspace-tab-content .empty-state {
    padding: 40px 20px;
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ============== NOTIFICATIONS ============== */

.notification-bell {
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 18px;
    color: var(--text-secondary);
    transition: color 0.2s;
}
.notification-bell:hover {
    color: var(--accent);
}
.notification-badge {
    position: absolute;
    top: -2px;
    right: 0;
    background: var(--danger);
    color: white;
    border-radius: 50%;
    min-width: 18px;
    height: 18px;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}
.notification-panel {
    position: absolute;
    top: 60px;
    left: 12px;
    right: 12px;
    max-width: 360px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
}
.notification-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-color);
}
.notification-panel-header h3 {
    font-size: var(--font-sm);
    margin: 0;
}
.btn-link {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: var(--font-xs);
    padding: 0;
}
.btn-link:hover { text-decoration: underline; }

.notification-list { padding: var(--space-2); }

.notification-item {
    padding: var(--space-3);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-2);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.15s;
}
.notification-item:hover { background: var(--bg-tertiary); }
.notification-item.unread {
    border-left: 3px solid var(--accent);
    background: var(--bg-tertiary);
}
.notification-item-title {
    font-size: var(--font-sm);
    font-weight: 600;
    margin-bottom: 4px;
}
.notification-item-message {
    font-size: var(--font-xs);
    color: var(--text-muted);
    margin-bottom: 6px;
}
.notification-item-time {
    font-size: 11px;
    color: var(--text-muted);
}
.notification-actions {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-2);
}
.notification-actions .btn {
    font-size: var(--font-xs);
    padding: 4px 12px;
}
.notification-empty {
    padding: var(--space-6);
    text-align: center;
    color: var(--text-muted);
    font-size: var(--font-sm);
}

/* Workspace notes */
.workspace-note {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-3);
}
.workspace-note-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
}
.workspace-note-title {
    font-weight: 600;
    font-size: var(--font-base);
}
.workspace-note-meta {
    font-size: var(--font-xs);
    color: var(--text-muted);
}
.workspace-note-content {
    font-size: var(--font-sm);
    color: var(--text-secondary);
    white-space: pre-wrap;
    line-height: 1.5;
}
.workspace-note-actions {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-2);
}

/* Member status badges */
.member-status-pending {
    font-size: 10px;
    background: var(--warning, #f59e0b);
    color: white;
    padding: 1px 6px;
    border-radius: 10px;
}
.member-status-declined {
    font-size: 10px;
    background: var(--danger);
    color: white;
    padding: 1px 6px;
    border-radius: 10px;
}

/* ============== PROJECTS ============== */

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

.project-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    cursor: pointer;
    transition: all 0.15s ease;
}

.project-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
}

.project-card-title {
    font-size: var(--font-md);
    font-weight: 600;
    margin-bottom: var(--space-2);
}

.project-card-desc {
    font-size: var(--font-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-3);
}

.project-card-progress {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.project-card-meta {
    display: flex;
    justify-content: space-between;
    margin-top: var(--space-2);
    font-size: var(--font-xs);
    color: var(--text-muted);
}

.project-card-status {
    text-transform: uppercase;
    font-size: var(--font-xs);
    font-weight: 500;
}

.status-active .project-card-status { color: var(--success); }
.status-done .project-card-status { color: var(--accent); }
.status-paused .project-card-status { color: var(--text-muted); }

/* Progress bars */
.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar.progress-sm {
    height: 4px;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
}

.progress-text {
    font-size: var(--font-sm);
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 36px;
    text-align: right;
}

.progress-text-sm {
    font-size: var(--font-xs);
    color: var(--text-muted);
    min-width: 30px;
}

/* Project detail */
.project-header {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
    flex-wrap: wrap;
}

.project-progress {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex: 1;
    min-width: 200px;
}

/* Project tree nodes */
.project-tree {
    padding: var(--space-2) 0;
}

.project-node {
    margin-bottom: var(--space-2);
}

.project-node-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
}

.project-node-header:hover {
    border-color: var(--border-color);
}

.node-content {
    flex: 1;
    font-size: var(--font-sm);
}

.node-label-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
}

.label-human { background: #dbeafe; color: #1d4ed8; }
.label-ai { background: #ede9fe; color: #7c3aed; }
.label-review { background: #fef3c7; color: #b45309; }
.label-done { background: var(--success-light); color: var(--success); }

[data-theme="dark"] .label-human { background: rgba(59,130,246,0.2); }
[data-theme="dark"] .label-ai { background: rgba(124,58,237,0.2); }
[data-theme="dark"] .label-review { background: rgba(180,83,9,0.2); }

.lock-badge {
    font-size: var(--font-xs);
}

.assign-badge {
    font-size: 10px;
    background: var(--accent-light);
    color: var(--accent);
    padding: 1px 6px;
    border-radius: var(--radius-full);
}

/* ============== Project Data Section (Map + Trees) ============== */

.project-data-section {
    margin: 0 0 var(--space-4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    overflow: hidden;
}

.pdata-tabs-bar {
    display: flex;
    gap: 0;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    padding: 0;
}

.pdata-tab {
    padding: 10px 18px;
    font-size: var(--font-sm);
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: color .15s, border-color .15s, background .15s;
}

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

.pdata-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: var(--bg-secondary);
}

.pdata-content {
    min-height: 200px;
}

/* Project Tasks */
.pdata-task-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--border-light);
    transition: background .15s;
}
.pdata-task-item:hover { background: var(--bg-hover); }
.pdata-task-item.done .pdata-task-title {
    text-decoration: line-through;
    color: var(--text-muted);
}
.pdata-task-check { flex-shrink: 0; cursor: pointer; }
.pdata-task-check input { width: 16px; height: 16px; cursor: pointer; }
.pdata-task-title { flex: 1; font-size: var(--font-sm); }
.pdata-task-del {
    opacity: 0;
    background: none;
    border: none;
    color: var(--danger);
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    transition: opacity .15s;
}
.pdata-task-item:hover .pdata-task-del { opacity: 0.6; }
.pdata-task-del:hover { opacity: 1 !important; }

.btn-icon-add {
    width: 22px; height: 22px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--accent);
    font-size: 14px; font-weight: 700;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 0; line-height: 1;
    opacity: 0; transition: opacity .15s;
    flex-shrink: 0;
}
.btn-icon-add:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
div:hover > .btn-icon-add { opacity: 1; }

/* Inline Map */
.pdata-map-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.pdata-map-container {
    height: clamp(400px, 65vh, calc(100vh - 260px));
    position: relative;
}

.pdata-map-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* Tree in project data */
.pdata-tree-panel {
    padding: var(--space-5);
}

.pdata-tree-header h2 {
    font-size: var(--font-lg);
    margin-bottom: var(--space-1);
}

.pdata-tree-header p {
    color: var(--text-muted);
    font-size: var(--font-sm);
    margin-bottom: var(--space-4);
}

.pdata-tree-content .tree-node-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.pdata-tree-content .tree-root > .tree-node-item {
    margin-bottom: var(--space-3);
}

.pdata-tree-content .tree-node-item {
    margin-bottom: var(--space-1);
}

.pdata-tree-content .tree-node-label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background .15s;
    font-size: var(--font-sm);
}

.pdata-tree-content .tree-node-label:hover {
    background: var(--bg-hover);
}

.pdata-tree-content .tree-toggle {
    font-size: 10px;
    transition: transform .2s;
    color: var(--text-muted);
}

.pdata-tree-content .tree-dot {
    color: var(--accent);
    font-size: 16px;
}

.pdata-tree-content .tree-node-item.collapsed > ul {
    display: none;
}

.pdata-tree-content .tree-node-item.collapsed .tree-toggle {
    transform: rotate(-90deg);
}

.pdata-tree-content .tree-node-list .tree-node-list {
    padding-left: var(--space-5);
    border-left: 1px solid var(--border-light);
    margin-left: var(--space-3);
}

.pdata-tree-content .tree-root > .tree-node-item > .tree-node-label {
    font-weight: 600;
    font-size: var(--font-base);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
}

.pdata-tree-diagram {
    overflow: auto;
    padding: var(--space-3);
}
/* Compact vertical tree - smaller boxes to fit screen */
.pdata-tree-diagram .tree-container {
    transform-origin: top center;
}
.pdata-tree-diagram .tree-node-box {
    min-width: 60px;
    max-width: 130px;
    font-size: 11px;
    padding: 4px 8px;
}
.pdata-tree-diagram .tree-children {
    gap: -20px;
    margin-top: 36px;
}
.pdata-tree-diagram > .tree-container > .tree-children > .tree-node {
    margin-left: -10px;
    margin-right: -10px;
}
.pdata-tree-diagram .tree-root.has-children > .tree-node-box::after,
.pdata-tree-diagram .tree-node.has-children > .tree-node-box::after {
    height: 18px;
    bottom: -18px;
}
.pdata-tree-diagram .tree-children::before {
    top: -18px;
}
.pdata-tree-diagram .tree-children > .tree-node::before {
    top: -18px;
    height: 18px;
}
.pdata-tree-diagram .tree-children > .tree-node::after {
    top: -20px;
}

/* Staggered layout - naprzemienne wyzej/nizej zeby nie zawijac tekstu */
.pdata-tree-diagram > .tree-container > .tree-children > .tree-node:nth-child(even) {
    margin-top: 140px;
}
.pdata-tree-diagram > .tree-container > .tree-children > .tree-node:nth-child(even)::before {
    top: -158px;
    height: 158px;
}
.pdata-tree-diagram > .tree-container > .tree-children > .tree-node:nth-child(even)::after {
    top: -160px;
}

/* Project overall progress (weighted) */
.pdata-progress-bar {
    margin: var(--space-3) var(--space-5);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.pdata-progress-track {
    flex: 1;
    height: 10px;
    background: var(--bg-tertiary);
    border-radius: 5px;
    overflow: hidden;
}

.pdata-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 5px;
    transition: width .5s ease;
}

.pdata-progress-text {
    font-size: var(--font-sm);
    font-weight: 600;
    color: var(--text-primary);
    min-width: 40px;
}

/* Block summary in project view */
.pdata-blocks-summary {
    padding: var(--space-3) var(--space-5);
}

.pdata-block-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border-light);
    font-size: var(--font-sm);
}

.pdata-block-row:last-child {
    border-bottom: none;
}

.pdata-block-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.pdata-block-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pdata-block-progress {
    width: 80px;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    flex-shrink: 0;
}

.pdata-block-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
}

.pdata-block-pct {
    width: 36px;
    text-align: right;
    font-size: 11px;
    color: var(--text-muted);
}

.pdata-block-weight {
    width: 30px;
    text-align: right;
    font-size: 10px;
    color: var(--text-muted);
}

/* ============== Project Preview Panel ============== */

.project-preview-panel {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin: 0 var(--space-4) var(--space-4);
    background: var(--bg-primary);
    overflow: hidden;
}
.project-preview-panel.hidden { display: none; }

.preview-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-2) var(--space-3);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}
.preview-toolbar-left { display: flex; align-items: center; gap: var(--space-2); }
.preview-toolbar-right { display: flex; align-items: center; gap: var(--space-1); }
.preview-title { font-weight: 600; font-size: 0.85rem; }

.preview-device-btn { opacity: 0.5; }
.preview-device-btn.active { opacity: 1; background: var(--accent); color: #fff; }

.preview-iframe-wrapper {
    display: flex;
    justify-content: center;
    background: var(--bg-hover);
    padding: var(--space-2);
    height: clamp(300px, 60vh, calc(100vh - 280px));
    transition: background 0.3s ease;
}

.preview-iframe-wrapper iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: #fff; /* intentional: iframe shows user's page */
    border-radius: var(--radius-sm, 6px);
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
    transition: width 0.3s ease;
}

.preview-iframe-wrapper.tablet iframe { width: 768px; max-width: 100%; }
.preview-iframe-wrapper.mobile iframe { width: 375px; max-width: 100%; }

/* ============== Project Split Layout (Claude CLI panel) ============== */

.project-split-layout {
    display: flex;
    flex-direction: row;
    gap: 0;
}
.project-split-layout:has(.project-right:not(.hidden)),
.project-split-layout:has(.project-detail-panel:not(.hidden)) {
    height: calc(100vh - 180px);
}

.project-left {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
    min-width: 0;
}
.project-left::-webkit-scrollbar { width: 6px; }
.project-left::-webkit-scrollbar-track { background: transparent; }
.project-left::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }

.project-resize-handle {
    width: 4px;
    cursor: col-resize;
    background: var(--border-color);
    transition: background 0.15s;
    flex-shrink: 0;
}
.project-resize-handle:hover,
.project-resize-handle.dragging {
    background: var(--accent);
}

.project-right {
    width: 500px;
    min-width: 300px;
    max-width: 70vw;
    display: flex;
    flex-direction: column;
    background: var(--bg-tertiary);
}

.project-right.hidden {
    display: none;
}
.project-resize-handle.hidden {
    display: none;
}

/* Detail panel (right column for block details) */
.project-detail-panel {
    width: 400px;
    min-width: 250px;
    max-width: 50vw;
    display: flex;
    flex-direction: column;
    background: var(--bg-tertiary);
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
}
.project-detail-panel.hidden { display: none; }
.project-detail-resize {
    width: 4px;
    cursor: col-resize;
    background: var(--border-color);
    transition: background .15s;
    flex-shrink: 0;
}
.project-detail-resize:hover { background: var(--accent); }
.project-detail-resize.hidden { display: none; }
.detail-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}
.detail-panel-header h4 { margin: 0; font-size: var(--font-base); }
.detail-panel-body {
    padding: 16px;
    flex: 1;
    overflow-y: auto;
}
.detail-panel-body .block-status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}
.block-status-planned { background: var(--bg-hover); color: var(--text-muted); }
.block-status-design { background: rgba(59,130,246,0.15); color: #3b82f6; }
.block-status-dev { background: rgba(245,158,11,0.15); color: #f59e0b; }
.block-status-done { background: rgba(34,197,94,0.15); color: #22c55e; }
.detail-block-tasks { margin-top: 16px; }
.detail-block-tasks h5 { margin: 0 0 8px; font-size: var(--font-sm); color: var(--text-muted); }
.detail-task-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: var(--font-sm);
}
.detail-task-item.done { opacity: 0.5; text-decoration: line-through; }

.detail-section {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}
.detail-section:last-child { border-bottom: none; }
.detail-section h5 { margin: 0 0 8px; font-size: var(--font-sm); color: var(--text-muted); }
.detail-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.btn-icon-edit {
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); font-size: 14px; padding: 2px 6px;
    border-radius: var(--radius-sm);
    transition: color .15s, background .15s;
}
.btn-icon-edit:hover { color: var(--accent); background: var(--bg-hover); }

.progress-block-row:hover {
    background: var(--bg-hover);
}
.progress-block-row.active-block {
    background: var(--accent-bg, rgba(99,102,241,0.1));
    outline: 1px solid var(--accent);
}

/* Folder info bar */
.project-folder-info {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-light);
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: var(--font-xs);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Claude CLI header */
.project-claude-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.project-claude-header h4 {
    margin: 0;
    font-size: var(--font-base);
    font-weight: 600;
    color: var(--text-primary);
}

/* Project requests badge + panel */
.project-req-badge {
    background: var(--primary) !important;
    color: #fff !important;
    font-size: 11px;
    padding: 2px 10px;
    border-radius: 12px;
    cursor: pointer;
    animation: pulse-badge 2s ease-in-out infinite;
}
@keyframes pulse-badge { 0%,100%{opacity:1} 50%{opacity:.7} }
.project-requests-panel {
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    max-height: 280px;
    overflow-y: auto;
}
.project-requests-tabs {
    display: flex;
    gap: 4px;
    padding: 6px 12px;
    border-bottom: 1px solid var(--border-light);
}
.project-requests-tabs .btn.active { background: var(--primary); color: #fff; }
.project-requests-list { padding: 0; }
.project-req-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
    font-size: 12px;
}
.project-req-card:hover { background: var(--bg-secondary); }
.project-req-from {
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
    min-width: 80px;
}
.project-req-title { flex: 1; color: var(--text-primary); }
.project-req-status {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    white-space: nowrap;
}
.project-req-status.pending { background: #fef3c7; color: #92400e; }
.project-req-status.accepted, .project-req-status.processing { background: #dbeafe; color: #1e40af; }
.project-req-status.done { background: #d1fae5; color: #065f46; }
.project-req-status.failed { background: #fee2e2; color: #991b1b; }
.project-req-status.rejected { background: #e5e7eb; color: #374151; }
.project-req-actions { display: flex; gap: 4px; }
.project-req-actions .btn { font-size: 10px; padding: 2px 8px; }

/* Claude connection status badge */
.claude-status {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    line-height: 1.4;
}

.claude-status.connected {
    background: var(--success-light);
    color: var(--success);
}

.claude-status.connecting {
    background: rgba(245, 158, 11, 0.12);
    color: #D97706;
}

.claude-status.error {
    background: var(--danger-light);
    color: var(--danger);
}

/* Claude messages area */
.project-claude-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.project-claude-messages::-webkit-scrollbar {
    width: 6px;
}

.project-claude-messages::-webkit-scrollbar-track {
    background: transparent;
}

.project-claude-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.project-claude-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============== Claude Chat: Modern ChatGPT-style ============== */

/* Chat container with sidebar */
.claude-chat-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Chat sessions sidebar */
.claude-sidebar {
    width: 200px;
    min-width: 200px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.claude-sidebar-header {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.claude-sidebar-header button {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 16px;
    padding: 0 2px;
    line-height: 1;
}
.claude-sidebar-header button:hover { opacity: 0.7; }
.claude-sessions-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px;
}
.claude-sessions-list::-webkit-scrollbar { width: 4px; }
.claude-sessions-list::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }
.claude-session-item {
    padding: 6px 8px;
    font-size: 12px;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.claude-session-item:hover { background: var(--bg-hover); }
.claude-session-item.active {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 600;
}
.claude-session-item .session-meta {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Chat main area (right of sidebar) */
.claude-chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Messages */
.claude-msg {
    max-width: 85%;
    padding: 8px 14px;
    margin: 3px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.55;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.claude-msg + .claude-msg { border-top: none; }

/* AI messages: left-aligned */
.claude-msg-assistant {
    align-self: flex-start;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

/* User messages: right-aligned, lighter bg */
.claude-msg-user {
    align-self: flex-end;
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Markdown in AI messages */
.claude-msg-assistant h1,
.claude-msg-assistant h2,
.claude-msg-assistant h3 {
    margin: 6px 0 3px;
    font-size: 13px;
    font-weight: 700;
}
.claude-msg-assistant p { margin: 3px 0; }
.claude-msg-assistant ul,
.claude-msg-assistant ol { margin: 3px 0; padding-left: 18px; }
.claude-msg-assistant li { margin: 1px 0; }
.claude-msg-assistant hr { border: none; border-top: 1px solid var(--border-color); margin: 6px 0; }
.claude-msg-assistant table {
    border-collapse: collapse;
    margin: 4px 0;
    width: 100%;
    font-size: 11px;
}
.claude-msg-assistant th,
.claude-msg-assistant td {
    border: 1px solid var(--border-color);
    padding: 3px 6px;
    text-align: left;
}
.claude-msg-assistant th { background: var(--bg-hover); font-weight: 600; }
.claude-msg-assistant code {
    background: rgba(0,0,0,0.06);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 12px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}
.claude-msg-assistant pre {
    background: rgba(0,0,0,0.06);
    padding: 8px 10px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 4px 0;
    font-size: 12px;
}
.claude-msg-assistant pre code {
    background: none;
    padding: 0;
}

/* Tool use logs (compact) */
.claude-tool-log {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 14px;
    font-size: 11px;
    color: var(--text-muted);
    opacity: 0.7;
    transition: opacity 0.2s;
}
.claude-tool-log:hover { opacity: 1; }
.claude-tool-log .tool-icon { font-size: 12px; flex-shrink: 0; }
.claude-tool-log .tool-name { font-weight: 600; color: var(--text-secondary); white-space: nowrap; }
.claude-tool-log .tool-summary { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); }
.claude-tool-log.tool-done { opacity: 0.4; }
.claude-tool-log.tool-done .tool-name::after { content: ' ✓'; color: var(--success); }
.claude-tool-log.tool-error { opacity: 0.8; }
.claude-tool-log.tool-error .tool-name { color: var(--danger); }
.claude-tool-log.tool-error .tool-name::after { content: ' ✗'; color: var(--danger); }
[data-theme="dark"] .claude-tool-log { color: #666; }
[data-theme="dark"] .claude-tool-log .tool-name { color: #888; }

/* Claude typing indicator */
.claude-typing {
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-xs);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.claude-typing.hidden {
    display: none;
}

.claude-typing .typing-dots span {
    animation: claude-typing-blink 1.4s infinite;
    font-size: 18px;
    line-height: 1;
}

.claude-typing .typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.claude-typing .typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes claude-typing-blink {
    0%, 60%, 100% { opacity: 0.2; }
    30% { opacity: 1; }
}

/* Claude input area */
.project-claude-input {
    display: flex;
    gap: var(--space-2);
    padding: var(--space-3);
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.project-claude-input input {
    flex: 1;
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-sm);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s;
}

.project-claude-input input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-light);
}

.project-claude-input .btn {
    padding: var(--space-2) var(--space-3);
    min-width: 40px;
}
.claude-mode-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: var(--font-xs);
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
}
.claude-mode-toggle input { margin: 0; cursor: pointer; }
.claude-mode-toggle input:checked + span,
.claude-mode-toggle:has(input:checked) { color: var(--accent); font-weight: 600; }

/* MCP servers bar */
.claude-mcp-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: var(--space-1) var(--space-3);
    border-top: 1px solid var(--border-light);
    background: var(--bg-tertiary);
    min-height: 0;
}
.claude-mcp-bar:empty { display: none; }
.mcp-chip {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    white-space: nowrap;
}
.mcp-connected {
    background: var(--success-light);
    color: var(--success);
    font-weight: 600;
}
.mcp-disconnected {
    background: var(--danger-light);
    color: var(--danger);
}
.mcp-model {
    background: var(--accent-light);
    color: var(--accent);
}
.mcp-tools {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

/* Dark mode: Preview panel */
[data-theme="dark"] .preview-iframe-wrapper iframe { box-shadow: 0 2px 12px rgba(0,0,0,0.4); }

/* Dark mode: Claude panel darker than main area */
[data-theme="dark"] .project-right {
    background: #0D0D0D;
    border-left-color: #1F1F1F;
}
[data-theme="dark"] .project-claude-header {
    background: #111;
    border-bottom-color: #1F1F1F;
}
[data-theme="dark"] .project-claude-messages::-webkit-scrollbar-thumb { background: #333; }
[data-theme="dark"] .claude-msg-assistant {
    background: #1A1A1A;
}
[data-theme="dark"] .claude-msg-assistant code,
[data-theme="dark"] .claude-msg-assistant pre {
    background: rgba(255,255,255,0.06);
}
[data-theme="dark"] .claude-msg-user {
    background: var(--accent);
}
[data-theme="dark"] .project-claude-input {
    background: #111;
    border-top-color: #1F1F1F;
}
[data-theme="dark"] .project-claude-input input {
    background: #1A1A1A;
    border-color: #2D2D2D;
}
[data-theme="dark"] .project-folder-info {
    background: #0D0D0D;
    border-bottom-color: #1F1F1F;
}
[data-theme="dark"] .claude-status.connecting {
    background: rgba(245, 158, 11, 0.15);
    color: #FBBF24;
}
[data-theme="dark"] .claude-sidebar {
    background: #111;
    border-right-color: #1F1F1F;
}
[data-theme="dark"] .claude-sidebar-header {
    border-bottom-color: #1F1F1F;
}
[data-theme="dark"] .claude-session-item:hover { background: #1A1A1A; }
[data-theme="dark"] .claude-session-item.active { background: rgba(99,102,241,0.15); }

/* Responsive: stack vertically on mobile */
@media (max-width: 768px) {
    .project-split-layout {
        flex-direction: column;
        height: auto;
    }

    .project-left {
        min-height: 200px;
        max-height: 50vh;
        padding: var(--space-3);
    }

    .project-right {
        width: 100%;
        min-width: 100%;
        height: 50vh;
        border-left: none;
        border-top: 1px solid var(--border-color);
    }

    .project-preview-panel { margin: 0 var(--space-2) var(--space-2); }
    .preview-iframe-wrapper { height: 40vh; }
    .preview-device-btn { display: none; }
}

.btn-lock {
    background: var(--accent-light);
    color: var(--accent);
    font-size: 11px;
    padding: 2px 8px;
}

.btn-unlock {
    background: var(--success-light);
    color: var(--success);
    font-size: 11px;
    padding: 2px 8px;
}

.node-progress-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 2px var(--space-3) var(--space-1);
}

.node-progress-slider {
    width: 60px;
    height: 4px;
    -webkit-appearance: none;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    cursor: pointer;
}

.node-progress-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
}

/* ============== GROUPS ============== */

.groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-4);
}

.group-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    cursor: pointer;
    transition: all 0.15s ease;
}

.group-card:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-md);
}

.group-card h4 {
    font-size: var(--font-md);
    margin-bottom: var(--space-1);
}

.group-card p {
    font-size: var(--font-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.group-member-count {
    font-size: var(--font-xs);
    color: var(--text-muted);
}

.group-tabs {
    display: flex;
    gap: var(--space-2);
    margin: var(--space-4) 0;
}

/* Member row */
.member-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--border-light);
}

.member-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-light);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: var(--font-sm);
}

.member-name {
    flex: 1;
    font-size: var(--font-sm);
}

.member-role {
    font-size: var(--font-xs);
    color: var(--text-muted);
    text-transform: uppercase;
}

/* ============== ADMIN ============== */

.admin-tabs {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: var(--space-2);
}

.admin-tab-content {
    min-height: 200px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-sm);
}

.admin-table th {
    text-align: left;
    padding: var(--space-2) var(--space-3);
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
    font-size: var(--font-xs);
    text-transform: uppercase;
}

.admin-table td {
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--border-light);
}

.admin-table tr:hover td {
    background: var(--bg-tertiary);
}

.status-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
}

.status-badge.active { background: var(--success-light); color: var(--success); }
.status-badge.inactive { background: var(--danger-light); color: var(--danger); }
.status-badge.pending { background: #fef3c7; color: #b45309; }
.status-badge.accepted { background: var(--success-light); color: var(--success); }
.status-badge.expired { background: var(--bg-tertiary); color: var(--text-muted); }

.nowrap { white-space: nowrap; }
.audit-details {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* User cards grid */
.admin-users-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: var(--space-4);
}

.user-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-4);
}
.user-card-inactive { opacity: 0.6; }

.user-card-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.user-card-avatar {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    object-fit: cover;
    flex-shrink: 0;
}
.user-card-avatar-placeholder {
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: var(--font-lg);
}

.user-card-info { flex: 1; min-width: 0; }
.user-card-name { font-weight: 600; font-size: var(--font-sm); }
.user-card-email { font-size: 11px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.user-card-meta {
    display: flex;
    gap: var(--space-4);
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: var(--space-3);
}

.user-card-actions {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.btn-danger-subtle {
    color: var(--danger);
    border-color: var(--danger);
}
.btn-danger-subtle:hover {
    background: var(--danger);
    color: white;
}

.status-badge.revoked { background: var(--danger-light); color: var(--danger); }
.status-badge.used { background: var(--success-light); color: var(--success); }

/* Permission checkboxes */
.perm-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
}

.perm-checkbox {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--font-sm);
    cursor: pointer;
    padding: var(--space-1);
}

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

/* Template cards */
.template-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    margin-bottom: var(--space-3);
}

.template-card h4 {
    margin-bottom: var(--space-1);
}

.template-card p {
    font-size: var(--font-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.template-category {
    font-size: var(--font-xs);
    color: var(--text-muted);
    text-transform: uppercase;
}

.badge-system {
    font-size: 10px;
    background: var(--accent-light);
    color: var(--accent);
    padding: 1px 6px;
    border-radius: var(--radius-full);
    margin-left: var(--space-2);
}

/* ============== KNOWLEDGE BASE ============== */

.knowledge-filters {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.knowledge-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.knowledge-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-4);
}

.knowledge-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}

.knowledge-header h4 {
    flex: 1;
    font-size: var(--font-base);
}

.knowledge-category {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    text-transform: uppercase;
}

.knowledge-score {
    font-size: var(--font-xs);
    font-weight: 600;
    color: var(--accent);
}

.knowledge-content {
    font-size: var(--font-sm);
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: var(--space-2);
}

.knowledge-meta {
    display: flex;
    gap: var(--space-3);
    font-size: var(--font-xs);
    color: var(--text-muted);
}

.knowledge-source {
    color: var(--accent);
    text-decoration: none;
}

.knowledge-source:hover {
    text-decoration: underline;
}

.input-search {
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-sm);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-width: 200px;
}

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

/* ============== SKILLS SECTION ============== */

.skills-tabs {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: var(--space-2);
    flex-wrap: wrap;
}

.skills-tab-content { min-height: 200px; }

.skills-summary-bar {
    display: flex;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
    padding: var(--space-4);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.skills-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

.skills-stat-number {
    font-size: var(--font-xl);
    font-weight: 700;
    color: var(--accent);
}

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

.skills-domain-bar {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    flex-wrap: wrap;
}

.domain-chip {
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--font-xs);
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    transition: all 0.15s;
}

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

.skills-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.skill-category-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    transition: box-shadow 0.15s;
}

.skill-category-card:hover { box-shadow: var(--shadow-md); }

.skill-cat-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.skill-cat-icon {
    font-size: 24px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.skill-cat-info { flex: 1; }

.skill-cat-name {
    font-size: var(--font-md);
    font-weight: 600;
    color: var(--text-primary);
}

.skill-cat-count {
    font-size: var(--font-xs);
    color: var(--text-muted);
}

.skill-cat-ring {
    position: relative;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.skill-cat-ring svg { width: 44px; height: 44px; }

.skill-cat-ring-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: var(--font-xs);
    font-weight: 700;
    color: var(--text-primary);
}

.skill-sub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--space-3);
}

.skill-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-2);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    min-height: 80px;
    justify-content: center;
}

.skill-block:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.skill-block__name {
    font-size: var(--font-sm);
    font-weight: 500;
    color: var(--text-primary);
}

.skill-block__status {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

/* Proficiency states */
.skill-block--expert {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

.skill-block--proficient {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.1);
}

.skill-block--intermediate {
    border-color: #F59E0B;
    background: rgba(245, 158, 11, 0.1);
}

.skill-block--beginner {
    border-color: #F97316;
    background: rgba(249, 115, 22, 0.1);
}

.skill-block--learning {
    border-color: #8B5CF6;
    background: rgba(139, 92, 246, 0.05);
    animation: skill-pulse 2s ease-in-out infinite;
}

@keyframes skill-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.3); }
    50% { box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1); }
}

.skill-block--suggested {
    border-color: var(--text-muted);
    border-style: dashed;
    background: transparent;
    opacity: 0.6;
}

.skill-block--suggested:hover {
    opacity: 1;
    border-color: var(--accent);
}

.skill-block--suggested .skill-block__name { color: var(--text-muted); }

/* Proficiency dots */
.skill-dots {
    display: flex;
    gap: 3px;
}

.skill-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-color);
    transition: background 0.15s;
}

.skill-dot--filled { background: var(--accent); }
.skill-block--expert .skill-dot--filled { background: var(--success); }
.skill-block--proficient .skill-dot--filled { background: var(--accent); }
.skill-block--intermediate .skill-dot--filled { background: #F59E0B; }
.skill-block--beginner .skill-dot--filled { background: #F97316; }
.skill-block--learning .skill-dot--filled { background: #8B5CF6; }

/* Editable dots in modal */
.skill-dots--edit .skill-dot {
    width: 14px;
    height: 14px;
    cursor: pointer;
}

.skill-dots--edit .skill-dot:hover { background: var(--accent); transform: scale(1.2); }

/* Service skills - user count badge */
.skill-block__users {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: var(--space-1);
}

/* Learning section */
.learning-filters {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.learning-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.learning-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    display: flex;
    gap: var(--space-4);
    align-items: center;
}

.learning-item__icon {
    font-size: 28px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.learning-item__content { flex: 1; }

.learning-item__title {
    font-weight: 600;
    margin-bottom: var(--space-1);
}

.learning-item__desc {
    font-size: var(--font-sm);
    color: var(--text-secondary);
}

/* Knowledge enhancements */
.knowledge-toolbar {
    display: flex;
    gap: var(--space-3);
    align-items: center;
    margin-bottom: var(--space-4);
    flex-wrap: wrap;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--font-sm);
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
}

.knowledge-badge-ai {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    background: rgba(139, 92, 246, 0.15);
    color: #8B5CF6;
    text-transform: uppercase;
    margin-left: var(--space-1);
}

.knowledge-verified {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    margin-left: var(--space-1);
}

.knowledge-unverified {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    background: rgba(245, 158, 11, 0.15);
    color: #B45309;
    margin-left: var(--space-1);
}

.knowledge-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    margin-top: var(--space-2);
}

.knowledge-tag {
    font-size: 10px;
    padding: 1px 6px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: var(--radius-full);
    cursor: pointer;
}

.knowledge-tag:hover { background: var(--accent); color: white; }

/* Skill detail modal */
.skill-detail-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.skill-detail-proficiency { margin-bottom: var(--space-4); }

.skill-detail-section {
    margin-bottom: var(--space-4);
}

.skill-detail-section h4 {
    font-size: var(--font-sm);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-2);
}

.resource-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2);
    border-radius: var(--radius-sm);
    transition: background 0.1s;
}

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

.resource-item a {
    color: var(--accent);
    text-decoration: none;
    font-size: var(--font-sm);
}

.resource-item a:hover { text-decoration: underline; }

/* Detection badge */
.detection-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    border-radius: var(--radius-full);
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    margin-left: var(--space-1);
}

@media (max-width: 768px) {
    .skill-sub-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
    .skills-summary-bar { flex-wrap: wrap; justify-content: center; }
    .skills-tabs { overflow-x: auto; white-space: nowrap; }
    .skill-category-card { padding: var(--space-3); }
    .learning-item { flex-direction: column; text-align: center; }
    .knowledge-toolbar { flex-direction: column; align-items: stretch; }
}

/* ============== CHAT WIDGET ============== */

.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.chat-toggle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: transform 0.15s ease;
}

.chat-toggle:hover {
    transform: scale(1.05);
}

.chat-panel {
    position: absolute;
    bottom: 60px;
    right: 0;
    width: 360px;
    max-height: 480px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.chat-title {
    font-weight: 600;
    font-size: var(--font-sm);
    flex: 1;
}

.chat-mode-select select {
    font-size: var(--font-xs);
    padding: 2px 6px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-3);
    min-height: 200px;
    max-height: 320px;
}

.chat-msg {
    max-width: 85%;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-2);
    font-size: var(--font-sm);
    line-height: 1.4;
    word-wrap: break-word;
}

.chat-msg-user {
    background: var(--accent);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.chat-msg-assistant {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.chat-msg-system {
    background: var(--danger-light);
    color: var(--danger);
    font-size: var(--font-xs);
    text-align: center;
    margin: 0 auto var(--space-2);
}

.chat-input-area {
    display: flex;
    gap: var(--space-2);
    padding: var(--space-3);
    border-top: 1px solid var(--border-color);
}

.chat-input-area input {
    flex: 1;
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-sm);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
}

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

/* ============== USER INFO ============== */

.user-info {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    margin-bottom: var(--space-2);
}

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

.user-name {
    font-size: var(--font-sm);
    font-weight: 500;
    color: var(--text-primary);
}

/* ============== NAV ADMIN ============== */

.nav-admin {
    border-top: 1px solid var(--border-color);
    margin-top: var(--space-2);
    padding-top: var(--space-2);
}

/* ============== PROJECT MINI (Today) ============== */

.project-list-mini {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.project-mini {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) 0;
    cursor: pointer;
    font-size: var(--font-sm);
}

.project-mini:hover {
    color: var(--accent);
}

.project-mini span {
    flex: 1;
}

.project-mini .progress-bar {
    width: 80px;
}

/* ============== EMPTY STATE ============== */

.empty-state {
    color: var(--text-muted);
    font-size: var(--font-sm);
    text-align: center;
    padding: var(--space-6) var(--space-4);
}

/* ============== RESPONSIVE ============== */

@media (max-width: 768px) {
    .chat-panel {
        width: calc(100vw - 40px);
        right: -10px;
    }

    .projects-grid,
    .groups-grid {
        grid-template-columns: 1fr;
    }

    .perm-grid {
        grid-template-columns: 1fr;
    }

    .admin-table {
        font-size: var(--font-xs);
    }

    .admin-table th,
    .admin-table td {
        padding: var(--space-1) var(--space-2);
    }
}

/* ============== MISSING STYLES FIX ============== */

.group-tab-content {
    min-height: 100px;
}

.event-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.bell-icon {
    font-size: 18px;
    line-height: 1;
}

.chat-icon {
    font-size: 20px;
    line-height: 1;
}

.tasks-today,
.habits-today,
.events-today {
    min-height: 60px;
}

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

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

/* ============== Settings ============== */
.settings-section {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.settings-section-title {
    font-size: var(--font-lg);
    margin: 0 0 4px 0;
    color: var(--text);
}

.settings-section-desc {
    font-size: var(--font-sm);
    color: var(--text-secondary);
    margin: 0 0 16px 0;
}

.settings-fields {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.settings-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.settings-field label {
    font-weight: 500;
    font-size: var(--font-sm);
    color: var(--text);
}

.settings-input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: var(--font-base);
    width: 100%;
    max-width: 480px;
    box-sizing: border-box;
}

.settings-input:focus {
    border-color: var(--accent);
    outline: none;
}

select.settings-input {
    cursor: pointer;
}

.settings-password-wrap {
    display: flex;
    gap: 8px;
    align-items: center;
    max-width: 480px;
}

.settings-password-wrap input {
    flex: 1;
}

.settings-help {
    font-size: 12px;
    color: var(--text-secondary);
    opacity: 0.7;
}

.settings-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.text-success {
    color: #22c55e;
    font-size: var(--font-sm);
}

.text-error {
    color: #ef4444;
    font-size: var(--font-sm);
}

/* ============== Permission Matrix (PrestaShop-style) ============== */
.perm-matrix-container {
    max-height: 60vh;
    overflow-y: auto;
}

.perm-matrix-toolbar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.perm-matrix-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-sm);
}

.perm-matrix-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--card-bg);
}

.perm-matrix-table th,
.perm-matrix-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}

.perm-section-header {
    text-align: left;
    font-weight: 600;
    min-width: 200px;
}

.perm-action-header {
    text-align: center;
    font-weight: 600;
    white-space: nowrap;
}

.perm-action-header label {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: center;
    cursor: pointer;
    font-weight: 600;
}

.perm-section-cell {
    text-align: left;
}

.perm-section-cell label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-weight: 500;
}

.perm-section-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.perm-check-cell {
    text-align: center;
}

.perm-cb {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent);
}

.perm-matrix-table tbody tr:hover {
    background: rgba(255,255,255,0.03);
}

.perm-matrix-table tbody tr:nth-child(even) {
    background: rgba(255,255,255,0.015);
}

/* ============== Nav Apps Section ============== */
.nav-apps-section {
    border-top: 1px solid var(--border);
    padding-top: 8px;
    margin-top: 8px;
}

.nav-apps-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 12px;
}

.nav-apps-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    font-weight: 600;
}

.nav-apps-add {
    background: none;
    border: 1px dashed var(--border);
    color: var(--text-secondary);
    width: 24px;
    height: 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.nav-apps-add:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(var(--accent-rgb, 59,130,246), 0.1);
}

.nav-apps-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-apps-empty {
    font-size: 11px;
    color: var(--text-secondary);
    padding: 8px 12px;
    opacity: 0.6;
}

.nav-app-item {
    font-size: 13px !important;
}

/* ============== App Section Layout ============== */
.app-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 16px;
    height: calc(100vh - 120px);
}

.app-chat-main {
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

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

.app-chat-input {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border);
}

.app-chat-input input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: var(--font-base);
}

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

.app-sidebar-right {
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
}

.app-tree-panel,
.app-context-panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
}

.app-tree-panel h4,
.app-context-panel h4 {
    margin: 0 0 8px 0;
    font-size: var(--font-sm);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.app-tree-node {
    font-size: 13px;
    padding: 3px 0;
    color: var(--text);
}

.app-tree-bullet {
    color: var(--accent);
    font-size: 8px;
    margin-right: 6px;
}

/* ============== Full Chat Page (OpenAI style) ============== */
.chat-full-layout {
    display: flex;
    height: calc(100vh - 80px);
    gap: 0;
    transition: all 0.2s ease;
}

.chat-full-layout.split-active {
    gap: 1px;
}

.chat-full-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-full-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}
.chat-full-messages::-webkit-scrollbar { width: 6px; }
.chat-full-messages::-webkit-scrollbar-track { background: transparent; }
.chat-full-messages::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
.chat-full-messages::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* OpenAI-style messages */
.chat-full-messages .chat-msg {
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
    padding: 16px 24px;
    border-radius: 0;
    font-size: 15px;
    line-height: 1.6;
}

.chat-full-messages .chat-msg-user {
    background: transparent;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    padding-bottom: 20px;
    margin-bottom: 4px;
    align-self: auto;
}

.chat-full-messages .chat-msg-user::before {
    content: 'Ty';
    display: block;
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 4px;
    color: var(--text-secondary);
}

.chat-full-messages .chat-msg-assistant {
    background: transparent;
    color: var(--text);
    padding-bottom: 20px;
    align-self: auto;
}

.chat-full-messages .chat-msg-assistant::before {
    content: 'AI';
    display: block;
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 4px;
    color: var(--accent);
}

.chat-full-messages .chat-msg-assistant code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.chat-full-messages .chat-msg-assistant strong {
    font-weight: 700;
}

.chat-full-messages .chat-msg-assistant ul {
    margin: 8px 0;
    padding-left: 20px;
}

.chat-full-messages .chat-msg-assistant li {
    margin: 4px 0;
}

.chat-full-input {
    display: flex;
    gap: 8px;
    padding: 16px 24px;
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

.chat-full-input input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
}

.chat-full-input input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(var(--accent-rgb, 59,130,246), 0.2);
}

.chat-full-input .btn-primary {
    border-radius: 12px;
    padding: 12px 20px;
}

/* Split panel (right side) */
.chat-split-panel {
    width: 340px;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--bg-secondary);
}

.chat-split-tabs {
    display: flex;
    gap: 4px;
    padding: 8px;
    border-bottom: 1px solid var(--border);
}

.chat-split-tabs .btn {
    font-size: 12px;
}

.split-tab-content {
    padding: 12px;
    flex: 1;
    overflow-y: auto;
}

.split-tab-content h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: var(--text-secondary);
}

/* AI Tools checkboxes */
.ai-tool-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.ai-tool-item:last-child { border-bottom: none; }

.ai-tool-item input[type="checkbox"] {
    margin-top: 3px;
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.ai-tool-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ai-tool-name {
    font-weight: 500;
    font-size: 13px;
    color: var(--text);
}

/* Dark mode: Chat AI full */
[data-theme="dark"] .chat-full-messages .chat-msg-user {
    color: var(--text-primary);
    border-bottom-color: var(--border-color);
}
[data-theme="dark"] .chat-full-messages .chat-msg-assistant {
    color: var(--text-primary);
}
[data-theme="dark"] .chat-full-messages .chat-msg-assistant code {
    background: #2a2a2a;
    color: #e5e7eb;
}
[data-theme="dark"] .chat-full-messages .chat-msg-assistant pre {
    background: #1a1a1a;
    border: 1px solid #333;
    color: #e5e7eb;
}
[data-theme="dark"] .chat-full-input input {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
}
[data-theme="dark"] .chat-full-input input::placeholder {
    color: var(--text-muted);
}
[data-theme="dark"] .chat-split-panel {
    border-left-color: var(--border-color);
    background: var(--bg-secondary);
}
[data-theme="dark"] .chat-split-tabs {
    border-bottom-color: var(--border-color);
}
[data-theme="dark"] .ai-tool-item {
    border-bottom-color: var(--border-color);
}
[data-theme="dark"] .ai-tool-name {
    color: var(--text-primary);
}

.ai-tool-desc {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Activity feed */
.activity-item {
    padding: 6px 0;
    font-size: 12px;
    border-bottom: 1px solid var(--border);
}

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

/* Expand button in widget */
.btn-expand-chat {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    padding: 2px 4px;
}

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

#btn-split-view {
    font-family: monospace;
    letter-spacing: -2px;
}

#btn-split-view.active {
    background: var(--accent);
    color: white;
}

@media (max-width: 768px) {
    .chat-split-panel { display: none; }
    .chat-full-messages .chat-msg { padding: 12px 16px; }
    .chat-full-input { padding: 12px 16px; }
}

/* ============== Chat typing indicator ============== */
.chat-typing {
    padding: 6px 12px;
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.typing-dots span {
    animation: typing-blink 1.4s infinite;
    font-size: 20px;
    line-height: 1;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-blink {
    0%, 60%, 100% { opacity: 0.2; }
    30% { opacity: 1; }
}

/* ============== Icon picker ============== */
.icon-picker {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 4px 0;
}

.icon-opt {
    width: 36px;
    height: 36px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.icon-opt:hover { border-color: var(--accent); }
.icon-opt.selected { border-color: var(--accent); background: rgba(var(--accent-rgb, 59,130,246), 0.15); }

.pin-app-form .form-group {
    margin-bottom: 12px;
}

.pin-app-form textarea.settings-input {
    resize: vertical;
    min-height: 40px;
}

@media (max-width: 768px) {
    .app-layout {
        grid-template-columns: 1fr;
    }
    .app-sidebar-right {
        display: none;
    }
}

/* Wide modal for permission matrix */
.modal-content:has(.perm-matrix-container) {
    max-width: 700px;
}

@media (max-width: 720px) {
    .modal-content:has(.perm-matrix-container) {
        max-width: 95vw;
    }
    .perm-section-header { min-width: 140px; }
    .perm-action-header label { font-size: 11px; }
}

/* ============== AGENTS SYSTEM ============== */

.agents-filter-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}
.agents-filter-tabs .btn {
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 0.82rem;
    padding: 5px 12px;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
}
.agents-filter-tabs .btn:hover {
    background: var(--hover-bg);
    color: var(--text);
}
.agents-filter-tabs .btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.agents-filter-tabs .tab-count {
    font-size: 0.72em;
    opacity: 0.7;
    margin-left: 2px;
}
.agent-type-badge {
    display: inline-block;
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    margin-left: 6px;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.agents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-3);
}

.agent-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: var(--space-3);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}
.agent-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.agent-card-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}
.agent-card-icon {
    font-size: 28px;
    line-height: 1;
}
.agent-card-name {
    font-size: var(--font-md);
    margin: 0;
}
.agent-card-status {
    font-size: var(--font-xs);
    padding: 2px 8px;
    border-radius: 10px;
}
.status-active { background: var(--success-bg); color: var(--success-text); }
.status-inactive { background: var(--muted-bg); color: var(--muted-text); }
.agent-card-desc {
    font-size: var(--font-sm);
    color: var(--text-secondary);
    margin: 0 0 var(--space-2);
    min-height: 36px;
}
.agent-card-stats {
    display: flex;
    gap: var(--space-3);
    font-size: var(--font-xs);
    color: var(--text-secondary);
}
.agent-card-stats span { display: flex; align-items: center; gap: 4px; }

/* Agent Detail */
.agent-detail-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
    flex-wrap: wrap;
}
.agent-detail-icon { font-size: 32px; }
.agent-detail-header h2 { margin: 0; }
.agent-detail-desc {
    color: var(--text-secondary);
    margin-bottom: var(--space-3);
}
.agent-status-badge {
    font-size: var(--font-xs);
    padding: 2px 10px;
    border-radius: 12px;
}

/* Agent Tabs */
.agent-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: var(--space-3);
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
    padding-bottom: var(--space-2);
}

/* Overview */
.agent-overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: var(--space-3);
}
.overview-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: var(--space-3);
}
.overview-card h4 { margin: 0 0 var(--space-2); font-size: var(--font-sm); color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.overview-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-2); }
.stat-item { text-align: center; }
.stat-number { display: block; font-size: 24px; font-weight: 700; }
.stat-label { font-size: var(--font-xs); color: var(--text-secondary); }
.agent-prompt-preview {
    font-size: var(--font-xs);
    background: var(--bg-secondary, #f5f5f5);
    padding: var(--space-2);
    border-radius: var(--radius-sm);
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 150px;
    overflow-y: auto;
}

/* Skill blocks for agents */
.skill-block {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: var(--space-2);
    border-left: 3px solid var(--border);
}
.skill-block.skill-expert { border-left-color: #28a745; }
.skill-block.skill-proficient { border-left-color: #2196f3; }
.skill-block.skill-intermediate { border-left-color: #ffc107; }
.skill-block.skill-basic { border-left-color: #ff9800; }
.skill-block.skill-beginner { border-left-color: #dc3545; }
.skill-core-highlight { box-shadow: 0 0 0 1px gold; }
.skill-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: var(--font-sm);
}
.core-star { color: gold; }
.skill-block-body {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--space-1);
}
.skill-prof { font-size: var(--font-xs); color: var(--text-secondary); }
.skill-actions { display: flex; gap: 4px; align-items: center; }
.skill-prof-select {
    font-size: 11px;
    padding: 2px 4px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--bg);
}
.btn-icon-sm {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 4px;
    border-radius: 4px;
    opacity: 0.6;
}
.btn-icon-sm:hover { opacity: 1; background: var(--bg-secondary, #eee); }
.btn-danger-icon:hover { color: var(--danger, #dc3545); }
.skill-badge.skill-core {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: var(--font-xs);
    background: var(--primary-bg, #e3f2fd);
    margin: 2px;
}

/* Assign skills modal */
.assign-skills-tree { max-height: 400px; overflow-y: auto; }
.assign-cat { margin-bottom: var(--space-2); }
.assign-cat h4 { margin: 0 0 4px; font-size: var(--font-sm); }
.assign-skills-list { display: flex; flex-wrap: wrap; gap: 4px; }
.assign-skill-item {
    font-size: var(--font-xs);
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    background: var(--bg-secondary, #f5f5f5);
    border-radius: 4px;
    cursor: pointer;
}
.assign-skill-item:hover { background: var(--primary-bg, #e3f2fd); }

/* Knowledge items */
.knowledge-item {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: var(--space-2) var(--space-3);
    margin-bottom: var(--space-2);
}
.knowledge-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-1);
}
.knowledge-item-header h4 { margin: 0; font-size: var(--font-sm); }
.knowledge-item-meta {
    display: flex;
    gap: var(--space-2);
    font-size: var(--font-xs);
    color: var(--text-secondary);
}
.knowledge-cat { background: var(--bg-secondary, #f0f0f0); padding: 1px 6px; border-radius: 4px; }
.knowledge-verified { color: #28a745; }
.knowledge-item-content {
    font-size: var(--font-sm);
    color: var(--text-secondary);
    margin: var(--space-1) 0;
}
.knowledge-item-actions {
    display: flex;
    gap: var(--space-2);
    font-size: var(--font-xs);
}
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; padding: 0; font-size: inherit; }
.btn-link:hover { text-decoration: underline; }
.btn-danger-link { color: var(--danger, #dc3545); }

/* Schemas */
.schemas-list { display: flex; flex-direction: column; gap: var(--space-2); }
.schema-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: var(--space-3);
}
.schema-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: var(--space-1);
}
.schema-card-header h4 { margin: 0; }
.schema-meta { display: flex; gap: var(--space-2); font-size: var(--font-xs); color: var(--text-secondary); }
.schema-actions { display: flex; gap: var(--space-2); margin-top: var(--space-2); }
.schema-tree { list-style: none; padding-left: 20px; }
.schema-tree li { padding: 4px 0; position: relative; }
.schema-tree li::before { content: ''; position: absolute; left: -14px; top: 0; bottom: 0; width: 1px; background: var(--border); }
.schema-tree li::after { content: ''; position: absolute; left: -14px; top: 14px; width: 10px; height: 1px; background: var(--border); }
.human-badge {
    display: inline-block;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(245, 158, 11, 0.15);
    color: #F59E0B;
    margin-left: 4px;
}

/* Agent projects */
.agent-projects-list { display: flex; flex-direction: column; gap: var(--space-2); }
.agent-project-item {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: var(--space-2) var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}
.agent-project-info h4 { margin: 0; font-size: var(--font-sm); }
.agent-project-role {
    font-size: var(--font-xs);
    background: var(--primary-bg, #e3f2fd);
    padding: 1px 8px;
    border-radius: 10px;
}
.agent-project-progress {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    flex: 1;
    max-width: 200px;
}

/* Agent chat */
.agent-chat-container {
    display: flex;
    flex-direction: column;
    height: 500px;
    background: var(--bg-secondary, #f8f9fa);
    border-radius: var(--radius);
    overflow: hidden;
}
.agent-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-3);
}
.agent-chat-input {
    display: flex;
    gap: var(--space-1);
    padding: var(--space-2);
    border-top: 1px solid var(--border);
    background: var(--card-bg);
}
.agent-chat-input input { flex: 1; }
.chat-msg { margin-bottom: var(--space-2); }
.chat-msg.chat-user .chat-msg-content {
    background: var(--primary);
    color: white;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius) var(--radius) 4px var(--radius);
    display: inline-block;
    max-width: 80%;
    float: right;
    clear: both;
}
.chat-msg.chat-assistant .chat-msg-content {
    background: var(--card-bg);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius) var(--radius) var(--radius) 4px;
    display: inline-block;
    max-width: 80%;
    clear: both;
}
.chat-msg-time { font-size: 10px; color: var(--text-secondary); display: block; clear: both; margin-top: 2px; }

/* Learning timeline */
.learning-timeline { display: flex; flex-direction: column; gap: var(--space-2); }
.learning-entry {
    display: flex;
    gap: var(--space-2);
    padding: var(--space-2);
    background: var(--card-bg);
    border-radius: var(--radius);
}
.learning-icon { font-size: 20px; min-width: 28px; text-align: center; }
.learning-info { flex: 1; }
.learning-type {
    font-size: var(--font-xs);
    background: var(--bg-secondary, #eee);
    padding: 1px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}
.learning-desc { font-size: var(--font-sm); margin: 4px 0; }
.learning-time { font-size: 10px; color: var(--text-secondary); }

/* Empty state small */
.empty-state-sm { color: var(--text-secondary); font-size: var(--font-sm); text-align: center; padding: var(--space-3); }

/* Toolbars */
.agent-skills-toolbar, .agent-knowledge-toolbar, .agent-schemas-toolbar, .agent-projects-toolbar {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
    align-items: center;
}
.agent-knowledge-toolbar .input-search { flex: 1; }

/* Code block */
.code-block {
    background: var(--bg-secondary, #f5f5f5);
    padding: var(--space-2);
    border-radius: var(--radius-sm);
    font-size: var(--font-xs);
    overflow-x: auto;
    white-space: pre-wrap;
}

/* Btn danger */
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { opacity: 0.9; }

/* Missing agent classes */
.agent-card-info { flex: 1; min-width: 0; }
.agent-tab-content { padding: var(--space-2) 0; }
.schema-tree-view { max-height: 400px; overflow-y: auto; padding: var(--space-2); }

/* ============== Tree View Panel ============== */
.tree-view-panel { padding: 24px; height: 100%; overflow-y: auto; }
.tree-view-header h2 { font-size: 1.3rem; font-weight: 600; margin: 0; }
.tree-view-content { padding: 0; }

.tree-node-list { list-style: none; padding: 0; margin: 0; }
.tree-node-list .tree-node-list { padding-left: 20px; border-left: 1px solid var(--border-light); margin-left: 8px; }
.tree-root { padding-left: 0; border-left: none; margin-left: 0; }

.tree-node-item { margin: 2px 0; }
.tree-node-label { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: var(--radius); cursor: pointer; font-size: 0.9rem; transition: background 0.15s; }
.tree-node-label:hover { background: var(--hover-bg); }
.tree-toggle { font-size: 9px; width: 16px; text-align: center; transition: transform 0.2s; color: var(--text-muted); }
.tree-dot { font-size: 14px; width: 16px; text-align: center; color: var(--accent); }
.tree-node-text { flex: 1; }

.tree-node-item.collapsed > .tree-node-label .tree-toggle { transform: rotate(-90deg); }
.tree-node-item.collapsed > .tree-node-list { display: none; }

.tree-node-item.has-children > .tree-node-label { font-weight: 500; }

/* Agent responsive */
@media (max-width: 768px) {
    .agents-grid { grid-template-columns: 1fr; }
    .agent-overview-grid { grid-template-columns: 1fr; }
    .agent-chat-container { height: 350px; }
    .agent-detail-header { flex-direction: column; align-items: flex-start; }
    .agent-tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
    .agent-tabs .btn { white-space: nowrap; flex-shrink: 0; }
    .agent-project-item { flex-direction: column; align-items: flex-start; }
    .agent-project-progress { max-width: 100%; }
}

/* ============== Folder Panel (collapsible + resizable) ============== */

.folder-panel {
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-secondary);
}

.folder-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    user-select: none;
    min-height: 32px;
}

.folder-panel-left {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
    cursor: pointer;
}

.folder-arrow {
    font-size: 10px;
    transition: transform 0.2s;
    color: var(--text-muted);
    flex-shrink: 0;
}
.folder-arrow.open { transform: rotate(90deg); }

.folder-path-label {
    font-size: 11px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.folder-panel-tabs {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.pleft-tab {
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 2px 8px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.15s;
    line-height: 1.2;
}
.pleft-tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.pleft-tab.active {
    background: var(--accent-light);
    color: var(--accent);
    border-color: var(--accent);
}

.folder-panel-body {
    overflow: hidden;
    height: 200px;
}

.folder-panel-content {
    height: 100%;
    overflow-y: auto;
}
.folder-panel-content::-webkit-scrollbar { width: 5px; }
.folder-panel-content::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }

.folder-panel-resize {
    height: 4px;
    cursor: row-resize;
    background: var(--border-light);
    transition: background 0.15s;
}
.folder-panel-resize:hover,
.folder-panel-resize.dragging {
    background: var(--accent);
}

/* File tree */
.file-tree {
    padding: 4px 8px;
    font-size: 12px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

.ft-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 4px;
    border-radius: 3px;
    cursor: default;
    white-space: nowrap;
    color: var(--text-secondary);
}
.ft-item:hover { background: var(--bg-hover); }

.ft-dir > .ft-item { cursor: pointer; font-weight: 500; color: var(--text-primary); }

.ft-arrow {
    font-size: 8px;
    width: 12px;
    text-align: center;
    transition: transform 0.15s;
    color: var(--text-muted);
    flex-shrink: 0;
}
.ft-dir.open > .ft-item > .ft-arrow { transform: rotate(90deg); }

.ft-icon { font-size: 13px; flex-shrink: 0; }

.ft-name { overflow: hidden; text-overflow: ellipsis; }

.ft-size {
    font-size: 10px;
    color: var(--text-muted);
    margin-left: auto;
    padding-left: 8px;
    flex-shrink: 0;
}

.ft-children {
    padding-left: 16px;
    display: none;
}
.ft-dir.open > .ft-children { display: block; }

/* Live iframe in folder panel */
.project-live-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
}

/* ============== Claude Sidebar Collapsible + Resize ============== */

.claude-sidebar.collapsed {
    width: 40px !important;
    min-width: 40px !important;
}
.claude-sidebar.collapsed .sidebar-title,
.claude-sidebar.collapsed .claude-sessions-list,
.claude-sidebar.collapsed .claude-sidebar-header button:not(.sidebar-collapse-btn) {
    display: none;
}

.sidebar-collapse-btn {
    background: none !important;
    border: none !important;
    color: var(--text-muted) !important;
    cursor: pointer;
    font-size: 14px !important;
    padding: 2px 4px !important;
    line-height: 1;
    flex-shrink: 0;
}
.sidebar-collapse-btn:hover { color: var(--text-primary) !important; }

.sidebar-title { flex: 1; }

.claude-sidebar-resize {
    width: 4px;
    cursor: col-resize;
    background: var(--border-light);
    transition: background 0.15s;
    flex-shrink: 0;
}
.claude-sidebar-resize:hover,
.claude-sidebar-resize.dragging {
    background: var(--accent);
}

/* Session item action icons */
.session-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-actions {
    display: none;
    gap: 2px;
    flex-shrink: 0;
}
.claude-session-item:hover .session-actions { display: flex; }

.session-action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 11px;
    padding: 1px 3px;
    border-radius: 3px;
    line-height: 1;
}
.session-action-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.session-action-btn.danger:hover { color: var(--danger); }

/* ============== Change Requests Admin ============== */

.cr-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
}

.cr-filters select {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
}

.cr-worker-status {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.cr-worker-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.cr-worker-dot.active { background: var(--success); }
.cr-worker-dot.inactive { background: var(--danger); }

.cr-new-form {
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    margin-bottom: 16px;
}
.cr-new-form .setting-item { margin-bottom: 8px; }
.cr-new-form .input { font-size: var(--font-sm); }
.cr-new-form textarea.input { font-family: var(--font-family); }

.cr-card {
    padding: 12px 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    gap: 12px;
}

.cr-status-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    flex-shrink: 0;
}
.cr-status-badge.pending { background: rgba(245,158,11,0.12); color: #D97706; }
.cr-status-badge.processing { background: rgba(99,102,241,0.12); color: var(--accent); }
.cr-status-badge.done { background: var(--success-light); color: var(--success); }
.cr-status-badge.failed { background: var(--danger-light); color: var(--danger); }
.cr-status-badge.rejected { background: var(--bg-tertiary); color: var(--text-muted); }

.cr-info { flex: 1; min-width: 0; }
.cr-title { font-weight: 600; font-size: 13px; color: var(--text-primary); }
.cr-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.cr-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* Dark theme overrides */
[data-theme="dark"] .folder-panel { background: #111; }
[data-theme="dark"] .folder-panel-header { border-color: #222; }
[data-theme="dark"] .folder-panel-resize { background: #222; }
[data-theme="dark"] .ft-item:hover { background: #1a1a1a; }
[data-theme="dark"] .claude-sidebar-resize { background: #222; }
[data-theme="dark"] .cr-card { background: var(--bg-secondary); border-color: var(--border-color); }

/* ============== Messages ============== */
.messages-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.messages-list { display: flex; flex-direction: column; gap: 4px; }
.message-item {
    padding: 12px 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background 0.15s;
}
.message-item:hover { background: var(--bg-secondary); }
.message-item.unread { border-left: 3px solid var(--primary); background: rgba(99, 102, 241, 0.04); }
.message-item-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
.message-item-who { font-weight: 600; font-size: 13px; }
.message-item-date { font-size: 12px; color: var(--text-secondary); }
.message-item-subject { font-size: 14px; color: var(--text-primary); }
.message-full { padding: 16px; }
.message-full-header { margin-bottom: 16px; }
.message-full-header h3 { margin: 0 0 8px; }
.message-meta { font-size: 13px; color: var(--text-secondary); }
.message-body { white-space: pre-wrap; line-height: 1.6; font-size: 14px; }
.compose-message { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg-badge {
    position: absolute; top: 2px; right: 4px;
    background: var(--danger); color: #fff;
    font-size: 10px; font-weight: 700;
    min-width: 16px; height: 16px;
    border-radius: 8px; display: flex;
    align-items: center; justify-content: center;
    padding: 0 4px;
}
.nav-item { position: relative; }
[data-theme="dark"] .message-item { border-color: var(--border-color); }
[data-theme="dark"] .message-item:hover { background: var(--bg-tertiary); }
[data-theme="dark"] .message-item.unread { background: rgba(99, 102, 241, 0.08); }

/* ============== Automations (n8n iframe) ============== */
.n8n-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
}
.n8n-iframe {
    width: 100%;
    flex: 1;
    min-height: calc(100vh - 120px);
    border: none;
}
[data-theme="dark"] .n8n-container { border-color: var(--border-color); }

/* ============== Orphan Folders ============== */
.orphan-folder-card {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
}
.orphan-info { flex: 1; }
.orphan-name { font-weight: 600; font-size: 14px; }
.orphan-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.orphan-actions { display: flex; gap: 8px; }
[data-theme="dark"] .orphan-folder-card { border-color: var(--border-color); }

/* ============== App Preview (iframe in Moje Aplikacje) ============== */
.app-preview-container {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.app-preview-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}
.app-preview-iframe {
    width: 100%;
    flex: 1;
    min-height: 0;
    border: none;
    background: white;
}
#app-section.active {
    display: flex;
    flex-direction: column;
    height: 100%;
}
#app-section .section-header { flex-shrink: 0; }
[data-theme="dark"] .app-preview-container { border-color: #222; }
[data-theme="dark"] .app-preview-toolbar { background: #111; }

/* ============== PROJECT AGENTS PANEL ============== */
.project-agents-panel {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
    background: var(--card-bg);
}
.project-agents-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 8px; padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}
.project-agents-header h4 { margin: 0; font-size: 0.95rem; }
.project-agents-tree { max-height: 400px; overflow-y: auto; }
.project-agent-requests { max-height: 300px; overflow-y: auto; }
.project-agent-node {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 8px; border-radius: 6px; cursor: pointer;
    font-size: 0.85rem; transition: background 0.15s;
}
.project-agent-node:hover { background: var(--hover-bg); }
.agent-node-icon { font-size: 1.1em; }
.agent-node-name { font-weight: 500; }
.agent-node-role {
    font-size: 0.72em; padding: 1px 6px; border-radius: 8px;
    background: var(--primary); color: #fff; opacity: 0.8;
}
.agent-node-scope { opacity: 0.5; font-size: 0.8em; cursor: help; }
.agent-req-badge {
    background: #e74c3c; color: #fff; font-size: 0.65rem;
    padding: 1px 5px; border-radius: 8px; font-weight: 600;
}
.agent-requests-badge {
    background: #e74c3c; color: #fff; font-size: 0.72rem;
    padding: 2px 8px; border-radius: 10px; font-weight: 600;
}
.agent-request-card {
    border: 1px solid var(--border-color); border-radius: 6px;
    padding: 10px; margin-bottom: 8px;
}
.agent-request-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 4px; font-size: 0.85rem;
}
.agent-request-title { font-weight: 600; font-size: 0.9rem; }
.priority-high, .priority-urgent { color: #e74c3c; font-weight: 600; }
.priority-normal { color: var(--text-secondary); }

/* ============== WORKSHOP ============== */
.workshop-search-bar {
    margin-bottom: var(--space-4);
}
.workshop-search-bar .input {
    width: 100%;
    padding: 10px 14px;
    font-size: var(--font-md);
}
.workshop-search-results {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: var(--space-4);
}
.ws-search-item {
    display: flex;
    gap: var(--space-3);
    align-items: center;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.15s;
}
.ws-search-item:last-child { border-bottom: none; }
.ws-search-item:hover { background: var(--bg-hover); }
.ws-sr-mfr { font-weight: 600; min-width: 100px; }
.ws-sr-model { color: var(--text-primary); flex: 1; }
.ws-sr-code { color: var(--text-secondary); font-size: var(--font-sm); font-family: monospace; }
.ws-sr-power { color: var(--accent); font-size: var(--font-sm); font-weight: 500; }

.workshop-breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
    font-size: var(--font-sm);
    flex-wrap: wrap;
}
.ws-bc-link { color: var(--accent); cursor: pointer; }
.ws-bc-link:hover { text-decoration: underline; }
.ws-bc-sep { color: var(--text-muted); }
.ws-bc-active { color: var(--text-primary); font-weight: 600; }

.workshop-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-3);
}
@media (max-width: 768px) {
    .workshop-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
    .workshop-grid { grid-template-columns: 1fr; }
}

.ws-mfr-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    cursor: pointer;
    transition: all 0.15s;
}
.ws-mfr-card:hover { border-color: var(--accent); background: var(--accent-light); }
.ws-mfr-priority { border-left: 3px solid var(--accent); }
.ws-mfr-name { font-weight: 600; font-size: var(--font-md); margin-bottom: 4px; }
.ws-mfr-stats { font-size: var(--font-xs); color: var(--text-muted); }

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

.ws-model-item, .ws-engine-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}
.ws-model-item:hover, .ws-engine-item:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}
.ws-model-name { font-weight: 500; flex: 1; }
.ws-model-years { color: var(--text-muted); font-size: var(--font-sm); }
.ws-model-engines { color: var(--text-secondary); font-size: var(--font-xs); min-width: 90px; text-align: right; }

.ws-engine-item { flex-wrap: wrap; }
.ws-engine-main { display: flex; gap: var(--space-3); align-items: center; flex: 1; min-width: 200px; }
.ws-engine-code { font-weight: 600; font-family: monospace; font-size: var(--font-sm); }
.ws-engine-desc { color: var(--text-secondary); font-size: var(--font-sm); }
.ws-engine-details { display: flex; gap: var(--space-3); align-items: center; }
.ws-engine-fuel {
    font-size: var(--font-xs); padding: 2px 8px; border-radius: var(--radius-full);
    background: var(--bg-tertiary); color: var(--text-secondary);
}
.ws-engine-cap { font-size: var(--font-xs); color: var(--text-muted); }
.ws-engine-power { font-size: var(--font-sm); font-weight: 500; color: var(--accent); }

.ws-vehicle-header { margin-bottom: var(--space-5); }
.ws-vehicle-header h2 { font-size: var(--font-lg); font-weight: 600; margin-bottom: 4px; }
.ws-vehicle-meta { display: flex; gap: var(--space-3); color: var(--text-secondary); font-size: var(--font-sm); flex-wrap: wrap; }
.ws-vehicle-meta span {
    padding: 2px 10px; background: var(--bg-tertiary); border-radius: var(--radius-full);
}

.ws-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: var(--space-2);
}
.ws-tab {
    padding: 6px 14px;
    font-size: var(--font-sm);
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: all 0.15s;
    white-space: nowrap;
    font-family: var(--font-family);
}
.ws-tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.ws-tab-active { background: var(--accent-light); color: var(--accent); font-weight: 500; }

.ws-endpoint-data { min-height: 100px; }

.ws-section-title {
    font-weight: 600; font-size: var(--font-md);
    margin: var(--space-5) 0 var(--space-3) 0;
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--border-color);
}
.ws-table-title {
    font-weight: 500; font-size: var(--font-base);
    margin: var(--space-4) 0 var(--space-2) 0;
    color: var(--text-secondary);
}

.ws-data-table {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: var(--space-3);
}
.ws-data-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border-light);
    gap: var(--space-4);
}
.ws-data-row:last-child { border-bottom: none; }
.ws-row-label { color: var(--text-secondary); flex-shrink: 0; max-width: 50%; }
.ws-row-value { font-weight: 500; text-align: right; word-break: break-word; }
.ws-unit { color: var(--text-muted); font-weight: 400; font-size: var(--font-sm); }
.ws-row-section {
    font-weight: 600;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-light);
    font-size: var(--font-sm);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.ws-row-divider {
    height: 1px; background: var(--border-color); margin: 0;
}

.ws-pre {
    background: var(--bg-tertiary);
    padding: var(--space-4);
    border-radius: var(--radius-md);
    overflow-x: auto;
    font-size: var(--font-sm);
    white-space: pre-wrap;
    word-break: break-word;
}

.ws-loading {
    text-align: center;
    padding: var(--space-8);
    color: var(--text-muted);
}
.ws-error {
    text-align: center;
    padding: var(--space-8);
    color: var(--danger);
}
.ws-no-results {
    text-align: center;
    padding: var(--space-6);
    color: var(--text-muted);
}

/* ============== WORKSHOP MAIN TABS ============== */
.workshop-main-tabs {
    display: flex;
    gap: 4px;
    margin-left: auto;
}
.ws-main-tab {
    padding: 6px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: var(--font-sm);
    transition: all 0.15s;
}
.ws-main-tab:hover { background: var(--bg-hover); color: var(--text-primary); }
.ws-main-tab-active {
    background: var(--accent-light);
    color: var(--accent);
    border-color: var(--accent);
    font-weight: 500;
}
.workshop-tab-content.hidden { display: none; }

/* ============== AUTODATA DB STATS ============== */
.ad-stats-grid { margin-bottom: var(--space-5); }

.ad-stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}
.ad-stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-4);
    text-align: center;
}
.ad-stat-card.ad-stat-accent {
    border-color: var(--accent);
    background: var(--accent-light);
}
.ad-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}
.ad-stat-accent .ad-stat-value { color: var(--accent); }
.ad-stat-label {
    font-size: var(--font-xs);
    color: var(--text-muted);
    margin-top: 4px;
}

/* Sections (brands, endpoints) */
.ad-section {
    margin-bottom: var(--space-5);
}
.ad-section h3 {
    font-size: var(--font-md);
    font-weight: 600;
    margin-bottom: var(--space-3);
    color: var(--text-primary);
}

/* Brands with data */
.ad-brands-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.ad-brand-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 6px 0;
}
.ad-brand-name {
    min-width: 120px;
    font-weight: 500;
    font-size: var(--font-sm);
}
.ad-brand-bar-wrap {
    flex: 1;
    height: 8px;
    background: var(--bg-tertiary, var(--border));
    border-radius: 4px;
    overflow: hidden;
}
.ad-brand-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.3s;
}
.ad-brand-count {
    min-width: 110px;
    text-align: right;
    font-size: var(--font-xs);
    color: var(--text-secondary);
    font-family: monospace;
}

/* Endpoints coverage */
.ad-endpoints-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 4px;
}
.ad-ep-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 10px;
    font-size: var(--font-sm);
    border-radius: var(--radius-sm, 4px);
}
.ad-ep-row:nth-child(odd) { background: var(--bg-secondary); }
.ad-ep-name { color: var(--text-primary); }
.ad-ep-count { color: var(--text-muted); font-family: monospace; font-size: var(--font-xs); }

/* ============== AUTODATA DB SEARCH ============== */
.ad-search-section {
    margin-bottom: var(--space-5);
}
.ad-search-section h3 {
    font-size: var(--font-md);
    font-weight: 600;
    margin-bottom: var(--space-3);
}
.ad-search-results {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 400px;
    overflow-y: auto;
    background: var(--bg-primary);
}
.ad-search-results.hidden { display: none; }
.ad-search-item {
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light, var(--border));
    transition: background 0.1s;
}
.ad-search-item:last-child { border-bottom: none; }
.ad-search-item:hover { background: var(--bg-hover); }
.ad-search-item.ad-has-data { border-left: 3px solid var(--accent); }

.ad-si-main {
    display: flex;
    gap: var(--space-3);
    align-items: center;
    margin-bottom: 2px;
}
.ad-si-mfr { font-weight: 600; min-width: 90px; }
.ad-si-model { color: var(--text-primary); }
.ad-si-code { color: var(--text-muted); font-family: monospace; font-size: var(--font-xs); }

.ad-si-details {
    display: flex;
    gap: var(--space-3);
    font-size: var(--font-xs);
    color: var(--text-secondary);
}
.ad-si-fuel {
    background: var(--bg-secondary);
    padding: 1px 6px;
    border-radius: 3px;
}
.ad-si-cap { color: var(--text-muted); }
.ad-si-power { color: var(--accent); font-weight: 500; }
.ad-si-badge {
    background: var(--accent);
    color: #fff;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
}
.ad-si-badge-empty {
    background: var(--text-muted);
    opacity: 0.5;
}

/* ============== AUTODATA VEHICLE DETAIL ============== */
.ad-vehicle-detail.hidden { display: none; }
.ad-vehicle-header {
    margin-bottom: var(--space-4);
}
.ad-back-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px 12px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: var(--font-sm);
    margin-bottom: var(--space-3);
    transition: all 0.15s;
}
.ad-back-btn:hover { border-color: var(--accent); color: var(--accent); }
.ad-vehicle-header h2 {
    font-size: var(--font-lg);
    font-weight: 600;
    margin-bottom: 4px;
}
.ad-mid-badge {
    font-family: monospace;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    padding: 1px 8px;
    border-radius: 4px;
    font-size: var(--font-xs);
}
.ad-ep-count {
    font-size: var(--font-sm);
    color: var(--text-muted);
    margin-top: 4px;
}
.ad-ep-tabs {
    flex-wrap: wrap;
}

/* ============== AUTODATA OVERVIEW TAB ============== */
.ov-hero {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--accent-light, rgba(59,130,246,0.06)) 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius, 8px);
    padding: var(--space-6, 24px);
    margin-bottom: var(--space-6, 24px);
    text-align: center;
}
.ov-hero-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.ov-hero-desc {
    font-size: var(--font-sm);
    color: var(--text-muted);
    margin-bottom: var(--space-5, 20px);
}
.ov-hero-stats {
    display: flex;
    justify-content: center;
    gap: var(--space-4, 16px);
    flex-wrap: wrap;
}
.ov-hero-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 90px;
    padding: var(--space-3, 12px) var(--space-4, 16px);
    background: var(--bg-primary);
    border-radius: var(--radius, 8px);
    border: 1px solid var(--border-light, var(--border));
}
.ov-hero-stat-accent {
    border-color: var(--accent);
    background: var(--accent-light, rgba(59,130,246,0.08));
}
.ov-hero-num {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}
.ov-hero-stat-accent .ov-hero-num { color: var(--accent); }
.ov-hero-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Categories */
.ov-categories {
    display: flex;
    flex-direction: column;
    gap: var(--space-3, 12px);
    margin-bottom: var(--space-6, 24px);
}
.ov-category {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius, 8px);
    overflow: hidden;
    cursor: pointer;
}
.ov-cat-header {
    display: flex;
    align-items: center;
    gap: var(--space-3, 12px);
    padding: var(--space-4, 16px);
    transition: background 0.15s;
}
.ov-category:hover .ov-cat-header { background: var(--bg-hover, rgba(0,0,0,0.02)); }
.ov-cat-icon {
    color: var(--accent);
    flex-shrink: 0;
    display: flex;
    align-items: center;
}
.ov-cat-info { flex: 1; min-width: 0; }
.ov-cat-name { font-weight: 600; font-size: var(--font-md, 1rem); color: var(--text-primary); }
.ov-cat-meta { font-size: var(--font-xs, 0.75rem); color: var(--text-muted); margin-top: 2px; }
.ov-cat-badge {
    font-size: var(--font-xs, 0.75rem);
    font-weight: 600;
    padding: 2px 10px;
    border-radius: 12px;
    flex-shrink: 0;
}
.ov-cat-badge-full { background: rgba(16,185,129,0.12); color: #10b981; }
.ov-cat-badge-partial { background: rgba(245,158,11,0.12); color: #f59e0b; }
.ov-cat-badge-empty { background: var(--bg-tertiary, var(--border)); color: var(--text-muted); }
.ov-cat-chevron {
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.2s;
    flex-shrink: 0;
}
.ov-category-open .ov-cat-chevron { transform: rotate(180deg); }

/* Category body (collapsed by default) */
.ov-cat-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}
.ov-category-open .ov-cat-body {
    max-height: 2000px;
}

/* Endpoints */
.ov-endpoint {
    padding: var(--space-3, 12px) var(--space-4, 16px);
    border-top: 1px solid var(--border-light, var(--border));
    cursor: default;
}
.ov-ep-has-data { }
.ov-ep-no-data { opacity: 0.5; }
.ov-ep-header {
    display: flex;
    align-items: center;
    gap: var(--space-2, 8px);
    margin-bottom: 4px;
}
.ov-ep-status {
    font-size: var(--font-sm);
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}
.ov-ep-has-data .ov-ep-status { color: #10b981; font-weight: 700; }
.ov-ep-no-data .ov-ep-status { color: var(--text-muted); }
.ov-ep-name { font-weight: 500; color: var(--text-primary); }
.ov-ep-key {
    font-family: monospace;
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-tertiary, var(--border));
    padding: 1px 6px;
    border-radius: 3px;
    margin-left: auto;
}
.ov-ep-count {
    font-size: var(--font-xs, 0.75rem);
    font-weight: 600;
    color: var(--accent);
    flex-shrink: 0;
    min-width: 60px;
    text-align: right;
}
.ov-ep-none { color: var(--text-muted); font-weight: 400; }
.ov-ep-desc {
    font-size: var(--font-sm, 0.875rem);
    color: var(--text-secondary);
    margin-left: 28px;
    line-height: 1.4;
}
.ov-ep-bar-wrap {
    display: flex;
    align-items: center;
    gap: var(--space-2, 8px);
    margin-left: 28px;
    margin-top: 6px;
}
.ov-ep-bar-wrap > .ov-ep-bar {
    height: 4px;
    background: var(--accent);
    border-radius: 2px;
    min-width: 2px;
    max-width: 200px;
}
.ov-ep-bar-wrap::before {
    content: '';
    position: absolute;
}
.ov-ep-pct {
    font-size: 11px;
    color: var(--text-muted);
}

/* Fix bar wrap to have background */
.ov-ep-bar-wrap {
    position: relative;
}
.ov-ep-bar-wrap > .ov-ep-bar {
    position: relative;
    z-index: 1;
}

/* Brands grid */
.ov-section {
    margin-bottom: var(--space-6, 24px);
}
.ov-section h3 {
    font-size: var(--font-md, 1rem);
    font-weight: 600;
    margin-bottom: var(--space-3, 12px);
    color: var(--text-primary);
}
.ov-brands-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-2, 8px);
}
.ov-brand {
    display: flex;
    align-items: center;
    gap: var(--space-2, 8px);
    padding: 6px 10px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm, 4px);
    border: 1px solid var(--border-light, var(--border));
}
.ov-brand-name {
    min-width: 80px;
    font-size: var(--font-sm, 0.875rem);
    font-weight: 500;
}
.ov-brand-bar-wrap {
    flex: 1;
    height: 6px;
    background: var(--bg-tertiary, var(--border));
    border-radius: 3px;
    overflow: hidden;
}
.ov-brand-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
}
.ov-brand-stats {
    font-size: 11px;
    font-family: monospace;
    color: var(--text-secondary);
    min-width: 80px;
    text-align: right;
}
.ov-brand-stats span { color: var(--text-muted); }

/* Usage section */
.ov-usage {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius, 8px);
    padding: var(--space-5, 20px);
    margin-bottom: var(--space-5, 20px);
}
.ov-usage h3 {
    font-size: var(--font-md, 1rem);
    font-weight: 600;
    margin-bottom: var(--space-4, 16px);
}
.ov-usage-items {
    display: flex;
    flex-direction: column;
    gap: var(--space-3, 12px);
    margin-bottom: var(--space-4, 16px);
}
.ov-usage-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3, 12px);
}
.ov-usage-step {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--font-sm);
    flex-shrink: 0;
}
.ov-usage-text {
    font-size: var(--font-sm, 0.875rem);
    color: var(--text-secondary);
    line-height: 1.5;
    padding-top: 4px;
}
.ov-usage-note {
    font-size: var(--font-xs, 0.75rem);
    color: var(--text-muted);
    border-top: 1px solid var(--border-light, var(--border));
    padding-top: var(--space-3, 12px);
    font-style: italic;
}

@media (max-width: 640px) {
    .ov-hero-stats { gap: var(--space-2, 8px); }
    .ov-hero-stat { min-width: 75px; padding: var(--space-2, 8px); }
    .ov-hero-num { font-size: 1.1rem; }
    .ov-brands-grid { grid-template-columns: 1fr; }
    .ov-ep-key { display: none; }
}

/* ============== STRUKTURYZATOR: Pasek projektow + Schematy ============== */
.struct-projects-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0 12px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 12px;
    overflow-x: auto;
}
.struct-projects-scroll {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: nowrap;
    min-height: 36px;
}
.struct-project-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}
.struct-project-chip:hover {
    border-color: var(--primary);
    background: var(--bg-tertiary, var(--bg-secondary));
}
.struct-project-chip.active {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}
.struct-project-chip .chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}
.struct-project-chip.active .chip-dot {
    background: #fff;
}
.struct-project-chip-all {
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: none;
    font-size: 12px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.15s;
}
.struct-project-chip-all:hover {
    color: var(--text-primary);
}
.struct-project-chip-all.active {
    color: var(--text-primary);
    border-color: var(--text-muted);
    font-weight: 600;
}

/* Schema editor */
.schema-editor-wrap {
    position: absolute;
    inset: 0;
    background: var(--bg-primary);
    z-index: 10;
    display: flex;
    flex-direction: column;
}
.schema-editor-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
}
.schema-editor-title {
    flex: 1;
    font-weight: 600;
    font-size: 14px;
}
.schema-editor-iframe {
    flex: 1;
    border: none;
    width: 100%;
}

/* Schema list items */
.struct-schema-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm, 6px);
    cursor: pointer;
    font-size: 12px;
    transition: background 0.1s;
}
.struct-schema-item:hover {
    background: var(--bg-tertiary, rgba(0,0,0,0.05));
}
.struct-schema-item .schema-icon {
    font-size: 14px;
    opacity: 0.6;
}
.struct-schema-item .schema-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.struct-schema-item .schema-del {
    opacity: 0;
    cursor: pointer;
    color: var(--danger, #ef4444);
    font-size: 14px;
    transition: opacity 0.1s;
}
.struct-schema-item:hover .schema-del {
    opacity: 0.7;
}
.struct-schema-item .schema-del:hover {
    opacity: 1;
}

/* ============== ELEMENT DETAIL PANEL (slide-in right) ============== */
.element-detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.25);
    z-index: 900;
    transition: opacity 0.2s;
}
.element-detail-overlay.hidden { display: none; }

.element-detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 42%;
    min-width: 340px;
    max-width: 700px;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    box-shadow: -4px 0 24px rgba(0,0,0,0.12);
    z-index: 910;
    display: flex;
    flex-direction: column;
    transform: translateX(0);
    transition: transform 0.25s ease;
}
.element-detail-panel.hidden {
    transform: translateX(100%);
    pointer-events: none;
}
.element-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.element-detail-header h3 {
    font-size: var(--font-md);
    font-weight: 600;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    margin-right: var(--space-3);
}
.element-detail-body {
    flex: 1;
    overflow: auto;
    padding: 0;
}
.element-detail-body iframe {
    width: 100%;
    height: 100%;
    border: none;
}
/* Detail info (when no frontend_path) */
.element-detail-info {
    padding: var(--space-5);
}
.element-detail-info .detail-desc {
    color: var(--text-secondary);
    font-size: var(--font-sm);
    margin-bottom: var(--space-4);
    line-height: 1.5;
}
.element-detail-info .detail-status {
    display: inline-block;
    font-size: var(--font-xs);
    font-weight: 500;
    padding: 2px 10px;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    margin-bottom: var(--space-4);
}
.element-detail-info .detail-status[data-s="done"] { background: var(--success-light); color: var(--success); }
.element-detail-info .detail-status[data-s="dev"] { background: var(--accent-light); color: var(--accent); }
.element-detail-info .detail-status[data-s="design"] { background: rgba(245,158,11,.12); color: #f59e0b; }
.element-detail-info .detail-list {
    list-style: none;
    padding: 0;
    margin: 0 0 var(--space-5) 0;
}
.element-detail-info .detail-list li {
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border-light);
    font-size: var(--font-sm);
    color: var(--text-primary);
}
.element-detail-info .detail-list li::before {
    content: "\2022";
    color: var(--accent);
    margin-right: var(--space-2);
    font-weight: bold;
}
.element-detail-info .btn-request {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--font-sm);
    font-weight: 500;
    transition: background 0.15s;
}
.element-detail-info .btn-request:hover { background: var(--accent-hover); }
.element-detail-info .btn-request:disabled {
    opacity: 0.5;
    cursor: default;
}
.element-detail-info .btn-request.sent {
    background: var(--success);
}

/* Clickable tree nodes / map blocks */
.tree-node-box.clickable,
.tree-node-label.clickable {
    cursor: pointer;
    transition: box-shadow 0.15s, background 0.15s;
}
.tree-node-box.clickable:hover {
    box-shadow: 0 0 0 2px var(--accent);
}
.tree-node-label.clickable:hover {
    background: var(--accent-light);
    border-radius: var(--radius-sm);
}
/* SVG map clickable blocks */
.pdata-map-container svg rect.clickable-block {
    cursor: pointer;
    transition: stroke-width 0.15s;
}
.pdata-map-container svg rect.clickable-block:hover {
    stroke-width: 3;
    filter: brightness(1.1);
}

@media (max-width: 768px) {
    .element-detail-panel {
        width: 100%;
        min-width: 0;
        max-width: none;
    }
}

/* ============== Project Main Tree Layout ============== */
.pdata-maintree-layout {
    display: flex;
    height: clamp(400px, 70vh, calc(100vh - 240px));
    overflow: hidden;
}

.pdata-maintree-left {
    flex: 1;
    overflow: auto;
    min-width: 0;
    transition: flex 0.3s ease;
}

.pdata-maintree-layout .pdata-maintree-left:has(~ .pdata-maintree-right[style*="display: none"]),
.pdata-maintree-layout .pdata-maintree-left:has(~ .pdata-maintree-right:empty) {
    flex: 1;
}

.pdata-maintree-right {
    width: 40%;
    min-width: 320px;
    max-width: 50%;
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    overflow: hidden;
}

.pdata-maintree-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) var(--space-4);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 2;
}

.pdata-maintree-title {
    font-weight: 600;
    font-size: var(--font-sm);
    color: var(--text-secondary);
}

/* Tree node clickable states */
.tree-node-box.clickable {
    cursor: pointer;
    transition: box-shadow 0.15s, background 0.15s, transform 0.1s;
}
.tree-node-box.clickable:hover {
    box-shadow: 0 0 0 2px var(--accent);
    transform: translateY(-1px);
}
.tree-node-box.active-node {
    box-shadow: 0 0 0 3px var(--accent) !important;
    background: var(--accent-light, rgba(99, 102, 241, 0.15)) !important;
}
.tree-node-box.has-frontend {
    position: relative;
}
.tree-fp-badge {
    font-size: 10px;
    position: absolute;
    top: 2px;
    right: 4px;
    opacity: 0.7;
}
.tree-status-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}
.tree-status-dot.tree-status-planned { background: #64748b; }
.tree-status-dot.tree-status-dev { background: #f59e0b; }
.tree-status-dot.tree-status-done { background: #22c55e; }

/* Block detail panel (right column) */
.block-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    flex-shrink: 0;
}
.block-detail-header h3 {
    font-size: var(--font-base);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    margin-right: var(--space-2);
}
.block-detail-iframe {
    flex: 1;
    width: 100%;
    border: none;
    display: block;
}
.block-detail-body {
    padding: var(--space-4);
    overflow-y: auto;
    flex: 1;
}
.block-detail-desc {
    color: var(--text-secondary);
    font-size: var(--font-sm);
    margin-bottom: var(--space-3);
    line-height: 1.5;
}
.block-detail-meta {
    display: flex;
    gap: var(--space-2);
    align-items: center;
    margin-bottom: var(--space-3);
}
.block-status-badge {
    font-size: var(--font-xs);
    padding: 2px 8px;
    border-radius: 9999px;
    font-weight: 600;
}
.block-status-badge.block-status-planned { background: #64748b33; color: #94a3b8; }
.block-status-badge.block-status-dev { background: #f59e0b33; color: #f59e0b; }
.block-status-badge.block-status-done { background: #22c55e33; color: #22c55e; }
.block-progress-badge {
    font-size: var(--font-xs);
    padding: 2px 8px;
    border-radius: 9999px;
    background: var(--accent-light, rgba(99, 102, 241, 0.15));
    color: var(--accent);
    font-weight: 600;
}
.block-detail-list {
    list-style: none;
    padding: 0;
    margin: 0 0 var(--space-4) 0;
}
.block-detail-list li {
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border-light, var(--border-color));
    font-size: var(--font-sm);
    color: var(--text-primary);
}
.block-detail-list li:last-child { border-bottom: none; }
.block-detail-list li::before {
    content: '\25B8';
    margin-right: var(--space-2);
    color: var(--accent);
}
.block-gen-btn {
    width: 100%;
    margin-top: var(--space-3);
    padding: var(--space-3);
    font-size: var(--font-sm);
}
.block-gen-btn.sent {
    background: var(--success, #22c55e) !important;
    cursor: default;
}

@media (max-width: 768px) {
    .pdata-maintree-layout {
        flex-direction: column;
        height: auto;
    }
    .pdata-maintree-right {
        width: 100%;
        min-width: 0;
        max-width: none;
        border-left: none;
        border-top: 1px solid var(--border-color);
        max-height: 50vh;
    }
}
