:root {
    --sidebar-width: 240px;
}

body {
    background-color: #f4f6fb;
}
[data-bs-theme="dark"] body {
    background-color: #14161c;
}

/* ---------- Auth pages ---------- */
.auth-content {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}
.auth-wrapper { width: 100%; max-width: 440px; }
.auth-card { border-radius: 16px; border: none; }

/* ---------- App shell ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}
.sidebar {
    width: var(--sidebar-width);
    background: #101828;
    color: #fff;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    overflow-y: auto;
    transition: transform .25s ease;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 700;
    font-size: 1.15rem;
    padding: 1.25rem 1.25rem 1rem;
    color: #fff;
}
.sidebar-nav { display: flex; flex-direction: column; padding: .5rem .75rem; }
.sidebar-nav a {
    color: #b6bfd1;
    text-decoration: none;
    padding: .6rem .75rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: .65rem;
    font-size: .92rem;
    margin-bottom: 2px;
}
.sidebar-nav a i { width: 18px; text-align: center; }
.sidebar-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-nav a.active { background: #0d6efd; color: #fff; }
.sidebar-nav hr { border-color: rgba(255,255,255,.1); margin: .5rem 0; }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1035;
}

.app-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .sidebar-backdrop.show { display: block; }
    .app-main { margin-left: 0; }
}

.topbar {
    background: #fff;
    padding: .85rem 1.25rem;
    border-bottom: 1px solid #e9ecef;
    position: sticky;
    top: 0;
    z-index: 1020;
}
[data-bs-theme="dark"] .topbar { background: #1b1e27; border-color: #2a2e3a; }

.app-content { padding: 1.5rem; flex: 1; }

.avatar-fallback, .avatar-fallback-lg {
    background: #0d6efd;
    color: #fff;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}
.avatar-fallback { width: 32px; height: 32px; font-size: .85rem; }
.avatar-fallback-lg { width: 100px; height: 100px; font-size: 2.25rem; }
.avatar-img { object-fit: cover; }

/* ---------- Cards ---------- */
.stat-card { border: none; border-radius: 14px; }
.stat-icon {
    width: 42px; height: 42px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.15rem;
    margin-bottom: .6rem;
}
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-label { color: #6c757d; font-size: .82rem; margin-top: .15rem; }

.habit-card { border: none; border-radius: 14px; }
.habit-color-dot {
    width: 10px; height: 10px; border-radius: 50%;
    display: inline-block; flex-shrink: 0;
}
.category-icon {
    width: 46px; height: 46px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem;
}
.report-tile { border: none; border-radius: 14px; transition: transform .15s ease, box-shadow .15s ease; color: inherit; }
.report-tile:hover { transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,.08); }

/* ---------- Habit rows ---------- */
.habit-row { transition: background .15s ease; }
.habit-checkbox { width: 1.15em; height: 1.15em; cursor: pointer; }

/* ---------- Spark strip ---------- */
.spark-strip { display: flex; justify-content: space-between; gap: 6px; }
.spark-day { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.spark-dot {
    width: 22px; height: 22px; border-radius: 50%;
    background: #e9ecef; display: inline-block;
}
.spark-dot.filled { background: #fd7e14; }

/* ---------- Calendar ---------- */
.cal-weekdays {
    display: grid; grid-template-columns: repeat(7, 1fr);
    text-align: center; font-size: .78rem; color: #6c757d;
    margin-bottom: .35rem; font-weight: 600;
}
.cal-grid {
    display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
}
.cal-cell {
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    font-size: .8rem;
    background: #f1f3f6;
    position: relative;
}
[data-bs-theme="dark"] .cal-cell { background: #262a35; }
.cal-cell.empty { background: transparent; }
.cal-daynum { font-size: .72rem; color: #6c757d; position: absolute; top: 3px; left: 5px; }
.cal-cell.is-today { outline: 2px solid #0d6efd; }
.cal-cell.state-completed { background: #d1e7dd; color: #0f5132; }
.cal-cell.state-partial { background: #fff3cd; color: #664d03; }
.cal-cell.state-missed { background: #f8d7da; color: #842029; }
.cal-cell.state-today, .cal-cell.state-today-empty { background: #cfe2ff; color: #084298; }
.cal-cell.state-upcoming { background: #f1f3f6; color: #6c757d; }
.cal-cell.state-not-scheduled { background: transparent; color: #adb5bd; }

.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: middle; }
.legend-dot.state-completed { background: #d1e7dd; }
.legend-dot.state-partial { background: #fff3cd; }
.legend-dot.state-missed { background: #f8d7da; }
.legend-dot.state-today { background: #cfe2ff; }
.legend-dot.state-not-scheduled { background: #e9ecef; }
