/* Custom UI replacement for native alert/confirm/prompt */
#appUI-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
#appUI-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
#appUI-modal {
    background: #fff;
    width: 90%;
    max-width: 350px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
    color: #1C1C1E;
    font-family: inherit;
}
#appUI-overlay.active #appUI-modal {
    transform: scale(1);
}
#appUI-icon {
    font-size: 3rem;
    text-align: center;
    margin-top: 1.5rem;
}
#appUI-title {
    font-size: 1.25rem;
    font-weight: 800;
    text-align: center;
    margin: 0.5rem 1.5rem 0.5rem 1.5rem;
}
#appUI-message {
    font-size: 0.95rem;
    text-align: center;
    margin: 0 1.5rem 1.5rem 1.5rem;
    color: #8E8E93;
    white-space: pre-wrap;
}
#appUI-input-container {
    display: none;
    margin: 0 1.5rem 1.5rem 1.5rem;
}
#appUI-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ced4da;
    border-radius: 12px;
    font-size: 1rem;
    outline: none;
    font-family: inherit;
}
#appUI-input:focus {
    border-color: #0A2342;
}
#appUI-buttons {
    display: flex;
    border-top: 1px solid rgba(0,0,0,0.05);
}
.appUI-btn {
    flex: 1;
    padding: 1rem;
    border: none;
    background: transparent;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
}
.appUI-btn:active {
    background: rgba(0,0,0,0.05);
}
#appUI-btn-cancel {
    color: #FF3B30;
    border-right: 1px solid rgba(0,0,0,0.05);
    display: none;
}
#appUI-btn-confirm {
    color: #007AFF;
}

/* Toasts */
#appUI-toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    pointer-events: none;
}
.appUI-toast {
    background: rgba(10, 35, 66, 0.9);
    color: white;
    padding: 12px 24px;
    border-radius: 100px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s ease;
}
.appUI-toast.show {
    opacity: 1;
    transform: translateY(0);
}
.appUI-toast.error {
    background: rgba(255, 59, 48, 0.9);
}
/* =========================================
   SYSTEM BUTTONS (Unified Design)
   ========================================= */
.btn-sys-close {
    position: absolute; 
    top: 16px; 
    right: 16px;
    width: 34px; 
    height: 34px; 
    border-radius: 50%;
    background: #FF3B30; 
    color: white;
    border: none;
    box-shadow: 0 4px 10px rgba(255, 59, 48, 0.3);
    display: flex; 
    align-items: center; 
    justify-content: center;
    font-size: 14px; 
    font-weight: 800; 
    cursor: pointer;
    transition: transform 0.2s;
    z-index: 100;
}
.btn-sys-close:active { transform: scale(0.9); }

.btn-sys-block {
    width: 100%; 
    padding: 16px; 
    border-radius: 20px; 
    font-size: 16px; 
    font-weight: 800; 
    border: none;
    cursor: pointer; 
    margin-bottom: 12px;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-align: center;
    text-transform: none;
    line-height: 1.2;
    font-family: inherit;
    box-sizing: border-box;
}
.btn-sys-block:active { transform: scale(0.97); }
.btn-sys-block:last-child { margin-bottom: 0; }

.btn-sys-primary {
    background: linear-gradient(135deg, var(--primary, #0A2342) 0%, #153e75 100%);
    color: white; 
    box-shadow: 0 10px 25px rgba(10, 35, 66, 0.15);
}

.btn-sys-secondary {
    background: #E5E5EA; 
    color: var(--primary, #0A2342);
    box-shadow: none; 
}
.btn-sys-secondary:active { background: #D1D1D6; }

.btn-sys-danger {
    background: var(--danger, #FF3B30); 
    color: white;
    box-shadow: 0 10px 25px rgba(255, 59, 48, 0.25);
}

.btn-sys-accent {
    background: linear-gradient(135deg, var(--accent, #007AFF) 0%, #f39c12 100%);
    color: white; 
    box-shadow: 0 10px 25px rgba(0, 122, 255, 0.2);
}

.btn-sys-icon {
    width: 48px; 
    height: 48px; 
    border-radius: 16px;
    background: var(--primary, #0A2342); 
    color: white;
    border: none; 
    display: inline-flex; 
    align-items: center; 
    justify-content: center;
    font-size: 18px; 
    cursor: pointer; 
    box-shadow: 0 4px 15px rgba(10,35,66,0.15);
    transition: transform 0.2s;
}
.btn-sys-icon:active { transform: scale(0.9); }
