/* ════════════════════════════════════════════════════════════════
   PWA update banner — shown when a new SW version is waiting.
   User taps "تحديث الآن" → postMessage SKIP_WAITING → page reloads.
   ════════════════════════════════════════════════════════════════ */

@keyframes pwaBannerSlideDown {
    from { transform: translateY(-100%); }
    to   { transform: translateY(0); }
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(-20px) scale(0.95); }
}

/* ============================================= */
.mobile-dashboard { display: none; }

@media (max-width: 768px) {
    .mobile-dashboard {
        display: flex;
        flex-direction: column;
        gap: 12px;
        padding: 4px 2px 0;  
    }
    .dashboard-desktop { display: none !important; }
    /* Bottom-nav clearance — last card sits 12px above the nav (matches card-to-card gap) */
    .main-content > .view {
        padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
    }
    #view-dashboard {
        padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
    }
}

.m-card {
    background: var(--c-surface);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(15,23,42,0.06);
    border: 1px solid var(--c-border);
}
.m-card.m-clickable { cursor: pointer; transition: transform var(--mo-fast) var(--ease-out); }
.m-card.m-clickable:active { transform: scale(0.97); }

.m-label { font-size: 0.78rem; color: var(--text-muted); font-weight: 700; display: block; margin-bottom: 6px; }
/* Section icon before a card label: neutral, never coloured by meaning */
.m-label-ico {
    display: inline-flex; align-items: center; justify-content: center; vertical-align: middle;
    width: 24px; height: 24px; border-radius: var(--radius-sm); font-size: .75rem;
    background: var(--c-primary-soft); color: var(--c-primary);
    margin-inline-end: 6px; flex-shrink: 0;
}
.m-unit { font-size: var(--fs-xs); color: var(--c-text-muted); font-weight: 600; }
.m-row-between { display: flex; justify-content: space-between; align-items: center; }
.m-tiny { font-size: 0.75rem; color: var(--text-faint); }
.m-pill { font-size: 0.75rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: var(--c-surface-2); color: var(--text-strong); }

/* Hero card — RTL-right-aligned with clear hierarchy */
.m-hero {
    background: var(--c-primary);
    color: var(--c-on-primary);
    border: none;
    padding: 16px 18px 14px;
    position: relative;
    overflow: hidden;
}
.m-hero-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 1;
    margin-bottom: 10px;
}
.m-hero-label-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.m-hero-ico {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255,255,255,0.22);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
}
.m-hero-label-txt {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--c-on-primary);
    opacity: 0.95;
}
.m-hero-days {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: var(--c-primary-hover); /* AA: white on it 7.9:1 (a white tint on the hero fell to 4:1) */
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--c-on-primary);
}
.m-hero-days i { font-size: 0.65rem; opacity: 0.85; }
.m-hero-num {
    font-size: 2.1rem;
    font-weight: 800;
    color: var(--c-on-primary);
    line-height: 1.1;
    margin: 4px 0 10px;
    direction: rtl;            /* amount, then «ر.س» on its left */
    text-align: start;
    font-family: var(--font-ui);
    letter-spacing: -0.3px;
    position: relative;
    z-index: 1;
}
.m-hero-num.is-negative { color: var(--c-danger-soft); }
.m-hero-sar {
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0.7;
    margin-inline-start: 4px;
}
.m-hero-note {
    font-size: 0.68rem;
    color: rgba(255,255,255,0.9); /* AA on --c-primary */
    line-height: 1.45;
    text-align: start;
    position: relative;
    z-index: 1;
}

/* Progress bar */
.m-progress {
    height: 10px;
    background: var(--c-surface-2);
    border-radius: 999px;
    overflow: hidden;
    margin: 10px 0 8px;
}
.m-progress-bar {
    height: 100%;
    width: 0%;
    background: var(--c-primary);
}
.m-progress-bar.warn { background: var(--c-warning); }
.m-progress-bar.over { background: var(--c-danger); }

/* Upcoming list */
.m-upcoming { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.m-upcoming-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 10px; background: var(--c-bg); border-radius: 10px;
}
.m-upcoming-row .name { font-size: 0.85rem; color: var(--text-main); font-weight: 600; }
.m-upcoming-row .days { font-size: 0.7rem; color: var(--text-muted); }
.m-upcoming-row .amt { font-size: 0.85rem; font-weight: 700; color: var(--danger-text); font-variant-numeric: tabular-nums; }
.m-upcoming-empty { text-align: center; color: var(--text-faint); font-size: 0.8rem; padding: 14px; }

/* Top categories */
.m-cats { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.m-cat-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; }
.m-cat-row .n { color: var(--text-main); font-weight: 600; }
.m-cat-row .a { color: var(--text-strong); font-variant-numeric: tabular-nums; font-weight: 700; }
.m-cat-empty { text-align: center; color: var(--text-faint); font-size: 0.8rem; padding: 10px; }

/* «يمكنك إنفاقه بأمان» breakdown (features/dashboard/safe-to-spend.js) */
.sts-period { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 10px; }
.sts-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--c-border); }
.sts-row__label { font-weight: 700; color: var(--text-strong); font-size: 0.9rem; }
.sts-row__label small { display: block; font-weight: 500; color: var(--text-faint); font-size: 0.72rem; margin-top: 2px; }
.sts-row__amt { font-weight: 800; white-space: nowrap; }
.sts-row__amt--in { color: var(--success-text); }
.sts-row__amt--out { color: var(--danger-text); }
.sts-items { list-style: none; margin: 4px 0 0; padding: 0 12px 6px 0; font-size: 0.8rem; color: var(--text-muted); }
.sts-items li { display: flex; justify-content: space-between; padding: 3px 0; }
.sts-row--total { border-bottom: 0; border-top: 2px solid var(--c-border); margin-top: 4px; padding-top: 12px; }
.sts-row--total .sts-row__label, .sts-row--total .sts-row__amt { font-size: 1.05rem; color: var(--c-text); }

/* Warranty alert — one compact row under «يمكنك إنفاقه» (features/dashboard/mobile.js) */
.m-alert-row {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    width: 100%;
    min-height: 44px;
    padding: var(--sp-2) var(--sp-3);
    background: var(--c-warning-soft);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    color: var(--c-text);
    font: inherit;
    font-size: var(--fs-sm);
    font-weight: 700;
    text-align: start;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: transform var(--mo-fast) var(--ease-out);
}
.m-alert-row:active { transform: scale(0.97); }
.m-alert-row__icon { color: var(--c-warning); flex-shrink: 0; }
.m-alert-row__text { flex: 1; min-width: 0; }
.m-alert-row__chev { color: var(--c-text-muted); font-size: var(--fs-xs); flex-shrink: 0; }

/* Empty state: one clear first step (accounts card, home) */
.m-empty {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-4) var(--sp-3);
    border: 1px dashed var(--c-border-strong);
    border-radius: var(--radius-md);
    text-align: center;
}
.m-empty__icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-pill);
    background: var(--c-primary-soft);
    color: var(--c-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}
.m-empty__title { font-size: var(--fs-md); font-weight: 800; color: var(--c-text); }
.m-empty__text { font-size: var(--fs-sm); color: var(--c-text-muted); line-height: var(--lh-body); max-width: 30ch; }
.m-empty__btn { margin-top: var(--sp-1); }
.m-accounts-wrap.is-empty .m-accounts-sum { display: none; }
