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

:root {
    /* iOS 18 High-Fidelity Enterprise Palette */
    --ios-blue: #0A84FF;
    --ios-green: #30D158;
    --ios-red: #FF453A;
    --ios-orange: #FF9F0A;
    --ios-indigo: #5E5CE6;
    --ios-teal: #64D2FF;
    --ios-gray: #8E8E93;

    --radius-ios-lg: 24px;
    --radius-ios-md: 16px;
    --radius-ios-sm: 10px;
    --nav-height: 90px;

    /* Precision Physics */
    --ease-ios: cubic-bezier(0.1, 0.7, 0.1, 1);
    --spring-ios: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Base Theme Logic - Ultra Luxury Focus */
body.dark-mode {
    --bg-system: #000000;
    --bg-secondary: #0A0A0C;
    --bg-grouped: #161618;
    --text-main: #FFFFFF;
    --text-secondary: rgba(255, 255, 255, 0.55);
    --separator: rgba(255, 255, 255, 0.08);
    --glass: rgba(22, 22, 24, 0.82);
    --border-glass: rgba(255, 255, 255, 0.05);
    --shadow-premium: 0 10px 40px rgba(0, 0, 0, 0.5);
}

body.light-mode {
    --bg-system: #F2F2F7;
    --bg-secondary: #FFFFFF;
    --bg-grouped: #FFFFFF;
    --text-main: #000000;
    --text-secondary: rgba(60, 60, 67, 0.6);
    --separator: rgba(0, 0, 0, 0.08);
    --glass: rgba(255, 255, 255, 0.85);
    --border-glass: rgba(0, 0, 0, 0.03);
    --shadow-premium: 0 10px 40px rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, sans-serif;
    background-color: var(--bg-system);
    color: var(--text-main);
    transition: background-color 0.5s var(--ease-ios);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
    font-family: 'Outfit', sans-serif;
}

/* --- SECURITY ISOLATION --- */
#app {
    display: none;
    padding-bottom: calc(var(--nav-height) + 20px);
}

#app.authorized {
    display: block;
    animation: iosSlideUp 0.6s var(--ease-ios);
}

@keyframes iosSlideUp {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.98);
        filter: blur(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

/* --- THE LOCK SCREEN (v6.0 LUXURY EDITION) --- */
.lock-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-system);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
}

.lock-screen.hidden {
    animation: fadeOut 0.4s var(--ease-ios) forwards;
    pointer-events: none;
}

@keyframes fadeOut {
    to {
        opacity: 0;
    }
}

.lock-glyph {
    font-size: 80px;
    margin-bottom: 40px;
    filter: drop-shadow(0 0 20px var(--ios-blue));
    animation: pulseLock 3s infinite var(--ease-ios);
}

.lock-screen h1 {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 15px;
    letter-spacing: -0.5px;
}

.lock-screen p {
    font-size: 17px;
    color: var(--text-secondary);
    line-height: 1.6;
    max-width: 320px;
}

@keyframes pulseLock {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

/* --- DASHBOARD LUXURY --- */
.screen {
    display: none;
    padding: 25px 20px;
}

.screen.active {
    display: block;
}

.large-title {
    margin-bottom: 35px;
}

.large-title h1 {
    font-size: 42px;
    font-weight: 800;
    margin: 0;
    letter-spacing: -1.5px;
}

/* MESH GRADIENT WALLET (iOS 18 v6.0) */
.hero-wallet {
    background: #000;
    background-image:
        radial-gradient(at 0% 0%, hsla(210, 100%, 35%, 1) 0, transparent 50%),
        radial-gradient(at 100% 0%, hsla(230, 100%, 35%, 1) 0, transparent 50%),
        radial-gradient(at 100% 100%, hsla(200, 100%, 45%, 1) 0, transparent 50%),
        radial-gradient(at 0% 100%, hsla(220, 100%, 45%, 1) 0, transparent 50%);
    border-radius: var(--radius-ios-lg);
    padding: 30px;
    color: white;
    margin-bottom: 35px;
    box-shadow: 0 25px 50px -12px rgba(0, 122, 255, 0.4);
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.hero-wallet .label {
    font-size: 13px;
    font-weight: 700;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.hero-wallet .value {
    font-size: 40px;
    font-weight: 800;
    margin-top: 10px;
    font-family: 'Outfit', sans-serif;
    letter-spacing: -1px;
}

/* Receding effect for iOS Stack */
#app {
    transition: transform 0.5s var(--ease-ios), filter 0.5s var(--ease-ios), border-radius 0.5s var(--ease-ios);
}

#app.ios-recede {
    transform: translateY(20px) scale(0.94);
    filter: brightness(0.7) blur(2px);
    border-radius: 32px;
    overflow: hidden;
}

/* Control Grid - Precision Buttons */
.icon-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 35px;
}

.luxury-btn {
    background: var(--bg-grouped);
    border-radius: 20px;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    align-items: start;
    gap: 14px;
    border: 1px solid var(--border-glass);
    position: relative;
    transition: transform 0.2s var(--spring-ios), background 0.2s;
}

.luxury-btn:active {
    transform: scale(0.94);
    background: var(--bg-secondary);
}

.luxury-btn .icon-bg {
    width: 50px;
    height: 50px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.luxury-btn .label {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-main);
    font-family: 'Outfit';
}

/* Enterprise List Styles (iOS 18 v6.0) */
.enterprise-section {
    margin-bottom: 35px;
}

.section-meta {
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin: 0 0 10px 20px;
    letter-spacing: 1px;
    font-weight: 700;
}

.section-card {
    background: var(--bg-grouped);
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid var(--border-glass);
    box-shadow: var(--shadow-premium);
}

.luxury-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    position: relative;
}

.luxury-row:not(:last-child)::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20px;
    right: 0;
    height: 0.5px;
    background: var(--separator);
}

.luxury-row:active {
    background: var(--separator);
}

.luxury-row .main-info .title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-main);
}

.luxury-row .main-info .sub {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.luxury-row .side-info {
    text-align: right;
    display: flex;
    align-items: center;
    gap: 10px;
}

.luxury-row .side-info .amount {
    font-size: 18px;
    font-weight: 700;
    font-family: 'Outfit';
}

/* Enterprise Badges */
.luxury-badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.badge-red {
    background: rgba(255, 69, 58, 0.15);
    color: var(--ios-red);
}

/* --- LUXURY PIXEL-PERFECTION (v6.1) --- */

.luxury-nav {
    position: fixed;
    bottom: 25px;
    left: 20px;
    right: 20px;
    height: 75px;
    background: var(--glass);
    backdrop-filter: blur(50px);
    -webkit-backdrop-filter: blur(50px);
    border-radius: 24px;
    border: 1px solid var(--border-glass);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 5000;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
}

.nav-item {
    background: none;
    border: none;
    color: var(--ios-gray);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    transition: all 0.2s var(--ease-ios);
    width: 60px;
    padding: 0;
}

.nav-item.active {
    color: var(--ios-blue);
    transform: translateY(-4px);
}

.nav-item .icon {
    font-size: 26px;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
}

.nav-item span {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.premium-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 94vh;
    background: var(--bg-secondary);
    border-radius: 32px 32px 0 0;
    /* iOS 18 Standard Radius */
    z-index: 9000;
    transition: transform 0.5s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
    padding-bottom: env(safe-area-inset-bottom);
    transform: translateY(100%);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3);
}

.premium-sheet.active {
    transform: translateY(0);
}

.sheet-header {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    border-bottom: 0.5px solid var(--separator);
    background: var(--bg-secondary);
    border-radius: 32px 32px 0 0;
}

.sheet-header .header-slot {
    flex: 1;
    display: flex;
    align-items: center;
}

.sheet-header .header-slot.center {
    justify-content: center;
}

.sheet-header .header-slot.right {
    justify-content: flex-end;
}

.sheet-header h2 {
    font-size: 17px;
    font-weight: 700;
    margin: 0;
    color: var(--text-main);
    white-space: nowrap;
}

.sheet-btn {
    background: none;
    border: none;
    font-size: 17px;
    font-weight: 500;
    padding: 10px;
    cursor: pointer;
    color: var(--ios-blue);
    font-family: 'Inter', sans-serif;
}

.sheet-btn.cancel {
    color: var(--ios-red);
}

.sheet-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px 300px;
    /* Massive bottom padding for keyboard clearance */
    scrollbar-width: none;
    scroll-behavior: smooth;
}

.luxury-input-group {
    background: var(--bg-grouped);
    border-radius: 12px;
    margin-bottom: 25px;
    border: 0.5px solid var(--border-glass);
    overflow: hidden;
}

.input-row {
    height: 60px;
    /* ERP Business Class Height */
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.05);
    background: var(--bg-main);
    transition: background 0.2s ease, transform 0.2s ease;
    scroll-margin-top: 100px;
    /* Keep focused input visible */
}

.input-row:last-child {
    border-bottom: none;
}

.input-row:focus-within {
    background: #fff;
    box-shadow: inset 0 0 0 1px var(--ios-blue);
    z-index: 10;
}

.input-row label {
    width: 120px;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-sub);
}

.input-row input,
.input-row select {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 17px;
    font-family: 'Outfit', sans-serif;
    color: var(--text-main);
    padding: 0;
    height: 100%;
    text-align: right;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

/* Luxury Chevron for Select */
.input-row select {
    padding-right: 25px;
    background-image: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 14 14' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3.5 5.25L7 8.75L10.5 5.25' stroke='%238E8E93' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0px center;
}

/* Unified Enterprise Buttons */
.ios-action-btn {
    background: var(--bg-grouped);
    border: 0.5px solid var(--border-glass);
    color: var(--ios-blue);
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.ios-action-btn:active {
    background: var(--separator);
    transform: scale(0.96);
}

.ios-back-btn {
    background: none;
    border: none;
    color: var(--ios-blue);
    font-size: 17px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px;
}

.main-balance-box h2 {
    color: var(--ios-green);
    margin: 10px 0;
}

.main-balance-box span {
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* Custom Delete Button v6.0 */
.btn-delete {
    background: rgba(255, 69, 58, 0.1);
    color: var(--ios-red);
    border: none;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    margin-top: 10px;
    width: 100%;
}

.btn-delete:active {
    background: var(--ios-red);
    color: white;
}

/* Search Engine Polish */
.search-container {
    margin-bottom: 30px;
    position: relative;
}

.luxury-search {
    width: 100%;
    height: 54px;
    border-radius: 16px;
    background: var(--bg-grouped);
    border: 1px solid var(--border-glass);
    padding: 0 20px 0 50px;
    font-size: 17px;
    color: var(--text-main);
}

.search-icon {
    position: absolute;
    left: 18px;
    top: 16px;
    font-size: 20px;
    color: var(--text-secondary);
}

/* Animation Overlays */
.blur-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 6000;
    backdrop-filter: blur(20px);
    transition: opacity 0.4s;
    opacity: 0;
}

.blur-overlay.active {
    display: block;
    opacity: 1;
}

/* Segmented Mastery */
.luxury-segmented {
    background: var(--bg-grouped);
    padding: 3px;
    border-radius: 14px;
    display: flex;
    margin-bottom: 30px;
    border: 1px solid var(--border-glass);
}

.lux-seg-btn {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px;
    border-radius: 11px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
    transition: all 0.3s;
}

.lux-seg-btn.active {
    background: var(--bg-secondary);
    color: var(--text-main);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* --- ENTERPRISE FEEDBACK SYSTEM (v6.4) --- */
.ios-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 20000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ios-loading-overlay.active {
    display: flex;
    opacity: 1;
}

.spinner-ios {
    width: 60px;
    height: 60px;
    background: var(--bg-secondary);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-premium);
    border: 1px solid var(--border-glass);
}

.spinner-ios::after {
    content: "";
    width: 25px;
    height: 25px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--ios-blue);
    border-radius: 50%;
    animation: spin-ios 0.8s linear infinite;
}

@keyframes spin-ios {
    to {
        transform: rotate(360deg);
    }
}

.ios-toast {
    position: fixed;
    top: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: var(--bg-secondary);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    padding: 12px 24px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-premium);
    z-index: 21000;
    transition: transform 0.6s var(--spring-ios);
    border: 1px solid var(--border-glass);
    pointer-events: none;
}

.ios-toast.active {
    transform: translateX(-50%) translateY(0);
}

.ios-toast .icon {
    font-size: 20px;
}

.ios-toast .msg {
    font-size: 15px;
    font-weight: 600;
}

.toast-success .icon {
    color: var(--ios-green);
}

.toast-error .icon {
    color: var(--ios-red);
}

@media (max-width: 400px) {
    .ios-toast {
        width: 90%;
    }
}

/* Button Loading State */
.ios-submit-btn.loading,
.sheet-btn.loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
    color: transparent !important;
}

.ios-submit-btn.loading::after,
.sheet-btn.loading::after {
    content: "•••";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 20px;
    letter-spacing: 2px;
    animation: pulse-dots 1s infinite;
}

@keyframes pulse-dots {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 1;
    }
}

/* UoM Badge */
.uom-badge {
    font-size: 11px;
    font-weight: 700;
    background: var(--bg-secondary);
    color: var(--ios-blue);
    padding: 2px 6px;
    border-radius: 6px;
    margin-left: 4px;
    opacity: 0.8;
}