/* Base Variables - Light Mode (Premium) */
:root {
    /* Colors */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #eff6ff;

    --bg-main: #f8fafc;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;

    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-sidebar: #cbd5e1;
    --text-sidebar-active: #ffffff;

    --border: #e2e8f0;
    --border-dark: #334155;

    /* Status Colors */
    --status-now: #ec4899;
    /* Pink */
    --status-waiting: #f59e0b;
    /* Amber */
    --status-review: #8b5cf6;
    /* Purple */
    --status-done: #10b981;
    /* Emerald */
    --status-hold: #64748b;
    /* Slate */

    /* Shadows & Radii */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --transition: 0.2s ease;
    --font-stack: 'Cairo', system-ui, -apple-system, sans-serif;

    /* Warning toast */
    --warning-bg: #fef3cd;
    --warning-border: #ffc107;
}

/* Dark Mode Wrapper */
html[data-theme="dark"] {
    --bg-main: #0f172a;
    --bg-surface: #1e293b;
    --bg-card: #1e293b;
    --bg-sidebar: #020617;

    --text-main: #f8fafc;
    --text-muted: #94a3b8;

    --border: #334155;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.5);

    --warning-bg: #422006;
    --warning-border: #b45309;
}

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

body {
    font-family: var(--font-stack);
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    overflow: hidden;
    font-size: 14px;
}

/* Typography */
h1,
h2,
h3,
h4 {
    font-weight: 700;
}

h2 {
    font-size: 1.25rem;
}

h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

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

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    border-inline-end: 1px solid var(--border-dark);
}

.sidebar-header {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid var(--border-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-header h2 {
    color: white;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.nav-section h3 {
    margin-bottom: 0.5rem;
}

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

.section-header h3 {
    margin: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: transparent;
    border: none;
    color: var(--text-sidebar);
    font-family: var(--font-stack);
    font-size: 0.95rem;
    text-align: right;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.nav-item .nav-badge {
    margin-inline-start: auto;
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-sidebar-active);
    font-size: 0.7rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    min-width: 18px;
    text-align: center;
}

.nav-item .nav-badge.view-count {
    background: rgba(148, 163, 184, 0.35);
    color: #f8fafc;
}

.nav-item.active .nav-badge.view-count {
    background: rgba(255, 255, 255, 0.24);
    color: #ffffff;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-sidebar-active);
}

.nav-item.active {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

.nav-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-list li {
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-item-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.nav-list li:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-sidebar-active);
}

.nav-list li.active-filter {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-inline-start: 3px solid var(--primary);
}

/* Sidebar section count badge */
.sidebar-section-count {
    font-size: 0.72rem;
    color: rgba(148, 163, 184, 0.6);
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}

/* Sidebar show-more button */
.sidebar-show-more {
    display: block;
    width: 100%;
    background: transparent;
    border: none;
    color: rgba(148, 163, 184, 0.6);
    font-family: var(--font-stack);
    font-size: 0.78rem;
    text-align: center;
    padding: 0.25rem 0;
    cursor: pointer;
    margin-top: 0.1rem;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.sidebar-show-more:hover {
    color: var(--text-sidebar-active);
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-show-more.hidden {
    display: none;
}

.sidebar-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--border-dark);
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.35rem;
}

.sidebar-footer .btn {
    font-size: 0.72rem;
    padding: 0.4rem 0.5rem;
    gap: 0.3rem;
    border-color: var(--border-dark);
    color: var(--text-sidebar);
    background: transparent;
    justify-content: center;
}

.sidebar-footer .btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

.sidebar-footer .btn i {
    font-size: 0.9rem;
}

.sidebar-footer .btn:last-of-type {
    grid-column: 2 / 3;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Top Bar */
.top-bar {
    height: 70px;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    flex-shrink: 0;
}

.search-bar {
    display: flex;
    align-items: center;
    background-color: var(--bg-main);
    border-radius: var(--radius-md);
    padding: 0.5rem 1rem;
    width: 400px;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.search-bar:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.search-bar input {
    border: none;
    background: transparent;
    width: 100%;
    padding: 0 0.5rem;
    font-family: var(--font-stack);
    outline: none;
    color: var(--text-main);
    font-size: 0.95rem;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.notifications-btn {
    position: relative;
}

.notifications-count {
    position: absolute;
    top: -6px;
    inset-inline-start: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: #ef4444;
    color: #ffffff;
    font-size: 0.68rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    border: 2px solid var(--bg-surface);
}

.auth-status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-main);
    color: var(--text-muted);
    font-size: 0.8rem;
    white-space: nowrap;
}

.auth-status-badge.connected {
    border-color: #16a34a;
    color: #166534;
    background: #f0fdf4;
}

.sync-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-main);
    color: var(--text-muted);
    font-size: 0.78rem;
    white-space: nowrap;
}

.sync-status-badge.status-local {
    border-color: #f59e0b;
    color: #92400e;
    background: #fffbeb;
}

.sync-status-badge.status-syncing,
.sync-status-badge.status-idle {
    border-color: #3b82f6;
    color: #1d4ed8;
    background: #eff6ff;
}

.sync-status-badge.status-ok {
    border-color: #16a34a;
    color: #166534;
    background: #f0fdf4;
}

.sync-status-badge.status-error {
    border-color: #ef4444;
    color: #991b1b;
    background: #fef2f2;
}

.sync-status-badge.status-conflict {
    border-color: #be123c;
    color: #9f1239;
    background: #fff1f2;
}

html[data-theme="dark"] .auth-status-badge.connected {
    border-color: #22c55e;
    color: #bbf7d0;
    background: rgba(34, 197, 94, 0.15);
}

.view-toggle {
    display: flex;
    background: var(--bg-main);
    border-radius: var(--radius-md);
    padding: 0.25rem;
    border: 1px solid var(--border);
}

.view-toggle button {
    padding: 0.4rem 0.6rem;
    border-radius: calc(var(--radius-md) - 2px);
    color: var(--text-muted);
}

.view-toggle button.active {
    background: var(--bg-surface);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-family: var(--font-stack);
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
    font-size: 0.95rem;
}

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

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

.btn.primary.outline {
    background-color: transparent;
    color: var(--primary);
    border-color: var(--primary);
}

.btn.primary.outline:hover {
    background-color: var(--primary-light);
}

.btn.secondary {
    background-color: var(--bg-main);
    color: var(--text-main);
    border-color: var(--border);
}

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

.btn.xs {
    padding: 0.22rem 0.55rem;
    font-size: 0.75rem;
}

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

.btn.danger:hover {
    background-color: #fee2e2;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
    transition: var(--transition);
    padding: 0.2rem;
    border-radius: 4px;
}

.icon-btn:hover {
    color: var(--primary);
    background: rgba(0, 0, 0, 0.05);
}

.icon-btn.xs {
    font-size: 1rem;
    color: var(--text-sidebar);
}

.full-width {
    width: 100%;
}

.mt-2 {
    margin-top: 0.5rem;
}

/* Dropdown */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: var(--bg-surface);
    min-width: 200px;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    top: 110%;
    right: 0;
    overflow: hidden;
}

.dropdown:hover .dropdown-content {
    display: block;
}

.dropdown-content a {
    color: var(--text-main);
    padding: 0.75rem 1rem;
    text-decoration: none;
    display: block;
    font-size: 0.9rem;
    transition: var(--transition);
}

.dropdown-content a:hover {
    background-color: var(--bg-main);
    color: var(--primary);
}

/* View Container */
.view-container {
    flex: 1;
    overflow: hidden;
    position: relative;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

/* Kanban Board */
.kanban-board {
    display: flex;
    gap: 1.5rem;
    height: 100%;
    overflow-x: auto;
    padding-bottom: 1rem;
}

.kanban-column {
    flex: 0 0 320px;
    background-color: var(--bg-main);
    /* slightly off-surface */
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    max-height: 100%;
    border: 1px solid var(--border);
}

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

.kanban-header h3 {
    margin: 0;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.count-badge {
    background: var(--border);
    color: var(--text-main);
    padding: 0.1rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.kanban-cards {
    padding: 1rem;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Task Card */
.task-card {
    background-color: var(--bg-surface);
    border-radius: var(--radius-md);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.task-card:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
    border-color: var(--primary-light);
}

.task-card.dragging {
    opacity: 0.5;
}

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

.card-title {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-main);
    line-height: 1.4;
}

.card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.badge {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
}

.badge.category {
    background: #e0e7ff;
    color: #4338ca;
}

.badge.entity {
    background: #dcfce7;
    color: #15803d;
}

.badge.partner {
    background: #ffedd5;
    color: #c2410c;
}

.badge.due {
    background: #fee2e2;
    color: #b91c1c;
}

.badge.tag {
    background: var(--bg-main);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.badge.status-label {
    border: 1px solid transparent;
}

.badge.status-draft {
    background: #fffbeb;
    color: #b45309;
    border-color: #fcd34d;
}

.badge.status-pending {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #bfdbfe;
}

.badge.status-review {
    background: #ecfeff;
    color: #0f766e;
    border-color: #99f6e4;
}

.badge.status-completed {
    background: #ecfdf5;
    color: #047857;
    border-color: #a7f3d0;
}

.badge.status-hold {
    background: #f1f5f9;
    color: #475569;
    border-color: #cbd5e1;
}

.badge.status-progress {
    background: #eef2ff;
    color: #4338ca;
    border-color: #c7d2fe;
}

.badge.status-scheduled {
    background: #ede9fe;
    color: #6d28d9;
    border-color: #ddd6fe;
}

.badge.status-blocked {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fecaca;
}

.badge.badge-sector {
    background: #eef2ff;
    color: #4338ca;
    border-color: #c7d2fe;
}

.badge.badge-activity {
    background: #fdf4ff;
    color: #a21caf;
    border-color: #e9a8f0;
}

.badge.badge-activity:hover,
.badge.badge-sector:hover {
    filter: brightness(0.95);
}

.badge.urgency-badge {
    border: 1px solid transparent;
}

.badge.urgency-overdue {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fecaca;
}

.badge.urgency-urgent {
    background: #fff7ed;
    color: #9a3412;
    border-color: #fed7aa;
}

.badge.urgency-soon {
    background: #fffbeb;
    color: #92400e;
    border-color: #fde68a;
}

.badge.publish-badge {
    background: rgba(212, 175, 55, 0.12);
    color: var(--gold);
    border: 1px solid rgba(212, 175, 55, 0.35);
}

.badge.draft-task-badge {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fcd34d;
}

.badge.minister-stale-badge {
    background: #fff1f2;
    color: #be123c;
    border: 1px solid #fecdd3;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    padding-top: 0.5rem;
    margin-top: 0.5rem;
}

.card-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.card-progress-container {
    margin: 0.4rem 0;
    padding: 0 0.25rem;
}

.card-progress-head {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.28rem;
}

.task-card.urgency-overdue {
    border-inline-start-color: #dc2626;
}

.task-card.urgency-urgent {
    border-inline-start-color: #ea580c;
}

.task-card.urgency-soon {
    border-inline-start-color: #ca8a04;
}

.task-card.minister-stale {
    box-shadow: 0 0 0 1px rgba(244, 63, 94, 0.22);
}

/* List View */
.list-view {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: auto;
    flex: 1;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: right;
}

.data-table th,
.data-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: var(--bg-main);
    font-weight: 700;
    color: var(--text-muted);
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-table tbody tr:hover {
    background: rgba(37, 99, 235, 0.04);
    cursor: pointer;
    border-inline-start: 3px solid var(--primary);
}

html[data-theme="dark"] .data-table tbody tr:hover {
    background: rgba(37, 99, 235, 0.08);
}

.hidden {
    display: none !important;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
    justify-content: flex-end;
    overflow-y: auto;
    /* Drawer on side */
}

.modal-overlay.active {
    display: flex;
}

/* Drawer for Tasks */
.drawer {
    background: var(--bg-surface);
    width: 600px;
    max-width: 100%;
    height: 100vh;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease forwards;
}

html[dir="rtl"] .drawer {
    animation: slideInRTL 0.3s ease forwards;
}

@keyframes slideInRTL {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(0);
    }
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

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

.drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.drawer-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 1rem;
}

.spacer {
    flex: 1;
}

/* Simple Modal */
.modal {
    background: var(--bg-surface);
    width: 400px;
    max-width: calc(100vw - 1.5rem);
    max-height: calc(100vh - 1.5rem);
    margin: auto;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

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

.modal-body {
    padding: 1.5rem;
    min-height: 0;
    overflow-y: auto;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    flex-shrink: 0;
}

/* Minister Publish Source */
.pm-data-source {
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    font-size: 0.8125rem;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.pm-data-source-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--text-main);
}

.pm-data-source-title i {
    color: var(--gold);
}

.pm-data-source-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.pm-data-source-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.pm-data-source-actions .btn {
    font-size: 0.75rem;
}

.pm-data-source-actions .btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
}

input[type="text"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-stack);
    outline: none;
    transition: var(--transition);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

/* Checklist */
.checklist-container {
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.checklist-add {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.checklist-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

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

.btn-remove-check {
    color: #ef4444;
    background: none;
    border: none;
    cursor: pointer;
}

/* Filters Bar */
.filters-bar {
    padding: 0.5rem 1.5rem;
    background: var(--bg-main);
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 0.5rem;
}

.filter-chip {
    background: var(--primary-light);
    color: var(--primary);
    padding: 0.2rem 0.8rem;
    border-radius: 16px;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    border: 1px solid var(--primary);
}

.filter-chip .close {
    cursor: pointer;
}

.filter-chip.filter-chip-clear {
    cursor: pointer;
    background: #fff1f2;
    border-color: #fecdd3;
    color: #be123c;
}

.filter-chip.filter-chip-toggle {
    cursor: pointer;
    border-style: dashed;
}

.filter-chip.filter-chip-toggle.active {
    background: #f0fdf4;
    color: #166534;
    border-color: #16a34a;
}

.list-empty-row td {
    text-align: center;
    color: var(--text-muted);
    padding: 1.1rem 0.75rem;
}

/* Matrix Views */
.matrix-view {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex: 1;
    min-height: 0;
}

.matrix-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 0.85rem 1rem;
}

.matrix-mode-toggle {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.matrix-mode-toggle .btn {
    font-size: 0.82rem;
    padding: 0.45rem 0.75rem;
}

.matrix-mode-toggle .btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.matrix-summary {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.matrix-stat {
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.2rem 0.65rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.matrix-stat strong {
    color: var(--text-main);
}

.matrix-stat.danger {
    background: #fff1f2;
    border-color: #fecdd3;
    color: #be123c;
}

.matrix-content {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding-inline-end: 0.25rem;
}

.matrix-table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    overflow: auto;
}

.matrix-table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
}

.matrix-table th,
.matrix-table td {
    padding: 0.65rem;
    border-bottom: 1px solid var(--border);
    border-inline-start: 1px solid var(--border);
    text-align: center;
}

.matrix-table th:first-child,
.matrix-table td:first-child {
    border-inline-start: none;
}

.matrix-corner {
    position: sticky;
    top: 0;
    right: 0;
    z-index: 4;
    min-width: 220px;
    text-align: right;
    background: var(--bg-main);
    color: var(--text-muted);
}

.matrix-col-header {
    position: sticky;
    top: 0;
    z-index: 3;
    min-width: 110px;
    white-space: nowrap;
    background: var(--bg-main);
    color: var(--text-muted);
    font-size: 0.83rem;
}

.matrix-row-header {
    position: sticky;
    right: 0;
    z-index: 2;
    min-width: 220px;
    text-align: right;
    background: var(--bg-surface);
    font-weight: 700;
    white-space: nowrap;
}

.capability-table tbody tr:hover {
    background: var(--primary-light);
}

.matrix-cell-hit {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: none;
    background: #16a34a;
    color: #fff;
    cursor: pointer;
    position: relative;
    transition: var(--transition);
}

.matrix-cell-hit:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
    background: #15803d;
}

.matrix-workload {
    position: absolute;
    top: -8px;
    left: -8px;
    min-width: 16px;
    height: 16px;
    border-radius: 999px;
    background: #f59e0b;
    color: #fff;
    border: 2px solid var(--bg-surface);
    font-size: 0.62rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.2rem;
}

.matrix-cell-miss {
    color: var(--text-muted);
    opacity: 0.6;
    font-weight: 700;
}

.matrix-tip {
    margin-top: 0.65rem;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.matrix-empty-state {
    min-height: 220px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    color: var(--text-muted);
}

.matrix-empty-state i {
    font-size: 2rem;
}

.matrix-empty-state h3 {
    margin: 0;
    color: var(--text-main);
}

.matrix-empty-state p {
    margin: 0;
}

.matrix-entity-group {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    margin-bottom: 0.8rem;
    overflow: hidden;
}

.matrix-entity-group summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    background: var(--bg-main);
    border-bottom: 1px solid var(--border);
    font-weight: 700;
}

.matrix-entity-group summary::-webkit-details-marker {
    display: none;
}

.entity-count {
    font-size: 0.78rem;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.1rem 0.55rem;
}

.matrix-entity-body {
    padding: 1rem;
    display: grid;
    gap: 0.85rem;
}

.assignment-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.8rem;
    background: var(--bg-main);
}

.assignment-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.8rem;
    margin-bottom: 0.7rem;
}

.assignment-card-header h4 {
    font-size: 0.98rem;
    margin-bottom: 0.25rem;
}

.assignment-card-header p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.assignment-card-header .btn {
    font-size: 0.8rem;
    padding: 0.35rem 0.65rem;
}

.assignment-slots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.65rem;
}

.assignment-slot {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.55rem;
    background: var(--bg-surface);
}

.assignment-slot.gap {
    border-style: dashed;
    border-color: #fb7185;
    background: #fff1f2;
}

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

.sector-pill {
    background: #e2e8f0;
    color: #334155;
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: 999px;
    padding: 0.14rem 0.55rem;
}

.assignment-slot-body {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.assignment-badges {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    min-height: 24px;
}

.assignment-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.14rem 0.5rem;
    border: 1px solid transparent;
}

.assignment-badge.primary {
    background: #dcfce7;
    color: #166534;
    border-color: #86efac;
}

.assignment-badge.secondary {
    background: #ffedd5;
    color: #9a3412;
    border-color: #fdba74;
}

.assignment-remove {
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.assignment-gap-label {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    color: #be123c;
    font-size: 0.75rem;
    font-weight: 700;
}

.assignment-select {
    font-size: 0.82rem;
    padding: 0.38rem 0.48rem;
}

/* === Agreements Summary === */
.agreements-summary {
    display: flex;
    gap: 0.5rem;
    padding: 0.65rem 1.5rem;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
}

/* === Card Enhancements === */

/* Category Badge Colors */
.badge-agreement {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-project {
    background: #ede9fe;
    color: #7c3aed;
}

.badge-meeting {
    background: #ccfbf1;
    color: #0d9488;
}

.badge-visit {
    background: #ffedd5;
    color: #ea580c;
}

.badge-task {
    background: #e0e7ff;
    color: #4338ca;
}

/* Due Date Color Coding */
.due-overdue {
    color: #dc2626 !important;
    font-weight: 700;
}

.due-urgent {
    color: #d97706 !important;
}

.due-ok {
    color: #16a34a !important;
}

/* Checklist Progress */
.checklist-progress-badge {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.checklist-progress-badge.checklist-behind {
    background: #fff7ed;
    color: #9a3412;
    border-color: #fed7aa;
}

.checklist-progress-badge.checklist-steady {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #bfdbfe;
}

.checklist-progress-badge.checklist-complete {
    background: #ecfdf5;
    color: #047857;
    border-color: #a7f3d0;
}

.checklist-progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.checklist-progress-fill {
    height: 100%;
    background: #10b981;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.checklist-progress-fill.checklist-behind {
    background: #f59e0b;
}

.checklist-progress-fill.checklist-steady {
    background: var(--primary);
}

.checklist-progress-fill.checklist-complete {
    background: #10b981;
}

/* Drag Handle */
.drag-handle {
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.2s;
    cursor: grab;
    margin-inline-end: 0.25rem;
}

.task-card:hover .drag-handle {
    opacity: 0.5;
}

/* Quick Status Select */
.quick-status-select {
    font-size: 0.7rem;
    padding: 0.1rem 0.25rem;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--bg-main);
    color: var(--text-muted);
    cursor: pointer;
    font-family: var(--font-stack);
    max-width: 90px;
}

/* Empty Kanban Column */
.kanban-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 2rem;
    color: var(--text-muted);
    text-align: center;
}

.kanban-empty-state i {
    font-size: 2rem;
    opacity: 0.4;
}

.kanban-empty-state p {
    font-size: 0.85rem;
}

/* Sidebar Count Badge */
.sidebar-count {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-sidebar);
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    min-width: 20px;
    text-align: center;
}

/* === Notes System === */
.notes-section {
    margin-top: 0.5rem;
}

.notes-toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.notes-empty-hint {
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 1rem;
    text-align: center;
    background: var(--bg-main);
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
}

.note-entry {
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}

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

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

.note-actions {
    display: flex;
    gap: 0.25rem;
}

.note-editor {
    width: 100%;
    min-height: 80px;
    font-family: "Courier New", monospace;
    font-size: 0.85rem;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    color: var(--text-main);
    resize: vertical;
    direction: rtl;
}

.note-preview {
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    line-height: 1.6;
    font-size: 0.9rem;
}

.note-preview h2,
.note-preview h3,
.note-preview h4 {
    margin: 0.5rem 0;
}

.note-preview ul {
    padding-inline-start: 1.5rem;
}

.note-preview code {
    background: var(--bg-main);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-size: 0.85em;
}

.note-preview a {
    color: var(--primary);
}

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

.history-entry {
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 0;
}

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

.history-entry pre {
    white-space: pre-wrap;
    font-size: 0.8rem;
    margin-top: 0.3rem;
    background: var(--bg-main);
    padding: 0.5rem;
    border-radius: var(--radius-md);
}

/* Responsive */
@media (max-width: 980px) {
    .top-bar {
        height: auto;
        padding: 0.8rem 1rem;
        gap: 0.75rem;
        align-items: flex-start;
        flex-direction: column;
    }

    .search-bar {
        width: 100%;
    }

    .top-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .sidebar {
        width: 235px;
    }

    .matrix-corner,
    .matrix-row-header {
        min-width: 170px;
    }
}

@media (max-width: 720px) {
    .app-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    body {
        overflow: auto;
    }

    .sidebar {
        width: 100%;
        border-inline-end: none;
        border-bottom: 1px solid var(--border-dark);
    }

    .main-content {
        min-height: calc(100vh - 320px);
    }

    .view-container {
        padding: 0.9rem;
    }

    .filters-bar {
        padding: 0.55rem 0.9rem;
    }

    .matrix-mode-toggle {
        width: 100%;
    }

    .matrix-mode-toggle .btn {
        width: 100%;
        justify-content: center;
    }

    .matrix-summary {
        width: 100%;
    }
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-dark);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Knowledge Base View */
.knowledge-base-view {
    padding: 1.5rem;
}

.notifications-view {
    padding: 1.5rem;
}

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

.notifications-header h2 {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.2rem;
}

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

.notification-card {
    border: 1px solid var(--border);
    background: var(--bg-card);
    border-radius: 12px;
    padding: 0.9rem 1rem;
    display: flex;
    justify-content: space-between;
    gap: 0.9rem;
    align-items: flex-start;
}

.notification-card.unread {
    border-color: var(--primary);
    box-shadow: inset 3px 0 0 var(--primary);
}

.notification-card.severity-critical {
    border-color: rgba(239, 68, 68, 0.45);
}

.notification-card.severity-warning {
    border-color: rgba(245, 158, 11, 0.45);
}

.notification-main h3 {
    margin: 0 0 0.35rem;
    font-size: 0.95rem;
}

.notification-main p {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.6;
    font-size: 0.86rem;
}

.notification-meta {
    margin-top: 0.55rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    font-size: 0.76rem;
    color: var(--text-muted);
}

.notification-actions {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.notifications-empty {
    border: 1px dashed var(--border);
    border-radius: 10px;
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-muted);
}

.notifications-empty i {
    font-size: 2rem;
    opacity: 0.55;
    display: block;
    margin-bottom: 0.4rem;
}

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

.kb-header h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    color: var(--text);
}

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

.kb-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
}

.kb-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.kb-card-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.kb-preview {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.6;
    max-height: 100px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.kb-preview p {
    margin: 0;
}

.kb-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.kb-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.kb-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.kb-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.kb-empty p {
    margin-top: 0.75rem;
}

/* Undo Toast */
.undo-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    animation: slideUp 0.3s ease;
}

.undo-toast.hidden {
    display: none;
}

.status-toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    max-width: min(90vw, 420px);
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.7rem 1rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    animation: slideUp 0.3s ease;
    line-height: 1.5;
}

.status-toast.hidden {
    display: none;
}

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

    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

/* Search Highlighting */
.search-highlight {
    background: #fef08a;
    color: #713f12;
    border-radius: 2px;
    padding: 0 2px;
}

[data-theme="dark"] .search-highlight {
    background: #854d0e;
    color: #fef9c3;
}

/* Sidebar Collapse */
.sidebar.collapsed {
    width: 60px;
    min-width: 60px;
    overflow: hidden;
}

.sidebar.collapsed .sidebar-header h2,
.sidebar.collapsed .sidebar-nav h3,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-list li span,
.sidebar.collapsed .sidebar-footer,
.sidebar.collapsed .section-header .icon-btn,
.sidebar.collapsed .sidebar-count,
.sidebar.collapsed .nav-item::after {
    display: none;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 0.6rem;
}

.sidebar.collapsed .nav-item i {
    font-size: 1.25rem;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 0.75rem 0.5rem;
}

.sidebar-collapse-btn {
    margin-inline-start: auto;
}

.sidebar.collapsed .sidebar-collapse-btn i {
    transform: rotate(180deg);
}

/* Keyboard Shortcuts Modal */
.shortcut-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

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

.shortcut-row kbd {
    display: inline-block;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0.2rem 0.5rem;
    font-family: monospace;
    font-size: 0.85rem;
    min-width: 28px;
    text-align: center;
}

/* Sortable List Headers */
.data-table th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.data-table th.sortable:hover {
    color: var(--primary);
}

.data-table th.sortable i {
    font-size: 0.8rem;
    opacity: 0.5;
    margin-inline-start: 0.25rem;
}

/* Entity Dossier */
.entity-dossier {
    padding: 1.5rem;
    height: 100%;
    overflow-y: auto;
}

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

.dossier-header h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.4rem;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.dossier-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.dossier-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

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

.stat-card.stat-danger {
    border-color: #ef4444;
    background: #fef2f2;
}

[data-theme="dark"] .stat-card.stat-danger {
    background: rgba(239, 68, 68, 0.1);
}

.stat-number {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--primary);
}

.stat-card.stat-danger .stat-number {
    color: #ef4444;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.dossier-section {
    margin-bottom: 1.5rem;
}

.dossier-section h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
}

.dossier-breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.dossier-note {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    line-height: 1.7;
}

.dossier-btn {
    opacity: 0;
    transition: opacity 0.2s;
}

li:hover .dossier-btn {
    opacity: 1;
}

/* Contacts */
.contacts-picker {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.contacts-picker-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.contacts-picker-actions select {
    flex: 1;
}

.contact-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    min-height: 32px;
}

.contact-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

.contact-chip-name {
    cursor: pointer;
    font-weight: 600;
}

.contact-chip-name:hover {
    color: var(--primary);
}

.contact-chip-action {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-decoration: none;
    padding: 0 0.15rem;
}

.contact-chip-action:hover {
    color: var(--primary);
}

.contact-chip-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 0.15rem;
    font-size: 0.8rem;
}

.contact-chip-remove:hover {
    color: #ef4444;
}

/* Contact Cards in Dossier */
.contacts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.75rem;
}

.contact-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

.contact-card:hover {
    border-color: var(--primary);
}

.contact-card-name {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 0.15rem;
}

.contact-card-role {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.contact-card-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.8rem;
}

.contact-card-info a {
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.contact-card-info a:hover {
    text-decoration: underline;
}

.contact-card-notes {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
    border-top: 1px solid var(--border);
    padding-top: 0.4rem;
}

/* Export Context Pack Modal */
.export-preview-stats {
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-top: 0.5rem;
}

.export-stat-row {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    font-size: 0.85rem;
}

.export-stat-row+.export-stat-row {
    border-top: 1px solid var(--border);
}

/* =====================================================
   AUTH GATE — Full-Screen Login
   ===================================================== */
.auth-gate {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.auth-gate.hidden {
    display: none;
}

.auth-gate-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(37, 99, 235, 0.12) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
        var(--bg-sidebar);
    z-index: 0;
}

html[data-theme="dark"] .auth-gate-bg {
    background:
        radial-gradient(ellipse at 20% 50%, rgba(37, 99, 235, 0.15) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.1) 0%, transparent 50%),
        #020617;
}

.auth-card {
    position: relative;
    z-index: 1;
    background: var(--bg-surface);
    border-radius: 20px;
    width: 100%;
    max-width: 420px;
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.05);
    overflow: hidden;
    animation: authCardIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authCardIn {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.96);
    }

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

.auth-card-header {
    padding: 2.5rem 2rem 1.5rem;
    text-align: center;
}

.auth-logo {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: white;
    box-shadow: 0 8px 24px rgba(37, 99, 235, 0.3);
}

.auth-card-header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 0.4rem;
}

.auth-card-header p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.auth-card-body {
    padding: 0 2rem 2rem;
}

.auth-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-main);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    padding: 0 0.75rem;
    transition: all 0.2s;
}

.auth-input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.auth-input-wrapper i {
    color: var(--text-muted);
    font-size: 1.1rem;
    flex-shrink: 0;
}

.auth-input-wrapper input {
    border: none;
    background: transparent;
    width: 100%;
    padding: 0.75rem 0.5rem;
    font-family: var(--font-stack);
    font-size: 0.95rem;
    outline: none;
    color: var(--text-main);
}

.auth-submit-btn {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    font-size: 1rem;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.25rem 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.auth-sent-icon {
    text-align: center;
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 1rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.7;
        transform: scale(1.05);
    }
}

.auth-sent-msg {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.7;
    margin-bottom: 1.5rem;
}

.auth-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 1rem auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.auth-loading-msg {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.auth-card-footer {
    padding: 0.75rem 2rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    background: var(--bg-main);
}

/* =====================================================
   FRONTEND POLISH — Refined Details
   ===================================================== */

/* Smoother sidebar transition */
.sidebar {
    transition: width 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Better card hover with subtle left border accent */
.task-card {
    border-inline-start: 3px solid transparent;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.task-card:hover {
    border-inline-start-color: var(--primary);
}

/* Status color strips on kanban headers */
.kanban-header {
    position: relative;
}

.kanban-header::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
}

.kanban-column:nth-child(1) .kanban-header::after {
    background: var(--status-now);
}

.kanban-column:nth-child(2) .kanban-header::after {
    background: var(--status-waiting);
}

.kanban-column:nth-child(3) .kanban-header::after {
    background: var(--status-review);
}

.kanban-column:nth-child(4) .kanban-header::after {
    background: var(--status-done);
}

.kanban-column:nth-child(5) .kanban-header::after {
    background: var(--status-hold);
}

/* Refined modal backdrop */
.modal-overlay {
    backdrop-filter: blur(4px);
}

/* Input focus improvements */
input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
    outline: none;
}

/* Badge refinement — pill shapes */
.badge {
    letter-spacing: 0.01em;
}

/* Smooth page transitions */
.view-container>div {
    animation: viewFadeIn 0.2s ease;
}

@keyframes viewFadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

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

/* Drawer slide-in */
.modal-overlay.active .drawer {
    animation: drawerSlide 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes drawerSlide {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

html[dir="rtl"] .modal-overlay.active .drawer {
    animation-name: drawerSlideRtl;
}

@keyframes drawerSlideRtl {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(0);
    }
}

/* Modal scale-in */
.modal-overlay.active .modal {
    animation: modalScaleIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Topbar subtle shadow on scroll feel */
.top-bar {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* Kanban column gentle stagger on load (opt-in to prevent refresh flashes) */
body[data-kanban-animate="1"] .kanban-column {
    animation: colFadeIn 0.3s ease backwards;
}

body[data-kanban-animate="1"] .kanban-column:nth-child(1) {
    animation-delay: 0s;
}

body[data-kanban-animate="1"] .kanban-column:nth-child(2) {
    animation-delay: 0.05s;
}

body[data-kanban-animate="1"] .kanban-column:nth-child(3) {
    animation-delay: 0.1s;
}

body[data-kanban-animate="1"] .kanban-column:nth-child(4) {
    animation-delay: 0.15s;
}

body[data-kanban-animate="1"] .kanban-column:nth-child(5) {
    animation-delay: 0.2s;
}

@keyframes colFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

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

/* Nav item subtle left accent on active */
.nav-item.active {
    box-shadow: inset 3px 0 0 0 rgba(255, 255, 255, 0.3);
}

/* Scrollbar polish for sidebar */
.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

/* --- Command Palette --- */
.cmd-palette-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(6px);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 18vh;
}

.cmd-palette-overlay.active {
    display: flex;
    animation: fadeIn 0.15s ease-out;
}

.cmd-palette {
    width: min(560px, 92vw);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
    overflow: hidden;
    animation: scaleIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.cmd-input-row i {
    font-size: 1.25rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.cmd-input-row input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: var(--font-stack);
    font-size: 1rem;
    color: var(--text-main);
    outline: none;
}

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

.cmd-input-row kbd {
    font-family: var(--font-stack);
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 5px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.cmd-results {
    max-height: 360px;
    overflow-y: auto;
    padding: 0.5rem;
}

.cmd-result-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.1s;
}

.cmd-result-item:hover,
.cmd-result-item.selected {
    background: var(--primary-light);
}

.cmd-result-item.selected {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.cmd-result-item i {
    font-size: 1.2rem;
    color: var(--primary);
    flex-shrink: 0;
    width: 28px;
    text-align: center;
}

.cmd-result-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.cmd-result-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cmd-result-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cmd-result-type {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: var(--bg-main);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    flex-shrink: 0;
}

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

/* Hidden utility */
.hidden {
    display: none !important;
}

/* Phosphor spin animation */
.ph-spin {
    animation: spin 1s linear infinite;
}
