:root {
    /* Colors - Dark Theme */
    --bg-app: #030303;
    --bg-panel: #0a0a0c;
    --bg-card: #121214;
    --bg-hover: #1e1e24;
    
    --border-subtle: #27272a;
    --border-strong: #3f3f46;
    
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    
    /* Accents */
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    
    /* Status Colors */
    --status-open-bg: rgba(59, 130, 246, 0.15);
    --status-open-color: #60a5fa;
    --status-in-progress-bg: rgba(234, 179, 8, 0.15);
    --status-in-progress-color: #fbd38d;
    --status-resolved-bg: rgba(34, 197, 94, 0.15);
    --status-resolved-color: #4ade80;
    --status-overdue-bg: rgba(239, 68, 68, 0.15);
    --status-overdue-color: #f87171;
    
    /* Priority Colors */
    --priority-high-bg: rgba(220, 38, 38, 0.2);
    --priority-high-color: #fca5a5;
    --priority-medium-bg: rgba(217, 119, 6, 0.2);
    --priority-medium-color: #fcd34d;
    --priority-low-bg: rgba(22, 163, 74, 0.2);
    --priority-low-color: #86efac;

    /* Typography */
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-medium: 0.3s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-app);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    overflow: hidden; /* Prevent body scroll, layout handles it */
}


.login-page {
    overflow: auto;
    min-height: 100vh;
    background:
        radial-gradient(1000px 420px at 10% -10%, rgba(59, 130, 246, 0.15), transparent),
        radial-gradient(900px 360px at 110% -20%, rgba(139, 92, 246, 0.14), transparent),
        var(--bg-app);
}

.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 460px;
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 28px;
    box-shadow: 0 26px 60px rgba(0, 0, 0, 0.45);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    font-weight: 700;
    font-size: 20px;
}

.login-brand i {
    font-size: 22px;
}

.login-card h1 {
    font-size: 22px;
    margin-bottom: 8px;
}

.login-subtitle {
    margin: 0 0 18px;
    color: var(--text-secondary);
    font-size: 14px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.login-error {
    margin: 0;
    color: #fca5a5;
    font-size: 13px;
}

.notification-trigger {
    position: relative;
}

.notification-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    border-radius: 999px;
    padding: 0 4px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    line-height: 16px;
    text-align: center;
}

.notification-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 340px;
    max-height: 420px;
    overflow: hidden;
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    display: none;
    z-index: 2000;
}

.notification-panel.open {
    display: block;
}

.notification-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.notification-list {
    max-height: 360px;
    overflow-y: auto;
}

.notification-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.notification-item i {
    margin-top: 2px;
    color: var(--accent-blue);
}

.notification-copy p {
    margin: 0;
    font-size: 13px;
    color: var(--text-primary);
}

.notification-copy span {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-muted);
}

.notification-empty {
    padding: 18px 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Layout */
.app-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    transition: width var(--transition-medium), opacity var(--transition-medium), border-color var(--transition-medium);
}

.app-layout.sidebar-collapsed .sidebar {
    width: 0;
    opacity: 0;
    border-right-color: transparent;
    pointer-events: none;
}

.sidebar-header {
    padding: 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
}

.logo i {
    font-size: 24px;
    color: var(--text-primary);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px;
}

.nav-links {
    list-style: none;
    margin-bottom: 24px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.nav-link i {
    font-size: 18px;
}

.nav-link:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.nav-link.active {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.nav-section-title i {
    transition: transform var(--transition-fast);
}

.project-links.is-collapsed {
    display: none;
}

.project-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
    font-family: var(--font-family);
}

.btn-primary {
    background-color: var(--text-primary);
    color: #000;
}

.btn-primary:hover {
    background-color: #d4d4d8;
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-strong);
    color: var(--text-primary);
}

.btn-outline:hover {
    background-color: var(--bg-hover);
}

.btn-icon-only {
    background-color: transparent;
    color: var(--text-secondary);
    padding: 8px;
    border-radius: 50%;
}

.btn-icon-only:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.btn-block {
    width: 100%;
}

/* User Profile Mini */
.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: white;
}

.avatar-circle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: var(--accent-purple);
    color: white;
}

.avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.bg-purple {
    background-color: var(--accent-purple);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.user-email {
    font-size: 12px;
    color: var(--text-secondary);
}

.person-role {
    font-size: 13px;
    color: var(--text-muted);
}


/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px;
    border-bottom: 1px solid var(--border-subtle);
}

.page-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 4px;
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
}

#btn-filter.has-active-filter {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.filter-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 56px;
    width: 320px;
    background: var(--bg-panel);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    z-index: 2000;
    display: none;
}

.filter-panel.open {
    display: block;
}

.filter-panel-header,
.filter-panel-footer {
    padding: 12px;
}

.filter-panel-header {
    border-bottom: 1px solid var(--border-subtle);
}

.filter-panel-body {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.filter-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.filter-check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.filter-panel-footer {
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Inputs */
.search-box {
    position: relative;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box input, .form-input, .form-select, .form-textarea {
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: 6px;
    font-family: var(--font-family);
    font-size: 14px;
    transition: border-color var(--transition-fast);
}

.search-box input {
    padding-left: 36px;
    width: 240px;
}

.search-box input:focus, .form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--border-strong);
}

/* View Container */
.view-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

/* Kanban / Dashboard specific layout helpers */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
}

.metric-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 20px;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-strong);
}

/* Helper Classes */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

/* Metric Cards */
.metric-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.metric-icon { width: 40px; height: 40px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.metric-value { font-size: 32px; font-weight: 700; margin-bottom: 4px; }
.metric-label { font-size: 14px; color: var(--text-secondary); }
.border-danger { border-color: var(--status-overdue-bg); }
.trend { font-size: 14px; display: flex; align-items: center; gap: 4px; }
.trend.positive { color: var(--status-resolved-color); }
.trend.negative { color: var(--status-overdue-color); }
.trend i { font-size: 14px; }

/* Section Header */
.section-header { margin-bottom: 24px; }
.section-header h2 { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.text-secondary { color: var(--text-secondary); }
.mb-xl { margin-bottom: 32px; }
.ml-auto { margin-left: auto; }

/* Kanban Board */
.kanban-board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; padding-bottom: 16px; min-height: 500px; width: 100%; }
.kanban-column { min-width: 0; background: rgba(255,255,255,0.02); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.kanban-header { display: flex; justify-content: space-between; align-items: center; }
.kanban-title { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.kanban-title .count { color: var(--text-muted); background: var(--bg-hover); padding: 2px 8px; border-radius: 12px; font-size: 12px; }
.kanban-cards { display: flex; flex-direction: column; gap: 12px; min-height: 100px; }
.kanban-cards.drag-over { outline: 1px dashed var(--border-strong); outline-offset: 4px; border-radius: 10px; background: rgba(255,255,255,0.03); }

/* Issue Cards */
.issue-card { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 8px; padding: 16px; cursor: pointer; transition: transform 0.2s, border-color 0.2s; }
.issue-card:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.issue-card[draggable="true"] { cursor: grab; }
.issue-card.dragging { opacity: 0.45; transform: scale(0.98); cursor: grabbing; }
.issue-card-header { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 12px; color: var(--text-muted); }
.issue-title { font-size: 14px; font-weight: 500; margin-bottom: 12px; line-height: 1.4; cursor: pointer; }
.issue-title:hover { color: var(--accent-blue); text-decoration: underline; }
.issue-meta { display: flex; gap: 8px; margin-bottom: 16px; align-items: center; font-size: 12px; }
.issue-project { color: var(--text-secondary); }
.issue-footer { display: flex; justify-content: space-between; align-items: center; color: var(--text-muted); font-size: 12px; }
.issue-date, .issue-comments { display: flex; align-items: center; gap: 4px; }
.issue-date i, .issue-comments i { font-size: 12px; }
.status-open { color: var(--status-open-color); background: var(--status-open-bg); }
.status-in-progress { color: var(--status-in-progress-color); background: var(--status-in-progress-bg); }
.status-resolved { color: var(--status-resolved-color); background: var(--status-resolved-bg); }
.status-overdue { color: var(--status-overdue-color); background: var(--status-overdue-bg); }
.priority-high { color: var(--priority-high-color); background: var(--priority-high-bg); border-radius: 4px; padding: 2px 6px; }
.priority-medium { color: var(--priority-medium-color); background: var(--priority-medium-bg); border-radius: 4px; padding: 2px 6px; }
.priority-low { color: var(--priority-low-color); background: var(--priority-low-bg); border-radius: 4px; padding: 2px 6px; }

/* Data Table */
.table-container { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 12px; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table th { padding: 16px; font-size: 12px; font-weight: 600; color: var(--text-muted); border-bottom: 1px solid var(--border-strong); white-space: nowrap; }
.data-table td { padding: 16px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
.data-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.issue-cell { display: flex; flex-direction: column; gap: 4px; }
.issue-id { font-size: 12px; color: var(--text-muted); }
.issue-title-link { color: var(--text-primary); text-decoration: none; font-weight: 500; font-size: 14px; }
.issue-title-link:hover { color: var(--accent-blue); text-decoration: underline; }
.table-project { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); font-size: 14px; }
.table-assignee { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.table-assignee .avatar { width: 28px; height: 28px; font-size: 11px; }

/* Grids */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 24px; }

/* Cards */
.project-card, .person-card { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 16px; transition: transform 0.2s, border-color 0.2s; }
.project-card:hover, .person-card:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.project-card-header, .person-card-header { display: flex; align-items: flex-start; gap: 16px; }
.project-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 24px; color: white; }
.project-info h3, .person-info h3 { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.project-id, .person-username { font-size: 13px; color: var(--text-muted); }
.project-desc { font-size: 14px; color: var(--text-secondary); line-height: 1.5; }
.project-stats, .person-stats { border-top: 1px solid var(--border-subtle); padding-top: 16px; display: flex; justify-content: space-between; }
.stat { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--text-secondary); }
.stat strong { font-size: 18px; font-weight: 600; }
.person-email { font-size: 14px; color: var(--text-secondary); display: flex; align-items: center; gap: 8px; }

/* Settings */
.settings-container { display: flex; flex-direction: column; gap: 24px; max-width: 800px; }
.settings-section { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 12px; padding: 24px; }
.settings-header { font-size: 18px; font-weight: 600; margin-bottom: 24px; display: flex; align-items: center; gap: 8px; padding-bottom: 16px; border-bottom: 1px solid var(--border-subtle); }
.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-group label { font-size: 14px; color: var(--text-secondary); }
.form-input { width: 100%; border: 1px solid var(--border-subtle); padding: 12px 16px; border-radius: 8px; background: var(--bg-app); color: var(--text-primary); }

.settings-toggle-row {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 12px 14px;
    background: var(--bg-app);
}

.settings-toggle-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

/* Modals */
.modal-backdrop { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000; opacity: 0; pointer-events: none; transition: opacity 0.2s ease; }
.modal-backdrop.open { opacity: 1; pointer-events: all; }
.modal-content { background: var(--bg-panel); border: 1px solid var(--border-subtle); border-radius: 12px; width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; transform: translateY(20px); transition: transform 0.2s ease; box-shadow: 0 20px 40px rgba(0,0,0,0.4); }
.modal-backdrop.open .modal-content { transform: translateY(0); }
.modal-header { padding: 24px; border-bottom: 1px solid var(--border-subtle); display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { font-size: 18px; font-weight: 600; margin: 0; }
.modal-body { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-footer { padding: 24px; border-top: 1px solid var(--border-subtle); display: flex; justify-content: flex-end; gap: 12px; }
.close-btn { background: transparent; border: none; color: var(--text-muted); cursor: pointer; font-size: 20px; transition: color 0.15s; }
.close-btn:hover { color: var(--text-primary); }

.btn-sm {
    padding: 6px 10px;
    font-size: 12px;
}

.empty-state {
    background: var(--bg-card);
    border: 1px dashed var(--border-strong);
    border-radius: 12px;
    padding: 24px;
    color: var(--text-secondary);
}

.modal-content-lg {
    max-width: 920px;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.form-grid-2 .full {
    grid-column: 1 / -1;
}

.form-textarea {
    width: 100%;
    resize: vertical;
    min-height: 80px;
}

.project-color-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.project-color-picker {
    width: 48px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
}

.project-color-hex {
    flex: 1;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.detail-item {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 12px;
}

.detail-item.full {
    grid-column: 1 / -1;
}

.detail-item label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.detail-item p {
    color: var(--text-secondary);
    line-height: 1.5;
}

@media (max-width: 1100px) {
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .kanban-board {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .form-grid-2,
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 820px) {
    .app-layout {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    body {
        overflow: auto;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-subtle);
    }

    .main-content {
        min-height: 0;
    }

    .top-bar {
        padding: 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .view-container {
        padding: 16px;
    }

    .search-box input {
        width: 100%;
        min-width: 220px;
    }

    .notification-panel {
        right: auto;
        left: 0;
        width: min(92vw, 340px);
    }

    .filter-panel {
        right: auto;
        left: 0;
        width: min(92vw, 320px);
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .kanban-board {
        grid-template-columns: 1fr;
    }
}
