/* =============================================================================
   Farm OS — Shell v3 (Product Redesign)
   ============================================================================= */

:root {
    --shell-sidebar-w: 272px;
    --shell-app-bar-h: 52px;
    --shell-bottom-nav-h: 72px;
    --shell-fab-clearance: 64px;
    --shell-content-max: 1440px;
    --shell-content-pad-top-mobile: calc(var(--shell-app-bar-h) + env(safe-area-inset-top, 0px) + 10px);
    --shell-content-pad-bottom-mobile: calc(
        var(--shell-bottom-nav-h) + env(safe-area-inset-bottom, 0px) + var(--shell-fab-clearance) + 16px
    );
    --shell-ease: cubic-bezier(0.22, 1, 0.36, 1);
    --shell-shadow-soft: 0 2px 16px rgba(15, 23, 42, 0.06);
    --shell-shadow-float: 0 12px 40px rgba(15, 23, 42, 0.12);
}

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ─── Auth gating — hide app chrome when logged out ─── */
body.fm-logged-out #app-container,
body:not(.fm-logged-in) #app-container {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}
body.fm-logged-in #app-container {
    display: flex !important;
    visibility: visible !important;
    pointer-events: auto !important;
}
body.fm-logged-in #login-view { display: none !important; }
body.fm-logged-out #login-view { display: flex !important; }
body.fm-logged-in {
    overflow: hidden;
    height: 100%;
    height: 100dvh;
}

body.fm-logged-out #global-search-overlay,
body.fm-logged-out #global-search-overlay.open,
body.fm-logged-out #floating-action-button,
body.fm-logged-out #filter-fab,
body.fm-logged-out .contextual-fab,
body.fm-logged-out #more-menu-modal,
body.fm-logged-out .shell-bottom-nav,
body.fm-logged-out .mobile-app-bar,
body.fm-logged-out .shell-sidebar {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* ─── App layout ─── */
#app-container {
    min-height: 100vh;
    min-height: 100dvh;
    height: 100dvh;
    overflow: hidden;
    background: var(--fm-bg) !important;
}

.main-content-area {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    scroll-padding-top: 8px;
    scroll-padding-bottom: var(--shell-content-pad-bottom-mobile);
    padding: var(--shell-content-pad-top-mobile) 14px var(--shell-content-pad-bottom-mobile) 14px !important;
}

@media (min-width: 768px) {
    #app-container {
        flex-direction: row;
    }
    .main-content-area {
        padding: 1.25rem 2rem 5.5rem calc(var(--shell-sidebar-w) + 1.5rem) !important;
        scroll-padding-bottom: 96px;
        max-width: 100%;
    }
    .main-content-area > .view {
        max-width: var(--shell-content-max);
        margin: 0 auto;
    }
}

/* ─── Desktop sidebar ─── */
.shell-sidebar {
    display: none;
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--shell-sidebar-w);
    flex-direction: column;
    background: var(--fm-surface) !important;
    border-right: 1px solid var(--fm-border);
    padding: 1rem 0.75rem;
    z-index: 40;
    overflow-y: auto;
}

@media (min-width: 768px) {
    .shell-sidebar {
        display: flex !important;
    }
}

.shell-brand {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.5rem 0.5rem 1rem;
    border-bottom: 1px solid var(--fm-border);
    margin-bottom: 0.75rem;
}
.shell-brand-mark {
    width: 44px; height: 44px; border-radius: 14px;
    background: var(--fm-gradient);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.35rem;
    box-shadow: 0 6px 20px rgba(5, 150, 105, 0.25);
}
.shell-brand-title {
    font-size: 1.125rem; font-weight: 800; letter-spacing: -0.02em;
    background: var(--fm-gradient);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.shell-brand-farm { font-size: 0.75rem; color: var(--fm-text-secondary); margin-top: 2px; }

.shell-controls { padding: 0 0.25rem 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; }
.shell-control-label { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--fm-text-muted); }
.shell-select {
    width: 100%; font-size: 0.8rem !important; padding: 0.5rem 0.75rem !important;
    border-radius: 10px !important; border: 1px solid var(--fm-border) !important;
    background: var(--fm-surface-2) !important;
}

.shell-nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.shell-nav-group { border-radius: 12px; }
.shell-nav-group.expanded .shell-nav-children { display: flex; }
.shell-nav-group.expanded .shell-nav-chevron { transform: rotate(180deg); }

.shell-nav-primary {
    display: flex; align-items: center; gap: 0.65rem;
    padding: 0.7rem 0.85rem; border-radius: 12px;
    color: var(--fm-text-secondary); font-weight: 600; font-size: 0.875rem;
    text-decoration: none; transition: background 0.15s, color 0.15s;
    width: 100%; border: none; background: none; cursor: pointer;
}
.shell-nav-primary i:first-child { width: 20px; text-align: center; }
.shell-nav-chevron { margin-left: auto; font-size: 0.65rem; opacity: 0.5; transition: transform 0.2s var(--shell-ease); }
.shell-nav-primary:hover, .shell-nav-child:hover { background: var(--fm-surface-2); color: var(--fm-text); }
.shell-nav-primary.nav-link-active, .shell-nav-child.nav-link-active {
    background: var(--fm-primary-light) !important;
    color: var(--fm-primary-dark) !important;
}

.shell-nav-children {
    display: none; flex-direction: column; gap: 1px;
    padding: 0.25rem 0 0.35rem 0.5rem; margin-left: 0.75rem;
    border-left: 2px solid var(--fm-border);
}
.shell-nav-child {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.5rem 0.75rem; border-radius: 10px;
    font-size: 0.8rem; font-weight: 500; color: var(--fm-text-secondary);
    text-decoration: none; transition: all 0.15s;
}
.shell-nav-child i { width: 18px; text-align: center; font-size: 0.8rem; }

.shell-sidebar-footer {
    margin-top: auto; padding-top: 0.75rem; border-top: 1px solid var(--fm-border);
    display: flex; flex-direction: column; gap: 4px;
}
.shell-footer-btn {
    display: flex; align-items: center; gap: 0.65rem;
    padding: 0.65rem 0.85rem; border-radius: 10px; border: none; background: none;
    font-size: 0.85rem; font-weight: 600; color: var(--fm-text-secondary); cursor: pointer;
    width: 100%; text-align: left;
}
.shell-footer-btn:hover { background: var(--fm-surface-2); }
.shell-footer-btn-danger { color: var(--fm-danger); }

/* ─── Mobile app bar ─── */
.mobile-app-bar {
    display: block;
    position: fixed; top: 0; left: 0; right: 0; z-index: 50;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(16px) saturate(1.2);
    border-bottom: 1px solid var(--fm-border);
    padding: env(safe-area-inset-top, 0) 12px 0 12px;
}
.mobile-app-bar-row {
    display: flex; align-items: center; justify-content: space-between;
    height: var(--shell-app-bar-h); gap: 8px;
}
.mobile-farm-pill {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 10px; border-radius: 99px;
    background: var(--fm-surface-2); border: 1px solid var(--fm-border);
    font-size: 0.75rem; font-weight: 700; color: var(--fm-text);
    max-width: 42%; overflow: hidden; cursor: pointer;
}
.mobile-farm-pill-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--fm-primary); flex-shrink: 0; }
.mobile-farm-pill-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mobile-page-title {
    flex: 1; text-align: center; font-size: 0.9rem; font-weight: 700;
    color: var(--fm-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mobile-app-bar-actions { display: flex; gap: 4px; }
.app-bar-btn {
    width: 36px; height: 36px; border-radius: 10px; border: none;
    background: transparent; color: var(--fm-text-secondary);
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    transition: background 0.15s;
}
.app-bar-btn:hover, .app-bar-btn:active { background: var(--fm-surface-2); color: var(--fm-primary); }
.app-bar-btn-danger { color: var(--fm-danger); }

/* ─── Bottom nav ─── */
.shell-bottom-nav {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    height: var(--shell-bottom-nav-h);
    padding-bottom: env(safe-area-inset-bottom, 0);
    background: rgba(255,255,255,0.94);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--fm-border);
    box-shadow: 0 -4px 24px rgba(15,23,42,0.06);
}
.shell-bottom-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; padding: 6px 4px; border: none; background: none;
    color: var(--fm-text-muted); font-size: 0.6rem; font-weight: 700;
    text-decoration: none; cursor: pointer; transition: color 0.15s, transform 0.15s;
    min-height: 48px;
}
.shell-bottom-item i { font-size: 1.15rem; transition: transform 0.2s var(--shell-ease); }
.shell-bottom-item.nav-link-active { color: var(--fm-primary); }
.shell-bottom-item.nav-link-active i { transform: scale(1.08); }

/* ─── Page chrome ─── */
.page-chrome {
    display: flex; align-items: flex-start; gap: 0.875rem;
    margin-bottom: 1rem; padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--fm-border);
    animation: fadeUp 0.25s var(--shell-ease);
}
.page-chrome.hidden { display: none !important; }
.page-chrome-icon-wrap {
    width: 44px; height: 44px; border-radius: 14px;
    background: var(--fm-primary-light); color: var(--fm-primary-dark);
    display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
}
.page-chrome-title { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.page-chrome-subtitle { font-size: 0.8rem; color: var(--fm-text-secondary); margin-top: 2px; }

/* ─── Views ─── */
.view {
    display: none !important;
    padding: 0 0 1.25rem;
}
.view.active {
    display: block !important;
    opacity: 1 !important;
    transform: none !important;
    visibility: visible !important;
    animation: none !important;
}
.view.home-command-center.active {
    display: flex !important;
    flex-direction: column;
    gap: 1.25rem;
}

@media (min-width: 768px) {
    .view { padding: 0 0 1.5rem; }
    .view .view-header h1,
    .view .view-header .view-subtitle { display: none; }
}

/* Mobile: page chrome is the single title — hide duplicate in-view headers */
.view .view-header h1,
.view .view-header .view-subtitle {
    display: none;
}
.view .view-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    min-height: 0;
}
.view.legacy-orphan { display: none !important; }

/* Onboarding strip on dashboard */
.home-onboarding {
    background: linear-gradient(135deg, var(--fm-primary-light) 0%, var(--fm-surface) 100%);
    border: 1px solid var(--fm-border);
    border-radius: 16px;
    padding: 1rem;
}
.home-onboarding.hidden { display: none !important; }
.home-onboarding-head h2 { font-size: 1rem; font-weight: 800; }
.home-onboarding-head p { font-size: 0.75rem; color: var(--fm-text-secondary); margin-top: 2px; }
.home-onboarding-steps { display: flex; flex-direction: column; gap: 8px; margin-top: 0.75rem; }
.onboard-step {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 10px 12px; border-radius: 12px;
    background: var(--fm-surface); border: 1px solid var(--fm-border);
    text-align: left; cursor: pointer;
}
.onboard-step-icon {
    width: 36px; height: 36px; border-radius: 10px;
    background: var(--fm-primary-light); color: var(--fm-primary-dark);
    display: flex; align-items: center; justify-content: center;
}
.onboard-step-title { display: block; font-size: 0.85rem; font-weight: 700; }
.onboard-step-desc { display: block; font-size: 0.7rem; color: var(--fm-text-secondary); margin-top: 2px; }
.field-intercrop-badge {
    display: inline-block; font-size: 0.65rem; font-weight: 700;
    padding: 2px 6px; border-radius: 6px; margin-left: 4px;
    background: #dcfce7; color: #166534; vertical-align: middle;
}
.intercrop-fieldset {
    border: 1px solid var(--fm-border); border-radius: 12px;
    padding: 0.75rem; margin: 0;
}
.intercrop-fieldset legend { padding: 0 4px; }

@media (prefers-reduced-motion: reduce) {
    .view, .anim-fade-in, .anim-slide-up, .priority-card { animation: none !important; }
    * { transition-duration: 0.01ms !important; }
}
body.fm-initializing .view,
body.fm-initializing .anim-fade-in,
body.fm-initializing .anim-slide-up,
body.fm-initializing .priority-card,
body.fm-initializing .mandi-card {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
}

/* ─── HOME Command Center ─── */
/* layout only when dashboard view is active — see .view.home-command-center.active above */

.home-hero { display: flex; flex-direction: column; gap: 0.875rem; }
.home-hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; }
.home-greeting {
    font-size: 1.5rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.15;
    color: var(--fm-text);
}
.home-subgreeting { font-size: 0.8rem; color: var(--fm-text-secondary); margin-top: 4px; }
.home-setup-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 12px; border-radius: 99px;
    background: var(--fm-surface); border: 1px solid var(--fm-border);
    font-size: 0.75rem; font-weight: 700; color: var(--fm-primary);
    box-shadow: var(--shell-shadow-soft); cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}
.home-setup-chip:active { transform: scale(0.97); }

.home-hero-cards {
    display: grid; grid-template-columns: 1fr; gap: 10px;
}
@media (min-width: 640px) { .home-hero-cards { grid-template-columns: 1.2fr 1fr; } }

.home-weather-card {
    background: var(--fm-gradient);
    border-radius: 20px; padding: 1rem 1.125rem;
    color: white; box-shadow: 0 10px 32px rgba(5,150,105,0.28);
}
.home-weather-main { display: flex; align-items: center; gap: 12px; }
.home-weather-icon { font-size: 2rem; opacity: 0.9; }
.home-weather-temp { font-size: 2rem; font-weight: 800; line-height: 1; }
.home-weather-desc { font-size: 0.8rem; opacity: 0.9; margin-top: 2px; }
.home-weather-meta {
    display: flex; gap: 1rem; margin-top: 0.75rem; font-size: 0.75rem; opacity: 0.85;
}
.home-weather-badge {
    margin-top: 0.65rem; padding: 6px 10px; border-radius: 8px;
    background: rgba(255,255,255,0.18); font-size: 0.72rem; font-weight: 600;
}
.home-weather-badge.bad { background: rgba(220,38,38,0.35); }
.home-weather-impact { font-size: 0.72rem; margin-top: 6px; opacity: 0.9; }

.home-status-card {
    background: var(--fm-surface); border: 1px solid var(--fm-border);
    border-radius: 20px; padding: 1rem; box-shadow: var(--shell-shadow-soft);
}
.home-status-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--fm-text-muted); }
.home-status-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; text-align: center; }
.home-status-val { display: block; font-size: 1.1rem; font-weight: 800; color: var(--fm-text); }
.home-status-lbl { font-size: 0.65rem; color: var(--fm-text-muted); font-weight: 600; }

.home-section { display: flex; flex-direction: column; gap: 0.65rem; }
.home-section-header {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.home-section-header h2 {
    font-size: 0.95rem; font-weight: 800; letter-spacing: -0.01em;
    display: flex; align-items: center; gap: 8px;
}
.home-section-header h2 i { color: var(--fm-primary); font-size: 0.85rem; }
.home-badge {
    font-size: 0.7rem; font-weight: 800; padding: 3px 8px; border-radius: 99px;
    background: var(--fm-primary-light); color: var(--fm-primary-dark);
}

.home-priority-scroller {
    display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory;
    padding-bottom: 4px; -webkit-overflow-scrolling: touch;
}
.home-priority-scroller::-webkit-scrollbar { display: none; }

.priority-card {
    flex: 0 0 min(88%, 320px); scroll-snap-align: start;
    display: flex; flex-direction: column; gap: 8px;
    background: var(--fm-surface); border: 1px solid var(--fm-border);
    border-radius: 16px; padding: 14px; cursor: pointer;
    box-shadow: var(--shell-shadow-soft);
    transition: transform 0.2s var(--shell-ease), box-shadow 0.2s;
    position: relative; overflow: hidden;
}
.priority-card:active { transform: scale(0.98); }
.priority-card-accent {
    position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    background: var(--fm-info);
}
.priority-card.critical .priority-card-accent { background: var(--fm-danger); }
.priority-card.warn .priority-card-accent { background: var(--fm-accent); }
.priority-card-kicker { font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--fm-text-muted); padding-left: 8px; }
.priority-card-title { font-size: 0.95rem; font-weight: 700; padding-left: 8px; line-height: 1.3; }
.priority-card-sub { font-size: 0.75rem; color: var(--fm-text-secondary); padding-left: 8px; line-height: 1.4; }
.priority-card-cta {
    font-size: 0.72rem; font-weight: 700; color: var(--fm-primary);
    padding-left: 8px; margin-top: auto;
}

.home-quick-rail {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
.home-quick-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 6px; padding: 12px 6px; min-height: 72px;
    background: var(--fm-surface); border: 1px solid var(--fm-border);
    border-radius: 16px; cursor: pointer;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
    box-shadow: var(--shell-shadow-soft);
}
.home-quick-btn i { font-size: 1.25rem; color: var(--fm-primary); }
.home-quick-btn span { font-size: 0.65rem; font-weight: 700; color: var(--fm-text); text-align: center; }
.home-quick-btn:active { transform: scale(0.96); border-color: var(--fm-primary); }

.home-stats-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
}
@media (min-width: 640px) { .home-stats-grid { grid-template-columns: repeat(4, 1fr); } }

.stat-tile {
    display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
    padding: 14px; border-radius: 16px;
    background: var(--fm-surface); border: 1px solid var(--fm-border);
    text-align: left; cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: var(--shell-shadow-soft);
}
.stat-tile:active { transform: scale(0.98); }
.stat-tile-icon { color: var(--fm-primary); font-size: 0.9rem; opacity: 0.85; }
.stat-tile-value { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.02em; }
.stat-tile-label { font-size: 0.68rem; font-weight: 600; color: var(--fm-text-secondary); }
.stat-tile-warn .stat-tile-icon, .stat-tile-warn .stat-tile-value { color: var(--fm-accent); }

.home-finance-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.home-finance-card {
    padding: 14px; border-radius: 16px; border: none; text-align: left; cursor: pointer;
    transition: transform 0.15s;
}
.home-finance-card:active { transform: scale(0.98); }
.home-finance-expense { background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%); color: white; }
.home-finance-income { background: linear-gradient(135deg, #059669 0%, #0d9488 100%); color: white; }
.home-finance-lbl { font-size: 0.7rem; font-weight: 600; opacity: 0.85; display: block; }
.home-finance-val { font-size: 1.25rem; font-weight: 800; display: block; margin-top: 4px; }
.home-finance-sub { font-size: 0.65rem; opacity: 0.75; margin-top: 2px; display: block; }

.home-collapsible { border: 1px solid var(--fm-border); border-radius: 16px; background: var(--fm-surface); overflow: hidden; }
.home-collapsible-trigger { list-style: none; cursor: pointer; padding: 14px 14px 0; }
.home-collapsible-trigger::-webkit-details-marker { display: none; }
.home-collapsible[open] .home-collapsible-trigger { padding-bottom: 8px; }
.home-collapsible > :not(summary) { padding: 0 14px 14px; }

.home-ai-cards { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.home-ai-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.home-ai-input-row { display: flex; gap: 8px; }
.home-ai-input-row input { flex: 1; font-size: 0.85rem !important; }
.home-ai-response { margin-top: 10px; }

.home-insights-list { display: flex; flex-direction: column; gap: 8px; }
.home-recent-list { display: flex; flex-direction: column; gap: 0; }

.recent-activity-item {
    display: flex; gap: 12px; padding: 12px 0;
    border-bottom: 1px solid var(--fm-border);
}
.recent-activity-item:last-child { border-bottom: none; }
.recent-activity-icon {
    width: 36px; height: 36px; border-radius: 10px;
    background: var(--fm-surface-2); color: var(--fm-primary);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.recent-activity-title { font-size: 0.85rem; font-weight: 600; }
.recent-activity-meta { font-size: 0.72rem; color: var(--fm-text-muted); margin-top: 2px; }

.home-desktop-grid {
    display: none;
}
@media (min-width: 1024px) {
    .home-desktop-grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
        margin-top: 0.5rem;
    }
    .home-desktop-card {
        background: var(--fm-surface); border: 1px solid var(--fm-border);
        border-radius: 14px; padding: 14px; cursor: pointer;
        transition: box-shadow 0.2s, transform 0.2s;
    }
    .home-desktop-card:hover { box-shadow: var(--shell-shadow-float); transform: translateY(-2px); }
    .home-desktop-card .label { font-size: 0.7rem; color: var(--fm-text-muted); font-weight: 600; }
    .home-desktop-card .stat { font-size: 1.5rem; font-weight: 800; margin-top: 4px; }
    .home-desktop-card.wide { grid-column: span 2; }
    .home-desktop-card.warn { border-color: #fcd34d; background: #fffbeb; }
    .home-desktop-card.finance { border-color: #c4b5fd; background: #f5f3ff; }
    .home-tools-mini { display: flex; gap: 1rem; margin-top: 8px; font-size: 0.8rem; }
    .home-tools-mini em { font-style: normal; font-weight: 800; font-size: 1.1rem; display: block; }
}

/* Alerts */
.home-alerts .attention-item,
.home-alert-list .attention-item {
    display: flex; align-items: center; gap: 10px;
    padding: 12px; background: var(--fm-surface);
    border-radius: 12px; border: 1px solid #fecaca;
    cursor: pointer; transition: transform 0.15s;
}
.home-alert-list .attention-item:active { transform: scale(0.99); }

/* ─── Bottom sheets & modals ─── */
.more-menu-modal, .quick-action-sheet {
    align-items: flex-end !important;
    justify-content: flex-end !important;
}
.more-menu-modal .sheet-content,
.quick-action-sheet .sheet-content {
    width: 100% !important; max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    max-height: 85vh !important;
    padding: 0 1rem 1.25rem !important;
    transform: translateY(100%);
    transition: transform 0.28s var(--shell-ease);
}
.more-menu-modal.sheet-open .sheet-content,
.quick-action-sheet.sheet-open .sheet-content { transform: translateY(0); }

.sheet-handle {
    width: 36px; height: 4px; border-radius: 2px;
    background: var(--fm-border); margin: 10px auto 6px;
}
.sheet-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.5rem 0 1rem;
}
.sheet-header h3 { font-size: 1.1rem; font-weight: 800; }
.sheet-close {
    width: 36px; height: 36px; border-radius: 10px; border: none;
    background: var(--fm-surface-2); font-size: 1.25rem; cursor: pointer;
}
.sheet-lang-row { margin-bottom: 1rem; }

.more-menu-grid { display: flex; flex-direction: column; gap: 1rem; overflow-y: auto; max-height: 55vh; }
.more-menu-group-label {
    font-size: 0.65rem; font-weight: 800; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--fm-text-muted); margin-bottom: 8px;
}
.more-menu-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.more-menu-tile {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 14px 8px; border-radius: 14px;
    background: var(--fm-surface-2); border: 1px solid var(--fm-border);
    cursor: pointer; transition: transform 0.15s, background 0.15s;
}
.more-menu-tile:active { transform: scale(0.96); background: var(--fm-primary-light); }
.more-menu-tile-icon {
    width: 40px; height: 40px; border-radius: 12px;
    background: var(--fm-surface); display: flex; align-items: center; justify-content: center;
    color: var(--fm-primary); font-size: 1rem;
}
.more-menu-tile-label { font-size: 0.65rem; font-weight: 700; text-align: center; line-height: 1.2; }

.quick-action-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.quick-action-tile {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    padding: 1.25rem 1rem; border-radius: 16px;
    background: var(--fm-surface-2); border: 1px solid var(--fm-border);
    cursor: pointer; font-weight: 700; font-size: 0.8rem;
}
.quick-action-tile i { font-size: 1.5rem; color: var(--fm-primary); }

@media (max-width: 767px) {
    .fm-sheet:not(.more-menu-modal):not(.quick-action-sheet) {
        align-items: flex-end !important;
    }
    .fm-sheet:not(.more-menu-modal):not(.quick-action-sheet) .modal-content {
        width: 100% !important; max-width: 100% !important;
        border-radius: 20px 20px 0 0 !important;
        max-height: 92vh !important;
        margin-bottom: 0 !important;
        animation: sheetUp 0.3s var(--shell-ease);
    }
}
@keyframes sheetUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

/* ─── Contextual FAB ─── */
.contextual-fab {
    position: fixed; right: 16px; z-index: 45;
    bottom: calc(var(--shell-bottom-nav-h) + env(safe-area-inset-bottom, 0) + 12px);
    display: flex; align-items: center; gap: 8px;
    padding: 14px 18px; border-radius: 99px; border: none;
    background: var(--fm-gradient); color: white;
    font-weight: 700; font-size: 0.85rem;
    box-shadow: 0 8px 28px rgba(5,150,105,0.4);
    cursor: pointer; transition: transform 0.2s, box-shadow 0.2s;
}
.contextual-fab-label {
    font-size: 0.8rem; font-weight: 700; white-space: nowrap; color: white;
}
.contextual-fab.scale-0 { transform: scale(0); opacity: 0; pointer-events: none; }
.contextual-fab:active { transform: scale(0.96); }
.filter-fab {
    position: fixed; left: 16px; z-index: 45;
    bottom: calc(var(--shell-bottom-nav-h) + env(safe-area-inset-bottom, 0) + 12px);
    width: 52px; height: 52px; border-radius: 50%; border: none;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white; box-shadow: 0 8px 24px rgba(99,102,241,0.35);
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    transition: transform 0.2s;
}
.filter-fab.scale-0 { transform: scale(0); opacity: 0; pointer-events: none; }
@media (min-width: 768px) {
    .filter-fab { bottom: 24px; left: calc(var(--shell-sidebar-w) + 24px); }
}

@media (min-width: 768px) {
    .contextual-fab { bottom: 24px; right: 24px; }
    .shell-bottom-nav { display: none !important; }
    .mobile-app-bar { display: none !important; }
    .main-content-area {
        padding-top: 1.25rem !important;
    }
}

/* ─── Data views: mobile cards ─── */
@media (max-width: 767px) {
    .view table.responsive-hide-mobile { display: none; }
    .mobile-card-list { display: flex; flex-direction: column; gap: 10px; }
    .data-card {
        background: var(--fm-surface); border: 1px solid var(--fm-border);
        border-radius: 14px; padding: 14px;
        box-shadow: var(--shell-shadow-soft);
    }
    .data-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
    .data-card-title { font-weight: 700; font-size: 0.9rem; }
    .data-card-meta { font-size: 0.72rem; color: var(--fm-text-muted); margin-top: 4px; }
    .data-card-actions { display: flex; gap: 8px; margin-top: 10px; }
}

@media (min-width: 768px) {
    .mobile-card-list { display: none; }
}

/* ─── Horizontal scroll tabs ─── */
.scroll-tabs {
    display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
}
.scroll-tabs::-webkit-scrollbar { display: none; }
.scroll-tab {
    flex-shrink: 0; padding: 8px 14px; border-radius: 99px;
    font-size: 0.8rem; font-weight: 600; border: 1px solid var(--fm-border);
    background: var(--fm-surface); color: var(--fm-text-secondary); cursor: pointer;
    transition: all 0.15s;
}
.scroll-tab.active {
    background: var(--fm-primary-light); border-color: var(--fm-primary);
    color: var(--fm-primary-dark);
}

/* ─── Skeleton loaders ─── */
.skeleton-card {
    background: var(--fm-surface); border-radius: 14px; padding: 14px;
    border: 1px solid var(--fm-border);
}
.skeleton-line {
    height: 12px; border-radius: 6px;
    background: linear-gradient(90deg, var(--fm-surface-2) 25%, var(--fm-border) 50%, var(--fm-surface-2) 75%);
    background-size: 200% 100%; animation: shimmer 1.2s infinite;
    margin-bottom: 8px;
}
.skeleton-line.w-3\/4 { width: 75%; }
.skeleton-line.w-1\/2 { width: 50%; }
@keyframes shimmer { to { background-position: -200% 0; } }

.empty-state-v3 {
    text-align: center; padding: 2rem 1.25rem;
    background: var(--fm-surface-2); border-radius: 16px;
    border: 2px dashed var(--fm-border);
}
.empty-state-v3-icon { font-size: 2rem; color: var(--fm-text-muted); margin-bottom: 0.75rem; }
.empty-state-v3 h4 { font-weight: 800; margin-bottom: 0.5rem; }
.empty-state-v3 p { font-size: 0.85rem; color: var(--fm-text-secondary); margin-bottom: 1rem; }

.field-detail-panel {
    background: var(--fm-surface); border: 1px solid var(--fm-border);
    border-radius: 16px; padding: 14px; margin-bottom: 12px;
    box-shadow: var(--shell-shadow-soft); animation: fadeUp 0.25s var(--shell-ease);
}
.field-detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.field-detail-title { font-size: 1.1rem; font-weight: 800; }
.field-detail-meta { font-size: 0.8rem; color: var(--fm-text-secondary); margin-top: 2px; }
.field-detail-stats { display: flex; gap: 12px; font-size: 0.75rem; color: var(--fm-text-muted); margin: 10px 0; }
.field-quick-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.field-quick-btn {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px; border-radius: 12px; border: 1px solid var(--fm-border);
    background: var(--fm-surface-2); font-size: 0.8rem; font-weight: 700; cursor: pointer;
}
.field-quick-btn i { color: var(--fm-primary); }
.field-card { cursor: pointer; transition: box-shadow 0.15s, transform 0.15s; }
.field-card:active { transform: scale(0.99); }

.sidebar { display: none !important; }
.bottom-nav { display: none !important; }
.mobile-header { display: none !important; }
.hub-pills, .dash-stat-strip, .dashboard-detail-section { display: none !important; }
.weather-widget:not(.home-weather-card) { display: none; }

/* ─── Finance Hub split layout ─── */
.finance-hub-header {
    display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start;
    gap: 12px; margin-bottom: 16px;
}
.finance-hub-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.finance-hub-layout { display: flex; flex-direction: column; gap: 16px; }
.finance-hub-aside { display: flex; flex-direction: column; gap: 12px; }
.finance-summary-grid {
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
}
.finance-charts-panel {
    background: var(--fm-surface); border: 1px solid var(--fm-border);
    border-radius: 16px; overflow: hidden;
}
.finance-charts-toggle {
    padding: 12px 14px; font-weight: 700; font-size: 0.85rem; cursor: pointer;
    list-style: none; user-select: none;
}
.finance-charts-toggle::-webkit-details-marker { display: none; }
.finance-charts-stack { padding: 0 12px 12px; display: flex; flex-direction: column; gap: 10px; }
.finance-chart-card { margin: 0; }
.finance-hub-main {
    background: var(--fm-surface); border: 1px solid var(--fm-border);
    border-radius: 16px; padding: 12px; min-height: 280px;
}
.finance-transactions-toolbar { margin-bottom: 12px; }
.finance-tabs-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
.finance-tabs-scroll::-webkit-scrollbar { display: none; }
.finance-expense-toolbar { margin-bottom: 10px; }
.finance-inline-select { max-width: 180px; font-size: 0.8rem; }
.finance-transaction-list { display: flex; flex-direction: column; gap: 8px; }
.finance-tx-card {
    display: flex; align-items: center; gap: 12px;
    padding: 12px; border-radius: 14px;
    background: var(--fm-surface-2); border: 1px solid var(--fm-border);
}
.finance-tx-icon {
    width: 40px; height: 40px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    font-size: 0.95rem;
}
.finance-tx-icon.income { background: rgba(34, 197, 94, 0.12); color: var(--fm-success); }
.finance-tx-icon.expense { background: rgba(239, 68, 68, 0.1); color: var(--fm-danger); }
.finance-tx-body { flex: 1; min-width: 0; }
.finance-tx-title { font-weight: 700; font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.finance-tx-meta { font-size: 0.72rem; color: var(--fm-text-muted); margin-top: 2px; }
.finance-tx-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.finance-tx-amount { font-weight: 800; font-size: 0.9rem; }
.finance-tx-amount.income { color: var(--fm-success); }
.finance-tx-amount.expense { color: var(--fm-danger); }
.finance-tx-actions { display: flex; gap: 4px; }
.finance-tx-btn {
    width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--fm-border);
    background: var(--fm-surface); color: var(--fm-text-secondary); cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 0.75rem;
}
.finance-tx-btn:hover { background: var(--fm-surface-2); }

@media (min-width: 1024px) {
    .finance-hub-layout {
        display: grid;
        grid-template-columns: minmax(280px, 360px) 1fr;
        align-items: start;
        gap: 20px;
    }
    .finance-hub-aside { position: sticky; top: 12px; }
    .finance-charts-panel[open] .finance-charts-stack { max-height: calc(100dvh - 280px); overflow-y: auto; }
}

/* ─── Expense wizard ─── */
.expense-wizard-content {
    max-width: 480px; width: 100%; padding: 0;
    border-radius: 20px 20px 0 0; max-height: 92vh; overflow: hidden;
    display: flex; flex-direction: column;
}
@media (min-width: 640px) {
    .expense-wizard-content { border-radius: 20px; max-height: 88vh; }
}
.expense-wizard-form { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.expense-wizard-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding: 16px 16px 8px; gap: 12px;
}
.expense-wizard-title { font-size: 1.15rem; font-weight: 800; margin: 0; }
.expense-wizard-sub { font-size: 0.78rem; color: var(--fm-text-muted); margin: 4px 0 0; }
.expense-wizard-steps {
    display: flex; justify-content: center; gap: 8px; padding: 0 16px 12px;
}
.expense-wizard-step-dot {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    font-size: 0.65rem; color: var(--fm-text-muted); flex: 1; max-width: 72px;
}
.expense-wizard-step-dot span {
    width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 0.8rem;
    background: var(--fm-surface-2); border: 2px solid var(--fm-border);
}
.expense-wizard-step-dot em { font-style: normal; font-weight: 600; }
.expense-wizard-step-dot.active span { background: var(--fm-primary); border-color: var(--fm-primary); color: #fff; }
.expense-wizard-step-dot.done span { background: var(--fm-primary-light); border-color: var(--fm-primary); color: var(--fm-primary-dark); }
.expense-wizard-pane {
    display: none; padding: 0 16px 12px; overflow-y: auto; flex: 1; min-height: 0;
}
.expense-wizard-pane.active { display: block; animation: fadeUp 0.2s var(--shell-ease); }
.expense-cat-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px;
}
.expense-cat-chip {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 12px 6px; border-radius: 12px; border: 2px solid var(--fm-border);
    background: var(--fm-surface-2); font-size: 0.7rem; font-weight: 700;
    cursor: pointer; transition: all 0.15s; color: var(--fm-text-secondary);
}
.expense-cat-chip i { font-size: 1rem; color: var(--fm-primary); }
.expense-cat-chip.active {
    border-color: var(--fm-primary); background: var(--fm-primary-light);
    color: var(--fm-primary-dark);
}
.expense-amount-input { font-size: 1.5rem; font-weight: 800; text-align: center; }
.expense-review-card {
    background: var(--fm-surface-2); border: 1px solid var(--fm-border);
    border-radius: 14px; padding: 14px;
}
.expense-review-row {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 8px 0; border-bottom: 1px solid var(--fm-border); font-size: 0.85rem;
}
.expense-review-row:last-child { border-bottom: none; }
.expense-review-row span { color: var(--fm-text-muted); }
.expense-wizard-nav {
    display: flex; gap: 10px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--fm-border); background: var(--fm-surface);
}
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Data cards */
.data-card {
    background: var(--fm-surface); border: 1px solid var(--fm-border);
    border-radius: 14px; padding: 14px; box-shadow: var(--shell-shadow-soft);
}
.data-card-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.data-card-tag {
    font-size: 0.7rem; padding: 4px 8px; border-radius: 8px;
    background: var(--fm-surface-2); color: var(--fm-text-secondary);
}
.spray-review-products { margin: 8px 0 0; padding-left: 1rem; font-size: 0.8rem; color: var(--fm-text-secondary); }
.spray-wizard-content { max-width: 520px; }
.spray-wizard-pane { display: none; padding: 0 16px 12px; overflow-y: auto; flex: 1; min-height: 0; }
.spray-wizard-pane.active { display: block; }

/* Command palette v2 */
.search-result-group { padding: 4px 0; }
.search-result-group-label {
    font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--fm-text-muted); padding: 8px 16px 4px;
}
#global-search-overlay .search-result-item.active { background: var(--fm-primary-light); }
