/**
 * Aristos Authenticator — Enterprise Design System v2.0
 * World-class security UX · White-label ready
 *
 * Design principles:
 *   1. Every pixel communicates trust
 *   2. Depth through light, not decoration
 *   3. Information-dense yet breathable
 *   4. Motion that feels inevitable
 */

/* ============================================
   DESIGN TOKENS
   ============================================ */
:root {
    /* ---- Brand (white-label overridable via JS) ---- */
    --brand-accent: #9889C0;
    --brand-accent-rgb: 152, 137, 192;
    --brand-accent-light: #D8D0F5;
    --brand-accent-dark: #2d2769;
    --brand-gradient: linear-gradient(135deg, #2d2769 0%, #7666AA 52%, #9889C0 100%);
    --brand-radius: 16px;
    --ah-jacarta: #2D2769;
    --ah-lavender: #9889C0;
    --ah-steel: #241E31;
    --ah-athens: #E5E7EB;
    --ah-bg-dark: #090711;
    --ah-surface-dark: #161224;
    --ah-surface-elevated-dark: #211a34;
    --ah-border-dark: rgba(229, 231, 235, 0.12);
    --ah-radius-md: 12px;
    --ah-radius-lg: 16px;
    --ah-radius-xl: 20px;
    --ah-shadow-lg-dark: 0 24px 80px rgba(45, 39, 105, 0.26), 0 12px 40px rgba(0, 0, 0, 0.42);
    --ah-focus: 0 0 0 3px rgba(152, 137, 192, 0.22);

    /* ---- Surfaces (layered depth system) ---- */
    --color-bg: var(--ah-bg-dark);
    --color-surface-0: #0f0b1d;
    --color-surface-1: var(--ah-surface-dark);
    --color-surface-2: var(--ah-surface-elevated-dark);
    --color-surface-3: #2d2544;
    --color-border: var(--ah-border-dark);
    --color-border-subtle: rgba(255, 255, 255, 0.03);
    --color-border-accent: rgba(var(--brand-accent-rgb), 0.15);

    /* ---- Backwards-compat aliases ---- */
    --color-surface: var(--color-surface-1);
    --color-surface-elevated: var(--color-surface-2);
    --color-card-bg: var(--color-surface-1);
    --color-secondary-text: var(--color-text-secondary);

    /* ---- Text ---- */
    --color-text: #FFFFFF;
    --color-text-secondary: rgba(229, 231, 235, 0.72);
    --color-text-muted: rgba(229, 231, 235, 0.46);

    /* ---- Semantic ---- */
    --color-success: #34d399;
    --color-success-rgb: 52, 211, 153;
    --color-danger: #f87171;
    --color-danger-rgb: 248, 113, 113;
    --color-warning: #fbbf24;
    --color-warning-rgb: 251, 191, 36;
    --color-info: #60a5fa;

    /* ---- Gold shortcuts ---- */
    --color-gold: var(--brand-accent);
    --color-gold-light: var(--brand-accent-light);
    --color-gold-dark: var(--brand-accent-dark);
    --gold-gradient: var(--brand-gradient);
    --gold: var(--brand-accent);
    --gold-dark: var(--brand-accent-dark);
    --bg-tertiary: var(--color-surface-2);
    --border: var(--color-border);
    --text-primary: var(--color-text);
    --text-secondary: var(--color-text-secondary);

    /* ---- Typography ---- */
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-logo: 'Cyberiada', 'Inter', sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'JetBrains Mono', ui-monospace, monospace;

    /* ---- Type scale (minor third) ---- */
    --text-xs: 0.6875rem;
    --text-sm: 0.8125rem;
    --text-base: 0.9375rem;
    --text-lg: 1.125rem;
    --text-xl: 1.375rem;
    --text-2xl: 1.75rem;
    --text-3xl: 2.25rem;

    /* ---- Spacing (4px base) ---- */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 48px;

    /* ---- Radii ---- */
    --radius-sm: 8px;
    --radius-md: var(--brand-radius);
    --radius-lg: var(--ah-radius-lg);
    --radius-xl: var(--ah-radius-xl);
    --radius-full: 9999px;

    /* ---- Shadows (layered for realism) ---- */
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4), 0 1px 3px rgba(0,0,0,.2);
    --shadow-md: 0 4px 6px rgba(0,0,0,.35), 0 2px 4px rgba(0,0,0,.2);
    --shadow-lg: 0 10px 25px rgba(0,0,0,.5), 0 4px 10px rgba(0,0,0,.3);
    --shadow-xl: 0 20px 50px rgba(0,0,0,.6), 0 8px 20px rgba(0,0,0,.4);
    --shadow-gold: 0 4px 20px rgba(var(--brand-accent-rgb), 0.25), 0 0 60px rgba(var(--brand-accent-rgb), 0.08);
    --shadow-glow: 0 0 20px rgba(var(--brand-accent-rgb), 0.15);

    /* ---- Motion ---- */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 400ms;

    /* ---- Safe areas ---- */
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

/* ============================================
   RESET & FOUNDATION
   ============================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

/* Invisible scrollbars that reveal on scroll */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: rgba(var(--brand-accent-rgb), 0.2);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(var(--brand-accent-rgb), 0.4); }
* { scrollbar-width: thin; scrollbar-color: rgba(var(--brand-accent-rgb), 0.2) transparent; }

body {
    font-family: var(--font-primary);
    font-size: var(--text-base);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    letter-spacing: -0.01em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    overscroll-behavior: none;
}

/* Subtle ambient glow at top for depth */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse 80% 50% at 50% -20%, rgba(var(--brand-accent-rgb), 0.03) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

/* ============================================
   APP SHELL
   ============================================ */
#app {
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

/* ============================================
   HEADER — Frosted glass, minimal, confident
   ============================================ */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px var(--spacing-md);
    padding-top: calc(12px + var(--safe-top));
    background: rgba(11, 11, 15, 0.8);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-family: var(--font-logo);
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    background: var(--brand-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
}

.logo-sm { font-size: 0.875rem; letter-spacing: 0.15em; }
.logo-lg { font-size: 1.75rem; letter-spacing: 0.25em; }

.icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: color var(--duration-fast) var(--ease-smooth),
                background var(--duration-fast) var(--ease-smooth),
                transform var(--duration-fast) var(--ease-spring);
    -webkit-tap-highlight-color: transparent;
}

.icon-btn:hover, .icon-btn:focus-visible {
    background: var(--color-surface-2);
    color: var(--color-text);
}

.icon-btn:active {
    transform: scale(0.92);
    color: var(--brand-accent);
}

/* ============================================
   SECURITY STATUS BAR
   ============================================ */
.security-status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-sm);
    padding: 6px var(--spacing-md);
    background: var(--color-surface-0);
    border-bottom: 1px solid var(--color-border-subtle);
}

.security-status-bar .user-email {
    color: var(--color-success);
    font-size: var(--text-xs);
    font-weight: 500;
    flex-shrink: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.security-badges {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.security-badge {
    display: none;
    align-items: center;
    gap: 3px;
    padding: 2px 7px;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.03em;
    background: rgba(255, 255, 255, 0.03);
    color: rgba(255, 255, 255, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all var(--duration-normal) var(--ease-smooth);
}

.security-badge.active {
    display: inline-flex;
    background: rgba(var(--color-success-rgb), 0.08);
    color: var(--color-success);
    border-color: rgba(var(--color-success-rgb), 0.15);
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.app-main {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--spacing-md);
    padding-bottom: calc(var(--spacing-xl) + 80px + var(--safe-bottom));
    scroll-behavior: smooth;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--spacing-2xl) var(--spacing-lg);
    min-height: 60vh;
    animation: fadeIn var(--duration-slow) var(--ease-out);
}

.empty-icon {
    width: 88px;
    height: 88px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    margin-bottom: var(--spacing-lg);
    color: var(--color-gold);
    animation: breathe 3s ease-in-out infinite;
}

.empty-state h2 {
    font-size: var(--text-xl);
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    letter-spacing: -0.02em;
}

.empty-state p {
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-lg);
    max-width: 260px;
    line-height: 1.6;
    font-size: var(--text-sm);
}

/* ============================================
   ACCOUNTS LIST
   ============================================ */
.accounts-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ============================================
   ACCOUNT CARDS
   ============================================ */
.account-card {
    background: var(--color-surface-1);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform var(--duration-fast) var(--ease-spring),
                border-color var(--duration-normal) var(--ease-smooth),
                box-shadow var(--duration-normal) var(--ease-smooth);
    animation: cardEntrance var(--duration-slow) var(--ease-out) both;
}

.account-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(var(--brand-accent-rgb), 0.03) 0%, transparent 50%);
    opacity: 0;
    transition: opacity var(--duration-normal) var(--ease-smooth);
    pointer-events: none;
}

.account-card:hover, .account-card:focus-visible {
    border-color: var(--color-border-accent);
    box-shadow: var(--shadow-glow);
}

.account-card:hover::after { opacity: 1; }
.account-card:active { transform: scale(0.985); }

/* Push Auth Account Card */
.account-card-push {
    border-color: rgba(var(--color-success-rgb), 0.12);
    background: linear-gradient(165deg, var(--color-surface-1) 60%, rgba(var(--color-success-rgb), 0.03) 100%);
}

.account-card-push:hover, .account-card-push:focus-visible {
    border-color: rgba(var(--color-success-rgb), 0.3);
    box-shadow: 0 4px 20px rgba(var(--color-success-rgb), 0.12);
}

.account-icon-push {
    background: linear-gradient(135deg, #34d399, #059669) !important;
    color: #fff !important;
}

.account-badge-push {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-success);
    background: rgba(var(--color-success-rgb), 0.1);
    padding: 3px 8px;
    border-radius: var(--radius-full);
}

.account-push-status {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--color-border-subtle);
    font-size: var(--text-sm);
    color: var(--color-success);
}

.account-push-status svg { flex-shrink: 0; }

.account-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: var(--spacing-sm);
}

.account-icon {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-gradient);
    border-radius: var(--radius-sm);
    color: #fff;
    font-weight: 700;
    font-size: var(--text-sm);
    flex-shrink: 0;
}

.account-info { flex: 1; min-width: 0; }

.account-issuer {
    font-weight: 600;
    font-size: var(--text-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.01em;
}

.account-name {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.account-code-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
}

.account-code {
    font-family: var(--font-mono);
    font-size: 1.875rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    color: var(--color-gold);
    transition: color var(--duration-fast);
}

.account-timer {
    position: relative;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
}

.timer-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.timer-bg {
    fill: none;
    stroke: var(--color-surface-3);
    stroke-width: 3;
}

.timer-progress {
    fill: none;
    stroke: var(--color-gold);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 100.53;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear, stroke var(--duration-normal);
}

.timer-progress.warning { stroke: var(--color-warning); }
.timer-progress.danger { stroke: var(--color-danger); }

.timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-text-muted);
    font-family: var(--font-mono);
}

/* ============================================
   FAB
   ============================================ */
.fab {
    position: fixed;
    bottom: calc(var(--spacing-lg) + var(--safe-bottom));
    right: var(--spacing-lg);
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-gradient);
    border: none;
    border-radius: var(--radius-full);
    color: #fff;
    box-shadow: var(--shadow-gold);
    cursor: pointer;
    z-index: 50;
    transition: transform var(--duration-fast) var(--ease-spring),
                box-shadow var(--duration-normal) var(--ease-smooth);
}

.fab:hover, .fab:focus-visible {
    transform: scale(1.08);
    box-shadow: var(--shadow-gold), 0 0 40px rgba(var(--brand-accent-rgb), 0.15);
}

.fab:active { transform: scale(0.94); }

/* ============================================
   DRAWER
   ============================================ */
.drawer {
    position: fixed;
    inset: 0;
    z-index: 200;
}

.drawer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity var(--duration-slow) var(--ease-smooth);
}

.drawer.show .drawer-backdrop { opacity: 1; }

.drawer-content {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 300px;
    max-width: 82vw;
    background: var(--color-surface-0);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform var(--duration-slow) var(--ease-out);
}

.drawer.show .drawer-content { transform: translateX(0); }

.drawer-profile {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-lg);
    padding-top: calc(var(--spacing-xl) + var(--safe-top));
    background: linear-gradient(180deg, var(--color-surface-2) 0%, var(--color-surface-0) 100%);
    border-bottom: 1px solid var(--color-border);
}

.profile-avatar {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-gradient);
    border-radius: var(--radius-full);
    color: #fff;
    flex-shrink: 0;
}

.profile-info { flex: 1; min-width: 0; }

.profile-name {
    display: block;
    font-weight: 600;
    font-size: var(--text-base);
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-email {
    display: block;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-badge {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-success);
    flex-shrink: 0;
}

.drawer-security-card {
    margin: var(--spacing-md);
    padding: var(--spacing-md);
    background: rgba(var(--color-success-rgb), 0.06);
    border: 1px solid rgba(var(--color-success-rgb), 0.12);
    border-radius: var(--radius-md);
}

.security-status {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.security-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.security-icon.secure {
    background: rgba(var(--color-success-rgb), 0.15);
    color: var(--color-success);
}

.security-icon.warning {
    background: rgba(var(--color-warning-rgb), 0.15);
    color: var(--color-warning);
}

.security-text { flex: 1; }

.security-label {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
    margin-bottom: 1px;
}

.security-value {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-success);
}

.drawer-nav {
    flex: 1;
    padding: var(--spacing-md);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.drawer-nav hr {
    border: none;
    border-top: 1px solid var(--color-border-subtle);
    margin: var(--spacing-md) 0;
}

.nav-section { margin-bottom: var(--spacing-lg); }

.nav-section-title {
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text-muted);
    padding: var(--spacing-sm) var(--spacing-md);
    margin-bottom: var(--spacing-xs);
}

.drawer-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    width: 100%;
    padding: 10px var(--spacing-md);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-size: var(--text-base);
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    margin-bottom: 2px;
    transition: background var(--duration-fast) var(--ease-smooth),
                transform var(--duration-fast) var(--ease-spring);
}

.drawer-item:hover, .drawer-item:focus-visible {
    background: var(--color-surface-2);
}

.drawer-item:active {
    background: var(--color-surface-3);
    transform: scale(0.98);
}

.drawer-item svg {
    color: var(--color-text-secondary);
}

.drawer-item:hover svg, .drawer-item:focus-visible svg {
    color: var(--color-gold);
}

.drawer-item-icon {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface-2);
    border-radius: var(--radius-sm);
    color: var(--color-text-secondary);
    flex-shrink: 0;
    transition: background var(--duration-fast), color var(--duration-fast);
}

.drawer-item:hover .drawer-item-icon,
.drawer-item:focus-visible .drawer-item-icon {
    background: rgba(var(--brand-accent-rgb), 0.15);
    color: var(--color-gold);
}

.drawer-item:hover .drawer-item-icon svg,
.drawer-item:focus-visible .drawer-item-icon svg {
    stroke: var(--color-gold);
}

.drawer-item-text { flex: 1; font-weight: 500; }

.drawer-item-arrow {
    color: var(--color-text-muted);
    opacity: 0.3;
    flex-shrink: 0;
    transition: opacity var(--duration-fast), transform var(--duration-fast);
}

.drawer-item:hover .drawer-item-arrow {
    opacity: 0.7;
    transform: translateX(2px);
}

.drawer-item-badge {
    display: none;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--color-danger);
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    text-align: center;
    line-height: 18px;
}

.drawer-item-badge:not(:empty) { display: inline-block; }

.drawer-footer {
    padding: var(--spacing-lg);
    padding-bottom: calc(var(--spacing-lg) + var(--safe-bottom));
    border-top: 1px solid var(--color-border-subtle);
    text-align: center;
}

.drawer-footer .text-muted { color: var(--color-text-muted); }

.footer-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-xs);
}

.footer-brand .logo { font-size: 0.8rem; }

.footer-brand .version {
    font-size: 10px;
    color: var(--color-text-muted);
    background: var(--color-surface-2);
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 500;
}

.footer-tagline {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    letter-spacing: 0.05em;
}

/* ============================================
   MODALS — Sheet-style with spring animation
   ============================================ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity var(--duration-slow) var(--ease-smooth);
}

.modal.show .modal-backdrop { opacity: 1; }

.modal-content {
    position: relative;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    background: var(--color-surface-1);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    overflow: hidden;
    transform: translateY(100%);
    transition: transform var(--duration-slow) var(--ease-out);
}

/* Sheet drag handle */
.modal-content::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: var(--color-surface-3);
    border-radius: 2px;
    margin: 8px auto 0;
}

.modal.show .modal-content { transform: translateY(0); }

.modal-fullscreen {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
    z-index: 1001;
}

.modal-fullscreen::before { display: none; }

.modal-fullscreen .modal-content {
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--color-border-subtle);
}

.modal-fullscreen .modal-header {
    padding-top: calc(var(--spacing-md) + var(--safe-top));
    background: linear-gradient(180deg, var(--color-surface-2) 0%, var(--color-surface-1) 100%);
    border-bottom: 1px solid var(--color-border);
}

.modal-header h2 {
    font-size: var(--text-lg);
    font-weight: 600;
    letter-spacing: -0.02em;
}

.modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface-2);
    border: none;
    color: var(--color-text-muted);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background var(--duration-fast), color var(--duration-fast), transform var(--duration-fast) var(--ease-spring);
}

.modal-close:hover, .modal-close:focus-visible {
    background: var(--color-surface-3);
    color: var(--color-text);
}

.modal-close:active { transform: scale(0.9); }

.modal-body {
    padding: var(--spacing-lg);
    padding-bottom: calc(var(--spacing-lg) + var(--safe-bottom));
    overflow-y: auto;
}

/* ============================================
   ACTIVITY LOG
   ============================================ */
.activity-log-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    padding: 0;
}

.activity-log-controls {
    display: flex;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--color-surface-1);
    border-bottom: 1px solid var(--color-border-subtle);
    flex-shrink: 0;
}

.activity-log-controls .btn {
    flex: 1;
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--text-xs);
    font-weight: 600;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.activity-log-controls .btn svg { width: 14px; height: 14px; }

.activity-log-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-sm);
    -webkit-overflow-scrolling: touch;
}

.activity-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-2xl);
    color: var(--color-text-muted);
    min-height: 200px;
    font-size: var(--text-sm);
}

.activity-empty::before {
    content: '';
    width: 48px;
    height: 48px;
    margin-bottom: var(--spacing-md);
    background: var(--color-surface-2);
    border-radius: var(--radius-full);
    display: block;
}

.activity-item {
    display: flex;
    gap: var(--spacing-sm);
    padding: 10px var(--spacing-md);
    background: var(--color-surface-1);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-xs);
    border-left: 3px solid var(--color-border);
    transition: transform var(--duration-fast) var(--ease-spring);
}

.activity-item:active { transform: scale(0.985); }

.activity-item.info { border-left-color: var(--color-gold); }
.activity-item.success {
    border-left-color: var(--color-success);
    background: linear-gradient(135deg, var(--color-surface-1) 70%, rgba(var(--color-success-rgb), 0.04) 100%);
}
.activity-item.error {
    border-left-color: var(--color-danger);
    background: linear-gradient(135deg, var(--color-surface-1) 70%, rgba(var(--color-danger-rgb), 0.04) 100%);
}
.activity-item.warning { border-left-color: var(--color-warning); }

.activity-icon {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    flex-shrink: 0;
    font-size: var(--text-xs);
    font-weight: 700;
}

.activity-item.info .activity-icon { background: rgba(var(--brand-accent-rgb), 0.12); color: var(--color-gold); }
.activity-item.success .activity-icon { background: rgba(var(--color-success-rgb), 0.12); color: var(--color-success); }
.activity-item.error .activity-icon { background: rgba(var(--color-danger-rgb), 0.12); color: var(--color-danger); }

.activity-content { flex: 1; min-width: 0; overflow: hidden; }

.activity-message {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text);
    line-height: 1.4;
    word-break: break-word;
}

.activity-time {
    font-size: 10px;
    color: var(--color-text-muted);
    margin-top: 2px;
    font-family: var(--font-mono);
}

.activity-details {
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    background: var(--color-surface-0);
    padding: var(--spacing-sm);
    border-radius: var(--radius-sm);
    margin-top: var(--spacing-xs);
    font-family: var(--font-mono);
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 150px;
    overflow-y: auto;
    line-height: 1.4;
    border: 1px solid var(--color-border-subtle);
}

.activity-item.error .activity-details {
    background: rgba(var(--color-danger-rgb), 0.06);
    border-color: rgba(var(--color-danger-rgb), 0.12);
}

/* ============================================
   FORMS
   ============================================ */
.form-group { margin-bottom: var(--spacing-md); }

.form-group label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--color-text-secondary);
    letter-spacing: 0.01em;
}

.form-group input {
    width: 100%;
    padding: 12px var(--spacing-md);
    background: var(--color-surface-0);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-size: var(--text-base);
    font-family: inherit;
    transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}

.form-group input:focus {
    outline: none;
    border-color: var(--color-gold);
    box-shadow: 0 0 0 3px rgba(var(--brand-accent-rgb), 0.12);
}

.form-group input::placeholder { color: var(--color-text-muted); }

.form-hint {
    display: block;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    margin-top: var(--spacing-xs);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: 12px var(--spacing-lg);
    font-family: inherit;
    font-size: var(--text-base);
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    letter-spacing: -0.01em;
    transition: transform var(--duration-fast) var(--ease-spring),
                box-shadow var(--duration-normal) var(--ease-smooth),
                background var(--duration-fast),
                border-color var(--duration-fast);
    -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.97); }
.btn-block { width: 100%; }
.btn-lg { padding: 14px var(--spacing-xl); font-size: 1rem; }
.btn-sm { padding: var(--spacing-sm) var(--spacing-md); font-size: var(--text-sm); }

.btn-primary {
    background: var(--brand-gradient);
    color: #fff;
    box-shadow: 0 8px 24px rgba(var(--brand-accent-rgb), 0.22), inset 0 1px 0 rgba(255,255,255,0.12);
}

.btn-primary:hover, .btn-primary:focus-visible {
    box-shadow: 0 16px 40px rgba(var(--brand-accent-rgb), 0.32), inset 0 1px 0 rgba(255,255,255,0.14);
    transform: translateY(-2px);
}

.btn-primary:active { transform: translateY(0) scale(0.97); }

.btn-secondary {
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    color: var(--color-text);
}

.btn-secondary:hover, .btn-secondary:focus-visible {
    border-color: rgba(var(--brand-accent-rgb), 0.25);
    background: var(--color-surface-3);
}

.btn-danger {
    background: transparent;
    border: 1px solid rgba(var(--color-danger-rgb), 0.3);
    color: var(--color-danger);
}

.btn-danger:hover, .btn-danger:focus-visible {
    background: rgba(var(--color-danger-rgb), 0.1);
    border-color: var(--color-danger);
}

.btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
    border: none;
}

.btn-ghost:hover { color: var(--color-text); }

.btn-danger-outline {
    background: transparent;
    border: 1px solid rgba(var(--color-danger-rgb), 0.4);
    color: var(--color-danger);
}

.btn-danger-outline:hover {
    background: rgba(var(--color-danger-rgb), 0.08);
    border-color: var(--color-danger);
}

.btn-text {
    background: transparent;
    color: var(--color-text-secondary);
    border: none;
    padding: var(--spacing-md);
    font-size: var(--text-base);
    cursor: pointer;
    transition: color var(--duration-fast);
    margin-top: var(--spacing-sm);
}

.btn-text:hover { color: var(--color-text); }

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

hr {
    border: none;
    border-top: 1px solid var(--color-border-subtle);
    margin: var(--spacing-md) 0;
}

/* ============================================
   ADD ACCOUNT OPTIONS
   ============================================ */
.add-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

.add-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-lg);
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    cursor: pointer;
    transition: border-color var(--duration-normal), box-shadow var(--duration-normal), transform var(--duration-fast) var(--ease-spring);
}

.add-option:hover, .add-option:focus-visible {
    border-color: var(--color-border-accent);
    box-shadow: var(--shadow-glow);
}

.add-option:active { transform: scale(0.97); }

.add-option-icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface-0);
    border-radius: var(--radius-full);
    color: var(--color-gold);
}

.add-option span {
    font-size: var(--text-sm);
    font-weight: 500;
}

/* ============================================
   QR SCANNER
   ============================================ */
.scanner-body {
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.qr-reader {
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1;
    background: #000;
}

.qr-reader video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scanner-hint {
    padding: var(--spacing-lg);
    color: var(--color-text-secondary);
    text-align: center;
    font-size: var(--text-sm);
}

/* ============================================
   DETAIL MODAL
   ============================================ */
.detail-code-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-lg);
    padding: var(--spacing-lg);
    background: var(--color-surface-0);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-md);
}

.detail-code {
    font-family: var(--font-mono);
    font-size: var(--text-3xl);
    font-weight: 600;
    letter-spacing: 0.15em;
    color: var(--color-gold);
}

.detail-timer {
    position: relative;
    width: 48px;
    height: 48px;
}

.detail-name {
    text-align: center;
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-lg);
    font-size: var(--text-sm);
}

/* ============================================
   LOCK SCREEN
   ============================================ */
.lock-screen {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
}

.lock-content {
    text-align: center;
    padding: var(--spacing-xl);
    max-width: 300px;
}

.lock-content p {
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-lg);
}

.lock-icon {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface-2);
    border-radius: var(--radius-full);
    margin: 0 auto var(--spacing-lg);
    color: var(--color-gold);
}

.lock-content input {
    text-align: center;
    font-size: 1.5rem;
    letter-spacing: 8px;
}

.biometric-lock-icon {
    width: 96px;
    height: 96px;
    margin: var(--spacing-xl) auto var(--spacing-lg) auto;
    background: radial-gradient(circle, rgba(var(--brand-accent-rgb), 0.15) 0%, rgba(var(--brand-accent-rgb), 0.03) 70%);
    border: 1px solid rgba(var(--brand-accent-rgb), 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: breathe 2.5s ease-in-out infinite;
}

.biometric-lock-icon svg { color: var(--color-gold); }

.biometric-prompt {
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-xl);
    font-size: var(--text-sm);
}

#retryBiometricBtn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
}

/* ============================================
   TOAST
   ============================================ */
.toast {
    position: fixed;
    bottom: calc(100px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 10px var(--spacing-lg);
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    color: var(--color-text);
    font-size: var(--text-sm);
    font-weight: 500;
    opacity: 0;
    transition: all var(--duration-normal) var(--ease-out);
    z-index: 400;
    box-shadow: var(--shadow-lg);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    border-color: rgba(var(--color-success-rgb), 0.3);
    color: var(--color-success);
}

.toast.error {
    border-color: rgba(var(--color-danger-rgb), 0.3);
    color: var(--color-danger);
}

.toast.info {
    border-color: rgba(var(--brand-accent-rgb), 0.2);
    color: var(--color-gold);
}

.toast.warning {
    border-color: rgba(var(--color-warning-rgb), 0.3);
    color: var(--color-warning);
}

.copy-toast {
    position: fixed;
    bottom: calc(var(--safe-bottom) + 80px);
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--color-success);
    color: #fff;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    font-weight: 500;
    opacity: 0;
    transition: all var(--duration-normal) var(--ease-out);
    pointer-events: none;
    z-index: 1000;
}

.copy-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============================================
   PWA INSTALL OVERLAY
   ============================================ */
.install-overlay {
    position: fixed;
    inset: 0;
    background: var(--color-bg);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl) var(--spacing-lg);
    padding-top: calc(var(--spacing-2xl) + var(--safe-top));
    padding-bottom: calc(var(--spacing-2xl) + var(--safe-bottom));
    overflow-y: auto;
}

.install-overlay::before {
    content: '';
    position: fixed;
    top: -30%;
    left: 50%;
    transform: translateX(-50%);
    width: 160%;
    height: 160%;
    background:
        radial-gradient(ellipse 50% 40% at 50% 15%, rgba(var(--brand-accent-rgb), 0.12) 0%, transparent 60%),
        radial-gradient(circle at 20% 80%, rgba(var(--brand-accent-rgb), 0.04) 0%, transparent 40%),
        radial-gradient(circle at 80% 60%, rgba(45, 39, 105, 0.06) 0%, transparent 30%);
    pointer-events: none;
    animation: ambientDrift 12s ease-in-out infinite alternate;
}

@keyframes ambientDrift {
    0% { transform: translateX(-50%) translateY(0) scale(1); }
    100% { transform: translateX(-50%) translateY(-2%) scale(1.02); }
}

.install-content {
    text-align: left;
    max-width: 520px;
    width: 100%;
    animation: fadeInUp 0.7s var(--ease-out);
    margin: auto;
    position: relative;
    padding: 28px;
    border-radius: 28px;
    background:
        linear-gradient(145deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.018)),
        linear-gradient(180deg, rgba(22, 18, 36, 0.94), rgba(13, 10, 24, 0.92));
    border: 1px solid var(--ah-border-dark);
    box-shadow:
        0 34px 120px rgba(0, 0, 0, 0.48),
        0 18px 64px rgba(45, 39, 105, 0.30),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(24px) saturate(145%);
}

.install-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px;
    margin-bottom: 24px;
    border-radius: 20px;
    background: rgba(229, 231, 235, 0.035);
    border: 1px solid rgba(229, 231, 235, 0.10);
}

.install-brand-lockup {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.install-brand-lockup > img {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    box-shadow:
        0 14px 32px rgba(var(--brand-accent-rgb), 0.22),
        0 0 0 1px rgba(255, 255, 255, 0.08);
}

.install-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 18px;
}

.install-icon img {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    box-shadow:
        0 18px 44px rgba(var(--brand-accent-rgb), 0.22),
        0 0 0 1px rgba(255, 255, 255, 0.08);
}

.install-brand-lockup span {
    display: block;
    margin-top: 2px;
    color: rgba(229, 231, 235, 0.58);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.install-status {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 12px;
    border-radius: 999px;
    background: rgba(var(--brand-accent-rgb), 0.10);
    border: 1px solid rgba(var(--brand-accent-rgb), 0.24);
    color: rgba(229, 231, 235, 0.86);
    font-size: 0.68rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.install-content .logo-lg {
    font-family: var(--font-logo);
    font-size: 0.9rem;
    letter-spacing: 0.20em;
    color: rgba(var(--brand-accent-rgb), 0.72);
    -webkit-text-fill-color: unset;
    background: none;
    margin-bottom: 0;
    text-transform: uppercase;
}

.install-content h1 {
    font-size: clamp(1.85rem, 6vw, 2.55rem);
    font-weight: 900;
    color: var(--color-text);
    margin-bottom: 12px;
    letter-spacing: -0.055em;
    line-height: 0.98;
}

.install-description {
    color: rgba(229, 231, 235, 0.66);
    margin-bottom: 22px;
    line-height: 1.6;
    font-size: 0.94rem;
    max-width: 430px;
}

.install-assurance {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 22px;
}

.install-assurance-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    background: rgba(229, 231, 235, 0.038);
    border-radius: 18px;
    border: 1px solid rgba(229, 231, 235, 0.10);
    transition: border-color 0.25s, background 0.25s;
}

.install-assurance-row:hover {
    border-color: rgba(var(--brand-accent-rgb), 0.30);
    background: rgba(var(--brand-accent-rgb), 0.065);
}

.install-assurance-row svg {
    width: 21px;
    height: 21px;
    color: rgba(229, 231, 235, 0.88);
    flex-shrink: 0;
    margin-top: 2px;
}

.install-assurance-row strong {
    display: block;
    color: var(--color-text);
    font-size: 0.88rem;
    font-weight: 900;
    letter-spacing: -0.01em;
    margin-bottom: 3px;
}

.install-assurance-row span {
    display: block;
    color: rgba(229, 231, 235, 0.56);
    font-size: 0.78rem;
    line-height: 1.45;
}

.btn-install {
    width: 100%;
    margin-bottom: 16px;
    padding: 15px var(--spacing-xl);
    font-size: 0.95rem;
    font-weight: 900;
    border-radius: 16px;
    letter-spacing: 0;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--ah-jacarta), #52468f 54%, var(--ah-lavender));
    box-shadow: 0 18px 46px rgba(45, 39, 105, 0.34);
}

.btn-install::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.14) 0%, transparent 50%, rgba(255,255,255,0.06) 100%);
    pointer-events: none;
}

.btn-install svg { margin-right: var(--spacing-sm); }

.install-hint {
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    background: rgba(229, 231, 235, 0.055);
    border: 1px solid rgba(var(--brand-accent-rgb), 0.16);
    border-radius: var(--ah-radius-lg);
    margin-bottom: var(--spacing-lg);
}

.ios-instructions {
    text-align: left;
    padding: var(--spacing-lg);
    background: rgba(229, 231, 235, 0.055);
    border: 1px solid rgba(var(--brand-accent-rgb), 0.16);
    border-radius: var(--ah-radius-lg);
    margin-bottom: var(--spacing-lg);
}

.ios-instructions p {
    font-weight: 700;
    margin-bottom: var(--spacing-md);
    color: var(--brand-accent-light);
    font-size: var(--text-sm);
}

.ios-instructions ol {
    padding-left: var(--spacing-lg);
    color: var(--color-text-secondary);
}

.ios-instructions li {
    margin-bottom: var(--spacing-sm);
    line-height: 1.6;
}

.ios-instructions strong { color: var(--color-text); }

.install-footer {
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    margin-top: var(--spacing-2xl);
    letter-spacing: 0.04em;
    opacity: 0.7;
}

.brand-logo-image {
    width: clamp(96px, 18vw, 150px);
    height: auto;
    max-height: 36px;
    object-fit: contain;
    object-position: center;
    display: block;
}

.install-content .brand-logo-image {
    width: clamp(104px, 22vw, 164px);
    height: auto;
    max-height: 40px;
    margin: 0 auto;
}

.native-status-banner {
    position: fixed;
    left: var(--spacing-md);
    right: var(--spacing-md);
    bottom: calc(var(--safe-bottom) + var(--spacing-md));
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
    padding: 12px 14px;
    border-radius: var(--radius-lg);
    background: rgba(15, 11, 29, 0.92);
    border: 1px solid var(--color-border-accent);
    box-shadow: var(--shadow-lg);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
}

.offline-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(var(--spacing-xl) + var(--safe-top)) var(--spacing-lg) calc(var(--spacing-xl) + var(--safe-bottom));
    background: radial-gradient(ellipse 80% 55% at 50% 10%, rgba(var(--brand-accent-rgb), 0.12), transparent 70%), var(--color-bg);
}

.offline-card {
    width: 100%;
    max-width: 420px;
    padding: var(--spacing-xl);
    border-radius: var(--radius-xl);
    background: var(--color-surface-1);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.offline-icon {
    width: 88px;
    height: 88px;
    margin: var(--spacing-xl) auto var(--spacing-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-gold);
    border-radius: var(--radius-full);
    background: rgba(var(--brand-accent-rgb), 0.08);
    border: 1px solid var(--color-border-accent);
}

.offline-card h1 {
    font-size: var(--text-2xl);
    margin-bottom: var(--spacing-sm);
}

.offline-card p {
    color: var(--color-text-secondary);
    line-height: 1.6;
    margin-bottom: var(--spacing-xl);
}

/* Open App Overlay */
.open-app-graphic {
    margin: 2rem 0;
    padding: 1.5rem;
    background: rgba(var(--brand-accent-rgb), 0.05);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.open-app-hint {
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    margin-top: 1rem;
}

/* ============================================
   AUTH REQUEST MODAL
   ============================================ */
.auth-request-content {
    text-align: center;
    padding: var(--spacing-md);
}

.auth-request-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--spacing-lg);
    background: rgba(var(--brand-accent-rgb), 0.08);
    border: 1px solid rgba(var(--brand-accent-rgb), 0.12);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: breathe 2s ease-in-out infinite;
}

.auth-request-icon svg { color: var(--brand-accent-light); }

.auth-request-content h3 {
    font-size: var(--text-xl);
    margin-bottom: var(--spacing-sm);
}

.auth-request-info {
    background: var(--color-surface-0);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin: var(--spacing-lg) 0;
    border: 1px solid var(--color-border-subtle);
}

.auth-info-row {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--color-border-subtle);
}

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

.auth-info-label {
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
}

.auth-info-value {
    font-weight: 500;
    font-size: var(--text-sm);
}

.auth-request-actions {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

/* ============================================
   AUTH POPUP (compact toast-style)
   ============================================ */
.auth-popup {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    z-index: 10000;
    width: calc(100% - 32px);
    max-width: 400px;
    opacity: 0;
    transition: all var(--duration-slow) var(--ease-out);
    pointer-events: none;
}

.auth-popup.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.auth-popup.hidden { display: none; }

.auth-popup-content {
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-xl), 0 0 0 1px rgba(var(--brand-accent-rgb), 0.08);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
}

.auth-popup-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.auth-popup-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(var(--brand-accent-rgb), 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.auth-popup-title { flex: 1; min-width: 0; }

.auth-popup-title strong {
    display: block;
    font-size: var(--text-base);
    color: var(--color-text);
}

.auth-popup-device {
    display: block;
    font-size: var(--text-xs);
    color: var(--brand-accent-light);
    font-weight: 500;
}

.auth-popup-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--duration-fast);
    flex-shrink: 0;
}

.auth-popup-close:hover {
    background: var(--color-surface-3);
    color: var(--color-text);
}

.auth-popup-details {
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-md);
    padding-left: 48px;
}

.auth-popup-dot { margin: 0 6px; opacity: 0.5; }

.auth-popup-actions {
    display: flex;
    gap: var(--spacing-sm);
}

.auth-popup-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: transform var(--duration-fast) var(--ease-spring), box-shadow var(--duration-normal);
}

.auth-popup-approve {
    background: var(--brand-gradient);
    color: #fff;
}

.auth-popup-approve:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-gold);
}

.auth-popup-approve:active { transform: scale(0.98); }

.auth-popup-deny {
    background: transparent;
    border: 1px solid rgba(var(--color-danger-rgb), 0.4);
    color: var(--color-danger);
}

.auth-popup-deny:hover {
    background: rgba(var(--color-danger-rgb), 0.08);
    border-color: var(--color-danger);
}

/* ============================================
   FULLSCREEN AUTH CONFIRMATION
   ============================================ */
.fullscreen-auth {
    position: fixed;
    inset: 0;
    background: var(--color-bg);
    z-index: 10001;
    display: flex;
    flex-direction: column;
}

.fullscreen-auth.hidden { display: none; }

.fullscreen-auth-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 400px;
    margin: 0 auto;
    padding: var(--spacing-lg);
    width: 100%;
}

.fullscreen-auth-header {
    padding: var(--spacing-lg) 0;
    text-align: center;
}

.fullscreen-auth-header .logo {
    font-family: var(--font-logo);
    font-size: 1.5rem;
    letter-spacing: 0.2em;
    background: var(--brand-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.fullscreen-auth-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: var(--spacing-xl) 0;
}

.fullscreen-auth-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(var(--brand-accent-rgb), 0.08);
    border: 1px solid rgba(var(--brand-accent-rgb), 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--spacing-lg);
    animation: breathe 2s ease-in-out infinite;
}

.fullscreen-auth-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 var(--spacing-sm);
    letter-spacing: -0.02em;
}

.fullscreen-auth-status {
    font-size: var(--text-base);
    color: var(--color-text-secondary);
    margin: 0 0 var(--spacing-xl);
}

.fullscreen-auth-details {
    width: 100%;
    background: var(--color-surface-1);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
}

.auth-detail-row {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--color-border-subtle);
}

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

.auth-detail-label {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}

.auth-detail-value {
    font-size: var(--text-sm);
    color: var(--color-text);
    font-weight: 500;
}

.fullscreen-auth-actions {
    padding: var(--spacing-lg) 0;
}

/* ============================================
   BIOMETRIC SETUP MODAL
   ============================================ */
.biometric-setup-content {
    text-align: center;
    padding: var(--spacing-md);
}

.biometric-icon {
    width: 96px;
    height: 96px;
    margin: 0 auto var(--spacing-lg);
    background: radial-gradient(circle, rgba(var(--brand-accent-rgb), 0.15) 0%, rgba(var(--brand-accent-rgb), 0.03) 70%);
    border: 1px solid rgba(var(--brand-accent-rgb), 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.biometric-icon svg { color: var(--color-gold); }

.biometric-setup-content h3 {
    font-size: var(--text-xl);
    margin-bottom: var(--spacing-sm);
}

.biometric-status {
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    margin: var(--spacing-lg) 0;
    font-size: var(--text-sm);
}

.biometric-status.success {
    background: rgba(var(--color-success-rgb), 0.08);
    color: var(--color-success);
}

.biometric-status.error {
    background: rgba(var(--color-danger-rgb), 0.08);
    color: var(--color-danger);
}

.biometric-note {
    font-size: var(--text-xs);
    margin-top: var(--spacing-lg);
}

/* ============================================
   TENANT CARDS
   ============================================ */
.tenants-section { margin-bottom: var(--spacing-lg); }

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-md);
    padding: 0 var(--spacing-xs);
}

.section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--color-text-muted);
}

.tenant-card {
    background: var(--color-surface-1);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-smooth);
    position: relative;
    overflow: hidden;
}

.tenant-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, var(--color-gold) 0%, rgba(var(--brand-accent-rgb), 0.2) 100%);
    opacity: 0;
    transition: opacity var(--duration-normal);
}

.tenant-card.primary::before { opacity: 1; }

.tenant-card:hover {
    border-color: var(--color-border-accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.tenant-card:hover::before { opacity: 1; }
.tenant-card:active { transform: translateY(0) scale(0.99); }

.tenant-card.guest { opacity: 0.75; }
.tenant-card.guest:hover { opacity: 1; }

.tenant-row {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.tenant-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: var(--brand-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--text-lg);
    color: #fff;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    transition: transform var(--duration-fast) var(--ease-spring);
}

.tenant-card:hover .tenant-icon { transform: scale(1.05); }

.tenant-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

.tenant-content { flex: 1; min-width: 0; }

.tenant-header-row {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    margin-bottom: 4px;
}

.tenant-name {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--color-text);
}

.tenant-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    background: rgba(var(--brand-accent-rgb), 0.12);
    color: var(--color-gold);
}

.tenant-badge.guest {
    background: rgba(255, 255, 255, 0.04);
    color: var(--color-text-muted);
}

.tenant-domain {
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    margin-bottom: 6px;
}

.tenant-status {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-success);
    box-shadow: 0 0 8px rgba(var(--color-success-rgb), 0.5);
    animation: pulseGlow 2s infinite;
}

.status-text {
    font-size: var(--text-xs);
    color: var(--color-success);
    font-weight: 500;
}

.tenant-arrow {
    color: var(--color-text-muted);
    opacity: 0.3;
    flex-shrink: 0;
    transition: all var(--duration-fast);
}

.tenant-card:hover .tenant-arrow {
    opacity: 1;
    color: var(--color-gold);
    transform: translateX(4px);
}

/* ============================================
   OTP DISPLAY
   ============================================ */
.otp-section { margin-top: var(--spacing-lg); }

.otp-card {
    background: var(--color-surface-1);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
    transition: border-color var(--duration-normal), box-shadow var(--duration-normal);
}

.otp-card:hover {
    border-color: var(--color-border-accent);
    box-shadow: var(--shadow-glow);
}

.otp-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.otp-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-gradient);
    border-radius: var(--radius-sm);
    color: #fff;
    font-weight: 700;
    font-size: var(--text-sm);
}

.otp-info { flex: 1; }
.otp-issuer { font-weight: 600; font-size: var(--text-sm); }
.otp-account { font-size: var(--text-xs); color: var(--color-text-secondary); }

.otp-code-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--color-surface-0);
    border: 1px solid var(--color-border-subtle);
    border-radius: var(--radius-sm);
    padding: var(--spacing-sm) var(--spacing-md);
}

.otp-code {
    font-family: var(--font-mono);
    font-size: var(--text-2xl);
    font-weight: 600;
    letter-spacing: 0.15em;
    color: var(--color-gold);
    cursor: pointer;
    transition: transform var(--duration-fast) var(--ease-spring), color var(--duration-fast);
}

.otp-code:hover { transform: scale(1.02); }
.otp-code.copied { color: var(--color-success); }

.otp-timer {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.otp-timer-ring {
    width: 32px;
    height: 32px;
    position: relative;
}

.otp-timer-ring svg { transform: rotate(-90deg); }

.otp-timer-ring .timer-bg {
    fill: none;
    stroke: var(--color-surface-3);
    stroke-width: 3;
}

.otp-timer-ring .timer-progress {
    fill: none;
    stroke: var(--color-gold);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 100.53;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear, stroke var(--duration-normal);
}

.otp-timer-ring .timer-progress.warning { stroke: var(--color-warning); }
.otp-timer-ring .timer-progress.danger { stroke: var(--color-danger); }

.otp-timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-text-muted);
    font-family: var(--font-mono);
}

/* ============================================
   SETTINGS PAGE
   ============================================ */
.settings-container {
    padding: var(--spacing-lg) var(--spacing-md);
    max-width: 600px;
    margin: 0 auto;
}

.settings-title {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: var(--spacing-xl);
    letter-spacing: -0.03em;
}

.settings-section { margin-bottom: var(--spacing-xl); }

.settings-section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--color-text-muted);
    margin-bottom: var(--spacing-md);
}

.settings-list {
    background: var(--color-surface-1);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.settings-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--color-border-subtle);
    width: 100%;
    cursor: pointer;
    transition: background var(--duration-fast), transform var(--duration-fast) var(--ease-spring);
    text-align: left;
    font-family: inherit;
}

.settings-item:last-child { border-bottom: none; }

.settings-item:hover { background: rgba(255, 255, 255, 0.02); }

.settings-item:active {
    background: rgba(255, 255, 255, 0.04);
    transform: scale(0.99);
}

.settings-item-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: rgba(var(--brand-accent-rgb), 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-gold);
    flex-shrink: 0;
}

.settings-item-content { flex: 1; min-width: 0; }

.settings-item-text {
    display: block;
    font-size: var(--text-base);
    font-weight: 500;
    color: var(--color-text);
    margin-bottom: 2px;
}

.settings-item-desc {
    display: block;
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
}

.settings-item-arrow {
    color: var(--color-text-muted);
    opacity: 0.3;
    flex-shrink: 0;
    transition: all var(--duration-fast);
}

.settings-item:hover .settings-item-arrow {
    opacity: 0.8;
    color: var(--color-gold);
    transform: translateX(3px);
}

/* ============================================
   ANIMATIONS — Purposeful, physics-based
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

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

@keyframes cardEntrance {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes breathe {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.04); opacity: 0.85; }
}

@keyframes pulseGlow {
    0%, 100% { opacity: 1; box-shadow: 0 0 8px rgba(var(--color-success-rgb), 0.5); }
    50% { opacity: 0.6; box-shadow: 0 0 4px rgba(var(--color-success-rgb), 0.3); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

/* Staggered card entrance */
.account-card:nth-child(1) { animation-delay: 0ms; }
.account-card:nth-child(2) { animation-delay: 50ms; }
.account-card:nth-child(3) { animation-delay: 100ms; }
.account-card:nth-child(4) { animation-delay: 150ms; }
.account-card:nth-child(5) { animation-delay: 200ms; }
.account-card:nth-child(6) { animation-delay: 250ms; }
.account-card:nth-child(7) { animation-delay: 300ms; }
.account-card:nth-child(8) { animation-delay: 350ms; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (min-width: 600px) {
    .modal-content {
        border-radius: var(--radius-xl);
        margin: auto;
    }
    
    .modal-content::before { display: none; }
    
    .modal { align-items: center; }
    
    .install-content {
        margin-inline: auto;
    }
}

@media (max-width: 480px) {
    .install-content {
        padding: 22px;
        border-radius: 24px;
    }

    .install-topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }

    .install-status {
        min-height: 28px;
        font-size: 0.62rem;
    }

    .install-content h1 {
        font-size: 1.82rem;
    }
}

/* ============================================
   UTILITIES
   ============================================ */
.hidden { display: none !important; }
.text-muted { color: var(--color-text-muted); }

body {
    background:
        radial-gradient(circle at 16% 8%, rgba(var(--brand-accent-rgb), 0.18), transparent 28rem),
        radial-gradient(circle at 84% 18%, rgba(45, 39, 105, 0.40), transparent 32rem),
        linear-gradient(135deg, #070510 0%, #141021 48%, #241E31 100%);
}

body::before {
    background:
        linear-gradient(rgba(255,255,255,0.028) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.028) 1px, transparent 1px),
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(var(--brand-accent-rgb), 0.10) 0%, transparent 60%);
    background-size: 44px 44px, 44px 44px, auto;
}

.app-header,
.modal-content,
.drawer-panel,
.account-card,
.setup-card,
.vault-card,
.settings-card {
    background: linear-gradient(145deg, rgba(255,255,255,0.09), rgba(255,255,255,0.035)), rgba(14, 11, 27, 0.86);
    border-color: rgba(255,255,255,0.12);
    box-shadow: 0 24px 80px rgba(0,0,0,0.28);
}

.logo {
    background: none;
    -webkit-text-fill-color: #fff;
    color: #fff;
    text-shadow: 0 0 30px rgba(var(--brand-accent-rgb), 0.34);
}

.logo.logo-lg {
    position: relative;
    display: inline-flex;
    width: clamp(96px, 18vw, 150px);
    height: clamp(24px, 4.2vw, 36px);
    overflow: hidden;
    background: url('../brand/mono-light-cropped.png') center / contain no-repeat;
    font-size: 0;
    filter: drop-shadow(0 18px 38px rgba(var(--brand-accent-rgb), 0.24));
}

.install-content .logo.logo-lg {
    width: auto;
    height: auto;
    background: none;
    font-size: 0.9rem;
    filter: none;
}

.btn-primary,
.account-icon,
.drawer-logo,
.fab,
.scan-region-highlight {
    color: #fff !important;
}

.btn-primary svg,
.account-icon svg,
.drawer-logo svg {
    stroke: currentColor;
}

.app-header {
    background: rgba(9, 7, 17, 0.72);
    border-bottom-color: rgba(var(--brand-accent-rgb), 0.18);
}
