        * { margin: 0; padding: 0; box-sizing: border-box; }
        html { height: 100%; }
        body {
            height: 100%;
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            background: #f5f4f0;
            overflow-x: hidden;
        }
        
        /* Inputs - prevenir zoom no iOS */
        input, select, textarea, button {
            font-size: 16px !important;
            -webkit-appearance: none;
            touch-action: manipulation;
        }
        
        /* ===== LOADING & LOGIN ===== */
        .loading-overlay {
            position: fixed; top: 0; left: 0; right: 0; bottom: 0;
            background: linear-gradient(135deg, #1a1a2e 0%, #2d2d44 100%);
            display: flex; flex-direction: column; align-items: center; justify-content: center;
            z-index: 9999; color: white;
        }
        .loading-overlay.hidden { display: none; }
        .loading-spinner {
            width: 50px; height: 50px;
            border: 4px solid rgba(255,255,255,0.3);
            border-top-color: white;
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin-bottom: 1rem;
        }
        @keyframes spin { to { transform: rotate(360deg); } }
        
        .login-container {
            position: fixed; top: 0; left: 0; right: 0; bottom: 0;
            background: linear-gradient(135deg, #1a1a2e 0%, #2d2d44 100%);
            display: flex; align-items: center; justify-content: center;
            z-index: 9998;
        }
        .login-container.hidden { display: none; }
        .login-card {
            background: white; border-radius: 1rem; padding: 2.5rem;
            width: 90%; max-width: 480px; box-shadow: 0 20px 50px rgba(0,0,0,0.2);
        }
        .login-logo { text-align: center; margin-bottom: 2rem; display: flex; flex-direction: column; align-items: center; }
        .login-logo h1 { font-size: 1.75rem; color: #1f2937; margin-bottom: 0.25rem; }
        .login-logo span { font-size: 0.9rem; color: #6b7280; }
        .login-input {
            width: 100%; padding: 0.875rem 1rem;
            border: 1px solid #d1d5db; border-radius: 0.5rem; margin-bottom: 0;
            font-size: 1rem; transition: border-color 0.2s, box-shadow 0.2s;
        }
        .login-input:focus { outline: none; border-color: #eab308; box-shadow: 0 0 0 3px rgba(234, 179, 8, 0.15); }
        .login-input::placeholder { color: #9ca3af; }
        #login-form { display: flex; flex-direction: column; gap: 1.25rem; }
        .login-btn {
            width: 100%; padding: 0.875rem;
            background: linear-gradient(135deg, #1a1a2e 0%, #2d2d44 100%);
            color: white; border: none; border-radius: 0.5rem;
            font-weight: 600; font-size: 1rem; cursor: pointer;
            transition: background 0.2s; margin-top: 0.5rem;
        }
        .login-btn:hover { background: #eab308; color: #1a1a2e; }
        .login-btn:disabled { opacity: 0.6; }
        .login-error { color: #dc2626; font-size: 0.8rem; margin-top: 1rem; text-align: center; }
        .login-tab {
            flex: 1; padding: 0.875rem 1.5rem; border: none;
            background: #f5f4f0; cursor: pointer; border-radius: 0.5rem;
            font-weight: 600; font-size: 1rem; color: #6b7280;
            transition: all 0.2s;
        }
        .login-tab:hover { background: #e5e7eb; }
        .login-tab.active { background: linear-gradient(135deg, #eab308, #ca9a06); color: white; }
        #register-form { display: none; flex-direction: column; gap: 1.25rem; }
        
        /* ===== APP CONTAINER ===== */
        .app-container { display: none; height: 100%; flex-direction: column; }
        .app-container.active { display: flex; }
        
        /* ===== HEADER ===== */
        .header {
            background: linear-gradient(135deg, #1a1a2e 0%, #2d2d44 100%);
            color: white; padding: 1rem;
            position: sticky; top: 0; z-index: 100;
        }
        .header-top { display: flex; justify-content: space-between; align-items: center; }
        .header h1 { font-size: 1.1rem; font-weight: 700; }
        .header-actions { display: flex; gap: 0.5rem; }
        .header-btn {
            background: rgba(255,255,255,0.2); border: none; color: white;
            padding: 0.4rem 0.6rem; border-radius: 0.5rem; cursor: pointer; font-size: 0.8rem;
        }
        
        /* ===== CONTENT ===== */
        .content { flex: 1; overflow-y: auto; padding: 1rem; }
        
        /* ===== CARDS ===== */
        .card {
            background: white; border-radius: 0.75rem; padding: 1rem;
            margin-bottom: 0.75rem; box-shadow: 0 2px 6px rgba(0,0,0,0.06);
        }
        .card-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.5rem; color: #1f2937; }
        
        /* ===== FORM ===== */
        .form-section { margin-bottom: 1.5rem; }
        .section-title {
            font-size: 0.8rem; font-weight: 600; color: #6b7280;
            margin-bottom: 0.75rem; display: flex; align-items: center; gap: 0.5rem;
        }
        .form-row { display: flex; gap: 0.75rem; margin-bottom: 0.75rem; }
        .form-group { flex: 1; }
        .form-label { font-size: 0.7rem; font-weight: 500; color: #6b7280; margin-bottom: 0.25rem; display: block; }
        .form-input, .form-select {
            width: 100%; padding: 0.625rem 0.75rem;
            border: 1px solid #d1d5db; border-radius: 0.5rem; background: white;
        }
        .form-input:focus, .form-select:focus { outline: none; border-color: #eab308; }
        .form-input.readonly { background: #f5f4f0; }
        
        /* ===== BUTTONS ===== */
        .btn {
            padding: 0.75rem 1rem; border-radius: 0.5rem; font-weight: 600;
            cursor: pointer; border: none; font-size: 0.9rem;
            display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
        }
        .btn-primary { background: #eab308; color: #1a1a2e; font-weight: 600; }
        .btn-success { background: #eab308; color: #1a1a2e; font-weight: 600; }
        .btn-secondary { background: #6b7280; color: white; }
        .btn-danger { background: #dc2626; color: white; }
        .btn-block { width: 100%; }
        .btn-sm { padding: 0.5rem 0.75rem; font-size: 0.8rem; }
        
        /* ===== LISTA PEDIDOS ===== */
        .pedido-card {
            background: white; border-radius: 0.75rem; padding: 1rem;
            margin-bottom: 0.75rem; box-shadow: 0 2px 6px rgba(0,0,0,0.06);
            border-left: 4px solid #eab308; cursor: pointer;
        }
        .pedido-card:active { transform: scale(0.99); }
        .pedido-numero { font-weight: 700; color: #1a1a2e; font-size: 0.95rem; }
        .pedido-cliente { font-size: 0.85rem; color: #374151; margin-top: 0.25rem; }
        .pedido-meta { font-size: 0.75rem; color: #6b7280; margin-top: 0.25rem; display: flex; gap: 1rem; }
        .pedido-estado {
            display: inline-block; padding: 0.25rem 0.5rem; border-radius: 0.25rem;
            font-size: 0.7rem; font-weight: 600;
        }
        .estado-rascunho { background: #fef3c7; color: #92400e; }
        .estado-negociacao { background: #fef3c7; color: #1a1a2e; }
        .estado-aprovado { background: #fef3c7; color: #1a1a2e; }
        
        /* ===== CLIENTE CARD ===== */
        .cliente-card {
            background: white; border-radius: 0.5rem; padding: 0.75rem;
            margin-bottom: 0.5rem; cursor: pointer; border: 2px solid transparent;
        }
        .cliente-card:active { transform: scale(0.99); }
        .cliente-card.selected { border-color: #eab308; background: #fffbeb; }
        .cliente-nome { font-weight: 600; font-size: 0.9rem; }
        .cliente-nif { font-size: 0.75rem; color: #6b7280; }
        
        /* ===== CONTACTO CARD ===== */
        .contacto-option { padding: 0.5rem; border-bottom: 1px solid #f3f4f6; cursor: pointer; }
        .contacto-option:hover { background: #f5f4f0; }
        .contacto-option:last-child { border-bottom: none; }
        
        /* ===== LINHAS PEDIDO ===== */
        .linha-card {
            background: #f9fafb; border-radius: 0.5rem; padding: 0.75rem;
            margin-bottom: 0.5rem; border: 1px solid #e5e7eb;
        }
        .linha-header { display: flex; justify-content: space-between; align-items: flex-start; }
        .linha-descricao { font-weight: 600; font-size: 0.85rem; flex: 1; }
        .linha-subtotal { font-weight: 700; color: #eab308; font-size: 0.9rem; }
        .linha-detalhes { font-size: 0.75rem; color: #6b7280; margin-top: 0.25rem; }
        .linha-acoes { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
        .linha-btn {
            padding: 0.25rem 0.5rem; border-radius: 0.25rem; border: none;
            font-size: 0.7rem; cursor: pointer;
        }
        .linha-btn-edit { background: #fef3c7; color: #1a1a2e; }
        .linha-btn-delete { background: #fee2e2; color: #dc2626; }
        
        /* ===== TOTAIS ===== */
        .totais-card {
            background: linear-gradient(135deg, #1a1a2e 0%, #2d2d44 100%);
            color: white; border-radius: 0.75rem; padding: 1rem; margin-top: 1rem;
        }
        .total-row { display: flex; justify-content: space-between; padding: 0.25rem 0; }
        .total-row.final { font-size: 1.1rem; font-weight: 700; border-top: 2px solid rgba(255,255,255,0.3); padding-top: 0.5rem; margin-top: 0.25rem; }
        
        /* ===== MODAL ===== */
        .modal-overlay {
            position: fixed; top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0,0,0,0.5); display: flex; align-items: flex-end;
            z-index: 1000; opacity: 0; visibility: hidden; transition: all 0.3s;
        }
        .modal-overlay.active { opacity: 1; visibility: visible; }
        .modal-content {
            background: white; width: 100%; max-height: 90vh;
            border-radius: 1.5rem 1.5rem 0 0; overflow-y: auto;
            transform: translateY(100%); transition: transform 0.3s;
        }
        .modal-overlay.active .modal-content { transform: translateY(0); }
        .modal-header {
            position: sticky; top: 0; background: white;
            padding: 1rem; border-bottom: 1px solid #e5e7eb;
            display: flex; justify-content: space-between; align-items: center;
        }
        .modal-title { font-weight: 600; }
        .modal-close {
            background: #f5f4f0; border: none; width: 2rem; height: 2rem;
            border-radius: 50%; cursor: pointer; font-size: 1.1rem;
        }
        .modal-body { padding: 1rem; }
        
        /* ===== PREÇOS GRID ===== */
        .precos-grid { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
        .preco-btn {
            padding: 0.5rem 0.75rem; border-radius: 0.5rem;
            background: #f5f4f0; border: 2px solid transparent;
            cursor: pointer; text-align: center; min-width: 70px;
        }
        .preco-btn:active { transform: scale(0.95); }
        .preco-btn.selected { border-color: #eab308; background: #fef3c7; }
        .preco-label { font-size: 0.65rem; color: #6b7280; }
        .preco-valor { font-weight: 700; font-size: 0.85rem; }
        
        /* ===== EXPORT BUTTONS ===== */
        .export-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; margin-top: 1rem; }
        .export-btn { padding: 0.75rem; border-radius: 0.5rem; text-align: center; color: white; font-weight: 600; cursor: pointer; border: none; }
        .export-btn.whatsapp { background: #25d366; }
        .export-btn.email { background: #ea4335; }
        .export-btn.copy { background: #64748b; }
        .export-btn.save { background: #2563eb; }
        
        /* Bottom Sheet */
        .bottom-sheet-overlay {
            position: fixed; top: 0; left: 0; right: 0; bottom: 0;
            background: rgba(0,0,0,0.5); z-index: 9000;
            opacity: 0; visibility: hidden;
            transition: opacity 0.3s ease, visibility 0.3s ease;
        }
        .bottom-sheet-overlay.active { opacity: 1; visibility: visible; }
        .bottom-sheet {
            position: fixed; left: 0; right: 0; bottom: 0;
            background: white; border-radius: 1.25rem 1.25rem 0 0;
            padding: 0; z-index: 9001;
            transform: translateY(100%);
            transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
            max-width: 480px; margin: 0 auto;
            box-shadow: 0 -10px 40px rgba(0,0,0,0.15);
        }
        .bottom-sheet.active { transform: translateY(0); }
        .bottom-sheet-handle {
            width: 36px; height: 4px; background: #d1d5db;
            border-radius: 2px; margin: 0.75rem auto;
        }
        .bottom-sheet-title {
            text-align: center; font-weight: 700; font-size: 1rem;
            color: #1f2937; padding: 0 1.5rem 0.75rem;
        }
        .bottom-sheet-subtitle {
            text-align: center; font-size: 0.8rem; color: #6b7280;
            padding: 0 1.5rem 1rem;
        }
        .share-options {
            display: flex; justify-content: center; gap: 1.5rem;
            padding: 0.5rem 1.5rem 1.5rem;
        }
        .share-option {
            display: flex; flex-direction: column; align-items: center;
            gap: 0.5rem; cursor: pointer; border: none; background: none;
            -webkit-tap-highlight-color: transparent;
        }
        .share-option:active .share-icon { transform: scale(0.9); }
        .share-icon {
            width: 56px; height: 56px; border-radius: 50%;
            display: flex; align-items: center; justify-content: center;
            font-size: 1.5rem; transition: transform 0.15s ease;
        }
        .share-icon.whatsapp { background: #25d366; }
        .share-icon.email { background: #ea4335; }
        .share-icon.copy { background: #64748b; }
        .share-label { font-size: 0.75rem; color: #374151; font-weight: 500; }
        .bottom-sheet-actions {
            padding: 0 1.5rem 1.5rem;
            padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
        }
        .bottom-sheet-close {
            width: 100%; padding: 0.875rem; border: none;
            background: #f5f4f0; border-radius: 0.75rem;
            font-weight: 600; font-size: 0.9rem; color: #374151;
            cursor: pointer; transition: background 0.2s;
        }
        .bottom-sheet-close:active { background: #e5e7eb; }
        
        /* ===== TOAST ===== */
        .toast {
            position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%) translateY(100px);
            background: #1f2937; color: white; padding: 0.875rem 1.5rem;
            border-radius: 0.75rem; z-index: 2000; opacity: 0; transition: all 0.3s;
        }
        .toast.active { transform: translateX(-50%) translateY(0); opacity: 1; }
        .toast.success { background: #eab308; color: #1a1a2e; }
        .toast.error { background: #dc2626; }
        
        /* ===== TABS ===== */
        .tabs { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
        .tab {
            flex: 1; padding: 0.6rem 0.25rem; border: 2px solid #e5e7eb; border-radius: 0.5rem;
            background: white; font-weight: 600; cursor: pointer; text-align: center; font-size: 0.72rem;
        }
        .tab.active { border-color: #eab308; background: #fef3c7; color: #1a1a2e; }
        
        /* ===== EMPTY STATE ===== */
        .empty-state { text-align: center; padding: 2rem; color: #9ca3af; }
        .empty-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
        
        /* ===== SEARCH ===== */
        .search-box {
            position: relative;
            display: flex; align-items: center; background: white;
            border: 1px solid #e5e7eb; border-radius: 0.75rem; padding: 0.5rem 0.75rem;
            margin-bottom: 1rem;
        }
        .search-icon { color: #9ca3af; margin-right: 0.5rem; }
        .search-input { flex: 1; border: none; background: transparent; outline: none; padding-right: 1.5rem; }
        
        .hidden { display: none !important; }
        /* Install Banner */
        .install-banner {
            display: none;
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            background: linear-gradient(135deg, #1f2937, #111827);
            color: white;
            padding: 1rem;
            z-index: 10000;
            box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
            animation: slideUp 0.4s ease;
        }
        .install-banner.show { display: block; }
        @keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
        .install-banner-content {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            max-width: 600px;
            margin: 0 auto;
        }
        .install-banner img { width: 48px; height: 48px; border-radius: 0.5rem; }
        .install-banner-text { flex: 1; }
        .install-banner-text h4 { margin: 0; font-size: 0.9rem; font-weight: 700; }
        .install-banner-text p { margin: 0.15rem 0 0; font-size: 0.7rem; opacity: 0.7; }
        .install-btn { background: #f59e0b; color: #111; border: none; padding: 0.6rem 1.25rem; border-radius: 0.5rem; font-weight: 700; font-size: 0.85rem; cursor: pointer; white-space: nowrap; }
        .install-dismiss { background: none; border: none; color: #9ca3af; font-size: 1.2rem; cursor: pointer; padding: 0.25rem; }
