/* LifeStack – premium dark design system */

:root {
    --bg-app: #09090b;
    --bg-sidebar: #0c0c0f;
    --bg-card: #13131a;
    --bg-elevated: #1a1a22;
    --border: rgba(255, 255, 255, 0.07);
    --text: #fafafa;
    --text-muted: #a1a1aa;
    --text-dim: #71717a;
    --accent-purple: #a78bfa;
    --accent-green: #4ade80;
    --accent-yellow: #facc15;
    --accent-blue: #60a5fa;
    --accent-pink: #f472b6;
    --accent-orange: #fb923c;
    --accent-teal: #2dd4bf;
    --accent-teal-soft: rgba(45, 212, 191, 0.14);
    --sidebar-width: 240px;
    --radius: 14px;
    --radius-sm: 10px;
    --radius-pill: 999px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.35);
    --shadow-glow-purple: 0 0 32px rgba(167, 139, 250, 0.12);

    /* Spring-ish easing: no-overshoot "critically damped" curve for most UI,
       a gentle-overshoot curve reserved for momentum/success moments. */
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-press: 0.1s;
    --transition-fast: 0.15s var(--ease-out);
    --transition-base: 0.2s var(--ease-out);
    --transition-sheet: 0.32s var(--ease-out);

    /* legacy aliases */
    --bg: var(--bg-app);
    --surface: var(--bg-card);
    --sidebar-bg: var(--bg-sidebar);
    --sidebar-text: var(--text-muted);
    --sidebar-active-bg: rgba(167, 139, 250, 0.12);
    --sidebar-active-text: var(--text);
    --lime: var(--accent-yellow);
    --purple: var(--accent-purple);
    --purple-dark: #8b5cf6;
    --dark-card: var(--bg-elevated);
    --income: var(--accent-green);
    --expense: var(--accent-pink);
    --text-income: var(--accent-green);
    --text-expense: var(--accent-pink);
    --shadow: var(--shadow-sm);
    --chart-grid: rgba(255, 255, 255, 0.12);
    --chart-label: #a1a1aa;
    --chart-tick: rgba(255, 255, 255, 0.45);
    --chart-tooltip-bg: #1a1a22;
    --chart-tooltip-text: #fafafa;
    --font-weight-heading: 700;
    --font-weight-label: 600;
    --font-weight-body: 400;
}

[data-theme="light"] {
    --bg-app: #f4f4f5;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-elevated: #f4f4f5;
    --border: rgba(0, 0, 0, 0.1);
    --accent-teal: #0f766e;
    --accent-teal-soft: #ccfbf1;
    --text: #09090b;
    --text-muted: #52525b;
    --text-dim: #71717a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.08);
    --shadow-glow-purple: 0 0 32px rgba(139, 92, 246, 0.1);
    --sidebar-active-bg: rgba(139, 92, 246, 0.1);
    --chart-grid: rgba(9, 9, 11, 0.22);
    --chart-label: #3f3f46;
    --chart-tick: rgba(9, 9, 11, 0.55);
    --chart-tooltip-bg: #ffffff;
    --chart-tooltip-text: #09090b;
    --font-weight-heading: 650;
    --font-weight-label: 600;
    --font-weight-body: 400;
    --text-income: #15803d;
    --text-expense: #be185d;
}

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

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    font-size: 14px;
    font-weight: var(--font-weight-body);
    line-height: 1.5;
    color: var(--text);
    background: var(--bg-app);
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text);
    font-weight: var(--font-weight-heading);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

/* Tracking tightens with size — larger headings need more negative letter-spacing
   to read correctly; specific component classes below override these defaults. */
h1 { letter-spacing: -0.03em; }
h2 { letter-spacing: -0.025em; }
h3, h4, h5, h6 { letter-spacing: -0.015em; }

label {
    color: var(--text);
    font-weight: var(--font-weight-label);
}

[data-theme="light"] body {
    -webkit-font-smoothing: auto;
    letter-spacing: -0.008em;
}

/* Semantic text hierarchy — theme-aware across all pages */
.card-sub,
.page-subtitle,
.auth-subtitle,
.form-hint,
.dash-date,
.dash-status-line,
.cal-schedule-time,
.activity-time,
.dash-metric-label,
.journal-entry-meta,
.journal-detail-body,
.note-detail-body,
.note-card-body,
.table th,
.breadcrumb,
.header-crumb,
.finance-stat-label,
.gym-stat-detail,
.metric-trend--neutral {
    color: var(--text-muted);
}

.text-dim,
.dash-domain-delta,
.cal-day-num,
.note-card-meta {
    color: var(--text-dim);
}

.card-stat,
.card-stat-sm,
.dash-metric-value,
.dash-greeting,
.dash-section-title,
.dash-aside-title,
.dash-domain-name,
.activity-text,
.cal-schedule-title,
.journal-entry-title,
.journal-detail-title,
.page-head h1,
.card-head h2,
.empty-state h3,
.finance-net-worth,
.table td,
.form-control,
input,
select,
textarea {
    color: var(--text);
}

.card-sub,
.page-subtitle {
    color: var(--text-muted);
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: none; }

img, svg { display: block; }

/* ─── Layout ─── */

.layout {
    display: flex;
    min-height: 100vh;
    background: var(--bg-app);
}

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

.main-content {
    flex: 1;
    padding: 0 1.75rem 2rem;
}

.layout.sidebar-collapsed .main-wrapper { margin-left: 72px; }
.layout.sidebar-collapsed .sidebar { width: 72px; }
.layout.sidebar-collapsed .sidebar .logo-text,
.layout.sidebar-collapsed .sidebar .nav-label,
.layout.sidebar-collapsed .sidebar .nav-dot,
.layout.sidebar-collapsed .sidebar .nav-badge,
.layout.sidebar-collapsed .sidebar .sidebar-footer-label { display: none; }
.layout.sidebar-collapsed .sidebar .logo { justify-content: center; padding-inline: 0.5rem; }
.layout.sidebar-collapsed .sidebar .nav-link { justify-content: center; padding-inline: 0.75rem; }
.layout.sidebar-collapsed .sidebar .nav-link.active::after { display: none; }
.layout.sidebar-collapsed .sidebar .nav-collapse-btn .nav-icon svg { transform: rotate(180deg); }

/* ─── Sidebar ─── */

.sidebar {
    width: var(--sidebar-width);
    background: color-mix(in srgb, var(--bg-sidebar) 82%, transparent);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    padding: 1.25rem 0.875rem;
    transition: transform var(--transition-base), width var(--transition-base);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    color: var(--text);
    font-size: 1.0625rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    padding: 0.375rem 0.625rem;
    margin-bottom: 1.75rem;
    transition: opacity var(--transition-fast);
}

.logo:hover { opacity: 0.9; }

.logo-bars {
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: 18px;
    flex-shrink: 0;
}

.logo-bars span,
.logo-bars::before,
.logo-bars::after {
    display: block;
    height: 3px;
    border-radius: 2px;
}

.logo-bars::before { content: ''; width: 100%; background: var(--accent-purple); }
.logo-bars span { width: 100%; background: var(--accent-teal); }
.logo-bars::after { content: ''; width: 70%; background: var(--accent-yellow); }

.logo-dot {
    position: relative;
    display: block;
    width: 18px;
    height: 3px;
    flex-shrink: 0;
    background: var(--accent-teal);
    border-radius: 2px;
}

.logo-dot::before,
.logo-dot::after {
    content: '';
    position: absolute;
    left: 0;
    height: 3px;
    border-radius: 2px;
}

.logo-dot::before {
    top: -6px;
    width: 100%;
    background: var(--accent-purple);
}

.logo-dot::after {
    top: 6px;
    width: 70%;
    background: var(--accent-yellow);
}

.logo-text { white-space: nowrap; }

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    position: relative;
    transition: background var(--transition-fast), color var(--transition-fast), transform var(--duration-press) var(--ease-out);
}

.nav-link:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
}

.nav-link:active {
    transform: scale(0.97);
}

.nav-link.active {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 18px;
    border-radius: 0 3px 3px 0;
    background: var(--accent-purple);
}

.nav-link.active::after {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-purple);
    margin-left: auto;
    box-shadow: 0 0 8px rgba(167, 139, 250, 0.6);
    flex-shrink: 0;
}

.nav-link-sub {
    font-size: 0.8125rem;
    color: var(--text-dim);
}

.nav-link-sub:hover { color: var(--text-muted); }

.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    flex-shrink: 0;
    opacity: 0.85;
}

.nav-link.active .nav-icon { opacity: 1; color: var(--accent-purple); }

.nav-badge {
    margin-left: auto;
    background: rgba(167, 139, 250, 0.2);
    color: var(--accent-purple);
    font-size: 0.6875rem;
    font-weight: 700;
    padding: 0.1rem 0.45rem;
    border-radius: var(--radius-pill);
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 0.75rem 0 0;
    border-top: 1px solid var(--border);
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.nav-logout-form {
    margin: 0;
    width: 100%;
}

/* ─── Mobile tab bar (phone-width nav, hidden on desktop) ─── */

.mobile-tabbar { display: none; }

.tabbar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
    padding: 0.375rem 0.25rem;
    color: var(--text-dim);
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast), transform var(--duration-press) var(--ease-out);
}

.tabbar-item:active { transform: scale(0.92); }

.tabbar-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.375rem;
    border-radius: var(--radius-pill);
    opacity: 0.8;
    transition: opacity var(--transition-fast), background var(--transition-fast);
}

.tabbar-label {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.tabbar-item.active { color: var(--accent-teal); }
.tabbar-item.active .tabbar-icon {
    opacity: 1;
    background: rgba(45, 212, 191, 0.14);
}

.nav-logout-btn:hover {
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
}

.sidebar-collapse,
.nav-collapse-btn,
.nav-logout-btn {
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
}

.sidebar-collapse {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    font-size: 0.8125rem;
    font-weight: 500;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.sidebar-collapse:hover {
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.04);
}

/* ─── Header ─── */

.main-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1.75rem;
    background: color-mix(in srgb, var(--bg-app) 72%, transparent);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.menu-toggle {
    display: none;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 0.4rem;
    color: var(--text-muted);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.menu-toggle:hover { color: var(--text); background: var(--bg-card); }

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--text-muted);
    min-width: 0;
}

.breadcrumb-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-purple);
    flex-shrink: 0;
    box-shadow: 0 0 6px rgba(167, 139, 250, 0.5);
}

.breadcrumb-sep { color: var(--text-dim); }

.breadcrumb-current {
    color: var(--text);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-search {
    flex: 1;
    max-width: 420px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    background: var(--bg-card);
    border-radius: var(--radius-pill);
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.header-search:focus-within {
    border-color: rgba(167, 139, 250, 0.35);
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.1);
}

.header-search input {
    flex: 1;
    border: none;
    background: none;
    font-size: 0.875rem;
    outline: none;
    color: var(--text);
    min-width: 0;
}

.header-search input::placeholder { color: var(--text-dim); }
.header-search svg { color: var(--text-dim); flex-shrink: 0; }

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-left: auto;
}

.theme-toggle,
.header-theme {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), transform var(--duration-press) var(--ease-out);
}

.theme-toggle:hover,
.header-theme:hover {
    color: var(--text);
    background: var(--bg-elevated);
    border-color: rgba(255, 255, 255, 0.12);
}

.theme-toggle:active,
.header-theme:active,
.header-avatar:active,
.header-bell:active,
.header-profile:active {
    transform: scale(0.92);
}

.theme-icon {
    display: block;
}

.theme-icon--moon {
    display: none;
}

.theme-toggle--light .theme-icon--sun,
.header-theme.theme-toggle--light .theme-icon--sun {
    display: none;
}

.theme-toggle--light .theme-icon--moon,
.header-theme.theme-toggle--light .theme-icon--moon {
    display: block;
}

.header-profile {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem 0.25rem 0.25rem;
    border-radius: var(--radius-pill);
    transition: background var(--transition-fast), transform var(--duration-press) var(--ease-out);
}

.header-profile:hover { background: rgba(255, 255, 255, 0.04); }

.header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-purple), #7c3aed);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.08);
    transition: transform var(--duration-press) var(--ease-out);
}

.header-user { display: flex; flex-direction: column; }
.header-name { font-size: 0.8125rem; font-weight: 600; line-height: 1.2; }
.header-email { font-size: 0.6875rem; color: var(--text-dim); }
.header-chevron { color: var(--text-dim); }

.header-bell {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), transform var(--duration-press) var(--ease-out);
}

.header-bell:hover {
    color: var(--text);
    background: var(--bg-elevated);
    border-color: rgba(255, 255, 255, 0.12);
}

.bell-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--accent-purple);
    color: #fff;
    font-size: 0.5625rem;
    font-weight: 700;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-app);
}

/* ─── Page head ─── */

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-top: 0.5rem;
}

.page-head h1 {
    margin: 0;
    font-size: 1.625rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.page-subtitle {
    margin: 0.25rem 0 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.page-head-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.page-date {
    font-size: 0.8125rem;
    color: var(--text-dim);
}

.page-filter-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 0.45rem 1rem;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-muted);
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.page-filter-btn:hover {
    color: var(--text);
    background: var(--bg-elevated);
    border-color: rgba(255, 255, 255, 0.12);
}

/* ─── Cards ─── */

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.25rem;
    border: 1px solid var(--border);
    transition: border-color var(--transition-base), box-shadow var(--transition-base), transform var(--duration-press) var(--ease-out);
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-md);
}

a.card:active,
button.card:active {
    transform: scale(0.99);
}

.card-dark {
    background: var(--bg-elevated);
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.08);
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.card-head h2 {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text);
}

.card-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
}

.card-dark .card-icon { background: rgba(255, 255, 255, 0.08); }

.card-menu {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 1.125rem;
    line-height: 1;
    padding: 0.25rem;
    border-radius: 6px;
    transition: color var(--transition-fast), background var(--transition-fast);
}

.card-menu:hover { color: var(--text-muted); background: rgba(255, 255, 255, 0.05); }

.card-stat {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0.25rem 0;
    color: var(--text);
}

.card-stat-sm {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0.25rem 0;
    color: var(--text);
}

.card-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.card-dark .card-sub { color: var(--text-dim); }

.card-link {
    font-size: 0.8125rem;
    color: var(--accent-purple);
    font-weight: 500;
    transition: opacity var(--transition-fast);
}

.card-link:hover { opacity: 0.8; text-decoration: underline; }

.card-list { display: flex; flex-direction: column; gap: 1rem; }

.card-footer-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.chart-card { cursor: pointer; }
.chart-card:hover { border-color: rgba(167, 139, 250, 0.25); }
.chart-card:active { transform: scale(0.99); }
.chart-wrap { position: relative; height: 220px; }
.chart-wrap-sm { height: 180px; }

/* ─── Buttons ─── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: var(--radius-pill);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    line-height: 1.4;
    transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), opacity var(--transition-fast), transform var(--duration-press) var(--ease-out);
}

.btn:hover { text-decoration: none; }
.btn:active { transform: scale(0.96); }

.btn-primary {
    background: var(--accent-purple);
    color: #09090b;
    border-color: transparent;
}

.btn-primary:hover {
    background: #c4b5fd;
    opacity: 1;
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
    opacity: 1;
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: transparent;
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    opacity: 1;
}

.btn-outline {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.14);
    opacity: 1;
}

.btn-lime {
    background: var(--accent-yellow);
    color: #09090b;
}

.btn-lime:hover { background: #fde047; opacity: 1; }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.75rem; }
.btn-group { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ─── Badges ─── */

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-muted);
}

.badge-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-pill);
    font-size: 0.6875rem;
    font-weight: 600;
    background: rgba(74, 222, 128, 0.12);
    color: var(--accent-green);
}

.badge-pill-lime {
    background: rgba(250, 204, 21, 0.15);
    color: var(--accent-yellow);
}

.badge-income { background: rgba(74, 222, 128, 0.12); color: var(--text-income); }
.badge-expense { background: rgba(244, 114, 182, 0.12); color: var(--accent-pink); }
.badge-purple { background: rgba(167, 139, 250, 0.12); color: var(--accent-purple); }
.badge-blue { background: rgba(96, 165, 250, 0.12); color: var(--accent-blue); }
.badge-orange { background: rgba(251, 146, 60, 0.12); color: var(--accent-orange); }
.badge-teal { background: rgba(45, 212, 191, 0.12); color: var(--accent-teal); }

.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-income { color: var(--text-income); }
.text-expense { color: var(--text-expense); }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ─── Progress bars ─── */

.progress-list { display: flex; flex-direction: column; gap: 0.875rem; margin-top: 1rem; }
.progress-item { display: flex; flex-direction: column; gap: 0.375rem; }

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

.progress-track {
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill { height: 100%; border-radius: 3px; transition: width 0.4s ease; }
.fill-purple { background: var(--accent-purple); }
.fill-green { background: var(--accent-green); }
.fill-yellow, .fill-lime { background: var(--accent-yellow); }
.fill-blue { background: var(--accent-blue); }
.fill-pink { background: var(--accent-pink); }
.fill-teal { background: var(--accent-teal); }
.fill-dark { background: var(--text-dim); }

/* ─── Tables ─── */

.table-responsive { overflow-x: auto; border-radius: var(--radius-sm); }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.table th,
.table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-weight: 600;
    color: var(--text-dim);
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: rgba(255, 255, 255, 0.02);
}

.table tbody tr {
    transition: background var(--transition-fast);
}

.table tbody tr:hover { background: rgba(255, 255, 255, 0.03); }

.table tbody tr:last-child td { border-bottom: none; }

/* ─── Forms ─── */

.form-card { max-width: 640px; }

.form-page {
    width: 100%;
    max-width: none;
}

.form-layout { width: 100%; }

.form-section {
    margin-bottom: 1.75rem;
    padding-bottom: 1.75rem;
    border-bottom: 1px solid var(--border);
}

.form-section:last-of-type { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

.form-section-title {
    margin: 0 0 1rem;
    font-size: 0.9375rem;
    font-weight: 600;
}

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

.form-group-full { grid-column: 1 / -1; }

.form-group-checkbox {
    display: flex;
    align-items: center;
    padding-top: 0.5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--text-muted);
}

.field-error {
    display: block;
    color: var(--accent-pink);
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.field-hint {
    display: block;
    color: var(--text-dim);
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.form-group { margin-bottom: 1rem; }

.form-group label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
}

.form-control,
.form-page select,
.form-page input[type="text"],
.form-page input[type="number"],
.form-page input[type="date"],
.form-page input[type="email"],
.form-page input[type="password"],
.form-page input[type="search"],
.form-page textarea {
    width: 100%;
    padding: 0.6rem 0.875rem;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text);
    appearance: auto;
    font-family: inherit;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-page select {
    cursor: pointer;
    min-height: 42px;
}

.form-control:focus,
.form-page select:focus,
.form-page input:focus,
.form-page textarea:focus {
    outline: none;
    border-color: rgba(167, 139, 250, 0.45);
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.12);
}

.form-control::placeholder,
.form-page input::placeholder,
.form-page textarea::placeholder { color: var(--text-dim); }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.form-hint { font-size: 0.8125rem; margin-bottom: 1rem; color: var(--text-dim); }

/* ─── Empty state ─── */

.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
}

.empty-state h3 { margin: 0 0 0.5rem; color: var(--text); font-size: 1rem; }

.empty-state-compact {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.5rem 0;
}

.empty-state-compact p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ─── Modal ─── */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(4px);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    transition: opacity var(--transition-sheet), display var(--transition-sheet) allow-discrete;
}

.modal-overlay.open {
    display: flex;
    opacity: 1;
}

@starting-style {
    .modal-overlay.open { opacity: 0; }
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-width: 720px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    transform: scale(1) translateY(0);
    transition: transform var(--transition-sheet);
}

.modal-overlay.open .modal {
    transform: scale(1) translateY(0);
}

@starting-style {
    .modal-overlay.open .modal { transform: scale(0.96) translateY(8px); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.modal-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.modal-header-left h2 { margin: 0; font-size: 1.125rem; }

.modal-back {
    background: none;
    border: none;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--accent-purple);
    cursor: pointer;
    padding: 0;
}

.modal-back:hover { text-decoration: underline; }

.chart-modal-hint {
    margin: -0.5rem 0 0.5rem;
    font-size: 0.75rem;
    color: var(--text-dim);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-dim);
    line-height: 1;
    padding: 0.25rem;
    border-radius: 6px;
    transition: color var(--transition-fast), background var(--transition-fast);
}

.modal-close:hover { color: var(--text); background: rgba(255, 255, 255, 0.05); }

.modal-chart { height: 300px; margin: 1rem 0; }

/* ─── Alerts & messages ─── */

.messages { margin-bottom: 1rem; }

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    border: 1px solid transparent;
}

.alert-success { background: rgba(74, 222, 128, 0.1); color: var(--accent-green); border-color: rgba(74, 222, 128, 0.2); }
.alert-error, .alert-danger { background: rgba(244, 114, 182, 0.1); color: var(--accent-pink); border-color: rgba(244, 114, 182, 0.2); }
.alert-warning { background: rgba(250, 204, 21, 0.1); color: var(--accent-yellow); border-color: rgba(250, 204, 21, 0.2); }
.alert-info { background: rgba(96, 165, 250, 0.1); color: var(--accent-blue); border-color: rgba(96, 165, 250, 0.2); }

/* ─── Dashboard (legacy grid) ─── */

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

.dashboard-card,
.dashboard-stats { min-height: 0; }

.dashboard-finance { grid-column: 1; grid-row: 1; }

.dashboard-stats {
    grid-column: 2;
    grid-row: 1;
    display: grid;
    grid-template-rows: 1fr 1fr;
    gap: 1rem;
}

.dashboard-actions { grid-column: 1 / -1; grid-row: 2; }
.dashboard-detail { grid-column: span 1; }

.dashboard-stat-card {
    display: flex;
    flex-direction: column;
    color: var(--text);
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.action-grid .btn { width: 100%; justify-content: center; }

.stat-mini {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 88px;
    padding: 1rem 1.125rem;
}

.stat-mini .card-sub { display: block; margin-bottom: 0.5rem; }

.stat-mini .card-stat-sm {
    margin: 0;
    margin-top: auto;
    line-height: 1.2;
    word-break: break-word;
}

.stat-mini-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.stat-mini-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

/* ─── Dashboard ─── */

.dash-page-header {
    margin-bottom: 1.5rem;
}

.dash-greeting {
    margin: 0 0 0.25rem;
    font-size: clamp(1.5rem, 3vw, 1.875rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.2;
}

.dash-date {
    margin: 0 0 0.75rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.dash-status-line {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    margin: 0;
    font-size: 0.8125rem;
    color: var(--text-dim);
}

.dash-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
    gap: 1rem;
    align-items: start;
}

.dash-primary {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

.dash-metrics {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.dash-metric-card {
    padding: 1rem 1.125rem;
    min-height: 108px;
    display: flex;
    flex-direction: column;
}

.dash-metric-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.metric-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-dim);
}

.metric-dot--green { background: var(--accent-green); }
.metric-dot--blue { background: var(--accent-blue); }
.metric-dot--purple { background: var(--accent-purple); }
.metric-dot--yellow { background: var(--accent-yellow); }
.metric-dot--pink { background: var(--accent-pink); }

.metric-trend {
    font-size: 0.75rem;
    color: var(--text-dim);
    font-weight: 600;
}

.metric-trend--up { color: var(--text-income); }
.metric-trend--down { color: var(--text-expense); }

.dash-metric-value {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.dash-metric-label {
    margin: 0.25rem 0 0;
    font-size: 0.75rem;
    color: var(--text-dim);
}

.dash-aside {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

.dash-aside-card {
    padding: 1.125rem 1.25rem;
}

.dash-aside-card--grow {
    flex: 1;
}

.dash-aside-title {
    margin: 0 0 0.875rem;
    font-size: 0.9375rem;
    font-weight: 700;
}

.dash-quick-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.dash-quick-actions .btn {
    width: 100%;
    justify-content: center;
}

.dash-lower {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.dash-section-title {
    margin: 0 0 0.875rem;
    font-size: 1rem;
    font-weight: 700;
}

.dash-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.875rem;
}

.dash-section-head .dash-section-title {
    margin: 0;
}

.dash-domains {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.goals-ring-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.goals-ring-stats {
    display: flex;
    gap: 2rem;
}

.goals-ring-stat-num {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
    margin-bottom: 0.15rem;
}

.goals-ring-chart {
    position: relative;
    width: 88px;
    height: 88px;
    flex-shrink: 0;
}

.goals-ring-chart canvas {
    width: 100% !important;
    height: 100% !important;
}

.goals-ring-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.goals-ring-pct {
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
}

.icon-tile {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-bottom: 0.75rem;
}

.icon-tile svg { width: 20px; height: 20px; }

.icon-tile--green { background: rgba(74, 222, 128, 0.15); color: var(--accent-green); }
.icon-tile--yellow { background: rgba(250, 204, 21, 0.15); color: var(--accent-yellow); }
.icon-tile--purple { background: rgba(167, 139, 250, 0.15); color: var(--accent-purple); }
.icon-tile--blue { background: rgba(96, 165, 250, 0.15); color: var(--accent-blue); }
.icon-tile--pink { background: rgba(244, 114, 182, 0.15); color: var(--accent-pink); }

.dash-domain-card {
    display: block;
    padding: 1rem 1.125rem;
    color: inherit;
    transition: border-color var(--transition-fast), background var(--transition-fast), transform var(--duration-press) var(--ease-out);
}

.dash-domain-card:hover {
    border-color: rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.02);
}

.dash-domain-card:active {
    transform: scale(0.98);
}

.dash-domain-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.625rem;
}

.dash-domain-name {
    font-size: 0.875rem;
    font-weight: 600;
}

.dash-domain-delta {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.dash-domain-card .progress-track {
    margin-bottom: 0.5rem;
}

.dash-focus {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
}

.dash-focus-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.875rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    color: inherit;
    transition: border-color var(--transition-fast), background var(--transition-fast), transform var(--duration-press) var(--ease-out);
}

.dash-focus-item:hover {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.02);
}

.dash-focus-item:active {
    transform: scale(0.99);
}

.dash-focus-item--done {
    opacity: 0.65;
}

.dash-focus-check {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    border: 1.5px solid var(--border);
    flex-shrink: 0;
}

.dash-focus-check--done {
    background: var(--accent-green);
    border-color: var(--accent-green);
}

.dash-focus-text {
    flex: 1;
    font-size: 0.875rem;
    font-weight: 500;
}

.activity-feed {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.activity-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.activity-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.activity-item:first-child {
    padding-top: 0;
}

.activity-text {
    margin: 0 0 0.2rem;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.4;
}

.activity-time {
    font-size: 0.6875rem;
    color: var(--text-dim);
}

.cal-schedule-item--active {
    border-color: rgba(167, 139, 250, 0.25);
    background: rgba(167, 139, 250, 0.06);
}

.cal-schedule-title {
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.4;
}

.priority-pill {
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.2rem 0.45rem;
    border-radius: 4px;
    flex-shrink: 0;
}

.priority-pill--high { background: rgba(244, 114, 182, 0.15); color: var(--accent-pink); }
.priority-pill--medium { background: rgba(250, 204, 21, 0.12); color: var(--accent-yellow); }
.priority-pill--low { background: rgba(255, 255, 255, 0.06); color: var(--text-dim); }

/* legacy dashboard aliases */
.dash-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); gap: 1rem; }
.dash-side-panel { display: flex; flex-direction: column; gap: 1rem; }

.radar-wrap {
    position: relative;
    width: 100%;
    height: min(320px, 42vw);
    min-height: 240px;
}

.radar-wrap canvas,
.radar-wrap svg {
    width: 100% !important;
    height: 100% !important;
}

/* ─── Finance ─── */

.finance-page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.finance-page-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.finance-charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.finance-stats-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.finance-stat-value {
    margin: 0.35rem 0 0;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.finance-month-change {
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    background: rgba(74, 222, 128, 0.1);
    border: 1px solid rgba(74, 222, 128, 0.2);
    color: var(--text-income);
}

.finance-net-worth {
    margin: 0.25rem 0 0;
    font-size: clamp(2rem, 4vw, 2.75rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-income);
    line-height: 1.1;
}

.finance-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: stretch;
}

.finance-hero {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.finance-hero-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.finance-hero-title {
    margin: 0 0 0.25rem;
    font-size: 1.125rem;
    font-weight: 700;
}

.finance-hero-stat {
    margin: auto 0 0.35rem;
    font-size: clamp(2rem, 4vw, 2.75rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.1;
}

.finance-hero-label { margin: 0; color: var(--text-muted); }

.finance-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    min-height: 100%;
}

.finance-stat-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1rem 1.125rem;
    min-height: 0;
}

.finance-stat-top {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.finance-stat-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.finance-stat-icon--income { background: rgba(74, 222, 128, 0.12); color: var(--text-income); }
.finance-stat-icon--expense { background: rgba(244, 114, 182, 0.12); color: var(--accent-pink); }
.finance-stat-icon--balance { background: rgba(167, 139, 250, 0.12); color: var(--accent-purple); }
.finance-stat-icon--card { background: rgba(251, 146, 60, 0.12); color: var(--accent-orange); }

.finance-stat-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
}

.finance-stat-value {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    line-height: 1.2;
    word-break: break-word;
}

.finance-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 1.25rem;
}

.finance-toolbar select {
    padding: 0.45rem 0.75rem;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    font-size: 0.8125rem;
    background: var(--bg-elevated);
    color: var(--text);
}

.currency-badge {
    background: rgba(250, 204, 21, 0.15);
    color: var(--accent-yellow);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
}

.month-card { cursor: pointer; }
.month-card:hover { border-color: rgba(167, 139, 250, 0.25); }
.account-card-click { cursor: pointer; }

/* ─── Calendar ─── */

.cal-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
    align-items: start;
    margin-bottom: 1.5rem;
}

.cal-week-row--today td { background: rgba(167, 139, 250, 0.06); }

.cal-week-chip {
    display: inline-flex;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-purple);
    text-decoration: none;
    margin: 0 0.5rem 0.25rem 0;
}

.cal-week-chip:hover { text-decoration: underline; }

.cal-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.cal-nav { display: flex; gap: 0.5rem; }

.cal-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.cal-weekdays span {
    text-align: center;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.5rem 0;
}

.cal-week {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.cal-day {
    aspect-ratio: 1;
    min-height: 72px;
    min-width: 0;
    padding: 0.375rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.02);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow: hidden;
    color: inherit;
    text-decoration: none;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.cal-day:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border);
}

.cal-day--today {
    border-color: rgba(167, 139, 250, 0.35);
    background: rgba(167, 139, 250, 0.06);
}

.cal-day--selected {
    border-color: var(--accent-purple);
}

.cal-day--muted { opacity: 0.35; }

.cal-day-num {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.cal-day--today .cal-day-num { color: var(--accent-purple); }

.cal-day-dots {
    display: flex;
    gap: 0.25rem;
    margin-top: auto;
}

.cal-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cal-dot--workout { background: var(--accent-green); }
.cal-dot--note { background: var(--accent-purple); }

.cal-event-pill {
    font-size: 0.5625rem;
    font-weight: 600;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    background: rgba(167, 139, 250, 0.15);
    color: var(--accent-purple);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cal-event-pill.green { background: rgba(74, 222, 128, 0.12); color: var(--accent-green); }
.cal-event-pill.blue { background: rgba(96, 165, 250, 0.12); color: var(--accent-blue); }
.cal-event-pill.pink { background: rgba(244, 114, 182, 0.12); color: var(--accent-pink); }
.cal-event-pill.orange { background: rgba(251, 146, 60, 0.12); color: var(--accent-orange); }

.cal-schedule {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.cal-schedule-item {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.cal-schedule-item:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.1);
}

.cal-side-section { margin-top: 1.25rem; }
.cal-side-section:first-of-type { margin-top: 0; }

.cal-side-heading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
    margin: 0 0 0.625rem;
}

.cal-side-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    margin-bottom: 0.375rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    color: inherit;
    text-decoration: none;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.cal-side-item:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.1);
}

.cal-side-item .cal-schedule-title {
    font-size: 0.875rem;
    font-weight: 500;
}

.cal-schedule-time {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-dim);
    min-width: 48px;
}

/* ─── Journal / Notes ─── */

.journal-layout {
    display: grid;
    grid-template-columns: 260px 1fr 300px;
    gap: 1rem;
    min-height: calc(100vh - 180px);
}

.journal-entry-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow-y: auto;
    padding-right: 0.25rem;
}

.journal-entry {
    padding: 0.75rem 0.875rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.journal-entry:hover {
    background: rgba(255, 255, 255, 0.04);
}

.journal-entry.active {
    background: rgba(167, 139, 250, 0.08);
    border-color: rgba(167, 139, 250, 0.2);
}

.journal-entry-title {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0 0 0.25rem;
    color: var(--text);
}

.journal-entry-meta {
    font-size: 0.6875rem;
    color: var(--text-dim);
}

.journal-detail {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    overflow-y: auto;
}

.journal-detail-title {
    margin: 0 0 0.5rem;
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.journal-detail-body {
    font-size: 0.9375rem;
    line-height: 1.7;
    color: var(--text-muted);
}

.note-card {
    display: block;
    color: var(--text);
    height: 100%;
}

.note-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.note-card-title { margin: 0; font-size: 0.9375rem; font-weight: 600; }
.note-card-body { margin: 0 0 0.75rem; font-size: 0.8125rem; color: var(--text-muted); line-height: 1.5; }
.note-card-meta { font-size: 0.75rem; color: var(--text-dim); }
.note-detail-body { font-size: 0.9375rem; line-height: 1.7; color: var(--text-muted); }

.note-list-compact {
    list-style: none;
    margin: 0;
    padding: 0;
}

.note-list-compact li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--border);
}

.note-list-compact li:last-child { border-bottom: none; }

.note-list-title {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text);
    transition: color var(--transition-fast);
}

.note-list-title:hover { color: var(--accent-purple); }

/* ─── Fitness rings ─── */

.fitness-rings {
    position: relative;
    width: 160px;
    height: 160px;
    margin: 0 auto;
}

.fitness-ring {
    fill: none;
    stroke-linecap: round;
    transform-origin: center;
    transform: rotate(-90deg);
}

.fitness-ring-bg {
    stroke: var(--chart-grid);
}

.fitness-ring-move { stroke: var(--accent-pink); }
.fitness-ring-exercise { stroke: var(--accent-green); }
.fitness-ring-stand { stroke: var(--accent-teal); }

.fitness-rings-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.fitness-rings-value {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.fitness-rings-label {
    font-size: 0.6875rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.fitness-rings-legend {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

.fitness-legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.fitness-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.fitness-hero {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2rem;
    align-items: center;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.fitness-rings-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.fitness-hero-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.fitness-metric-card {
    padding: 1rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
}

.fitness-metric-label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    margin-bottom: 0.35rem;
}

.fitness-metric-value {
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* ─── Gym / workouts ─── */

.workout-item { padding: 0.875rem 0; border-bottom: 1px solid var(--border); }
.workout-item:last-child { border-bottom: none; }
.workout-item-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.workout-title { font-weight: 600; font-size: 0.875rem; transition: color var(--transition-fast); }
.workout-title:hover { color: var(--accent-purple); }
.exercise-tags { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.tag {
    padding: 0.15rem 0.5rem;
    font-size: 0.6875rem;
    background: rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-pill);
    color: var(--text-muted);
}

/* ─── Bento grid (legacy) ─── */

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

.bento-3 { grid-column: span 3; }
.bento-4 { grid-column: span 4; }
.bento-5 { grid-column: span 5; }
.bento-6 { grid-column: span 6; }
.bento-8 { grid-column: span 8; }
.bento-12 { grid-column: span 12; }

.bento-stack {
    grid-column: span 3;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ─── Charts & viz (legacy) ─── */

.bubble-viz {
    position: relative;
    height: 140px;
    margin: 1rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bubble {
    position: absolute;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 600;
    color: #fff;
}

.bubble-purple { width: 100px; height: 100px; background: var(--accent-purple); left: 15%; opacity: 0.85; }
.bubble-dark { width: 72px; height: 72px; background: var(--bg-elevated); left: 42%; z-index: 1; border: 1px solid var(--border); }
.bubble-lime { width: 56px; height: 56px; background: var(--accent-yellow); color: #09090b; right: 20%; z-index: 2; }
.bubble span { font-size: 0.625rem; opacity: 0.85; }

.dot-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 5px;
    margin-top: 1rem;
}

.dot {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
}

.dot-1 { background: rgba(167, 139, 250, 0.15); }
.dot-2 { background: rgba(167, 139, 250, 0.3); }
.dot-3 { background: var(--accent-purple); }
.dot-4 { background: #7c3aed; }

.bar-chart-monthly {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.5rem;
    height: 120px;
    margin-top: 1.25rem;
    padding-top: 0.5rem;
}

.bar-month {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    height: 100%;
    justify-content: flex-end;
}

.bar-col {
    width: 100%;
    max-width: 28px;
    border-radius: 6px 6px 0 0;
    background: rgba(255, 255, 255, 0.06);
    min-height: 20px;
}

.bar-col-active { display: flex; flex-direction: column; gap: 2px; background: none; min-height: auto; }
.bar-col-active .bar-seg-lime { height: 40px; background: var(--accent-yellow); border-radius: 4px 4px 0 0; }
.bar-col-active .bar-seg-purple { height: 55px; background: var(--accent-purple); border-radius: 4px 4px 0 0; }

.bar-month span {
    font-size: 0.625rem;
    color: var(--text-dim);
}

.bar-month-active span { color: var(--text); font-weight: 600; }

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.8125rem;
}

.list-item:last-child { border-bottom: none; }

.mt-sm { margin-top: 0.5rem; }

/* ─── Responsive ─── */

@media (min-width: 900px) {
    .dashboard-grid { grid-template-columns: repeat(6, 1fr); }
    .dashboard-finance { grid-column: span 2; grid-row: 1; }
    .dashboard-stats { grid-column: span 2; grid-row: 1; }
    .dashboard-actions { grid-column: span 2; grid-row: 1; }
    .dashboard-detail { grid-column: span 3; grid-row: 2; }
}

@media (max-width: 1100px) {
    .bento-3, .bento-4, .bento-5, .bento-6, .bento-8, .bento-stack { grid-column: span 12; }
    .dash-grid,
    .dash-layout { grid-template-columns: 1fr; }
    .dash-domains { grid-template-columns: 1fr; }
    .journal-layout { grid-template-columns: 220px 1fr; }
    .journal-layout > :last-child { grid-column: 1 / -1; }
    .cal-layout { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 32px rgba(0, 0, 0, 0.5);
    }

    .main-wrapper { margin-left: 0; }
    .layout.sidebar-collapsed .main-wrapper { margin-left: 0; }

    .menu-toggle { display: flex; }

    .main-header {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
    }

    .header-profile { order: 2; }
    .header-search { order: 3; flex: 1 1 100%; max-width: none; margin: 0; }
    .header-bell { order: 1; margin-left: auto; }

    .main-content { padding: 0 1rem calc(5.5rem + env(safe-area-inset-bottom, 0px)); }
    .page-head { flex-direction: column; align-items: flex-start; }

    .mobile-tabbar {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 150;
        justify-content: space-around;
        align-items: flex-start;
        padding: 0.5rem 0.25rem calc(0.5rem + env(safe-area-inset-bottom, 0px));
        background: color-mix(in srgb, var(--bg-sidebar) 82%, transparent);
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        border-top: 1px solid var(--border);
    }

    .dashboard-grid { grid-template-columns: 1fr; }
    .dashboard-finance,
    .dashboard-stats,
    .dashboard-actions,
    .dashboard-detail { grid-column: 1; }
    .dashboard-stats { grid-row: auto; }

    .dash-grid,
    .dash-layout { grid-template-columns: 1fr; }
    .dash-metrics { grid-template-columns: repeat(2, 1fr); }

    .finance-summary,
    .finance-charts-grid { grid-template-columns: 1fr; }
    .finance-stats-row { grid-template-columns: repeat(2, 1fr); }

    .fitness-hero { grid-template-columns: 1fr; text-align: center; }
    .fitness-hero-metrics { grid-template-columns: 1fr; }

    .journal-layout { grid-template-columns: 1fr; min-height: auto; }

    .cal-grid { gap: 2px; }
    .cal-day { min-height: 48px; }

    .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .header-user,
    .header-chevron { display: none; }

    .btn-group { flex-direction: column; }
    .btn-group .btn { width: 100%; }

    .finance-stats-grid { grid-template-columns: 1fr; grid-template-rows: auto; }
    .dash-metrics { grid-template-columns: 1fr; }
    .action-grid { grid-template-columns: 1fr; }
}

/* ─── Light theme component tweaks ─── */

[data-theme="light"] .nav-link:hover {
    background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .nav-link.active {
    background: var(--sidebar-active-bg);
}

[data-theme="light"] .header-search {
    background: var(--bg-card);
}

[data-theme="light"] .header-search input {
    color: var(--text);
}

[data-theme="light"] .header-profile:hover,
[data-theme="light"] .theme-toggle:hover,
[data-theme="light"] .header-theme:hover,
[data-theme="light"] .header-bell:hover,
[data-theme="light"] .sidebar-collapse:hover,
[data-theme="light"] .nav-collapse-btn:hover {
    background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .nav-logout-btn:hover {
    background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .sidebar {
    box-shadow: 1px 0 0 var(--border);
}

[data-theme="light"] .card {
    box-shadow: var(--shadow-sm);
}

[data-theme="light"] .btn-primary {
    color: #ffffff;
}

[data-theme="light"] .btn-primary:hover {
    background: #7c3aed;
    color: #ffffff;
}

[data-theme="light"] .dash-domain-card:hover,
[data-theme="light"] .dash-focus-item:hover,
[data-theme="light"] .cal-schedule-item:hover,
[data-theme="light"] .journal-entry:hover {
    background: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .progress-track,
[data-theme="light"] .notes-progress-track {
    background: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .finance-month-change {
    background: rgba(22, 163, 74, 0.1);
    border-color: rgba(22, 163, 74, 0.22);
}

[data-theme="light"] .badge-income {
    background: rgba(22, 163, 74, 0.1);
}

[data-theme="light"] .badge-expense {
    background: rgba(190, 24, 93, 0.1);
}

[data-theme="light"] .alert-success {
    color: var(--text-income);
}

/* ─── Accessibility: motion, transparency, contrast ─── */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .card:hover,
    .btn:active,
    .nav-link:active,
    .dash-domain-card:active,
    .dash-focus-item:active,
    .theme-toggle:active {
        transform: none !important;
    }
}

@media (prefers-reduced-transparency: reduce) {
    .sidebar,
    .main-header {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background: var(--bg-sidebar) !important;
    }
}

@media (prefers-contrast: more) {
    :root {
        --border: rgba(255, 255, 255, 0.35);
    }
    [data-theme="light"] {
        --border: rgba(0, 0, 0, 0.35);
    }
    .card,
    .sidebar,
    .main-header {
        border-width: 1.5px;
    }
}
