/* ================================================================
   THEME.CSS - Global Design Tokens & Base Styles
   Version: 4.0 (Final - Full Coverage)
   ================================================================ */

/* ================================================================
   0. RESPONSIVE BASE SCALE
   ================================================================
   Everything in this file (and most pages) sizes off `rem`, which is
   relative to the root (<html>) font-size. Scaling THAT down slightly on
   narrower screens shrinks text, padding, icons - anything in rem - 
   together, in one place, rather than hunting down individual px values
   across every page. ~15% reduction at phone width, smaller steps at
   tablet/laptop width, unchanged on large desktops. This is a baseline
   improvement; a handful of components with hard-coded px will still
   benefit from individual attention over time. */
/* ONE KNOB: --ui-scale. 1 = previous size, 0.85 = 15% smaller (current).
   All spacing/sizing is rem-based, so changing it rescales the whole app. */
:root {
    --ui-scale: 0.85;
    --fs-min: 11px;     /* readable floor for small text */
    --tap-min: 40px;    /* minimum touch target on coarse pointers */
}
html { font-size: 15px; }                                         /* large desktops */
@media (max-width: 1399.98px) and (min-width: 992px) {
    html { font-size: 14.5px; }                                   /* laptops */
}
@media (max-width: 991.98px) and (min-width: 576px) {
    html { font-size: 15px; }                                     /* tablets */
}
@media (max-width: 575.98px) {
    html { font-size: 15.5px; }                                   /* phones: body text ~13.5px */
}
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* ================================================================
   1.  CSS VARIABLES - DARK THEME (Default)
   ================================================================ */
:root {
    /* ----- Brand Constants (NEVER change with theme - same in light & dark) ----- */
    --brand-navy: #0B2E33;
    --brand-navy-2: #0E3B43;
    --brand-cream: #F8F4EE;
    --brand-ochre: #14917F;

    /* ----- Backgrounds ----- */
    --bg-primary: #0A2226;
    --bg-secondary: #0E2C31;
    --bg-card: rgba(248, 244, 238, 0.04);
    --bg-card-hover: rgba(248, 244, 238, 0.08);

    /* ----- Borders & Shadows ----- */
    --border-glass: rgba(248, 244, 238, 0.08);
    --shadow-card: 0 20px 60px -12px rgba(0, 0, 0, 0.8);

    /* ----- Text Colors ----- */
    --text-primary: #F5F2EC;
    --text-secondary: #B7C4C4;
    --text-muted: #7E9294;

    /* ----- Accent Colors (Melhik: Ember Ochre + Deep Anchor Teal) ----- */
    --accent-1: #14917F;
    --accent-2: #2C6E76;
    --accent-3: #D4A72C;
    --accent-4: #2E7D46;
    --accent-5: #C0442C;

    /* ----- Glow & Radius ----- */
    --glow-1: rgba(20, 145, 127, 0.25);
    --radius-lg: 1.5rem;
    --radius-md: 1rem;
    --radius-sm: 0.75rem;

    /* ----- Transitions ----- */
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

    /* ----- Sidebar (Dark) ----- */
    --sidebar-bg: rgba(11, 46, 51, 0.88);
    --sidebar-border: rgba(248, 244, 238, 0.08);
    --sidebar-hover: rgba(20, 145, 127, 0.10);
    --sidebar-active-bg: rgba(20, 145, 127, 0.20);
    --sidebar-active-border: rgba(20, 145, 127, 0.40);
    --sidebar-icon-color: #B7C4C4;
    --sidebar-text-color: #B7C4C4;
    --sidebar-gradient: linear-gradient(145deg, rgba(20, 145, 127, 0.06) 0%, rgba(44, 110, 118, 0.05) 100%);

    /* ----- Toggle ----- */
    --toggle-bg: rgba(248, 244, 238, 0.10);
    --toggle-dot: #F5F2EC;
}

/* ================================================================
   2.  CSS VARIABLES - LIGHT THEME
   ================================================================ */
.light-theme {
    /* ----- Backgrounds ----- */
    --bg-primary: #F5F5F3;
    --bg-secondary: #ECECE8;
    --bg-card: rgba(255, 255, 255, 0.78);
    --bg-card-hover: rgba(255, 255, 255, 0.92);

    /* ----- Borders & Shadows ----- */
    --border-glass: rgba(11, 46, 51, 0.08);
    --shadow-card: 0 20px 60px -12px rgba(11, 46, 51, 0.12);

    /* ----- Text Colors ----- */
    --text-primary: #14181B;
    --text-secondary: #3D5254;
    --text-muted: #6f7f81;

    /* ----- Accent Colors (Melhik: Ember Ochre + Deep Anchor Teal) ----- */
    --accent-1: #14917F;
    --accent-2: #0B2E33;
    --accent-3: #C4791F;
    --accent-4: #2E7D46;
    --accent-5: #C0442C;

    /* ----- Glow ----- */
    --glow-1: rgba(20, 145, 127, 0.18);

    /* ----- Sidebar (Light) ----- */
    --sidebar-bg: rgba(255, 255, 255, 0.82);
    --sidebar-border: rgba(11, 46, 51, 0.08);
    --sidebar-hover: rgba(11, 46, 51, 0.06);
    --sidebar-active-bg: rgba(20, 145, 127, 0.14);
    --sidebar-active-border: rgba(20, 145, 127, 0.35);
    --sidebar-icon-color: #3D5254;
    --sidebar-text-color: #3D5254;
    --sidebar-gradient: linear-gradient(145deg, rgba(20, 145, 127, 0.05) 0%, rgba(11, 46, 51, 0.03) 100%);

    /* ----- Toggle ----- */
    --toggle-bg: rgba(11, 46, 51, 0.08);
    --toggle-dot: #ffffff;
}

/* ================================================================
   3.  BASE & RESET
   ================================================================ */

/* ====== LOGO: light/dark-aware pair ======
   Two <img> tags with class="logo-img-light" / "logo-img-dark" - only the
   one matching the active theme is shown, so the Melhik mark (or a custom
   uploaded logo) always stays visible when the theme is switched. */
/* ================================================================
   LOGO THEME SWAP (2026-09) - !important is deliberate here: this is
   the one property (display) that must never lose to a more specific
   context selector like ".sidebar .brand .logo-img" or
   ".offcanvas .brand .logo-img", which is exactly what was happening
   - those 3-class selectors out-specificity a plain ".logo-img-dark"
   and silently won, showing both logos stacked in the sidebar
   regardless of theme. Sizing/filter/spacing for the logo still come
   from those context selectors as normal; only show/hide is pinned.
   ================================================================ */
.logo-img-light { display: inline-block !important; }
.logo-img-dark { display: none !important; }
.dark-theme .logo-img-light { display: none !important; }
.dark-theme .logo-img-dark { display: inline-block !important; }

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

html,
body {
    overflow-x: hidden;
    max-width: 100%;
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    background-image:
        radial-gradient(ellipse at 10% 20%, rgba(20, 145, 127, 0.07) 0%, transparent 60%),
        radial-gradient(ellipse at 90% 80%, rgba(44, 110, 118, 0.06) 0%, transparent 60%);
    transition: background 0.4s ease, color 0.3s ease;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.light-theme body {
    background-image:
        radial-gradient(ellipse at 10% 20%, rgba(20, 145, 127, 0.05) 0%, transparent 60%),
        radial-gradient(ellipse at 90% 80%, rgba(11, 46, 51, 0.03) 0%, transparent 60%);
}

h1, h2, h3, h4, h5, h6,
.brand-logo-text, .logo-text, .page-title, .section-title {
    font-family: 'Space Grotesk', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ----- Scrollbar ----- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}
::-webkit-scrollbar-thumb {
    background: var(--accent-1);
    border-radius: 0.75rem;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-2);
}

/* ================================================================
   4.  APP LAYOUT (Sidebar + Main Content)
   ================================================================ */
.app-wrapper {
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    width: 100%;
}

/* ================================================================
   5.  SIDEBAR (Desktop)
   ================================================================ */
.sidebar {
    flex: 0 0 16.25rem;
    width: 16.25rem;
    height: 100vh;
    height: 100dvh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    padding: 1.75rem 1.125rem 2rem;
    background: var(--sidebar-bg);
    backdrop-filter: blur(28px) saturate(1.6);
    -webkit-backdrop-filter: blur(28px) saturate(1.6);
    border-right: 1px solid var(--sidebar-border);
    box-shadow: 4px 0 40px rgba(0, 0, 0, 0.15);
    transition: background 0.4s ease, border-color 0.3s ease, box-shadow 0.4s ease;
    display: flex;
    flex-direction: column;
    z-index: 10;
    scrollbar-width: thin;
}

.light-theme .sidebar {
    background: var(--sidebar-bg);
    backdrop-filter: blur(28px) saturate(1.6);
    box-shadow: 4px 0 40px rgba(0, 0, 0, 0.05);
}

/* Subtle gradient overlay for extra depth */
.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--sidebar-gradient);
    pointer-events: none;
    z-index: 0;
}

.sidebar .brand,
.sidebar .nav {
    position: relative;
    z-index: 1;
}

/* ----- Brand / Logo ----- */
.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--sidebar-border);
    text-decoration: none;
}

.sidebar .brand .logo-img {
    flex-shrink: 0;
    height: 2.375rem;
    width: auto;
    filter: drop-shadow(0 4px 16px var(--glow-1));
    transition: filter 0.3s ease, transform 0.3s ease;
}

.sidebar .brand:hover .logo-img {
    filter: drop-shadow(0 6px 28px var(--glow-1));
}

.sidebar .brand .brand-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.25;
    /* FIX: without min-width:0, a flex child can't shrink below its
       content's natural width, so long text wraps instead of
       truncating - this was the actual cause of the tagline
       breaking onto an awkward second line. flex:1 lets it fill
       the remaining row width predictably. */
    min-width: 0;
    flex: 1;
}

.sidebar .brand .brand-text .main {
    font-weight: 800;
    font-size: 1.3rem;
    background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar .brand .brand-text .sub {
    font-size: max(0.65rem, var(--fs-min, 11px));
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: 0.3px;
    -webkit-text-fill-color: var(--text-muted);
    margin-top: 2px;
    /* FIX: forces a single line with a graceful "…" instead of
       wrapping into a cramped second line. */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ----- Navigation ----- */
.sidebar .nav {
    flex: 1;
    gap: 0.25rem;
}

.sidebar .nav-link {
    color: var(--sidebar-text-color);
    border-radius: 0.75rem;
    padding: 0.75rem 1.125rem;
    font-weight: 500;
    font-size: max(0.9rem, var(--fs-min, 11px));
    display: flex;
    align-items: center;
    gap: 0.875rem;
    transition: color .15s ease, background-color .15s ease, border-color .15s ease, box-shadow .15s ease, opacity .15s ease;
    text-decoration: none;
    cursor: pointer;
    position: relative;
    border: 1px solid transparent;
    background: transparent;
    margin: 0 2px;
    min-height: 3rem;
}

.sidebar .nav-link i {
    font-size: 1.3rem;
    width: 1.75rem;
    text-align: center;
    color: var(--sidebar-icon-color);
    transition: color 0.25s ease, transform 0.25s ease;
}

.sidebar .nav-link:hover {
    background: var(--sidebar-hover);
    color: var(--text-primary);
    border-color: var(--sidebar-border);
}

.sidebar .nav-link:hover i {
    color: var(--accent-1);
}

.sidebar .nav-link.active {
    background: var(--sidebar-active-bg);
    color: var(--accent-1);
    border-color: var(--sidebar-active-border);
    box-shadow: 0 0 28px rgba(20, 145, 127, 0.20);
}

.sidebar .nav-link.active i {
    color: var(--accent-1);
    transform: scale(1.1);
}

.sidebar .nav-link.active::before {
    content: '';
    position: absolute;
    left: -2px;
    top: 20%;
    height: 60%;
    width: 0.25rem;
    background: var(--accent-1);
    border-radius: 0 0.25rem 0.25rem 0;
    box-shadow: 0 0 20px var(--glow-1);
}

.sidebar .nav-link .badge {
    margin-left: auto;
    font-size: max(0.6rem, var(--fs-min, 11px));
    padding: 2px 0.75rem;
    border-radius: 2.5rem;
    background: var(--accent-1);
    color: #fff;
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* ----- Sidebar Scrollbar ----- */
.sidebar::-webkit-scrollbar {
    width: 4px;
}
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
    background: var(--accent-1);
    border-radius: 0.625rem;
}
.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--accent-2);
}

/* ----- Sidebar Footer (Upgrade / Admin) ----- */
.sidebar-footer {
    margin-top: auto;
    padding-top: 1.25rem;
    border-top: 1px solid var(--sidebar-border);
    position: relative;
    z-index: 1;
}

/* ====== QUOTA NUDGE (usage-near-limit widget) ====== */
.quota-nudge {
    display: block;
    padding: 0.625rem 0.875rem;
    margin-bottom: 0.625rem;
    border-radius: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    text-decoration: none;
    transition: color .15s ease, background-color .15s ease, border-color .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.quota-nudge:hover {
    background: var(--bg-card-hover);
}
.quota-nudge-head {
    display: flex;
    justify-content: space-between;
    font-size: max(0.72rem, var(--fs-min, 11px));
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}
.quota-nudge-bar {
    height: 0.3125rem;
    border-radius: 0.1875rem;
    background: color-mix(in srgb, var(--text-primary) 10%, transparent);
    overflow: hidden;
}
.quota-nudge-fill {
    height: 100%;
    border-radius: 0.1875rem;
    transition: width 0.4s ease;
}
.sidebar.collapsed .quota-nudge {
    padding: 0.5rem;
    text-align: center;
}
.sidebar.collapsed .quota-nudge-head span:first-child {
    display: none;
}
.sidebar.collapsed .quota-nudge-head {
    justify-content: center;
    font-size: max(0.65rem, var(--fs-min, 11px));
}

.upgrade-btn {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    background: linear-gradient(135deg, rgba(20, 145, 127, 0.15), rgba(44, 110, 118, 0.08));
    border: 1px solid var(--sidebar-active-border);
    color: var(--accent-1);
    text-decoration: none;
    font-weight: 600;
    font-size: max(0.85rem, var(--fs-min, 11px));
    transition: color .15s ease, background-color .15s ease, border-color .15s ease, box-shadow .15s ease, opacity .15s ease;
    min-height: 3rem;
}

.upgrade-btn:hover {
    background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
    color: #fff;
    box-shadow: 0 8px 30px var(--glow-1);
    border-color: transparent;
}

.upgrade-btn .arrow-icon {
    margin-left: auto;
    font-size: max(0.8rem, var(--fs-min, 11px));
}

.upgrade-btn .pro-badge {
    background: var(--accent-5);
    color: #fff;
    font-size: max(0.55rem, var(--fs-min, 11px));
    padding: 1px 0.5rem;
    border-radius: 2.5rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.admin-mode {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    background: rgba(20, 145, 127, 0.08);
    border: 1px solid var(--sidebar-border);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: max(0.85rem, var(--fs-min, 11px));
    min-height: 3rem;
}

.admin-mode i {
    color: var(--accent-1);
    font-size: 1.2rem;
}

/* ================================================================
   6.  MAIN CONTENT
   ================================================================ */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.75rem 2rem 3rem;
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
}

/* ================================================================
   7.  TOP BAR
   ================================================================ */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
    gap: 0.625rem;
}

.top-bar .user-avatar {
    display: flex;
    align-items: center;
    gap: 1.125rem;
    flex-wrap: wrap;
}

/* ----- Avatar Circle ----- */
.top-bar .user-avatar .avatar-circle {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid var(--border-glass);
    transition: var(--transition);
    box-shadow: 0 4px 16px rgba(20, 145, 127, 0.25);
    flex-shrink: 0;
}

.top-bar .user-avatar .avatar-circle:hover {
    border-color: var(--accent-1);
}

.top-bar .user-avatar .avatar-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ----- Plan Badge ----- */
.plan-badge {
    font-size: max(0.65rem, var(--fs-min, 11px));
    font-weight: 600;
    padding: 2px 0.875rem;
    border-radius: 2.5rem;
    display: inline-block;
    white-space: nowrap;
}

/* ----- Sidebar Toggle (Mobile Hamburger) ----- */
.sidebar-toggle {
    display: none;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.875rem;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: var(--transition);
    z-index: 1050;
    min-height: 2.75rem;
    min-width: 2.75rem;
    justify-content: center;
    align-items: center;
}

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

/* ----- Desktop Sidebar Toggle (Chevron) ----- */
.sidebar-toggle-desktop {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    padding: 0 0.625rem;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
    min-height: 2.75rem;
    min-width: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle-desktop:hover {
    color: var(--text-primary);
}

.sidebar-toggle-desktop i {
    transition: transform 0.3s ease;
}

/* Show desktop toggle on screens wider than 992px */
@media (min-width: 992px) {
    .sidebar-toggle-desktop {
        display: inline-flex;
    }
}

/* ================================================================
   8.  THEME TOGGLE (in top bar)
   ================================================================ */
.theme-toggle-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    padding: 0.25rem 0.75rem 0.25rem 0.5rem;
    border-radius: 2.5rem;
    backdrop-filter: blur(8px);
    transition: background 0.3s, border-color 0.3s;
    min-height: 2.75rem;
}

.theme-toggle-wrapper:hover {
    background: var(--bg-card-hover);
}

.theme-toggle {
    position: relative;
    width: 2.75rem;
    height: 1.5rem;
    background: var(--toggle-bg);
    border-radius: 2.5rem;
    cursor: pointer;
    transition: background 0.3s;
    border: 1px solid var(--border-glass);
    flex-shrink: 0;
}

.theme-toggle .dot {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 1.125rem;
    height: 1.125rem;
    background: var(--toggle-dot);
    border-radius: 50%;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.3s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.theme-toggle .icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: max(0.7rem, var(--fs-min, 11px));
    color: var(--text-muted);
    transition: opacity 0.3s;
    pointer-events: none;
}

.theme-toggle .icon-sun {
    left: 0.25rem;
    opacity: 1;
}
.theme-toggle .icon-moon {
    right: 0.25rem;
    opacity: 0.3;
}

.dark-theme .theme-toggle .icon-sun {
    opacity: 0.3;
}
.dark-theme .theme-toggle .icon-moon {
    opacity: 1;
}
.dark-theme .theme-toggle .dot {
    transform: translateX(20px);
}

.theme-label {
    font-size: max(0.6rem, var(--fs-min, 11px));
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

/* ================================================================
   9.  NOTIFICATIONS (Dropdown)
   ================================================================ */
.notification-wrapper {
    position: relative;
    display: inline-block;
}

.notification-bell {
    padding: 0.375rem 0.625rem !important;
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: 2.5rem;
    color: var(--text-secondary);
    transition: var(--transition);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    min-height: 2.75rem;
}

.notification-bell:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.15);
}

.notification-bell .bell-icon {
    font-size: 1.2rem;
}

.notification-badge {
    position: absolute;
    top: -0.375rem;
    right: -0.375rem;
    background: var(--accent-5);
    color: #fff;
    border-radius: 50%;
    padding: 2px 0.375rem;
    font-size: max(0.6rem, var(--fs-min, 11px));
    font-weight: 700;
    min-width: 1.125rem;
    text-align: center;
    box-shadow: 0 0 12px rgba(192, 68, 44, 0.4);
    display: none;
    line-height: 1.4;
}

/* ----- Dropdown ----- */
.notification-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    min-width: 23.75rem;
    max-width: 26.25rem;
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-glass);
    border-radius: 0.75rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    max-height: 28.75rem;
    overflow: hidden;
}

.notification-dropdown .dropdown-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 1;
}

.notification-dropdown .dropdown-header span {
    font-weight: 600;
    color: var(--text-primary);
    font-size: max(0.9rem, var(--fs-min, 11px));
}

.notification-dropdown .dropdown-header .dropdown-actions {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
    align-items: center;
}

.notification-list {
    max-height: 20rem;
    overflow-y: auto;
    padding: 0.25rem 0;
}

.notification-list::-webkit-scrollbar {
    width: 4px;
}
.notification-list::-webkit-scrollbar-thumb {
    background: var(--accent-1);
    border-radius: 0.625rem;
}
.notification-list::-webkit-scrollbar-track {
    background: transparent;
}

/* ----- Notification Item ----- */
.notification-item {
    padding: 0.625rem 0.875rem;
    border-bottom: 1px solid var(--border-glass);
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    gap: 0.625rem;
    align-items: flex-start;
}

.notification-item:hover {
    background: var(--bg-card-hover);
}

.notification-item .notif-icon {
    font-size: 1.1rem;
    margin-top: 2px;
    flex-shrink: 0;
    color: var(--accent-1);
    width: 1.5rem;
    text-align: center;
}

.notification-item .notif-content {
    flex: 1;
    min-width: 0;
}

.notification-item .notif-content .notif-message {
    color: var(--text-primary);
    font-size: max(0.85rem, var(--fs-min, 11px));
    line-height: 1.4;
}

.notification-item .notif-content .notif-time {
    color: var(--text-muted);
    font-size: max(0.65rem, var(--fs-min, 11px));
    margin-top: 2px;
}

.notification-item .notif-content .notif-time a {
    color: var(--accent-2);
    text-decoration: none;
    font-weight: 500;
}

.notification-item .notif-content .notif-time a:hover {
    text-decoration: underline;
}

.notification-item .notif-unread {
    width: 0.375rem;
    height: 0.375rem;
    border-radius: 50%;
    background: var(--accent-1);
    flex-shrink: 0;
    margin-top: 0.25rem;
}

/* ----- Empty State ----- */
.empty-notifications {
    padding: 1.875rem 1.25rem;
    text-align: center;
    color: var(--text-muted);
    font-size: max(0.9rem, var(--fs-min, 11px));
}

.empty-notifications i {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 0.625rem;
    opacity: 0.4;
}

/* ----- Dropdown Footer ----- */
.notification-dropdown .dropdown-footer {
    padding: 0.625rem 0.875rem;
    border-top: 1px solid var(--border-glass);
    text-align: center;
    background: var(--bg-card);
}

/* ----- Batch Actions ----- */
#batchActions {
    display: none;
    padding: 0.375rem 0.75rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-glass);
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

/* ================================================================
   10. OFFCANVAS (Mobile Sidebar)
   ================================================================ */
.offcanvas {
    background: var(--sidebar-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-right: 1px solid var(--sidebar-border);
    max-width: 17.5rem;
    z-index: 1050;
}

.light-theme .offcanvas {
    background: rgba(255, 255, 255, 0.92);
}

.offcanvas .offcanvas-header {
    border-bottom: 1px solid var(--sidebar-border);
    padding: 1.25rem 1.125rem;
}

.offcanvas .offcanvas-body {
    padding: 1.25rem 1.125rem;
}

.offcanvas .nav-link {
    color: var(--sidebar-text-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    font-weight: 500;
    font-size: max(0.9rem, var(--fs-min, 11px));
    display: flex;
    align-items: center;
    gap: 0.875rem;
    text-decoration: none;
    transition: var(--transition);
    min-height: 3rem;
}

.offcanvas .nav-link i {
    font-size: 1.25rem;
    width: 1.75rem;
    text-align: center;
    color: var(--sidebar-icon-color);
}

.offcanvas .nav-link:hover {
    background: var(--sidebar-hover);
    color: var(--text-primary);
}

.offcanvas .nav-link.active {
    background: var(--sidebar-active-bg);
    color: var(--accent-1);
    border-color: var(--sidebar-active-border);
}

.offcanvas .brand .logo-img {
    height: 2.5rem;
    width: auto;
    flex-shrink: 0;
    filter: drop-shadow(0 4px 12px var(--glow-1));
    transition: filter 0.3s ease;
}

.offcanvas .brand:hover .logo-img {
    filter: drop-shadow(0 6px 20px var(--glow-1));
}

/* ================================================================
   11. RESPONSIVE - SIDEBAR HIDE ON MOBILE
   ================================================================ */
@media (max-width: 991.98px) {
    .sidebar {
        display: none;
    }

    .sidebar-toggle {
        display: inline-flex;
        position: fixed;
        top: 0.75rem;
        left: 0.75rem;
        z-index: 1060;
        background: var(--bg-card);
        backdrop-filter: blur(12px);
        border: 1px solid var(--border-glass);
        border-radius: 50%;
        width: 2.75rem;
        height: 2.75rem;
        align-items: center;
        justify-content: center;
        padding: 0;
        font-size: 1.4rem;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    }

    .sidebar-toggle:hover {
        background: var(--bg-card-hover);
    }

    .main-content {
        padding: 1rem;
        padding-top: 4.375rem;
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
    }

    .top-bar {
        flex-wrap: wrap;
        gap: 0.5rem;
        margin-bottom: 1rem;
    }

    .top-bar .user-avatar {
        margin-left: auto;
    }

    .notification-dropdown {
        min-width: 20rem;
        right: -0.625rem;
    }

    /* Hide desktop toggle on mobile */
    .sidebar-toggle-desktop {
        display: none !important;
    }
}

@media (max-width: 575.98px) {
    .main-content {
        padding: 0.75rem;
        padding-top: 3.75rem;
    }

    .notification-dropdown {
        min-width: 17.5rem;
        right: -1.25rem;
    }

    .sidebar-toggle {
        width: 2.375rem;
        height: 2.375rem;
        font-size: 1.2rem;
        top: 0.5rem;
        left: 0.5rem;
    }
}

/* ================================================================
   12. EXTRA SMALL (≤400px) - ZERO REWORK
   ================================================================ */
@media (max-width: 400px) {
    .main-content {
        padding: 0.5rem;
        padding-top: 3.5rem;
    }

    .sidebar-toggle {
        width: 2.125rem;
        height: 2.125rem;
        font-size: 1rem;
        top: 0.375rem;
        left: 0.375rem;
    }

    .top-bar .user-avatar .avatar-circle {
        width: 2.25rem;
        height: 2.25rem;
        font-size: max(0.9rem, var(--fs-min, 11px));
    }

    .theme-toggle-wrapper .theme-label {
        display: none;
    }

    .theme-toggle-wrapper {
        padding: 0.25rem 0.5rem;
    }

    .theme-toggle {
        width: 2.25rem;
        height: 1.25rem;
    }

    .theme-toggle .dot {
        width: 0.875rem;
        height: 0.875rem;
        top: 2px;
        left: 2px;
    }

    .dark-theme .theme-toggle .dot {
        transform: translateX(16px);
    }
}

/* ================================================================
   13. UTILITY CLASSES
   ================================================================ */
.text-primary {
    color: var(--text-primary) !important;
}
.text-secondary {
    color: var(--text-secondary) !important;
}
.text-muted {
    color: var(--text-muted) !important;
}
.text-accent-1 {
    color: var(--accent-1) !important;
}
.text-accent-2 {
    color: var(--accent-2) !important;
}
.text-accent-3 {
    color: var(--accent-3) !important;
}
.text-accent-4 {
    color: var(--accent-4) !important;
}
.text-accent-5 {
    color: var(--accent-5) !important;
}

.bg-card {
    background: var(--bg-card);
}
.bg-card-hover {
    background: var(--bg-card-hover);
}
.bg-accent-1-soft {
    background: rgba(20, 145, 127, 0.12);
}
.bg-accent-2-soft {
    background: rgba(44, 110, 118, 0.10);
}
.bg-accent-3-soft {
    background: rgba(212, 167, 44, 0.10);
}
.bg-accent-4-soft {
    background: rgba(46, 125, 70, 0.10);
}
.bg-accent-5-soft {
    background: rgba(192, 68, 44, 0.10);
}

/* ----- Glass Card ----- */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: var(--transition);
}

.glass-card:hover {
    background: var(--bg-card-hover);
    border-color: rgba(255, 255, 255, 0.10);
}

/* ----- Quick Add Button ----- */
.quick-add-btn {
    padding: 0.5rem 1.125rem;
    border-radius: 2.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: max(0.8rem, var(--fs-min, 11px));
    transition: var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    min-height: 2.75rem;
}

.quick-add-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.15);
}

/* ----- Locked / Plan-Gated Feature UI ----------------------------
   Reusable across every page: a button/tab that isn't included in
   the user's plan renders in this muted, dashed, "locked" state
   instead of just being hidden - so people can SEE what they'd get
   by upgrading (better conversion) instead of it silently vanishing.
   Uses the same theme variables as everything else, so it adapts to
   light/dark automatically - no separate dark-mode overrides needed.
------------------------------------------------------------------ */
.quick-add-btn--locked,
.feature-locked-btn {
    opacity: 0.65;
    cursor: pointer;
    border-style: dashed;
    background: var(--bg-card);
    color: var(--text-muted);
}
.quick-add-btn--locked:hover,
.feature-locked-btn:hover {
    opacity: 0.9;
    border-color: var(--accent-1);
    color: var(--accent-1);
}
.feature-locked-btn .bi-lock-fill { color: inherit; }

/* Full-panel/tab overlay variant: wrap the gated content in
   <div class="feature-locked-overlay"> ... </div> and it blurs/dims
   the content underneath while showing a centered "Upgrade to
   unlock" prompt on top. */
.feature-locked-overlay {
    position: relative;
    min-height: 8.75rem;
}
.feature-locked-overlay > *:not(.feature-locked-cta) {
    filter: blur(4px);
    pointer-events: none;
    user-select: none;
    opacity: 0.5;
}
.feature-locked-cta {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    text-align: center;
    padding: 1.25rem;
    z-index: 5;
    background: color-mix(in srgb, var(--bg-card) 55%, transparent);
    border-radius: inherit;
}
.feature-locked-cta .lock-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--accent-1) 15%, transparent);
    color: var(--accent-1);
    font-size: 1.3rem;
}
.feature-locked-cta a.btn-upgrade-link {
    text-decoration: none;
    background: var(--accent-1);
    color: #fff;
    padding: 0.5rem 1.125rem;
    border-radius: 1.875rem;
    font-weight: 600;
    font-size: max(0.85rem, var(--fs-min, 11px));
}

/* ----- Glass Form Elements ----- */
.form-glass {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 0.625rem 1rem;
    transition: var(--transition);
    min-height: 2.75rem;
    width: 100%;
}

.form-glass:focus {
    background: var(--bg-card-hover);
    border-color: var(--accent-1);
    box-shadow: 0 0 0 3px var(--glow-1);
    color: var(--text-primary);
    outline: none;
}

.form-glass::placeholder {
    color: var(--text-muted);
}

.form-select.form-glass {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%239aa1b9' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px 12px;
    appearance: none;
    -webkit-appearance: none;
}

/* ----- Button Variants ----- */
.btn-primary-glass {
    background: linear-gradient(135deg, var(--mk-accent, #0F766E), var(--mk-accent-ink, #115E59));
    border: none;
    color: #fff;
    border-radius: var(--radius-sm);
    padding: 0.625rem 1.75rem;
    font-weight: 600;
    transition: var(--transition);
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
}

.btn-primary-glass:hover {
    box-shadow: 0 8px 30px var(--glow-1);
    color: #fff;
}

.btn-primary-glass-sm {
    padding: 0.375rem 1rem;
    font-size: max(0.75rem, var(--fs-min, 11px));
    min-height: 2.25rem;
    border-radius: 1.875rem;
}

.btn-danger-glass {
    background: rgba(192, 68, 44, 0.15);
    border: 1px solid var(--accent-5);
    color: var(--accent-5);
    border-radius: var(--radius-sm);
    padding: 0.375rem 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
}

.btn-danger-glass:hover {
    background: var(--accent-5);
    color: #fff;
}

.btn-success-glass {
    background: rgba(46, 125, 70, 0.15);
    border: 1px solid var(--accent-4);
    color: var(--accent-4);
    border-radius: var(--radius-sm);
    padding: 0.375rem 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
}

.btn-success-glass:hover {
    background: var(--accent-4);
    color: #fff;
}

.btn-outline-glass {
    background: transparent;
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    border-radius: 2.5rem;
    padding: 0.5rem 1.25rem;
    font-weight: 500;
    font-size: max(0.8rem, var(--fs-min, 11px));
    transition: color .15s ease, background-color .15s ease, border-color .15s ease, box-shadow .15s ease, opacity .15s ease;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    text-decoration: none;
    min-height: 2.75rem;
}

.btn-outline-glass:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent-1);
    color: var(--text-primary);
}

/* ----- Stat Card ----- */
.stat-card {
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    transition: var(--transition);
}

.stat-card:hover {
    background: var(--bg-card-hover);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.stat-card .label {
    font-size: max(0.75rem, var(--fs-min, 11px));
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-top: 0.25rem;
}

.stat-card .icon-wrap {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

/* ----- Badge Variants ----- */
.badge-soft {
    font-weight: 500;
    padding: 0.25rem 0.875rem;
    border-radius: 2.5rem;
    font-size: max(0.7rem, var(--fs-min, 11px));
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    transition: color .15s ease, background-color .15s ease, border-color .15s ease, box-shadow .15s ease, opacity .15s ease;
}

.badge-soft-accent-1 {
    background: rgba(20, 145, 127, 0.12);
    color: #14917F;
}
.badge-soft-accent-2 {
    background: rgba(44, 110, 118, 0.12);
    color: #2C6E76;
}
.badge-soft-accent-3 {
    background: rgba(212, 167, 44, 0.12);
    color: #D4A72C;
}
.badge-soft-accent-4 {
    background: rgba(46, 125, 70, 0.12);
    color: #2E7D46;
}
.badge-soft-accent-5 {
    background: rgba(192, 68, 44, 0.12);
    color: #C0442C;
}

/* ----- Task / Schedule Items ----- */
.task-item,
.schedule-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    transition: var(--transition);
    flex-wrap: wrap;
}

.task-item:hover,
.schedule-item:hover {
    background: var(--bg-card-hover);
}

.task-item .task-label {
    flex: 1;
    font-weight: 500;
    cursor: pointer;
}

.task-item .task-label.done {
    text-decoration: line-through;
    color: var(--text-muted);
}

.task-priority {
    font-size: max(0.65rem, var(--fs-min, 11px));
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 2px 0.625rem;
    border-radius: 2.5rem;
    font-weight: 600;
    white-space: nowrap;
}

.priority-high {
    background: rgba(192, 68, 44, 0.20);
    color: #C0442C;
}
.priority-medium {
    background: rgba(212, 167, 44, 0.18);
    color: #D4A72C;
}
.priority-low {
    background: rgba(46, 125, 70, 0.16);
    color: #2E7D46;
}

.schedule-item .time {
    font-weight: 600;
    font-size: max(0.85rem, var(--fs-min, 11px));
    color: var(--text-secondary);
    min-width: 4.375rem;
}

.schedule-item .title {
    flex: 1;
    font-weight: 500;
}

.schedule-item .category {
    font-size: max(0.7rem, var(--fs-min, 11px));
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 2px 0.75rem;
    border-radius: 2.5rem;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
}

/* ----- Finance Items ----- */
.finance-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--border-glass);
}

.finance-item:last-child {
    border-bottom: 0;
}

.finance-item .amount {
    font-weight: 700;
}

.amount-positive {
    color: var(--accent-4);
}
.amount-negative {
    color: var(--accent-5);
}

/* ----- Profile Picture Upload ----- */
.profile-pic-upload {
    width: 7.5rem;
    height: 7.5rem;
    border-radius: 50%;
    overflow: hidden;
    margin: 0 auto 0.9375rem;
    cursor: pointer;
    border: 3px solid var(--accent-1);
    position: relative;
    box-shadow: 0 8px 30px rgba(20, 145, 127, 0.25);
}

.profile-pic-upload img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-pic-upload .overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    text-align: center;
    padding: 0.375rem;
    font-size: max(0.7rem, var(--fs-min, 11px));
    opacity: 0;
    transition: 0.3s;
}

.profile-pic-upload:hover .overlay {
    opacity: 1;
}

/* ----- Bulk Add Rows ----- */
.item-row {
    display: flex;
    gap: 0.625rem;
    align-items: center;
    flex-wrap: wrap;
}

.item-row .description-input {
    flex: 1;
    min-width: 7.5rem;
}
.item-row .amount-input {
    flex: 0.8;
    min-width: 5rem;
}
.item-row .category-select {
    flex: 0.8;
    min-width: 6.25rem;
}
.item-row .payment-select {
    flex: 0.8;
    min-width: 5.625rem;
}
.item-row .remove-btn {
    color: var(--accent-5);
    cursor: pointer;
    font-size: 1.2rem;
}
.item-row .remove-btn:hover {
    color: #ff6b6b;
}

.bulk-items-container {
    max-height: 18.75rem;
    overflow-y: auto;
}

/* ----- Day Group (Financial Grouping) ----- */
.day-group {
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    margin-bottom: 0.625rem;
    background: var(--bg-card);
    transition: var(--transition);
}

.day-group:hover {
    background: var(--bg-card-hover);
}

.day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 0.875rem;
    cursor: pointer;
}

.day-header .date {
    font-weight: 600;
}
.day-header .total {
    font-weight: 700;
}

.day-items {
    padding: 0 0.875rem 0.625rem 0.875rem;
    display: none;
}

.day-items.show {
    display: block;
}

.day-items .item {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    font-size: max(0.9rem, var(--fs-min, 11px));
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-glass);
}

.day-items .item:last-child {
    border-bottom: 0;
}

.day-items .item .item-amount {
    font-weight: 500;
}

.toggle-icon {
    transition: transform 0.3s;
}
.toggle-icon.open {
    transform: rotate(180deg);
}

/* ----- Strategy Grid ----- */
.strategy-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.strategy-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 1rem;
    transition: var(--transition);
}

.strategy-card:hover {
    background: var(--bg-card-hover);
}

.strategy-card .card-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.strategy-card ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.strategy-card ul li {
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.strategy-card ul li:last-child {
    border-bottom: 0;
}

/* ----- Finance Summary Cards ----- */
.finance-summary-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.finance-summary-cards .fscard {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 0.875rem 1rem;
    text-align: center;
    transition: var(--transition);
}

.finance-summary-cards .fscard:hover {
    background: var(--bg-card-hover);
}

.finance-summary-cards .fscard .fslabel {
    font-size: max(0.7rem, var(--fs-min, 11px));
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.finance-summary-cards .fscard .fsvalue {
    font-size: 1.3rem;
    font-weight: 700;
}

/* ----- Recent Activity ----- */
.recent-activity-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-glass);
}

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

.activity-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: max(0.9rem, var(--fs-min, 11px));
    flex-shrink: 0;
}

.activity-icon.task {
    background: rgba(20, 145, 127, 0.2);
    color: var(--accent-1);
}
.activity-icon.note {
    background: rgba(44, 110, 118, 0.2);
    color: var(--accent-2);
}
.activity-icon.transaction {
    background: rgba(46, 125, 70, 0.2);
    color: var(--accent-4);
}
.activity-icon.habit {
    background: rgba(212, 167, 44, 0.2);
    color: var(--accent-3);
}
.activity-icon.project {
    background: rgba(192, 68, 44, 0.2);
    color: var(--accent-5);
}

/* ----- Vault Items ----- */
.vault-item {
    border-left: 4px solid var(--accent-1);
    padding-left: 0.625rem;
}

.vault-item .vault-type {
    font-size: max(0.7rem, var(--fs-min, 11px));
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 0.5rem;
    border-radius: 1.25rem;
    color: var(--text-secondary);
}

#vaultDropZone.drag-over {
    border-color: var(--accent-1);
    background: rgba(20, 145, 127, 0.1);
}

/* ----- Nav Tabs ----- */
.nav-tabs .nav-link {
    color: var(--text-secondary);
    border: 1px solid transparent;
    font-weight: 500;
    background: transparent;
}

.nav-tabs .nav-link.active {
    color: var(--accent-2);
    background: var(--bg-card);
    border-color: var(--border-glass) var(--border-glass) var(--bg-card);
}

.nav-tabs .nav-link:hover {
    border-color: var(--border-glass);
    color: var(--text-primary);
}

/* ----- Chart Container ----- */
.chart-container {
    position: relative;
    height: 12.5rem;
    width: 100%;
}

/* ----- Modal ----- */
.modal-content.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border-glass);
}

/* NOTE (v4.2): the full .modal-modern rule set (content/header/body/
   footer/btn-close/keyframes) used to be duplicated here AND in
   components.css with the two copies slowly drifting apart, which is
   exactly the kind of "same selector, two files" conflict that made
   modals render inconsistently across pages. components.css is now the
   single source of truth for .modal-modern - see its "MODALS (Modern
   Glass)" section, which also matches the theme-adaptive btn-close
   treatment used by project.php. Do not re-add .modal-modern rules here. */

/* ================================================================
   14. TABLE RESPONSIVE
   ================================================================ */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-glass);
}

.table-responsive table {
    width: 100%;
    min-width: 37.5rem;
    border-collapse: collapse;
    font-size: max(0.9rem, var(--fs-min, 11px));
}

.table-responsive table th,
.table-responsive table td {
    padding: 0.625rem 0.875rem;
    text-align: left;
    border-bottom: 1px solid var(--border-glass);
    white-space: nowrap;
}

.table-responsive table th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-primary);
}

.table-responsive table td {
    color: var(--text-secondary);
}

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

.table > :not(caption) > * > * {
    background-color: transparent !important;
    color: var(--text-secondary);
    border-bottom-color: var(--border-glass);
    vertical-align: middle;
}

.table thead th {
    color: var(--text-primary);
    font-weight: 600;
    border-bottom: 2px solid var(--border-glass);
}

@media (max-width: 575.98px) {
    .table-responsive table {
        font-size: max(0.75rem, var(--fs-min, 11px));
        min-width: 30rem;
    }
    .table-responsive table th,
    .table-responsive table td {
        padding: 0.375rem 0.625rem;
    }
}

/* ================================================================
   15. PREVENT HORIZONTAL SCROLL (global)
   ================================================================ */
/* (.row is NOT capped: max-width:100% on a Bootstrap row cancels its right
   negative margin and shifted every grid ~12px to the left on phones.
   Sideways scroll is prevented by the fit layer on html/body below.) */
.container-fluid {
    max-width: 100%;
}

/* ================================================================
   16. RESPONSIVE ADJUSTMENTS (Zero Rework)
   ================================================================ */
@media (max-width: 575.98px) {
    .finance-summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    .strategy-grid {
        grid-template-columns: 1fr;
    }
    .stat-card .value {
        font-size: 1.5rem;
    }
    .btn,
    .btn-sm,
    .btn-primary-glass,
    .btn-danger-glass,
    .btn-success-glass {
        min-height: 2.75rem;
        padding: 0.375rem 0.875rem;
    }
    .btn-sm {
        min-height: 2.25rem;
        font-size: max(0.7rem, var(--fs-min, 11px));
    }
    .form-control,
    .form-select {
        min-height: 2.75rem;
        font-size: max(0.9rem, var(--fs-min, 11px));
    }
}

@media (max-width: 400px) {
    .finance-summary-cards {
        grid-template-columns: 1fr 1fr;
        gap: 0.375rem;
    }
    .finance-summary-cards .fscard {
        padding: 0.5rem 0.375rem;
    }
    .finance-summary-cards .fscard .fsvalue {
        font-size: 1rem;
    }
    .task-item,
    .schedule-item {
        padding: 0.375rem 0.5rem;
        font-size: max(0.8rem, var(--fs-min, 11px));
        gap: 0.375rem;
    }
    .task-item .task-priority {
        font-size: max(0.5rem, var(--fs-min, 11px));
        padding: 1px 0.375rem;
    }
    .schedule-item .time {
        min-width: auto;
        font-size: max(0.65rem, var(--fs-min, 11px));
    }
    .quick-add-btn {
        font-size: 0;
        padding: 0.375rem 0.5rem;
    }
    .quick-add-btn i {
        font-size: 1.1rem;
        margin: 0;
    }
    .btn-primary-glass,
    .btn-danger-glass,
    .btn-success-glass {
        font-size: max(0.7rem, var(--fs-min, 11px));
        padding: 0.25rem 0.625rem;
        min-height: 2.25rem;
    }
    .stat-card .value {
        font-size: 1.4rem;
    }
    .modal-dialog {
        margin: 0.2rem;
    }
}

/* ================================================================
   17. SIDEBAR COLLAPSE (Desktop) - Icon Rail
   ================================================================
   header.php toggles a single ".collapsed" class on ".sidebar" via
   #sidebarToggleDesktop and persists it to localStorage. This block
   is the CSS half of that contract: it turns the sidebar into a
   slim icon-only rail (not a full hide), floats the toggle button
   at the sidebar's edge, and styles the hover tooltips the JS
   renders onto <body> for the collapsed rail's icons.
   ================================================================ */
.sidebar {
    transition: flex-basis 0.3s ease, width 0.3s ease, padding 0.3s ease;
}

.sidebar.collapsed {
    flex: 0 0 4.75rem;
    width: 4.75rem;
    min-width: 4.75rem;
    padding: 1.75rem 0.75rem 2rem;
    overflow: visible;
}

/* Brand: keep the icon, hide the wordmark */
.sidebar.collapsed .brand {
    justify-content: center;
    gap: 0;
}
.sidebar.collapsed .brand .brand-text {
    display: none;
}

/* Nav links: center icons, hide text labels */
.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.75rem 0;
    gap: 0;
}
.sidebar.collapsed .nav-link .link-label {
    display: none;
}
.sidebar.collapsed .nav-link i {
    font-size: 1.25rem;
}

/* Footer: upgrade button / admin badge collapse to icon-only */
.sidebar.collapsed .sidebar-footer .upgrade-btn,
.sidebar.collapsed .sidebar-footer .admin-mode {
    justify-content: center;
    padding: 0.625rem 0;
    gap: 0;
}
.sidebar.collapsed .sidebar-footer .upgrade-btn span,
.sidebar.collapsed .sidebar-footer .upgrade-btn .badge,
.sidebar.collapsed .sidebar-footer .upgrade-btn .arrow-icon,
.sidebar.collapsed .sidebar-footer .admin-mode span {
    display: none;
}

/* ----- Floating Rail Toggle ----- */
/* Sits on the sidebar/main-content seam; a sibling of .sidebar so it
   is never clipped by the sidebar's own overflow-y:auto scrollbox. */
.sidebar-rail-toggle {
    display: none;
    position: fixed;
    top: 50vh;
    left: 16.25rem;
    transform: translate(-50%, -50%);
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    z-index: 1030;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    transition: left 0.3s ease, background 0.2s ease, color 0.2s ease;
}
.sidebar-rail-toggle:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}
.sidebar-rail-toggle i {
    font-size: max(0.85rem, var(--fs-min, 11px));
    transition: transform 0.3s ease;
}
.sidebar.collapsed + .sidebar-rail-toggle {
    left: 4.75rem;
}
.sidebar.collapsed + .sidebar-rail-toggle i {
    transform: rotate(180deg);
}

@media (min-width: 992px) {
    .sidebar-rail-toggle {
        display: inline-flex;
    }
}
@media (max-width: 991.98px) {
    .sidebar-rail-toggle {
        display: none !important;
    }
}

/* ----- Floating tooltips for the collapsed icon rail ----- */
/* Rendered by header.php's JS onto <body>, positioned inline via
   getBoundingClientRect() - this block only supplies the look. */
.sidebar-floating-tooltip {
    position: fixed;
    transform: translateY(-50%);
    margin-left: 0.625rem;
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    font-size: max(0.8rem, var(--fs-min, 11px));
    font-weight: 600;
    white-space: nowrap;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-sm);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    pointer-events: none;
    opacity: 0;
    z-index: 1040;
    transition: opacity 0.15s ease;
}
.sidebar-floating-tooltip.show {
    opacity: 1;
}

.main-content.expanded {
    padding-left: 0;
}

/* Show desktop toggle on screens wider than 992px */
@media (min-width: 992px) {
    .sidebar-toggle-desktop {
        display: inline-flex;
    }
}

/* ================================================================
   MAIN CONTENT - Preserve Padding When Sidebar Collapses
   ================================================================ */

/* Rows inside the app keep Bootstrap's own symmetric gutters. (An older
   rule zeroed the row margins and gave columns 25px on the left but 12px on
   the right, so every card grid sat off-centre.) */

/* For grids that might have negative margins */
.main-content .dashboard-grid,
.main-content .procurement-summary-cards,
.main-content .kpi-grid {
    margin-left: 0;
    margin-right: 0;
}

/* ================================================================
   17. FIT LAYER  (every page: no sideways scroll, shell locked to screen)
   ================================================================ */
html, body { max-width: 100%; overflow-x: hidden; overflow-x: clip; }
img, svg, video, canvas, iframe, embed, object { max-width: 100%; }
.row > *, .main-content, .page-content, .card, .modal-content, .glass-card { min-width: 0; }
.main-content p, .main-content h1, .main-content h2, .main-content h3, .main-content h4,
.main-content h5, .main-content h6, .main-content td, .main-content th, .main-content label,
.main-content .card, .modal-body { overflow-wrap: anywhere; }
pre, code { white-space: pre-wrap; word-break: break-word; }

/* Tables: wrap instead of forcing a 600px minimum (wide ones still scroll INSIDE their box) */
.table-responsive { max-width: 100%; }
.table-responsive table { min-width: 0; white-space: normal; }
@media (max-width: 991.98px) {
    .table-responsive table { min-width: 0; }
    .table-responsive table th, .table-responsive table td {
        white-space: normal; word-break: break-word; padding: 0.3rem 0.4rem;
    }
}

/* Notification dropdown: never wider than the screen on phones */
@media (max-width: 575.98px) {
    .notification-dropdown {
        position: fixed; left: 0.5rem; right: 0.5rem; top: 3.5rem;
        width: auto; min-width: 0; max-width: none; margin-top: 0;
    }
}

/* Modals / offcanvas never exceed the viewport */
.modal-dialog { max-width: min(var(--bs-modal-width, 500px), calc(100vw - 1rem)); }
.modal-content { max-height: calc(100dvh - 1rem); }
.modal-body { overflow-y: auto; }
.offcanvas { max-width: 100vw; }

/* Safe areas (notch / gesture bar in the Android app) */
@supports (padding: max(0px)) {
    .main-content { padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
    .sidebar-toggle { margin-top: env(safe-area-inset-top, 0px); }
}

/* Touch targets: density stays compact on desktop, usable on phones */
@media (pointer: coarse) {
    .btn, .form-control, .form-select, .nav-link,
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), select, textarea {
        min-height: var(--tap-min);
    }
    .btn-sm, .form-control-sm, .form-select-sm { min-height: calc(var(--tap-min) - 6px); }
    /* iOS Safari zooms the page when focusing inputs under 16px */
    .form-control, .form-select, input, select, textarea { font-size: max(16px, 1rem); }
}

/* Sections that are also .container lose their side padding to shorthand rules like "padding: 5rem 0",
   which makes Bootstrap's negative row gutters poke past the screen edge. Restore it (higher specificity). */
section.container, div.container, main.container {
    padding-left: calc(var(--bs-gutter-x, 1.5rem) * 0.5);
    padding-right: calc(var(--bs-gutter-x, 1.5rem) * 0.5);
}

/* Android app (Play Store): no upgrade / purchase calls to action */
html.is-twa .upgrade-btn, html.is-twa .btn-upgrade-link, html.is-twa a[href$="upgrade"], html.is-twa a[href$="upgrade.php"] { display: none !important; }

/* ================================================================
   SIX-AREA MENU: sub-links of the active area + admin group label
   ================================================================ */
.nav-sub {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0.125rem 0 0.375rem 2.6rem;
    padding-left: 0.75rem;
    border-left: 2px solid var(--sidebar-border, rgba(0,0,0,0.08));
}
.nav-sub-link {
    color: var(--sidebar-text-color, inherit);
    text-decoration: none;
    font-size: max(0.82rem, var(--fs-min, 11px));
    padding: 0.35rem 0.625rem;
    border-radius: 0.5rem;
    opacity: 0.85;
}
.nav-sub-link:hover { background: var(--sidebar-hover); opacity: 1; }
.nav-sub-link.active { color: var(--accent-1); font-weight: 600; opacity: 1; }
.nav-group-label {
    font-size: max(0.68rem, var(--fs-min, 11px));
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.55;
    padding: 0.875rem 1.25rem 0.25rem;
}
.sidebar .nav-link .nav-off-badge,
.offcanvas .nav-link .nav-off-badge {
    background: transparent;
    color: inherit;
    border: 1px solid currentColor;
    opacity: 0.6;
}
.sidebar.collapsed .nav-sub,
.sidebar.collapsed .nav-group-label,
.sidebar.collapsed .nav-off-badge { display: none; }

/* Quick add "+" button (footer.php, assets/js/quick-add.js) */
.quick-add-fab {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    z-index: 1040;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    border: 0;
    background: var(--accent-1, #14917F);
    color: #fff;
    font-size: 1.6rem;
    box-shadow: 0 8px 24px rgba(11, 46, 51, 0.28);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.quick-add-fab:hover { box-shadow: 0 10px 28px rgba(11, 46, 51, 0.35); }
.quick-add-fab:focus-visible { outline: 3px solid var(--accent-2, #0B2E33); outline-offset: 3px; }
.qa-tabs .nav-link { font-size: 0.85rem; padding: 0.4rem 0.5rem; color: var(--text-secondary); }
.qa-tabs .nav-link.active { background: var(--accent-1, #14917F); color: #fff; }
@media (max-width: 767.98px) {
    .quick-add-fab { right: 1rem; bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); }
}
@media print { .quick-add-fab { display: none; } }
