@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
    --teal: #0d9488;
    --teal-dark: #0f766e;
    --purple: #7c3aed;
    --orange: #f97316;
    --ink: #1e1b2e;
    --muted: #6b7280;
    --bg: #f7f6fb;
    --panel: #ffffff;
    --border: #e6e3f0;
    --danger: #dc2626;
    --success: #16a34a;
    --radius: 12px;
}

/* Business space swaps the accent emphasis toward purple/orange to stay visually distinct from personal */
body.space-business {
    --accent-primary: var(--purple);
    --accent-secondary: var(--orange);
}
body.space-personal {
    --accent-primary: var(--teal);
    --accent-secondary: var(--purple);
}

* { box-sizing: border-box; }

html { overflow-x: hidden; }

body {
    margin: 0;
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--ink);
}

.money {
    font-family: 'Space Mono', monospace;
}

a { color: var(--accent-primary, var(--teal)); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- App shell (phone first) ---- */
.mobile-topbar {
    display: flex;
    align-items: center;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--ink);
    color: #fff;
    padding: 8px 10px;
    padding-top: max(8px, env(safe-area-inset-top));
}
.mobile-topbar .brand { margin: 0; font-size: 16px; flex-shrink: 0; }
.mobile-topbar .space-switch {
    margin: 0 0 0 auto;
    max-width: 168px;
}
.mobile-topbar .space-btn { font-size: 12px; padding: 6px 8px; }
.nav-toggle {
    width: 44px;
    height: 44px;
    border: 0;
    background: transparent;
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    flex-shrink: 0;
}
.nav-toggle span {
    display: block;
    height: 2px;
    background: #fff;
    border-radius: 2px;
}
.nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 12, 28, 0.45);
    z-index: 55;
}
body.nav-open .nav-overlay { display: block; }
body.nav-open { overflow: hidden; }

.app-shell {
    display: block;
    min-height: 100vh;
}

@media (max-width: 900px) {
    .has-tabbar .mobile-topbar { display: none; }
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 60;
    width: min(300px, 88vw);
    background: var(--ink);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 12px 14px 16px;
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    overflow: hidden;
}
body.nav-open .sidebar { transform: translateX(0); }
.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
    flex-shrink: 0;
}
.sidebar-head .brand { margin: 0; display: block; font-size: 18px; }
.nav-close {
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid rgba(255,255,255,.25);
    border-radius: 8px;
    background: transparent;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.sidebar-kind {
    margin: 0 0 12px;
    padding: 8px 12px;
    border-radius: 10px;
    background: rgba(255,255,255,0.08);
    color: #e2e8f0;
    font-size: 13px;
    font-weight: 700;
}

.brand {
    font-weight: 700;
    font-size: 20px;
    margin-bottom: 24px;
}
.brand span { color: var(--orange); }

.space-switch {
    display: flex;
    background: rgba(255,255,255,0.08);
    border-radius: 999px;
    padding: 4px;
    margin-bottom: 12px;
}
.space-btn {
    flex: 1;
    text-align: center;
    padding: 6px 10px;
    border-radius: 999px;
    color: #cbd5e1;
    font-size: 13px;
    font-weight: 600;
}
.space-btn:hover { text-decoration: none; }
.space-btn.active {
    background: linear-gradient(135deg, var(--teal), var(--purple));
    color: #fff;
}
body.space-business .space-btn.active {
    background: linear-gradient(135deg, var(--purple), var(--orange));
}

.main-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.nav-label {
    margin: 10px 12px 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #94a3b8;
}
.nav-label:first-child { margin-top: 0; }
.main-nav a {
    color: #cbd5e1;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 500;
}
.main-nav a:hover { background: rgba(255,255,255,0.08); text-decoration: none; color: #fff; }
.main-nav a.active { background: rgba(255,255,255,0.12); color: #fff; }

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.12);
    margin-top: 8px;
    padding-top: 12px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: #cbd5e1;
}
.sidebar-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    text-decoration: none;
}
.sidebar-profile:hover { text-decoration: none; color: #fff; }
.sidebar-avatar {
    width: 40px;
    height: 40px;
    font-size: 15px;
    flex-shrink: 0;
    box-shadow: none;
}
.sidebar-user { font-size: 13px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-logout {
    display: block;
    text-align: center;
    min-height: 44px;
    padding: 12px;
    border-radius: 10px;
    background: rgba(220, 38, 38, 0.18);
    color: #fecaca;
    font-size: 15px;
    font-weight: 700;
}
.sidebar-logout:hover { text-decoration: none; background: rgba(220, 38, 38, 0.28); color: #fff; }
.sw-card-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 10px;
}
.sw-card-toolbar-title {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
}
.hide-bal-btn {
    flex-shrink: 0;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--panel);
    color: var(--ink);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}
.hide-bal-btn:hover { background: var(--bg); }
body:not(.balances-hidden) .hide-bal-when-hidden { display: none; }
body.balances-hidden .hide-bal-when-shown { display: none; }
body.balances-hidden .money {
    color: transparent !important;
    text-shadow: none !important;
    user-select: none;
    position: relative;
}
body.balances-hidden .money::after {
    content: "••••••";
    color: var(--ink);
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    letter-spacing: .14em;
    pointer-events: none;
}
body.balances-hidden .sw-card .money::after {
    color: #fff;
}
body.balances-hidden .sw-card-pay.money::after {
    font-size: 28px;
}

.content {
    padding: 16px 14px 24px;
    max-width: none;
    overflow-x: hidden;
}

@media (min-width: 901px) {
    .mobile-topbar,
    .nav-overlay,
    .nav-close,
    .tabbar { display: none !important; }
    body.nav-open { overflow: auto; }
    .app-shell {
        display: flex;
        min-height: 100vh;
    }
    .sidebar {
        position: relative;
        transform: none;
        width: 232px;
        flex-shrink: 0;
        padding: 24px 16px;
        z-index: auto;
        overflow: hidden;
    }
    body.nav-open .sidebar { transform: none; }
    .sidebar-head { margin-bottom: 16px; }
    .sidebar-head .brand { font-size: 20px; }
    .content {
        flex: 1;
        padding: 32px 40px;
        max-width: 1100px;
        padding-bottom: 32px;
    }
}

/* ---- Common elements ---- */
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.page-head h1 { margin: 0; font-size: 24px; }
.page-head-sub {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 14px;
    font-weight: 400;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 24px;
}
.panel h2 { margin-top: 0; font-size: 16px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.two-col { display: grid; grid-template-columns: 1fr; gap: 16px; }
.purpose-line { margin: -4px 0 16px; color: var(--muted); font-size: 14px; max-width: 640px; }
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.kpi-grid-2 { grid-template-columns: 1fr 1fr; }
.kpi-grid-3 { grid-template-columns: 1fr 1fr; }
.kpi-card.available { grid-column: 1 / -1; }
.quick-grid { display: grid; grid-template-columns: 1fr; gap: 16px; margin-bottom: 16px; }
.pot-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }

@media (min-width: 901px) {
    .two-col { grid-template-columns: 1fr 1fr; gap: 24px; }
    .purpose-line { margin: -8px 0 24px; }
    .kpi-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
    .kpi-grid-2 { grid-template-columns: 1fr 1fr; }
    .kpi-grid-3 { grid-template-columns: repeat(3, 1fr); }
    .kpi-card.available { grid-column: auto; }
    .quick-grid { grid-template-columns: repeat(2, 1fr); gap: 24px; margin-bottom: 24px; }
    .pot-grid { grid-template-columns: 1fr 1fr; gap: 24px; }
}
.kpi-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.kpi-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 18px; font-weight: 700; line-height: 1.25; }
.kpi-sub { font-size: 12px; color: var(--muted); }
.kpi-target { font-size: 14px; font-weight: 500; color: var(--muted); }
.sw-live-hero { border: 2px solid var(--teal); }
.sw-hero-nums {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin: 8px 0 12px;
}
.sw-hero-value { font-size: 32px; color: var(--teal); }
@media (min-width: 901px) {
    .sw-hero-nums { grid-template-columns: 1fr 1fr; gap: 24px; }
    .sw-hero-value { font-size: 36px; }
}
.kpi-card.available { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.12); }
.sw-wallet-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.sw-wallet-list li {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
}
.sw-wallet-main { display: flex; flex-direction: column; gap: 2px; min-width: 160px; flex: 1; }
.sw-wallet-bal { display: grid; grid-template-columns: auto auto; gap: 2px 12px; align-items: baseline; }
.sw-wallet-list .tag { align-self: flex-start; }
.sw-card-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    margin-bottom: 8px;
}
.sw-card {
    background: linear-gradient(145deg, var(--sw-from, #0f766e), var(--sw-to, #2dd4bf));
    color: #fff;
    border-radius: 20px;
    padding: 20px 18px 16px;
    min-height: 220px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
}
.sw-card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sw-card-kicker { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; opacity: .85; }
.sw-card-badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.sw-card-badge {
    font-size: 11px;
    font-weight: 700;
    background: rgba(255,255,255,.2);
    border-radius: 999px;
    padding: 4px 8px;
}
.sw-card-space { width: 100%; margin: 0 0 8px; }
.sw-card-space label { color: #fff; font-size: 12px; }
.sw-card-space select {
    width: 100%;
    margin-top: 4px;
    background: rgba(255,255,255,.16);
    color: #fff;
    border: 1px solid rgba(255,255,255,.3);
    border-radius: 8px;
    padding: 8px;
}
.sw-card-space option { color: #1e1b2e; }
.sw-card-name { margin: 10px 0 4px; font-size: 18px; color: #fff; text-transform: none; letter-spacing: 0; }
.sw-card-channel {
    display: inline-block;
    align-self: flex-start;
    margin: 0 0 12px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(255,255,255,.18);
    border: 1px solid rgba(255,255,255,.28);
    border-radius: 999px;
}
.sw-card-label { margin: 0; font-size: 12px; opacity: .85; }
.sw-card-pay { margin: 0 0 4px; font-size: 32px; font-weight: 700; line-height: 1.1; }
.sw-card-split {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px 16px;
    margin: 0 0 10px;
}
.sw-card-split > div + div {
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,.2);
}
.sw-card-pay-alt { font-size: 26px; }
.sw-card-hint { margin: 0; font-size: 11px; opacity: .8; }
.choice-pills.dest-pills legend {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    font-size: 13px;
    font-weight: 600;
    margin: 0 0 6px;
    grid-column: 1 / -1;
}
.sw-card-svc {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0 0 16px;
    font-size: 13px;
    opacity: .9;
}
.sw-card-topup {
    margin-left: auto;
    color: #fff;
    font-weight: 700;
    font-size: 12px;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.sw-card-error { margin: 0 0 8px; font-size: 13px; color: #fecaca; }
.sw-card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.sw-card-actions .btn { min-height: 40px; }
.sw-card-actions form { display: contents; }
.sw-card-actions form.sw-card-space { display: block; width: 100%; flex-basis: 100%; }
.sw-card-foot { margin: 4px 0 18px; }
.sw-card-foot a { color: var(--accent-primary, var(--teal)); }
@media (min-width: 901px) {
    .sw-card-grid { grid-template-columns: repeat(2, 1fr); gap: 18px; }
    .sw-card-pay { font-size: 36px; }
    .sw-card-split { grid-template-columns: 1fr 1fr; }
    .sw-card-split > div + div {
        padding-top: 0;
        padding-left: 16px;
        border-top: 0;
        border-left: 1px solid rgba(255,255,255,.2);
    }
}
.kpi-card.available .kpi-value { color: var(--teal); }
.pot-card .pot-actions { margin-top: 12px; }
.stk-form .stk-phone input {
    font-size: 18px;
    padding: 12px 10px;
}
.stk-wait { border-color: var(--teal); }
.stk-status { font-weight: 600; }
code { font-size: 13px; background: var(--bg); padding: 1px 6px; border-radius: 4px; }
.positive { color: var(--success); }
.negative { color: var(--danger); }

/* ---- Forms ---- */
form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 12px;
}
form input, form select {
    font-family: inherit;
    font-size: 14px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--ink);
}
.txn-form, .filter-form {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    align-items: stretch;
}
.txn-form label, .filter-form { margin-bottom: 0; }
.txn-form .grow { min-width: 0; }
.txn-form label,
.filter-form select,
.filter-form input[type="date"] {
    width: 100%;
    min-width: 0;
}
.filter-form select,
.filter-form input[type="date"],
.filter-form .btn {
    min-height: 44px;
}
.page-transactions .panel {
    padding: 16px 14px;
    overflow: visible;
}
.txn-ledger h2 { margin-bottom: 4px; }
.txn-ledger-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.txn-ledger-head h2 { margin: 0; }
.txn-ledger-count { font-size: 12px; color: var(--muted); }
.txn-filters { margin-bottom: 8px; }
.txn-wallet-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px 0 12px;
    margin: 0 0 4px;
}
.txn-wallet-tab {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--ink);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}
.txn-wallet-tab:hover { text-decoration: none; background: var(--bg); }
.txn-wallet-tab.active {
    background: var(--txn-from, var(--accent-primary, var(--teal)));
    border-color: transparent;
    color: #fff;
}
.txn-row.txn-wallet,
.txn-history .txn-row {
    margin: 6px 0;
    padding: 12px 12px 12px 10px;
    border-bottom: 0;
    border-radius: 12px;
    border-left: 4px solid var(--txn-from, var(--teal));
    background: color-mix(in srgb, var(--txn-from, var(--teal)) 8%, white);
}
.txn-wallet-badge {
    display: inline-block;
    margin-top: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    background: color-mix(in srgb, var(--txn-from, var(--teal)) 16%, white);
    color: var(--txn-from, var(--teal));
}
.txn-live-badge {
    margin-left: 6px;
    opacity: .85;
    font-weight: 600;
}
.txn-status-pill {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}
.txn-status-pill.is-pending {
    background: #fef3c7;
    color: #92400e;
}
.txn-status-pill.is-failed {
    background: #fee2e2;
    color: #991b1b;
}
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
.txn-recat {
    margin: 8px 0 0;
}
.txn-recat select {
    width: auto;
    max-width: 100%;
    font-size: 13px;
    min-height: 36px;
    padding: 4px 8px;
}
.txn-day { margin-top: 18px; }
.txn-day:first-of-type { margin-top: 8px; }
.txn-day-label {
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
}
.txn-history { list-style: none; margin: 0; padding: 0; }
.txn-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.txn-row:last-child { border-bottom: 0; }
.txn-mark {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    background: var(--bg);
    color: var(--muted);
}
.txn-row-expense .txn-mark {
    background: color-mix(in srgb, var(--danger) 12%, white);
    color: var(--danger);
}
.txn-row-income .txn-mark {
    background: color-mix(in srgb, var(--success) 12%, white);
    color: var(--success);
}
.txn-row-transfer .txn-mark {
    background: color-mix(in srgb, var(--purple) 12%, white);
    color: var(--purple);
}
.txn-row-body { flex: 1; min-width: 0; }
.txn-row-title {
    margin: 0;
    font-weight: 600;
    font-size: 15px;
    word-break: break-word;
}
.txn-row-sub {
    margin: 2px 0 0;
    font-size: 13px;
    color: var(--muted);
    word-break: break-word;
}
.txn-receipt {
    margin: 6px 0 0;
    font-size: 12px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.txn-receipt code {
    font-family: 'Space Mono', monospace;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--ink);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 3px 8px;
}
.txn-row-body .tag { margin-top: 6px; }
.txn-row .money {
    flex-shrink: 0;
    font-size: 14px;
    text-align: right;
    padding-top: 8px;
}
@media (min-width: 901px) {
    .txn-form, .filter-form {
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
        align-items: flex-end;
    }
    .txn-form .grow { flex: 1; min-width: 180px; }
    .txn-form label,
    .filter-form select,
    .filter-form input[type="date"] { width: auto; }
    .page-transactions .panel { padding: 22px 24px; }
    .txn-filters {
        display: flex;
        flex-wrap: wrap;
        align-items: stretch;
    }
    .txn-filters select,
    .txn-filters input[type="date"] { flex: 1; min-width: 140px; }
}
.inline-form { display: inline-block; margin: 0; }

.btn {
    display: inline-block;
    border: none;
    border-radius: 8px;
    padding: 9px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    color: #fff;
    background: var(--accent-primary, var(--teal));
}
.btn:hover { opacity: 0.9; text-decoration: none; }
.btn-primary { background: linear-gradient(135deg, var(--teal), var(--purple)); }
body.space-business .btn-primary { background: linear-gradient(135deg, var(--purple), var(--orange)); }
.btn-small { padding: 5px 10px; font-size: 12px; background: var(--muted); }
.btn-danger { background: var(--danger); }
.btn-ghost {
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); }
.btn-on-dark { background: #fff; color: #134e4a; }
.btn-on-dark-ghost {
    background: transparent;
    color: #fff;
    border: 1px solid rgba(255,255,255,.45);
}
.btn-on-dark-ghost:hover { background: rgba(255,255,255,.12); }
.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}
.btn-row .btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.fee-notes { margin: 12px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }
#b2c-fees { scroll-margin-top: 72px; }

/* ---- Tables ---- */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
    text-align: left;
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .03em;
    border-bottom: 2px solid var(--border);
    padding: 8px 6px;
}
.data-table td { padding: 10px 6px; border-bottom: 1px solid var(--border); }
.text-right { text-align: right; }
.row-muted { opacity: 0.5; }
.empty-state { color: var(--muted); font-size: 14px; }

.tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: color-mix(in srgb, var(--tag-color, var(--teal)) 15%, white);
    color: var(--tag-color, var(--teal));
}

/* ---- Category / budget bars ---- */
.category-bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.category-bar-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.category-bar-track { background: var(--bg); border-radius: 999px; height: 8px; overflow: hidden; }
.category-bar-fill { height: 100%; border-radius: 999px; }
.category-bar-fill.over-budget { background: var(--danger) !important; }

.txn-list { list-style: none; margin: 0; padding: 0; }
.txn-list li {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.txn-list li:last-child { border-bottom: 0; }
.txn-list-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.txn-list .money { flex-shrink: 0; font-size: 13px; }

/* ---- Bar chart (reports) ---- */
.bar-chart { display: flex; align-items: flex-end; gap: 18px; height: 180px; padding-top: 10px; }
.bar-chart-col { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; height: 100%; justify-content: flex-end; }
.bar-chart-bars { display: flex; align-items: flex-end; gap: 4px; height: 100%; width: 100%; justify-content: center; }
.bar { width: 16px; border-radius: 3px 3px 0 0; min-height: 2px; }
.bar.income { background: var(--teal); }
.bar.expense { background: var(--orange); }
.bar-chart-label { font-size: 12px; color: var(--muted); }
.legend { display: flex; gap: 16px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.dot.income { background: var(--teal); }
.dot.expense { background: var(--orange); }
.report-month {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}
.report-month input[type="month"] {
    min-height: 40px;
    padding: 6px 10px;
}
.report-delta.is-up { color: #dc2626; }
.report-delta.is-down { color: #15803d; }
.bar-chart-weeks { height: 140px; }

/* ---- Alerts ---- */
.alert { padding: 10px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-success { background: #ecfdf5; color: var(--success); border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }

/* ---- Auth pages (PayApp home look) ---- */
.auth-page {
    display: block;
    min-height: 100vh;
    background: var(--bg);
}
.auth-shell {
    max-width: 440px;
    margin: 0 auto;
    min-height: 100vh;
    padding-bottom: 28px;
}
.auth-hero {
    background: linear-gradient(165deg, #5b8def 0%, #3b82f6 42%, #2563eb 100%);
    color: #fff;
    padding: 22px 20px 52px;
    padding-top: max(22px, env(safe-area-inset-top));
    border-radius: 0 0 28px 28px;
}
.auth-hero-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.auth-hero .pay-hello { margin: 0; }
.auth-hero-sub {
    margin: 14px 0 0;
    font-size: 13px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.88);
}
.auth-card {
    background: #fff;
    margin: -32px 16px 0;
    padding: 22px 20px 24px;
    border-radius: 18px;
    width: auto;
    max-width: none;
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.12);
}
.auth-card h1 { margin: 0 0 4px; font-size: 20px; }
.auth-card-kicker {
    margin: 0 0 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}
.auth-subtitle { color: var(--muted); margin-top: 0; margin-bottom: 20px; font-size: 14px; }
.auth-switch { text-align: center; font-size: 13px; color: var(--muted); margin-top: 16px; }
.auth-switch a { font-weight: 700; }
.auth-page form label { font-weight: 600; color: #64748b; }
.auth-page form input {
    min-height: 48px;
    padding: 12px 14px;
    border-radius: 14px;
    background: #f7f6fb;
    border: 1px solid var(--border);
    font-size: 16px;
}
.auth-page .btn-primary,
.auth-page form .btn-primary {
    width: 100%;
    min-height: 48px;
    border-radius: 14px;
    background: linear-gradient(165deg, #3b82f6, #2563eb);
    box-shadow: 0 10px 20px rgba(37, 99, 235, 0.22);
}
.auth-page .btn-ghost {
    width: 100%;
    min-height: 48px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: #fff;
    color: #1d4ed8;
    font-weight: 700;
}
#login-bio { width: 100%; margin-bottom: 4px; }
@media (min-width: 901px) {
    .auth-shell { padding: 24px 0 40px; }
    .auth-hero { border-radius: 24px; margin: 0 16px; }
    .auth-card { margin-top: -28px; }
    .auth-page form .btn-primary { width: 100%; }
}

.pwa-install-auth { text-align: center; margin: 16px 0 0; }
.pwa-install-bar {
    position: sticky;
    bottom: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    background: var(--ink);
    color: #fff;
    font-size: 13px;
}
.pwa-install-bar[hidden],
.pwa-install-auth[hidden] { display: none !important; }
.offline-banner {
    display: none;
    position: sticky;
    bottom: 0;
    margin: 0;
    padding: 8px 14px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    background: #fef3c7;
    color: #92400e;
    font-size: 13px;
    text-align: center;
}
body.is-offline .offline-banner { display: block; }
@media (display-mode: standalone) {
    .pwa-install-bar { display: none !important; }
}

.kpi-value { overflow-wrap: anywhere; }
.money { overflow-wrap: anywhere; }
.stk-form .btn-primary,
form .btn-primary { width: 100%; }
.btn { min-height: 44px; }
form input, form select { font-size: 16px; width: 100%; max-width: 100%; }

@media (min-width: 901px) {
    .kpi-value { font-size: 22px; }
    .stk-form .btn-primary,
    form .btn-primary { width: auto; }
    .btn { min-height: 0; }
}

.sidebar-user { display: flex; flex-direction: column; gap: 2px; }
.sidebar-handle { font-size: 12px; color: #94a3b8; font-weight: 500; }
.choice-pills {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 0 0 4px;
    padding: 0;
    border: 0;
}
.choice-pills legend {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}
.choice-pills label {
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    background: var(--bg);
    text-align: center;
    padding: 8px;
}
.choice-pills input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.choice-pills label:has(input:checked) {
    border-color: var(--accent-primary, var(--teal));
    background: color-mix(in srgb, var(--accent-primary, var(--teal)) 12%, white);
    color: var(--accent-primary, var(--teal));
}

.debt-section-title {
    margin: 8px 0 12px;
    font-size: 16px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.debt-card { margin-bottom: 0; }
.debt-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 10px;
}
.debt-person { margin: 0; font-weight: 700; font-size: 16px; }
.debt-overdue { border-color: var(--danger); }
.debt-overdue .kpi-sub { color: var(--danger); }
.debt-card .pot-actions + .pot-actions { margin-top: 8px; }

.lock-card h1 span { color: var(--orange); }
.lock-pin-form { margin-top: 16px; }
.lock-error { margin: 0 0 12px; }
.lock-error[hidden] { display: none !important; }
#login-bio { width: 100%; margin-bottom: 8px; }

/* ---- PayApp-inspired phone shell (original Fedha styles) ---- */
.has-tabbar .content {
    padding-bottom: 108px;
}
body.has-tabbar .pwa-install-bar {
    bottom: 76px;
}
.tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 52;
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    gap: 2px;
    padding: 6px 6px max(8px, env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 -10px 30px rgba(30, 27, 46, 0.08);
    border-top: 1px solid rgba(230, 227, 240, 0.8);
}
.tabbar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 2px;
    border: 0;
    background: none;
    color: #9aa3b2;
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
}
.tabbar-item svg { width: 22px; height: 22px; }
.tabbar-item:hover { text-decoration: none; color: #64748b; }
.tabbar-item.active { color: #3b82f6; }
.tabbar-home { position: relative; }
.tabbar-home-btn {
    width: 52px;
    height: 52px;
    margin-top: -22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #3b82f6;
    color: #fff;
    box-shadow: 0 10px 20px rgba(59, 130, 246, 0.4);
}
.tabbar-home-btn svg { width: 24px; height: 24px; }
.tabbar-home.active { color: #3b82f6; }
.tabbar-home.active .tabbar-home-btn { background: #2563eb; }

.page-dashboard .content {
    padding-left: 0;
    padding-right: 0;
    padding-top: 0;
}
.page-dashboard .alert {
    margin: 12px 16px 0;
}
.pay-hero {
    background: linear-gradient(165deg, #5b8def 0%, #3b82f6 42%, #2563eb 100%);
    color: #fff;
    padding: 18px 0 28px;
    border-radius: 0 0 28px 28px;
    margin-bottom: 8px;
}
body.space-business .pay-hero {
    background: linear-gradient(165deg, #8b5cf6 0%, #7c3aed 50%, #c2410c 120%);
}
.pay-hero-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 8px 18px 14px;
}
.pay-greet { min-width: 0; flex: 1; }
.pay-date {
    margin: 0 0 10px;
    display: inline-block;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.18);
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.95);
}
.pay-hello {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 20px;
    font-weight: 600;
    line-height: 1.3;
    color: #fff;
}
.pay-hello-name {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 999px;
    background: #fff;
    color: #1d4ed8;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
}
body.space-business .pay-hello-name { color: #6d28d9; }
.pay-hero-tools { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.pay-icon-btn.hide-bal-btn {
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.95);
    color: #1e293b;
    display: grid;
    place-items: center;
}
.pay-icon-btn.hide-bal-btn svg { width: 20px; height: 20px; display: block; }
.pay-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #fff;
    color: #2563eb;
    font-weight: 700;
    font-size: 16px;
    display: grid;
    place-items: center;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
    overflow: hidden;
}
.pay-avatar.has-photo { padding: 0; }
.pay-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.pay-avatar-link { display: block; border-radius: 50%; }
.pay-avatar-link:hover { text-decoration: none; }
body.space-business .pay-avatar { color: #7c3aed; }
.profile-avatar-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    flex-wrap: wrap;
}
.profile-avatar-preview {
    width: 88px;
    height: 88px;
    font-size: 32px;
    flex-shrink: 0;
}
.profile-avatar-actions { flex: 1; min-width: 200px; }
.pay-space-row {
    display: flex;
    gap: 8px;
    padding: 12px 18px 10px;
}
.pay-space-chip {
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255,255,255,0.16);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}
.pay-space-chip:hover { text-decoration: none; background: rgba(255,255,255,0.24); }
.pay-space-chip.active { background: #fff; color: #2563eb; }
.pay-hero .sw-card-toolbar.is-compact,
.pay-hero .sw-card-actions.is-compact,
.pay-hero .sw-card-foot.is-compact { display: none; }
.pay-hero .pay-empty-wallet { margin: 0 16px; }
.sw-card-grid.sw-card-carousel {
    display: flex;
    overflow-x: auto;
    gap: 14px;
    padding: 4px 18px 6px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}
.sw-card-carousel .sw-card {
    min-width: min(82vw, 340px);
    flex: 0 0 auto;
    scroll-snap-align: start;
    min-height: 168px;
    border-radius: 18px;
    box-shadow: 0 16px 32px rgba(15, 23, 42, 0.18);
}
.pay-body { padding: 8px 16px 0; }
.pay-quick {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 4px 0 16px;
}
.pay-quick-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--ink);
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}
.pay-quick-item:hover { text-decoration: none; }
.pay-quick-icon {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 8px 20px rgba(30, 27, 46, 0.06);
    display: grid;
    place-items: center;
    font-size: 20px;
}
.pay-quick-in { color: #16a34a; }
.pay-quick-out { color: #dc2626; }
.pay-quick-pot { color: #7c3aed; }
.pay-quick-debt { color: #2563eb; }
.pay-view-all {
    float: right;
    font-size: 13px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
}
.page-dashboard .kpi-card,
.page-dashboard .panel {
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(30, 27, 46, 0.04);
}

@media (min-width: 901px) {
    .tabbar { display: none !important; }
    .has-tabbar .content { padding-bottom: 32px; }
    body.has-tabbar .pwa-install-bar { bottom: 16px; }
    .page-dashboard .content {
        padding: 24px 40px 32px;
    }
    .pay-hero { border-radius: 24px; margin-bottom: 20px; }
    .sw-card-carousel .sw-card { min-width: 320px; }
}

.pay-avail {
    padding: 4px 18px 16px;
}
.pay-avail-label {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255,255,255,0.8);
}
.pay-avail-value {
    margin: 2px 0 6px;
    font-size: 34px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: #fff;
}
.pay-avail-eq {
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: 600;
    color: rgba(255,255,255,0.88);
}
.pay-avail-eq .money { color: #fff; }
.pay-locked-line {
    display: inline-block;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    opacity: 0.92;
}
.pay-locked-line:hover { text-decoration: underline; color: #fff; }

.recip-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 12px;
}
.recip-chip {
    border: 0;
    border-radius: 999px;
    padding: 8px 12px;
    background: #eef2ff;
    color: #1e3a8a;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}
.recip-chip:hover { background: #dbeafe; }
.recip-chip.is-on { background: #2563eb; color: #fff; }

.confirm-sheet {
    position: fixed;
    inset: 0;
    z-index: 80;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 16px;
}
.confirm-sheet[hidden] { display: none; }
.confirm-sheet-card {
    width: min(480px, 100%);
    background: #fff;
    border-radius: 20px 20px 16px 16px;
    padding: 20px 18px 16px;
    box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.2);
}
.confirm-sheet-card h2 { margin: 0 0 12px; }
.confirm-sheet-rows { margin: 0 0 16px; }
.confirm-sheet-rows div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid #eef2f7;
    font-size: 14px;
}
.confirm-sheet-rows dt { color: #64748b; font-weight: 600; }
.confirm-sheet-rows dd { margin: 0; font-weight: 700; text-align: right; }

.done-card { text-align: center; padding: 28px 18px; }
.done-kicker {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
}
.done-amount { font-size: 36px; font-weight: 800; margin: 0 0 8px; }
.done-phone { margin: 0 0 8px; font-size: 16px; }
.done-receipt { margin: 16px 0 8px; }
.done-actions { justify-content: center; }

.pot-move { display: grid; gap: 8px; }
.pot-use { margin-top: 8px; }
.pot-more { margin: 10px 0; }
.pot-more summary { cursor: pointer; font-weight: 700; color: #334155; }

