/* ============================================
   Organizei — App Styles
   Mobile-first SPA layout (375px base, 480px max)
   ============================================ */

/* ── App Shell ── */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    max-width: var(--max-width, 480px);
    margin: 0 auto;
    position: relative;
    background: var(--bg);
}

/* ── Header (56px sticky) ── */
.app-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: var(--z-header);
}
.app-header-title {
    font-size: var(--fs-lg);
    font-weight: var(--fw-bold);
    flex: 1;
    color: var(--text);
}
.app-header-back {
    background: none;
    border: none;
    color: var(--text);
    font-size: 20px;
    cursor: pointer;
    padding: 4px;
    display: none;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
}
.app-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.header-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--primary-light);
    cursor: pointer;
    object-fit: cover;
    transition: border-color var(--transition-fast);
}
.header-avatar:hover { border-color: var(--primary); }

/* Profile selector in header */
.profile-selector {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: var(--primary-light);
    border-radius: var(--radius-full);
    border: 1px solid transparent;
    cursor: pointer;
    font-size: var(--fs-sm);
    font-weight: var(--fw-medium);
    color: var(--primary);
    transition: all var(--transition-fast);
    min-height: 32px;
}
.profile-selector:hover { border-color: var(--primary); }
.profile-selector-icon { font-size: 16px; }

/* ── Content Area (flex:1, scrollable) ── */
.app-content {
    flex: 1;
    padding: 16px;
    padding-bottom: calc(var(--tab-bar-height) + 24px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* ── Tab Bar (56px fixed bottom) ── */
.tab-bar {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: var(--max-width, 480px);
    height: var(--tab-bar-height);
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: var(--z-tab-bar);
    padding: 0 8px;
}

/* Camera FAB (integrated in tab bar center, elevated) */
.tab-bar-fab-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    align-self: flex-end;
    margin-bottom: 4px;
}
.camera-fab {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: #fff;
    border: 4px solid var(--bg-card);
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-primary);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    margin-top: -28px;
    z-index: 2;
    position: relative;
}
.camera-fab:hover  { transform: scale(1.05); box-shadow: 0 8px 28px rgba(123,97,255,0.45); }
.camera-fab:active { transform: scale(0.92); }

/* Camera FAB pulse ring */
.camera-fab::after {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 2px solid var(--primary);
    opacity: 0;
    animation: camPulse 4s ease-out 2s infinite;
}
@keyframes camPulse {
    0%   { transform: scale(0.85); opacity: 0.5; }
    100% { transform: scale(1.35); opacity: 0; }
}

/* ── Pages ── */
.page { display: none; }
.page.active { display: block; animation: pageEnter 250ms ease-out; }

/* Page transitions */
@keyframes pageEnter {
    from { opacity: 0; transform: translateX(12px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes pageFadeOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}
.page-exit { animation: pageFadeOut 150ms ease-in forwards; }

/* ── Auth Page ── */
.auth-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 24px;
    text-align: center;
    background: var(--bg);
}
.auth-logo {
    font-size: 48px;
    margin-bottom: 16px;
}
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-8);
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
}
.auth-title {
    font-size: var(--fs-2xl);
    font-weight: var(--fw-extrabold);
    margin-bottom: 8px;
    color: var(--text);
}
.auth-subtitle {
    font-size: var(--fs-base);
    color: var(--text-secondary);
    margin-bottom: 32px;
}
.auth-form {
    width: 100%;
    max-width: 340px;
    margin: 0 auto;
}
.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: var(--text-muted);
    font-size: 12px;
}
.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}
.auth-toggle {
    font-size: var(--fs-sm);
    color: var(--text-muted);
    margin-top: 16px;
}
.auth-toggle a { color: var(--primary); font-weight: var(--fw-semibold); cursor: pointer; }

/* ── Onboarding ── */
.onboarding-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: var(--z-overlay);
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.onboarding-overlay.active { display: flex; }

/* Onboarding slides container (snap scroll) */
.onboarding-slides {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    width: 100%;
    max-width: 380px;
}
.onboarding-slides::-webkit-scrollbar { display: none; }
.onboarding-slide {
    flex: 0 0 100%;
    scroll-snap-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    min-height: 60vh;
}
.onboarding-slide-icon {
    font-size: 64px;
    margin-bottom: 24px;
    animation: slideIconFloat 3s ease-in-out infinite;
}
@keyframes slideIconFloat {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-8px); }
}

/* Onboarding dots */
.onboarding-dots {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin: 16px 0;
}
.onboarding-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
    transition: all 200ms ease;
}
.onboarding-dot.active {
    width: 24px;
    border-radius: 4px;
    background: var(--primary);
}

.onboarding-title {
    font-size: 22px;
    font-weight: var(--fw-extrabold);
    text-align: center;
    margin-bottom: 4px;
    color: var(--text);
}
.onboarding-subtitle {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 16px;
}
.onboarding-profiles {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    width: 100%;
    max-width: 380px;
}
.onboarding-profile {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 10px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: 44px;
}
.onboarding-profile:hover { border-color: var(--primary); }
.onboarding-profile.selected { border-color: var(--primary); background: var(--primary-light); }
.onboarding-profile-icon { font-size: 26px; margin-bottom: 4px; display: block; }
.onboarding-profile-name { font-size: var(--fs-sm); font-weight: var(--fw-bold); margin-bottom: 2px; }
.onboarding-profile-desc { font-size: var(--fs-xs); color: var(--text-muted); line-height: 1.3; }
.onboarding-actions {
    margin-top: 16px;
    text-align: center;
    width: 100%;
    max-width: 380px;
    padding-bottom: 24px;
}

/* ── Dashboard: Greeting ── */
.greeting {
    margin-bottom: 16px;
}
.greeting-title {
    font-size: var(--fs-xl);
    font-weight: var(--fw-bold);
    color: var(--text);
}
.greeting-subtitle {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
}

/* ── Dashboard: Stat Cards (horizontal scroll) ── */
.stat-cards-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 4px 0 16px;
    margin: 0 -16px;
    padding-left: 16px;
    padding-right: 16px;
}
.stat-cards-scroll::-webkit-scrollbar { display: none; }
.stat-cards-scroll .card-stat { scroll-snap-align: start; }

/* ── Dashboard: Chart Containers ── */
.chart-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: var(--space-5);
    margin-bottom: 16px;
}
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
}
.chart-title {
    font-size: var(--fs-base);
    font-weight: var(--fw-semibold);
    color: var(--text);
}
.chart-filters {
    display: flex;
    gap: 4px;
}
.chart-filter-chip {
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: var(--fs-xs);
    font-weight: var(--fw-medium);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    min-height: 28px;
}
.chart-filter-chip.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Pie chart with legend */
.chart-pie-wrapper {
    display: flex;
    align-items: center;
    gap: 16px;
}
.chart-legend {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.chart-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--fs-sm);
}
.chart-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.chart-legend-label {
    flex: 1;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chart-legend-value {
    font-weight: var(--fw-semibold);
    color: var(--text);
}

/* ── Category Grid (2 columns) ── */
.category-section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.category-section-title h3 {
    font-size: var(--fs-md);
    font-weight: var(--fw-bold);
}
.category-section-title a {
    font-size: var(--fs-sm);
    color: var(--primary);
    font-weight: var(--fw-medium);
}

/* Books Grid (existing class name) */
.books-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
.book-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
}
.book-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--category-color, var(--primary));
    border-radius: 0 4px 4px 0;
}
.book-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.book-card:active { transform: scale(0.98); }
.book-icon {
    font-size: 32px;
    margin-bottom: 8px;
    display: block;
}
.book-icon-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
    font-size: 24px;
}
.book-name {
    font-size: var(--fs-base);
    font-weight: var(--fw-semibold);
    color: var(--text);
    margin-bottom: 4px;
}
.book-count {
    font-size: 12px;
    color: var(--text-muted);
}

/* ── Item List ── */
.items-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.item-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.item-card:hover { border-color: var(--primary); }
.item-card:active { transform: scale(0.99); }
.item-thumb {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    object-fit: cover;
    background: var(--bg-input);
    flex-shrink: 0;
}
.item-info { flex: 1; min-width: 0; }
.item-title {
    font-size: var(--fs-base);
    font-weight: var(--fw-semibold);
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.item-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.item-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}
.item-value {
    font-size: var(--fs-base);
    font-weight: var(--fw-semibold);
    color: var(--primary);
}
.item-date {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    flex-shrink: 0;
}
.item-chevron {
    color: var(--text-muted);
    font-size: 16px;
    flex-shrink: 0;
}

/* ── Item Detail ── */
.item-detail-photo {
    width: 100%;
    max-height: 280px;
    object-fit: contain;
    border-radius: var(--radius-lg);
    background: var(--bg-input);
    margin-bottom: 16px;
    box-shadow: var(--shadow-md);
}
.item-detail-fields {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.item-field {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.item-field-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: var(--fw-semibold);
}
.item-field-value {
    font-size: var(--fs-base);
    font-weight: var(--fw-medium);
    color: var(--text);
    text-align: right;
    word-break: break-word;
    max-width: 60%;
}
.item-field-value.currency {
    font-size: var(--fs-md);
    font-weight: var(--fw-bold);
    color: var(--primary);
}

/* Item action bar (fixed bottom) */
.item-actions-bar {
    display: flex;
    justify-content: space-around;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
}
.item-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 10px;
    font-family: var(--font);
    cursor: pointer;
    padding: 6px 12px;
    min-height: 44px;
    min-width: 44px;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}
.item-action-btn:hover { background: var(--bg-hover); color: var(--text); }
.item-action-btn.danger { color: var(--error); }
.item-action-btn.danger:hover { background: var(--error-light); }
.item-action-btn-icon { font-size: 20px; }

/* ── Capture Overlay (fullscreen, 3 steps) ── */
.capture-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: var(--z-overlay);
    display: none;
    flex-direction: column;
}
.capture-overlay.active { display: flex; }

.capture-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    min-height: var(--header-height);
}
.capture-close {
    background: none;
    border: none;
    color: var(--text);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.capture-title { font-size: var(--fs-md); font-weight: var(--fw-semibold); flex: 1; }

.capture-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.capture-preview {
    width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: var(--radius-lg);
    background: var(--bg-input);
    position: relative;
}

/* Step 1: Analyzing — scan animation */
.capture-analyzing {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.capture-analyzing .capture-preview {
    border-radius: 0;
}
.capture-scan-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary-gradient);
    box-shadow: 0 0 12px rgba(123, 97, 255, 0.5), 0 0 40px rgba(123, 97, 255, 0.2);
    animation: scanLine 2s ease-in-out infinite;
    z-index: 1;
}
@keyframes scanLine {
    0%   { top: 0%; }
    50%  { top: 100%; }
    100% { top: 0%; }
}

.capture-result {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}
.capture-classification {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding: 12px;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
}
.capture-classification-icon { font-size: 20px; }
.capture-classification-text { font-size: var(--fs-base); font-weight: var(--fw-semibold); }
.capture-confidence {
    font-size: 12px;
    margin-left: auto;
    font-weight: var(--fw-semibold);
}
.capture-confidence.high   { color: var(--success); }
.capture-confidence.medium { color: var(--warning); }
.capture-confidence.low    { color: var(--error); }

.capture-fields {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.capture-field-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    transition: border-color var(--transition-fast);
}
.capture-field-card:focus-within { border-color: var(--primary); }
.capture-field-label {
    font-size: var(--fs-xs);
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    font-weight: var(--fw-semibold);
    margin-bottom: 4px;
}
.capture-field-value {
    font-size: 15px;
    font-weight: var(--fw-medium);
    color: var(--text);
}
.capture-field-value.editable { cursor: text; }

.capture-book-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.capture-book-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--bg-input);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
    min-height: 44px;
}
.capture-book-option.selected { border-color: var(--primary); background: var(--primary-light); }
.capture-book-option:hover { border-color: var(--primary); }
.capture-book-icon { font-size: 20px; }
.capture-book-name { font-size: var(--fs-base); font-weight: var(--fw-semibold); }

.capture-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
    background: var(--bg-card);
}

/* Capture loading */
.capture-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 40px;
    text-align: center;
}
.capture-loading-text {
    font-size: var(--fs-base);
    color: var(--text-secondary);
}
.capture-loading-dots {
    display: flex;
    gap: 6px;
}
.capture-loading-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    animation: dotPulse 1.2s ease-in-out infinite;
}
.capture-loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.capture-loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotPulse {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.3; }
    40%           { transform: scale(1);   opacity: 1; }
}

/* Step 3: Success — confetti + check */
.capture-success {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.capture-success-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    animation: successPop 300ms ease-out;
}
.capture-success-check {
    font-size: 36px;
    color: #fff;
}
@keyframes successPop {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}

.capture-success-title {
    font-size: var(--fs-xl);
    font-weight: var(--fw-bold);
    color: var(--success);
    margin-bottom: 4px;
}
.capture-success-subtitle {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* Confetti particles (12 pieces) */
.confetti-container {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}
.confetti {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    top: 50%;
    left: 50%;
    animation: confettiFall 1.5s ease-out forwards;
}
.confetti:nth-child(1)  { background: var(--primary); animation-delay: 0ms;  --cx: -60px;  --cy: -120px; --cr: 200deg; }
.confetti:nth-child(2)  { background: var(--accent);  animation-delay: 30ms; --cx: 70px;   --cy: -100px; --cr: -150deg; }
.confetti:nth-child(3)  { background: var(--warning);  animation-delay: 60ms; --cx: -30px;  --cy: -140px; --cr: 300deg; }
.confetti:nth-child(4)  { background: var(--error);   animation-delay: 90ms; --cx: 50px;   --cy: -90px;  --cr: -200deg; }
.confetti:nth-child(5)  { background: var(--primary); animation-delay: 50ms; --cx: -80px;  --cy: -80px;  --cr: 250deg; }
.confetti:nth-child(6)  { background: var(--accent);  animation-delay: 80ms; --cx: 90px;   --cy: -110px; --cr: -180deg; }
.confetti:nth-child(7)  { background: var(--warning);  animation-delay: 20ms; --cx: -50px;  --cy: -130px; --cr: 320deg; }
.confetti:nth-child(8)  { background: var(--primary); animation-delay: 70ms; --cx: 40px;   --cy: -100px; --cr: -240deg; }
.confetti:nth-child(9)  { background: var(--accent);  animation-delay: 40ms; --cx: -90px;  --cy: -90px;  --cr: 180deg; }
.confetti:nth-child(10) { background: var(--error);   animation-delay: 100ms;--cx: 60px;   --cy: -120px; --cr: -280deg; }
.confetti:nth-child(11) { background: var(--warning);  animation-delay: 60ms; --cx: -40px;  --cy: -70px;  --cr: 140deg; }
.confetti:nth-child(12) { background: var(--primary); animation-delay: 110ms;--cx: 80px;   --cy: -80px;  --cr: -120deg; }

@keyframes confettiFall {
    0%   { transform: translate(0, 0) rotate(0deg); opacity: 1; }
    100% { transform: translate(var(--cx), calc(var(--cy) + 250px)) rotate(var(--cr)); opacity: 0; }
}

/* ── Search Page ── */
.search-bar {
    margin-bottom: 16px;
}

/* ── Settings Page ── */
.settings-section {
    margin-bottom: 24px;
}
.settings-section-title {
    font-size: 12px;
    font-weight: var(--fw-semibold);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}
.settings-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color var(--transition-fast);
    min-height: 52px;
}
.settings-item:hover { border-color: var(--primary); }
.settings-item-icon { font-size: 20px; flex-shrink: 0; }
.settings-item-text { flex: 1; }
.settings-item-label { font-size: var(--fs-base); font-weight: var(--fw-medium); }
.settings-item-desc { font-size: 12px; color: var(--text-muted); }
.settings-item-value { font-size: var(--fs-base); color: var(--text-secondary); flex-shrink: 0; }
.settings-item-chevron { color: var(--text-muted); font-size: 14px; flex-shrink: 0; }

/* Settings divider */
.settings-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* Settings toggle switch */
.toggle-switch {
    position: relative;
    width: 48px;
    height: 24px;
    flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-track {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: background var(--transition-fast);
}
.toggle-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform var(--transition-fast);
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.toggle-switch input:checked + .toggle-track {
    background: var(--primary-gradient);
}
.toggle-switch input:checked + .toggle-track::after {
    transform: translateX(24px);
}

/* ── Usage Bar ── */
.usage-bar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}
.usage-bar-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}
.usage-bar-label { font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.usage-bar-count { font-size: var(--fs-sm); color: var(--text-muted); }

/* ── Subcategory Chips ── */
.subcategory-chips {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 4px 0 12px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.subcategory-chips::-webkit-scrollbar { display: none; }

.subcategory-chip {
    flex-shrink: 0;
    padding: 5px 14px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: var(--fw-medium);
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    min-height: 32px;
    display: flex;
    align-items: center;
}
.subcategory-chip:hover { border-color: var(--primary); }
.subcategory-chip.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Subcategory Badge (on items) */
.subcategory-badge {
    display: inline-flex;
    align-items: center;
    padding: 1px 8px;
    border-radius: 10px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: var(--fs-xs);
    font-weight: var(--fw-medium);
    white-space: nowrap;
    vertical-align: middle;
}

/* Subcategory Autocomplete */
.subcategory-autocomplete {
    position: relative;
}
.subcategory-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    box-shadow: var(--shadow-md);
    z-index: 10;
    max-height: 160px;
    overflow-y: auto;
}
.subcategory-option {
    padding: 10px 14px;
    font-size: var(--fs-base);
    color: var(--text);
    cursor: pointer;
    transition: background 100ms;
    min-height: 44px;
    display: flex;
    align-items: center;
}
.subcategory-option:hover {
    background: var(--bg-hover);
}

/* ── User Dropdown ── */
.user-dropdown {
    position: absolute;
    top: calc(var(--header-height) + 4px);
    right: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    z-index: var(--z-dropdown);
    display: none;
    overflow: hidden;
}
.user-dropdown.active { display: block; animation: dropdownFade 150ms ease-out; }
@keyframes dropdownFade {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.user-dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.user-dropdown-email { font-size: 12px; color: var(--text-muted); }
.user-dropdown-plan {
    font-size: var(--fs-xs);
    color: var(--primary);
    font-weight: var(--fw-semibold);
    text-transform: uppercase;
    margin-top: 2px;
}
.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--text-secondary);
    font-size: var(--fs-base);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: var(--font);
    transition: background var(--transition-fast);
    min-height: 44px;
}
.user-dropdown-item:hover { background: var(--bg-hover); color: var(--text); }
.user-dropdown-item.danger { color: var(--error); }
.user-dropdown-item.danger:hover { background: var(--error-light); }

/* ── Hidden Inputs ── */
#camera-input, #gallery-input { display: none; }

/* ── Chat Widget Push ── */
#axiom-chat-widget { bottom: calc(var(--tab-bar-height) + 12px) !important; }

/* ── Sidebar (if used in settings/about) ── */
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    font-size: var(--fs-base);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    min-height: 44px;
}
.sidebar-item:hover { background: var(--bg-hover); color: var(--text); }
.sidebar-item.active { background: var(--primary-light); color: var(--primary); font-weight: var(--fw-semibold); }
.sidebar-version {
    padding: 16px;
    font-size: var(--fs-xs);
    color: var(--text-muted);
    text-align: center;
}

/* ── Feed Filter Chips ── */
.feed-filter-chips {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 4px 0 12px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.feed-filter-chips::-webkit-scrollbar { display: none; }

.feed-filter-chip {
    flex-shrink: 0;
    padding: 5px 14px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: var(--fw-medium);
    font-family: var(--font);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    min-height: 32px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.feed-filter-chip:hover { border-color: var(--primary); }
.feed-filter-chip.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ── Feed List ── */
.feed-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.feed-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.feed-item:hover { border-color: var(--primary); }
.feed-item:active { transform: scale(0.99); }

.feed-item-thumb {
    width: 52px;
    height: 52px;
    border-radius: 10px;
    object-fit: cover;
    background: var(--bg-input);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.feed-item-content {
    flex: 1;
    min-width: 0;
}
.feed-item-title {
    font-size: var(--fs-base);
    font-weight: var(--fw-semibold);
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.feed-item-meta {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.feed-item-time {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    margin-top: 2px;
}
.feed-item-icon {
    font-size: 18px;
    flex-shrink: 0;
}

/* ── Desktop Sidebar ── */
.desktop-sidebar {
    display: none; /* hidden on mobile by default */
}

.app-main {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* ── Dark Mode: all screens covered via CSS variables ── */
/* Dark mode is handled entirely through :root / [data-theme="dark"] tokens in design-system.css */
/* No duplicate rules needed here -- all components use vars */

/* ── Responsive: small screens ── */
@media (max-width: 374px) {
    .books-grid { gap: 8px; }
    .stat-cards-scroll { gap: 8px; }
    .app-content { padding: 12px; padding-bottom: calc(var(--tab-bar-height) + 20px); }
}

/* ── Responsive: medium (tablet) ── */
@media (min-width: 481px) and (max-width: 767px) {
    .app-shell {
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }
}

/* ══════════════════════════════════════════════
   Desktop Layout (>= 768px): Sidebar + Content
   ═══���══════════════════════════════════════════ */
@media (min-width: 768px) {
    :root {
        --sidebar-width: 240px;
    }

    .app-shell {
        flex-direction: row;
        max-width: none;
        min-height: 100vh;
        min-height: 100dvh;
    }

    /* Show sidebar */
    .desktop-sidebar {
        display: flex;
        flex-direction: column;
        width: var(--sidebar-width);
        min-width: var(--sidebar-width);
        background: var(--bg-card);
        border-right: 1px solid var(--border);
        position: sticky;
        top: 0;
        height: 100vh;
        height: 100dvh;
        overflow-y: auto;
        z-index: var(--z-header);
    }

    .sidebar-brand {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 16px 20px;
        font-size: var(--fs-lg);
        font-weight: var(--fw-bold);
        color: var(--text);
        border-bottom: 1px solid var(--border);
    }

    .sidebar-nav {
        flex: 1;
        padding: 8px 12px;
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .sidebar-section-title {
        font-size: 11px;
        font-weight: var(--fw-semibold);
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.5px;
        padding: 8px 12px 4px;
    }

    .sidebar-divider {
        height: 1px;
        background: var(--border);
        margin: 8px 0;
    }

    .sidebar-cat-item {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 8px 12px;
        color: var(--text-secondary);
        font-size: var(--fs-sm);
        cursor: pointer;
        border-radius: var(--radius-sm);
        transition: all var(--transition-fast);
        min-height: 36px;
    }
    .sidebar-cat-item:hover { background: var(--bg-hover); color: var(--text); }
    .sidebar-cat-item .cat-count {
        margin-left: auto;
        font-size: var(--fs-xs);
        color: var(--text-muted);
    }

    /* Main content fills remaining space */
    .app-main {
        flex: 1;
        min-width: 0;
    }

    /* Remove max-width constraint on content */
    .app-content {
        max-width: none;
        padding-bottom: 24px;
    }

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

    /* Header stretches to content width only */
    .app-header {
        position: sticky;
        top: 0;
    }

    /* Stat cards in a row (not scrolling) */
    .stat-cards-scroll {
        flex-wrap: wrap;
        overflow-x: visible;
    }

    /* Charts side by side */
    .desktop-charts-row {
        display: flex;
        gap: 16px;
    }
    .desktop-charts-row .chart-container {
        flex: 1;
        min-width: 0;
    }

    /* Feed items slightly wider feel */
    .feed-list {
        max-width: 800px;
    }

    /* Categories grid 3 columns on desktop */
    .books-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Chat widget adjust for no tab bar */
    #axiom-chat-widget {
        bottom: 16px !important;
    }
}

/* ============================================
   Financial Module
   ============================================ */

/* Financial Stats Cards */
.card-stat-expense .card-stat-value { color: var(--error); }
.card-stat-income .card-stat-value { color: var(--accent); }
.card-stat-balance .card-stat-value { font-weight: 700; }

/* Finances Page */
.finances-period-filters { display: flex; gap: 8px; }
.finances-period-filters .chip {
    padding: 6px 16px; border-radius: 20px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text-secondary); font-size: 13px; cursor: pointer;
}
.finances-period-filters .chip.active {
    background: var(--primary); color: white; border-color: var(--primary);
}

/* Finances Dashboard */
.fin-filters { padding: 0 16px 16px; }
.fin-filters select {
    background: var(--surface); color: var(--text); border: 1px solid var(--border);
    border-radius: 8px; padding: 8px 12px; font-size: 14px;
}
.fin-summary {
    display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px;
    padding: 0 16px; margin-bottom: 24px;
}
.fin-card {
    background: var(--surface); border-radius: 12px; padding: 16px;
    border: 1px solid var(--border);
}
.fin-card-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.fin-card-value { font-size: 20px; font-weight: 700; }
.fin-card.expense .fin-card-value { color: var(--error); }
.fin-card.income .fin-card-value { color: var(--accent); }

.fin-charts {
    display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
    padding: 0 16px; margin-bottom: 24px;
}
.fin-chart-card {
    background: var(--surface); border-radius: 12px; padding: 20px;
    border: 1px solid var(--border);
}
.fin-chart-title { font-size: 14px; font-weight: 600; margin-bottom: 16px; }

.fin-pie-wrapper { display: flex; align-items: center; gap: 20px; }
.fin-pie { width: 120px; height: 120px; border-radius: 50%; flex-shrink: 0; background: var(--border); }
.fin-pie-legend { flex: 1; }
.fin-pie-legend-item { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 12px; }
.fin-pie-legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.fin-pie-legend-label { flex: 1; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fin-pie-legend-value { font-weight: 600; color: var(--text); }

.fin-bars { display: flex; align-items: flex-end; gap: 8px; height: 140px; padding-top: 20px; }
.fin-bar-col { display: flex; flex-direction: column; align-items: center; flex: 1; height: 100%; justify-content: flex-end; }
.fin-bar { width: 100%; border-radius: 4px 4px 0 0; background: var(--primary); min-height: 4px; transition: height 0.3s; }
.fin-bar-label { font-size: 10px; color: var(--text-secondary); margin-top: 4px; }
.fin-bar-value { font-size: 10px; color: var(--text-secondary); margin-bottom: 2px; white-space: nowrap; }

.fin-section { padding: 0 16px; margin-bottom: 24px; }
.fin-section-title { font-size: 14px; font-weight: 600; margin-bottom: 12px; }

/* Top categorias com barra de progresso */
.fin-top-item {
    display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
}
.fin-top-icon { font-size: 20px; width: 32px; text-align: center; }
.fin-top-info { flex: 1; min-width: 0; }
.fin-top-name { font-size: 13px; font-weight: 500; }
.fin-top-bar { height: 6px; background: var(--border); border-radius: 3px; margin-top: 4px; }
.fin-top-bar-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }
.fin-top-amount { font-size: 13px; font-weight: 600; text-align: right; min-width: 80px; }
.fin-top-pct { font-size: 11px; color: var(--text-secondary); text-align: right; min-width: 40px; }

/* Finance transaction items */
.fin-tx-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 0; border-bottom: 1px solid var(--border);
}
.fin-tx-icon {
    width: 40px; height: 40px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; background: var(--primary-light); flex-shrink: 0;
}
.fin-tx-info { flex: 1; min-width: 0; }
.fin-tx-name { font-size: 14px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fin-tx-date { font-size: 12px; color: var(--text-secondary); }
.fin-tx-amount { font-size: 15px; font-weight: 600; text-align: right; white-space: nowrap; }

/* Responsive: mobile */
@media (max-width: 768px) {
    .fin-charts { grid-template-columns: 1fr; }
    .fin-summary { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
    .fin-card-value { font-size: 16px; }
    .fin-card { padding: 12px; }
    .fin-pie-wrapper { flex-direction: column; align-items: center; }
}
@media (max-width: 400px) {
    .fin-summary { grid-template-columns: 1fr; }
}

/* Expense pie chart visual (legacy) */
.chart-pie-visual {
    width: 120px; height: 120px; border-radius: 50%; flex-shrink: 0;
}

/* Finance empty state */
.fin-empty { text-align: center; padding: 40px 16px; color: var(--text-secondary); }
.fin-empty-icon { font-size: 48px; margin-bottom: 12px; }
