/* ══════════════════════════════════════════════════════════════
   Pioneer System — Mobile-First Design System
   Base = Phone → min-width for larger screens
   ══════════════════════════════════════════════════════════════ */

/* ── DESIGN TOKENS ── */
:root {
    --primary-50: #eef2ff;
    --primary-100: #e0e7ff;
    --primary-200: #c7d2fe;
    --primary-300: #a5b4fc;
    --primary-400: #818cf8;
    --primary-500: #6366f1;
    --primary-600: #4f46e5;
    --primary-700: #4338ca;

    --neutral-50: #f8fafc;
    --neutral-100: #f1f5f9;
    --neutral-200: #e2e8f0;
    --neutral-300: #cbd5e1;
    --neutral-400: #94a3b8;
    --neutral-500: #64748b;
    --neutral-600: #475569;
    --neutral-700: #334155;
    --neutral-800: #1e293b;
    --neutral-900: #0f172a;

    --success: #10b981;
    --success-bg: #ecfdf5;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --info: #06b6d4;
    --info-bg: #ecfeff;

    --blue: #3b82f6;
    --purple: #8b5cf6;
    --indigo: #6366f1;
    --cyan: #06b6d4;
    --emerald: #10b981;
    --amber: #f59e0b;
    --rose: #f43f5e;
    --orange: #f97316;

    --max-width: 1400px;
    --nav-height: 56px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);

    --font-sans: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --transition-fast: 150ms cubic-bezier(.4,0,.2,1);
    --transition-base: 200ms cubic-bezier(.4,0,.2,1);
}

/* ── RESET ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
body {
    font-family: var(--font-sans);
    background: var(--neutral-50);
    color: var(--neutral-800);
    min-height: 100vh;
    min-height: 100dvh;
    direction: rtl;
    line-height: 1.5;
    overflow-x: hidden;
}
a { color: var(--primary-600); text-decoration: none; }
img { max-width: 100%; height: auto; }
input, select, button { font-family: var(--font-sans); }

/* ══════════════════════════════════════
   TOP BAR
   ══════════════════════════════════════ */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: 52px;
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-bottom: 1px solid var(--neutral-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.85rem;
}
.topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--neutral-900);
}
.topbar-logo {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.7rem;
    font-weight: 800;
    flex-shrink: 0;
}
.topbar-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary-600);
}
.topbar-sync {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.7rem;
    color: var(--neutral-400);
}
.sync-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
    flex-shrink: 0;
}
.sync-dot.warn { background: var(--warning); }
.sync-text { white-space: nowrap; }

/* ══════════════════════════════════════
   BOTTOM TAB BAR (Mobile Native)
   ══════════════════════════════════════ */
.bottombar {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    z-index: 100;
    background: rgba(255,255,255,.95);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-top: 1px solid var(--neutral-200);
    display: flex;
    align-items: stretch;
    height: 60px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottombar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    text-decoration: none;
    color: var(--neutral-400);
    -webkit-tap-highlight-color: transparent;
    transition: color var(--transition-fast);
    position: relative;
    padding: 0.35rem 0;
}
.bottombar-item:active { color: var(--primary-500); }
.bottombar-item.active {
    color: var(--primary-600);
}
.bottombar-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 2.5px;
    background: var(--primary-600);
    border-radius: 0 0 4px 4px;
}
.bottombar-icon {
    font-size: 1.25rem;
    line-height: 1;
    height: 1.35rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.bottombar-label {
    font-size: 0.58rem;
    font-weight: 500;
    line-height: 1;
}
.bottombar-item.active .bottombar-label {
    font-weight: 700;
}
.bottombar-more {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    color: var(--neutral-400);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    padding: 0.35rem 0;
    border: none;
    background: none;
    font-family: var(--font-sans);
}
.bottombar-more:active { color: var(--primary-500); }
.bottombar-more .bottombar-icon {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -2px;
}

/* ══════════════════════════════════════
   MORE DRAWER (Bottom Sheet)
   ══════════════════════════════════════ */
.more-drawer {
    display: none;
}
.more-drawer.open {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 200;
}
.more-drawer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.4);
    animation: fadeIn 0.2s ease;
}
.more-drawer-sheet {
    position: absolute;
    bottom: 0;
    right: 0;
    left: 0;
    background: white;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    padding: 0.75rem 0;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    animation: slideUp 0.25s cubic-bezier(.32,.72,0,1);
    max-height: 70vh;
    overflow-y: auto;
}
.more-drawer-handle {
    width: 36px;
    height: 4px;
    background: var(--neutral-300);
    border-radius: 2px;
    margin: 0 auto 0.65rem;
}
.more-drawer-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--neutral-500);
    padding: 0 1rem 0.5rem;
    border-bottom: 1px solid var(--neutral-100);
    margin-bottom: 0.35rem;
}
.more-drawer-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    text-decoration: none;
    color: var(--neutral-700);
    font-size: 0.9rem;
    font-weight: 500;
    -webkit-tap-highlight-color: transparent;
    transition: background var(--transition-fast);
}
.more-drawer-item:active { background: var(--neutral-50); }
.more-drawer-item.active {
    color: var(--primary-600);
    background: var(--primary-50);
    font-weight: 600;
}
.more-drawer-icon { font-size: 1.15rem; width: 1.5rem; text-align: center; flex-shrink: 0; }
.more-drawer-label { flex: 1; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ══════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════ */
.app-content {
    padding: 0.75rem;
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px) + 0.75rem);
}

/* ══════════════════════════════════════
   PAGE HEADER
   ══════════════════════════════════════ */
.page-header { margin-bottom: 1rem; }
.page-header h1 { font-size: 1.25rem; font-weight: 700; color: var(--neutral-900); letter-spacing: -0.02em; }
.page-header p { color: var(--neutral-500); font-size: 0.78rem; margin-top: 0.15rem; }
@media (min-width: 768px) {
    .page-header { margin-bottom: 1.5rem; }
    .page-header h1 { font-size: 1.75rem; }
    .page-header p { font-size: 0.9rem; margin-top: 0.25rem; }
}

/* ══════════════════════════════════════
   STAT CARDS — 2 col mobile, expand up
   ══════════════════════════════════════ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.stat-card {
    background: white;
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 3px;
    height: 100%;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.stat-card.blue::before { background: var(--blue); }
.stat-card.purple::before { background: var(--purple); }
.stat-card.green::before { background: var(--emerald); }
.stat-card.red::before { background: var(--rose); }
.stat-card.orange::before { background: var(--orange); }
.stat-card.cyan::before { background: var(--cyan); }
.stat-card.indigo::before { background: var(--indigo); }

.stat-card .stat-icon { font-size: 1rem; margin-bottom: 0.35rem; }
.stat-card .stat-value { font-size: 1.15rem; font-weight: 700; color: var(--neutral-900); line-height: 1.2; }
.stat-card .stat-label { color: var(--neutral-500); font-size: 0.68rem; font-weight: 500; margin-top: 0.1rem; }
.stat-card .stat-change { font-size: 0.65rem; font-weight: 600; margin-top: 0.3rem; display: inline-flex; align-items: center; gap: 0.2rem; padding: 0.15rem 0.4rem; border-radius: var(--radius-full); }
.stat-card .stat-change.up { color: var(--success); background: var(--success-bg); }
.stat-card .stat-change.down { color: var(--danger); background: var(--danger-bg); }

@media (min-width: 480px) {
    .stats-grid { gap: 0.65rem; }
    .stat-card { padding: 0.85rem; }
    .stat-card .stat-value { font-size: 1.3rem; }
    .stat-card .stat-label { font-size: 0.72rem; }
}
@media (min-width: 768px) {
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.75rem; margin-bottom: 1.25rem; }
    .stat-card { padding: 1.1rem 1.25rem; border-radius: var(--radius-lg); }
    .stat-card .stat-icon { width: 36px; height: 36px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center; font-size: 1.1rem; margin-bottom: 0.6rem; }
    .stat-card .stat-value { font-size: 1.6rem; }
    .stat-card .stat-label { font-size: 0.8rem; }
}

/* ── STAT PILLS ── */
.stats-row { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-bottom: 1rem; }
.stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: white;
    border: 1px solid var(--neutral-200);
    padding: 0.35rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--neutral-600);
}
.stat-pill .pill-value { font-weight: 700; color: var(--neutral-900); }
.stat-pill.green { border-color: #a7f3d0; color: #065f46; }
.stat-pill.green .pill-value { color: #047857; }
.stat-pill.red { border-color: #fecaca; color: #991b1b; }
.stat-pill.red .pill-value { color: #dc2626; }
.stat-pill.blue { border-color: #bfdbfe; color: #1e40af; }
.stat-pill.blue .pill-value { color: #2563eb; }
.stat-pill.orange { border-color: #fed7aa; color: #9a3412; }
.stat-pill.orange .pill-value { color: #ea580c; }
.stat-pill.purple { border-color: #ddd6fe; color: #5b21b6; }
.stat-pill.purple .pill-value { color: #7c3aed; }

@media (min-width: 480px) {
    .stats-row { gap: 0.45rem; }
    .stat-pill { font-size: 0.75rem; padding: 0.4rem 0.8rem; }
}

/* ══════════════════════════════════════
   CARDS
   ══════════════════════════════════════ */
.card {
    background: white;
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 0.75rem;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    border-bottom: 1px solid var(--neutral-100);
    gap: 0.5rem;
}
.card-header h3 { font-size: 0.85rem; font-weight: 600; color: var(--neutral-800); }
.card-body { padding: 0.75rem; }
.card-body.no-padding { padding: 0; }

@media (min-width: 768px) {
    .card { border-radius: var(--radius-lg); margin-bottom: 1rem; }
    .card-header { padding: 1rem 1.25rem; }
    .card-header h3 { font-size: 0.95rem; }
    .card-body { padding: 1.25rem; }
}

.mb-3 { margin-bottom: 0.75rem; }
@media (min-width: 768px) { .mb-3 { margin-bottom: 1.25rem; } }

/* ══════════════════════════════════════
   TABLES — Horizontal scroll on mobile
   ══════════════════════════════════════ */
.table-engine { position: relative; }

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.72rem;
    min-width: 600px;
}
.data-table th {
    background: var(--neutral-50);
    color: var(--neutral-500);
    font-weight: 600;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.55rem 0.5rem;
    text-align: right;
    border-bottom: 1px solid var(--neutral-200);
    position: sticky;
    top: 0;
    white-space: nowrap;
    z-index: 1;
}
.data-table td {
    padding: 0.5rem 0.5rem;
    border-bottom: 1px solid var(--neutral-100);
    color: var(--neutral-700);
    vertical-align: middle;
    white-space: nowrap;
}
.data-table tbody tr { transition: background var(--transition-fast); }
.data-table tbody tr:active { background: var(--neutral-50); }
.data-table tbody tr:last-child td { border-bottom: none; }

.data-table.compact th { font-size: 0.62rem; padding: 0.45rem 0.45rem; }
.data-table.compact td { padding: 0.4rem 0.45rem; font-size: 0.68rem; }

.data-table .amount {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.72rem;
    direction: ltr;
    text-align: right;
    white-space: nowrap;
}
.data-table .amount.positive { color: var(--success); }
.data-table .amount.negative { color: var(--danger); }

@media (min-width: 480px) {
    .data-table { font-size: 0.78rem; min-width: 700px; }
    .data-table th { font-size: 0.68rem; padding: 0.6rem 0.6rem; }
    .data-table td { padding: 0.55rem 0.6rem; }
    .data-table.compact th { font-size: 0.65rem; }
    .data-table.compact td { font-size: 0.72rem; padding: 0.45rem 0.5rem; }
}
@media (min-width: 768px) {
    .data-table { font-size: 0.85rem; min-width: auto; }
    .data-table th { font-size: 0.75rem; padding: 0.75rem 1rem; }
    .data-table td { padding: 0.75rem 1rem; }
    .data-table.compact th, .data-table.compact td { padding: 0.6rem 0.75rem; font-size: 0.8rem; }
}

/* ══════════════════════════════════════
   BADGES
   ══════════════════════════════════════ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.45rem;
    border-radius: var(--radius-full);
    font-size: 0.6rem;
    font-weight: 600;
    white-space: nowrap;
    line-height: 1.4;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #cffafe; color: #155e75; }
.badge-neutral { background: var(--neutral-100); color: var(--neutral-600); }
.badge-primary { background: var(--primary-100); color: var(--primary-700); }
.badge-purple { background: #ede9fe; color: #5b21b6; }

@media (min-width: 768px) {
    .badge { font-size: 0.7rem; padding: 0.2rem 0.6rem; }
}

/* ══════════════════════════════════════
   TABLE ENGINE — Toolbar (Mobile-First)
   ══════════════════════════════════════ */
.ts-toolbar {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.6rem;
    background: var(--neutral-50);
    border-bottom: 1px solid var(--neutral-200);
}
.ts-search {
    width: 100%;
    padding: 0.6rem 0.75rem 0.6rem 2.2rem;
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    background: #fff 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='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242.156a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E") no-repeat right 0.65rem center;
    font-family: var(--font-sans);
    transition: border-color var(--transition-fast);
}
.ts-search:focus { outline: none; border-color: var(--primary-400); }
.ts-search::placeholder { color: var(--neutral-400); }

.ts-filters {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.ts-filter {
    width: 100%;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    background: #fff;
    color: var(--neutral-700);
    cursor: pointer;
    appearance: auto;
    -webkit-appearance: auto;
}

.ts-date-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    direction: rtl;
}
.ts-date-group label { font-size: 0.72rem; color: var(--neutral-500); white-space: nowrap; }
.ts-date-input {
    flex: 1;
    min-width: 0;
    padding: 0.5rem 0.5rem;
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    background: #fff;
    color: var(--neutral-700);
    direction: ltr;
}
.ts-date-input:focus { outline: none; border-color: var(--primary-400); }

@media (min-width: 480px) {
    .ts-filters { flex-direction: row; flex-wrap: wrap; }
    .ts-filter { width: auto; min-width: 130px; }
}

@media (min-width: 768px) {
    .ts-toolbar {
        flex-direction: row;
        align-items: center;
        gap: 0.6rem;
        padding: 0.75rem 1rem;
    }
    .ts-search { max-width: 300px; flex: 0 0 auto; }
    .ts-filters { flex-direction: row; }
    .ts-filter { min-width: 120px; }
    .ts-date-group { flex-direction: row; }
    .ts-date-input { flex: 0 0 auto; min-width: 140px; }
}

/* ══════════════════════════════════════
   TABLE ENGINE — Pagination (Mobile-First)
   ══════════════════════════════════════ */
.ts-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.6rem;
    background: var(--neutral-50);
    border-top: 1px solid var(--neutral-200);
}
.ts-page-info { font-size: 0.7rem; color: var(--neutral-500); white-space: nowrap; }
.ts-page-controls { display: flex; align-items: center; gap: 0.2rem; }

.ts-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.8rem;
    height: 1.8rem;
    padding: 0 0.35rem;
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--neutral-600);
    font-size: 0.72rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}
.ts-page-btn:active:not(:disabled) { background: var(--neutral-100); }
.ts-page-btn.active { background: var(--primary-600); border-color: var(--primary-600); color: #fff; font-weight: 600; }
.ts-page-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.ts-page-nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.8rem;
    height: 1.8rem;
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--neutral-600);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}
.ts-page-nav:active:not(:disabled) { background: var(--neutral-100); }
.ts-page-nav:disabled { opacity: 0.35; cursor: not-allowed; }

.ts-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.2rem;
    height: 1.8rem;
    color: var(--neutral-400);
    font-size: 0.8rem;
}

.ts-empty td { padding: 2rem 0.75rem !important; font-size: 0.85rem; text-align: center; }

@media (min-width: 480px) {
    .ts-page-btn, .ts-page-nav { min-width: 2rem; height: 2rem; }
    .ts-page-info { font-size: 0.75rem; }
}
@media (min-width: 768px) {
    .ts-pagination { padding: 0.6rem 1rem; }
    .ts-page-btn { font-size: 0.8rem; }
}

/* ══════════════════════════════════════
   CLICKABLE NAMES
   ══════════════════════════════════════ */
.clickable-name {
    cursor: pointer;
    color: var(--primary-600);
    font-weight: 500;
    border-bottom: 1px dashed var(--primary-300);
    padding: 2px 0;
    -webkit-tap-highlight-color: transparent;
    transition: all var(--transition-fast);
}
.clickable-name:active {
    color: var(--primary-700);
    background: var(--primary-50);
    border-radius: 3px;
    padding: 2px 4px;
    margin: 0 -4px;
}

/* ══════════════════════════════════════
   DEBT SUMMARY
   ══════════════════════════════════════ */
.debt-summary {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.debt-card {
    background: white;
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-md);
    padding: 1rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.debt-card::before { content: ''; position: absolute; top: 0; right: 0; left: 0; height: 3px; }
.debt-card.pending::before { background: var(--warning); }
.debt-card.paid::before { background: var(--success); }
.debt-card.total::before { background: var(--primary-500); }
.debt-card .debt-icon { font-size: 1.2rem; margin-bottom: 0.5rem; }
.debt-card .debt-label { font-size: 0.78rem; color: var(--neutral-500); }
.debt-card .debt-amount { font-size: 1.4rem; font-weight: 700; margin: 0.3rem 0; }
.debt-card.pending .debt-amount { color: var(--warning); }
.debt-card.paid .debt-amount { color: var(--success); }
.debt-card.total .debt-amount { color: var(--primary-600); }
.debt-card .debt-count { font-size: 0.68rem; color: var(--neutral-400); }

@media (min-width: 480px) {
    .debt-summary { grid-template-columns: repeat(3, 1fr); }
}

/* ══════════════════════════════════════
   ALERTS
   ══════════════════════════════════════ */
.alerts { display: flex; flex-direction: column; gap: 0.4rem; }
.alert-badge {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-md);
    font-size: 0.78rem;
    font-weight: 500;
    width: 100%;
    justify-content: center;
}
.alert-badge.warn { background: var(--warning-bg); color: #92400e; border: 1px solid #fde68a; }
.alert-badge.danger { background: var(--danger-bg); color: #991b1b; border: 1px solid #fecaca; }
.alert-badge.info { background: var(--info-bg); color: #155e75; border: 1px solid #a5f3fc; }
.alert-badge.success { background: var(--success-bg); color: #166534; border: 1px solid #bbf7d0; }

@media (min-width: 768px) {
    .alerts { flex-direction: row; flex-wrap: wrap; }
    .alert-badge { width: auto; }
}

/* ══════════════════════════════════════
   HERO (Index page)
   ══════════════════════════════════════ */
.hero {
    text-align: center;
    padding: 2rem 0.75rem 1.5rem;
    position: relative;
}
.hero::before {
    content: '';
    position: absolute;
    top: -50%;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(99,102,241,.08) 0%, transparent 70%);
    pointer-events: none;
}
.hero h1 {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-600), var(--purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.03em;
    line-height: 1.1;
}
.hero-sub { color: var(--neutral-500); font-size: 0.85rem; margin-top: 0.5rem; }
.hero-sync {
    margin-top: 1rem;
    font-size: 0.78rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.8rem;
    background: white;
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-full);
}
.hero-sync::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--success); }
.hero-sync.warn { color: var(--warning); border-color: #fde68a; }
.hero-sync.warn::before { background: var(--warning); }

@media (min-width: 768px) {
    .hero { padding: 3rem 2rem 2rem; }
    .hero h1 { font-size: 2.75rem; }
    .hero-sub { font-size: 1.05rem; }
    .hero::before { width: 500px; height: 500px; }
}

/* ══════════════════════════════════════
   NAV GRID (Index page)
   ══════════════════════════════════════ */
.nav-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
    margin-top: 1.25rem;
}
.grid-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: white;
    border: 1px solid var(--neutral-200);
    border-radius: var(--radius-md);
    padding: 0.85rem;
    color: var(--neutral-800);
    text-decoration: none;
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}
.grid-card:active { background: var(--neutral-50); transform: scale(0.98); }
.grid-card-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    background: var(--neutral-50);
    flex-shrink: 0;
}
.grid-card-body h3 { font-size: 0.88rem; font-weight: 600; color: var(--neutral-800); }
.grid-card-body p { font-size: 0.72rem; color: var(--neutral-400); margin-top: 0.1rem; }

@media (min-width: 480px) {
    .nav-grid { grid-template-columns: repeat(2, 1fr); gap: 0.65rem; }
}
@media (min-width: 768px) {
    .nav-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 0.75rem; max-width: 1000px; margin-left: auto; margin-right: auto; margin-top: 1.5rem; }
    .grid-card { padding: 1.1rem 1.25rem; border-radius: var(--radius-lg); }
    .grid-card-icon { width: 48px; height: 48px; font-size: 1.35rem; }
    .grid-card-body h3 { font-size: 0.95rem; }
    .grid-card-body p { font-size: 0.8rem; }
}

/* ══════════════════════════════════════
   EMPTY STATE
   ══════════════════════════════════════ */
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--neutral-400); }
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.5; }
.empty-state h3 { font-size: 0.9rem; font-weight: 600; color: var(--neutral-600); margin-bottom: 0.15rem; }
.empty-state p { font-size: 0.8rem; color: var(--neutral-400); }

/* ══════════════════════════════════════
   FILTERS (Legacy)
   ══════════════════════════════════════ */
.filters { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.filter-input, .filter-select {
    width: 100%;
    background: white;
    border: 1px solid var(--neutral-200);
    color: var(--neutral-800);
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    transition: all var(--transition-fast);
}
.filter-input:focus, .filter-select:focus { outline: none; border-color: var(--primary-400); box-shadow: 0 0 0 3px rgba(99,102,241,.1); }
.filter-input::placeholder { color: var(--neutral-400); }

@media (min-width: 768px) {
    .filters { flex-direction: row; flex-wrap: wrap; align-items: center; }
    .filter-input, .filter-select { width: auto; min-width: 160px; }
}

/* ══════════════════════════════════════
   FOOTER
   ══════════════════════════════════════ */
.footer {
    text-align: center;
    padding: 1.25rem 0.75rem;
    padding-bottom: calc(1.25rem + var(--safe-bottom));
    color: var(--neutral-400);
    font-size: 0.68rem;
    border-top: 1px solid var(--neutral-100);
    margin-top: 1.5rem;
}
@media (min-width: 768px) {
    .footer { padding: 1.5rem 2rem; font-size: 0.75rem; margin-top: 2.5rem; }
}

/* ══════════════════════════════════════
   UTILITY
   ══════════════════════════════════════ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.text-muted { color: var(--neutral-400); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.font-mono { font-family: var(--font-mono); }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ══════════════════════════════════════
   QUICK FILTER PILLS
   ══════════════════════════════════════ */
.ts-active-filter {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.6rem;
    background: var(--primary-50);
    border: 1px solid var(--primary-200);
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    color: var(--primary-700);
    font-weight: 500;
}
.ts-active-filter button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    border: none;
    background: var(--primary-200);
    color: var(--primary-700);
    border-radius: 50%;
    font-size: 0.55rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}
.ts-active-filter button:active { background: var(--primary-400); color: #fff; }

/* ══════════════════════════════════════
   SCROLLBAR (thin on mobile)
   ══════════════════════════════════════ */
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--neutral-300); border-radius: 10px; }
@media (min-width: 768px) {
    ::-webkit-scrollbar { width: 6px; height: 6px; }
}

/* ══════════════════════════════════════
   TOUCH HELPERS
   ══════════════════════════════════════ */
@media (hover: none) and (pointer: coarse) {
    .data-table tbody tr { min-height: 44px; }
    .ts-page-btn, .ts-page-nav { min-height: 36px; min-width: 36px; }
    .clickable-name { padding: 4px 2px; }
}

/* ── CHART ── */
.chart-container { position: relative; width: 100%; max-height: 350px; margin: 0.5rem 0; }

/* ── SIMPLE TABLE (performance) ── */
.table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.table th, .table td { padding: 0.6rem 0.75rem; text-align: right; border-bottom: 1px solid var(--neutral-100); }
.table th { background: var(--neutral-50); font-weight: 600; color: var(--neutral-600); font-size: 0.75rem; }
.table td { color: var(--neutral-800); }
.table tbody tr:hover { background: var(--neutral-50); }
.text-green { color: var(--success); }
.text-blue { color: var(--primary-600); }
.text-red { color: var(--danger); }
.text-orange { color: var(--warning); }

/* ══════════════════════════════════════
   PERFORMANCE COMPARISON
   ══════════════════════════════════════ */
.perf-form { background: var(--neutral-50); border-radius: var(--radius-md); padding: 0.75rem; margin-bottom: 1rem; border: 1px solid var(--neutral-200); }
.perf-periods { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 0.75rem; }
.perf-period { background: white; border: 1px solid var(--neutral-200); border-radius: var(--radius-sm); padding: 0.75rem; }
.perf-period-header { font-weight: 700; font-size: 0.85rem; color: var(--success); margin-bottom: 0.4rem; }
.perf-period-header.perf-p2 { color: var(--primary-600); }
.perf-fields { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; font-size: 0.8rem; }
.perf-input { border: 1px solid var(--neutral-300); border-radius: var(--radius-sm); padding: 0.35rem 0.5rem; font-size: 0.8rem; }
.perf-btn { background: var(--primary-600); color: #fff; border: none; border-radius: var(--radius-sm); padding: 0.5rem 1.25rem; font-size: 0.85rem; font-weight: 600; cursor: pointer; width: 100%; }
.perf-btn:active { background: var(--primary-700); }

.perf-summary { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.perf-summary-col { text-align: center; }
.perf-summary-label { font-weight: 800; font-size: 1rem; color: var(--success); }
.perf-summary-label.perf-p2 { color: var(--primary-600); }
.perf-summary-dates { font-size: 0.75rem; color: var(--neutral-500); margin: 0.15rem 0; }
.perf-summary-days { font-size: 0.75rem; color: var(--neutral-400); }
.perf-vs { font-size: 1.1rem; font-weight: 800; color: var(--neutral-400); padding: 0 0.5rem; }

.perf-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin-bottom: 1rem; }
.perf-card { background: white; border: 1px solid var(--neutral-200); border-radius: var(--radius-md); padding: 0.75rem; position: relative; }
.perf-card-header { display: flex; align-items: center; gap: 0.35rem; font-weight: 600; font-size: 0.8rem; color: var(--neutral-700); margin-bottom: 0.5rem; }
.perf-card-icon { font-size: 1.1rem; }
.perf-card.green { border-top: 3px solid var(--success); }
.perf-card.blue { border-top: 3px solid var(--primary-500); }
.perf-card.red { border-top: 3px solid var(--danger); }
.perf-card.orange { border-top: 3px solid var(--warning); }
.perf-card-values { display: flex; flex-direction: column; gap: 0.4rem; }
.perf-card-p1 { }
.perf-card-amount { font-weight: 700; font-size: 1rem; color: var(--neutral-900); }
.perf-card-count { font-size: 0.65rem; color: var(--neutral-400); }
.perf-card-p2 { }
.perf-card-amount-sm { font-weight: 600; font-size: 0.85rem; color: var(--neutral-600); }

.growth-badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: var(--radius-full); font-size: 0.7rem; font-weight: 700; margin-top: 0.4rem; }
.growth-badge.up { background: #dcfce7; color: #166534; }
.growth-badge.down { background: #fce7e7; color: #991b1b; }

.perf-net { display: flex; align-items: center; justify-content: center; gap: 1rem; flex-wrap: wrap; padding: 0.5rem 0; }
.perf-net-item { text-align: center; }
.perf-net-label { font-size: 0.75rem; color: var(--neutral-500); margin-bottom: 0.2rem; }
.perf-net-value { font-weight: 800; font-size: 1.35rem; }
.perf-vs-small { font-weight: 600; color: var(--neutral-400); font-size: 0.85rem; }

.perf-avgs { }
.perf-avg-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0; border-bottom: 1px solid var(--neutral-100); }
.perf-avg-row:last-child { border-bottom: none; }
.perf-avg-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.perf-avg-dot.green { background: var(--success); }
.perf-avg-dot.blue { background: var(--primary-500); }
.perf-avg-dot.red { background: var(--danger); }
.perf-avg-dot.orange { background: var(--warning); }
.perf-avg-label { flex: 1; font-size: 0.8rem; color: var(--neutral-600); }
.perf-avg-value { font-weight: 700; font-size: 0.85rem; min-width: 70px; text-align: left; direction: ltr; }
.perf-avg-value-sm { font-weight: 500; font-size: 0.8rem; color: var(--neutral-500); min-width: 70px; text-align: left; direction: ltr; }

@media (min-width: 768px) {
    .perf-form { padding: 1rem; }
    .perf-periods { flex-direction: row; }
    .perf-period { flex: 1; }
    .perf-metrics { grid-template-columns: repeat(4, 1fr); }
    .perf-btn { width: auto; }
}
