/* ====================================
   HabitFlow Design System v2
   Dark Theme + Weekly Grid + Mobile
   ==================================== */

:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-surface: #1a1f36;
    --bg-surface-hover: #232942;
    --bg-surface-active: #2d3452;
    --bg-glass: rgba(26, 31, 54, 0.7);
    --bg-modal: rgba(10, 14, 26, 0.85);
    --border-color: rgba(255, 255, 255, 0.06);
    --border-accent: rgba(102, 126, 234, 0.3);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-accent: #818cf8;
    --accent-primary: #667eea;
    --accent-primary-hover: #7c8ef0;
    --accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --color-success: #34d399;
    --color-success-bg: rgba(52, 211, 153, 0.1);
    --color-warning: #fbbf24;
    --color-danger: #f87171;
    --color-danger-bg: rgba(248, 113, 113, 0.1);
    --color-info: #60a5fa;
    --color-income: #34d399;
    --color-expense: #f87171;
    --color-check: #43e97b;
    --color-check-bg: rgba(67, 233, 123, 0.15);
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(102, 126, 234, 0.15);
    --sidebar-width: 260px;
    --mobile-nav-h: 64px;
    --mobile-header-h: 56px;
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-smooth: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    z-index: 100;
    transition: all var(--transition-smooth);
}

.sidebar.collapsed {
    width: 64px;
    min-width: 64px;
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .section-header h3,
.sidebar.collapsed .category-list,
.sidebar.collapsed .tag-list,
.sidebar.collapsed .sidebar-section .btn-icon {
    display: none;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.logo-icon {
    font-size: 1.4rem;
    filter: drop-shadow(0 0 8px rgba(102, 126, 234, 0.5));
}

.logo-text {
    font-size: 1.15rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    white-space: nowrap;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-surface);
}

.sidebar.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

.sidebar-nav {
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 10px var(--space-md);
    border-radius: var(--radius-md);
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
    width: 100%;
    position: relative;
    font-family: inherit;
}

.nav-item:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(102, 126, 234, 0.12);
    color: var(--text-accent);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
}

.nav-icon {
    font-size: 1.1rem;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

.nav-badge {
    margin-left: auto;
    background: var(--accent-gradient);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: var(--radius-full);
}

.sidebar-section {
    padding: var(--space-md) var(--space-md) 0;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-sm);
}

.section-header h3 {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    color: var(--text-primary);
    background: var(--bg-surface);
}

.category-list,
.tag-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.category-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 6px var(--space-md);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.category-item:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.category-item.active {
    background: var(--bg-surface-active);
    color: var(--text-primary);
}

.category-color {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.category-count {
    margin-left: auto;
    font-size: 0.73rem;
    color: var(--text-muted);
}

.tag-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 0.73rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    margin: 2px;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

/* ===== SIDEBAR OVERLAY (mobile) ===== */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ===== MOBILE HEADER ===== */
.mobile-header {
    display: none;
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    height: var(--mobile-header-h);
    padding: 0 var(--space-md);
    align-items: center;
    justify-content: space-between;
}

.mobile-menu-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: var(--space-xs);
    display: flex;
    align-items: center;
}

.mobile-title {
    font-weight: 600;
    font-size: 1.05rem;
}

/* ===== MOBILE BOTTOM NAV ===== */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--mobile-nav-h);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    justify-content: space-around;
    align-items: center;
    z-index: 200;
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-family: inherit;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.mobile-nav-item.active {
    color: var(--text-accent);
}

.mobile-nav-item .mnav-icon {
    font-size: 1.25rem;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    min-width: 0;
    padding: var(--space-xl);
    overflow-y: auto;
    height: 100vh;
}

.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

.page.active.notes-page-wrapper {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: var(--space-xl);
    flex-wrap: wrap;
    gap: var(--space-md);
}

.page-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.88rem;
    margin-top: 4px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-wrap: wrap;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.45);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-ghost:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition-normal);
}

.card:hover {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-glow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
    font-size: 0.95rem;
    font-weight: 600;
}

.card-body {
    padding: var(--space-lg);
}

/* ===== FORMS ===== */
.form-group {
    margin-bottom: var(--space-md);
}

.form-group label {
    display: block;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: inherit;
    transition: all var(--transition-fast);
    outline: none;
}

.form-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-color {
    height: 42px;
    padding: 4px;
    cursor: pointer;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

.form-input-inline {
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: inherit;
    outline: none;
    padding: 4px 0;
    min-width: 100px;
}

.select-input {
    padding: 8px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-family: inherit;
    cursor: pointer;
    outline: none;
}

.filter-group {
    display: flex;
    gap: var(--space-sm);
}

.tags-input-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    min-height: 42px;
    align-items: center;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.73rem;
    background: rgba(102, 126, 234, 0.15);
    color: var(--text-accent);
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.tag-chip button {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0;
}

.day-picker {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.day-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    cursor: pointer;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.day-chip:has(input:checked) {
    background: rgba(102, 126, 234, 0.15);
    border-color: var(--accent-primary);
    color: var(--text-accent);
}

.day-chip input {
    display: none;
}

.subtasks-editor {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.subtask-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    background: var(--bg-secondary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.subtask-row input[type="text"] {
    flex: 1;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: inherit;
    outline: none;
}

.subtask-row .quant-fields {
    display: flex;
    gap: 4px;
    align-items: center;
}

.subtask-row .quant-fields input {
    width: 50px;
    padding: 4px 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.78rem;
    font-family: inherit;
    outline: none;
    text-align: center;
}

/* ===== MODALS ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-modal);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--space-lg);
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-sm {
    max-width: 380px;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.05rem;
    font-weight: 600;
}

.modal-body {
    padding: var(--space-lg);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding-top: var(--space-lg);
    margin-top: var(--space-sm);
    border-top: 1px solid var(--border-color);
}

.confirm-message {
    font-size: 0.92rem;
    color: var(--text-secondary);
    line-height: 1.6;
    padding: var(--space-md) 0;
}

/* ===== TODAY PAGE — Overall Progress ===== */
.overall-progress-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.overall-progress-section h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: var(--space-md);
}

.overall-chart-row {
    display: flex;
    align-items: center;
    gap: var(--space-xl);
}

.overall-bar-chart-container {
    flex: 1;
    height: 180px;
}

.overall-ring-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
}

.ring-center-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -60%);
    text-align: center;
}

.ring-pct {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
}

.ring-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-align: center;
}

/* ===== DAY CARDS ===== */
.day-cards-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.day-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all var(--transition-normal);
    cursor: default;
}

.day-card:hover {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.day-card.today-card {
    border-color: rgba(67, 233, 123, 0.3);
}

.day-card-header {
    text-align: center;
    margin-bottom: var(--space-md);
}

.day-card-header .day-name {
    font-weight: 700;
    font-size: 0.95rem;
}

.day-card-header .day-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.day-ring-wrapper {
    position: relative;
    width: 90px;
    height: 90px;
    margin-bottom: var(--space-md);
}

.day-ring-wrapper canvas {
    width: 90px;
    height: 90px;
}

.day-ring-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.day-card-tasks {
    width: 100%;
}

.day-card-tasks h4 {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 600;
}

.day-task {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    padding: 3px 0;
    color: var(--text-secondary);
}

.day-task.done {
    text-decoration: line-through;
    color: var(--text-muted);
}

.day-task-check {
    font-size: 0.85rem;
}

.today-bottom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
}

/* ===== WEEKLY GRID TABLE ===== */
.weekly-grid-wrapper {
    overflow-x: auto;
    margin-bottom: var(--space-xl);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.weekly-grid {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.weekly-grid thead th {
    padding: 12px 10px;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 2;
}

.weekly-grid thead th:first-child {
    text-align: left;
    padding-left: var(--space-lg);
    min-width: 200px;
}

.weekly-grid thead .th-day-name {
    font-size: 0.72rem;
    display: block;
}

.weekly-grid thead .th-day-num {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    display: block;
}

.weekly-grid thead .th-today {
    color: var(--color-check);
}

.weekly-grid tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition-fast);
}

.weekly-grid tbody tr:hover {
    background: var(--bg-surface-hover);
}

.weekly-grid tbody td {
    padding: 10px;
    text-align: center;
    vertical-align: middle;
}

.weekly-grid tbody td:first-child {
    text-align: left;
    padding-left: var(--space-lg);
    font-size: 0.88rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.weekly-grid tbody td:first-child .habit-icon {
    margin-right: 6px;
}

/* Grid checkbox */
.grid-check {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    font-size: 0.9rem;
    background: transparent;
    margin: 0 auto;
}

.grid-check:hover {
    border-color: var(--color-check);
    background: var(--color-check-bg);
}

.grid-check.checked {
    background: var(--color-check);
    border-color: var(--color-check);
    color: #fff;
    animation: checkPop 0.25s ease;
}

.grid-check.checked::after {
    content: '✓';
    font-weight: 700;
    font-size: 0.75rem;
}

.grid-check.missed {
    border-color: rgba(248, 113, 113, 0.3);
}

.grid-check.missed::after {
    content: '✕';
    color: var(--color-danger);
    font-size: 0.7rem;
}

@keyframes checkPop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
    }

    100% {
        transform: scale(1);
    }
}

/* Weekly summary row */
.weekly-grid tfoot td {
    padding: 10px;
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-muted);
    border-top: 2px solid var(--border-color);
    background: var(--bg-secondary);
    font-weight: 600;
}

.weekly-grid tfoot td:first-child {
    text-align: left;
    padding-left: var(--space-lg);
}

.summary-pct {
    font-weight: 700;
}

.summary-pct.good {
    color: var(--color-check);
}

.summary-pct.medium {
    color: var(--color-warning);
}

.summary-pct.low {
    color: var(--color-danger);
}

.week-nav {
    display: flex;
    gap: 4px;
}

/* ===== ANALYSIS PANEL ===== */
.analysis-panel {
    margin-bottom: var(--space-xl);
}

.analysis-row {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.analysis-row:last-child {
    border-bottom: none;
}

.analysis-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    min-width: 120px;
    flex-shrink: 0;
}

.analysis-values {
    display: flex;
    gap: var(--space-md);
    align-items: center;
    font-size: 0.82rem;
    color: var(--text-muted);
    min-width: 80px;
}

.analysis-bar-wrapper {
    flex: 1;
    height: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.analysis-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--color-check), #6ee7b7);
    border-radius: var(--radius-full);
    transition: width 0.5s ease;
}

/* ===== TASK ITEMS ===== */
.task-card-wrapper {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-md);
    overflow: hidden;
    transition: all var(--transition-normal);
}

.task-card-wrapper:hover {
    border-color: var(--border-accent);
}

.task-item {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-md);
    transition: all var(--transition-fast);
    border: 1px solid transparent;
}

.task-item:hover {
    background: var(--bg-surface-hover);
}

.task-checkbox {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    margin-top: 2px;
}

.task-checkbox:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.task-checkbox.checked {
    background: var(--accent-gradient);
    border-color: transparent;
}

.task-checkbox.checked::after {
    content: '✓';
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
}

.task-info {
    flex: 1;
    min-width: 0;
}

.task-title {
    font-size: 0.88rem;
    font-weight: 500;
}

.task-item.completed .task-title {
    text-decoration: line-through;
    color: var(--text-muted);
}

.task-meta {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-top: 4px;
    flex-wrap: wrap;
}

.task-meta-tag {
    font-size: 0.68rem;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: var(--bg-surface-active);
    color: var(--text-muted);
}

.task-meta-tag.category-tag {
    border: 1px solid;
}

.task-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.task-item:hover .task-actions {
    opacity: 1;
}

.task-expand-toggle {
    cursor: pointer;
    padding: 2px;
    transition: transform var(--transition-fast);
    margin-top: 2px;
}

.task-expand-toggle.expanded {
    transform: rotate(90deg);
}

.subtasks-wrapper {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
}

.subtasks-wrapper.open {
    max-height: 800px;
}

.subtask-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 6px var(--space-md) 6px 50px;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: all var(--transition-fast);
    border-radius: var(--radius-sm);
}

.subtask-item:hover {
    background: var(--bg-surface-hover);
}

.subtask-check {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 2px solid var(--border-color);
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    font-size: 0.5rem;
}

.subtask-check:hover {
    border-color: var(--accent-primary);
}

.subtask-check.checked {
    background: var(--accent-primary);
    border-color: transparent;
}

.subtask-check.checked::after {
    content: '✓';
    color: #fff;
    font-weight: 700;
}

.subtask-item.done {
    text-decoration: line-through;
    color: var(--text-muted);
}

.subtask-quant {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 4px;
}

.subtask-quant-btn {
    background: var(--bg-surface-active);
    border: none;
    color: var(--text-accent);
    cursor: pointer;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.73rem;
    font-family: inherit;
    transition: all var(--transition-fast);
}

/* ===== CALENDAR ===== */
.calendar-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-lg);
}

.calendar-grid-wrapper {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: var(--space-sm);
}

.calendar-weekdays span {
    text-align: center;
    font-size: 0.73rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: var(--space-sm);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all var(--transition-fast);
    color: var(--text-secondary);
    gap: 2px;
}

.calendar-day:hover {
    background: var(--bg-surface-hover);
}

.calendar-day.other-month {
    color: var(--text-muted);
    opacity: 0.4;
}

.calendar-day.today {
    background: rgba(102, 126, 234, 0.12);
    color: var(--text-accent);
    font-weight: 700;
}

.calendar-day.selected {
    background: var(--accent-gradient);
    color: #fff;
}

.day-dots {
    display: flex;
    gap: 3px;
}

.day-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent-primary);
}

.day-dot.reminder-dot {
    background: var(--color-warning);
}

.day-dot.birthday-dot {
    background: var(--color-danger);
}

.calendar-nav {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.calendar-month-label {
    font-weight: 600;
    min-width: 130px;
    text-align: center;
    font-size: 0.92rem;
}

.calendar-events-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.calendar-events-panel h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: var(--space-md);
}

.events-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.event-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    border-left: 3px solid var(--accent-primary);
    transition: all var(--transition-fast);
}

.event-item:hover {
    background: var(--bg-surface-hover);
}

.event-item.birthday {
    border-left-color: var(--color-danger);
}

.event-icon {
    font-size: 1.05rem;
}

.event-info {
    flex: 1;
}

.event-title {
    font-weight: 500;
}

.event-time {
    font-size: 0.73rem;
    color: var(--text-muted);
}

.event-actions {
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.event-item:hover .event-actions {
    opacity: 1;
}

/* ===== STATISTICS ===== */
.stats-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.stat-card {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    transition: all var(--transition-normal);
}

.stat-card:hover {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    display: block;
}

.stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.stats-charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
}

.chart-container {
    position: relative;
}

.chart-lg {
    min-height: 260px;
}

.chart-md {
    min-height: 230px;
}

.period-toggle {
    display: flex;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: 3px;
}

.period-toggle.small {
    margin: 0;
}

.period-btn {
    padding: 6px 14px;
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
}

.period-btn.active {
    background: var(--accent-gradient);
    color: #fff;
}

/* ===== FINANCE ===== */
.finance-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.finance-card {
    padding: var(--space-xl);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.finance-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.income-card {
    background: rgba(52, 211, 153, 0.05);
}

.income-card::before {
    background: linear-gradient(90deg, #34d399, #6ee7b7);
}

.expense-card {
    background: rgba(248, 113, 113, 0.05);
}

.expense-card::before {
    background: linear-gradient(90deg, #f87171, #fca5a5);
}

.balance-card {
    background: rgba(102, 126, 234, 0.05);
}

.balance-card::before {
    background: var(--accent-gradient);
}

.finance-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.finance-card-icon {
    font-size: 1.4rem;
}

.finance-card-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.finance-card-value {
    font-size: 1.6rem;
    font-weight: 700;
}

.income-card .finance-card-value {
    color: var(--color-income);
}

.expense-card .finance-card-value {
    color: var(--color-expense);
}

.balance-card .finance-card-value {
    color: var(--text-accent);
}

.finance-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
}

.finance-transactions-card {
    grid-column: 1 / 3;
}

.transaction-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.transaction-item:last-child {
    border-bottom: none;
}

.transaction-item:hover {
    background: var(--bg-surface-hover);
}

.transaction-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.transaction-info {
    flex: 1;
}

.transaction-category {
    font-size: 0.88rem;
    font-weight: 500;
}

.transaction-note {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.transaction-date {
    font-size: 0.73rem;
    color: var(--text-muted);
}

.transaction-amount {
    font-weight: 600;
    font-size: 0.92rem;
}

.transaction-amount.income {
    color: var(--color-income);
}

.transaction-amount.expense {
    color: var(--color-expense);
}

.transaction-actions {
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.transaction-item:hover .transaction-actions {
    opacity: 1;
}

/* ===== TOAST ===== */
.toast-container {
    position: fixed;
    bottom: 80px;
    right: var(--space-lg);
    z-index: 2000;
    display: flex;
    flex-direction: column-reverse;
    gap: var(--space-sm);
}

.toast {
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.82rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    animation: toastIn 0.3s ease;
    max-width: 340px;
}

.toast.success {
    border-left: 3px solid var(--color-success);
}

.toast.error {
    border-left: 3px solid var(--color-danger);
}

.toast.warning {
    border-left: 3px solid var(--color-warning);
}

.toast.info {
    border-left: 3px solid var(--color-info);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }
}

/* ===== EMPTY STATES ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl);
    color: var(--text-muted);
    text-align: center;
}

.empty-state-icon {
    font-size: 2.2rem;
    margin-bottom: var(--space-md);
    opacity: 0.5;
}

.empty-state-text {
    font-size: 0.88rem;
    max-width: 260px;
    line-height: 1.6;
}

.today-empty-state {
    padding-bottom: var(--space-md);
}

.today-empty-hint {
    margin-top: 6px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.today-upcoming-list {
    margin-top: var(--space-sm);
}

.tasks-archive-block {
    margin-top: var(--space-xl);
}

/* ===== UTILITIES ===== */
.text-success {
    color: var(--color-success);
}

.text-danger {
    color: var(--color-danger);
}

.text-accent {
    color: var(--text-accent);
}

.text-muted {
    color: var(--text-muted);
}

.mt-md {
    margin-top: var(--space-md);
}

.fw-600 {
    font-weight: 600;
}

.fs-sm {
    font-size: 0.82rem;
}

/* ============================================================
   RESPONSIVE — Tablet
   ============================================================ */
@media (max-width: 1100px) {
    .stats-summary {
        grid-template-columns: repeat(2, 1fr);
    }

    .stats-charts,
    .finance-grid {
        grid-template-columns: 1fr;
    }

    .finance-transactions-card {
        grid-column: 1;
    }

    .day-cards-row {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }
}

@media (max-width: 900px) {
    .today-bottom-grid {
        grid-template-columns: 1fr;
    }

    .calendar-layout {
        grid-template-columns: 1fr;
    }

    .finance-summary {
        grid-template-columns: 1fr;
    }

    .overall-chart-row {
        flex-direction: column;
    }
}

/* ============================================================
   RESPONSIVE — Mobile
   ============================================================ */
@media (max-width: 768px) {

    /* Sidebar: off-screen drawer */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 280px;
        min-width: 280px;
        transform: translateX(-100%);
        transition: transform var(--transition-smooth);
        z-index: 200;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar.collapsed {
        width: 280px;
        min-width: 280px;
    }

    .sidebar.collapsed .logo-text,
    .sidebar.collapsed .nav-label,
    .sidebar.collapsed .nav-badge,
    .sidebar.collapsed .section-header h3,
    .sidebar.collapsed .category-list,
    .sidebar.collapsed .tag-list,
    .sidebar.collapsed .sidebar-section .btn-icon {
        display: block;
    }

    /* Show mobile elements */
    .mobile-header {
        display: flex;
    }

    .mobile-nav {
        display: flex;
    }

    /* Hide desktop elements */
    .sidebar-toggle {
        display: none;
    }

    .page-header .header-actions .btn {
        font-size: 0.78rem;
        padding: 8px 14px;
    }

    /* Main content adjustments */
    .main-content {
        padding: var(--space-md);
        padding-bottom: calc(var(--mobile-nav-h) + var(--space-md));
        height: auto;
        min-height: 100vh;
    }

    .page-header {
        flex-direction: column;
        gap: var(--space-sm);
        margin-bottom: var(--space-md);
    }

    .page-header h1 {
        font-size: 1.2rem;
    }

    /* Weekly grid: fit completely on mobile */
    .weekly-grid {
        min-width: 100%;
        table-layout: fixed;
    }

    .weekly-grid tbody td {
        padding: 4px 2px;
    }

    .weekly-grid thead th {
        padding: 4px 2px;
    }

    .weekly-grid tbody td:first-child {
        max-width: 80px;
        width: 80px;
        font-size: 0.72rem;
        padding-left: 4px;
        white-space: normal;
        word-wrap: break-word;
    }

    .weekly-grid thead th:first-child {
        padding-left: 4px;
        width: 80px;
        max-width: 80px;
    }

    .weekly-grid thead .th-day-name {
        font-size: 0.6rem;
    }
    
    .weekly-grid thead .th-day-num {
        font-size: 0.75rem;
    }

    .grid-check {
        width: 22px;
        height: 22px;
    }
    
    .grid-check.checked::after {
        font-size: 0.6rem;
    }

    /* Day cards */
    .day-cards-row {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
        gap: var(--space-sm);
    }

    .day-card {
        padding: var(--space-md);
    }

    .day-ring-wrapper {
        width: 70px;
        height: 70px;
    }

    .day-ring-wrapper canvas {
        width: 70px;
        height: 70px;
    }

    .day-ring-center {
        font-size: 0.9rem;
    }

    /* Stats */
    .stats-summary {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-sm);
    }

    .stat-card {
        padding: var(--space-md);
        gap: var(--space-sm);
    }

    .stat-icon {
        width: 38px;
        height: 38px;
        font-size: 1rem;
    }

    .stat-value {
        font-size: 1.1rem;
    }

    /* Forms */
    .form-row {
        grid-template-columns: 1fr;
    }

    .filter-group {
        flex-direction: column;
        width: 100%;
    }

    .select-input {
        width: 100%;
    }

    /* Modal */
    .modal {
        max-width: 100%;
        border-radius: var(--radius-lg);
    }

    .modal-overlay {
        padding: var(--space-md);
    }

    /* Finance */
    .finance-card {
        padding: var(--space-md);
    }

    .finance-card-value {
        font-size: 1.2rem;
    }

    /* Toast — above mobile nav */
    .toast-container {
        bottom: calc(var(--mobile-nav-h) + var(--space-md));
        right: var(--space-md);
        left: var(--space-md);
    }

    .toast {
        max-width: 100%;
    }

    /* Overall progress */
    .overall-progress-section {
        padding: var(--space-md);
    }

    .overall-bar-chart-container {
        height: 140px;
    }

    /* Notes responsive */
    .notes-layout { flex-direction: column !important; }
    .notes-sidebar { width: 100% !important; border-right: none !important; }
    .notes-sidebar.hidden { display: none !important; }
    .note-editor { padding-left: 0 !important; }
    .note-editor.active { display: flex !important; }
    .note-empty-state { display: none !important; }
}

@media (max-width: 420px) {
    .day-cards-row {
        grid-template-columns: 1fr 1fr;
    }

    .stats-summary {
        grid-template-columns: 1fr;
    }

    .day-card {
        padding: var(--space-sm);
    }

    .day-ring-wrapper {
        width: 60px;
        height: 60px;
    }

    .day-ring-wrapper canvas {
        width: 60px;
        height: 60px;
    }

    .day-ring-center {
        font-size: 0.78rem;
    }

    .day-card-header .day-name {
        font-size: 0.82rem;
    }

    .header-actions {
        width: 100%;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }
}
