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

body {
    background: #111;
    color: #eee;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    padding: 12px 20px;
    background: #1a1a1a;
    border-bottom: 1px solid #333;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

header h1 {
    font-size: 1.2rem;
    font-weight: 500;
}

.sprint-badge {
    background: #6366f1;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Tabs */
.tabs {
    display: flex;
    background: #1a1a1a;
    border-bottom: 1px solid #333;
    padding: 0 20px;
}

.tab {
    background: none;
    border: none;
    color: #888;
    padding: 10px 16px;
    font-size: 0.85rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}

.tab:hover {
    color: #ccc;
}

.tab.active {
    color: #eee;
    border-bottom-color: #6366f1;
}

/* Views */
.view {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* Board */
.board {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    padding: 16px;
    flex: 1;
    overflow: hidden;
}

.column {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: border-color 0.2s, background 0.2s;
}

.column.drag-over {
    background: rgba(99, 102, 241, 0.08);
    border-color: #6366f1;
}

.column-header {
    padding: 10px 14px;
    background: #222;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
    font-size: 0.85rem;
}

.column-count {
    background: #333;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    color: #aaa;
}

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

.column-footer {
    padding: 8px;
    border-top: 1px solid #282828;
}

/* Task Cards */
.task-card {
    background: #252525;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 10px 12px;
    cursor: grab;
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
    user-select: none;
}

.task-card:hover {
    border-color: #555;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

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

.task-card.dragging {
    opacity: 0.4;
    transform: rotate(1deg);
}

.task-card .task-title {
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 6px;
    word-break: break-word;
}

.task-card .task-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.task-card .task-desc {
    font-size: 0.75rem;
    color: #888;
    margin-bottom: 6px;
    word-break: break-word;
}

/* Priority indicators */
.priority-high {
    border-left: 3px solid #ef4444;
}

.priority-medium {
    border-left: 3px solid #f59e0b;
}

.priority-low {
    border-left: 3px solid #22c55e;
}

/* Category badge */
.category-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 8px;
    font-size: 0.65rem;
    font-weight: 500;
    color: #fff;
}

/* Priority badge */
.priority-label {
    font-size: 0.65rem;
    color: #777;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Task actions */
.task-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.task-actions button {
    background: none;
    border: none;
    color: #555;
    cursor: pointer;
    padding: 2px 4px;
    font-size: 0.75rem;
    border-radius: 3px;
}

.task-actions button:hover {
    color: #eee;
    background: #333;
}

/* Backlog */
.backlog-header, .sprints-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
}

.backlog-header h2, .sprints-header h2 {
    font-size: 1rem;
    font-weight: 500;
}

.backlog-filters {
    display: flex;
    gap: 8px;
}

.filter-select {
    min-width: 120px;
}

.backlog-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 20px;
}

.backlog-item {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.backlog-item .task-info {
    flex: 1;
    min-width: 0;
}

.backlog-item .task-title {
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 4px;
}

.backlog-item .task-meta {
    display: flex;
    gap: 8px;
    align-items: center;
}

.backlog-item .backlog-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* Sprints */
.sprints-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 20px 20px;
}

.sprint-card {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 10px;
}

.sprint-card.active {
    border-color: #6366f1;
}

.sprint-card .sprint-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.sprint-card .sprint-name {
    font-size: 0.95rem;
    font-weight: 500;
}

.sprint-status {
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sprint-status.planning {
    background: #333;
    color: #aaa;
}

.sprint-status.active {
    background: rgba(99, 102, 241, 0.2);
    color: #818cf8;
}

.sprint-status.completed {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.sprint-card .sprint-goal {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 10px;
}

.sprint-card .sprint-stats {
    display: flex;
    gap: 16px;
    font-size: 0.75rem;
    color: #777;
    margin-bottom: 10px;
}

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

.sprint-card .sprint-dates {
    font-size: 0.7rem;
    color: #555;
}

/* Sprint inline task list */
.sprint-tasks {
    border-top: 1px solid #282828;
    margin-top: 12px;
    padding-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sprint-tasks-empty {
    font-size: 0.8rem;
    color: #555;
    text-align: center;
    padding: 8px 0;
}

.sprint-task-item {
    background: #222;
    border: 1px solid #333;
    border-radius: 5px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sprint-task-item .task-info {
    flex: 1;
    min-width: 0;
}

.sprint-task-item .task-title {
    font-size: 0.82rem;
    font-weight: 500;
    margin-bottom: 3px;
}

.sprint-task-item .task-meta {
    display: flex;
    gap: 6px;
    align-items: center;
}

.sprint-task-item .backlog-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.task-status-label {
    font-size: 0.6rem;
    padding: 1px 6px;
    border-radius: 6px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.task-status-label.status-not_started {
    background: #333;
    color: #aaa;
}

.task-status-label.status-ongoing {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.task-status-label.status-done {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 6px;
    color: #666;
}

.empty-state .muted {
    font-size: 0.8rem;
    color: #555;
}

/* Buttons */
.btn {
    background: #333;
    border: 1px solid #444;
    color: #eee;
    padding: 6px 14px;
    font-size: 0.8rem;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.15s;
}

.btn:hover {
    background: #444;
}

.btn-primary {
    background: #6366f1;
    border-color: #6366f1;
}

.btn-primary:hover {
    background: #5558e6;
}

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

.btn-danger:hover {
    background: #b91c1c;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.75rem;
}

.btn-add {
    width: 100%;
    background: transparent;
    border: 1px dashed #444;
    color: #666;
    padding: 6px;
    font-size: 0.8rem;
    border-radius: 5px;
    cursor: pointer;
}

.btn-add:hover {
    border-color: #6366f1;
    color: #6366f1;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    width: 90%;
    max-width: 480px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid #333;
}

.modal-header h3 {
    font-size: 0.95rem;
    font-weight: 500;
}

.btn-close {
    background: none;
    border: none;
    color: #888;
    font-size: 1.3rem;
    cursor: pointer;
    line-height: 1;
}

.btn-close:hover {
    color: #eee;
}

.modal-body {
    padding: 18px;
}

/* Form elements */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    color: #aaa;
    margin-bottom: 5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 10px;
    background: #252525;
    border: 1px solid #444;
    border-radius: 5px;
    color: #eee;
    font-size: 0.85rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #6366f1;
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
}

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

/* Category list in modal */
.category-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.category-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: #252525;
    border-radius: 5px;
}

.category-color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.category-item span {
    flex: 1;
    font-size: 0.85rem;
}

.category-item button {
    background: none;
    border: none;
    color: #555;
    cursor: pointer;
    font-size: 0.8rem;
}

.category-item button:hover {
    color: #ef4444;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Responsive */
@media (max-width: 768px) {
    .board {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }

    .column {
        min-height: 200px;
    }

    .backlog-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .backlog-item .backlog-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

/* Deadline */
.task-deadline {
    font-size: 0.7rem;
    color: #888;
    margin-bottom: 6px;
}

.task-deadline::before {
    content: '\1F4C5 ';
}

.task-deadline.overdue {
    color: #ef4444;
}

.task-deadline.overdue::before {
    content: '\26A0\FE0F ';
}

/* Calendar Strip */

#calendar-section {
    border-bottom: 1px solid #333;
}

.calendar-connect {
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #1a1a1a;
    font-size: 0.8rem;
    color: #666;
}

.calendar-strip {
    background: #1a1a1a;
    padding: 8px 16px 12px;
}

.calendar-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 0.8rem;
}

#calendar-week-label {
    font-weight: 500;
    font-size: 0.85rem;
    min-width: 160px;
    text-align: center;
}

.calendar-cache-age {
    margin-left: auto;
    color: #555;
    font-size: 0.7rem;
}

.calendar-disconnect-btn {
    color: #666;
    font-size: 1rem;
    line-height: 1;
}

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

.calendar-day {
    background: #222;
    border: 1px solid #333;
    border-radius: 4px;
    min-height: 80px;
    max-height: 160px;
    overflow-y: auto;
    padding: 6px;
}

.calendar-day.today {
    border-color: #6366f1;
}

.calendar-day-header {
    font-size: 0.65rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
}

.calendar-day-header .day-number {
    font-weight: 600;
    color: #ccc;
}

.calendar-day.today .day-number {
    color: #6366f1;
}

.calendar-event {
    background: rgba(99, 102, 241, 0.15);
    border-left: 2px solid #6366f1;
    border-radius: 2px;
    padding: 2px 5px;
    margin-bottom: 3px;
    font-size: 0.65rem;
    color: #ccc;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: default;
}

.calendar-event:hover {
    background: rgba(99, 102, 241, 0.25);
}

.calendar-event.all-day {
    background: rgba(99, 102, 241, 0.25);
    border-left-color: #818cf8;
    font-weight: 500;
}

.calendar-event .event-time {
    color: #888;
    margin-right: 4px;
}

.calendar-no-events {
    font-size: 0.6rem;
    color: #444;
    text-align: center;
    padding-top: 8px;
}

@media (max-width: 768px) {
    .calendar-days {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Activity Log */

.activity-log {
    max-height: 160px;
    overflow-y: auto;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 8px;
    background: #111;
    font-size: 0.8rem;
}

.activity-entry {
    display: flex;
    gap: 10px;
    padding: 4px 0;
    border-bottom: 1px solid #222;
}

.activity-entry:last-child {
    border-bottom: none;
}

.activity-time {
    color: #666;
    white-space: nowrap;
    flex-shrink: 0;
}

.activity-label {
    color: #bbb;
}

/* Habits */

.habits-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
}

.habits-header h2 {
    font-size: 1rem;
    font-weight: 500;
}

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

.habits-today {
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.habit-today-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.habit-today-row:active {
    background: #222;
}

.habit-today-row.habit-done {
    opacity: 0.5;
}

.habit-today-row.habit-done .habit-name {
    text-decoration: line-through;
    color: #666;
}

.habit-checkbox {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid #444;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.habit-checkbox .habit-check-icon {
    width: 22px;
    height: 22px;
    color: transparent;
    transition: color 0.15s;
}

.habit-checkbox.checked {
    background: #6366f1;
    border-color: #6366f1;
    transform: scale(1.05);
}

.habit-checkbox.checked .habit-check-icon {
    color: #fff;
}

.habit-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.habit-name {
    font-size: 0.9rem;
    font-weight: 500;
    flex: 1;
}

.habit-week-progress {
    font-size: 0.7rem;
    color: #888;
    background: #252525;
    padding: 2px 8px;
    border-radius: 10px;
}

.habit-edit-btn {
    background: none;
    border: none;
    color: #444;
    cursor: pointer;
    padding: 4px;
    font-size: 0.8rem;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}

.habit-today-row:hover .habit-edit-btn {
    opacity: 1;
}

/* Habit history dot grid */

.habits-history {
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.habit-history-card {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 14px 16px;
}

.habit-history-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.habit-freq-label {
    margin-left: auto;
    font-size: 0.65rem;
    color: #666;
}

.habit-dot-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.habit-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.habit-dot.done {
    opacity: 1;
}

.habit-dot.missed {
    background: #252525;
}

.habit-dot.not-due {
    background: transparent;
}

/* Paused habits */

.habits-paused-section {
    margin: 16px 20px 20px;
    border-top: 1px solid #282828;
    padding-top: 12px;
}

.habits-paused-header {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    color: #666;
}

.habits-paused-count {
    background: #252525;
    padding: 1px 7px;
    border-radius: 8px;
    font-size: 0.65rem;
}

.habits-paused-list {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.habit-paused-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: #1a1a1a;
    border: 1px solid #282828;
    border-radius: 6px;
    opacity: 0.6;
}

.habit-paused-row .habit-name {
    flex: 1;
    font-size: 0.82rem;
    color: #888;
}

.habit-reactivate-btn {
    font-size: 0.7rem;
    color: #6366f1;
    background: none;
    border: 1px solid #6366f1;
    border-radius: 4px;
    padding: 3px 10px;
    cursor: pointer;
}

.habit-reactivate-btn:hover {
    background: rgba(99, 102, 241, 0.15);
}

/* Frequency day picker */

.freq-day-toggles {
    display: flex;
    gap: 6px;
}

.freq-day-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid #444;
    background: transparent;
    color: #888;
    font-size: 0.7rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.freq-day-btn.selected {
    background: #6366f1;
    border-color: #6366f1;
    color: #fff;
}

@media (max-width: 768px) {
    .habit-dot {
        width: 8px;
        height: 8px;
    }
    .habit-dot-grid {
        gap: 2px;
    }
}
