:root {
    --sidebar-width: 240px;
    --topbar-height: 56px;
    --primary: #4361ee;
    --primary-light: #e8ecfd;
    --bg: #f5f7fb;
    --card-bg: #fff;
    --text: #1e293b;
    --text-muted: #94a3b8;
    --border: #e2e8f0;
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; margin: 0; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); }

.app-container { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    flex-direction: column;
    flex-shrink: 0;
    padding: 1rem 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: 0 1.25rem 1.5rem;
    font-size: 1.15rem;
    font-weight: 700;
}

.sidebar-brand i { font-size: 1.5rem; }

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem 1.25rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: .925rem;
    transition: all .15s;
    border-left: 3px solid transparent;
}

.sidebar-nav li a:hover { background: var(--bg); color: var(--text); }
.sidebar-nav li.active a { color: var(--primary); background: var(--primary-light); border-left-color: var(--primary); font-weight: 600; }

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

.top-bar {
    height: var(--topbar-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    flex-shrink: 0;
}

.page-title { font-weight: 700; }
.top-bar-actions { margin-left: auto; }

.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1rem 1rem 0;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    align-items: start;
    gap: 1rem;
    max-width: none;
    margin: 3.75rem 0 0;
}

@media (min-width: 992px) {
    .dashboard-grid {
        grid-template-columns: 380px 1fr;
        padding-left: .6rem;
    }
}

@media (min-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 420px 1fr;
        padding-left: .75rem;
    }
}

/* Card */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: .75rem 1rem;
}

.card-header h6 {
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* Calendar */
.calendar-card .card-body {
    padding-bottom: 1.25rem !important;
}

.calendar-card .calendar-nav {
    margin-top: 1.35rem;
    margin-left: -.35rem;
    margin-right: .35rem;
}

.calendar-table {
    width: calc(100% - .5rem);
    border-collapse: collapse;
    table-layout: fixed;
    margin-top: 1.1rem;
    margin-left: -.25rem;
}

.calendar-table th {
    text-align: center;
    font-size: .8rem;
    color: var(--text-muted);
    padding: .5rem .25rem;
    font-weight: 600;
}

.calendar-table td {
    text-align: center;
    padding: .45rem .25rem;
    font-size: .9rem;
    cursor: pointer;
    border-radius: 8px;
    position: relative;
    transition: all .15s;
    vertical-align: middle;
}

.calendar-table td:hover:not(.other-month) {
    background: var(--primary-light);
}

.calendar-table td.other-month {
    color: #cbd5e1;
    cursor: default;
}

.calendar-table td.today {
    background: #fef3c7;
    font-weight: 700;
}

.calendar-table td.today span {
    color: var(--text);
}

.calendar-table td.selected {
    background: var(--primary) !important;
    color: #fff !important;
    font-weight: 700;
}

.calendar-table td.selected span { color: #fff; }

.calendar-table td.has-event .event-dot {
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 5px;
    height: 5px;
    background: var(--danger);
    border-radius: 50%;
}

.calendar-title { font-size: 1.05rem; font-weight: 600; }

/* Filters */
.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}

.chip {
    padding: .25rem .75rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--card-bg);
    font-size: .8rem;
    cursor: pointer;
    transition: all .15s;
    color: var(--text-muted);
}

.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.chip-blue { border-color: #3b82f6; color: #3b82f6; }
.chip-blue.active { background: #3b82f6; color: #fff; }
.chip-yellow { border-color: var(--warning); color: var(--warning); }
.chip-yellow.active { background: var(--warning); color: #fff; }
.chip-green { border-color: var(--success); color: var(--success); }
.chip-green.active { background: var(--success); color: #fff; }
.chip-purple { border-color: #8b5cf6; color: #8b5cf6; }
.chip-purple.active { background: #8b5cf6; color: #fff; }

/* Reminder Items */
.reminder-item {
    display: flex;
    gap: .75rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    transition: background .15s;
}

.reminder-item:hover { background: #f8fafc; }
.reminder-item:last-child { border-bottom: none; }

.reminder-time {
    flex-shrink: 0;
    font-size: .9rem;
    font-weight: 700;
    color: var(--text-muted);
    padding-top: .15rem;
    width: 50px;
}

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

.reminder-content h6 { font-size: .95rem; font-weight: 600; }

/* YouTube */
.youtube-link {
    margin-top: .75rem !important;
}

.youtube-link a {
    align-items: flex-start !important;
    gap: .75rem !important;
}

.yt-thumb {
    width: clamp(132px, 18vw, 180px);
    aspect-ratio: 16 / 9;
    height: auto;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    border: 1px solid var(--border);
}

.youtube-link a {
    color: var(--text);
}

.youtube-link a:hover { opacity: .85; }

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: .15rem;
    align-items: center;
}

.action-buttons .btn { padding: .2rem .35rem; font-size: .85rem; }

/* Offcanvas (mobile sidebar) */
.offcanvas .sidebar-nav li a {
    padding: .85rem 1.5rem;
    font-size: 1rem;
}

/* Responsive */
@media (max-width: 575.98px) {
    .content-area { padding: .5rem; }
    .dashboard-grid { margin-top: 1rem; }
    .card-header { padding: .5rem .75rem; }
    .card-body { padding: .5rem !important; }
    .reminder-item { padding: .75rem .5rem; }
    .reminder-time { width: 40px; font-size: .8rem; }
    .action-buttons .btn { padding: .15rem .25rem; font-size: .75rem; }
    .youtube-link a {
        align-items: flex-start !important;
        flex-direction: column;
    }
    .yt-thumb { width: min(100%, 220px); }
    .calendar-table th { font-size: .7rem; }
    .calendar-table td { font-size: .8rem; padding: .3rem .15rem; }
    .calendar-title { font-size: .9rem; }
    .filter-chips { gap: .25rem; }
    .chip { font-size: .7rem; padding: .2rem .5rem; }
}

@media (min-width: 576px) and (max-width: 991.98px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .calendar-card {
        max-width: 100%;
    }
}

/* scrollbar */
.content-area::-webkit-scrollbar { width: 6px; }
.content-area::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* Toast notification */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
}

/* Task management */
.task-hero-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: clamp(1.25rem, 3vw, 2rem);
    margin-bottom: 1rem;
    color: #fff;
    background: linear-gradient(135deg, #0f172a, #2563eb);
    border-radius: 18px;
    box-shadow: 0 16px 42px rgba(37, 99, 235, .2);
}

.category-hero-panel {
    background: linear-gradient(135deg, #111827, #0f766e);
    box-shadow: 0 16px 42px rgba(15, 118, 110, .18);
}

.task-eyebrow {
    margin: 0 0 .35rem;
    opacity: .78;
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.task-hero-panel h1,
.task-form-intro h1,
.task-detail-card h1,
.task-delete-card h1 {
    margin: 0;
    font-weight: 800;
}

.task-hero-copy {
    max-width: 42rem;
    margin: .75rem 0 0;
    opacity: .88;
}

.task-hero-action {
    white-space: nowrap;
    border-radius: 999px;
    font-weight: 700;
}

.task-alert { border-radius: 12px; }

.task-metric-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.task-metric-card {
    padding: 1.25rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

.task-metric-card span {
    display: block;
    color: var(--text-muted);
    font-weight: 700;
}

.task-metric-card strong {
    display: block;
    margin-top: .35rem;
    font-size: 2rem;
    line-height: 1;
}

.task-metric-card.danger strong { color: var(--danger); }

.task-toolbar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 150px 150px 150px auto auto;
    gap: .75rem;
    padding: .85rem;
    margin-bottom: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.task-bulk-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .75rem;
    padding: .85rem 1rem;
    margin-bottom: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.task-select-all,
.mobile-task-select {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    margin: 0;
    color: var(--text-muted);
    font-weight: 800;
}

.task-check-cell {
    width: 5.75rem;
    text-align: center;
    white-space: nowrap;
}

.task-table-card,
.task-form-card,
.task-detail-card,
.task-delete-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
    overflow: hidden;
}

.task-table-card thead th {
    color: var(--text-muted);
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.task-table-card td,
.task-table-card th {
    padding: 1rem;
}

.task-drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    margin-right: .35rem;
    color: var(--text-muted);
    background: transparent;
    border: 0;
    border-radius: 8px;
    cursor: grab;
    vertical-align: middle;
}

.task-drag-handle:hover,
.task-draggable-row:hover .task-drag-handle {
    color: var(--primary);
    background: var(--primary-light);
}

.task-drag-handle:active {
    cursor: grabbing;
}

.task-draggable-row {
    transition: background .15s, box-shadow .15s, opacity .15s;
}

.task-draggable-row.task-dragging {
    opacity: .58;
    background: #eef2ff;
    box-shadow: inset 4px 0 0 var(--primary);
}

.task-title { font-weight: 800; }

.task-desc {
    max-width: 30rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.date-cell { font-weight: 700; }

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 4.8rem;
    padding: .38rem .7rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 800;
}

.category-badge,
.priority-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 3.6rem;
    padding: .34rem .65rem;
    border-radius: 999px;
    font-size: .76rem;
    font-weight: 800;
    white-space: nowrap;
}

.category-badge {
    color: #0f766e;
    background: #ccfbf1;
}

.priority-low {
    color: #64748b;
    background: #f1f5f9;
}

.priority-normal {
    color: #2563eb;
    background: #dbeafe;
}

.priority-high {
    color: #b45309;
    background: #fef3c7;
}

.priority-urgent {
    color: #be123c;
    background: #ffe4e6;
}

.status-pending {
    color: #b45309;
    background: #fef3c7;
}

.status-progress {
    color: #2563eb;
    background: #dbeafe;
}

.status-complete {
    color: #15803d;
    background: #dcfce7;
}

.mobile-task-list {
    display: grid;
    gap: .85rem;
}

.mobile-task-card {
    padding: 1rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
}

.mobile-task-select {
    margin-bottom: .75rem;
}

.mobile-task-select .task-drag-handle {
    margin-right: 0;
}

.mobile-task-head,
.mobile-task-meta,
.mobile-task-actions,
.task-form-actions,
.task-detail-header,
.task-delete-summary {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.mobile-task-head {
    justify-content: space-between;
}

.mobile-task-tags {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
    margin-top: .65rem;
}

.mobile-task-head h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 800;
}

.mobile-task-card p {
    color: var(--text-muted);
    margin: .75rem 0;
}

.mobile-task-meta {
    justify-content: space-between;
    color: var(--text-muted);
    font-size: .9rem;
    font-weight: 700;
    margin-bottom: .85rem;
}

.mobile-task-actions { flex-wrap: wrap; }

.empty-state {
    padding: 2rem;
    text-align: center;
    background: var(--card-bg);
    border: 1px dashed var(--border);
    border-radius: 14px;
}

.empty-state h2 { font-weight: 800; }

.task-form-shell {
    display: grid;
    grid-template-columns: .85fr 1.15fr;
    gap: 1.25rem;
    align-items: start;
}

.category-form-shell {
    display: grid;
    grid-template-columns: .75fr 1.25fr;
    gap: 1.25rem;
    align-items: start;
}

.task-form-intro {
    position: sticky;
    top: calc(var(--topbar-height) + 1.5rem);
    padding: 2rem;
    color: #fff;
    background: linear-gradient(135deg, #0f172a, #0f766e);
    border-radius: 18px;
}

.task-form-intro p:last-child {
    margin-bottom: 0;
    opacity: .84;
}

.task-form-card {
    padding: clamp(1rem, 3vw, 2rem);
}

.task-form-grid,
.task-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.task-form-actions {
    justify-content: flex-end;
    flex-wrap: wrap;
}

.task-detail-card,
.task-delete-card {
    padding: clamp(1.25rem, 4vw, 2.25rem);
}

.task-detail-header {
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.25rem;
}

.task-detail-description {
    color: var(--text-muted);
    font-size: 1.08rem;
}

.task-detail-grid {
    margin: 1.5rem 0;
}

.task-detail-grid div,
.task-remarks-box,
.task-delete-summary {
    padding: 1rem;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 12px;
}

.task-detail-grid dt {
    color: var(--text-muted);
    font-size: .8rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.task-detail-grid dd {
    margin: .35rem 0 0;
    font-weight: 800;
}

.task-remarks-box {
    margin-bottom: 1rem;
}

.task-remarks-box p {
    margin: .5rem 0 0;
    color: var(--text-muted);
}

.task-delete-card {
    max-width: 680px;
    margin: 0 auto;
}

.task-delete-summary {
    justify-content: space-between;
    margin: 1rem 0 1.25rem;
}

@media (max-width: 991.98px) {
    .task-form-shell { grid-template-columns: 1fr; }
    .category-form-shell { grid-template-columns: 1fr; }
    .task-form-intro { position: static; }
}

@media (max-width: 767.98px) {
    .task-hero-panel {
        align-items: flex-start;
        flex-direction: column;
        border-radius: 14px;
    }
    .task-hero-action { width: 100%; }
    .task-metric-grid { grid-template-columns: 1fr; }
    .task-toolbar { grid-template-columns: 1fr; }
    .task-toolbar .btn { width: 100%; }
    .task-bulk-bar {
        align-items: stretch;
        flex-direction: column;
    }
    .task-bulk-bar .btn { width: 100%; }
    .task-detail-header {
        flex-direction: column;
        gap: 1rem;
    }
    .task-detail-grid { grid-template-columns: 1fr; }
    .task-form-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }
    .task-delete-summary {
        align-items: flex-start;
        flex-direction: column;
    }
}
