/* === Phony Wallet — pay.phony.cam ===
   Default theme: monochrome (B&W). Switchable via [data-theme="..."] on body. */

/* Base resets and tokens */
:root {
    /* These are overridden by the body[data-theme] block below.
       The base values here are the monochrome theme. */
    --bg-base: #08080a;
    --bg-1: #0c0c0f;
    --bg-2: #11111a;
    --text: #fafafa;
    --text-muted: #8a8b94;
    --rim: rgba(255,255,255,0.07);
    --rim-strong: rgba(255,255,255,0.14);

    --primary: #f5f5f7;
    --primary-2: #d4d4d8;
    --primary-3: #a1a1aa;
    --on-primary: #08080a;

    --accent-glow: rgba(255,255,255,0.12);
    --accent-glow-strong: rgba(255,255,255,0.20);

    --success: #cfcfcf;
    --warn: #d4d4d8;
    --danger: #f5b3b3;

    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 22px;
    --radius-xl: 28px;
    --blur: 14px;
    --liquid-strong: 0 30px 80px -20px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.04) inset;
    --ease: cubic-bezier(.22,.78,.36,1);
}

/* === Themes === */
body[data-theme="mono"] {
    --bg-base: #08080a;
    --bg-1: #0c0c0f;
    --bg-2: #11111a;
    --text: #fafafa;
    --text-muted: #8a8b94;
    --primary: #f5f5f7;
    --primary-2: #d4d4d8;
    --primary-3: #a1a1aa;
    --on-primary: #08080a;
    --accent-glow: rgba(255,255,255,0.12);
    --accent-glow-strong: rgba(255,255,255,0.20);
    --success: #e7e7e9;
    --warn: #d4d4d8;
    --danger: #f5b3b3;
}
body[data-theme="midnight"] {
    --bg-base: #050510;
    --bg-1: #0a0d1f;
    --bg-2: #10142b;
    --text: #f5f5f7;
    --text-muted: #8b8fa6;
    --primary: #4f7cff;
    --primary-2: #6c5ce7;
    --primary-3: #8b6ff8;
    --on-primary: #fff;
    --accent-glow: rgba(79,124,255,0.20);
    --accent-glow-strong: rgba(108,92,231,0.32);
    --success: #6ee7b7;
    --warn: #fbbf24;
    --danger: #f87171;
}
body[data-theme="violet"] {
    --bg-base: #0a0612;
    --bg-1: #120a22;
    --bg-2: #1a0f30;
    --text: #f5f5f7;
    --primary: #a855f7;
    --primary-2: #c084fc;
    --primary-3: #ec4899;
    --on-primary: #fff;
    --accent-glow: rgba(168,85,247,0.22);
    --accent-glow-strong: rgba(236,72,153,0.30);
    --success: #6ee7b7;
}
body[data-theme="azure"] {
    --bg-base: #04070f;
    --bg-1: #06121f;
    --bg-2: #0a1c30;
    --text: #f5f5f7;
    --primary: #38bdf8;
    --primary-2: #0ea5e9;
    --primary-3: #06b6d4;
    --on-primary: #04070f;
    --accent-glow: rgba(56,189,248,0.22);
    --accent-glow-strong: rgba(14,165,233,0.30);
    --success: #6ee7b7;
}
body[data-theme="emerald"] {
    --bg-base: #050d0a;
    --bg-1: #07171f;
    --bg-2: #0a1f24;
    --text: #f5f5f7;
    --primary: #10b981;
    --primary-2: #34d399;
    --primary-3: #14b8a6;
    --on-primary: #04140e;
    --accent-glow: rgba(16,185,129,0.22);
    --accent-glow-strong: rgba(52,211,153,0.30);
    --success: #34d399;
}
body[data-theme="amber"] {
    --bg-base: #0c0905;
    --bg-1: #1a130a;
    --bg-2: #241a0d;
    --text: #fafafa;
    --primary: #f59e0b;
    --primary-2: #fbbf24;
    --primary-3: #f97316;
    --on-primary: #110a02;
    --accent-glow: rgba(245,158,11,0.22);
    --accent-glow-strong: rgba(249,115,22,0.30);
}
body[data-theme="rose"] {
    --bg-base: #0d050a;
    --bg-1: #1a0a13;
    --bg-2: #240e1a;
    --text: #fafafa;
    --primary: #f43f5e;
    --primary-2: #fb7185;
    --primary-3: #ec4899;
    --on-primary: #fff;
    --accent-glow: rgba(244,63,94,0.22);
    --accent-glow-strong: rgba(236,72,153,0.30);
}
body[data-theme="sand"] {
    --bg-base: #0e0c08;
    --bg-1: #1a1610;
    --bg-2: #241f17;
    --text: #f5efde;
    --text-muted: #a89e87;
    --primary: #d4a574;
    --primary-2: #c8956a;
    --primary-3: #b8845a;
    --on-primary: #1a1208;
    --accent-glow: rgba(212,165,116,0.22);
    --accent-glow-strong: rgba(184,132,90,0.30);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg-base); color: var(--text); font-family: 'Inter', -apple-system, sans-serif; min-height: 100vh; }
body {
    background:
        radial-gradient(ellipse 80% 50% at 80% -10%, var(--accent-glow-strong), transparent 60%),
        radial-gradient(ellipse 60% 40% at 10% 100%, var(--accent-glow), transparent 60%),
        var(--bg-base);
    overflow-x: hidden;
    transition: background .3s var(--ease);
}
/* iPhone notch / Dynamic Island safe-area for PWA installed mode */
@supports (padding-top: env(safe-area-inset-top)) {
    .app-header {
        padding-top: calc(14px + env(safe-area-inset-top));
        padding-left: calc(22px + env(safe-area-inset-left));
        padding-right: calc(22px + env(safe-area-inset-right));
    }
    #login-screen.active {
        padding-top: calc(24px + env(safe-area-inset-top));
        padding-bottom: calc(24px + env(safe-area-inset-bottom));
    }
    .app-main {
        padding-left: calc(18px + env(safe-area-inset-left));
        padding-right: calc(18px + env(safe-area-inset-right));
        padding-bottom: calc(60px + env(safe-area-inset-bottom));
    }
    .app-foot {
        padding-bottom: calc(30px + env(safe-area-inset-bottom));
    }
    #toast-container {
        bottom: calc(20px + env(safe-area-inset-bottom));
    }
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: 0; background: none; color: inherit; }

.muted { color: var(--text-muted); font-size: 13px; }
.glass {
    background: rgba(15,15,18,0.7);
    border: 1px solid var(--rim);
    backdrop-filter: blur(var(--blur)) saturate(170%);
    -webkit-backdrop-filter: blur(var(--blur)) saturate(170%);
}

/* SVG icons (use href="#i-*") */
.ic    { width: 20px; height: 20px; flex-shrink: 0; display: inline-block; vertical-align: middle; }
.ic-sm { width: 16px; height: 16px; flex-shrink: 0; display: inline-block; vertical-align: middle; }

/* === Screens === */
.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }

/* === Login screen === */
#login-screen.active {
    display: flex; align-items: center; justify-content: center; padding: 24px; position: relative;
}
.login-bg { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.orb {
    position: absolute; border-radius: 50%; filter: blur(80px); opacity: .55;
}
.orb-1 { width: 500px; height: 500px; left: -150px; top: -150px; background: radial-gradient(circle, var(--accent-glow-strong), transparent 70%); }
.orb-2 { width: 600px; height: 600px; right: -200px; bottom: -200px; background: radial-gradient(circle, var(--accent-glow), transparent 70%); }

.login-card {
    width: 100%; max-width: 440px;
    padding: 36px 32px; border-radius: var(--radius-xl);
    z-index: 1;
    box-shadow: var(--liquid-strong);
    animation: pop .4s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

.brand {
    display: inline-flex; align-items: center; gap: 10px;
    margin-bottom: 24px;
}
.brand-mark {
    width: 36px; height: 36px; border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    display: flex; align-items: center; justify-content: center;
    color: var(--on-primary);
    box-shadow: 0 6px 20px var(--accent-glow-strong);
}
.brand-mark .ic { width: 20px; height: 20px; }
.brand-text { font-weight: 800; font-size: 20px; letter-spacing: -.02em; }
.brand-tag {
    font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
    background: var(--rim);
    color: var(--text);
    border: 1px solid var(--rim-strong);
    text-transform: uppercase; letter-spacing: .5px;
}

.login-card h1 { font-size: 26px; font-weight: 700; margin-bottom: 6px; letter-spacing: -.02em; }
.login-card .muted { margin-bottom: 24px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text-muted); }
input[type="text"], input[type="password"], input[type="number"], input[type="email"] {
    width: 100%; padding: 13px 16px; font-size: 16px;
    background: rgba(255,255,255,0.04);
    border: 1.5px solid var(--rim); border-radius: 12px;
    color: var(--text); font-family: inherit; outline: none;
    transition: border-color .2s, background .2s;
}
input:focus { border-color: var(--primary); background: rgba(255,255,255,0.06); }

.error-msg {
    background: rgba(245,179,179,0.1); color: var(--danger);
    border: 1px solid rgba(245,179,179,0.3); border-radius: 10px;
    padding: 10px 14px; margin-bottom: 14px; font-size: 13px;
}

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 20px; border-radius: 12px; font-weight: 600; font-size: 14px; transition: all .2s; cursor: pointer; }
.btn-block { width: 100%; }
.btn-large { padding: 15px 22px; font-size: 16px; min-height: 50px; }
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: var(--on-primary); border: 0;
    box-shadow: 0 8px 24px var(--accent-glow-strong);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 32px var(--accent-glow-strong); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-secondary { background: rgba(255,255,255,0.06); border: 1px solid var(--rim); color: var(--text); }
.btn-secondary:hover { background: rgba(255,255,255,0.1); }

.login-foot { text-align: center; margin-top: 18px; }
.login-foot a { color: var(--text-muted); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.login-foot a:hover { color: var(--text); }

/* === App layout === */
.app-header {
    position: sticky; top: 0; z-index: 50;
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 22px;
    border-bottom: 1px solid var(--rim);
    backdrop-filter: blur(20px) saturate(170%);
    -webkit-backdrop-filter: blur(20px) saturate(170%);
    background: rgba(8,8,10,0.7);
}
.brand-small .brand-mark { width: 32px; height: 32px; }
.brand-small .brand-text { font-size: 16px; }
.brand-small .brand-tag { font-size: 9.5px; padding: 2px 6px; }

.header-right { display: flex; align-items: center; gap: 8px; }
.user-pill {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 12px 6px 6px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--rim);
    border-radius: 999px;
}
.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    color: var(--on-primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px;
}
.user-meta { line-height: 1.1; }
.user-name { font-weight: 600; font-size: 13px; }
.user-id { font-size: 11px; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }

.icon-btn {
    width: 36px; height: 36px; border-radius: 10px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--rim);
    color: var(--text-muted);
    display: inline-flex; align-items: center; justify-content: center;
    transition: all .15s;
}
.icon-btn:hover { background: rgba(255,255,255,0.08); color: var(--text); }
.icon-btn.small { width: 30px; height: 30px; }
.icon-btn.small .ic-sm { width: 14px; height: 14px; }

/* Theme popover */
.theme-popover {
    position: absolute;
    top: 70px;
    right: 22px;
    z-index: 100;
    padding: 16px;
    border-radius: 18px;
    background: rgba(15,15,18,0.92);
    border: 1px solid var(--rim-strong);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    width: 260px;
    animation: pop .2s var(--ease);
}
.theme-popover-title { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .8px; margin-bottom: 12px; }
.theme-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.theme-swatch {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--rim);
    color: var(--text);
    font-size: 13px; font-weight: 500;
    transition: all .15s;
}
.theme-swatch:hover { background: rgba(255,255,255,0.06); }
.theme-swatch.active { border-color: var(--primary); background: rgba(255,255,255,0.06); }
.theme-swatch .sw {
    width: 22px; height: 22px; border-radius: 7px;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.1) inset;
    flex-shrink: 0;
}
.sw.mono     { background: linear-gradient(135deg, #f5f5f7, #a1a1aa); }
.sw.midnight { background: linear-gradient(135deg, #4f7cff, #6c5ce7); }
.sw.violet   { background: linear-gradient(135deg, #a855f7, #ec4899); }
.sw.azure    { background: linear-gradient(135deg, #38bdf8, #06b6d4); }
.sw.emerald  { background: linear-gradient(135deg, #10b981, #14b8a6); }
.sw.amber    { background: linear-gradient(135deg, #f59e0b, #f97316); }
.sw.rose     { background: linear-gradient(135deg, #f43f5e, #ec4899); }
.sw.sand     { background: linear-gradient(135deg, #d4a574, #b8845a); }

.app-main {
    max-width: 980px; margin: 0 auto;
    padding: 24px 18px 60px;
    display: flex; flex-direction: column; gap: 22px;
}

/* === Balance card === */
.balance-card {
    position: relative;
    padding: 28px 28px 24px;
    border-radius: var(--radius-xl);
    border-color: var(--rim-strong);
    overflow: hidden;
    background: linear-gradient(135deg, var(--accent-glow), var(--accent-glow) 30%, rgba(15,15,18,0.7));
    box-shadow: var(--liquid-strong);
}
.balance-glow {
    position: absolute; top: -50%; right: -20%;
    width: 80%; height: 200%;
    background: radial-gradient(ellipse 50% 40% at 50% 50%, var(--accent-glow-strong), transparent 70%);
    filter: blur(40px); pointer-events: none;
}
.balance-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; position: relative; }
.balance-label { font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .8px; font-weight: 600; }
.balance-amount {
    display: flex; align-items: baseline; gap: 4px;
    font-weight: 800; letter-spacing: -.04em;
    margin-bottom: 6px; position: relative;
}
.balance-currency { font-size: 32px; color: var(--text-muted); }
.balance-value {
    font-size: 64px; line-height: 1;
    background: linear-gradient(135deg, var(--text) 0%, var(--primary) 50%, var(--primary-2) 100%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.balance-sub { font-size: 13px; color: var(--text-muted); position: relative; }

.balance-actions {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
    margin-top: 22px; position: relative;
}
.btn-action {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 14px 10px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--rim);
    border-radius: var(--radius);
    font-size: 12.5px; font-weight: 600; color: var(--text);
    transition: all .15s;
}
.btn-action .ic { color: var(--text-muted); }
.btn-action:hover { background: rgba(255,255,255,0.07); transform: translateY(-1px); border-color: var(--rim-strong); }
.btn-action:hover .ic { color: var(--text); }
.btn-action.primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-2));
    border-color: transparent;
    color: var(--on-primary);
    box-shadow: 0 6px 20px var(--accent-glow-strong);
}
.btn-action.primary .ic { color: var(--on-primary); }
.btn-action.primary:hover { box-shadow: 0 10px 28px var(--accent-glow-strong); }

/* === Tabs === */
.tabs {
    display: flex; gap: 6px;
    padding: 6px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--rim);
    border-radius: 14px;
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
    flex: 1; padding: 10px 14px;
    border-radius: 10px;
    font-size: 13.5px; font-weight: 600;
    color: var(--text-muted);
    transition: all .15s;
    white-space: nowrap;
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
}
.tab:hover { color: var(--text); }
.tab.active {
    background: rgba(255,255,255,0.08);
    color: var(--text);
    box-shadow: 0 0 0 1px var(--rim-strong) inset;
}

.tab-content { display: none; }
.tab-content.active { display: block; animation: fade .25s var(--ease); }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* === Cards === */
.card {
    padding: 22px;
    border-radius: var(--radius-lg);
    border-color: var(--rim);
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
.card-head h3 { font-size: 17px; font-weight: 700; }

.filter-row {
    display: flex; gap: 8px; margin-bottom: 14px;
    overflow-x: auto; scrollbar-width: none; padding-bottom: 4px;
}
.filter-row::-webkit-scrollbar { display: none; }
.chip-filter {
    padding: 6px 14px; border-radius: 999px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--rim);
    color: var(--text-muted); font-size: 12.5px; font-weight: 600;
    white-space: nowrap;
    transition: all .15s;
}
.chip-filter:hover { color: var(--text); }
.chip-filter.active {
    background: rgba(255,255,255,0.08);
    color: var(--text);
    border-color: var(--rim-strong);
}

/* === History list === */
.history-list, .invoices-list { display: flex; flex-direction: column; gap: 8px; }
.empty { padding: 30px; text-align: center; color: var(--text-muted); font-size: 13px; }

.history-item {
    display: grid;
    grid-template-columns: 38px 1fr auto;
    gap: 14px;
    padding: 12px 14px;
    background: rgba(255,255,255,0.025);
    border: 1px solid var(--rim);
    border-radius: var(--radius);
    align-items: center;
    transition: background .15s;
}
.history-item:hover { background: rgba(255,255,255,0.05); }
.hi-icon {
    width: 38px; height: 38px; border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.06);
    color: var(--text);
}
.hi-icon .ic { width: 18px; height: 18px; }
.hi-icon.income { color: var(--success); background: rgba(255,255,255,0.08); }
.hi-icon.expense { color: var(--text-muted); }

.hi-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hi-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hi-sub { font-size: 12px; color: var(--text-muted); }

.hi-amount {
    font-weight: 700; font-size: 15px;
    font-family: 'JetBrains Mono', monospace;
    text-align: right;
    white-space: nowrap;
}
.hi-amount.positive { color: var(--success); }
.hi-amount.negative { color: var(--text); }
.hi-amount-sub { font-size: 11px; color: var(--text-muted); font-family: 'Inter', sans-serif; }

/* === Invoice cards === */
.invoice-item {
    padding: 14px 16px;
    background: rgba(255,255,255,0.025);
    border: 1px solid var(--rim);
    border-radius: var(--radius);
}
.invoice-item.pending  { border-color: var(--rim-strong); }
.invoice-item.credited { border-color: var(--rim-strong); }
.invoice-item.expired, .invoice-item.rejected { opacity: .55; }

.iv-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.iv-row + .iv-row { margin-top: 6px; }
.iv-amount { font-weight: 700; font-size: 16px; }
.iv-status { font-size: 12px; padding: 3px 10px; border-radius: 999px; font-weight: 600; display: inline-flex; align-items: center; gap: 5px; }
.iv-status.pending  { background: rgba(255,255,255,0.06); color: var(--text-muted); }
.iv-status.credited { background: rgba(255,255,255,0.10); color: var(--text); }
.iv-status.expired, .iv-status.rejected { background: rgba(245,179,179,0.10); color: var(--danger); }
.iv-meta { color: var(--text-muted); font-size: 12px; }

.app-foot {
    text-align: center; padding: 30px 18px; font-size: 12px;
}

/* === Toast === */
#toast-container {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    display: flex; flex-direction: column; gap: 8px;
    z-index: 9999;
    pointer-events: none;
}
.toast {
    padding: 12px 20px; border-radius: 12px;
    background: rgba(20,20,30,0.95);
    border: 1px solid var(--rim-strong);
    backdrop-filter: blur(20px);
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    color: var(--text); font-weight: 600; font-size: 14px;
    transform: translateY(20px); opacity: 0;
    transition: all .3s var(--ease);
    pointer-events: all;
    max-width: 90vw;
    display: inline-flex; align-items: center; gap: 8px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }

/* === Mobile === */
@media (max-width: 720px) {
    .app-header { padding: 12px 14px; }
    .user-meta { display: none; }
    .user-pill { padding: 4px; }
    .app-main { padding: 16px 12px 40px; gap: 16px; }
    .balance-card { padding: 20px 18px; border-radius: 22px; }
    .balance-value { font-size: 44px; }
    .balance-currency { font-size: 24px; }
    .balance-actions { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .btn-action { padding: 12px 8px; font-size: 12px; }
    .card { padding: 16px; border-radius: 18px; }
    .login-card { padding: 28px 22px; }
    .login-card h1 { font-size: 22px; }
    .history-item { grid-template-columns: 34px 1fr auto; padding: 11px 12px; gap: 10px; }
    .hi-icon { width: 34px; height: 34px; }
    .hi-icon .ic { width: 16px; height: 16px; }
    .hi-title { font-size: 13px; }
    .tabs { padding: 4px; }
    .tab { padding: 9px 12px; font-size: 12.5px; }
    .tab span { display: none; }
    .tab .ic-sm { width: 18px; height: 18px; }
    .theme-popover { right: 12px; left: 12px; width: auto; }
    .theme-grid { grid-template-columns: repeat(2, 1fr); }
}
