/* ═══════════════════════════════════════════
   YiDingBang Modern UI
   ═══════════════════════════════════════════ */

/* Prevent horizontal overflow on all devices */
html, body { max-width: 100vw; overflow-x: hidden; }

/* ── Delete Mode: hide delete buttons unless enabled ── */
html:not(.delete-mode) .btn-delete { display: none !important; }

/* ── Sidebar ── */
.sidebar {
    width: 240px;
    min-height: 100vh;
    min-height: 100dvh;
    background: linear-gradient(180deg, #1e1b4b 0%, #312e81 50%, #3730a3 100%);
    color: white;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    transition: width 0.25s ease, transform 0.25s ease;
    /* Reserve room for the iOS notch / status bar so the logo and first
       nav item aren't hidden behind it on standalone PWA mode. */
    padding-top: env(safe-area-inset-top);
}

.sidebar.collapsed {
    width: 0;
    overflow: hidden;
}

/* ── Nav Links ── */
.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 14px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 500;
    color: rgba(255,255,255,0.55);
    transition: all 0.2s ease;
    text-align: left;
    cursor: pointer;
    border: 1px solid transparent;
}
.nav-link:hover {
    color: rgba(255,255,255,0.9);
    background: rgba(255,255,255,0.08);
}
.nav-link.active {
    color: white;
    background: rgba(255,255,255,0.13);
    border-color: rgba(255,255,255,0.1);
    box-shadow: 0 0 20px rgba(99,102,241,0.15);
}
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

.nav-group { margin-top: 2px; }
.nav-group-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 7px 14px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    color: rgba(255,255,255,0.35);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    border: none;
    background: none;
}
.nav-group-label:hover { color: rgba(255,255,255,0.6); }
.nav-group-label .nav-icon { width: 14px; height: 14px; margin-right: 6px; }
.nav-chevron { transition: transform 0.2s ease; opacity: 0.5; }
.nav-group.collapsed .nav-chevron { transform: rotate(-90deg); }
.nav-group-items { overflow: hidden; transition: max-height 0.25s ease; max-height: 1200px; }
.nav-group.collapsed .nav-group-items { max-height: 0; }
.nav-group-items .nav-link { padding-left: 36px; font-size: 13px; }

/* ── Cards ── */
.card {
    background: white;
    border-radius: 16px;
    border: 1px solid rgba(0,0,0,0.06);
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.02);
    transition: box-shadow 0.25s ease, transform 0.25s ease;
    overflow: hidden;
    max-width: 100%;
}
.card-hover:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.08), 0 8px 32px rgba(0,0,0,0.04);
    transform: translateY(-2px);
}
.card-gradient {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border: none;
}

/* ── Buttons ── */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(99,102,241,0.3);
    border: none;
    cursor: pointer;
}
.btn-primary:hover {
    box-shadow: 0 4px 16px rgba(99,102,241,0.4);
    transform: translateY(-1px);
}
.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    background: transparent;
    color: #64748b;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s ease;
    border: 1px solid #e2e8f0;
    cursor: pointer;
}
.btn-ghost:hover { background: #f1f5f9; color: #334155; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    background: #fef2f2;
    color: #dc2626;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid #fecaca;
    transition: all 0.15s ease;
    cursor: pointer;
}
.btn-danger:hover { background: #fee2e2; }
.btn-success {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    background: #ecfdf5;
    color: #059669;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid #a7f3d0;
    transition: all 0.15s ease;
    cursor: pointer;
}
.btn-success:hover { background: #d1fae5; }
.btn-warning {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    background: #fffbeb;
    color: #d97706;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid #fde68a;
    transition: all 0.15s ease;
    cursor: pointer;
}
.btn-warning:hover { background: #fef3c7; }
.btn-icon {
    padding: 6px;
    border-radius: 8px;
    color: #94a3b8;
    transition: all 0.15s ease;
    cursor: pointer;
    background: transparent;
    border: none;
    display: inline-flex;
    align-items: center;
}
.btn-icon:hover { color: #475569; background: #f1f5f9; }

/* ── Forms ── */
.form-input {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    border-radius: 10px;
    border: 1.5px solid #e2e8f0;
    padding: 8px 12px;
    /* 16px on touch devices stops iOS Safari from zooming in on focus.
       Desktop keeps the more compact 13px so dense forms (rental tax,
       trip detail) don't get visually noisy. */
    font-size: 16px;
    background: white;
    transition: all 0.2s ease;
    outline: none;
    color: #1e293b;
    text-align: left;
    box-sizing: border-box;
}
@media (min-width: 640px) {
    .form-input { font-size: 13px; }
}
.form-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
input[type="date"].form-input,
input[type="datetime-local"].form-input {
    min-width: 0;
    -webkit-min-logical-width: 0;
}
.form-input::placeholder { color: #cbd5e1; }
.form-select {
    display: block;
    width: 100%;
    max-width: 100%;
    border-radius: 10px;
    border: 1.5px solid #e2e8f0;
    padding: 8px 12px;
    /* Same iOS-zoom mitigation as .form-input above. */
    font-size: 16px;
    background: white;
    transition: all 0.2s ease;
    outline: none;
    color: #1e293b;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M4.646 5.646a.5.5 0 01.708 0L8 8.293l2.646-2.647a.5.5 0 01.708.708l-3 3a.5.5 0 01-.708 0l-3-3a.5.5 0 010-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}
@media (min-width: 640px) {
    .form-select { font-size: 13px; }
}

/* Bottom-nav safe-area: on mobile only, push the main content above the
   home indicator so the bottom nav (which now reserves env(safe-area-inset-bottom))
   doesn't sit on top of the last row of content.

   Math: the bottom nav's visible height is `min-h-[56px]` (button row) +
   env(safe-area-inset-bottom) (the home-indicator zone padded inside the
   nav). Main's padding-bottom must equal that exactly so the last
   content row sits flush with the top of the nav — no visible gap of
   body bg showing through (which would be a different colour from the
   nav's `bg-white` and read as "empty space"). */
@media (max-width: 639.98px) {
    .ydb-main-mobile-bottom {
        padding-bottom: calc(56px + env(safe-area-inset-bottom)) !important;
    }
}

/* G8: bottom-nav button absorbs the home-indicator safe-area into its
   own min-height instead of leaving it as empty padding inside the nav.
   Result: the button visually fills all the way to viewport.bottom (no
   "empty white strip" between buttons and the screen edge), and the
   icon, being vertically centred inside the larger button, sits ~17px
   closer to the bottom edge — which was the user's complaint. The 56px
   floor is preserved on non-notched devices (env() resolves to 0).
   Trade-off: the bottom slice of each button overlaps the iOS
   home-indicator gesture zone — taps very close to the bottom edge may
   be intercepted by the home gesture, but most taps work fine. The
   user explicitly accepted this trade-off. !important is needed to
   beat Tailwind's `min-h-[56px]` which is also on each button.

   G14: also pad the BUTTON BOTTOM by the safe-area amount so the
   icon+label content sits ABOVE the home-indicator graphic (the
   labels were ending up at ~25px from the screen edge after G13
   extended the nav into the safe-area zone — visually overlapped
   by the iOS home indicator pill). With both min-height +
   padding-bottom set, content area = 56px (the original tap-target
   height) and content stays vertically centred there; the bottom
   safe-area zone of the button is just nav-coloured background,
   no interactive content inside the gesture-conflict region. */
@media (max-width: 639.98px) {
    .ydb-bottom-nav-btn {
        min-height: calc(56px + env(safe-area-inset-bottom)) !important;
        padding-bottom: env(safe-area-inset-bottom) !important;
    }
}

/* G16: restore G13's negative bottom offset on the bottom nav.
   G15 had removed it on the (wrong) assumption that the iOS PWA
   layout viewport extends to the screen edge — empirically that's
   NOT true on the user's iPhone PWA: with `bottom: 0` (G15 state)
   they report a body-bg-coloured strip filling the 34px between the
   nav.bottom and the actual screen edge. That confirms the iOS PWA
   layout viewport stops ABOVE the home-indicator zone (regardless of
   our `viewport-fit=cover` + `black-translucent` meta tags — likely
   because iOS cached the brief G7-era "default" status-bar-style at
   PWA install time and never re-reads it without a reinstall).
   Pushing the nav.bottom DOWN by env(safe-area-inset-bottom) extends
   the nav element through the home-indicator zone all the way to
   the actual screen edge, so the body-bg strip below the nav goes
   away. The G14 `padding-bottom: env(SA)` on .ydb-bottom-nav-btn
   (rule above) keeps the icon+label content in the top 56px of the
   90px button — well above the home-indicator graphic — so we get
   both: nav-coloured background extending to the screen edge AND
   content sitting safely above the gesture/indicator zone. */
@media (max-width: 639.98px) {
    #mobile-bottom-nav {
        bottom: calc(0px - env(safe-area-inset-bottom)) !important;
    }
}

/* G19/G22: HARDCODED safe-area handling for iOS standalone PWA. The
   /debug-viewport page on iPhone 14 Pro Max iOS 18.7 in our PWA
   installation shows env(safe-area-inset-bottom) returns 0px even
   though the device has a home-indicator zone — meaning every G14
   padding-bottom and G16/G17 negative-bottom-offset rule above was
   silently no-op'd by the broken env() value.

   The .ydb-ios-pwa class is added to <html> by app.js's
   detectIosPwa() (it checks the legacy navigator.standalone === true
   property — the modern @media (display-mode: standalone) returns
   NO on this device, also verified by /debug-viewport).

   G22 (REVERTED G20 again): user supplied a screenshot proving that
   on iPhone 14 Pro Max iOS 18.7 PWA, the iOS home-indicator zone
   doesn't just draw a small pill ON TOP of content — it actually
   CLIPS off the bottom ~30px of any content placed in that zone.
   G20's "anchor content to screen edge" approach (justify-content:
   flex-end + min-height: 56 + padding-bottom: 0) made the bottom
   half of every nav icon literally invisible (only the top of each
   icon shape was rendered). This is fundamentally incompatible with
   iOS PWA — content has to be ABOVE the home-indicator zone to be
   fully visible, period.

   Restored G19: 90px button (56px content area + 34px home-indicator
   buffer), content centred in the top 56px so icons + labels sit
   fully above the clipping zone. The bottom 34px of each button is
   nav-coloured background only (no content there to clip). */
.ydb-ios-pwa .ydb-bottom-nav-btn {
    min-height: calc(56px + 34px) !important;  /* 90px = content area + home-indicator buffer */
    padding-bottom: 34px !important;            /* push icon+label into the top 56px */
}

@media (max-width: 768px) {
    .ydb-ios-pwa .sidebar {
        padding-bottom: 34px;  /* keeps Sign-out button above home-indicator pill */
    }
}

.form-select:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.form-checkbox {
    width: 16px;
    height: 16px;
    border-radius: 5px;
    border: 1.5px solid #cbd5e1;
    accent-color: #6366f1;
}

/* ── Tables ── */
.data-table {
    width: 100%;
    font-size: 13px;
    border-collapse: separate;
    border-spacing: 0;
}
.data-table thead th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 10px 16px;
    border-bottom: 1.5px solid #f1f5f9;
    background: #fafbfc;
}
.data-table thead th:first-child { border-radius: 10px 0 0 0; }
.data-table thead th:last-child { border-radius: 0 10px 0 0; }
.data-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid #f8fafc;
    vertical-align: middle;
}
.data-table tbody tr {
    transition: background 0.15s ease;
}
.data-table tbody tr:hover {
    background: #f8fafc;
}
.data-table tbody tr:last-child td { border-bottom: none; }

/* ── Tags / Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.badge-blue { background: #eef2ff; color: #4f46e5; }
.badge-green { background: #ecfdf5; color: #059669; }
.badge-yellow { background: #fffbeb; color: #d97706; }
.badge-red { background: #fef2f2; color: #dc2626; }
.badge-gray { background: #f1f5f9; color: #64748b; }
.badge-purple { background: #f5f3ff; color: #7c3aed; }

/* ── Stat Cards ── */
.stat-card {
    background: white;
    border-radius: 16px;
    border: 1px solid rgba(0,0,0,0.06);
    padding: 20px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: 16px 16px 0 0;
}
.stat-card.stat-income::before { background: linear-gradient(90deg, #10b981, #34d399); }
.stat-card.stat-expense::before { background: linear-gradient(90deg, #f43f5e, #fb7185); }
.stat-card.stat-balance::before { background: linear-gradient(90deg, #6366f1, #8b5cf6); }
.stat-value {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-top: 6px;
}
.stat-label {
    font-size: 12px;
    font-weight: 600;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── Bill type colors ── */
.bill-electricity { background: #fef9c3; color: #a16207; }
.bill-waste { background: #dcfce7; color: #15803d; }
.bill-broadband { background: #dbeafe; color: #1d4ed8; }
.bill-misc { background: #f1f5f9; color: #475569; }

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.5);
    backdrop-filter: blur(4px);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal-container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.15);
    max-width: 750px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
    animation: modalIn 0.25s ease-out;
}

/* ── Toast ── */
.toast {
    padding: 10px 18px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    color: white;
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    animation: toastIn 0.3s ease-out, toastOut 0.3s ease-in forwards;
    animation-delay: 0s, 2.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}
.toast-success { background: linear-gradient(135deg, #059669, #10b981); }
.toast-error { background: linear-gradient(135deg, #dc2626, #f43f5e); }

/* ── Section Headers ── */
.section-header {
    font-size: 13px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 12px;
}

/* ── Tab styling ── */
.tab-bar {
    display: flex;
    gap: 2px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 12px;
    width: fit-content;
    margin-bottom: 24px;
}
.tab-btn {
    padding: 7px 16px;
    border-radius: 9px;
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    background: transparent;
}
.tab-btn:hover { color: #334155; }
.tab-btn.active {
    background: white;
    color: #1e293b;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ── Gmail Body Sandbox ── */
.gmail-body { word-break: break-word; overflow-wrap: break-word; }
.gmail-body img { max-width: 100%; height: auto; }
.gmail-body table { max-width: 100%; font-size: 13px; }
.gmail-body a { color: #6366f1; text-decoration: underline; }

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #94a3b8;
}
.empty-state-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    color: #cbd5e1;
}
.empty-state-text {
    font-size: 14px;
    font-weight: 500;
}

/* ── Progress Bar ── */
.progress-bar {
    height: 6px;
    border-radius: 3px;
    background: #f1f5f9;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* ── Report print styles ── */
@media print {
    .sidebar, header, .no-print, #toast-container { display: none !important; }
    .modal-overlay { position: static !important; background: none !important; backdrop-filter: none !important; }
    .modal-container { box-shadow: none !important; max-height: none !important; border-radius: 0 !important; }
    body { background: white !important; }
    main { padding: 0 !important; }
}

/* ── Mobile responsive ── */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        width: 260px;
        /* G16: restored G13's negative bottom offset on the sidebar
           (G15 had removed it on a wrong assumption — the iOS PWA
           layout viewport empirically stops above the home-indicator
           zone, so `bottom: 0` leaves a body-bg gap below the
           sidebar. Negative offset extends the sidebar element
           through that zone to the actual screen edge.) The G14
           padding-bottom: env(SA) keeps the bottom-most sidebar
           content (Sign-out button) above the home-indicator graphic,
           so the bottom 34px of the sidebar is just gradient
           background, no clickable content in the gesture zone. */
        top: 0;
        bottom: calc(0px - env(safe-area-inset-bottom));
        left: 0;
        height: auto;
        min-height: 0;
        padding-bottom: env(safe-area-inset-bottom);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay {
        display: none;
        position: fixed;
        /* G17: extend overlay through the iOS PWA home-indicator zone
           to the actual screen bottom edge — same short-layout-viewport
           workaround we apply to the sidebar (G16) and the bottom nav
           (G16). `inset: 0` stops at the layout viewport bottom which
           is ~34px above the actual screen edge on iOS PWA, leaving a
           visible body-bg strip below the overlay on the right side
           (the part not covered by the open sidebar). The negative
           bottom offset is a no-op on contexts where env(safe-area-
           inset-bottom) = 0 (desktop, Android without gesture nav). */
        top: 0;
        left: 0;
        right: 0;
        bottom: calc(0px - env(safe-area-inset-bottom));
        background: rgba(0, 0, 0, 0.5);
        z-index: 40;
    }
    .sidebar-overlay.open { display: block; }
    #app-shell { flex-direction: column; }
    main { padding-left: 1rem !important; padding-right: 1rem !important; overflow-x: hidden; }
    main, #app-content, .card, .card > * { max-width: 100%; overflow-wrap: break-word; }
    textarea, input, select { max-width: 100%; min-width: 0; box-sizing: border-box; }
    /* Prevent iOS zoom on input focus — must be 16px+ */
    .form-input, .form-select, textarea.form-input { font-size: 16px !important; }
    header .flex { padding-left: 1rem !important; padding-right: 1rem !important; }
    .modal-container { margin: 1rem; max-height: 90vh; }
    .data-table { font-size: 11px; }
    .data-table th, .data-table td { padding: 6px 8px; }
    .stat-card { padding: 14px; }
    .stat-value { font-size: 22px; }
    .card { padding: 14px; }
    .tab-bar { width: 100%; overflow-x: auto; }
    .tab-btn { padding: 7px 12px; font-size: 12px; white-space: nowrap; }
    .btn-primary, .btn-ghost { padding: 8px 14px; font-size: 12px; }
}

@media (max-width: 480px) {
    main { padding-left: 0.75rem !important; padding-right: 0.75rem !important; }
    /* Prevent horizontal overflow on mobile */
    main, #app-content, .card, .card > * { max-width: 100%; overflow-wrap: break-word; }
    textarea, input, select { max-width: 100%; min-width: 0; box-sizing: border-box; }
    textarea.form-input { resize: vertical; }
    .card { padding: 12px; border-radius: 12px; }
    .stat-card { padding: 12px; }
    .stat-value { font-size: 20px; }
    .data-table { font-size: 12px; }
    .data-table th, .data-table td { padding: 5px 6px; }
    .section-header { font-size: 12px; }
    .btn-primary, .btn-ghost { padding: 7px 12px; font-size: 11px; }
    .btn-sm { padding: 4px 8px; font-size: 11px; }
    .btn-icon { padding: 10px; min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
    .form-input, .form-select { font-size: 16px !important; padding: 8px 10px; }
    input[type="date"].form-input, input[type="datetime-local"].form-input { min-width: 0; -webkit-appearance: none; }
    .badge { font-size: 10px; padding: 2px 8px; }
    .modal-container { margin: 0.5rem; border-radius: 16px; }
    .tab-btn { padding: 6px 10px; font-size: 11px; }
}

/* ── Loading Skeleton ── */
.skeleton { background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%); background-size: 200% 100%; animation: skeleton-shimmer 1.5s ease-in-out infinite; border-radius: 8px; }
.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-text.w-3-4 { width: 75%; }
.skeleton-text.w-1-2 { width: 50%; }
.skeleton-text.w-1-3 { width: 33%; }
.skeleton-circle { border-radius: 50%; }
@keyframes skeleton-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── Animations ── */
.fade-in { animation: fadeIn 0.35s ease-out; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); }

/* ── Line Clamp ── */
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ── WhatsApp Chat Backup ── */
.wa-layout { display: flex; gap: 0; border: 1px solid var(--color-border); border-radius: 12px; overflow: hidden; height: calc(100vh - 220px); min-height: 400px; }
.wa-sidebar { width: 320px; min-width: 260px; border-right: 1px solid var(--color-border); display: flex; flex-direction: column; background: var(--color-bg-secondary); }
.wa-search { padding: 8px; }
.wa-filter-row { padding: 0 8px; }
.wa-chat-list { flex: 1; overflow-y: auto; }
.wa-chat-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--color-border); transition: background .15s; }
.wa-chat-item:hover { background: var(--color-bg-hover); }
.wa-chat-active { background: var(--color-primary-light) !important; }
.wa-chat-icon { font-size: 1.5rem; flex-shrink: 0; }
.wa-chat-info { flex: 1; min-width: 0; }
.wa-chat-name { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-chat-preview { font-size: .78rem; color: var(--color-text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-chat-time { font-size: .7rem; color: var(--color-text-tertiary); white-space: nowrap; flex-shrink: 0; }
.wa-badge { background: var(--color-primary); color: #fff; font-size: .65rem; padding: 1px 5px; border-radius: 10px; margin-left: 4px; }
.wa-badge-new { background: #22c55e; color: #fff; font-size: .65rem; padding: 1px 6px; border-radius: 10px; margin-left: 4px; font-weight: 700; }
.wa-chat-unread { background: #f0fdf4; }
.wa-chat-unread .wa-chat-name { color: #16a34a; }
.wa-new-divider { text-align: center; padding: 8px 0; color: #22c55e; font-size: .75rem; font-weight: 600; }
.wa-main { flex: 1; display: flex; flex-direction: column; }
.wa-msg-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--color-border); background: var(--color-bg-secondary); }
.wa-msg-list { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.wa-msg { max-width: 75%; display: flex; flex-direction: column; }
.wa-msg-me { align-self: flex-end; }
.wa-msg-other { align-self: flex-start; }
.wa-msg-sender { font-size: .7rem; font-weight: 600; color: var(--color-primary); margin-bottom: 1px; margin-left: 8px; }
.wa-msg-bubble { padding: 8px 12px; border-radius: 12px; font-size: .88rem; line-height: 1.4; word-break: break-word; white-space: pre-wrap; }
.wa-msg-me .wa-msg-bubble { background: #dcf8c6; color: #111; border-bottom-right-radius: 4px; }
.wa-msg-other .wa-msg-bubble { background: var(--color-bg-secondary); border-bottom-left-radius: 4px; }
.wa-msg-time { font-size: .65rem; color: var(--color-text-tertiary); margin-top: 2px; padding: 0 8px; }
.wa-msg-me .wa-msg-time { text-align: right; }
@media (max-width: 768px) {
    .wa-layout { flex-direction: column; height: auto; }
    .wa-sidebar { width: 100%; min-width: auto; border-right: none; border-bottom: 1px solid var(--color-border); max-height: 300px; }
}

/* ── Dark Mode ── */
.dark .card { background: #1e293b; border-color: rgba(255,255,255,0.08); box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.dark .card-hover:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.3); }
.dark .modal-container { background: #1e293b; box-shadow: 0 25px 50px rgba(0,0,0,0.5); }
.dark .form-input { background: #0f172a; border-color: #334155; color: #e2e8f0; }
.dark .form-input:focus { border-color: #818cf8; box-shadow: 0 0 0 3px rgba(99,102,241,0.2); }
.dark .form-input::placeholder { color: #475569; }
.dark .form-select { background-color: #0f172a; border-color: #334155; color: #e2e8f0; }
.dark .form-select:focus { border-color: #818cf8; }
.dark .form-label { color: #94a3b8; }
.dark .section-header { color: #e2e8f0; }
.dark .btn-ghost { color: #94a3b8; border-color: #334155; }
.dark .btn-ghost:hover { background: #1e293b; color: #e2e8f0; }
.dark .btn-danger { background: #1c1917; border-color: #7f1d1d; color: #fca5a5; }
.dark .btn-success { background: #022c22; border-color: #065f46; color: #6ee7b7; }
.dark .btn-warning { background: #1c1917; border-color: #78350f; color: #fcd34d; }
.dark .btn-icon { color: #64748b; }
.dark .btn-icon:hover { background: #1e293b; color: #e2e8f0; }
.dark header { background: rgba(15,23,42,0.85) !important; backdrop-filter: blur(20px); border-color: rgba(255,255,255,0.06) !important; }
.dark .nav-group-label { color: rgba(255,255,255,0.7); }
.dark #notif-panel { background: #1e293b; border-color: #334155; }
.dark .toast { background: #1e293b; color: #e2e8f0; border-color: #334155; }
.dark .tab-bar { background: #1e293b; }
.dark .tab-btn { color: #94a3b8; }
.dark .tab-btn:hover { color: #e2e8f0; }
.dark .tab-btn.active { background: #334155; color: #f1f5f9; box-shadow: 0 1px 3px rgba(0,0,0,0.3); }
.dark .data-table th { color: #94a3b8; border-color: #334155; }
.dark .data-table td { border-color: #1e293b; }
.dark .data-table tr:hover { background: #1e293b; }
.dark .empty-state-icon { color: #475569; }
.dark .empty-state-text { color: #64748b; }
.dark .stat-card { background: #1e293b; border-color: rgba(255,255,255,0.06); }
.dark .stat-label { color: #94a3b8; }
.dark .progress-bar { background: #1e293b; }
.dark .badge { border-color: rgba(255,255,255,0.1); }

/* ── Family Notes ── */
.fn-board { columns: 1; column-gap: 1rem; }
@media (min-width: 640px) { .fn-board { columns: 2; } }
@media (min-width: 1024px) { .fn-board { columns: 3; } }
@media (min-width: 1280px) { .fn-board { columns: 4; } }
.fn-card { break-inside: avoid; margin-bottom: 1rem; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

